fortran

Fortran runtime error: Cannot open file (No such file or directory)


Disclaimer: I'm using a program written in FORTRAN and I'm having trouble using it. I'm not proficient in FORTRAN at all. I apologise in advanced if this is a dummy question.

I'm getting the following error:

At line 1494 of file phot_star_fit18.f90 (unit = 45)
    Fortran runtime error: Cannot open file '/Users/.../SSPFITTING/GASFIT/ssp/ssplist.d': No such file or directory

Error termination. Backtrace:
#0  0x10a0a9729
#1  0x10a0aa3f5
#2  0x10a0aab59
#3  0x10a16f70a
#4  0x10a16f950
#5  0x10a09815c
#6  0x10a09ee5e

Line 1494 is:

open(unit=45,file=splist,status='old',action='read')

In the /Users/.../SSPFITTING/GASFIT/ssp/ directory I have the following files relating to ssplist. something:

ssplist.dat2
ssplist.dat04
ssplist.dat5
ssplist.dat08

Could anyone shed some light on why this is failing and why the code is expecting a ssplist.d file?


Solution

  • There is not enough data in the question to ascertain whether this really is the issue, but I have a strong suspicion:

    It tries to open a file called /Users/.../SSPFITTING/GASFIT/ssp/ssplist.d which doesn't exist. Now there are several files that start with ssplist.d, but none where this is the full name.

    If you try to assign an overlong string to a fixed length char variable, the last characters are dropped:

    program string1
        implicit none
        character(len=8) :: h
        h = "Hello World"
        print *, h
    end program string1
    

    Prints:

    Hello Wo
    

    My suggestion is to search for the declaration of your character variable splist, I suspect it to look something like this:

    character(len=xx) :: splist
    

    but might also be older:

    character*xx splist
    

    or something like this, where xx is a number. This xx needs to be at least the number of characters in /Users/.../SSPFITTING/GASFIT/ssp/ssplist.dat08 (I also suspect that you have replaced a long list of subdirectories with ... so I can't tell you how many characters that are.) My suspicion is that that number is just a little to short.