I am getting runtime error in the following statement:
where filenum5 = 95146
if I use the same statement to wite to display useing the following statement:
I am getting the following:
1.000000000000000E-003 -5.169878828456423E-026 5.298296723730590E-004
Or, with formatting
0.0010 -0.000000 0.000530 0.000640
if I make output to another constant output file unit like
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?
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.
See if you can add IOMSG specifier to the WRITE statement and examine what message the compiler gives you re: the run-time error:
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.
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.
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.)
>> 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.
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.
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.