The hierarchical subgrid data structures contained in CLM2.1 are implemented in the code through the modules clmtype.F90, clm_mapping.F90 and clmpoint.F90 (all in the /src/main subdirectory). The new code makes extensive use of the Fortran 90 implementation of the derived data type. This permits the user to define new data types that can consist of multiple standard data types (integers, doubles, strings) as well as other derived data types.
The entire definition of the CLM2.1 subgrid hierarchy is contained in module clmtype.F90. The module, clmtype.F90, is organized such that derived types which are members of other derived types are defined first (a Fortran 90 compiler requirement). In particular, the energy and mass conservation data types are defined first, followed by data types constituting the pft level, column level, landunit level, gridcell level and the model domain level. Finally, the hierarchical organization of these types is defined, starting with the model domain level, which consists in part of a pointer to an array of gridcells, each of which consists in part of a pointer to an array of landunits, each of which has a pointer to an array of columns, which each have a pointer to an array of pfts. The last section of clmtype.F90 includes additional data structures that map the hierarchical organization to simple 1d vectors at each level for history, restart and initial file output.
The basic functions of subroutine clm_map() in clm_mapping.F90 are memory allocation for the subgrid hierarchy and initialization of areas and weights associated with each subgrid component. Use is made of input gridded datasets defining the spatial distribution of pfts and other surface types (glacier, lake, etc.). This is the primary routine that needs to be modified in order to accommodate different subgrid representations using the data structures defined in clmtype.F90.
Module clmpoint.F90 creates arrays of one-dimensional real and integer pointers for various clmtype derived type components. These arrays are integral to the CLM2.1 history file handler logic as well as the restart and initial file generation. The exact usage of these arrays in the model's history file logic is discussed in more detail in section 6.
Finally, CLM2.1 includes the module, pft2columnMod.F90, which contains methods for averaging fluxes and states between levels in the hierarchy (currently pft to column in the current implementation). It is intended that similar routines for averaging from column to landunit and from landunit to gridcell will be added later.