filefortranfortran77

Unable to open file by a relative path in FORTRAN 77


I wrote FORTRAN 77 code which opens (creates) a file and writes some information into it. Everything works great if I open the file like

INTEGER U
U=1
OPEN(U, FILE='data.txt')

But if I want the file to be created in a different dir specifying a relative path (OS Ubuntu)

INTEGER U
U=1
OPEN(U, FILE='../output_files/data.txt')

my gfortran compiler gives me the following error:

OPEN(U,FILE='../output_files/data.txt')
           1
Error: Invalid value for FILE specification at (1)

Seems like absolute path is working in my case. I have spent some time doing some research on the Internet and found that every manual I looked into said that relative path should work as well. That's important for me. Is it possible to fix this somehow?

Update

The real code I was using is

INTEGER U
U=1
OPEN(U, FILE='output_files/energies_and_first_interaction_coordinates_mum.txt')

and the error is

  OPEN(U,FILE='output_files/energies_and_first_interaction_coordinates_mum.txt')
         1
  Error: Invalid value for FILE specification at (1)

Solution

  • I found the solution, thanks to francescalus and L. Scott Johnson.The problem was that the command to open file was expanded beyond 72 position on the line (the name of my file was to long).