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

Output extra variable in CESM2.2/CAM6

nuvolet

Toni Viudez
Member
Greetings,

We are trying to add a new extra output variable that is not already output from the model.
Basically what we want to have in the history files are one of the input files we are using in that particular module, which is a gridded data with same spatial and temporal resolution as other variables.
We understood that there are basically 3 calls that need to be done:
  • addfld
  • add_default (optional)
  • outfld
For addfld, (addfld = Add a field to master field list), we saw we have to indicate: (fname, units, numlev, avgflag, long_name, decomp_type, [flag_xyfill], [flag_isccplev], [sampling_seq]) , where the 3 last ones are optional.

For add_default (optional, add_default = Add a field to the list of default fields on history file) needs to specify: (name, tindex, flag).

And finally for outfld (accumulate (or take min, max, etc. as appropriate) input field into its history buffer for appropriate tapes), it needs (fname, field, idim, c).

Assuming that we are using only addled and outfld as is used in other output variables in the module we are customizing, at the moment we are only able to have the variable in the history file but it is empty, which we already know it is not. Additionally we have seen and error in the cesium.log file like that: [zf09:03133] PMIX ERROR: NO-PERMISSIONS in file dstore_base.c at line 237, which we do not know if that's the reason and we do not know how to solve.
Does anybody have a suggestion?

Thanks in advance
 

cacraig

Cheryl Craig
CSEG and Liaisons
Staff member
Data is stored when outfld is called, but it is not written out until a later time in the process. Since your code aborted prematurely, it is most likely that the history file writing was not reached.

If you need more details, you will need to give us more information as specified at: Information to include in help requests

Also, I cloned and checked out cesm2_2_beta06, and there is no file dstore_base.c in the CESM code base, so it must be a file specific to your setup.
 

nuvolet

Toni Viudez
Member
Hi Cheryl,

Thanks for your response.
I think I was not using properly the function addfld, I was following a pdf I found from one of the CESM workshops and it looks like the function has been updated.
Before it was called like this:

Code:
call addfld (fname, units, numlev, avgflag, long_name, decomp_type, [flag_xyfill], [flag_isccplev], [sampling_seq])

and looks like is like this:

Code:
call addfld(fname, dimnames, avgflag, units, long_name, gridname,flag_xyfill, sampling_seq, standard_name, fill_value)

Now my concern is how I want to specify that the new variable only I wan tot define by name, dimnames, avgflag, units, long_name and fill_value.
How I can finally define the fill_value as -999.0:
Like this:
call addfld(fname, dimnames, avgflag, units, long_name, fill_value=-999.0)
or like this:
call addfld(fname, dimnames, avgflag, units, long_name, -999.0)

Thanks in advance
 

cacraig

Cheryl Craig
CSEG and Liaisons
Staff member
Your question is a basic Fortran question. In Fortran, optional arguments can be specified in the calling list one of two ways, by order or by name.

In your first example, using "fill_value=-999.0" you are specifying the value with its name and this will work properly. Optional arguments can appear in any order when you supply the name.

In your second example, since you do not specify the name, then Fortran will use the order of the variable in the argument list. Since the sixth argument is "flag_xyfill", it will attempt to use the value -999.0 for it. This is incorrect.
 

nuvolet

Toni Viudez
Member
I defined the fill_value as indicated in the first case and it didn't work:

Code:
  call addfld('Target_AOD','horiz_only','A','kg/kg'  ,'AOD Nudging Target',fill_value=-999.0  )
                                                                                                1
Error: There is no specific subroutine for the generic ‘addfld’ at (1)

Thanks
 

cacraig

Cheryl Craig
CSEG and Liaisons
Staff member
You have single quotes around horiz_only. This is a variable that is being brought in via a "use" statement and not a string.
 

nuvolet

Toni Viudez
Member
When I use this addfld declaration but without the specification of the fill_value it works.
Here it is the example even with other variable which is defined by default in the module I want to customize:

Code:
   call addfld('Target_Q',(/ 'lev' /),'A','kg/kg'  ,'Q Nudging Target'  )
   call addfld('Target_AOD','horiz_only','A','kg/kg'  ,'AOD Nudging Target')

While when I do what is shown above, it shows me that error.

