OPEN statement in Fortran (g77)

Toon Moene toon@moene.indiv.nluug.nl
Fri Sep 12 18:49:00 GMT 2003


Prof. M.B. Patil wrote:

> A question about OPEN statement in Fortran:
> 
> The following does not seem to work:
>       open (unit=1,file='~/xyz/try2.in',status='old')
> 
> The error message I get is the following:
> 
> open: No such file or directory
> apparent state: unit 1 named ~xyz/try2.in
> lately writing direct unformatted external IO
> Aborted

This is unfortunate, but inevitable.  The home directory character ~ is 
specific to certain shells, i.e., they only work if you type something like:

ls -l ~/xyz/try2.in

in your shell, which interprets it as `ls -l $HOME/xyz/try2.in'.

The above program just opens the file with name '~/xyz/try2.in' - it 
doesn't do any such "translation", because the Fortran standard mandates 
it to use the name literally.

Hope this helps,

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://gcc-g95.sourceforge.net/ (under construction)



More information about the Gcc-bugs mailing list