Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

Add new namelist variables

ldong@unm_edu

New Member
Hi there,

I am doing aquaplanet simulation using cesm CAM standalone scripts with cam4 physics. As for use_case, I used aquaplanet_cam4.xml. After configuration and building namelist, I desire to add a few more new namelist variables which are not present in the output "atm_in" file. For instance, I wanted to add 'cldfrc_dp1=0.14D0' (the deep convection parameter for cloud fraction calculation) in the atm_in file. Below is what I did in editing the namelist related files.

1. In the source code models/atm/cam/src/physics/cam/cloud_fraction.F90, I first defined the new namelist variable and then added it to the existing namelist group by doing:

real(r8) :: cldfrc_dp1 = unset_r8
...
namelist /cldfrc_nl/ cldfrc_dp1, cldfrc_freeze_dry, cldfrc_ice, cldfrc_rhminl, cldfrc_rhminh

2. In namelist_definition.xml (in the CAM standalone bld directory), I added following content in the Cloud Fraction section.


Default: set by build-namelist


3. In namelist_default_cam.xml, I added the following content in the Cloud Fraction section.

0.14D0

4. In the build-namelist script, I added the following content in the Cloud Fraction section.

add_default($nl, 'cldfrc_dp1');

5. Then configure with the modified source code "cloud_fraction.F90" in the mod source directory. Build the model and build namelist. Then I did see the new namelist parameter 'cldfrc_dp1=0.14D0' showing up in the atm_in file.

6. Run the model, but it crashed returning an error message "ENDRUN:cldfrc_readnl:: ERROR reading namelist"

Did I miss something here? I'd appreciate if anyone can advise how to properly add a new namelist variable. Thanks.

Li
 

ldong@unm_edu

New Member
Hi,

Just noticed that in my previous post the statement of defining the new namelist variable in cloud_fraction.F90 is not readable. It should read:

real(r8) :: cldfrc_dp1 = unset_r8

Thanks.

Li

ldong said:
Hi there,

I am doing aquaplanet simulation using cesm CAM standalone scripts with cam4 physics. As for use_case, I used aquaplanet_cam4.xml. After configuration and building namelist, I desire to add a few more new namelist variables which are not present in the output "atm_in" file. For instance, I wanted to add 'cldfrc_dp1=0.14D0' (the deep convection parameter for cloud fraction calculation) in the atm_in file. Below is what I did in editing the namelist related files.

1. In the source code models/atm/cam/src/physics/cam/cloud_fraction.F90, I first defined the new namelist variable and then added it to the existing namelist group by doing:

real(r8) :: cldfrc_dp1 = unset_r8
...
namelist /cldfrc_nl/ cldfrc_dp1, cldfrc_freeze_dry, cldfrc_ice, cldfrc_rhminl, cldfrc_rhminh

2. In namelist_definition.xml (in the CAM standalone bld directory), I added following content in the Cloud Fraction section.


Default: set by build-namelist


3. In namelist_default_cam.xml, I added the following content in the Cloud Fraction section.

0.14D0

4. In the build-namelist script, I added the following content in the Cloud Fraction section.

add_default($nl, 'cldfrc_dp1');

5. Then configure with the modified source code "cloud_fraction.F90" in the mod source directory. Build the model and build namelist. Then I did see the new namelist parameter 'cldfrc_dp1=0.14D0' showing up in the atm_in file.

6. Run the model, but it crashed returning an error message "ENDRUN:cldfrc_readnl:: ERROR reading namelist"

Did I miss something here? I'd appreciate if anyone can advise how to properly add a new namelist variable. Thanks.

Li
 

eaton

CSEG and Liaisons
Did you rebuild the model after making changes to cloud_fraction.F90? The procedure that you outlined sounds correct.

FYI, the cldfrc_dp1 variable and others have been added to the namelist in CAM-5.1 which will be included in CESM1.0.3 due to be released soon (maybe next week).
 

rajkmsaini

Dr. Raj Saini
Member
Hi there,

I am doing aquaplanet simulation using cesm CAM standalone scripts with cam4 physics. As for use_case, I used aquaplanet_cam4.xml. After configuration and building namelist, I desire to add a few more new namelist variables which are not present in the output "atm_in" file. For instance, I wanted to add 'cldfrc_dp1=0.14D0' (the deep convection parameter for cloud fraction calculation) in the atm_in file. Below is what I did in editing the namelist related files.

1. In the source code models/atm/cam/src/physics/cam/cloud_fraction.F90, I first defined the new namelist variable and then added it to the existing namelist group by doing:

