CCPP and SCM Online Tutorial | Exercise 4: Add a new variable

Add a new variable to a CCPP-compliant scheme

Adding a New Variable

In this section, we will explore how to pass a new variable onto an existing scheme. The surface latent and sensible heat fluxes will be adjusted in scheme fix_sys_bias_sfc to be time-dependent using the existing variable solhr (time in hours after 00 UTC at the current timestep). The surface fluxes will now only be modified between the hours of 20:30 and 8:30 UTC, which correspond to the hours of 6:00 AM and 6:00 PM local time in Darwin, Australia, where this case is located. 

Step 1: Add Time Dependency to the fix_sys_bias_sfc_time Scheme

Edit file $SCM_WORK/ccpp-scm/ccpp/physics/physics/fix_sys_bias_sfc.F90 and add solhr to the argument list for subroutine fix_sys_bias_sfc_run:

subroutine fix_sys_bias_sfc_run (im, con_cp, con_rd, con_hvap, p1, t1, solhr, hflx_r, qflx_r, errmsg, errflg)

Then declare solhr as a real variable:

real(kind=kind_phys), intent(in) :: solhr

Next, add the time-dependent surface flux modification using an if statement between the CCPP error message handling and the do loop:

if (solhr > 8.5 .and. solhr < 20.5) return

A metadata entry should be added to the table for subroutine fix_sys_bias_sfc_run in file $SCM_WORK/ccpp-scm/ccpp/physics/physics/fix_sys_bias_sfc.meta.

[t1]
  standard_name = air_temperature_at_surface_adjacent_layer
  long_name = mean temperature at lowest model layer
  units = K
  dimensions = (horizontal_loop_extent)
  type = real
  kind = kind_phys
  intent = in
[solhr]
  standard_name = forecast_utc_hour
  long_name = time in hours after 00z at the current timestep
  units = h
  dimensions = ()
  type = real
  kind = kind_phys
  intent = in
[hflx_r]
...

Note: If you don’t want to type, you can copy over completed versions of these files:

cp $SCM_WORK/ccpp-scm/tutorial_files/add_new_variable/fix_sys_bias_sfc.F90 $SCM_WORK/ccpp-scm/ccpp/physics/physics
cp $SCM_WORK/ccpp-scm/tutorial_files/add_new_variable/fix_sys_bias_sfc.meta $SCM_WORK/ccpp-scm/ccpp/physics/physics

Since solhr is an existing variable, you do not need to modify the host model. Additionally, no changes are needed in the SDF or in the prebuild script since you are simply modifying a scheme and not adding a new scheme. You can proceed to rebuilding the SCM.

Step 2: Build the Executable, Run the Model, and Inspect the Output

Issue these commands to rebuild the SCM executable :

cd $SCM_WORK/ccpp-scm/scm/bin
cmake ../src -DCCPP_SUITES=ALL
make

In order to avoid overwriting the output produced in exercise “Add a new scheme”, first rename the output directory:

mv $SCM_WORK/ccpp-scm/scm/run/output_twpice_SCM_RRFS_v1beta_sas_sfcmod $SCM_WORK/ccpp-scm/scm/run/output_twpice_RSAS_sfcmod

The following command will run the SCM for the TWP-ICE case using suite RRFS_v1beta_sas_sfcmod with scheme fix_sys_bias_sfc modified to use variable solhr:

Note: if you are using a Docker container, add -d at the end of the command

./run_scm.py -c twpice -s SCM_RRFS_v1beta_sas_sfcmod 

Upon completion of the run, the following subdirectory will be created, with a log file and results in NetCDF format in file output.nc:

$SCM_WORK/ccpp-scm/scm/run/output_twpice_SCM_RRFS_v1beta_sas_sfcmod

To visualize the results, edit file $SCM_WORK/ccpp-scm/scm/etc/scripts/plot_configs/twpice_scm_tutorial.ini and add the new test directory name and label name to the first two lines:

scm_datasets = output_twpice_SCM_RRFS_v1beta_sas/output.nc,
output_twpice_RSAS_sfcmod/output.nc, output_twpice_SCM_RRFS_v1beta_sas_sfcmod/output.nc
scm_datasets_labels = RRFSv1beta_sas,RRFSv1beta_sas_sfcmod,RRFSv1beta_sas_sfcmod_time
plot_dir = plots_twpice_R_sas_sfcmod_time/

Note: If you don’t want to type, you can copy over a pre-generated plot configuration file:

cp $SCM_WORK/ccpp-scm/tutorial_files/add_new_variable/twpice_scm_tutorial.ini $SCM_WORK/ccpp-scm/scm/etc/scripts/plot_configs

Change into the following directory:

cd $SCM_WORK/ccpp-scm/scm/run/

Next, run the following command to generate plots for the last three exercises in this tutorial.

Note: if you are using a Docker container, add -d at the end of the command

./scm_analysis.py twpice_scm_tutorial.ini

The script creates a new subdirectory within the $SCM_WORK/ccpp-scm/scm/run/ directory called plots_twpice_R_sas_sfcmod_time/comp/active

Inspect the Results

Q: Examine the surface latent heat flux and the surface sensible heat flux  in files time_series_shf.pdf and time_series_lhf.pdf, respectively. How does the latent heat flux differ from the previous exercise?

A: Instead of adding 40 W m-2 to the latent heat flux throughout the simulation, the latent heat flux value was modified only between the hours of 6 AM and 6 PM local time to mimic the observed diurnal cycle feature.

Q: Examine the temperature bias and the specific humidity bias  in files profiles_bias_T.pdf and profiles_bias_qv.pdf, respectively. How are the temperature and moisture profiles affected by the surface latent heat flux  modification?

A: When the surface latent heat flux is increased in the TWP-ICE case, the column temperature and moisture are improved in the middle and lower troposphere, but it turns out to be too hot and humid around 400 hPa.