Skip to content

Commit 4c31b93

Browse files
authored
update test harness to support masks without the vectorized dimension being horizontal (fabm-model#66)
* update test harness to support masks without the vectorized dimension being horizontal * test/host: simplified check_surface/check_bottom mask treatment
1 parent 665ed01 commit 4c31b93

File tree

1 file changed

+40
-20
lines changed

1 file changed

+40
-20
lines changed

src/test/host.F90

+40-20
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ subroutine test_update(apply_mask, restrict_range)
849849
real(rke), pointer _DIMENSION_GLOBAL_ :: pdata
850850
real(rke), pointer _DIMENSION_GLOBAL_HORIZONTAL_ :: pdata_hz
851851
logical :: valid
852+
logical :: any_unmasked
852853

853854
call configure_range(randomize=restrict_range)
854855
call configure_mask(randomize=apply_mask)
@@ -1238,18 +1239,22 @@ subroutine test_update(apply_mask, restrict_range)
12381239
call apply_mask_2d(surface_state(_PREARG_HORIZONTAL_LOCATION_DIMENSIONS_ ivar), model%surface_state_variables(ivar)%missing_value)
12391240
end do
12401241

1242+
any_unmasked = .true.
12411243
call start_test('check_interior_state < min')
12421244
_BEGIN_OUTER_INTERIOR_LOOP_
12431245
call model%check_interior_state(_PREARG_INTERIOR_IN_ .true., valid)
12441246
#ifdef _HAS_MASK_
12451247
# ifdef _FABM_HORIZONTAL_MASK_
1246-
call assert(valid .neqv. any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))), 'check_interior_state', 'invalid result')
1248+
# if _FABM_VECTORIZED_DIMENSION_INDEX_==_FABM_DEPTH_DIMENSION_INDEX_
1249+
any_unmasked = _IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))
1250+
# else
1251+
any_unmasked = any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_)))
1252+
# endif
12471253
# else
1248-
call assert(valid .neqv. any(_IS_UNMASKED_(mask _INDEX_GLOBAL_INTERIOR_(_START_:_STOP_))), 'check_interior_state', 'invalid result')
1254+
any_unmasked = any(_IS_UNMASKED_(mask _INDEX_GLOBAL_INTERIOR_(_START_:_STOP_)))
12491255
# endif
1250-
#else
1251-
call assert(.not. valid, 'check_interior_state', 'invalid result')
12521256
#endif
1257+
call assert(valid .neqv. any_unmasked, 'check_interior_state', 'invalid result')
12531258
_END_OUTER_INTERIOR_LOOP_
12541259
do ivar = 1, size(model%interior_state_variables)
12551260
call check_interior(interior_state(_PREARG_LOCATION_DIMENSIONS_ ivar), &
@@ -1261,10 +1266,13 @@ subroutine test_update(apply_mask, restrict_range)
12611266
_BEGIN_OUTER_HORIZONTAL_LOOP_
12621267
call model%check_surface_state(_PREARG_HORIZONTAL_IN_ .true., valid)
12631268
#ifdef _HAS_MASK_
1264-
call assert(valid .neqv. any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))), 'check_surface_state', 'invalid result')
1265-
#else
1266-
call assert(.not. valid, 'check_surface_state', 'invalid result')
1269+
# if _FABM_VECTORIZED_DIMENSION_INDEX_==_FABM_DEPTH_DIMENSION_INDEX_
1270+
any_unmasked = _IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))
1271+
# else
1272+
any_unmasked = any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_)))
1273+
# endif
12671274
#endif
1275+
call assert(valid .neqv. any_unmasked, 'check_surface_state', 'invalid result')
12681276
_END_OUTER_HORIZONTAL_LOOP_
12691277
do ivar = 1, size(model%surface_state_variables)
12701278
call check_horizontal(surface_state(_PREARG_HORIZONTAL_LOCATION_DIMENSIONS_ ivar), &
@@ -1276,10 +1284,13 @@ subroutine test_update(apply_mask, restrict_range)
12761284
_BEGIN_OUTER_HORIZONTAL_LOOP_
12771285
call model%check_bottom_state(_PREARG_HORIZONTAL_IN_ .true., valid)
12781286
#ifdef _HAS_MASK_
1279-
call assert(valid .neqv. any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))), 'check_bottom_state', 'invalid result')
1280-
#else
1281-
call assert(.not. valid, 'check_bottom_state', 'invalid result')
1287+
# if _FABM_VECTORIZED_DIMENSION_INDEX_==_FABM_DEPTH_DIMENSION_INDEX_
1288+
any_unmasked = _IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))
1289+
# else
1290+
any_unmasked = any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_)))
1291+
# endif
12821292
#endif
1293+
call assert(valid .neqv. any_unmasked, 'check_bottom_state', 'invalid result')
12831294
_END_OUTER_HORIZONTAL_LOOP_
12841295
do ivar = 1, size(model%bottom_state_variables)
12851296
call check_horizontal(bottom_state(_PREARG_HORIZONTAL_LOCATION_DIMENSIONS_ ivar), &
@@ -1310,13 +1321,16 @@ subroutine test_update(apply_mask, restrict_range)
13101321
call model%check_interior_state(_PREARG_INTERIOR_IN_ .true., valid)
13111322
#ifdef _HAS_MASK_
13121323
# ifdef _FABM_HORIZONTAL_MASK_
1313-
call assert(valid .neqv. any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))), 'check_interior_state', 'invalid result')
1324+
# if _FABM_VECTORIZED_DIMENSION_INDEX_==_FABM_DEPTH_DIMENSION_INDEX_
1325+
any_unmasked = _IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))
1326+
# else
1327+
any_unmasked = any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_)))
1328+
# endif
13141329
# else
1315-
call assert(valid .neqv. any(_IS_UNMASKED_(mask _INDEX_GLOBAL_INTERIOR_(_START_:_STOP_))), 'check_interior_state', 'invalid result')
1330+
any_unmasked = any(_IS_UNMASKED_(mask _INDEX_GLOBAL_INTERIOR_(_START_:_STOP_)))
13161331
# endif
1317-
#else
1318-
call assert(.not. valid, 'check_interior_state', 'invalid result')
13191332
#endif
1333+
call assert(valid .neqv. any_unmasked, 'check_interior_state', 'invalid result')
13201334
_END_OUTER_INTERIOR_LOOP_
13211335
do ivar = 1, size(model%interior_state_variables)
13221336
call check_interior(interior_state(_PREARG_LOCATION_DIMENSIONS_ ivar), &
@@ -1328,10 +1342,13 @@ subroutine test_update(apply_mask, restrict_range)
13281342
_BEGIN_OUTER_HORIZONTAL_LOOP_
13291343
call model%check_surface_state(_PREARG_HORIZONTAL_IN_ .true., valid)
13301344
#ifdef _HAS_MASK_
1331-
call assert(valid .neqv. any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))), 'check_surface_state', 'invalid result')
1332-
#else
1333-
call assert(.not. valid, 'check_surface_state', 'invalid result')
1345+
# if _FABM_VECTORIZED_DIMENSION_INDEX_==_FABM_DEPTH_DIMENSION_INDEX_
1346+
any_unmasked = _IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))
1347+
# else
1348+
any_unmasked = any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_)))
1349+
# endif
13341350
#endif
1351+
call assert(valid .neqv. any_unmasked, 'check_surface_state', 'invalid result')
13351352
_END_OUTER_HORIZONTAL_LOOP_
13361353
do ivar = 1, size(model%surface_state_variables)
13371354
call check_horizontal(surface_state(_PREARG_HORIZONTAL_LOCATION_DIMENSIONS_ ivar), &
@@ -1343,10 +1360,13 @@ subroutine test_update(apply_mask, restrict_range)
13431360
_BEGIN_OUTER_HORIZONTAL_LOOP_
13441361
call model%check_bottom_state(_PREARG_HORIZONTAL_IN_ .true., valid)
13451362
#ifdef _HAS_MASK_
1346-
call assert(valid .neqv. any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))), 'check_bottom_state', 'invalid result')
1347-
#else
1348-
call assert(.not. valid, 'check_bottom_state', 'invalid result')
1363+
# if _FABM_VECTORIZED_DIMENSION_INDEX_==_FABM_DEPTH_DIMENSION_INDEX_
1364+
any_unmasked = _IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_))
1365+
# else
1366+
any_unmasked = any(_IS_UNMASKED_(mask_hz _INDEX_GLOBAL_HORIZONTAL_(_START_:_STOP_)))
1367+
# endif
13491368
#endif
1369+
call assert(valid .neqv. any_unmasked, 'check_bottom_state', 'invalid result')
13501370
_END_OUTER_HORIZONTAL_LOOP_
13511371
do ivar = 1, size(model%bottom_state_variables)
13521372
call check_horizontal(bottom_state(_PREARG_HORIZONTAL_LOCATION_DIMENSIONS_ ivar), &

0 commit comments

Comments
 (0)