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

identify write statement error

HAl-S
New Contributor I
437 Views

I am getting runtime error in the following statement:

write(filenum5,'(F10.4,3F12.6)') time1,GN_omegaXs(i),GN_omegaYs(i),GN_omegaZs(i)

where filenum5 = 95146

if I use the same statement to wite to display useing the following statement:

write(*,*) time1,GN_omegaXs(i),GN_omegaYs(i),GN_omegaZs(i)

I am getting the following:

  1.000000000000000E-003 -5.169878828456423E-026  5.298296723730590E-004
  6.395912741480726E-004

Or, with formatting

write(*,'(F10.4,3F12.6)') time1,GN_omegaXs(i),GN_omegaYs(i),GN_omegaZs(i)

    0.0010   -0.000000    0.000530    0.000640

if I make output to another constant output file unit like

write(11111,'(F10.4,3F12.6)') time1,GN_omegaXs(i),GN_omegaYs(i),GN_omegaZs(i)

there is no error happens

if I use the iostat=k in the write statement, the value of k=30

 

Any idea of what is happening? or suggestion?

Thanks

 

0 Kudos
8 Replies
jimdempseyatthecove
Honored Contributor III
437 Views

What is the version number of your Fortran compiler?

Some of the earlier versions of Fortran had limitations on the values you can use for unit numbers. It appears yours has a 16 bit limitation

95146 = 1 0111 0011 1010 1010 = 17 bits
11111 = 0 0010 1011 0110 0111 = 14 bits

limit your unit numbers to 15 bits (.le. 32767) and you should be ok.

The V17 (and possibly V18) Compiler Limits does not state current limits for I/O unit numbers.

Jim Dempsey

0 Kudos
FortranFan
Honored Contributor II
437 Views

See if you can add IOMSG specifier to the WRITE statement and examine what message the compiler gives you re: the run-time error:

https://software.intel.com/en-us/fortran-compiler-18.0-developer-guide-and-reference-i/o-message-specifier-iomsg

0 Kudos
HAl-S
New Contributor I
437 Views

Thanks for your help

I do not know exactly the compiler version. I am working on super computer in the Department. 

However I found the following runtime issue on the compiler v16.0, but I cannot understand the issue exactly.

30

severe (30): Open failure

FOR$IOS_OPEFAI. An error was detected by the Intel® Fortran RTL I/O system while attempting to open a file in an OPENINQUIRE, or other I/O statement. This message is issued when the error condition is not one of the more common conditions for which specific error messages are provided. It can occur when an OPEN operation was attempted for one of the following:

  • Segmented file that was not on a disk or a raw magnetic tape

  • Standard I/O file that had been closed

0 Kudos
HAl-S
New Contributor I
437 Views

Also, for the size allwaed in the unit, I do not think this is the issue as I have a longer units (e.g. 3201000000) on the other parts of the code and they works well without problems.

0 Kudos
Steve_Lionel
Honored Contributor III
437 Views

Did you declare filenum as integer?  Please show us a short but complete example, and also tell us what the error message is (full and exact text). Otherwise you have all of us guessing.

There are no 16-bit unit number limitations in any version of Intel Fortran (at least since version 8.)

0 Kudos
jimdempseyatthecove
Honored Contributor III
437 Views

>>  I do not think this is the issue as I have a longer units (e.g. 3201000000)

If an internal number for I/O unit number is 16-bits, the above number becomes

0110 0010 0100 0000 (25152)

The fact that you have used the number without error, may mean, you had no other unit open who's value resolved the 16-bit value of 25152.

As a test, with your version of Fortran, open a File on unit 10, and then (without closing that file) open a file on unit 65536+10. If there be an internal use of 16-bit unit number then these two files will have a collision of unit numbers and you will get an appropriate error message.

also>> 3201000000

that number resolves to a 32-bit negative number. IOW an invalid unit number. As to why no error, if that number is truncated to 16 bits, it becomes a positive 16-bit number.

Jim Dempsey

0 Kudos
Steve_Lionel
Honored Contributor III
437 Views

Unless there's a bug somewhere, Intel Fortran supports unit numbers up to 2147483643.

0 Kudos
HAl-S
New Contributor I
437 Views

Hello Steve and Jim:

I am very thanks for your comments; 

I figured out what is the issue:

In this subroutine, this Write-statement is inside a Do-loop of range 1~160. I discovered that there is a limit on the number of opened files at a time. Therefore, I tried to close the files at each end of the Do-loop; then, while want to rewrite on the same file in the next loop index, I open these files with position='Append', make the write actions, then close again; and so on to the end of Do-loop.

With this, I can finally overcome this runtime error after a lot of diagnosing processes.

 

I am very thanks for all your recommendations.

 

0 Kudos
Reply