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: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: "Prof. M.B. Patil" <mbpatil at ee dot iitb dot ac dot in>
- Cc: gcc-bugs at gcc dot gnu dot org, bug-gcc at gnu dot org
- Date: Sat, 13 Sep 2003 13:37:43 +0200
- Subject: Re: OPEN statement in Fortran (g77)
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <Pine.GSO.4.44.0309130800560.21267-100000@bhairav.ee.iitb.ac.in>
Prof. M.B. Patil wrote:
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.
Yep, same reason. $HOME is expanded by the shell (it's an environment
variable of the shell, after all).
The following should work (this all non-standard Fortran, but supported
by many compilers):
CHARACTER*128 HOME
CALL GETENV('HOME', HOME) ! Gets value of the HOME env. var.
OPEN(UNIT=1,FILE=HOME(1:LEN_TRIM(HOME))//'/xyz/try2.in',
, STATUS='OLD')
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)