Thanks
 

cacraig

Cheryl Craig
CSEG and Liaisons
Staff member
This is an example from the actual CAM code:

call addfld ('SNOWHICE', horiz_only, 'A', 'm','Snow depth over ice', fill_value = 1.e30_r8)

Note that there are no quotes around horiz_only. You also need to make your "fill_value=-999.0_r8". This makes the fill value be a double precision instead of single precision. I tried the above example with "fill_value=1.e30" and I got the same message about it not matching a specific subroutine. This subroutine does not appear to handle single precision reals, for the fill_value.
 

nuvolet

Toni Viudez
Member
In which module is located this example?.
I made the changes you suggested?

Code:
call addfld('Target_AOD',horiz_only,'A','kg/kg','AOD Nudging Target',fill_value=-999.0_r8)

And now says that:

Code:
    call addfld('Target_AOD',horiz_only,'A','kg/kg','AOD Nudging Target',fill_value=-999.0_r8)
                                      1
Error: Symbol ‘horiz_only’ at (1) has no IMPLICIT type

How did is horrid_only defined in the module you are using?.

Thanks in advance
 

nuvolet

Toni Viudez
Member
In which module is located this example?.
I made the changes you suggested?

Code:
call addfld('Target_AOD',horiz_only,'A','kg/kg','AOD Nudging Target',fill_value=-999.0_r8)

And now says that:

Code:
    call addfld('Target_AOD',horiz_only,'A','kg/kg','AOD Nudging Target',fill_value=-999.0_r8)
                                      1
Error: Symbol ‘horiz_only’ at (1) has no IMPLICIT type

How did is horrid_only defined in the module you are using?.

Thanks in advance
In fact I have been also looking where this function is defined (cam_history.F90, located in /components/cam/src/control) and the description is defined in line 5170-5171 as:

Code:
 call addfld(fname, dimnames, avgflag, units, long_name, gridname,         &
         flag_xyfill, sampling_seq, standard_name, fill_value)

Thanks
 

cacraig

Cheryl Craig
CSEG and Liaisons
Staff member
As I mentioned in passing earlier (but probably without enough detail), you need to bring in horiz_only via a "use" statement. The complete line you need to add to the top of your subroutine is:
use cam_history, only: horiz_only

The example is from src/physics/cam/cam_diagnostics.F90, but addfld is used throughout the code in many modules.
 

nuvolet

Toni Viudez
Member
As I mentioned in passing earlier (but probably without enough detail), you need to bring in horiz_only via a "use" statement. The complete line you need to add to the top of your subroutine is:


The example is from src/physics/cam/cam_diagnostics.F90, but addfld is used throughout the code in many modules.
I added this line:

Code:
use cam_history   ,only: addfld, horiz_only

at the beginning of the subroutine (nudging_init in nudging.F90), where I am modifying the module besides the

Code:
call addfld('Target_AOD',horiz_only,'A','kg/kg','AOD Nudging Target',fill_value=-999.0_r8)

and still getting some problems.
When the case is compiled and executed, it is asking me to look at the cesium.log file (enclosed ).

Thanks for your help.
 

Attachments

  • cesm-log-220616-171656.txt
    30.5 KB · Views: 4

cacraig

Cheryl Craig
CSEG and Liaisons
Staff member
I am seeing the following error:
flbc_inti: time out of bounds for dataset = /CERES/sarb/aviudezm/CESM2.2/data/input/atm/waccm/lb/LBC_1750-2014_CMIP6_0p5degLat_c170126.nc
ERROR: Unknown error submitted to shr_abort_abort.

This indicates to me that you have an error with your setup (and it has nothing to do with your added code). It sounds like you are requesting the job to be run outside of the 1750-2014 time range.

If you need us to further debug this, we will need you to include the information specified at: Information to include in help requests

This may also end up being moved to the WACCM forum, but I'll see if I can't help you with more information.
 

nuvolet

Toni Viudez
Member
I am seeing the following error:
flbc_inti: time out of bounds for dataset = /CERES/sarb/aviudezm/CESM2.2/data/input/atm/waccm/lb/LBC_1750-2014_CMIP6_0p5degLat_c170126.nc
ERROR: Unknown error submitted to shr_abort_abort.

