\documentclass{article}

\begin{document}

\def\np#1{#1}

\title{Tutorial MON : tracer convective transport and scavenging
\date{\today}}

\maketitle


\section{Installing 1D test case}

\subsection{Install a new version}

Install the last version of the model :
\begin{verbatim}
wget http://www.lmd.jussieu.fr/~hourdin/COURS/install.sh
chmod +x install.sh
\end{verbatim}


\begin{verbatim}
cd LMDZ20150217
wget http://www.lmd.jussieu.fr/~hourdin/COURS/eq_rd_cv.tar
tar xvf eq_rd_cv.tar
cd eq_rd_cv
\end{verbatim}

To compile and run the case :
\begin{verbatim}
./compile
./lmdz1d.e
\end{verbatim}


\subsection{Radon and lead}

In the file \verb+traceur.def+, you can see that two trace species,
named RN, for radon, and PB, for lead, are already defined in addition
to vapor and condensed water. Visualize these two tracers in the file
\verb+histhf.nc+. The NetCDF variables RN and PB are numbers of atoms
per unit mass, in kg$^{-1}$. Usually, activities are preferred for
comparison with observations. The activities per unit mass, in Bq
kg$^{-1}$, are:
\begin{equation}
  A_\mathrm{Rn} = \frac{\mathrm{RN}}{\np{4.765E5}} 
\end{equation}
\begin{equation}
  A_\mathrm{Pb} = \frac{\mathrm{PB}}{\np{1.028E9}}
\end{equation}
(The numerical values that appear in these fractions are the lifetimes
Plot the time evolution
\begin{verbatim}
set v upper
fill rn
set v lower
fill pb
\end{verbatim}
Intepret the diurnal cycle of Rn near the surface.
Intepret the vertical distribution of Rn and Pb
using the tendencies
\begin{verbatim}
drn_vdf   : turbulent diffusion tendencies
drn_con   : convective tendecies
drn_the   : thermal plume model tendencies
\end{verbatim}


\section{Inserting new tracers}

We will now explain how to modify the code in order to add idealized
tracers. As an example, we will add two tracers, and call them
\verb+TrA+ and \verb+TrB+.
The first tracer will be transported by the boundary
layer and convective sub-grid-scale motion, in addition to large-scale
advection. 
The second tracer will only be scavenged by rainfall.

We will have to modify the Fortran program but let us first consider
the run-time parameters that we have to modify. At run-time, we decide
to include the tracers \verb+TrA+ and \verb+TrB+ in the
simulation by changing the file \verb+traceur.def+. Change the number
of tracers at the first line of \verb+traceur.def+ and append one line
for each tracer:
\begin{verbatim}
6
14 14 H2Ov
10 10 H2Ol
10 10 RN
10 10 PB
10 10 TrA
10 10 TrB
\end{verbatim}

Now let us turn to the Fortran program. The two only files we need to
modify are \verb+phylmd/traclmdz_mod.F90+ and \verb+phylmd/physiq.F90+.
Here are the changes you
should make in that file.
\begin{itemize}
\item Declare two new module variables, \verb+id_TrA+ and
  \verb+id_TrB+, with type integer. These are the identifying
  numbers of the tracers in the program. You can take a previous
  declaration (\verb+id_pcsat+, \verb+id_pcocsat+ \dots) as a
  template. (Do not forget the OpenMP directives.)
\item All remaining changes will be made in the procedure
  \verb+traclmdz_init+, which is inside the module
  \verb+traclmdz_mod+. In order to define \verb+id_TrA+ and
  \verb+id_TrB+, the program will scan the file \verb+traceur.def+,
  looking for TrA and TrB. So you should initialize
  \verb+id_TrA+ and \verb+id_TrB+ to 0 before the loop beginning
  at line 175. There is a comment just above, saying ``Recherche des
  traceurs connus'', which means ``looking for known tracers''.
\item In the body of this loop, set \verb+id_TrA+ to the value of
  index \verb+it+ if tname(iiq) equals TrA. You can add the test
  near line 265, for instance, after the test for pcq0. You can take
  another tracer as a template. Do the same for \verb+id_TrB+.
\begin{verbatim}
       ELSE IF ( tname(iiq) == "TrA") THEN
          id_TrA=it
          tr_seri(:,:,id_TrA)=0.
          aerosol(id_TrA) = .FALSE. 
       ELSE IF ( tname(iiq) == "TrB") THEN
          id_TrB=it
          tr_seri(:,:,id_TrB)=0.
          aerosol(id_TrB) = .TRUE. 
\end{verbatim}
    The key \verb+aerosol+ is there to decide if the tracer
    will be scavenged (\verb+aerosols=.true.+) or not.
\item Finally, we will define the source of tracer in 
   \verb+phylmd/physiq.F90+.
   Just after 
\begin{verbatim}
  !   ****************     Fin  de   IF ( debut  )   ***************
\end{verbatim}
add
\begin{verbatim}
DO iq=1,nqtot
     IF (tname(iq)=='TrA') THEN
        qx(:,1,iq)=qx(:,1,iq)+pdtphys/86400.
  print*,'Ajout traceurs A '
     ELSE IF (tname(iq)=='TrB') THEN
        qx(:,1,iq)=qx(:,1,iq)+pdtphys/86400.
  print*,'Ajout traceurs B '
     ENDIF
  ENDDO
\end{verbatim}

which will add tracer in the first layer.
\verb+pdtphys+ is the time-step of the model.
\end{itemize}


Make the changes and run a new simulation.

Look at the new tracers.


\section{Sensitivity to scavenging}

Scavenging is controled by the last lines of physiq.def and
by the parameters defined in the file \verb+lsc_scav_param.data+.
The efficiency of large-scale scavenging is strongly affected by
the last to lines of \verb+lsc_scav_param.data+
Make some tests.

You can desactivate the convective scavenging with the key 
\verb+convscav=n+ in \verb+physiq.def+ and also modify
its efficiency with \verb+ccntrAA+ and \verb+ccntrENV+.

You can also desactivate convection \verb+iflag_con=0+ or change the 
surface evaporation by changeing the soil water reservoir
\verb+qsol0=20+.
\end{document}
