Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

How to add a new variable into the wrfinput that can be used by the physical schemes

Erenw

New member
Hi,
I think the roughness parameterizations may not present satisfied results of sea surface roughness length, thus, i wanna use the z0 from the ERA5 or HYCOM by adding z0 to the wrfinput file. Now, i only know that the Registry.EM_COMMON need to be modified for 'ZNT'. Except for this, i have no idea what else should i do so that i can use the ZNT directly in the relevant physical schemes. Could anyone help me or are there other solutions, e.g. something like sst_update.
Thanks for your time, i am grateful for your advice.
 
Hi,

Please follow the steps below to add ZNT to wrfinput:

(1) read ZNT from ERA5, include this variable in your intermediate files.

(2) edit METGRID.TBL so that metgrid.exe can process ZNT. For example, add the line below to METGRID.TBL:
name=ERA5Z0 ; output_name=ZNT

(3) In Registry.EM_COMMON. Change the line below from

state real ZNT ij misc 1 - i3r "ZNT" "TIME-VARYING ROUGHNESS LENGTH"

to:

state real ZNT ij misc 1 - i03r "ZNT" "TIME-VARYING ROUGHNESS LENGTH" "m"

(4) remember to do ./clean -a, then recompile WRF

Let me know if you have any issues.
 
Thank you so much, Ming. i got it worked! two more questions i wanna ask:
1. The ZNT already exists in the wrfinput file, does wrf read it as one of the initial and lateral boundary variables? or i need to modify the WRF code?
2. The roughness in the surface layer scheme like MYNN and MYJ will be recalculated the ZNT, e.g." Z0=MAX(USTFC*USTAR*USTAR,1.59E-5)" in the MYJ scheme. Should i comment out the calculation of Z0 and make it only an input variable in the relevant subroutines
 
Last edited:
ZNT is only read into WRF as initial condition. It is not included in the lateral boundary condition.

If you want to keep ZNT unchanged, then yes you should comment out those codes that calculate ZNT.
 
Oh, I need a time-varying z0.
How could I make ZNT the lateral boundary condition? which code file should I review?
 
Hi Ming,

Thanks for your previous answer. I have a similar issue and would greatly appreciate your assistance.

I am trying to add a new variable to the static data in WPS and then use it in the CAM UW shallow convection module. I have successfully added the new variable to the met_em files, where its values are correct. However, when I try to include it in WRF, the wrfinput_d01 file only shows the name of the new variable, but all its values are zero.

I suspect there might be an issue with my Registry files, but I have already added the new variable to Registry, Registry.EM, Registry.EM_COMMON, registry.cam, and other related files. Despite this, I cannot figure out why the variable's values are zero in the wrfinput file.

Attached are the outputs of the variable in met_em file and the wrfinput file, and the code files I modified.

Thank you very much for your help!
 

Attachments

  • code.tar
    354.9 KB · Views: 1
  • output_tanslope_metfile.txt
    1.3 MB · Views: 1
  • output_tanslope_wrfinput.txt
    536.2 KB · Views: 1
Would you please clarify how you change the codes?
Hi Ming,

Thank you for your response, and I apologize for the late reply. Sure, I can clarify the code changes I made.

I modified files in the Registry, dym_em, phys, and inc directories.
  1. Registry Files:
    • I added the new variable tanslope in the readonly package within the Registry, Registry.backup, and Registry.EM files.
    • In the Registry.EM_COMMON file, I added tanslope in the camuwshcuscheme package with shcu_physics == 2.
    • The following line was added to the registry.cam file:

      state real tanslope ij misc 1 - i012rhd=(interp_mask_field:lu_index,iswater)u=(copy_fcnm) "tanslope" "tan(slope) from 90-m DEM" ""

    • All modifications in the Registry files are recorded in the attached file Registry_changes.txt.
  2. dym_em File:
    • The variable tanslope was added in the shallowcu_driver subroutine within module_first_rk_step_part1.F.
    • The attached file dyn_em_changes.png shows this change.
  3. phys Files:
    • I added the variable in the corresponding subroutines within the module_shallowcu_driver and module_shcu_camuwshcu_driver files.
    • These changes are detailed in the attached photos.
  4. inc Files:
    • The variable tanslope was added in 16 files, as detailed in inc_changes.txt.
With these modified files, WRF can be compiled successfully. However, I suspect there might be an issue with the modified Registry files, causing the variable values to be zero in the wrfinput file. Therefore, I have attached all modified Registry files for your review.

Thank you very much for your time and help.
 

Attachments

  • inc_changes.txt
    3.8 KB · Views: 1
  • phys_change5_in_module_shcu_camuwshcu_driver.png
    phys_change5_in_module_shcu_camuwshcu_driver.png
    8.9 KB · Views: 0
  • phys_change4_in_module_shcu_camuwshcu_driver.png
    phys_change4_in_module_shcu_camuwshcu_driver.png
    35.6 KB · Views: 0
  • phys_change3_in_module_shallowcu_driver.png
    phys_change3_in_module_shallowcu_driver.png
    48 KB · Views: 0
  • phys_change2_in_module_shallowcu_driver.png
    phys_change2_in_module_shallowcu_driver.png
    11.1 KB · Views: 0
  • phys_change1_in_module_shallowcu_driver.png
    phys_change1_in_module_shallowcu_driver.png
    90 KB · Views: 0
  • dyn_em_change.png
    dyn_em_change.png
    175.1 KB · Views: 0
  • Registry_changes.txt
    5.1 KB · Views: 1
  • Registry.tar
    65.3 KB · Views: 0
I didn't see any issues in your code modification. Sorry that I don't have an immediate answer to the problem...

Just one quick test:

please add the line below to Registry.EM_COMMON and remove it from registry.cam

state real tanslope ij misc 1 - i012rhd=(interp_mask_field:lu_index,iswater)u=(copy_fcnm) "tanslope" "tan(slope) from 90-m DEM" ""

Then recompile WRF and try again. Please let me know whether it works. Thanks.
 
Top