Exercise 0: cputime
The following code only has one active process at any time - can you see
why?
Compile (ifort exer0.f90 -o exer0 -lmpi) and run with
> qsub -q express -lncpus=4,walltime=0:02:00,vmem=450mb -wd
mpirun ./exer0
ctrl-d
and check the cpu usage of all processes using qps jobid.
(Redo this exercise with Vampir later.)
program exer0
implicit none
include 'mpif.h'
integer :: mpirank, mpisize, err, i, j
real(8) :: s
call MPI_Init(err)
call MPI_Comm_rank(MPI_COMM_WORLD, mpirank, err)
call MPI_Comm_size(MPI_COMM_WORLD, mpisize, err)
s = 0.0
do i=0, mpisize-1
if (i == mpirank) then
do j=1, 50000000
s = s + log(sqrt(1.1+cos(0.00001*j+mpirank)))
end do
write(*,*) s
end if
call MPI_Barrier(MPI_COMM_WORLD, err)
end do
call MPI_Finalize(err)
end program exer0
|