Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

FORMAT statement question.

Please help me understand the difference between format statements 102 and 103 below.  I thought format statement 102 had an unnecessary extra set of parentheses, but not true.  The added parentheses significantly change the interpretation of the two format statements.  (Format 102 is printing in the format I desire.)  Please help me understand how the added parentheses in 102 are working to change the meaning of the format.

 

 write (intOutFile, 102) (i, dblNodeStaArray(i), dblSpanFraArray(i), dblNodeDepthArray(i), dblNodeTopRefArray(i), i = 1, intNumNodes)

102     format ((i6, 1x, 4(2x, f15.3)))

     1             0.000            1.000           93.000           10.000

     2            27.000            1.010           93.000           10.000

     3            54.000            1.020           93.000           10.000

     4            81.000            1.030           93.000           10.000

 

 write (intOutFile, 103) (i, dblNodeStaArray(i), dblSpanFraArray(i), dblNodeDepthArray(i), dblNodeTopRefArray(i), i = 1, intNumNodes)

103     format (i6, 1x, 4(2x, f15.3))

     1             0.000            1.000           93.000           10.000

            0.000           27.000            1.010           93.000

           10.000            0.000           54.000            1.020

           93.000           10.000            0.000           81.000

            1.030           93.000           10.000            0.000

 

 

  

Robert A Magliola
0 Kudos
3 Replies
Highlighted
Black Belt
1 View

See Dr. Fortran's article,

See Dr. Fortran's article, https://software.intel.com/en-us/blogs/2009/07/01/doctor-fortran-in-revert-revert-the-end-of-the-format-is-nigh , and note this excerpt from Clive Page's "Professional Programmer's Guide to Fortran 77", http://www.star.le.ac.uk/~cgp/prof77.html (near the end of section 10.9) :

If the format list is exhausted when there are still more items in the data-transfer list then forced reversion occurs: the file is positioned at the beginning of the next record and the format list is scanned again, starting at the left-parenthesis matching the last preceding right-parenthesis. If this is preceded by a repeat-count then this count is re-used. If there is no preceding right-parenthesis then the whole format is re-used. 

0 Kudos
Highlighted
Beginner
1 View

Thank you very much for the

Thank you very much for the quick and clear response and the links to the references.

Robert A Magliola
0 Kudos
Highlighted
Black Belt
1 View

Something else about those

Something else about those two format specifications may be worth noting. The use of F15.3 hides something quite serious. The values printed for i, i=2,4 are all 0.000. You may wish to see what gets printed if you were to replace F15.3 by, say, E15.3. Small integers, interpreted as reals, are seen as denormalized numbers, i.e., reals that are less than TINY(1e0)

0 Kudos