Brief summary of bug
The xsmrpool_loss state variable looks like it's only used if use_crop is true, but it's written to the restart file always. I think this is responsible for the carbon balance errors we're seeing when we try to interpolate a non-crop initial condition file to a crop case.
General bug information
CTSM version you are using: ctsm1.0.dev105-22-gfc141769d
Does this bug cause significantly incorrect results in the model's science? No
Configurations affected: Any crop configuration that interpolates initial conditions from a non-crop case
Details of bug
@ekluzek found that, with new initial conditions files, a number of Clm45BgcCrop cases are failing. I reproduced the failure in one of these tests (ERP_P36x2_D_Ld5.f10_f10_musgs.I1850Clm45BgcCrop.cheyenne_intel.clm-crop) using his branch with updated initial conditions files (ctsm1.0.dev105-22-gfc141769d). This fails with a carbon balance error, with beg & end carbon balance of 1e36. An interesting thing about this configuration is that it appears to be interpolating from a non-crop initial conditions file onto a crop case (I'm not sure if this is intentional).
It looks like the problem – or at least a problem – is related to the relatively new xsmrpool_loss restart variable. It looks like this variable is only used in crop cases, and it is only set to 0 in InitCold if running with crop. However, it is always written to the restart file. So, in a non-crop case, NaN values will be written to the restart file. If you interpolate from a non-crop case to a crop case using such a restart file, you will end up with NaN (or maybe spval) values on the finidat_interp_dest.nc file, which I think is what is causing these carbon balance errors. (If you use an older restart file that doesn't have the xsmrpool_loss field, then this problem doesn't show up because, in the crop case, the values on the finidat_interp_dest.nc file will be left at their cold start initialization values, which are, correctly, 0.)
I think the solution is to only add the xsmrpool_loss restart variable if use_crop is true – similarly to other crop-specific variables in CNVegCarbonStateType. I have not verified that this solves the problem. Note that this change will need to be made in the code base that you use to create the new (non-crop) initial conditions files (it is not enough to put this code change in place in the code base from which you run the Clm45BgcCrop tests if they are using already-bad non-crop initial conditions files).
Brief summary of bug
The
xsmrpool_lossstate variable looks like it's only used ifuse_cropis true, but it's written to the restart file always. I think this is responsible for the carbon balance errors we're seeing when we try to interpolate a non-crop initial condition file to a crop case.General bug information
CTSM version you are using:
ctsm1.0.dev105-22-gfc141769dDoes this bug cause significantly incorrect results in the model's science? No
Configurations affected: Any crop configuration that interpolates initial conditions from a non-crop case
Details of bug
@ekluzek found that, with new initial conditions files, a number of Clm45BgcCrop cases are failing. I reproduced the failure in one of these tests (
ERP_P36x2_D_Ld5.f10_f10_musgs.I1850Clm45BgcCrop.cheyenne_intel.clm-crop) using his branch with updated initial conditions files (ctsm1.0.dev105-22-gfc141769d). This fails with a carbon balance error, with beg & end carbon balance of 1e36. An interesting thing about this configuration is that it appears to be interpolating from a non-crop initial conditions file onto a crop case (I'm not sure if this is intentional).It looks like the problem – or at least a problem – is related to the relatively new
xsmrpool_lossrestart variable. It looks like this variable is only used in crop cases, and it is only set to 0 in InitCold if running with crop. However, it is always written to the restart file. So, in a non-crop case, NaN values will be written to the restart file. If you interpolate from a non-crop case to a crop case using such a restart file, you will end up with NaN (or maybe spval) values on thefinidat_interp_dest.ncfile, which I think is what is causing these carbon balance errors. (If you use an older restart file that doesn't have thexsmrpool_lossfield, then this problem doesn't show up because, in the crop case, the values on thefinidat_interp_dest.ncfile will be left at their cold start initialization values, which are, correctly, 0.)I think the solution is to only add the
xsmrpool_lossrestart variable ifuse_cropis true – similarly to other crop-specific variables in CNVegCarbonStateType. I have not verified that this solves the problem. Note that this change will need to be made in the code base that you use to create the new (non-crop) initial conditions files (it is not enough to put this code change in place in the code base from which you run the Clm45BgcCrop tests if they are using already-bad non-crop initial conditions files).