Learning Fortran: Compilers, Debugging & More

  • Context: Fortran 
  • Thread starter Thread starter Sievers
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary
SUMMARY

This discussion focuses on setting up a development environment for Fortran 90/95, specifically for users transitioning from Matlab. Key components include selecting a suitable code editor, compiler (g95 or gfortran), and a debugging environment. The installation process involves writing code in an editor, compiling it, and linking it to create an executable. The importance of a debugger is emphasized for troubleshooting logical errors post-compilation.

PREREQUISITES
  • Familiarity with programming concepts and syntax
  • Understanding of compilers and linkers
  • Basic knowledge of debugging techniques
  • Experience with text editors for coding
NEXT STEPS
  • Research the differences between g95 and gfortran compilers for Fortran
  • Explore various code editors suitable for Fortran development
  • Learn about debugging tools and environments compatible with Fortran
  • Find additional resources such as tutorials and books on Fortran programming
USEFUL FOR

Students, researchers, and developers transitioning to Fortran from other programming languages, particularly those with a background in Matlab.

Sievers
Messages
1
Reaction score
0
Hi guys

Im quite proficient when it comes to Matlab, and am now scheduled to learn Fortran 90/95 for a PhD-project (OS: winXP/win7) and I want to ease the transition as much as possible. I have been scouring the internet to learn more about what I am faced with and one thing keeps bugging me: While there seem to be plenty of tutorials explaining how the language itself works (I have recently gotten the "Fortran 95/2003 explained" book as well), there seem to be little or no information on how to set everything up to run. Which surprises me as this seems to not just be a simple "Install and use" program. By now I understand that the compiler is the 'engine', into which code must be thrown, for an eventual output. So i guess my question is simply:

  • In which program should I then write my code? (Cygwin is a name that keeps popping up but I also understand that there are several alternatives?)
  • Which compiler should I use (g95, gfortran, etc? All documentation and opinions I find are from 2007 and back, so I guess much have changed)
  • I read somewhere that a debugging environment would be needed as well? Which, and where can I learn more?
  • Is the installation process simply just what I listed above? "Code-editor -> Compiler -> Debugger"?
  • Also, apart from the book I already purchased, do you have any valuable suggestions (tutorials, other books, etc.) as how to best go around learning Fortran.

Thanks in advance!
 
Technology news on Phys.org
No one has responded, so I'll put in my 2 cents.
Sievers said:
Hi guys

Im quite proficient when it comes to Matlab, and am now scheduled to learn Fortran 90/95 for a PhD-project (OS: winXP/win7) and I want to ease the transition as much as possible. I have been scouring the internet to learn more about what I am faced with and one thing keeps bugging me: While there seem to be plenty of tutorials explaining how the language itself works (I have recently gotten the "Fortran 95/2003 explained" book as well), there seem to be little or no information on how to set everything up to run. Which surprises me as this seems to not just be a simple "Install and use" program. By now I understand that the compiler is the 'engine', into which code must be thrown, for an eventual output.
Right. A Fortran development system is not just a program - it consists of at the least a compiler and linker. The compiler translates your Fortran code to object code, and the linker combines your object code with other code you used, and produces an executable.
Sievers said:
So i guess my question is simply:

  • In which program should I then write my code? (Cygwin is a name that keeps popping up but I also understand that there are several alternatives?)
  • Which compiler should I use (g95, gfortran, etc? All documentation and opinions I find are from 2007 and back, so I guess much have changed)
  • I read somewhere that a debugging environment would be needed as well? Which, and where can I learn more?
  • Is the installation process simply just what I listed above? "Code-editor -> Compiler -> Debugger"?
  • Also, apart from the book I already purchased, do you have any valuable suggestions (tutorials, other books, etc.) as how to best go around learning Fortran.

Thanks in advance!

The code you write is a text file, so anything from Notepad or equivalent on up can be used.
The last Fortran compiler I used was about 15 years ago, and was from Lahey. I don't have any experience with the compilers you listed, so can't make any recommendations.
A debugging environment isn't an absolute requirement, but I wouldn't want to try to write programs without one.

The development process for an application you write (as opposed to installing the development tools) is 1) write code in editor --> 2) compile code --> 3) link code. If the compiler finds errors, you use the information the compiler gives you to go back to step 1. After all semantic errors are fixed, it's possible that you have linker errors, which also need to be fixed.

After you get an executable (no compiler errors or linker errors) it's possible you have errors in logic that cause your application to produce erroneous results. That's where the debugger comes in handy, allowing you to single-step through the code to verify that the appropriate values are being calculated.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 17 ·
Replies
17
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
6
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K