CTSM icon indicating copy to clipboard operation
CTSM copied to clipboard

Some FATES-SP configurations are calling patch%itype

Open rgknox opened this issue 7 months ago • 2 comments

The tests: SMS_D.1x1_brazil.I2000Clm60FatesSpCruRsGs.derecho_gnu.clm-FatesColdDryDepSatPhen and ERP_P128x2_Ld30.f45_f45_mg37.I2000Clm60FatesSpCruRsGs.derecho_intel.clm-FatesColdSatPhen

generate a run fail with the following error message:

 At line 879 of file /glade/u/home/rgknox/ctsm/src/main/subgridWeightsMod.F90
dec2438.hsn.de.hpc.ucar.edu 0: Fortran runtime error: Index '-9998' of dimension 2 of array 'subgrid_weights_diagnostics%pct_nat_pft' below lower bound of 1
dec2438.hsn.de.hpc.ucar.edu 0:

Here is line 879

This issue is newly generated with issue #2933 and PR: #2935 , that PR sets itype to a bogus value that will trigger this type of error, so that it is not inappropriately used.

When fates is active, the itype should never be used, even in SP. Yes, with FATES-SP we do associate patches with a specific PFT, but FATES does not follow the same PFT indexing convention that is found in the surface file, so associating a patch with a pft on the clm-side is meaningless and impossible.

rgknox avatar May 14 '25 00:05 rgknox

I was able to bypass the previous error by removing the call to have PCT_NAT_PFT in the diagnostics. The ERP_P128x2_Ld30.f45_f45_mg37.I2000Clm60FatesSpCruRsGs.derecho_intel.clm-FatesColdSatPhen test still generates the following error further in the call sequence though:

dec0068.hsn.de.hpc.ucar.edu 9: forrtl: error (65): floating invalid
dec0068.hsn.de.hpc.ucar.edu 9: Image              PC                Routine            Line        Source             
dec0068.hsn.de.hpc.ucar.edu 9: libpthread-2.31.s  000014733E3D08C0  Unknown               Unknown  Unknown
dec0068.hsn.de.hpc.ucar.edu 9: cesm.exe           0000000002B39517  satellitephenolog         521  SatellitePhenologyMod.F90
dec0068.hsn.de.hpc.ucar.edu 9: cesm.exe           0000000002B304D2  satellitephenolog         303  SatellitePhenologyMod.F90
dec0068.hsn.de.hpc.ucar.edu 9: cesm.exe           0000000000AAEEBD  clm_initializemod         711  clm_initializeMod.F90

Here is line 521

As far as I can tell, here is where mlai2t is calculated:

https://github.com/ESCOMP/CTSM/blob/ctsm5.3.043/src/biogeochem/SatellitePhenologyMod.F90#L493

~~This needs to call some transform where FATES PFTS are mapped and weighted to be associated with PFTs in a streams dataset.~~

We pass the LAI data associated with the pfts from the file to FATES, so we don't need to transform this data with weights to the FATES pft definitions here. However, we should not be storing this data on the patch structure. Its misleading us to think that the patches are associated with the LAI from the dataset (which is true for CN but not FATES).

cc'ing @adrifoster @rosiealice @glemieux

rgknox avatar May 14 '25 00:05 rgknox

Here are some changes that allow us to circumvent usage of itype with FATES:

https://github.com/ESCOMP/CTSM/pull/2935/commits/54a7ce600dafc70281e99accf37f4e642bd9cf27

Ideally, via a future PR, the satellite phenology module would store its data outside of the patch structure, perhaps arrays that are grid index x pft index.

rgknox avatar May 14 '25 14:05 rgknox