Rconfig registry entry for a non-namelist variable

Topics related to current and future physics in the WRF as well as any problems you may have.

Rconfig registry entry for a non-namelist variable

Postby hannah » Fri Sep 16, 2011 11:36 am

I would like to add a variable that is calculated in one of the microphysics schemes to the WRF output. I understand I need to add an "rconfig" entry to the Registry file to do this, but all the examples and documentation for this are for new variables that are defined in the namelist, rather than variables that are already defined in the code (microphysics scheme in this case).


example for a namelist variable:
# Type Sym How set N entries Default
rconfig integer spec_bdy_width namelist,bdy_control 1 1

It is the "How set" entry that I am confused about. Surely I need to specify somewhere that this variable can be found in the microphysics scheme so the model knows where to look for it.

Any help would be much appreciated.

Hannah
hannah
 
Posts: 27
Joined: Wed Jan 19, 2011 10:39 am

Re: Rconfig registry entry for a non-namelist variable

Postby jimmyc » Sun Sep 18, 2011 10:17 am

Adding a variable to the Registry does not require adding an rconfig entry. Rconfig is for adding a new namelist option. The how set feature is the default value of that variable.

The Registry is essentially a declaration of the output variables. Otherwise, at the top of the subroutine you are adding this variable it might say Local, so that the added variable does not conflict with other variables from this massive code base.

If the variable is already in the code, check to see if it is a local variable at the top of the subroutine (where it would be declared). Otherwise, check to see if it is in the registry. If it is already in the registry you just have to add the history stream (specifying where you want the variable output). if it isn't in the registry then you have to add it, by following another variable example.

It would help more if I knew what variable and what scheme you are adding to so I can follow along with what you are doing.
The views expressed in this message do not necessarily reflect those of NOAA or the National Weather Service or the University of Oklahoma.
James Correia, Jr
jimmyc
 
Posts: 519
Joined: Tue Apr 15, 2008 1:10 am

Re: Rconfig registry entry for a non-namelist variable

Postby hannah » Mon Sep 19, 2011 5:11 am

Thanks so much for getting back to me. The variable I need is "lamr" from the thompson microphysics scheme. Lamr is the slope of the raindrop distribution function (number raindrops as a function of drop diameter). It is declared locally near the top of subroutine mp_thompson. It isn't in the registry already...
hannah
 
Posts: 27
Joined: Wed Jan 19, 2011 10:39 am

Re: Rconfig registry entry for a non-namelist variable

Postby jimmyc » Mon Sep 19, 2011 8:32 am

Ok.
So the first thing is to move it out of the local definition and into a declared position using "INOUT" in the microphysics scheme. Then add it to the subroutine call statement within the MP scheme.
then you will add it repetitively through the calling tree: microphysics driver, physics driver, etc. This includes adding it to solve_em.F in the dyn_em directory.
Then add it to the Registry.EM file (probably by looking at the qvapor and moist examples).

After looking at the variable there are a few things to note:
1. It is defined as Double precision.
2. It is used extensively in the code in a number of different ways and subroutines within the thompson code.

So you will need to define it for all grid points ijk. Then you will have to decide which radii you are keeping, unless you are keeping all of them in which case it will be ijk and some other dimension which you will have to define (4 dimensional).
The views expressed in this message do not necessarily reflect those of NOAA or the National Weather Service or the University of Oklahoma.
James Correia, Jr
jimmyc
 
Posts: 519
Joined: Tue Apr 15, 2008 1:10 am

Re: Rconfig registry entry for a non-namelist variable

Postby hannah » Mon Sep 19, 2011 9:18 am

Thank you so much for going to the trouble to check through the code. I understand what you said about passing the variable up through the tree and then adding it to the registry, but not the last paragraph you wrote.

1. Why do I need to redefine it for all ijk, as it is already defined in the subroutine? And how can I do this?
2. Why do I need to decide which radii to keep? Lamr is the slope of the distribution, which is defined over all radii.
hannah
 
Posts: 27
Joined: Wed Jan 19, 2011 10:39 am

Re: Rconfig registry entry for a non-namelist variable

Postby jimmyc » Mon Sep 19, 2011 9:40 am

I wasn't very clear, apologies. I saw lamr defined in a lot of ways, sometimes being computed and other times redefined as the inverse of ilamr. It was then defined in a variety of if statements. It is also defined in

