test_centers Subroutine

public subroutine test_centers(this)

Arguments

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

Calls

proc~~test_centers~~CallsGraph proc~test_centers test_centers ESMF_GridGetCoord ESMF_GridGetCoord proc~test_centers->ESMF_GridGetCoord anyexceptions anyexceptions proc~test_centers->anyexceptions assert_that assert_that proc~test_centers->assert_that ims ims proc~test_centers->ims jms jms proc~test_centers->jms lats lats proc~test_centers->lats lons lons proc~test_centers->lons mpiassertequal mpiassertequal proc~test_centers->mpiassertequal mpiasserttrue mpiasserttrue proc~test_centers->mpiasserttrue none~getlocalpet ESMF_TestCase%getLocalPET proc~test_centers->none~getlocalpet sourcelocation sourcelocation proc~test_centers->sourcelocation 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_centers(this)
      class (Test_LatLonGridFactory), intent(inout) :: this

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

      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))
         j_1 = 1 + sum(p%jms(:petY))
         j_n = sum(p%jms(:petY+1))
      end select

      ! X
      call ESMF_GridGetCoord(this%grid, coordDim=1, staggerLoc=ESMF_STAGGERLOC_CENTER, &
           & farrayPtr=centers, _RC)

      select type (p => this%testparameter)
      type is (GridCase)
         @mpiAssertEqual(p%lons(i_1:i_n), centers(:,1)*MAPL_RADIANS_TO_DEGREES, message='Wrong centers X.', tolerance=1.d-5)
      end select

      ! Y
      call ESMF_GridGetCoord(this%grid, coordDim=2, staggerLoc=ESMF_STAGGERLOC_CENTER, &
           & farrayPtr=centers, _RC)

      select type (p => this%testparameter)
      type is (GridCase)
         @mpiAssertEqual(p%lats(j_1:j_n), centers(1,:)*MAPL_RADIANS_TO_DEGREES, message='Wrong centers Y.', tolerance=1.d-5)
      end select
      
   end subroutine test_centers