wiki:cypress/Programming/FortranExamples/OpenMpFortran

Version 1 (modified by cmaggio, 10 years ago) ( diff )

migrated content from ccs wiki

OpenMP FORTRAN

Hello World

!hello_omp.f90: display a message on the screen 
program helloworld
  use omp_lib
  !
  integer::id, nthreads
  print *, "F90 Start"
  !
  !$omp parallel private(id) 
  id = omp_get_thread_num()
  print *,"hello from ", id
  !$omp barrier
  if (id == 0) then
     nthreads = omp_get_num_threads();
     print *,nthreads," threads said hello!"
  endif
  !$omp end parallel
  print *, "End"
end program helloworld

Compile with GNU Fortran

gfortran hello_omp.f90 -fopemp

Compile with PGI Fortran

pgf90 hello_omp.f90 -mp

Compile with Intel Fortran

ifort hello_omp.f90 -openmp

Examples of Jobscript

See Example

Note: See TracWiki for help on using the wiki.