The variable as it is written is not an array. So I guess you can simply pass lamr back to mp_gt_driver and then asign it as a 2d array after the call to mp_thompson. In the same fashion that pptrain is assigned to pcp_ra.

So in that case in the subroutine mp_gt_driver:
1. lets call the new variable, hlamr, under !..Subroutine arguements:
DOUBLE PRECISION, DIMENSION(ims:ime,jms,jme), INTENT(INOUT):: hlamr

2. add the reassignment:
hlamr(i,j) = lamr !this gives you the very last occurence of lamr from the mp_thompson subroutine

3. Add lamr to the subroutine call mp_thompson.

4. Add hlamr to the call for mp_gt_driver and add it to all the calls for the microphysics all the way back down to solve_em.F

5. Add hlamr to the Registry:
state real hlamr ij misc - - rh "hlamr" "Hannah's lamr" "Units"

making sure to format it like the registry does. rh means hlamr will be in the restart and history io stream. the history one is the wrfout file. I wrote "units" but you can add the actual units.

I am less confident about the use of double precision in the registry so I just left it as a real.

Then recompile.

That should get you started. Good Luck!
The views expressed in this message do not necessarily reflect those of NOAA or the National Weather Service or the University of Oklahoma.
James Correia, Jr
jimmyc
 
Posts: 519
Joined: Tue Apr 15, 2008 1:10 am

Re: Rconfig registry entry for a non-namelist variable

Postby hannah » Mon Sep 19, 2011 10:20 am

ok, thats brilliant thank you. I'm just not sure about one thing - the variable hlamr has dimensions i and j only, so does that mean there will be one value for each grid box in my domain? What I need is a value of lamr for each grid box and time step - does the time step part come in somewhere else in the model?
hannah
 
Posts: 27
Joined: Wed Jan 19, 2011 10:39 am

Re: Rconfig registry entry for a non-namelist variable

Postby jimmyc » Mon Sep 19, 2011 10:35 am

The way WRF is configured, you will get data at every output time you select. If you want data at every time step, well thats a lot of data!

One way you can deal with it is to compute statistics at every output time, which would help deal with the data volume.

The only other option is to put this variable in its own history file using the namelist options and changing the Registry entry to add an output stream.
The views expressed in this message do not necessarily reflect those of NOAA or the National Weather Service or the University of Oklahoma.
James Correia, Jr
jimmyc
 
Posts: 519
Joined: Tue Apr 15, 2008 1:10 am

Re: Rconfig registry entry for a non-namelist variable

Postby hannah » Mon Sep 19, 2011 11:12 am

No I meant every time step that is output in the history file, not every model time step! So it sounds like it should work then, I'll give it a go. Thanks for all your help.
hannah
 
Posts: 27
Joined: Wed Jan 19, 2011 10:39 am

Re: Rconfig registry entry for a non-namelist variable

Postby hannah » Tue Oct 04, 2011 11:34 am

Hi jimmyc,

The situation has evolved a bit since you last advised me and I am now having another difficulty:

To summarise:

- lamr is defined in the thompson microphysics scheme within various do k=kts,kte loops, but is a dimensionless number that is constantly overwritten. I need to get lamr at the surface for each grid (i,j) and history output time.
- I defined lamr as a 1D variable with dimension kts:kte, and replaced lamr with lamr(k) everywhere in the subroutine mp_thompson.
- at the end of the subroutine I assign lamr(kts) to lamr_surf (a dimensionless variable) :
lamr_surf = lamr(kts)
- in mp_gt_driver I define hlamr as real with dimensions (ims:ime,jms:jme) and assign
hlamr(i,j) = lamr_surf
after the call to the mp_thompson subroutine.
- I pass hlamr up to microphysics_driver and solve_em.

the problem is that hlamr, which does appear in the output file after registry edition, is 0 everywhere. I have printed out hlamr in solve_em (after the call to microphysics_driver) and it is reasonable (0 in some grids but non-zero elswhere) and somehow this gets overwritten somewhere else in the model.

Can you help??

Many thanks,
Hannah
hannah
 
Posts: 27
Joined: Wed Jan 19, 2011 10:39 am

Next

Return to Physics

Who is online

Users browsing this forum: No registered users and 5 guests