Business Format

Business Format

Some fortran compilers provide a non-standard business format, where numbers can be formatted to identify ,000 and for $1,230.00.
This is especially convenient when writing large numbers.
This is an output format only and does not conflict with , used as an input delimiter.
Does ifort provide for this formatting capability for both real and integer values ?
An example format is:
write (lu,9001) ' Testing array size =',m_i4, mb, iostat
9001 format (a, b'zz,zzz,zzz,zz#', 3x, b'zzz,zz#.##', ' mb : error code ', i0)

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The problem with non-standard formats like that is, that they are, well, non-standard. The specific format code would probably different from compiler to compiler and possibly even vary between compiler versions.

The simplest and most robust solution is to create a formatting function yourself that does this:

character(len=20) :: business_number

integer :: number

business_number = business_format( number )

This should not be too hard to do - just write the number to a string, using an internal write and then insert commas in the right place

(Note that there is standard support for decimal points versus commas)



Just to close on this - no, Intel Fortran does not support a "business" format edit descriptor. Arjen makes a good suggestion. In general I recommend avoiding non-standard features whenever possible,

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today