- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is my code and the name of the file is comp.f:
program comp
complex :: x
x=(6.3,1.0)
print*,x
end program comp
If I compile it with ifort "ifort comp.f", when I run it "./a.out", this is the output:
(6.300000,1.000000)
If I compile it with gfortran "gfortran comp.f", when I run it "./a.out", this is the output:
( 6.30000019 , 1.00000000 )
I need an "ifort"like output. Because I am working in some remote computer, I am forced to use gfortran. But the output is problematic because afterwards I need to read in the output in "Wolfram Mathematica"...so,
Is there anyway that I can get the output I would get with ifort, but using gfortran?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is an example. For the purposes of writing in a format that you desire, it would be good for you to read the chapters on I/O formatting in a Fortran manual or book.
program comp complex :: x x=(6.3,1.0) write(*,10) x 10 format(1x,'(',F0.6,',',F0.6,')') end program comp
This program gives the same output with GFortran and IFort.
(6.300000,1.000000)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want the output formatted in a particular manner, you should specify the appropriate format instead of using list-directed output. Secondly, note that when you are using 32-bit floats, 6.30000019 and 6.300000 are identical, with the internal representation Z'40C9999A'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks mecej4,
yes I supposed I needed to format that, but I have not been able find how to skip those blanks I get compiling it with gfortran. The book I follow for fortran programing is "Fortran 95 Using F" by Walter S. Brainerd, Charles H. Goldberg and Jeanne C. Adams. If it is a trivial thing for experienced programmers, could you tell me what would be the formatting way to skip those blanks and get an "ifort"like output?
P.D.: yes know thanks, but I usually use double precission.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is an example. For the purposes of writing in a format that you desire, it would be good for you to read the chapters on I/O formatting in a Fortran manual or book.
program comp complex :: x x=(6.3,1.0) write(*,10) x 10 format(1x,'(',F0.6,',',F0.6,')') end program comp
This program gives the same output with GFortran and IFort.
(6.300000,1.000000)

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page