This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: OPEN statement in Fortran (g77)


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]