This indicates to me that you have an error with your setup (and it has nothing to do with your added code). It sounds like you are requesting the job to be run outside of the 1750-2014 time range.

If you need us to further debug this, we will need you to include the information specified at: Information to include in help requests

This may also end up being moved to the WACCM forum, but I'll see if I can't help you with more information.
I am running this case only for one day each 3 hours from 2010-01-01 to 2010-01-02, for instance in my user_nl_cam I have:

Code:
avgflag_pertape = 'A','I'
nhtfrq = 0, -3
mfilt  = 1, 8
fincl1 = 'U','V','T','Q','AODVISdn', 'Target_AOD'
fincl2 = 'U','V','T','Q','AODVISdn', 'Target_AOD'

I am using MERRA 32 level and also the data I want to start nudging which is AODs from my own source.

Thanks
 

cacraig

Cheryl Craig
CSEG and Liaisons
Staff member
Unfortunately you have not provided enough information for me to be able to try to duplicate your run. I can't give you an answer as what you've provided does not indicate a problem.

Without further information, here are my suggestions:

Check the date you are running with:
./xmlquery RUN_STARTDATE

If it does not return 2010-01-01, then that is your problem.

If that is fine, I suspect that your setup has a problem in it. I would suggest that you try running a similar job with code that has not been modified. If that works, then I would add your changes in in the smallest increments possible until you find what brings in the problem.
 

nuvolet

Toni Viudez
Member
As I mentioned in passing earlier (but probably without enough detail), you need to bring in horiz_only via a "use" statement. The complete line you need to add to the top of your subroutine is:


The example is from src/physics/cam/cam_diagnostics.F90, but addfld is used throughout the code in many modules.
Hi Cheryl,

I have also included this (flag_xyfill=.true) in the same line like this:

Code:
call addfld('Target_AOD',horiz_only,'A','kg/kg','AOD Nudging Target', flag_xyfill=.true.,fill_value=-999.0_r8)

And I have the result I wanted, which passing the fill values.

On the other hand, now I have another problem regarding having a new defined variable with more than 3 dimension.
For instance, I defined a new variable like:

Code:
real(r8),allocatable:: Model_Qaer     (:,:,:,:)  !(pcols,pver,naer,begchunk:endchunk)

Which compared to other in the same module (nudging.F90) like Q is:

Code:
real(r8),allocatable:: Model_Q     (:,:,:)  !(pcols,pver,begchunk:endchunk)

I want to have the new variable for all the advected aerosols (naer).

I create this variable like:

Code:
 do naer=1,27
     Model_Qaer(:ncol,:pver,naer,lchnk)=phys_state(lchnk)%q(:ncol,:pver,idxaer(naer))       
 end do

Where idxaer, is the index where is located each advected aerosol in the q array, which I already know its value by using cnst_get_ind and save it in an another array.
Then when I add the new file like:

Code:
call addfld('Model_Qaer',(/ 'lev' /),'A',''  ,'Qaer Nudging Model  ', flag_xyfill=.true.,fill_value=-999.0_r8)

And the out field like:

Code:
call outfld('Model_Qaer',Model_Qaer(:,:,:,lchnk),pcols,lchnk)

All the same procedure as I did for the previous case of Target_AOD.
When I create the entire case, the run does not give me any error of compilation or run but the history files I have the new variable I created (Model_Qaer) only has the following dimensions:

Code:
float Model_Qaer (time=8,levels=32,lat=192,lon=288)

While I would like something like this:

Code:
float Model_Qaer (time=8,naer=27,levels=32,lat=192,lon=288)

I hope it makes sense what I am trying to ask.

Thanks
 

cacraig

Cheryl Craig
CSEG and Liaisons
Staff member
Yes, your question makes sense. The problem is that when you called addfld, you only specified
(/ 'lev' /)

That explains why your output field does not have the naer dimension.

Try using
(/ 'lev', 'naer'/)

You will also need to call
add_hist_coord

to register the history coordinate for "naer". You can see examples of doing this in: src/physics/cam/cospsimulator_intr.F90
 

nuvolet

Toni Viudez
Member
Thanks Cheryl.
I will give a try to se if I can add this new coordinate using that subroutine.
 
Top