#
Fortran Wiki

Edit descriptors

Overview | Integer | Real

## Overview

Conventions:

`w`

- the number of characters to use
`m`

- the minimum number of characters to be used
`d`

- the number of digits to the right of the decimal point
`e`

- the number of digits in the exponent

Data Type |
Edit Descriptors |

`integer` |
`Iw` |
`Iw.m` |

`real` |
Decimal form |
`Fw.d` |

Exponential form |
`Ew.d` |
`Ew.dEe` |

Scientific form |
`ESw.d` |
`ESw.dEe` |

Engineering form |
`ENw.d` |
`ENw.dEe` |

`logical` |
`Lw` |

`character` |
`A` |
`Aw` |

Positioning |
Horizontal |
`nX` |

Tabbing |
`Tc` |
`TLc` , `TRc` |

Vertical |
`/` |

Others |
Grouping |
`r(....)` |

Format Scanning Control |
`:` |

Sign Control |
`S` , `SP` , `SS` |

Blank Control |
`BN` , `BZ` |

Fortran edit descriptors

## Integer Editing

Integer values may be formatted using the `i`

edit descriptor which has two forms: ‘iw’ and ‘iw.m’. In the first form, `w`

specifies the width and in the second, `m`

specifies the minimum number of digits to output. For example, the integer 37 printed using the edit descriptor ‘i5’ will appear as `bbb37`

and when printed using `i5.3`

it will appear as `bb037`

(where `b`

denotes a blank).

## Real Editing

The `F`

, `E`

, `EN`

, `ES`

, `D`

, and `G`

edit descriptors are used for editing real and complex items, with two such descriptors being required for each complex item. For input, all of the six descriptors are equivalent. For output, the `E`

, `EN`

, and `ES`

descriptors produce both decimal and exponent parts. They differ in the number of digits written to the left of the decimal with `E`

writing none, `ES`

(scientific) writes one, and `EN`

(engineering) writing one to three, such that the exponent is divisible by three. The `F`

descriptor, on the other hand, writes a fixed number of digits without an exponent field. `D`

is interchangeable with `E`

. `G`

will automatically choose between `F`

and `E`

.

## Minimal field width editing

In Fortran 95 and later, the `I`

, `F`

, `B`

, `O`

, and `Z`

edit descriptors may be specified with a width of zero in order to use as little space as possible. This will prevent leading blank space before numbers, but it will also protect against overflow caused by a field width that is too narrow (which normally results in a string of asterisks being printed).

Revised on September 13, 2010 16:12:21
by

Jason Blevins
(128.146.137.198)
(3556 characters / 1.0 pages)