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/create a passive tracer in CAM

starrystarrynighttt

LLD
New Member
Dear all,

I am trying to learn how to add a passive tracer in the CAM module but am still confused after some previous posts:

(e.g., CAM tracer https://bb.cgd.ucar.edu/cesm/threads/help-about-passive-ozone-in-cesm.2595/; https://bb.cgd.ucar.edu/cesm/threads/how-to-add-water-tracers-to-cam6.5001/; BHIST_BPRP co2vmr not recognized)

The idea is to add a specific initial distribution concentration of the tracer in the atmosphere and some sources/sinks at the surface boundary layer. We don't want the tracer to interact with other components (at least at this point). The first step thing would be to see how the distribution of the tracer change with time.

I am currently using CAM4/5 with CESM1.2 but could try CESM2 as well.

Can someone point me to any documents or websites I should look at, or explain a little bit how this should work?

Thanks a lot.
 

nusbaume

Jesse Nusbaumer
CSEG and Liaisons
Staff member
Hello,

Apologies for the slow response! You can certainly add a passive tracer, but it will require the modification of the CAM source code in order to implement it. Essentially, you will need to create a new "register" subroutine that calls cnst_add, which adds a new advected tracer to the model. That call will also provide an index you can use to extract the actual tracer values from the state%q variable. You can also use the cnst_get_ind subroutine to get the index based off the tracer name. The cnst_add and cnst_get_ind subroutines can be found here (for CESM1.2):

CESM1.2/models/atm/cam/src/physics/cam/constituents.F90

or here (for CESM2):

CESM2.1.3/components/cam/src/physics/cam/constituents.F90

The subroutine you create will need to be called inside the phys_register subroutine which is located here (for CESM1.2):

CESM1.2/models/atm/cam/src/physics/cam/physpkg.F90

or here (for CESM2):

CESM2.1.3/components/cam/src/physics/cam/physpkg.F90

You'll also want to include some addfld and outfld calls in order to output your tracer to the history file. The addfld call provides the name and meta-data of your tracer, while the outfld call is when the variable is actually added to the file. You can find examples of these calls throughout the source code, such as in cam_diagnostics.F90, which should be located in the same directory as the previous files.

Finally, I believe the tracer will be initialized to zero if you don't set the values yourself, so there likely won't be any interesting output until you specify at least non-zero initial conditions (or add source/sink terms).

Anyways, I hope that helps, and if you run into any problems or issues please let us know (we'll hopefully respond more quickly next time).

Thanks, and have a great day!

Jesse
 

koichi omi

koichi
New Member
Hello,

I create a passive tracer for the ice mass produced by contrail formation due to aircraft H2O emission.
I would like to add sink terms (sedimentation and sublimation) to my passive tracer.

I modified source codes (micro_mg_cam.F90) as follows.
From line 256, the following lines were added.

do k=1,pver
do i=1,ncol
! sublimation + sedimentation
if (state_loc%q(i,k,ixcnttrc) > 0._r8 .and. state_loc%q(i,k,ixcldice) > 0._r8) then
ptend_loc%q(i,k,ixcnttrc) = qisedten(i,k)+qisevap(i,k)
end if
end do
end do

"ixcnttrc" means an index for my tracer.

However, the following error occurred and the simulation stopped.

Fatal error solving for eddsclrm
Fatal error solving for eddsclrm
Error in advance_windm_edsclrm
Intent(in)
dt = 300.000000000000
Fatal error solving for eddsclrm
Fatal error solving for eddsclrm
wm_zt = 0.000000000000000E+000 -2.302706653301477E-003
-4.123865875471712E-003 -5.165215514340527E-003 -5.874901124363955E-003
-7.016639616069772E-003 -8.426658749125491E-003 -9.851572143910862E-003
-1.164216834124984E-002 -1.274459601400508E-002 -1.244118640712365E-002
-1.152626839580721E-002 -3.392023923834975E-003 5.392722894302918E-003
4.298413137594175E-003 -1.770560306331032E-003 -1.120036649195527E-002
-2.102065571004882E-002 -2.649712558829950E-002 -2.589218349149915E-002
-2.221563557069088E-002 -1.885234106807314E-002 -1.548526644231121E-002
-1.296258389052083E-002 -1.292731057212253E-002 -8.517559923897237E-003
-3.191742873669683E-003 -9.493345093060653E-004 -1.741586979622753E-004
5.751092838540656E-003 1.660317812462543E-002 2.257076159828490E-002
2.390076509879786E-002

Could you tell me how to add sink terms for sedimentation and sublimation correctly?
 

nusbaume

Jesse Nusbaumer
CSEG and Liaisons
Staff member
Hi Koichi,

Apologies for the slow response! I suspect the error you are getting is because the sedimentation and sublimation tendencies aren’t being scaled by the amount of your “ixcnttrc” tracer that is in that grid box. In other words there might be cloud ice in the grid cell that is not from contrails which is contributing to the sedimentation tendency, and then when you apply it to the contrail cloud only you end up removing too much mass, causing negative tracer values which will then cause problems elsewhere in the model. A quick solution could look something like this:

Code:
real(r8) :: contrail_ratio !ratio of contrail ice to total ice
...
if (state_loc%q(i,k,ixcnttrc) > 0._r8 .and. state_loc%q(i,k,ixcldice) > 0._r8) then
   contrail_ratio = ptend_loc%q(i,k,ixcnttrc) / state_loc%q(i,k,ixcldice)
   ptend_loc%q(i,k,ixcnttrc) = contrail_ratio*(qisedten(i,k)+qisevap(i,k))
end if

Anyways, I hope that helps, and if you still run into that “eddsclrm” error even with scaled sink tendencies then please let me know.

Thanks, and have a great day!

Jesse
 
Top