- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have fortran program that is running on IBM AIX OS, which are written by Fortran77 format. And we are developing them with Visual Studio 2019 to run the program on Windows OS. But we are having a problem using WRITE statement. It works different behavior between on IBM AIX and on Windows10. We'll show some examples below.
Please let me know how to change default list-directed format of WRITE statement.
(a)
Code:
write(6, *) A
Result:
On AIX, we get " 216".
But, on Windows, we get " 216"
(b)
Code:
write(6, E10.4) A
Result:
On AIX, we get " .8435E+07".
But, on Windows, we get "0.8435E+07"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You cannot do that: list-directed output does not provide any way of controlling the details. That is precisely the reason fr using it: you want the output without fuss and want it in some convenient way, as appropriate for the variables. But with that you relinquish all control that you have with explicit formats.
The only solution is to use explicit formats, because they provide almost all control options that you want.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You cannot do that: list-directed output does not provide any way of controlling the details. That is precisely the reason fr using it: you want the output without fuss and want it in some convenient way, as appropriate for the variables. But with that you relinquish all control that you have with explicit formats.
The only solution is to use explicit formats, because they provide almost all control options that you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply! I'll try another way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Arjen is correct in that the Fortran standard leaves a lot up to the implementation for list-directed formatting, but there is a solution now for the first case and in the future for the second.
For the first case, where the Intel compiler adds more than one space for integers, add the compiler option "-assume noold_ldout_format". You can also use -standard-semantics that includes this option. Example (from Windows):
D:\Projects>type t.f90
implicit none
integer :: a
a = 216
write (*,*) a
end
D:\Projects>ifx /nologo t.f90
D:\Projects>t.exe
216
D:\Projects>ifx /nologo /assume:noold_ldout_format t.f90
D:\Projects>t.exe
216
For the second case, Fortran 2018 makes the leading zero optional for D, E, F and G formats - some compilers put it in, some don't. Fortran 2023, the next standard revision (to be published later this year), gives you control over this with a new LEADING_ZERO= keyword in the OPEN statement (as well as three new format edit descriptors.) In the future, when this feature gets implemented, you would be able to open your output file with LEADING_ZERO='SUPPRESS' and have the zero omitted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler option "-assume noold_ldout_format" works, and I can get what I want about case (a)! Thank you very much!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page