Saturday, October 11, 2008

The main code to use mpi_distrbt

This is the example of the script you can insert in your main program to use mpi_istrbt.



max_ipara=bzq ! the maximum array dimension to be parallelized
if(MPImyid.eq.0)then ! do the distribution in main node only
write(6,*)' Master process #',MPImyid,' starting'
c
call mpi_distrbt(max_ipara,nummpiprocsm,
& MPInumprocs,ipara_ini_fin)
endif ! master processor selection
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
c
c THIS IS EXECUTED BY ALL (MASTER+SLAVE) PROCESSORS
c
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
write(6,*)' Slave process #',MPImyid,' starting'
c blocking receive of integer data
icount=2*MPInumprocs
iroot=0
call MPI_BCAST(ipara_ini_fin, icount, MPI_INTEGER, iroot,
& MPI_COMM_WORLD, ierr)

c call the serial version
ipara_ini=ipara_ini_fin(1,MPImyid)
ipara_fin=ipara_ini_fin(2,MPImyid)

write(6,*)'Slave #',MPImyid,
& ' computing from ipara ',ipara_ini,' to ',ipara_fin

No comments: