Eclipse for Scientific Computing

Fortran IDE for macOS

If you want or have to develop in Fortran on a Mac and you are looking for a convenient IDE you do not have the same opportunities as Windows or GNU/Linux users. Especially to find an appropriate and affordable one for students and hobbyists which is comparable to e.g. Code::Blocks was not easy. But Eclipse for Scientific Computing fills the gap.

This how-to and field report covers Eclipse as a Fortran IDE mainly. Not so much on setting up a Fortran toolchain.

Code::Blocks?

On Windows and GNU/Linux I use Code::Blocks (with the Fortran Plugin installed).Which is a good IDE for Fortran for many target groups.

To set this up on GNU/Linux refer (English) Install and Setup Code::Blocks for Fortran on GNU/Linux for Windows you find help at 10 minutes to setup Modern Fortran 2003 / 2008 with CB on Windows.

Unfortunately there is no pre-compiled macOS version of Code::Blocks for Fortran available and I failed to build it on my own. I tried a lot of alternatives for macOS like Geany, prior Photran on Eclipse, VS Code, etc. There is also a compiler-independend commercial IDE available: SimplyFortran, but 140.– USD was too much for a time to time Fortran programmer hobbyist. But not too bad for more enthusiastic Fortran programmers.

Is Eclipse for Scientific Computing a good alternative for macOS?

My requirements

Must-haves:

  • Affordable for students and hobbyists (not more than 50.– USD/EUR)
  • Fortran77/90 fixed- and free-form editors
  • Syntax highlighting
  • Comment-out functionality by short-cut or at least by menu
  • Automatic makefile-generation (or at least build management which can handle module-dependencies), if wanted
  • Graphical debugger frontend

Nice-to-haves:

  • Code-completion
  • Symbol-Browser
  • Call-tips for function and subroutine arguments
  • Refractoring tools
  • Git-support

Eclipse for Scientific Computing (EfSC) has all the must-haves and some nice-to-haves (symbol-browser, Refactoring tools and Git-support).

What is Eclipse for Scientific Computing

EfSC is mainly the integration of the two plugins:

  • CDT (C/C++ Development Tooling)
  • Photran (Integrated Development Environment and Refactoring Tool for Fortran)

in Eclipse. Photran was build on top of CDT. I tried Photran in the past. But I had problems bring the makefile-generation to work and some other issues. Today it is much more mature and setup is no longer a problem because it is now fully integrated.

But you still can see that EfSC was designed for C/C++ in the first place.

Setup

Fortran Toolchain

As I mentioned before I will not go into detail on this topic. If you do not have a Fortran toolchain already installed, I recommend the free (of cost) gfortran from GNU. Therefore I also recommend to install a package manager (Homebrew or MacPorts) where you can easily install gfortran and other stuff you may or will need later. Take the extra time for one of these package manager you will not regret it. If installed just one command is sufficient.

Download

Download EfSC from eclipse.org. Scroll down to “Eclipse IDE for Scientific Computing” and choose your platform. EfSC is also available for macOS on Apple’s new M1 ARCH64-achitecture. You get an DMG. As an Mac user you know what to do.

You do not need a Java JRE installed. It is bundled with current EfSCs.

Configuration

EfSC does almost work out of the box for Fortran. But it needs still some configuration.

  1. After the first start a Welcome screens appears. Close the tab by clicking on the X.

    Eclipse Welcome Screen

    Welcome Screen

  2. Go to the program menu ECLIPSE > PREFERENCES, on the left pane choose GENERAL > PERSPECTIVES and choose “Fortran” and click on MAKE DEFAULT.

    Eclipse-Perspectives

    Preferences > Perspectives

  3. On macOS EfSC does not find the Fortran compiler because it is not in the standard path “/usr/bin/” but in “/us/local/bin/” (Homebrew) or “/opt/local/bin/” (Macports). You will get the error message:/bin/sh: /usr/bin/gfortran: No such file or directory during building. In the next chapter there is a solution. You cannot solve this issue here globally unfortunately.

First working project

Setup a project

  1. Menu FILE > NEW > FORTRAN PROJECT. If “Fortran Project” is not available, choose OTHERS.
    1. In the wizard, expand FORTRAN
    2. Choose FORTRAN PROJECT
    3. NEXT
  2. In the Fortran Project box give your project a name in “Project name:”.

    Fortran Project

    Fortran Project

  3. You can leave “Use default location” checked.
  4. Choose “Project type:
    1. If you want an auto-generated Makefile choose “Others > Executable (GNU Fortran on Mac OS X)”, in “Toolchains:” “GCC Fortran”
    2. If you have a Makefile already or want do make one on your own choose “Makefile project > “Empty Project – Fortran”, in “Toolchains:” click on “– Other Toolchain —“
  5. NEXT
  6. Select your configurations (Debug or Release or both)

    Build configurations

    Build configurations

  7. To set up your compiler path (mentioned above), click on ADVANCED SETTINGS …
  8. On the left pane choose “Fortran Build > Settings”
  9. On the right choose the first configuration, let’s say “Debug”
  10. On Tab “Tool Settings” go to “GNU Fortran Compiler” an change “Command” to your complete path of your Fortran compiler.
    Compiler Settings

    Compiler Settings

    1. MacPorts: /opt/local/bin/gfortran
    2. Homebrew: /usr/local/bin/gfortran
  11. Do the same for “MacOS X Fortran Linker”

    Linker Settings

    Linker Settings

  12. Repeat this steps (10-11) for the other configuration(s), e.g. “Release”.
  13. APPLY AND CLOSE
  14. FINISH

