-
Notifications
You must be signed in to change notification settings - Fork 343
Description
In unittestSubGridMod there are calls to add different levels of the subgrid hierarchy: gridcell, landunit, column, patch, and cohort. In most unit tests just the levels needed are created. In order to really fill the subgrid hierarchy in the way the model does -- you need to make sure all the levels are done. In most of these cases you just want a simple setup done for anything below the level you are adding. So a single simple patch added beneath a column for example.
To facilitate this we'll be adding an optional argument to the add calls to add a simple level below the one created. So for example, with unittest_add_column, an optional add_simple_patch will add a simple patch beneath the column. This can also be done for unittest_add_landunit with add_simple_column, and for unittest_add_gridcell with add_simple_landunit. I figure these all will just be a simple baresoil veg patch. The argument doesn't mentioned "baresoil", but that's probably OK.
I noticed this because in #3666 I had added more error checking to get_proc_bounds, so it noticed that these subgrid levels weren't being set for a lot of the unittests.
Here's the comment from the PR:
So for this one case, I'll make sure the lower level hierarchy is setup by doing this sort of thing:
diff --git a/src/dyn_subgrid/test/dynInitColumns_test/test_init_columns.pf b/src/dyn_subgrid/test/dynInitColumns_test/test_init_columns.pf
index ade2e6d95..79ec506f9 100644
--- a/src/dyn_subgrid/test/dynInitColumns_test/test_init_columns.pf
+++ b/src/dyn_subgrid/test/dynInitColumns_test/test_init_columns.pf
@@ -66,24 +66,24 @@ contains
! The first landunit is neither natural veg nor crop
call unittest_add_landunit(my_gi=gi, ltype=istwet, wtgcell=0.25_r8)
- call unittest_add_column(my_li=li, ctype=1, wtlunit=0.5_r8)
- call unittest_add_column(my_li=li, ctype=1, wtlunit=0.5_r8)
+ call unittest_add_column(my_li=li, ctype=1, wtlunit=0.5_r8, add_simple_patch=.true.)
+ call unittest_add_column(my_li=li, ctype=1, wtlunit=0.5_r8, add_simple_patch=.true.)
call unittest_add_landunit(my_gi=gi, ltype=1, wtgcell=0.5_r8)
this%l1 = li
- call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8)
- call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8)
+ call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8, add_simple_patch=.true.)
+ call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8, add_simple_patch=.true.)
! This column (the second column on the landunit with ltype=1) will be the target for
! some tests of initialization of a new column
this%c_new = ci
- call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8)
- call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8)
+ call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8, add_simple_patch=.true.)
+ call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8, add_simple_patch=.true.)
call unittest_add_landunit(my_gi=gi, ltype=2, wtgcell=0.25_r8)
this%l2 = li
- call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8)
- call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8)
- call unittest_add_column(my_li=li, ctype=1, wtlunit=0.5_r8)
+ call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8, add_simple_patch=.true.)
+ call unittest_add_column(my_li=li, ctype=1, wtlunit=0.25_r8, add_simple_patch=.true.)
+ call unittest_add_column(my_li=li, ctype=1, wtlunit=0.5_r8, add_simple_patch=.true.)
call unittest_subgrid_setup_end()
The new optional "add_simple_patch" argument means add a single simple patch below the column created. This could be done in other unittests to make sure the patch level is set when columns are added. The same sort of thing could be done for landunit and grid level as well.
Originally posted by @ekluzek in #3666 (comment)