Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran 77 problem!

  1. Jul 5, 2010 #1
    I am using one progran,have problem with char function.
    open(28, file=rfile, form='unformatted', status='old')
    I have entered write line.This is what I get:
    open: No such file or directory
    apparent state: unit 28 named fd01.picks
    last format: list io
    lately writing sequential formatted external IO
    What is actually char doing?
  2. jcsd
  3. Jul 5, 2010 #2


    Staff: Mentor

    I haven't done any Fortran for a few years, but here's what seems to be happening.

    char(id1+48) converts the integer value id1 + 48 to a character. char(id2 + 48) converts the integer value id2+48 to a character.

    This line of code --
    -- concatenates the two characters and stores them in the rfile string at indexes 3 and 4.

    It's hard to tell exactly what's happening here without knowing the values of id1 and id2, but it seems that char(id1+48) is '0' and char(id2+48) is '1'.

    Your code seems to be looking for a file named fd01.picks. Are you sure that this file exists in the directory the program is looking in? It appears that the open line is not able to find this file - that's what the error message is saying.
  4. Jul 5, 2010 #3
    You are right fd01.picks is the file.Well I still have problems with new line:
    open(28, file=rfile, form='unformatted', status='old')
    I get this:
    open: No such file or directory
    apparent state: unit 28 named fd01.picks
    last format: list io
    lately writing sequential formatted external IO
  5. Jul 5, 2010 #4


    Staff: Mentor

    You didn't answer the question I asked in the last line of my previous post. Is the program able to find the file it's trying to open - fd01.picks?

    Look in the directory that you're executable program file is in. I believe that's the directory in which your program is looking. If this directory doesn't contain fd01.picks, that's why you're getting the error you see.
  6. Jul 6, 2010 #5
    Thanks for helping me!
    data xsource/nsources*-9999999./,
    + isource/nsources*-1/,tfile,rfile,r2file,ofile,t2file
    + /'fd .times','fd .picks','rec. ','fd .calc',
    This is part of the code for initialization parameters.
    fd01.picks should be output file,travel times are there that is what I want to get from the program.
  7. Jul 6, 2010 #6
    Now I have put fd01.picks from examples into my directory.I still have problems:
    FD: finite difference traveltime calculation
    open: No such file or directory
    apparent state: unit 28 named fd18.picks
    last format: list io
    lately writing sequential formatted external IO
  8. Jul 6, 2010 #7


    Staff: Mentor

    This code doesn't look like Fortran or any language I know about, so I don't know what it's doing. Even so, the problem might be the spaces in the names of these files:

    'fd .times'
    'fd .picks'
    'fd .calc'

    Before you run your Fortran program, but after you run the code above, look in the directory where your program is, and check that there is a file fd01.picks there. Your program is reporting that it can't find this file.
  9. Jul 6, 2010 #8


    User Avatar

    Staff: Mentor

    The DATA statement is valid Fortran, assuming the "+" at the beginning of the following lines is actually in the correct location to indicate a statement-continuation line. (The forum software tends to "eat" extra blank spaces.) It simply initializes variables to the indicated values.

    It appears that the character-manipulation code in the first two posts is intended to replace those blank spaces with digits.

    It looks like the program is constructing the file name correctly, because the error message displays the correct file name. The problem is that the file isn't in the directory (or folder) in which the program is looking for it.

    As you say, usually a program looks first in the directory in which the program itself is located. If the file really is in that directory, then Milentije needs to find out where the program actually expects the file to be. It may depend on a compiler setting, or an operating-system thing like a Unix shell's PATH variable.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Fortran problem Date
Fortran for Computational Fluid Dynamics Problems Jan 11, 2018
Fortran77 data compiler problem Jan 19, 2017
Problem with fortran and lapack Nov 28, 2016
Function problem Aug 31, 2015