Difference between revisions of "Fortran1"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
=Fortran1: The Basics= | =Fortran1: The Basics= | ||
− | We'll forge our path through the | + | 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: |
<pre> | <pre> | ||
Line 27: | Line 27: | ||
</pre> | </pre> | ||
− | '''Bingo!''' You've just compiled and run, perhaps your first, Fortran90 program. | + | '''Bingo!''' You've just compiled and run, perhaps your first, Fortran90 program. Hurrah! we're on our way:) Everybody whoop! |
+ | |||
+ | OK, you'd better reign in your excitement. 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: | ||
+ | |||
+ | <pre> | ||
+ | ! | ||
+ | ! 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 | ||
+ | </pre> | ||
+ | |||
+ | We have: | ||
+ | #some comment lines, giving us a helpful narrative | ||
+ | #the start of the '''main program unit''' | ||
+ | #the '''implicit none''' statement (more of that in a moment) | ||
+ | #a '''write''' statement, printing our greeting to the screen | ||
+ | #and last, but not least, the end of the main program. | ||
==Baskets and the Types of Things== | ==Baskets and the Types of Things== |
Revision as of 21:26, 31 January 2008
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!
OK, you'd better reign in your excitement. 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 that in a moment)
- a write statement, printing our greeting to the screen
- and last, but not least, the end of the main program.