ArrDescrCreateWriterComm Subroutine

public subroutine ArrDescrCreateWriterComm(arrdes, full_comm, num_writers, rc)

Arguments

Type IntentOptional Attributes Name
type(ArrDescr), intent(inout) :: arrdes
integer, intent(in) :: full_comm
integer, intent(in) :: num_writers
integer, intent(out), optional :: rc

Calls

proc~~arrdescrcreatewritercomm~~CallsGraph proc~arrdescrcreatewritercomm ArrDescrCreateWriterComm interface~mapl_assert MAPL_Assert proc~arrdescrcreatewritercomm->interface~mapl_assert mpi_bcast mpi_bcast proc~arrdescrcreatewritercomm->mpi_bcast mpi_comm_rank mpi_comm_rank proc~arrdescrcreatewritercomm->mpi_comm_rank mpi_comm_split mpi_comm_split proc~arrdescrcreatewritercomm->mpi_comm_split proc~mapl_return MAPL_Return proc~arrdescrcreatewritercomm->proc~mapl_return proc~mapl_verify MAPL_Verify proc~arrdescrcreatewritercomm->proc~mapl_verify at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception

Called by

proc~~arrdescrcreatewritercomm~~CalledByGraph proc~arrdescrcreatewritercomm ArrDescrCreateWriterComm proc~mapl_esmfstatereadfromfile MAPL_ESMFStateReadFromFile proc~mapl_esmfstatereadfromfile->proc~arrdescrcreatewritercomm proc~mapl_genericfinalize MAPL_GenericFinalize proc~mapl_genericfinalize->proc~arrdescrcreatewritercomm proc~mapl_genericrecord MAPL_GenericRecord proc~mapl_genericrecord->proc~arrdescrcreatewritercomm proc~mapl_genericstatesave MAPL_GenericStateSave proc~mapl_genericstatesave->proc~arrdescrcreatewritercomm proc~mapl_genericstatesave->proc~mapl_genericstatesave proc~mapl_genericinitialize MAPL_GenericInitialize proc~mapl_genericinitialize->proc~mapl_esmfstatereadfromfile proc~mapl_genericrefresh MAPL_GenericRefresh proc~mapl_genericrefresh->proc~mapl_esmfstatereadfromfile proc~mapl_genericrefresh->proc~mapl_genericrefresh proc~mapl_genericstaterestore MAPL_GenericStateRestore proc~mapl_genericstaterestore->proc~mapl_esmfstatereadfromfile proc~mapl_genericstaterestore->proc~mapl_genericstaterestore

Source Code

    subroutine ArrDescrCreateWriterComm(arrdes, full_comm, num_writers, rc)
       type(ArrDescr), intent(inout) :: arrdes
       integer, intent(in) :: full_comm
       integer, intent(in) :: num_writers
       integer, optional, intent(out) :: rc

       integer :: status, nx, ny, color, ny_by_writers, myid, j, writer_rank

       nx = size(arrdes%i1)
       ny = size(arrdes%j1)
       _ASSERT(num_writers <= ny,'num writers must be less or equal to than NY')
       _ASSERT(mod(ny,num_writers)==0,'num writerss must evenly divide NY')
       call mpi_comm_rank(full_comm,myid, status)
       _VERIFY(status)
       color =  arrdes%NX0
       call MPI_COMM_SPLIT(full_comm, color, MYID, arrdes%Ycomm, status)
       _VERIFY(status)
       color = arrdes%NY0
       call MPI_COMM_SPLIT(full_comm, color, MYID, arrdes%Xcomm, status)
       _VERIFY(status)
       ny_by_writers = ny/num_writers
       if (mod(myid,nx*ny/num_writers) == 0) then
          color = 0
       else
          color = MPI_UNDEFINED
       endif
       call MPI_COMM_SPLIT(full_comm, color, myid, arrdes%writers_comm, status)
       _VERIFY(status)
       if (num_writers==ny) then
          arrdes%IOgathercomm = arrdes%Xcomm
       else
            j = arrdes%NY0 - mod(arrdes%NY0-1,ny_by_writers)
          call MPI_COMM_SPLIT(full_comm, j, myid, arrdes%IOgathercomm, status)
          _VERIFY(status)
       endif
       if (arrdes%writers_comm /= MPI_COMM_NULL) then
          call mpi_comm_rank(arrdes%writers_comm,writer_rank,status)
          _VERIFY(STATUS)
       end if
       call MPI_BCast(writer_rank,1,MPI_INTEGER,0,arrdes%iogathercomm,status)
       _VERIFY(STATUS)
       arrdes%writer_id = writer_rank

       _RETURN(_SUCCESS)

    end subroutine ArrDescrCreateWriterComm