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

Eclipse PTP Setup: FORTRAN

  1. Dec 28, 2011 #1
    Alrighty then :smile: So in order to solve a problem in a previous thread, I simply reinstalled Eclipse, but this time i went with the Parallel Tools Platform since it is supposed to work with FOTRAN too.

    I created a C++ project first and did the 'Hello World' thing to make sure it was working. C++ is working fine as far as I can tell.

    So I switched to a FORTRAN project and I am having trouble Building. I have a screenshot below. Perhaps someone can help me out with what this might mean? I am used to using Digital Fortran (yeah, I know--old as dinosaurs) where I simply write code, build and run.

  2. jcsd
  3. Dec 29, 2011 #2
    EDIT: I think I should include some more details:

    I am using a Mac OS = Snow Leopard.

    The exact steps I used to generate the error in the screenshot above:

    1) Right-click in Package Explorer: New -> FORRAN Project ->Makefile Project ->Demo Hello World FORTRAN

    2) Attempt to Build the source code that was generated by the Hello World Project creation.


    a) I don't know why I use the 'Makefile' projects, I just saw it in a tutorial. Can someone enlighten me?

    b) When I select the Makefile project, there are options in the 'Toolchains' window. I think this might be related to my problem: When the box that says "Show project types and toolchains only if they are supported on the platform" is checked I only see the XLF Tool Chain. But if I uncheck it, I can see GCC Fortran. (See new screen shots below). Selecting the GCC Fortran does not help resolve the issue, but it raises my question of why does is it NOT available when the box IS checked?

    With Box checked:


    With Box Unchecked:

  4. Dec 29, 2011 #3

    I like Serena

    User Avatar
    Homework Helper

    In your first screenshot you can see a file named "Makefile".
    Can you show its contents?
  5. Dec 29, 2011 #4
    Hi ILS :smile: There actually are no contents in the makefile. Perhaps that is the problem. I don't know a lot (anything really) about makefiles. It seems like most "modern" languages don't need you to explicitly make a makefile. Am I correct in saying that? After some Googling, it seems like the types of things that a makefile does are the types of things that get done automatically when you build/link etc.

    I have written plenty of FORTRAN code in my graduate work, but never once encountered a makefile. I think I should look into getting a different project type to work. For example, I think that I should be using the option "Executable (GNU Fortran on MacOS X)" would be a more "normal" option. Normal as in 'just type some source code and then run it'.

    However I recall that project type gave me errors too. I'll post back momentarily with the new errors. Thanks!
  6. Dec 29, 2011 #5

    I like Serena

    User Avatar
    Homework Helper

    Hi! ;)

    FYI, you always need a file specifying which files to compile and link.
    Also where to find include files and libraries.
    And in particular which compiler and linker to use.
    This information is kept in either a project file or a makefile.

    When you already have a makefile you can tell Eclipse to get this information from it by creating a Makefile project.

    Otherwise you have to tell Eclipse this, although it can make an educated guess, after which Eclipse generates a makefile and uses that.
  7. Dec 29, 2011 #6
    So if I follow these steps:

    1) New -> Fortran Project -> Executable (Gnu Fortran on MacOS X)

    2) In the Project: New -> source folder

    3) In Source folder: New -> Named HelloWorld1.for -> Select from dropdown: fixed form template

    Upon running a simple Hello World I get the following screen. Here is what is bothering me:

    a) The source folder icon named HelloWorld1 in the package explorer on the left has a little superscripted "C" on it whereas the project folder icon has a superscripted "F". So I think Eclpipse is thinking this is C or something.

    b) In the error window there is the C/C++ thing under 'type' which makes me think the same.

  8. Dec 29, 2011 #7

    I like Serena

    User Avatar
    Homework Helper

    I think your problem is: "gfortran: command not found."

    This error shows that Eclipse does understand that you are compiling a fortran file.

    So the question is: do you have gfortran on your system?
    And if so, perhaps you need to configure in which directory it is.

    In the Console tab-sheet you should be able to see which command is actually given.
    Perhaps you can show what it says?
  9. Dec 29, 2011 #8
    I do have gfortran installed. I confirmed this by typing: gfortran --version in a terminal window. The console tab contents are as follows.

    Code (Text):

    **** Build of configuration Debug for project HellowWorld1 ****

    make all
    Building file: ../HelloWorld1/HelloWorld1.for
    Invoking: GNU Fortran Compiler
    gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -o "HelloWorld1/HelloWorld1.o" "../HelloWorld1/HelloWorld1.for"
    /bin/sh: gfortran: command not found
    make: *** [HelloWorld1/HelloWorld1.o] Error 127

    **** Build Finished ****
    Thanks again :smile:
  10. Dec 29, 2011 #9

    I like Serena

    User Avatar
    Homework Helper

    So what happens if you type:

    gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -o "HelloWorld1/HelloWorld1.o" "../HelloWorld1/HelloWorld1.for"

    in a terminal window?
  11. Dec 29, 2011 #10
    I get the following error:

    Code (Text):
    Last login: Thu Dec 29 14:51:40 on ttys000
    Salad-Samurais-MacBook-Pro:~ saladsamurai$ gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -o "HelloWorld1/HelloWorld1.o" "../HelloWorld1/HelloWorld1.for"
    gfortran: error: ../HelloWorld1/HelloWorld1.for: No such file or directory
    gfortran: fatal error: no input files
    compilation terminated.
  12. Dec 29, 2011 #11

    I like Serena

    User Avatar
    Homework Helper

    Can you change the current directory first to the "HelloWorld1" directory?
    That way the gfortran compiler should be able to find the source file "../HelloWorld1/HelloWorld1.for".

    Anyway, apparently you have a PATH environment problem, meaning that Eclipse cannot find gfortran in the default PATH, but from the terminal window you can.
    Did you already reboot your computer?
  13. Dec 29, 2011 #12
    Hi ILS. I changed to the correct directory (duh :blushing:) and I still get the same error.

    With regard to rebooting: Since when do you mean? If you mean since last night, yes. Also, I keep hearing about this PATH thingy, what is that? Is that an environmental variable?

    I think we are certainly honing in on the problem: The C++ code works fine, so I wonder why the gfortran is not. I guess we need a way of checking "where" the gfortran compiler and where Eclipse is expecting it to be. As of now, it seems that the problem is that the two are not equal.
  14. Dec 29, 2011 #13

    I like Serena

    User Avatar
    Homework Helper

    If you are in the correct directory, you should not get the same error...
    So apparently you are not in the correct directory.

    I meant rebooting since you installed fortran...

    Let's check this.
    Can you type the following commands in a terminal window?

    which gfortran
    echo $PATH
  15. Dec 29, 2011 #14
    Oof! You're write. I only went to the parent 'project' folder. This is what I get:

    Code (Text):
    --MacBook-Pro:HellowWorld1 saladsamurai$ cd HelloWorld1
    saladsamurai-MacBook-Pro:HelloWorld1 saladsamurai$ gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -o "HelloWorld1/HelloWorld1.o" "../HelloWorld1/HelloWorld1.for"
    /var/folders/9K/9KvTsFwDELOjojSdLl+IFU+++TI/-Tmp-//ccQVvBsP.s:unknown:FATAL:can't create output file: HelloWorld1/HelloWorld1.o
    saladsamurais-MacBook-Pro:HelloWorld1 saladsamurai$
    When I type "which gfortran" I get:

    Code (Text):
    ANd when I type "echo $PATH" I get:

    Code (Text):
  16. Dec 29, 2011 #15

    I like Serena

    User Avatar
    Homework Helper

    Can you close eclipse and then restart eclipse from the terminal window by typing:

    That way Eclipse will inherit the PATH environment variable from your terminal window effectively fixing the problem that gfortran cannot be found.
  17. Dec 29, 2011 #16
    Hmmm. When I type eclipse in a terminal I get the error:

    Code (Text):
    -bash: eclipse: command not found
  18. Dec 29, 2011 #17
    Let me guess: eclipse is not on the PATH ? :tongue:
  19. Dec 29, 2011 #18

    I like Serena

    User Avatar
    Homework Helper

    Try to find out where eclipse is and start it with the entire path.
    On my linux system it is:
    $ /opt/eclipse/eclipse

    Perhaps you can find it with:
    $ locate eclipse

    Right! :wink:
  20. Dec 29, 2011 #19
    the locate command needs to generate a database as this is the 1st time I have used it. Before doing so, what exactly am I looking for? Eclipse is weird to me in that it's not installed in my applications folder like all other programs. It's just a 'folder' that I downloaded from the site. I run it by clicking on an icon inside of this folder.

    The thing is, I have Eclipse PTP and Eclipse SDK. Both of them have their own folder on my desktop. I run each from within their respective folders. Is that helpul?
  21. Dec 29, 2011 #20

    I like Serena

    User Avatar
    Homework Helper

    Perhaps you can right-click on the icon and select "Properties" or something like that (I'm not a Mac user).
    That should tell you what it's named and where it is...

    Alternatively you can try:
    $ cd ~/Desktop
    $ ls
    and see if you can find those folders...

    Or perhaps you can drag and drop (or copy and paste) the icon in the Terminal window...

    Of perhaps you can open some sort of file explorer and search for a file named eclipse...

    Last edited: Dec 29, 2011
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook