28#if defined DISTRIBUTE && defined DISJOINTED
29 PUBLIC :: split_communicator
30 PUBLIC :: assign_communicator
67#if defined ATM_COUPLING && defined MCT_LIB
74#if defined WAV_COUPLING && defined MCT_LIB
102 integer,
allocatable ::
proc(:,:,:)
113#if defined DISTRIBUTE && defined PROFILE
127# if defined DISJOINTED || \
128 (defined pio_lib && \
129 (defined asynchronous_pio || defined asynchronous_scorpio))
133# if defined DISJOINTED
134 logical :: fullmaster
136 integer :: forkcolor = -1
140 integer :: nsubgroups
141 integer :: taskcolor = -1
145# if defined PIO_LIB && \
146 (defined asynchronous_pio || defined asynchronous_scorpio)
167# if defined PIO_LIB && defined DISTRIBUTE && \
168 (defined asynchronous_pio || defined asynchronous_scorpio)
169 integer :: peer_comm_world
170 integer :: inter_comm_world
171 integer :: io_comm_world
174 integer :: full_comm_world
175 integer :: fork_comm_world
176 integer :: task_comm_world
187# ifdef DOUBLE_PRECISION
189 integer,
parameter ::
mp_float = mpi_double_precision
194 integer,
parameter ::
mp_float = mpi_real
218 integer,
intent(in) :: ngrids
236 IF (.not.
allocated(
proc))
THEN
237 allocate (
proc(0:1,4,ngrids) )
238 proc(0:1,1:4,1:ngrids)=0
241 IF (.not.
allocated(
cstr))
THEN
246 IF (.not.
allocated(
cend))
THEN
252 IF (.not.
allocated(
csum))
THEN
263#if defined DISTRIBUTE && defined PROFILE
292 IF (
allocated(
proc))
deallocate (
proc )
293 IF (
allocated(
cstr))
deallocate (
cstr )
294 IF (
allocated(
cend))
deallocate (
cend )
297 IF (
allocated(
csum))
deallocate (
csum )
331 CALL omp_set_dynamic (.false.)
346#elif defined DISTRIBUTE
358 IF (myerror.ne.0)
THEN
360 10
FORMAT (/,
' ROMS - Unable to inquire number of', &
361 &
' processors in the group.')
403#if defined DISTRIBUTE && defined DISJOINTED
405 SUBROUTINE split_communicator (Nsplit, Ntasks)
447 integer,
intent(in) :: nsplit, ntasks
451 integer :: myerror, mysize
452 integer :: i, lstr, serror
454 integer,
allocatable :: groupranks(:)
456 character (len=MPI_MAX_ERROR_STRING) :: string
468 CALL mpi_comm_rank (full_comm_world,
fullrank, myerror)
469 CALL mpi_comm_size (full_comm_world, fullsize, myerror)
498 nsubgroups=nsplit*ntasks
499 IF (mod(fullsize, nsubgroups).ne.0)
THEN
501 WRITE (
stdout,10) nsubgroups, fullsize
509 CALL mpi_comm_split (full_comm_world, forkcolor, forkkey, &
510 & fork_comm_world, myerror)
511 IF (myerror.ne.mpi_success)
THEN
512 CALL mpi_error_string (myerror, string, lstr, serror)
513 WRITE (
stdout,20)
'MPI_COMM_SPLIT',
'TASK_COMM_WORLD', &
524 IF (ntasks.gt.1)
THEN
525 tasksize=fullsize/ntasks
528 CALL mpi_comm_split (full_comm_world, taskcolor, taskkey, &
529 & task_comm_world, myerror)
530 IF (myerror.ne.mpi_success)
THEN
531 CALL mpi_error_string (myerror, string, lstr, serror)
532 WRITE (
stdout,20)
'MPI_COMM_SPLIT',
'TASK_COMM_WORLD', &
537 CALL mpi_comm_rank (task_comm_world,
taskrank, myerror)
539 task_comm_world=full_comm_world
546 10
FORMAT (/,
' SPLIT_COMMUNICATOR - illegal configuration, ', &
547 &
'Nsplit * Ntasks = ',i0,/,22x, &
548 &
'needs to be less, equal, or a multiple of the ', &
549 &
'communicator size, FullSize = ',i0,/,22x, &
550 &
'That is, MOD(FullSise, Nsplit*Ntask)=0')
551 20
FORMAT (/,
' SPLIT_COMMUNICATOR - error during ',a, &
552 &
' call, Comm = ',a,
', Rank = ',i0,
' Error = ',i0,/,22x,a)
555 END SUBROUTINE split_communicator
557 SUBROUTINE assign_communicator (choice)
573 character (len=*),
intent(in) :: choice
585 SELECT CASE (trim(choice))
586 CASE (
'FORK',
'SPLIT',
'CONCURRENT')
615 END SUBROUTINE assign_communicator
integer function my_threadnum()
integer function my_numthreads()
integer, parameter mp_double
integer, parameter mp_float
subroutine, public initialize_parallel
integer, dimension(:), allocatable first_tile
real(r8), dimension(:,:,:), allocatable cend
real(r8), dimension(:,:,:), allocatable cstr
real(r8), dimension(4) total_model
integer, dimension(:), allocatable last_tile
subroutine, public deallocate_parallel
integer, dimension(:,:,:), allocatable proc
subroutine, public allocate_parallel(ngrids)
real(r8), dimension(:,:,:), allocatable csum
integer, parameter nregion