Removal of Content Advisory - April 2024

Advisory to Numerical Weather Prediction (NWP) containers users: As of the beginning of April 2024, all support assets for Numerical Weather Prediction (NWP) containers will be removed from the DTC website. Users should download all reference materials of interest prior to April 2024.

NWP Containers Online Tutorial | Customization > Post Processing

Adding a new output variable to UPP

Perhaps you would like to output a variable in WRF and UPP that is not part of the "out of the box" configuration provided with the tutorial cases. In this example, we will demonstrate how to modify the WRF namelist.input and UPP control files to output maximum updraft helicity. Note: This variable has already been added for the tutorial cases, but the steps provide a roadmap for other variables.

Go to the scripts directory for the desired case. In this example, we will be using the derecho case:

cd ${PROJ_DIR}/container-dtc-nwp/components/scripts/derecho_20120629
Note: it is important that you make changes to the namelists in this "scripts" directory instead of in the run directories you already created; the scripts which actually run the NWP containers (such as run_wrf.ksh) will copy these namelists to the appropriate locations when you run the containers, which will overwrite any files that already exist there!

In order to output maximum updraft helicity, you will need to edit the WRF namelist.input by setting nwp_diagnostics = 1 under the time_control section in the namelist.input. See below for what this entry looks like:

 &time_control
 run_days = 0,
 run_hours = 24,
 .
 .
 .
 nwp_diagnostics = 1
 /

For more information on the nwp_diagnostics package, please see the WRF documentation. Once the local changes to the namelist.input have been made, run WRF per the instructions in the tutorial. If the changes were successfully executed, you should see the UP_HELI_MAX variable in the WRF output.

Changes to the UPP control files are necessary to output maximum updraft helicity in the post-processed GRIB2 files. More extensive descriptions are provided in the UPP User's Guide, but the necessary steps will be briefly outlined below.

First, if you are not still in the scripts directory, navigate there:

cd ${PROJ_DIR}/container-dtc-nwp/components/scripts/derecho_20120629

The new variable needs to be added to the postcntrl.xml file, which is a file composed of a series of parameter blocks specifying the variables, fields, and levels. To add maximum helicity, add the following block (note: order in the file does not matter as long as the variables are within the </paramset> and </postxml> tags):

<param>
<shortname>MAX_UPHL_ON_SPEC_HGT_LVL_ABOVE_GRND_2-5km</shortname>
<pname>MXUPHL</pname>
<table_info>NCEP</table_info>
<scale>-3.0</scale>
</param>

Information on the specifics of populating the parameter blocks is available in the UPP User's Guide. Once the postcntrl.xml file is updated, additional control files need to be modified.

Due to software requirements, these changes need to be made using the UPP code directory that lives in the UPP container. To enter the container,

SELECT THE APPROPRIATE CONTAINER INSTRUCTIONS FOR YOUR SYSTEM BELOW:

To enter the Docker container, execute the following command:

docker run --rm -it -e LOCAL_USER_ID=`id -u $USER` \
 -v ${PROJ_DIR}/container-dtc-nwp/components/scripts/derecho_20120629:/home/scripts/case \
 --name run-derecho-upp dtcenter/upp:3.5.1 /bin/bash

All changes that need to be made will be under the UPP parm directory. First, the necessary control files need to be copied into the parm directory:

cd /comsoftware/upp/UPPV4.1/parm
cp /home/scripts/case/post*xml .

An optional step to ensure the user-edited XML stylesheets (EMC_POST_CTRL_Scheme.xsd and EMC_POST_Avblflds_Scheme.xsd) are error free is to validate the postcntrl.xml and postavblflds.xml files. If the validation is successful, confirmation will be given (e.g., postcntrl.xml validates). Otherwise, it will return error messages. To run the optional validation step:

xmllint --noout --schema EMC_POST_CTRL_Schema.xsd postcntrl.xml
xmllint --noout --schema EMC_POST_Avblflds_Schema.xsd post_avblflds.xml

Once the XMLs are validated, the user will need to generate the flat file. Edit the makefile_comm to point to the full path of the parm directory in container space. The makefile_comm will call the perl program POSTXMLPreprocessor.pl to generate the flat file, postxconfig-NT_WRF.txt. Modify the makefile_comm to change the path of FLATFILEDIR and FLATFILENAME:

FLATFILEDIR = /comsoftware/upp/UPPV4.1/parm
FLATFILENAME = postxconfig-NT_WRF.txt

To generate the flat file type:

mv makefile_comm makefile
make

