MAPL_GetImsJms Subroutine

public subroutine MAPL_GetImsJms(Imins, Imaxs, Jmins, Jmaxs, Ims, Jms, rc)

Uses

  • proc~~mapl_getimsjms~~UsesGraph proc~mapl_getimsjms MAPL_GetImsJms module~mapl_sortmod MAPL_SortMod proc~mapl_getimsjms->module~mapl_sortmod iso_fortran_env iso_fortran_env module~mapl_sortmod->iso_fortran_env module~mapl_exceptionhandling MAPL_ExceptionHandling module~mapl_sortmod->module~mapl_exceptionhandling module~mapl_errorhandlingmod MAPL_ErrorHandlingMod module~mapl_exceptionhandling->module~mapl_errorhandlingmod module~mapl_throwmod MAPL_ThrowMod module~mapl_exceptionhandling->module~mapl_throwmod module~mapl_errorhandlingmod->module~mapl_throwmod mpi mpi module~mapl_errorhandlingmod->mpi

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:) :: Imins
integer, intent(in), dimension(:) :: Imaxs
integer, intent(in), dimension(:) :: Jmins
integer, intent(in), dimension(:) :: Jmaxs
integer, pointer :: Ims(:)
integer, pointer :: Jms(:)
integer, intent(out), optional :: rc

Calls

proc~~mapl_getimsjms~~CallsGraph proc~mapl_getimsjms MAPL_GetImsJms interface~mapl_assert MAPL_Assert proc~mapl_getimsjms->interface~mapl_assert interface~mapl_sort MAPL_Sort proc~mapl_getimsjms->interface~mapl_sort proc~mapl_return MAPL_Return proc~mapl_getimsjms->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_getimsjms->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~~mapl_getimsjms~~CalledByGraph proc~mapl_getimsjms MAPL_GetImsJms none~set~92 MaplGrid%set none~set~92->proc~mapl_getimsjms proc~get_esmf_grid_layout get_esmf_grid_layout proc~get_esmf_grid_layout->proc~mapl_getimsjms proc~mapl_genericinitialize MAPL_GenericInitialize proc~mapl_genericinitialize->proc~mapl_getimsjms proc~mapl_gridget MAPL_GridGet proc~mapl_gridget->proc~mapl_getimsjms

Source Code

  subroutine MAPL_GetImsJms(Imins,Imaxs,Jmins,Jmaxs,Ims,Jms,rc)

!  Given lists of the min and max Is and Js in each processor
!  in a rectangular layout, it computes the number of elements
!  in each of the I columns and the number in each of the j
!  rows of the layout. Pointers Ims and Jms are allocated with the i and j
!  sizes of the layout (nx and ny) and filled with the IMs and JMs.

!  The four input lists must be in the same order, but the order
!  is arbitrary. Nx and Ny can be obtained from the sizes of
!  Ims and Jms, respectively


    use MAPL_SortMod

    integer, dimension(:), intent(IN   ) :: Imins,Imaxs,Jmins,Jmaxs
    integer, pointer                     :: Ims(:),Jms(:)
    integer, optional,   intent(out) :: rc

    integer              :: nx, ny, nx0, ny0, nde, k
    integer, allocatable :: Im0(:), Jm0(:)
    integer              :: minI,minJ ! in case the starting index is zero
    integer              :: status

    _ASSERT(.not.associated(Ims), 'Ims is associated and should not be.')
    _ASSERT(.not.associated(Jms), 'Jms is associated and should not be.')

!   The original minI and minJ are assumed to be 1
!   The index of EASE grid  is starting from 0
    minI = minval(Imins,DIM=1)
    minJ = minval(Jmins,DIM=1)
    nx = count(Jmins==minJ)
    ny = count(Imins==minI)

    allocate(Ims(nx),Jms(ny), __STAT__)
    allocate(Im0(nx),Jm0(ny), __STAT__)

    nde = size(Imins)

    nx0 = 1
    ny0 = 1

    do k=1,nde
       if(Imins(k)==minI) then
          Jms(ny0) = Jmaxs(k)-Jmins(k) + 1
          Jm0(ny0) = Jmins(k)
          if(ny0==ny) then
             exit
          else
             ny0 = ny0 + 1
          end if
       end if
    end do

    do k=1,nde
       if(Jmins(k)==minJ) then
          Ims(nx0) = Imaxs(k)-Imins(k) + 1
          Im0(nx0) = Imins(k)
          if(nx0==nx) then
             exit
          else
             nx0 = nx0 + 1
          end if
       end if
    end do

    call MAPL_Sort(Im0,Ims)
    call MAPL_Sort(Jm0,Jms)

    deallocate(Im0,Jm0,__STAT__)

    _RETURN(ESMF_SUCCESS)
  end subroutine MAPL_GetImsJms