Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran in Windows

Status
Not open for further replies.

cjkogan111

Technical User
Jul 12, 2007
5
US
Hello,
I downloaded gfortran (95) - mingw/native windows onto a windows XP OS.

I am trying to open a file outside of the default directory (bin)
I have tried the following methods:

OPEN(8,file='test\a.txt',status='old')

OPEN(8,file='c:\Program Files\gfortran\bin\test\a.txt',status='old')

For each, I get the following error -
Fortran runtime error: Invalid arguments

If I open a file in the default directory it works fine:
OPEN(8,file='a.txt',status='old')

Any suggestions?
Thanks,
cjkogan111
 
Hi,

The error is in \ which is only used in dos and windows (as far as I know, I don't know what mac uses)

Fortran uses the unix convention, so you need to use / instead. The compiler will handle the difference between \ and / otherwise your code wouldn't be portable.

Something like:

OPEN(8,file='./test/a.txt',status='old')

Should work I think

Regards,

Gerrit
 
Hi,

If GerritGroot's suggestion does not work try this:

1) Use double backslash. That could work.
OPEN(8,file='c:\\Program Files\\gfortran\\bin\\test\\a.txt',status='old')

2) Put the file name in a variable (that works fine in MS-Fortran for DOS):
character*80 str
str = 'c:\Program Files\gfortran\bin\test\a.txt'
lstr = len_trim(str)
open(8,file=str(1:lstr),status='old')

Best wishes
gullipe

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top