MAPL_CFIOReadBundleWait Subroutine

public subroutine MAPL_CFIOReadBundleWait(MCFIO, RC)

Arguments

Type IntentOptional Attributes Name
type(MAPL_CFIO), intent(inout) :: MCFIO
integer, intent(out), optional :: RC

Calls

proc~~mapl_cfioreadbundlewait~~CallsGraph proc~mapl_cfioreadbundlewait MAPL_CFIOReadBundleWait esmf_fieldbundleget esmf_fieldbundleget proc~mapl_cfioreadbundlewait->esmf_fieldbundleget esmf_fieldget esmf_fieldget proc~mapl_cfioreadbundlewait->esmf_fieldget proc~mapl_collectivewait MAPL_CollectiveWait proc~mapl_cfioreadbundlewait->proc~mapl_collectivewait proc~mapl_return MAPL_Return proc~mapl_cfioreadbundlewait->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_cfioreadbundlewait->proc~mapl_verify proc~mapl_collectivewait->proc~mapl_return proc~mapl_collectivewait->proc~mapl_verify mpi_recv mpi_recv proc~mapl_collectivewait->mpi_recv mpi_wait mpi_wait proc~mapl_collectivewait->mpi_wait 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

Source Code

  subroutine MAPL_CFIOReadBundleWait(MCFIO,rc)

    type(MAPL_CFIO  ),               intent(INOUT) :: MCFIO
    integer,               optional, intent(  OUT) :: RC

    integer :: nn,k,l
    logical :: myGlobal

    type(ESMF_Field) :: field
    real, pointer    :: ptr3d(:,:,:) => null()
    integer          :: status

    nn = 0
    VARS: do L=1,size(MCFIO%VarDims)

       RANK: if (MCFIO%VarDims(L)==2) then

          nn=nn+1
          myGlobal = (mcfio%mype == mcfio%krank(nn))

          call MAPL_CollectiveWait(mcfio%reqs(nn),rc=status)
          _VERIFY(STATUS)
          if (myGlobal) then
             deallocate(mcfio%buffer(nn)%ptr)
          end if

       else if (MCFIO%VarDims(L)==3) then

          do k = 1,MCFIO%lm
             nn=nn+1
             myGlobal = (mcfio%mype == mcfio%krank(nn))
             call MAPL_CollectiveWait(mcfio%reqs(nn),rc=status)
             _VERIFY(STATUS)

             if (myGlobal) then
                deallocate(mcfio%buffer(nn)%ptr)
                !ALT these two have been cleaned earlier
                ! deallocate(mcfio%reqs(nn)%read_array)
                ! nullify(mcfio%reqs(nn)%read_array)
             end if
          end do

          if (mcfio%gsiMode) then
             call ESMF_FieldBundleGet(MCFIO%BUNDLE, trim(mcfio%varname(L)), field=FIELD, RC=STATUS)
             _VERIFY(STATUS)
             call ESMF_FieldGet(field,0,farrayptr=ptr3d,rc=status)
             call SwapV_(ptr3d)
          end if

       end if RANK

    end do VARS

    _RETURN(ESMF_SUCCESS)

    contains

   subroutine SwapV_(fld)
    implicit none
    real,intent(inout) ::  fld(:,:,:)
    real,allocatable   :: work(:,:,:)
    integer im, jm, km
    im   = size(fld,1)
    jm   = size(fld,2)
    km   = size(fld,3)
    allocate (work(im,jm,km))
    work = fld
    fld(:,:,km:1:-1) = work(:,:,1:km:+1)
    deallocate (work)
    end subroutine SwapV_

  end subroutine MAPL_CFIOReadBundleWait