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

Wildcard Format Write

Nick2
New Contributor I
904 Views
I have a question about code that looks like this:

WRITE (IFIL,*) XOUT, (PLTVAL(J,I),J=1,IPTS)

XOUT and PLTVAL are either double or single precision values.

In one instance, I get a line that looks like this:


0.000000000000000E+000 128930.930924782 354.774066602473 330.477857203495 9275.40669654240 2453231.04053296 -3.88026220562964


In another instance (different project), I get a bunch of lines that look like this:


0.000000000000000E+000 64805.3993318746 0.000000000000000E+000

0.000000000000000E+000 11541.8275238493 1721980668.39294

575.247120749910 6.55100000000000 0.000000000000000E+000

0.000000000000000E+000 15572516.7609353 300.000000000000


So, which one is correct, and why the difference?


In single precision I get output that looks like this:

0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00

0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00

0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00

0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00

0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00


Seems consistent with the second example in double-precision


Thanks!

0 Kudos
3 Replies
Steven_L_Intel1
Employee
904 Views
You are using list-directed formatting. This leaves the choice of formatting largely up to the implementation and you have no control of the presentation. List-directed uses different formats depending on the magnitude of the value. Also, the choice of when to start a new line is implementation-dependent.

If the format matters to you, use an explicit format.
0 Kudos
mecej4
Honored Contributor III
904 Views
This is a side comment: It is misleading/confusing to call '*' a "wildcard" when used as a unit specifier in a Fortran program. The asterisk is/was used for several purposes in Fortran. Examples, some involving obsolete/deprecated usage:

REAL*4
CHARACTER*8 STR(*)
call sub(a,b,c,*2,*3) (alternate return)

In none of these cases does the asterisk have the same meaning as in regular expressions.
0 Kudos
Arjen_Markus
Honored Contributor II
904 Views
In fixed form source it is also an alternative to C in the first column (comment) and
you can also use it as any ordinary character for line continuation in the sixth column.

And there are many more uses.

Regards,

Arjen
0 Kudos
Reply