Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Business Format

John_Campbell
New Contributor II
540 Views
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) . John
0 Kudos
2 Replies
Arjen_Markus
Honored Contributor I
540 Views

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)

Regards,

Arjen

0 Kudos
Steven_L_Intel1
Employee
540 Views

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,

0 Kudos
Reply