real(r8) :: cldfrc_dp1 = unset_r8
...
namelist /cldfrc_nl/ cldfrc_dp1, cldfrc_freeze_dry, cldfrc_ice, cldfrc_rhminl, cldfrc_rhminh

2. In namelist_definition.xml (in the CAM standalone bld directory), I added following content in the Cloud Fraction section.


Default: set by build-namelist


3. In namelist_default_cam.xml, I added the following content in the Cloud Fraction section.

0.14D0

4. In the build-namelist script, I added the following content in the Cloud Fraction section.

add_default($nl, 'cldfrc_dp1');

5. Then configure with the modified source code "cloud_fraction.F90" in the mod source directory. Build the model and build namelist. Then I did see the new namelist parameter 'cldfrc_dp1=0.14D0' showing up in the atm_in file.

6. Run the model, but it crashed returning an error message "ENDRUN:cldfrc_readnl:: ERROR reading namelist"

Did I miss something here? I'd appreciate if anyone can advise how to properly add a new namelist variable. Thanks.

Li

Hello Friend,

Did you solve this problem?

I am stuck similar problem. Can you help me regarding this? I want to add some other variables to store into history files. I use cesme1_2_2/cam5.3.

Thanks in advance.
 

rajkmsaini

Dr. Raj Saini
Member
Hello Dear Eaton,

Can you please share some document related this.?

I am new to used CESM. Please tell me in detail so I can implement.

Thank you in advance.


The procedure outlined in the original post is correct. What is the error you get?
 

eaton

CSEG and Liaisons
I just checked the CAM User's Guide and I don't see that this procedure is
contained there. So it appears there is no detailed documentation.

I will add a few details to the outline in the original post in this
thread. You didn't say what CESM version you are using, so I will assume a
recent version, CESM2.x.

1. The example is adding a new variable to an existing namelist in
cloud_fraction.F90. Note that in recent code the filepath is now
components/cam/src/physics/cam/cloud_fraction.F90. Also note that the
variable that was being added, cldfrc_dp1, is now part of the namelist in
the released code.

In the cloud_fraction module, after reading the namelist variables,
cldfrc_dp1 is assigned to the module variable dp1. It is common to use
shorter variable names in the module than are needed in the namelist.
Variables in the namelist must be unique to CAM. For that reason the
convention is to prepend some identifier that is unique to the module, in
this case 'cldfrc_' is prepended to 'dp1'.

The other important detail which I just noticed is missing from the
original post is that since the namelist is only read by the master task,
the values must be broadcast to all other tasks. In this example that is
done by the following line of code:

call mpibcast(dp1 , 1, mpir8, 0, mpicom)

This is an old style example; we're in a gradual process of updating the
broadcast statements to use the MPI interfaces directly rather than use
this wrapper 'mpibcast' routine. So you'll see different versions
depending on which module you look at. The only thing you need to know to
copy this line for a new variable is that mpir8 means the data variable is
an 8-byte real, and the argument '1' means that 1 8-byte data value is
being broadcast.

2. The location of the namelist definition file is
components/cam/bld/namelist_files/namelist_definition.xml

The entry for cldfrc_dp1 is:

Code:
<entry id="cldfrc_dp1" type="real" category="cldfrc"
       group="cldfrc_nl" valid_values="" >
parameter for deep convection cloud fraction.
Default: set by build-namelist
</entry>

Every namelist variable that the build-namelist utility adds to the atm_in
file must be defined in this file. See the documention at the top of the
file for a description of the attributes. Getting the attributes right is
the only thing that is necessary for build-namelist to recognize the new
variable. The content of the 'entry' elements is only used for
auto-generated namelist documentation.

At this point the newly added variable can be used. If you add the
variable and value pair to user_nl_cam it will appear in atm_in in the
correct namelist group. If you don't add it to user_nl_cam then it won't
appear in atm_in. If you wish to have the new variable appear
automatically in atm_in without having to add it to user_nl_cam, then steps
3 and 4 in the original post will accomplish that. But in development work
it's often the case that the new variables are for testing something rather
than for production code and the effort to get the correct values to be
added to atm_in by default are not really necessary.
 

rajkmsaini

Dr. Raj Saini
Member
Thank you for you reply, Drear Eaton.

I am using cesm_1_1_2 and am new to use this software. Its a very big task me to understand this. I am going through it step by step.

Sidewise, I am working on a problem where I need to to defined user define value of relative humidity
like rhminl = 0.800, 0.85 and 0.99 .

