test_corners Subroutine

public subroutine test_corners(this)

Arguments

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

Calls

proc~~test_corners~~CallsGraph proc~test_corners test_corners ESMF_GridGetCoord ESMF_GridGetCoord proc~test_corners->ESMF_GridGetCoord ims ims proc~test_corners->ims jms jms proc~test_corners->jms lats lats proc~test_corners->lats lons lons proc~test_corners->lons mpiassertequal mpiassertequal proc~test_corners->mpiassertequal mpiasserttrue mpiasserttrue proc~test_corners->mpiasserttrue none~getlocalpet ESMF_TestCase%getLocalPET proc~test_corners->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_corners(this)
      class (Test_LatLonCorners), intent(inout) :: this

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

      integer :: petX, petY
      integer :: i_1, i_n, j_1, j_n

      select type (p => this%testParameter)
      type is (GridCase)
         petX = mod(this%getLocalPET(), p%nx)
         petY = this%getLocalPET() / p%nx

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

         i_1 = 1 + sum(p%ims(:petX))
         i_n = sum(p%ims(:petX+1))
         if (p%dateline == 'XY') then
            if (petX+1 == size(p%ims)) i_n = i_n + 1
         end if
         j_1 = 1 + sum(p%jms(:petY))
         j_n = sum(p%jms(:petY+1))
         if (petY+1==size(p%jms)) j_n=j_n+1
      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(p%lons(i_1:i_n), corners(:,1)*MAPL_RADIANS_TO_DEGREES, message='Wrong corners X.', tolerance=1.d-5)
      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(p%lats(j_1:j_n), corners(1,:)*MAPL_RADIANS_TO_DEGREES, message='Wrong corners Y.', tolerance=1.d-5)
      end select
      
   end subroutine test_corners