Skip to content

Conversation

@LluisFB
Copy link
Contributor

@LluisFB LluisFB commented Sep 5, 2025

Enhance model output to include CORDEX output demands and new potential useful diagnostics

TYPE: new feature

KEYWORDS: CORDEX, diagnostics, post-process, impact studies, scheme free diagnostics

SOURCE: Lluís Fita Centro de Investigaciones del Mar y la Atmósfera (CIMA), IRL IFAECI UBA-CONICET-CNRS-IRD, Argentina

DESCRIPTION OF CHANGES:
Problem:
The CORDEX-WRF module was initially dedicated to provide the outputs requested in any CORDEX exercise. This tends to be a tedious post-processing work, in sometimes is as long as the simulation by it self. the goal is to provide the diagnostics whilst the integration of the simulation. Enormously reducing the need for post-processing by increasing a little the integration time of the model.

Solution:
A new module has been created which adds about 150 new diagnostics to the model output.
Aside to provide an answer to an specific climate related demand from the CORDEX WRF community, it grew fast to provide:

  • Additional non-specific CORDEX diagnostics
  • Generic definitions of certain diagnostics that might be scheme dependent
  • Introduction of additional variables in the integration-time p-level vertical interpolation

ISSUE: For use when this PR closes an issue.
Fixes #2243

LIST OF MODIFIED FILES: list of changed files (use git diff --name-status master to get formatted list)

A       README.cordex
M       README.md
M       Registry/Registry.EM_COMMON
M       Registry/Registry.EM_COMMON.var
A       Registry/registry.cordex
M       Registry/registry.diags
M       Registry/registry.em_shared_collection
M       dyn_em/solve_em.F
M       dyn_em/start_em.F
M       frame/module_driver_constants.F
M       main/depend.common
M       phys/Makefile
A       phys/module_diag_cordex.F
M       phys/module_diag_pld.F
M       phys/module_diagnostics_driver.F
A       phys/module_diagvar_cordex.F
M       phys/module_physics_init.F

TESTS CONDUCTED:

  1. Do mods fix problem? How can that be demonstrated, and was that test conducted?
  2. Are the Jenkins tests all passing?
    Independent tests have been performed aimed to show the correct performance of the module

RELEASE NOTE:
First version (v1.3) of the module was accompanied by an article in GMD:
Lluís Fita, Jan Polcher, Theodore M. Giannaros, Torge Lorenz, Josipa Milovac, Giannis Sofiadis, Eleni Katragkou and Sophie Bastin, 2019: CORDEX-WRF v1.3: development of a module for the Weather Research and Forecasting (WRF) model to support the CORDEX community, Geosci. Model Dev., 12, 1029-1066, 2019, doi 10.5194/gmd-12-1029-2019

Current version of the module is v.3 and it provides about 150 new diagnostics a new section in the namelist.input labelled &cdxwrf with new parameters. Outputs are grouped in 3 files:

  • wrfcdx_d<domain>_<date>: main output file at auxhist19 with most of the variables
  • wrfhfcdx_d<domain>_<date>: high-frequency (e,g, 10 minutes) output file at auxhist18 only for RAIN and COLMAX implemented to assist the tracking convective systems
  • wrfpress_d<domain>_<date>: p-level interpolated variables at auxhist23 with the additional variables

You can find more details in the CDXWRF WIKI

This work was made possible by the participation of the co-authors of the article, talks with a lot of different researchers from a lot of different countries and even other sciences. Thanks to all of them

LluisFB and others added 30 commits June 20, 2025 18:33
…X-WRF module