I am not able to define because I am new ti this software use.

Main big problem with this software is lack of user guide and manual informations.

If you help me regarding this so It a great help me step by stem to understand this.

Thank you in advance.



I just checked the CAM User's Guide and I don't see that this procedure is
contained there. So it appears there is no detailed documentation.

I will add a few details to the outline in the original post in this
thread. You didn't say what CESM version you are using, so I will assume a
recent version, CESM2.x.

1. The example is adding a new variable to an existing namelist in
cloud_fraction.F90. Note that in recent code the filepath is now
components/cam/src/physics/cam/cloud_fraction.F90. Also note that the
variable that was being added, cldfrc_dp1, is now part of the namelist in
the released code.

In the cloud_fraction module, after reading the namelist variables,
cldfrc_dp1 is assigned to the module variable dp1. It is common to use
shorter variable names in the module than are needed in the namelist.
Variables in the namelist must be unique to CAM. For that reason the
convention is to prepend some identifier that is unique to the module, in
this case 'cldfrc_' is prepended to 'dp1'.

The other important detail which I just noticed is missing from the
original post is that since the namelist is only read by the master task,
the values must be broadcast to all other tasks. In this example that is
done by the following line of code:

call mpibcast(dp1 , 1, mpir8, 0, mpicom)

This is an old style example; we're in a gradual process of updating the
broadcast statements to use the MPI interfaces directly rather than use
this wrapper 'mpibcast' routine. So you'll see different versions
depending on which module you look at. The only thing you need to know to
copy this line for a new variable is that mpir8 means the data variable is
an 8-byte real, and the argument '1' means that 1 8-byte data value is
being broadcast.

2. The location of the namelist definition file is
components/cam/bld/namelist_files/namelist_definition.xml

The entry for cldfrc_dp1 is:

Code:
<entry id="cldfrc_dp1" type="real" category="cldfrc"
       group="cldfrc_nl" valid_values="" >
parameter for deep convection cloud fraction.
Default: set by build-namelist
</entry>

Every namelist variable that the build-namelist utility adds to the atm_in
file must be defined in this file. See the documention at the top of the
file for a description of the attributes. Getting the attributes right is
the only thing that is necessary for build-namelist to recognize the new
variable. The content of the 'entry' elements is only used for
auto-generated namelist documentation.

At this point the newly added variable can be used. If you add the
variable and value pair to user_nl_cam it will appear in atm_in in the
correct namelist group. If you don't add it to user_nl_cam then it won't
appear in atm_in. If you wish to have the new variable appear
automatically in atm_in without having to add it to user_nl_cam, then steps
3 and 4 in the original post will accomplish that. But in development work
it's often the case that the new variables are for testing something rather
than for production code and the effort to get the correct values to be
added to atm_in by default are not really necessary.
 

rajkmsaini

Dr. Raj Saini
Member
Still, I could not get success to solve my problem by following this.

Hi there,

I am doing aquaplanet simulation using cesm CAM standalone scripts with cam4 physics. As for use_case, I used aquaplanet_cam4.xml. After configuration and building namelist, I desire to add a few more new namelist variables which are not present in the output "atm_in" file. For instance, I wanted to add 'cldfrc_dp1=0.14D0' (the deep convection parameter for cloud fraction calculation) in the atm_in file. Below is what I did in editing the namelist related files.

1. In the source code models/atm/cam/src/physics/cam/cloud_fraction.F90, I first defined the new namelist variable and then added it to the existing namelist group by doing:

real(r8) :: cldfrc_dp1 = unset_r8
...
namelist /cldfrc_nl/ cldfrc_dp1, cldfrc_freeze_dry, cldfrc_ice, cldfrc_rhminl, cldfrc_rhminh

2. In namelist_definition.xml (in the CAM standalone bld directory), I added following content in the Cloud Fraction section.


Default: set by build-namelist


3. In namelist_default_cam.xml, I added the following content in the Cloud Fraction section.

0.14D0

4. In the build-namelist script, I added the following content in the Cloud Fraction section.

add_default($nl, 'cldfrc_dp1');

5. Then configure with the modified source code "cloud_fraction.F90" in the mod source directory. Build the model and build namelist. Then I did see the new namelist parameter 'cldfrc_dp1=0.14D0' showing up in the atm_in file.

6. Run the model, but it crashed returning an error message "ENDRUN:cldfrc_readnl:: ERROR reading namelist"

Did I miss something here? I'd appreciate if anyone can advise how to properly add a new namelist variable. Thanks.

Li
 
Top