This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: OPEN statement in Fortran (g77)
- From: "Prof. M.B. Patil" <mbpatil at ee dot iitb dot ac dot in>
- To: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Cc: gcc-bugs at gcc dot gnu dot org, <bug-gcc at gnu dot org>
- Date: Sat, 13 Sep 2003 08:05:36 +0530 (IST)
- Subject: Re: OPEN statement in Fortran (g77)
> > 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.
>
Thanks a lot. Is there any other way to access the home directory? (The
program may be residing one/two/three/.. levels below the home directory,
otherwise I could have used ../ or ../../ etc. These seem to work fine)
I tried using $HOME instead of tilde, but that gave the same error.
Regards,
Mahesh Patil