# Create the source code
cat << Eof > HelloWorld.f90
program helloworld_mpi_omp
use mpi
use omp_lib
implicit none
integer :: rank, thread, provided, ierr
integer(kind=omp_lock_kind) :: io_lock
call omp_init_lock(io_lock)
call MPI_Init(ierr)
call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
!\$omp parallel private(thread)
thread = omp_get_thread_num()
call omp_set_lock(io_lock)
print *, 'HelloWorld from rank ', rank, ' thread ', thread
call omp_unset_lock(io_lock)
!\$omp end parallel
call omp_destroy_lock(io_lock)
call MPI_Finalize(ierr)
end program helloworld_mpi_omp
Eof
# Note: change !\$omp to !$omp if you type the above code by hand.
module purge
module load craype-x86-milan
module load PrgEnv-intel
# or
# module load cpeIntel/23.09
# Compile the source file 'HelloWorld.cpp'
ftn -craype-verbose -o hello.exe HelloWorld.f90 -fopenmp
# Run the program
srun -p compute-devel -N1 -n4 -c2 hello.exe |