Skip to content

ZZ_ IO REFACTOR NOTES

tobey edited this page Mar 30, 2016 · 1 revision

....Refactor notes....

The model has several "run stages" (eq, sp, tr, sc), and there needs to be a means to transfer data between stages. Each stage should start using the state generated by the previous stage. For eq stage, for which there is no prior stage, the model should start from a state described in a set of parameter and configuration files.

Need format for restart file...

Properties/Description of Fengming's Implementation:
  • For eq stage, the model state is initialized using values from the cmt_* files in the config/ directory.

  • For subsequent stages, the model state is initialized from "restart files" held in the DATA/<testcase>/output/ directory.

  • The "restart file" is a NetCDF file written to DATA/<testcase>/output with a suffix denoting the stage.

  • The restart-xx.nc is unlimited along the CHTID dimension. Essentially each Cohort has a unique ID (used heavily elsewhere in the model and input structure) that is related to the pixel location (from upper right?) of the entire AIEM input domain.

  • CohortLookup appears to be the class/data structure representation of the values in the config/cmt_* directory. It appears that in all initialization cases, at least some of the values in CohortLookup are used. In some cases, some values are chosen from a restart-xx.nc instead of the config/ directory.

  • RestartData is the data structure that holds the information that needs to be updated and passed between stages.

  • RestartInputer - reads a restart-xx.nc file into a RestartData object (via pointer)

  • RestartOutputer - writes data from a RestartData object (via pointer) to variables in a NetCDF file.

  • Many (all?) of the "data" classes (Soil_Env, Soil_Bgc, Ground, Snow_Env, etc) have methods that initialize from the CohortLookup or a restart file:

    • ::initializeState(..) functions initialize from CohortLookup values
    • ::initializeState5restart(..) functions initialize from RestartData values

The restart-xx.nc file looks like this:

$ ncdump -h restart-sp.nc
netcdf restart-sp {
dimensions:
	CHTID = UNLIMITED ; // (1 currently)
	PFT = 10 ;
	PFTPART = 3 ;
	ROOTLAYER = 10 ;
	SNOWLAYER = 6 ;
	SOILLAYER = 23 ;
	ROCKLAYER = 5 ;
	FRONTNUM = 10 ;
	PRVYEAR = 10 ;
	PRVMONTH = 12 ;
variables:
	int CHTID(CHTID) ;
	int ERRCODE(CHTID) ;
	int DSR(CHTID) ;
	int FIREA2SORGN(CHTID) ;
	int YSF(CHTID) ;
	int IFWOODY(CHTID, PFT) ;
	int IFDECIWOODY(CHTID, PFT) ;
	int IFPERENIAL(CHTID, PFT) ;
	int NONVASCULAR(CHTID, PFT) ;
	int VEGAGE(CHTID, PFT) ;
....

Properties/Description of refactored code:
  • config/cmt_* files were moved to a parameters/ directory.
  • Looks like RestartData is for the most part directly re-usable