Fortran
Toon Moene
toon@moene.indiv.nluug.nl
Fri Apr 21 05:54:00 GMT 2000
Demas Ami wrote:
> I'm new to linux. I tried to compile my fortran program using G77 and it
> works. But when I run
> the program, after I type the input file and the designated output file,
> the program got aborted.
> I already put the input file in the same directory as the program. My
> program work in windows
> using MS compiler.
>
> I use the following sintax for open file:
>
> open(unit=5, file='inputfile', status='new')
> open(unit=6, file='output', status='unknown')
>
> read(5,*)n ...........(something like this)
>
> write(6,*) hf ........(something like this)
>
> Is it impossible to write program in linux(g77) using the input file
> and writing the output into fiel
Well, as far as you showed us your program, this is all standard fortran
77, so it should work when compiled with g77.
However, there's one problem with it:
You read from a file for which you stated on the open statement that it
doesn't exist yet: "open(...,status='new')
That's only possible if you first write to the file on unit 5, before
reading from it (you also have to rewind before reading).
The snippets you showed are not conclusive in this regard, but if you
only intend to read from unit 5, you cannot open it with "status='new'".
If you do, you'll get the following error from the run time library:
open: 'new' file exists
apparent state: unit 5 named infile
Cheers,
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://xena.eas.asu.edu/~andy (under construction)
More information about the Gcc
mailing list