Skip to content

Commit d5b2497

Browse files
committed
Add basic unit test for new cubed sphere calc type. Also, fix a few things.
1 parent 9c94056 commit d5b2497

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed

src/Infrastructure/Grid/interface/ESMF_Grid.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14829,7 +14829,7 @@ function ESMF_GridCreateCubedSphereReg(tileSize,keywordEnforcer, &
1482914829
else
1483014830
coordTypeKindLocal=ESMF_TYPEKIND_R8
1483114831
endif
14832-
14832+
1483314833
! Set default coord. calc. flag
1483414834
coordCalcFlagLocal=ESMF_CUBEDSPHERECALC_1TILE
1483514835
if (present(coordCalcFlag)) coordCalcFlagLocal= coordCalcFlag
@@ -14994,7 +14994,7 @@ function ESMF_GridCreateCubedSphereReg(tileSize,keywordEnforcer, &
1499414994

1499514995
! Set coordinate calc method balop's[ed on flag (by setting local_algorithm switch)
1499614996
local_algorithm=.false.
14997-
if (coordCalcFlag == ESMF_CUBEDSPHERECALC_LOCAL) local_algorithm=.true.
14997+
if (coordCalcFlagLocal == ESMF_CUBEDSPHERECALC_LOCAL) local_algorithm=.true.
1499814998

1499914999
! Generate glocal edge coordinates and local center coordinates
1500015000
if (docenter .and. docorner) then
@@ -15493,7 +15493,7 @@ function ESMF_GridCreateCubedSphereIReg(tileSize, &
1549315493

1549415494
! Set coordinate calc method balop's[ed on flag (by setting local_algorithm switch)
1549515495
local_algorithm=.false.
15496-
if (coordCalcFlag == ESMF_CUBEDSPHERECALC_LOCAL) local_algorithm=.true.
15496+
if (coordCalcFlagLocal == ESMF_CUBEDSPHERECALC_LOCAL) local_algorithm=.true.
1549715497

1549815498
! Generate glocal edge coordinates and local center coordinates
1549915499
if (docenter .and. docorner) then

src/Infrastructure/Grid/tests/ESMF_GridCreateUTest.F90

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2871,7 +2871,7 @@ program ESMF_GridCreateUTest
28712871

28722872
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
28732873
!-----------------------------------------------------------------------------
2874-
2874+
28752875
!-----------------------------------------------------------------------------
28762876
!NEX_UTest
28772877
write(name, *) "Testing GridCreateCubedSphere with SchmidtTransform"
@@ -3313,6 +3313,59 @@ program ESMF_GridCreateUTest
33133313
call ESMF_Test(((rc.eq.ESMF_SUCCESS) .and. correct), name, failMsg, result, ESMF_SRCLINE)
33143314

33153315

3316+
!-----------------------------------------------------------------------------
3317+
!NEX_UTest
3318+
write(name, *) "Testing GridCreateCubedSphere with calcCoordType=ESMF_CUBEDSPHERECALC_LOCAL"
3319+
write(failMsg, *) "Incorrect result"
3320+
3321+
! create grid
3322+
rc=ESMF_SUCCESS
3323+
grid=ESMF_GridCreateCubedSphere(15, &
3324+
staggerLocList = (/ESMF_STAGGERLOC_CENTER, ESMF_STAGGERLOC_CORNER/), &
3325+
coordCalcFlag=ESMF_CUBEDSPHERECALC_LOCAL, rc=localrc)
3326+
if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
3327+
3328+
3329+
! Write to make sure it looks ok
3330+
call ESMF_GridCellWriteVTK(grid, "csGrid", rc=localrc)
3331+
if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
3332+
3333+
! Loop through just making sure coordinates are there
3334+
call ESMF_GridGet(grid, localDECount=localDECount, rc=localrc)
3335+
if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
3336+
3337+
do lde = 0, localDECount-1
3338+
3339+
call ESMF_GridGetCoord(grid, coordDim=1, localDE=lde, farrayPtr=fptr1, &
3340+
exclusiveLBound=exlbnd, exclusiveUBound=exubnd, rc=localrc)
3341+
if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
3342+
call ESMF_GridGetCoord(grid, coordDim=2, localDE=lde, farrayPtr=fptr2, &
3343+
exclusiveLBound=exlbnd, exclusiveUBound=exubnd, rc=localrc)
3344+
if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
3345+
3346+
#if 0
3347+
print *, "coords from de", lde
3348+
3349+
print *, "lower bounds = [", exlbnd(1), ", ", exlbnd(2), "]"
3350+
print *, "upper bounds = [", exubnd(1), ", ", exubnd(2), "]"
3351+
3352+
print *, "["
3353+
do j = 1, exubnd(1)
3354+
do i = 1, exubnd(2)
3355+
print *, "[", fptr1(i,j), ", ", fptr2(i,j), "]"
3356+
enddo
3357+
enddo
3358+
print *, "]"
3359+
#endif
3360+
enddo
3361+
3362+
! destroy grid
3363+
call ESMF_GridDestroy(grid, rc=localrc)
3364+
if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
3365+
3366+
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
3367+
!-----------------------------------------------------------------------------
3368+
33163369
!-----------------------------------------------------------------------------
33173370
! Stop testing
33183371
call ESMF_TestEnd(ESMF_SRCLINE)

0 commit comments

Comments
 (0)