Fortran1
Fortran1: The Basics
We'll forge our path through the verdant garden of Fortran90 using a number of examples. To get your copy of these examples, from the version control repository, login to your favourite linux machine (perhaps dylan), and type:
svn co http://source.ggy.bris.ac.uk/subversion/fortran1/trunk --username=guest ./fortran1
hello, world
Without further ado, and in-keeping with the most venerable of traditions, let's meet our first example--"hello, world":
cd fortran1/examples/example1
and type:
make
Now type:
./hello_world.exe
Bingo! You've just compiled and run, perhaps your first, Fortran90 program. Hurrah! we're on our way:) Everybody whoop! Yeehah!
OK, OK...you'd better reign in your excitement. This is serious you know!:)
Enough of the magic, let's take a look inside the source code file. Open-up hello_world.f90, using cat, less, more or your favourite text editor, and you'll see:
! ! This is a comment line. ! Below is a simple 'hello, world' program written in Fortran90. ! It illustrates creating a main 'program' unit together ! with good habits, such as using 'implicit none' and comments. ! program hello_world implicit none write(*,*) "hello, world" end program hello_world
We have:
- some comment lines, giving us a helpful narrative
- the start of the main program unit
- the implicit none statement (more of this in a moment)
- a write statement, printing our greeting to the screen
- and last, but not least, the end of the main program.