From 7031c9dd24831af754862b23d7d8244e7983b237 Mon Sep 17 00:00:00 2001 From: braczka Date: Mon, 9 Sep 2024 14:52:43 -0600 Subject: [PATCH 1/7] THM is mandatory WRF temp variable --- models/wrf/readme.rst | 13 ++++++++++++- models/wrf/tutorial/README.rst | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/models/wrf/readme.rst b/models/wrf/readme.rst index ebb322751..0e36421e6 100644 --- a/models/wrf/readme.rst +++ b/models/wrf/readme.rst @@ -24,7 +24,10 @@ Some important WRF-DART updates include: operator calculations. - Version 11.5.0: Improves compatibility with WRFv4+ versions where - the prognostic 3D temperature variable is THM. + the prognostic 3D temperature variable is THM. It is now mandatory to + include THM instead of T in the ``wrf_state_variables`` namelist. + + It is always recommended that you update your DART version to the `latest release `__ before beginning new research. @@ -336,6 +339,14 @@ For example: 'PSFC','QTY_PRESSURE','TYPE_PS','UPDATE','999', +.. Important:: + + It is mandatory to include ``THM`` instead of ``T`` as the ``TYPE_T`` WRF + temperature variable. This is because ``THM`` is the prognostic temperature variable + that will impact the forecast when updated. Also, including ``T`` can give + boundscheck errors as described in `issue #728. `__ + + - polar, periodic_x The ``Polar`` and ``periodic_x`` namelist values are used in global WRF simulations. diff --git a/models/wrf/tutorial/README.rst b/models/wrf/tutorial/README.rst index 2dd00180d..4a0bd6c4e 100644 --- a/models/wrf/tutorial/README.rst +++ b/models/wrf/tutorial/README.rst @@ -19,12 +19,16 @@ either WRF or DART. versions 11.4.0 and earlier because those older versions do not account for different coordinate systems including the sigma hybrid coordinates as described in `DART Issue #650 `__. + Furthermore, older versions do not account for the prognostic temperature variable switch from ``T`` (perturbation potential temperature) to ``THM``, (either perturbation potential temperature or perturbation moist potential temperature) as described in `DART issue #661 `__. The current implementation of the code sets ``T=THM`` because within &dynamics section of ``namelist.input`` - ``use_theta_m=0``. + ``use_theta_m=0``. For this reason, It is mandatory to include ``THM`` instead of + ``T`` as the ``TYPE_T`` within the wrf_state_variables namelist. Furthermore, including + ``T`` in the namelist can lead to errors in the WRF model_mod bounds check as + described in `Issue #728. `__ Earlier version of WRF (v3.9) may run without errors with more recent versions of DART (later than 11.4.0), but the assimilation performance will be deprecated. From 0f5f41616243770c550c810d3ec1679e1d554ada Mon Sep 17 00:00:00 2001 From: braczka Date: Thu, 3 Oct 2024 16:09:29 -0600 Subject: [PATCH 2/7] Force error for WRF variable T --- models/wrf/model_mod.f90 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/models/wrf/model_mod.f90 b/models/wrf/model_mod.f90 index 9ca5ddbe7..82684bb99 100644 --- a/models/wrf/model_mod.f90 +++ b/models/wrf/model_mod.f90 @@ -694,6 +694,19 @@ subroutine static_init_model() ! JPH now that we have the domain ID just go ahead and get type indices once ! NOTE: this is not strictly necessary - can use only stagger info in the future (???) + + ! If using WRF temperature variable 'T' instead of 'THM' fail immediately to + ! prevent boundscheck errors. For WRFv4 and later version variable 'T' is + ! diagnostic, thus updating the 'THM' variable (prognostic) is preferred. + + if ( wrf%dom(id)%type_t >= 0 .and. get_type_ind_from_type_string(id,'T') >=0) then + + write(errstring,*)'WRF temperature variable T in model_nml must be replaced & + with THM for WRFv4 and later' + call error_handler(E_ERR,'static_init_model', errstring, source, revision, revdate) + + endif + wrf%dom(id)%type_u = get_type_ind_from_type_string(id,'U') wrf%dom(id)%type_v = get_type_ind_from_type_string(id,'V') wrf%dom(id)%type_w = get_type_ind_from_type_string(id,'W') From fac042b175cb936cfe516f3dbb7715a8e6c8076d Mon Sep 17 00:00:00 2001 From: braczka Date: Wed, 9 Oct 2024 08:38:28 -0600 Subject: [PATCH 3/7] Simplify THM error call --- models/wrf/model_mod.f90 | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/models/wrf/model_mod.f90 b/models/wrf/model_mod.f90 index 82684bb99..45c596794 100644 --- a/models/wrf/model_mod.f90 +++ b/models/wrf/model_mod.f90 @@ -695,14 +695,10 @@ subroutine static_init_model() ! JPH now that we have the domain ID just go ahead and get type indices once ! NOTE: this is not strictly necessary - can use only stagger info in the future (???) - ! If using WRF temperature variable 'T' instead of 'THM' fail immediately to - ! prevent boundscheck errors. For WRFv4 and later version variable 'T' is - ! diagnostic, thus updating the 'THM' variable (prognostic) is preferred. - - if ( wrf%dom(id)%type_t >= 0 .and. get_type_ind_from_type_string(id,'T') >=0) then + if (get_type_ind_from_type_string(id,'T') >=0) then - write(errstring,*)'WRF temperature variable T in model_nml must be replaced & - with THM for WRFv4 and later' + write(errstring,*)'WRF temperature variable T in model_nml must be replaced', & + ' with THM for WRFv4 and later' call error_handler(E_ERR,'static_init_model', errstring, source, revision, revdate) endif @@ -747,6 +743,23 @@ subroutine static_init_model() !wrf%dom(id)%type_fall_spd = get_type_ind_from_type_string(id,'VT_DBZ_WT') wrf%dom(id)%type_hdiab = get_type_ind_from_type_string(id,'H_DIABATIC') + ! If using WRF temperature variable 'T' instead of 'THM' fail immediately to + ! prevent boundscheck errors. For WRFv4 and later version variable 'T' is + ! diagnostic, thus updating the 'THM' variable (prognostic) is preferred. + + if ( wrf%dom(id)%type_t >= 0 .and. get_type_ind_from_type_string(id,'T') >=0) then + + write(errstring,*)'WRF temperature variable T in model_nml must be replaced & + with THM for WRFv4 and later' + call error_handler(E_ERR,'static_init_model', errstring, source, revision, revdate) + + endif + + + + + + ! variable bound table for setting upper and lower bounds of variables var_bounds_table(1:wrf%dom(id)%number_of_wrf_variables,1) = wrf%dom(id)%lower_bound var_bounds_table(1:wrf%dom(id)%number_of_wrf_variables,2) = wrf%dom(id)%upper_bound From 934d82ed8e022bda3b7ae78c0a7ffb11cbb4d3f0 Mon Sep 17 00:00:00 2001 From: braczka Date: Wed, 9 Oct 2024 08:42:01 -0600 Subject: [PATCH 4/7] Correct THM error call --- models/wrf/model_mod.f90 | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/models/wrf/model_mod.f90 b/models/wrf/model_mod.f90 index 45c596794..9f135421b 100644 --- a/models/wrf/model_mod.f90 +++ b/models/wrf/model_mod.f90 @@ -695,6 +695,11 @@ subroutine static_init_model() ! JPH now that we have the domain ID just go ahead and get type indices once ! NOTE: this is not strictly necessary - can use only stagger info in the future (???) + ! If using WRF temperature variable 'T' instead of 'THM' fail immediately to + ! prevent boundscheck errors. For WRFv4 and later version variable 'T' is + ! diagnostic, thus updating the 'THM' variable (prognostic) is preferred. + + if (get_type_ind_from_type_string(id,'T') >=0) then write(errstring,*)'WRF temperature variable T in model_nml must be replaced', & @@ -743,23 +748,6 @@ subroutine static_init_model() !wrf%dom(id)%type_fall_spd = get_type_ind_from_type_string(id,'VT_DBZ_WT') wrf%dom(id)%type_hdiab = get_type_ind_from_type_string(id,'H_DIABATIC') - ! If using WRF temperature variable 'T' instead of 'THM' fail immediately to - ! prevent boundscheck errors. For WRFv4 and later version variable 'T' is - ! diagnostic, thus updating the 'THM' variable (prognostic) is preferred. - - if ( wrf%dom(id)%type_t >= 0 .and. get_type_ind_from_type_string(id,'T') >=0) then - - write(errstring,*)'WRF temperature variable T in model_nml must be replaced & - with THM for WRFv4 and later' - call error_handler(E_ERR,'static_init_model', errstring, source, revision, revdate) - - endif - - - - - - ! variable bound table for setting upper and lower bounds of variables var_bounds_table(1:wrf%dom(id)%number_of_wrf_variables,1) = wrf%dom(id)%lower_bound var_bounds_table(1:wrf%dom(id)%number_of_wrf_variables,2) = wrf%dom(id)%upper_bound From 2d99f18ee4b8ffc2e2c5c94d958590f10c7b3cb0 Mon Sep 17 00:00:00 2001 From: braczka Date: Thu, 10 Oct 2024 15:42:29 -0600 Subject: [PATCH 5/7] Enforcing inclusion of THM --- models/wrf/model_mod.f90 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/models/wrf/model_mod.f90 b/models/wrf/model_mod.f90 index 9f135421b..381c60cc1 100644 --- a/models/wrf/model_mod.f90 +++ b/models/wrf/model_mod.f90 @@ -695,15 +695,17 @@ subroutine static_init_model() ! JPH now that we have the domain ID just go ahead and get type indices once ! NOTE: this is not strictly necessary - can use only stagger info in the future (???) - ! If using WRF temperature variable 'T' instead of 'THM' fail immediately to - ! prevent boundscheck errors. For WRFv4 and later version variable 'T' is - ! diagnostic, thus updating the 'THM' variable (prognostic) is preferred. + ! The model_nml must contain WRF temperature variable 'THM' to + ! prevent boundcheck error. For WRFv4 and later versions variable 'T' is + ! diagnostic, thus updating the 'THM' variable (prognostic) is also preferred + ! for all DA applications. + - if (get_type_ind_from_type_string(id,'T') >=0) then + if (get_type_ind_from_type_string(id,'T') >=0 .or. get_type_ind_from_type_string(id,'THM') <=0) then - write(errstring,*)'WRF temperature variable T in model_nml must be replaced', & - ' with THM for WRFv4 and later' + write(errstring,*)'WRF temperature variable THM must appear in DART model_nml', & + ' for WRFv4 and later' call error_handler(E_ERR,'static_init_model', errstring, source, revision, revdate) endif From 75b25ce5803faf0c6b8ef3681ce60b1c5746670c Mon Sep 17 00:00:00 2001 From: Brett Raczka Date: Tue, 22 Oct 2024 10:57:06 -0600 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Helen Kershaw <20047007+hkershaw-brown@users.noreply.github.com> --- models/wrf/readme.rst | 3 +-- models/wrf/tutorial/README.rst | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/models/wrf/readme.rst b/models/wrf/readme.rst index 0e36421e6..04fc4267b 100644 --- a/models/wrf/readme.rst +++ b/models/wrf/readme.rst @@ -343,8 +343,7 @@ For example: It is mandatory to include ``THM`` instead of ``T`` as the ``TYPE_T`` WRF temperature variable. This is because ``THM`` is the prognostic temperature variable - that will impact the forecast when updated. Also, including ``T`` can give - boundscheck errors as described in `issue #728. `__ + that will impact the forecast when updated. - polar, periodic_x diff --git a/models/wrf/tutorial/README.rst b/models/wrf/tutorial/README.rst index 4a0bd6c4e..6e3a7be73 100644 --- a/models/wrf/tutorial/README.rst +++ b/models/wrf/tutorial/README.rst @@ -26,9 +26,7 @@ either WRF or DART. `DART issue #661 `__. The current implementation of the code sets ``T=THM`` because within &dynamics section of ``namelist.input`` ``use_theta_m=0``. For this reason, It is mandatory to include ``THM`` instead of - ``T`` as the ``TYPE_T`` within the wrf_state_variables namelist. Furthermore, including - ``T`` in the namelist can lead to errors in the WRF model_mod bounds check as - described in `Issue #728. `__ + ``T`` as the ``TYPE_T`` within the wrf_state_variables namelist. Earlier version of WRF (v3.9) may run without errors with more recent versions of DART (later than 11.4.0), but the assimilation performance will be deprecated. From 95fbd1af91ea9cfa7a2fb6c80263536c52d9c839 Mon Sep 17 00:00:00 2001 From: braczka Date: Tue, 22 Oct 2024 10:58:30 -0600 Subject: [PATCH 7/7] Editing boundscheck error comment --- models/wrf/model_mod.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/wrf/model_mod.f90 b/models/wrf/model_mod.f90 index 381c60cc1..b48167294 100644 --- a/models/wrf/model_mod.f90 +++ b/models/wrf/model_mod.f90 @@ -695,8 +695,8 @@ subroutine static_init_model() ! JPH now that we have the domain ID just go ahead and get type indices once ! NOTE: this is not strictly necessary - can use only stagger info in the future (???) - ! The model_nml must contain WRF temperature variable 'THM' to - ! prevent boundcheck error. For WRFv4 and later versions variable 'T' is + ! Prevent boundscheck error by making WRF temperature variable 'THM' as mandatory. + ! Also, for WRFv4 and later versions variable 'T' is ! diagnostic, thus updating the 'THM' variable (prognostic) is also preferred ! for all DA applications.