Fill project with code

  1. Click on your project name in the Project Explorer
  2. OPTIONAL: You can organize your code in one and more source folders by FILE > NEW > FORTRAN SOURCE FOLDER

    Source folder

    Source folder

  3. FILE > NEW > FORTRAN SOURCE FILE
  4. Type in a file name in “Source file:”, e.g. hello.f90

    Source file

    Source file

  5. IMPORTANT: Choose the desired template. Be aware that the default gives you a fixed form template. If you want to use modern Fortran’s free-form, choose:
    • “Default free-form Fortran source file template” or
    • “Fortran module (free-form)” or
    • “Fortran class (free-form)”, respectively.
      For normal Fortran programs choose the first.
  6. FINISH
  7. You get a skeleton code:
    program hello
        implicit none
    end program hello
  8. Lets add one more line and save
    program hello
        implicit none
        print*, "Hello World"
    end program hello
  9. You can add other (source) files, e.g. modules, etc. the same way.

You have access for all of these menu commands from the toolbar as well.

Build and run your project

Run project

Run project

  1. Be sure that your current project is chosen in the Project Explorer
  2. Choose your configuration to build: Menu: PROJECT > BUILD CONFIGURATION > SET ACTIVE
  3. PROJECT > BUILD PROJECT
  4. Check Tab “Console” in the pane below for errors, warning or success.
  5. Menu: RUN > RUN, choose “Local Fortran Application” then OK
  6. You find terminal output in the Console tab below.

You have access for all of these menu commands from the toolbar as well.

Beginners who have frequent edit-build-debug-cycles and short codes can switch to “auto build” in PROJECT > PROPERTIES > Fortran Build > Behavior > Build on resource save (Auto build).

Auto build

Auto build on save

Issues and bugs

  • EfSC build process does not recognize capital extensions, like “F90” as Fortran sources
    Many Fortran compilers, so as Gfortran, pre-process these files, and process pre-processor directives in your code. Unfortunately you cannot add these extensions to the extensions list in PREFERENCES > C/C++ > FILE TYPES. EfSC is not case sensitive in this case and reject them as doubles. EfSC is very flexible. Maybe it is possible to setup the pre-processor in “Build Steps” in C/C++ BUILD > SETTINGS. But nothing simple.
  • Compiler path
    Correcting the compiler path for every new project is annoying. I have not found any settings to set this Eclipse-wide. This does not happen on GNU/Linux for obvious reasons: Gfortran is in /usr/bin/. I have not tested it on Windows.

What is missing

In comparison to other Fortran IDEs, EfSC has unique features for parallel and remote computing. But if you just look for an IDE for local work EfSC lacks some useful features other IDEs provide:

  • Code auto-complete
  • Call tips for function and subroutine arguments
  • Automated element renaming
  • Auto-build (Makefile generation) for libraries

Target groups

Students

To setup the compiler path on every new project is annoying, especially for students in a Fortran course who create a lot of small projects frequently.

But they get a convenient auto-build environment with a graphical debugger. This is useful for bigger projects with external modules.

If students just have to deal with small projects of just one source file, a graphical debugger and auto-build or Git-integrity is not important. To avoid the use of the command-line (many people are afraid of) and normal editors I recommend the lightweight IDE Geany for this target group. It runs for one-file Fortran projects almost out-of-the box. Just switch from tab to spaces indentation in Edit > Preferences > Editor > Indentation > Type > Spaces.

But if these students go for Eclipse anyway I recommend to turn on the auto-build on save at PROJECT > PROPERTIES > Fortran Build > Build on rescource save (Auto build).

The pre-processing bug will not have an impact on these users.

If students work on medium projects beyond beginner Fortran courses the situation is different. Therefore EfSC can be useful.

Hobbyists, researcher, postgraduates

For medium scale projects the compiler path inconvenience is not a big deal. The auto-build and debugger features overcompensate this issue. Especially if they have to deal with HPC and can make use of the parallel-computing-capabilities of EfSC or the refactoring tools.

Unfortunately convenient features as code-autocompletion, automated element renaming, call tips for function and subroutine arguments, etc. are not included. Furthermore the auto-build feature cannot build libraries. You have to write them on your own or use external tools.

The preprocessing bug could have an impact.

But if they could afford 140,- USD they should give SimplyFortran a try. 30 day trial is available free of charge.

Professionals

I guess they will use a commercial IDE and compiler and/or use a different platform 😉 But EfSC has unique features for them. The synchronized projects if they work on code for supercomputers or clusters. And also the Parallel Tools Platform with parallel debugger, tools for MPI/OpenMP, etc.

Conclusion

Eclipse for Scientific Computing is the best non-commercial Fortran IDE for macOS. It is cross-plattform, so you can use it on all systems you are on, not only macOS.

For High Performance Computing (HPC) the synchronized projects make it unique, even on other platforms. Also an enormous plus is the Parallel Tools Platform with its parallel debugger and MPI/OpenMP integration, if you need this. But where there is light there is shadow also.

For a student who just has to handle a lot but small one file projects in a Fortran course, Eclipse is maybe to much hassle due to  project configuration.

For medium scale developer outside the HPC some convenient features other IDEs provide are missing. But it is still a good IDE for macOS for this target group. On other platforms Code::Blocks for Fortran is maybe a better alternative. But we are here on a Mac. Maybe a commercial IDE fits the whole, like SimplyFortran.

For HPC-developer Eclipse for Scientific Computing is for them. The parallel tools and remote development capabilities to let run your code on a remote supercomputer supports them. But I am not such a developer.

 

Leave a Reply

Your email address will not be published.