Can anyone help me to understand what is a back storage file in FORTRAN to which I write statements with unit 3 like
write(3) my_number
my_number may eb some integer/real
I am trying to underatns an old piece of code that has such statements
Welcome to our forums
Can anyone help me to understand what is a back storage file in FORTRAN to which I write statements with unit 3 like
write(3) my_number
my_number may eb some integer/real
I am trying to underatns an old piece of code that has such statements
Also: I do not find where the file is opened.
My question is where is this getting written into?
There must be a file opened on unit 3 that is an unformatted file. Some compilers will open a default named file, other compilers will give an error that the file is not opened. Is it your program, or are you just providing a subroutine ? You might not see the code that opens the file.
John
With FTN95 you get a run time error...
Error 94, in file ... Unit has neither been OPENed nor preconnected.
If you don't get this error report then I guess there must be an OPEN statement somewhere in your code.
I'm not getting a runtime error. I will be trying with FTN 95 only next week.
All this old code needs to work with FTN 95 finally
I have a 2011 version of FORTRAN intel compiler and it works with that.
Is it compiler dependent?
Also, I noticed that the data is read correctly :
integer rn,a,b
integer itype, w, h
mbck=3
rn=1
a=4
b=7
write(mbck) rn,a,b
rewind mbck
read(mbck) itype, w, h
close(mbck)
I see that there is a file named fort3 at the location my project folder structure exists.
But the characters written inside the are unreadable (I opened the file in wordpad) the characters appear like below
Is this a binary file?
The good old DEC VAX Fortran compiler used to automatically open a file if there was no explicit OPEN statement, i.e. FORT003.DAT in that case. This was a 'get-around' for old code derived from batch machines where the OPEN statement within the Fortran language did not exist and the files were assigned as part of the batch commands.
Paul is right, you should insert an OPEN statement at the appropriate point, and probably a CLOSE statement as well.
Yes the data is binary with record length information at the start and end of each record. The length information is compiler dependent and has been discussed at length in this forum. Do not expect an unformatted file from another compiler to be readable.