# Eclipse PTP Setup: FORTRAN

1. Dec 28, 2011

Alrighty then 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. Dec 29, 2011

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.

*Note:

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:

3. Dec 29, 2011

### I like Serena

In your first screenshot you can see a file named "Makefile".
Can you show its contents?

4. Dec 29, 2011

Hi ILS 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!

5. Dec 29, 2011

### I like Serena

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.

6. Dec 29, 2011

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.

7. Dec 29, 2011

### I like Serena

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?

8. Dec 29, 2011

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"
make: *** [HelloWorld1/HelloWorld1.o] Error 127

**** Build Finished ****

Thanks again

9. Dec 29, 2011

### I like Serena

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?

10. Dec 29, 2011

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. 11. Dec 29, 2011 ### I like Serena 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? 12. Dec 29, 2011 ### Saladsamurai Hi ILS. I changed to the correct directory (duh ) 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. 13. Dec 29, 2011 ### I like Serena 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

14. Dec 29, 2011

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): /usr/local/bin/gfortran ANd when I type "echo$PATH" I get:

Code (Text):
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin

15. Dec 29, 2011

### I like Serena

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

That way Eclipse will inherit the PATH environment variable from your terminal window effectively fixing the problem that gfortran cannot be found.

16. Dec 29, 2011

Hmmm. When I type eclipse in a terminal I get the error:

Code (Text):

17. Dec 29, 2011

Let me guess: eclipse is not on the PATH ? :tongue:

18. Dec 29, 2011

### I like Serena

Okay.
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!

19. Dec 29, 2011

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?

20. Dec 29, 2011

### I like Serena

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...

Or...

Last edited: Dec 29, 2011