CH-Earth / summa

Structure for Unifying Multiple Modeling Alternatives:
http://www.ral.ucar.edu/projects/summa
GNU General Public License v3.0
80 stars 104 forks source link

bugfix of error reporting in coupled_em soil balance check #442

Closed wknoben closed 3 years ago

wknoben commented 3 years ago

Incorrect solution method was returned by opSplittin, resulting in an incorrect error message in the soil balance check in coupled_em.

Also addresses #441 because this fix uses the stateTypeSplit variable, inside what was previously called the stateTypeSplit DO loop. The loop construct is renamed to stateTypeSplitLoop.

Error message before fix:

1980  5  1  0  0
 solution method           =            3
data_step                 =       3600.0000000000
totalSoilCompress         =          0.0000000000
scalarTotalSoilLiq        =        881.7115625650
scalarTotalSoilIce        =        329.8913458868
balanceSoilWater0         =       1209.7726357183
balanceSoilWater1         =       1211.6029084519
balanceSoilInflux         =          1.8391640923
balanceSoilBaseflow       =          0.0000000000
balanceSoilDrainage       =          0.0089130253
balanceSoilET             =         -0.1470989161
scalarSoilWatBalError     =          0.1471205826
scalarSoilWatBalError     =          0.0001471206
absConvTol_liquid         =          0.0000100000

FATAL ERROR: run_oneGRU (gru index = 47131)/run_oneHRU (hruId = 71027547)/coupled_em/soil hydrology does not balance

Solution method 3 does not exist; only 1 (fullyCoupled) and 2 (stateTypeSplit) are currently available in opSplittin.f90. opSplittin returns solution method 3 because the splitting is handled inside a DO loop, and the loop's index variable is used to report the solution method. Fortran increments the loop index at the end of each iteration and terminates the loop if index > stop_value. In the case of solution method 2, the loop is not terminated early if a solution is found and the index is thus incremented to 3. This stops the DO loop stops because 3 > 2 but the index stays at the incremented value and thus no longer matches the solution method. This fix prevents this from happening.

Error message after fix:

1980  5  1  0  0
 solution method           =            2
data_step                 =       3600.0000000000
totalSoilCompress         =          0.0000000000
scalarTotalSoilLiq        =        881.7115625650
scalarTotalSoilIce        =        329.8913458868
balanceSoilWater0         =       1209.7726357183
balanceSoilWater1         =       1211.6029084519
balanceSoilInflux         =          1.8391640923
balanceSoilBaseflow       =          0.0000000000
balanceSoilDrainage       =          0.0089130253
balanceSoilET             =         -0.1470989161
scalarSoilWatBalError     =          0.1471205826
scalarSoilWatBalError     =          0.0001471206
absConvTol_liquid         =          0.0000100000

FATAL ERROR: run_oneGRU (gru index = 47131)/run_oneHRU (hruId = 71027547)/coupled_em/soil hydrology does not balance