Programming/Fortran

From HPC
Revision as of 15:21, 30 January 2017 by Pysdlb (talk | contribs) (Created page with "== Programming Details == Fortran (formerly FORTRAN, derived from Formula Translation) is a general-purpose, imperative programming language that is especially suited to nume...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation , search

Programming Details

Fortran (formerly FORTRAN, derived from Formula Translation) is a general-purpose, imperative programming language that is especially suited to numeric computation and scientific computing.


Programming example

program variableTesting
implicit none

   ! declaring variables
   integer :: total,average
   complex :: cx
   logical :: done
   character(len=80) :: message ! a string of 80 characters

   !assigning values
   total = 20000
   average = 1666
   done = .true.
   message = "A big Hello from HPC"

   cx = (3.0, 5.0) ! cx = 3.0 + 5.0i

        if (total .ge. average) then
                print *, total, " greater or equal than average"
        else
                print *, total, " less than average"
        endif

   Print *, average
   Print *, cx
   Print *, done
   Print *, message

end program variableTesting

Compilation

The program would be compiled in the following way, optional Intel compiler available too:


module load gcc/4.9.3
gfortran -o testFortran  testFortran.f03