If a new flat file is successfully generated, you will see a message "Flat file is new generated." In order to save the postxconfig-NT_WRF.txt file outside of the container, we need to move it to the directory in container space that is mounted to your local scripts directory. After that is complete, you can exit the container.

mv postxconfig-NT_WRF.txt /home/scripts/case
exit

After completing these steps, rerun the WRF and UPP steps as usual with Docker commands.  

To enter the Singularity container, we can leverage the "sandbox" feature and make the changes locally. Execute the following command:

cd ${PROJ_DIR}
singularity  build  --sandbox   upp_3.5.1   ${CASE_DIR}/upp_3.5.1.sif

This will create a directory called "upp_3.5.1" in your ${PROJ_DIR}. We can now go into that directory and leverage the already built UPP code to make the necessary changes.

cd ${PROJ_DIR}/upp_3.5.1/comsoftware/upp/UPPV4.1/parm
cp ${PROJ_DIR}/dtc-nwp-container/components/scripts/derecho_20120629/post*xml .

An optional step to ensure the user-edited XML stylesheets (EMC_POST_CTRL_Scheme.xsd and EMC_POST_Avblflds_Scheme.xsd) are error free is to validate the postcntrl.xml and postavblflds.xml files. If the validation is successful, confirmation will be given (e.g., postcntrl.xml validates). Otherwise, it will return error messages. To run the optional validation step:

xmllint --noout --schema EMC_POST_CTRL_Schema.xsd postcntrl.xml
xmllint --noout --schema EMC_POST_Avblflds_Schema.xsd post_avblflds.xml

Once the XMLs are validated, the user will need to generate the flat file. Edit the makefile_comm to point to the full path of the parm directory in container space. The makefile_comm will call the perl program POSTXMLPreprocessor.pl to generate the flat file, postxconfig-NT_WRF.txt. Modify the makefile_comm to change the path of FLATFILEDIR and FLATFILENAME:

FLATFILEDIR = /comsoftware/upp/UPPV4.1/parm
FLATFILENAME = postxconfig-NT_WRF.txt

To generate the flat file type:

mv makefile_comm makefile
make

If a new flat file is successfully generated, you will see a message "Flat file is new generated." We then want to make sure to copy this new postxconfig-NT_WRF.txt file to the local case scripts directory to ensure it is used.  

cp ${PROJ_DIR}/upp_3.5.1/comsoftware/upp/UPPV4.1/parm/postxconfig-NT_WRF.txt  ${PROJ_DIR}/container-dtc-nwp/components/scripts/derecho_20120629

Rerun WRF using the wps_wrf_3.5.1.sif as in the Derecho tutorial (note for this example we assume you're `pwd` is ${PROJ_DIR}:

singularity exec -B ${PROJ_DIR}/data:/data -B ${PROJ_DIR}/container-dtc-nwp/components/scripts/common:/home/scripts/common -B ${PROJ_DIR}/container-dtc-nwp/components/scripts/derecho_20120629:/home/scripts/case -B ${CASE_DIR}/wpsprd:/home/wpsprd -B ${CASE_DIR}/wrfprd:/home/wrfprd ./wps_wrf_3.5.1.sif /home/scripts/common/run_wrf.ksh

Finally, run UPP using the "sandbox" Singularity container:

singularity exec -B/glade:/glade -B${PROJ_DIR}/data:/data -B${PROJ_DIR}/container-dtc-nwp/components/scripts/common:/home/scripts/common -B${PROJ_DIR}/container-dtc-nwp/components/scripts/derecho_20120629:/home/scripts/case -B ${CASE_DIR}/postprd:/home/postprd -B ${CASE_DIR}/wrfprd:/home/wrfprd upp_3.5.1 /home/scripts/common/run_upp.ksh

 

Some final notes on adding a new output variable with WRF and/or UPP:

  • In the official WRF release, maximum updraft helicity is already enabled to be output via the WRF Registry files. All that is needed to be available in the WRF output files is to modify the namelist.input by setting nwp_diagnostics = 1. If you need to modify the WRF Registry file, please contact us for assistance.

  • In the official UPP release, maximum updraft helicity is already a supported variable. While a large number of variables are supported, not all variables are written out. The original postcntrl.xml did not specify outputting maximum updraft helicity; therefore, modifications were made to add the variable to output. To add a new variable that is not available in UPP and to access a list of fields produced by UPP, please see the UPP User's Guide.

If you have further questions regarding customization, please post them to the Customization Category of DTC NWP Containers GitHub Discussions forum.