Wiki

Clone wiki

templates / How to Add a New Output Variable

This page explains which parts of the code you will need to modify to add land surface output variables for either LIS-CABLE or WRF-LIS-CABLE. These are only valid if the variable already exist in the CABLE variable or can be calculated easily from existing variables. It does not have the steps to add a variable to CABLE. For adding atmospheric output variables you will need to check the WRF users page.

In this example, we will describe how this was implemented for the CABLE variable fwsoil which is a variable describing the soil moisture limitation on stomatal conductance.

The following modifications need to be made to the model code, and then you need to recompile the code for this to work.

CABLE driver file

<path_to_model_code>/nuwrf/WRFV3/lis/surfacemodels/land/cable/cable_driv_mod.F90

Because fwsoil is a variable used in the canopy module, the placement follows other canopy variables. If you wanted to add a soil variable, have a look at a variable like the soil moisture wb to guide you on the placement of the code additions.

In the cable_2canopy subroutine add:

      canopy%fwsoil = cable_struc(n)%cable(t)%fwsoil

In the cable_2cable subroutine add:

      cable_struc(n)%cable(t)%fwsoil       = canopy%fwsoil(1)

In the cable_prepdiag subroutine add:

      cable_struc(n)%cable(t)%fwsoil   = canopy%fwsoil(1)

In the cable_watervals subroutine add:

      cable_struc(n)%cable(t)%fwsoil = LIS_rc%udef

In the cable_LISdiagnose subroutine add:

      call LIS_diagnoseSurfaceOutputVar(n,t,LIS_MOC_FWSOIL,value=                      &
           cable_struc(n)%cable(t)%fwsoil/fl,                                   &
           vlevel=1,unit="-",direction="-",surface_type=LIS_rc%lsm_index)

CABLE module file that defines the CABLE type

<path_to_model_code>/nuwrf/WRFV3/lis/surfacemodels/land/cable/cable_module.F90 - this is where you add new state variables.

In the section for state variables add the following:

   real :: fwsoil

LIS file to define outputs

<path_to_model_code>/nuwrf/WRFV3/lis/core/LIS_histDataMod.F90

To help with the placement of the following code additions, it can be helpful to search another variable such as TVEG and add the following after the same lines for TVEG:

   public :: LIS_MOC_FWSOIL  
   integer :: LIS_MOC_FWSOIL     = -9999
    call ESMF_ConfigFindLabel(modelSpecConfig,"FWsoil:",rc=rc)
    call get_moc_attributes(modelSpecConfig, LIS_histData(n)%head_lsm_list, &
         "FWsoil",&
         "soil water limitation",&
         "soil water limitation",rc)
    if ( rc == 1 ) then
       call register_dataEntry(LIS_MOC_LSM_COUNT,LIS_MOC_FWSOIL,&
            LIS_histData(n)%head_lsm_list,&
            n,2,ntiles,(/"-","%"/),1,(/"-"/),1,1,1,&
            model_patch=.true.)
    endif

Finally you will need to add the output variable to the MODEL_OUTPUT_LIST.TBL_d01 in the templates before you create the decks for your simulation following the format of:

FWsoil:       1  -       -    1 0 0 1 210 1       # Soil Water Limitation

Note that you will want to keep things consistent with the sign convention, units etc that you have specified in the model code additions.

The header of MODEL_OUTPUT_LIST.TBL_d01 explains what each column corresponds to.

Updated