L. Fita, J. Polcher, T. M. Giannaros, T. Lorenz, J. Milovac, G. Sofiadis, E. Katragkou,
  and S. Bastin (2019): CORDEX-WRF v1.3: development of a module for the Weather
  Research and Forecasting (WRF) model to support the CORDEX community, Geosci.
  Model Dev., 12, 1029-1066, doi: 10.5194/gmd-12-1029-2019
 - `var_colmax1D': Subroutine to compute 1D maximum radar reflectivity
It gets a mix of high-frequency variables, new soil variables, debugging also by time and closest point to a given coordinates
@dudhia
Copy link
Collaborator

dudhia commented Dec 17, 2025

I think PR #2247 was temporary during some compile problems, so now we can discard it.
Is everything activated by -D choices or are there namelist choices needed in combination?
If we want to test the likely most commonly used one what would you recommend?

@LluisFB
Copy link
Contributor Author

LluisFB commented Dec 17, 2025

Aside of the pre-compilation flags, it has namelist parameters. I included default values in order to simplify its use.

I would recommend to use CXWRF=3 and activate the diagnose of the convective extremes. So in the namelist:

&cordex
 output_cordex              = 1 
 output_wb                  = 0
 convxtrm_diag              = 1
/

@dudhia
Copy link
Collaborator

dudhia commented Jan 8, 2026

We have tried all the CDXWRF levels. 2 and 3 worked.
WRFCDX_1 and_ WRFCDX_All have the same variables causing the compile error. 'press' may only be defined above CDXWRF=2
WRFCDX_4 seems to not be activating this code and DIABH is not showing up for compile. This is the only #elif, so maybe it is related to that.
#ifdef CDXWRF

#if CDXWRF>=1

#elif CDXWRF>=4

                ,DIABH=grid%h_diabatic                                 &

                ,QVTTEND=grid%qvttend, QCTTEND=grid%qcttend            & 

                ,QRTTEND=grid%qrttend, QSTTEND=grid%qsttend            &

@LluisFB
Copy link
Contributor Author

LluisFB commented Jan 9, 2026

my apologies, I revised the compilation for CDXWRF=4, there were some mistakes. I fixed them and pushed into my fork

Lluís

@smileMchen
Copy link
Collaborator

@LluisFB
Can you clarify what you have changed for CDXWRF=4?
Any changes for CDXWRF=1?
Thanks.

@LluisFB
Copy link
Contributor Author

LluisFB commented Jan 12, 2026

HI @smileMchen,

These are only changes to compile when CXWRF=4, there where some mistakes in the configuration of the pre-compilation ifs. These are the changes regarding the code

I just modified the following:

  • Last commit
$ git diff HEAD^..HEAD
diff --git a/phys/module_diagnostics_driver.F b/phys/module_diagnostics_driver.F
index 4e151e38..13bfffb0 100644
--- a/phys/module_diagnostics_driver.F
+++ b/phys/module_diagnostics_driver.F
@@ -1415,8 +1415,8 @@ CONTAINS
                     ,FRACSOIL10CM=grid%fracsoil10cm                        &
 #ifdef CDXWRF
 #if CDXWRF>=1
-
-#elif CDXWRF>=4
+#endif
+#if CDXWRF>=4
                     ,DIABH=grid%h_diabatic                                 &
                     ,QVTTEND=grid%qvttend, QCTTEND=grid%qcttend            & 
                     ,QRTTEND=grid%qrttend, QSTTEND=grid%qsttend            &

  • Previous last commit
$ git diff HEAD~2
diff --git a/Registry/registry.diags b/Registry/registry.diags
index 90c5b0fd..4e28b3b7 100644
--- a/Registry/registry.diags
+++ b/Registry/registry.diags
@@ -9,19 +9,18 @@ dimspec    np      2     namelist=num_press_levels         z     num_press_level
 #### Added for CORDEX!
 ## L. Fita 2 grid coordinates for the londbg,latdbg
 dimspec    iit     2     constant=2                        z     iit
-ifdef CDXWRF=3
+
 ## L. Fita. This should work, but WRF is not prepared for 4D output variables like this
-dimspec    ht      2     namelist=nhtasrng                 c     nhtasrng
-dimspec    hh      2     namelist=nhhursrng                c     nhhursrng
-dimspec    lt      2     namelist=nltasrng                 c     nltasrng
-dimspec    lh      2     namelist=nlhursrng                c     nlhursrng
-dimspec    wd      2     namelist=nwbdsrng                 c     nwbdsrng
-dimspec    ws      2     namelist=nwssrng                  c     nwssrng
+dimspec    ht      2     namelist=nhtasrng                 z     nhtasrng
+dimspec    hh      2     namelist=nhhursrng                z     nhhursrng
+dimspec    lt      2     namelist=nltasrng                 z     nltasrng
+dimspec    lh      2     namelist=nlhursrng                z     nlhursrng
+dimspec    wd      2     namelist=nwbdsrng                 z     nwbdsrng
+dimspec    ws      2     namelist=nwssrng                  z     nwssrng
 ## L. Fita, so, WRF output will provide a (n[h/l]tasrng*n[h/l]hursrng) 3D variable instead
 dimspec    hth     2     namelist=nhtashursrng             z     nhtashursrng
 dimspec    lth     2     namelist=nltashursrng             z     nltashursrng
 dimspec    wds     2     namelist=nwbdswssrng              z     nwbdswssrng
-endif 

Lluís

@smileMchen
Copy link
Collaborator

smileMchen commented Jan 12, 2026

@ LluisFB
Thanks for the clarification. I have tried to compileCDXWRF with options 1,2,3, and 4. While options 2-4 can be done successfully, option 1 still doesn't work. Below are part of the errors I have seen during compiling:

module_diag_cordex.f90:811:59:

811 | CALL var_press(p(i,:,j), pb(i,:,j), dimz, press(i,:,j))

Error: Syntax error in argument list at (1)

module_diag_cordex.f90:814:75:
814 | CALL var_zg(ph(i,:,j), phb(i,:,j), dimz1, dimz, stzg(i,:,j), zg(i,:,j))

Error: Syntax error in argument list at (1)

module_diag_cordex.f90:816:31:

816 | geopoth(i,:,j) = zg(i,:,j)*g

There are more errors similar to above shown during compiling .....

@LluisFB
Copy link
Contributor Author

LluisFB commented Jan 13, 2026

Dear @smileMchen,

My apologies. There was an issue in the pre-compilation flags. I just committed the fix.

I should checked all the combinations.

Sorry,

Lluís

@weiwangncar
Copy link
Collaborator

@LluisFB Have you tried to compile the modified code on your system? The regression tests returned some syntax errors in module_diag_cordex.F. See one of the test output files here.
output_3.txt

@LluisFB
Copy link
Contributor Author

LluisFB commented Jan 14, 2026

Dear @weiwangncar,

In my system (personal computer with Debian 12and gcc compilers) I just finished to successfully re-compile with CDXWRF=2, CDXWRF=3, CDXWRF=4. CDXWRF=1 test was successfully performed yesterday (Jan 13th) and any further changes were made in the code.

@weiwangncar
Copy link
Collaborator

@LluisFB The regression tests do not test your particular option but for standard compilation and runs. So can you take a look at the attached file from above (output_3.txt), see if there is anything you can change. I tested your code with standard compilation on our computer with gfortran, it failed and pointed to the same syntax errors as shown in output_3.txt file. Thanks.

@LluisFB
Copy link
Contributor Author

LluisFB commented Jan 14, 2026

@weiwangncar I understand.

So, in your compilation / execution tests, which branch are you using? Do you activate any of the pre-compilation flags?

I will reproduce the compilation in my system and come back with the solution.

Thanks

@weiwangncar
Copy link
Collaborator

@LluisFB I cloned your code and checked out cdxwrf branch. I'm not using any of your options. I am only trying to compile default WRF code, without using any of your pre-compilation flags. This is to make sure your modification would not affect default use of the model.

@LluisFB
Copy link
Contributor Author

LluisFB commented Jan 14, 2026

HI @weiwangncar

I see what happens. The module is compiled even if the pre-compilation flags are not activated.

I do not know if it is an 'elegant' solution, but in my last commit, I emptied the module when the main flag is not activated

MODULE module_diag_cordex
#ifdef CORDEXDIAG

(....)
#endif
END MODULE module_diag_cordex

My apologies, for all the troubles I am making.I should have made all these tests before submitting the Pull Request. Sorry for making waste your time.

I am re-compiling again with CDXWRF=4 to see if it does crashes the compilation

Lluís

@LluisFB
Copy link
Contributor Author

LluisFB commented Jan 14, 2026

Re-compilation for CDXWRF=4 worked.

I assume it will work for the rest.

Lluís

@weiwangncar
Copy link
Collaborator

@LluisFB Will compilation work if you do not use any CDXWRF pre-compilation flags?

@smileMchen
Copy link
Collaborator

Re-compilation for CDXWRF=4 worked.

I assume it will work for the rest.

Lluís

Yes I can confirm that this option works. But the option CDXWRF=1 still failed. I will try the newly committed codes after the MPAS tutorial and keep you updated.

@LluisFB
Copy link
Contributor Author

LluisFB commented Jan 14, 2026

Yes @weiwangncar, I compiled as it is without using any flag

@LluisFB
Copy link
Contributor Author

LluisFB commented Jan 14, 2026

Hi @smileMchen,

Did you tried the last version? With all the new commits? I will re-check for CDXWRF=1

@weiwangncar
Copy link
Collaborator

It looks like the last commit worked for regression tests:

Test Type              | Expected  | Received |  Failed
= = = = = = = = = = = = = = = = = = = = = = = =  = = = =
Number of Tests        : 23           24
Number of Builds       : 60           57
Number of Simulations  : 158           150        0
Number of Comparisons  : 95           86        0

Failed Simulations are: 
None
Which comparisons are not bit-for-bit: 
None

@LluisFB
Copy link
Contributor Author

LluisFB commented Jan 14, 2026

Well, good news!

Again apologies for all the foreseeable issues.

Lluís

@smileMchen
Copy link
Collaborator

Hi @smileMchen,

Did you tried the last version? With all the new commits? I will re-check for CDXWRF=1

I used the 2nd latest commit. I haven't tried the latest one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two README.* files added should be moved to the doc/ folder, and ideally reworded to the instructions that would be used with https://github.com/wrf-model/WRF instead of still pointing to the fork branch. Could the two be combined into one README?

Information regarding WRF Model citations (including a DOI) can be found here: [https://www2.mmm.ucar.edu/wrf/users/citing_wrf.html](https://www2.mmm.ucar.edu/wrf/users/citing_wrf.html).

The WRF Model is open-source code in the public domain, and its use is unrestricted. The name "WRF", however, is a registered trademark of the University Corporation for Atmospheric Research. The WRF public domain notice and related information may be found here: [https://www2.mmm.ucar.edu/wrf/users/public.html](https://www2.mmm.ucar.edu/wrf/users/public.html).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change. It will help with tracking file history to have only changes that meaningfully change the file, unless the whitespace edits are deliberate.

cp configure.cordex.wrf configure.wrf
```

