Find the answer to your Linux question:
Results 1 to 10 of 10
Hi all! I am trying to compile one program, but I am getting this error: Code: f77 -g -c -o ask.o ask.f make: f77: Command not found make: *** [ask.o] ...
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    14

    fortran package

    Hi all!

    I am trying to compile one program, but I am getting this error:
    Code:
    f77 -g  -c -o ask.o ask.f
    make: f77: Command not found
    make: *** [ask.o] Error 127
    I have compiled that program successfully while I was working on Fedora, but now when I work on openSUSE, I can't seem to compile it. I believe that it is a matter of fortran packages that need to be installed (at least, that was the case when I had compiled it on Fedora). I've installed gccfortran 4.3. with libgfortran libraries, also an f2c software and perl-ExtUtils-F77, but I still receive the same error. Are these latterones even needed (perl.. and f2c)?

    My question is: what package should I try to find and/or which repositories should I add to the repository list (if necessary)?

    Thank you.

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    It looks like the default rules have not been updated. Here's one way to fix this:
    Code:
    #!/bin/bash -
    
    # @(#) s1       Demonstrate change to make rule for Fortran.
    
    echo
    echo "(Versions displayed with local utility \"version\")"
    version >/dev/null 2>&1 && version =o $(_eat $0 $1) make gfortran
    echo
    
    FILE=hw.f
    rm -f hw
    echo " Input file $FILE:"
    cat $FILE
    
    echo
    echo " makefile.1:"
    cat makefile.1
    
    echo
    echo " Results of default make:"
    make -f makefile.1
    ./hw
    rm -f hw
    
    echo
    echo " makefile.2:"
    cat makefile.2
    
    echo
    echo " Results of make:"
    make -f makefile.2
    ./hw
    
    exit 0
    Producing:
    Code:
    $ ./s1
    
    (Versions displayed with local utility "version")
    Linux 2.6.22.17-0.1-default
    GNU bash 3.2.25
    GNU Make 3.81
    GNU Fortran (GCC) 4.2.1 (SUSE Linux)
    
     Input file hw.f:
          program main
          write(6,*) " Hello, world from fortran."
          end
    
     makefile.1:
    hw: hw.f
    
     Results of default make:
    f77    hw.f   -o hw
    make: f77: Command not found
    make: *** [hw] Error 127
    ./s1: line 22: ./hw: No such file or directory
    
     makefile.2:
    FC = gfortran
    hw: hw.f
    
     Results of make:
    gfortran    hw.f   -o hw
      Hello, world from fortran.
    The variable FC is the key. You can view the default rules with option "-p" -- the listing is long and complex. See man make for more details.

    In looking through the openSuSE repository I have, f77 / g77 was not mentioned, but perhaps it would come in with some other package ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  3. #3
    Linux Newbie tvilkov's Avatar
    Join Date
    Jan 2007
    Location
    Moscow
    Posts
    136
    try gfortran. It should come by default with gnu compile collection (i.e gcc). I did fortran programming no so long ago using it. Just try
    Code:
    gfortan hello.f90
    Gentoo 2.6.24 amd64
    AMD Anthlon 64 X2, 2 GB RAM, Asus M2N-MX, nVidia GeForce 9600GT 512Mb, 250Gb + 160Gb HDDs

  4. #4
    Just Joined!
    Join Date
    Jan 2008
    Posts
    14
    Thanks for the reply, but I've come across another problem. Here's what I've got after I had entered the code:
    Code:
    archie.leach@archie-leach:~/Desktop> ./s1
    bash: ./s1: Permission denied
    I have to admit of using that non-popular "su", when I saw that "permission denied" message, but the result was the same.

    Why can't I run the script?

    Also, I've tried gfortran before, but all I got was
    Code:
    -bash: gfortran: command not found
    Thanks, anyway

  5. #5
    Linux Newbie tvilkov's Avatar
    Join Date
    Jan 2007
    Location
    Moscow
    Posts
    136
    well, it seems that fortran is not intalled. You have to install it. I don't know how to do it in openSUSE, but in Fedora you do
    Code:
    yum install gfortran
    Do a search in your package install manager. It should be there
    Gentoo 2.6.24 amd64
    AMD Anthlon 64 X2, 2 GB RAM, Asus M2N-MX, nVidia GeForce 9600GT 512Mb, 250Gb + 160Gb HDDs

  6. #6
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    One way to run a script is:
    Code:
    bash s1
    however, to run scripts like commands, you need first to add execute permission (necessary only once, the permission will then stay with the file):
    Code:
    chmod +x s1
    then you can use:
    Code:
    ./s1
    Try either one (or both) of those actions first, but we also may need to review how you installed gfortran (as you stated in your first post). To get a start on that, please run these commands:
    Code:
    whereis gfortran
    echo $PATH
    and post the results. For example, it should look something like this:
    Code:
    $ whereis gfortran
    gfortran: /usr/bin/gfortran /usr/bin/X11/gfortran /usr/share/man/man1/gfortran.1.gz
    $ echo $PATH
    /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
    $
    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  7. #7
    Just Joined!
    Join Date
    Jan 2008
    Posts
    14
    Thank you for chmod, I totally forgot all about it. It did the trick, as well as the example of the code - I get the same output, thanks.

    As for gfortran, I've installed some more packages, which had resolved the compiler issues. Thanks once again.

    FC is most likely the answer to my problem, but do you know or can you at least point me to the FC use with ratfor?

    Namely, after I tried to compile the code, I've received the same "f77: command not found error". I've used FC in a makefile which has a ratfor preprocessor, but without any success.

    Does ratfor even has any effect on the compiler?

    Here's that makefile:
    Code:
    .SUFFIXES: .r
    .r.f:
    	ratfor -C $< > $@
    FFLAGS = -g
    #To optimize, use the next FFLAGS
    #FFLAGS = -O4
    TJOLIB = ../Subs/subs.a
    BINDIR = ../../bin
    
    pwaveqn: pwaveqn.f	
    	f77 $(FFLAGS) -o $(BINDIR)/pwaveqn pwaveqn.f $(TJOLIB) $(SACLIB)
    I've tried to comment-out the line "f77 $(FFLAGS)...." but then it reported some undefined references (which I believe is because of the missing libraries TJOLIB and SACLIB).

    Is there a way to set these libraries AND use FC = gfortran at the same time?
    Thanks.

  8. #8
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    Glad to hear of your success.

    I'm not sure we're on the same frequency here. Are you saying that you have a ratfor code, or that you think it is somehow connected to a different problem?

    The best way to ask questions like this is to create the smallest example that illustrates the problem, then post it, your actual results, and what you expected. That's how I attempted to guess the solution to your problem, and I illustrated it with a script that showed how make first failed, then succeeded. For example, looking at only parts of a larger makefile may obscure the real problem, because it may lie elsewhere in the file, and no one wants to wade through a complicated makefile or source code file.

    The repository I have for openSuSE shows nothing for ratfor, by the way ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  9. #9
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    A brief addendum. The post at Tim Prince - Re: g77=>gfortran ? suggests that as of gcc 4, there is no g77 / f77 compiler available, only the Fortran compiler named gfortran. So references to f77 and g77 will need to be modified somehow -- each case may vary, I don't know if gfortran will handle all f77 / g77 codes, but the implication at the gnu newsgroup is that it should.

    This likely explains why openSuSE has no f77 / g77 (although I see an entry for g77 in Debian lenny repository).

    One could search for a similar explanation for ratfor. It was probably dropped some time ago. The gnu.org software search simply says:
    Code:
    Your search for ratfor
     
    No results found!
    ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  10. #10
    Just Joined!
    Join Date
    Jan 2008
    Posts
    14
    Thanks for the effort, I know that there is no ratfor (now I am wondering why has it been put in the makefile at all?).

    Here's the thing: the program I wish to compile has a couple of smaller programs which have their own makefiles. There is a script that compiles all of them, only thing that needs to be set is the path of the environment variable, but that's not the issue.

    I have resolved the compiling problem by simply adding the line FC = gfortran to all of the smaller makefiles, and changed the f77 command to gfortran. It did the trick, but with some warnings and errors.

    I know that sometimes warnings can be ignored, but errors shouldn't. Do you recognize any of the following?

    Code:
    gfortran -g  -c -o ask.o ask.f
    ask.f:18.21:
    
      100 format(80(a1,$))                                                  
                        1
    Warning: $ should be the last specifier in format at (1)
    How do I put $ as the last specifier?

    Code:
    gfortran -g -o ../../bin/ppstime ppstime.f ../Subs/subs.a /home/archie.leach/Desktop/RF/bin/sacio.a
    ppstime.f:14.16:
    
          data suf /'.dvp ','.dvs ','.drho'/                                
                   1
    Warning: initialization string truncated to match variable at (1)
    I don't even understand this one..

    Code:
    gfortran -g   -c -o getmodl.o getmodl.f
    getmodl.f:18.72:
    
             read(nu,'(i3,1x,8f8.2)') il, alpha(i),beta(i),rho(i),thk(i),j1,
                                                                           1
    Error: Expected variable in READ statement at (1)
    I believe that the last one includes greater knowledge of Fortran programming than my own, but I still need to ask if there is a way to resolve these errors in an easier way?

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...