test_shape Subroutine

public subroutine test_shape(this)

Arguments

Type IntentOptional Attributes Name
class(Test_LatLonCorners), intent(inout) :: this

Calls

proc~~test_shape~2~~CallsGraph proc~test_shape~2 test_shape ESMF_GridGetCoord ESMF_GridGetCoord proc~test_shape~2->ESMF_GridGetCoord mpiassertequal mpiassertequal proc~test_shape~2->mpiassertequal mpiasserttrue mpiasserttrue proc~test_shape~2->mpiasserttrue none~getlocalpet ESMF_TestCase%getLocalPET proc~test_shape~2->none~getlocalpet ESMF_VMGet ESMF_VMGet none~getlocalpet->ESMF_VMGet none~getvm ESMF_TestCase%getVM none~getlocalpet->none~getvm ESMF_GridCompGet ESMF_GridCompGet none~getvm->ESMF_GridCompGet

Source Code

   subroutine test_shape(this)
      class (Test_LatLonCorners), intent(inout) :: this

      integer :: status
      integer, parameter :: SUCCESS = 0
      real(ESMF_KIND_R8), pointer :: corners(:,:)

      integer :: petX, petY
      integer, allocatable :: imc(:), jmc(:)

      select type (p => this%testParameter)
      type is (GridCase)

         petX = mod(this%getLocalPET(), p%nx)
         petY = this%getLocalPET() / p%nx

         allocate(imc(size(p%ims)),jmc(size(p%jms)))
         imc = p%ims
         jmc = p%jms
         select type (p => this%testParameter)
         type is (GridCase)
            if (p%dateline == 'XY') then
               if (petX+1 == size(p%ims)) imc(petY+1)=imc(petX+1)+1
            end if
         end select
         if (petY+1 == size(p%jms)) jmc(petY+1)=jmc(petY+1)+1

         @mpiAssertTrue(petX >= 0)
         @mpiAssertTrue(petX < size(p%ims))
         @mpiAssertTrue(petY >= 0)
         @mpiAssertTrue(petY < size(p%jms))
      end select

      ! X
      call ESMF_GridGetCoord(this%grid, coordDim=1, staggerLoc=ESMF_STAGGERLOC_CORNER, &
           & farrayPtr=corners, rc=status)
      @mpiAssertTrue(status==SUCCESS, message='Failed to get grid x corners.')

      select type (p => this%testparameter)
      type is (GridCase)
         @mpiAssertEqual([imc(petX+1),jmc(petY+1)], shape(corners), message='Wrong shape.')
      end select

      ! Y
      call ESMF_GridGetCoord(this%grid, coordDim=2, staggerLoc=ESMF_STAGGERLOC_CORNER, &
           & farrayPtr=corners, rc=status)
      @mpiAssertTrue(status==SUCCESS, message='Failed to geet grid x corners.')

      select type (p => this%testparameter)
      type is (GridCase)
         @mpiAssertEqual([imc(petX+1),jmc(petY+1)], shape(corners), message='Wrong shape.')
      end select

      select type (p => this%testparameter)
      type is (GridCase)
         deallocate(imc,jmc)
      end select
      
   end subroutine test_shape