Getting Started with Standard Make
This tutorial demands almost no knowledge of elcipse, make and fortran. Here emphasis is layed on learning how to perform basic tasks while quickly navigating through the different wizards and windows, which otherwise could consume a lot of time and attention. In more advanced tutorials hints to basic shortcuts will be omitted.
Contents
Setting up the project "hello"
Start the "New: Select a wizard" from „File > New > Other“(Hint: Hitting "Ctrl+n" gets you there faster).
Select „Fortran Project“ (Hint: Insert >"Fotran" in the 'Wizards' field, then Fortran can be selected by clicking 2 times "tab" and "arrow down" ). Now go to the next Page (Hint: Press "Alt+n").
Type >"hello" in the „Project name“. It will be used as the folder. Select the project type: "Make project > Empty Project" and „GCC Tool Chain“. (Here again: 2 times "tab" to go to „Project type“, then the "arrow keys" and „+“ to open "Make project > Empty Project" . Press „tab“ to select „GCC Tool Chain“). Press "return" to finish (if it asks whether to open the associated perspective, select „Remember my decision“ and „Yes“).
Instering the first "hello world" program hello.f90
As before start the "New:Select a wizard". Then select „Fortran > Source File“ (Hint: Insert >"source"; 2 x "tab" + arrows to "Fortran > Source File"). Hit „return“ to go to "Next".
Insert hello.f90 to be the name of the file. "Browse" ("Alt+O") to the folder "hello". "Alt+f“, „return" to finish, then paste this program:
program hello print *, "hello world" end
Creating the make file
Once again open the "New:Select a wizard". Select "General > Untitled Text File" and paste the following in the new tab
all : gfortran hello.f90
(Beware! Not Whitespaces but "tab" in second line)
Now save the modified text file ("Ctrl + s"). Enter makefile as a filename. Insert hello in the parent folder cell ("Alt + e") and save it.
Building and testing the program
Press "Alt + p", „b“ to build the project. "Ctrl + F11" and "Enter" to run resulting binary (the selection C/C++ | Fortran, and the debugger is only important for debugging purposes, so you can just hit enter twice).
Introducing modules
Create the new „Fortran > Source file“ > module1.f90 (Source Folder should already be selected correctly), hit "enter". Paste
module module1 contains subroutine hi() print *, "hi from module1" end subroutine end
and save it.
Change to the "hello.f90" tab ("Ctrl + Page Up"). Select all ("Ctrl + a") and replace by
program hello use module1 print *, "hello world" call hi end
and don't forget to save it.
Change the tab to "makefile". Change it in the following way:
all : gfortran module1.f90 hello.f90
Build and test the program in one operation, by simply pressing "Ctrl + F11"
Managing multiple executables and modules
Create new sourcefile "bye.f90", and fill it with
program bye use module1 call hi print *, "and bye" end program
Change the makefile to
all : hello bye module1.mod : module1.f90 gfortran -c module1.f90 module1.o : module1.f90 gfortran -c module1.f90 hello : module1.o hello.o gfortran -o hello module1.o hello.o hello.o : module1.mod hello.f90 gfortran -c hello.f90 bye : module1.o bye.o gfortran -o bye module1.o bye.o bye.o : module1.mod bye.f90
gfortran -c bye.f90
Build the project. Then select "hello - [x86/Ie]" in the "Fortran Project" bar. Press on the run-button (white triangle in a green circle) to test it. Select "bye - [x86/Ie]" and run it.
You should see something like
hi from module1 and bye
To find out how you can manage modules without editing the makefile proceed to the Getting Started with Managed Make tutorial.