3. edit the `configure.wrf` and add the line (after the line `-DNETCDF` and/or `-DCLWRFGHG`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to explore other configuration methods other than needing to directly modify the configure.wrf file. Perhaps doing something similar to kpp/titan/venus in ./configure would be more appealing?

```
cp Registry/registry.cordex Registry/registry.cordex_comp
```
2. modify the `Registry/registry.cordex_comp` accordingly to the value of `CDXWRF`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The registry supports ifdef, ifndef, endif constructs. This doesn't immediately work for the exact logic laid out here since the define is hierarchical but this were broken out into 4 individual defines automatically during ./configure then users would not need to modify the registry each time.

state real s_pl i{np}j misc 1 Z h{23} "S_PL" "Pressure level data, Speed" "m s-1"
state real td_pl i{np}j misc 1 Z h{23} "TD_PL" "Pressure level data, Dew point temperature" "K"
state real q_pl i{np}j misc 1 Z h{23} "Q_PL" "Pressure level data, Mixing ratio" "kg/kg"
state real q_pl i{np}j misc 1 Z h{23} "Q_PL" "Pressure level data, water vapour Mixing ratio" "kg/kg"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was changing the description intentional?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file could instead be conditionally be compiled (see frame/Makefile RSL_OBJS for an example on control of this via a variable). Likewise, the compile logic and file additions should be equally done in the CMake build as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CDXWRF module in WRFv7.1

6 participants