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

leading zero in 3(G) format, there or not

Brian_Murphy
New Contributor II
604 Views

I'm writing floating point data to a text file with a (G) format and for a number like 0.12345 the presence of a leading zero depends on whether I'm running the program from a DOS command line or running it from inside the visual studio debugger.  Is this supposed to happen?

0 Kudos
8 Replies
Steven_L_Intel1
Employee
604 Views

No, and I think you're not properly explaining what you are seeing.  Small but complete code example, please, with sample output in both cases.

0 Kudos
Brian_Murphy
New Contributor II
604 Views
WRITE(90,'(3(G))') xi2, xi*30.D0/DPI, xi/2.D0/DPI This produces: 0.9251200198775795 588.6800268942104 9.811333781570173 with or without the leading zero on the first value depending on whether I'm running from the debugger or in a dos window. Unit 90 is an open text file.
0 Kudos
mecej4
Honored Contributor III
604 Views

Depending on the attributes used to OPEN the file and compiler options such as /vms, ASA carriage control may be in play. That would explain why a leading '0' character would cause the program to output a blank line followed by the rest of the record.

Is xi2 computable from xi?

0 Kudos
Steven_L_Intel1
Employee
604 Views

Please show a complete program and also show the compile options used. I would also discourage you from using "G" with no width as that is non-standard. You could use G0, maybe with a 1X after the G0. Are you running the same executable in both environments or recompiling? Show options in both cases.

Fortran carriage control is not on by default, but Intel Fortran generally doesn't add a leading zero when F format is in effect. Maybe you're running an executable built by some other compiler?

0 Kudos
Brian_Murphy
New Contributor II
604 Views
I replied with more information, but the forum lost my post. Or did it? I seem to have a lot of trouble with this.
0 Kudos
Steven_L_Intel1
Employee
604 Views

It's possible the post got held for moderation - we're working to improve that. Use "Send Author A Message" to send it to me if you want,

0 Kudos
Brian_Murphy
New Contributor II
604 Views
I see now I could have been a little more explicit. The leading zero that I'm talking about is in front of the decimal point of 0.123, not at the start of the line. This is not a big deal. I was mostly surprised to see the program producing different output inside and outside the debugger.
0 Kudos
Steven_L_Intel1
Employee
604 Views

I'm still looking for a test case I can build and run myself. There should not be a difference.

0 Kudos
Reply