- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following program is working fine in UNIX where as printing ****** in windows. Please let me know what is wrong with write(STRING1,I9) 12.35 statement
program fortrantest
CHARACTER*9 CLOCK1
write (CLOCK1,'(I9)')12.35
write(*,*)"REDDYO - ",CLOCK1
end program fortrantest
Thanks
Chandra.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following program is working fine in UNIX where as printing ****** in windows. Please let me know what is wrong with write(STRING1,I9) 12.35 statement
program fortrantest
CHARACTER*9 CLOCK1
write (CLOCK1,'(I9)')12.35
write(*,*)"REDDYO - ",CLOCK1
end program fortrantest
Thanks
Chandra.
You have an argument mis-match between your format string (I9) = integer width of 9, and 12.35 which is either real(4) or real(8). Make a change to make the two consistent (both integer or both float).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
program main
CHARACTER*9 CLOCK1
real x
x=12.35
write (CLOCK1,'(f5.2)') x
write(*,*) "REDDYO - ", CLOCK1
end program
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Others have pointed out that there is a mismatch between your data and your format. Since this is an error, compilers are free torespond however they like. I've seen three distinct behaviors from various compilers for this particular error:
1. Crap out with error message
2.Truncate the real to an integer, print the integer, and keep going
3. Act as if the real variable was equivalenced to an integer, and attempt to print the integer version of what is in the memory location. This is likely to get you *****'s because the integer version is often a very large number. I suspect in these cases this is an "argument association" type of equivalence where a call to the run-time library for formatted output is passing the real variable's address to a routine that is expecting an integer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Fortran does #3 by default. To have it give an error message, add the option /check:fornat
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page