How to download and install Fortran
To get started with using Fortran you need a compiler compatible with your desired Fortran version. NTNU has an educational license for NAG Fortran builder, and it supports FORTRAN 90 with most of the implementations from FORTRAN 2008. For a guide to dowloading and setting up licensing properly visit NTNU softwares pages (link).
Getting started with Fortran
In the Fortran builder most work is done in projects. The project folder should contain all the files for the current project, including input and output files.
Creating your first project
- After opening the program for the first time, go to file → new → new project and the "create project" menu will open
- Recommended project type for first time users is "Console Application" but there are others options
- Console Application: A Fortran program or application that uses a console window for i/o.
- Static Library: A library of routines that can be statically linked into a program
- Simdem Application: A Fortran program or application that uses the Simdem library for plotting or menu based programming. There are over 60 template programs provided.
- Lapack Application: A Fortran program or application that uses the Lapack linear algebra library. NAG provide over 15 templates with several examples per template.
- Dynamic Link Library: A library that can be linked to dynamically by a program or application. The program can be written in another language, e.g. C++ Visual Basic. The application could be Excel or Matlab for example.
- You can either look at the templates for "Console Application" or create a blank project.
Creating a new file
- After creating a project. You need to create a file. File→new→ file (ctrl+N)
- To create a fortran script choose a .f90 file (Fortran90). It's common practice to name the first file in a program "main"
- You are now ready to start programming in Fortran.
Hello World
Copy the code snippet bellow to create your first program. It will print "Hello world" to the i/o window.
program main implicit none print *, 'Hello World' end program
Execute a program
To run a script click the lightning symbol on the toolbar. This will execute the script without debugging features. The play button next to the lightning will execute the script with debugging features
Useful tutorials
- Fortran in action (example)
- Nice introduction to programming by fortrantutorial.com (PDF)
- Including C++ functions in Fortran
- Original documentation for Fortran 90