\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage{ifpdf}

\ifpdf
\else
\usepackage[active]{srcltx}
\fi

\usepackage{amsmath}

\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{geometry}

\usepackage[np]{numprint}

\usepackage{hyperref}
\ifpdf
\hypersetup{pdftitle={Tutorial Aerosols}, pdfauthor={LMDZ team},
  hypertexnames=false, pdfstartview=FitBH}
\fi

\author{LMDZ team}
\title{LDMZ tutorial: aerosol effects}
\date{January 2023}

\geometry{top=2cm,bottom=2cm,left=2.5cm,right=2.5cm}

\begin{document}

\maketitle

%\noindent
This tutorial focuses on how to activate and diagnose aerosol effects in LMDZ.\\

%\noindent
This document can be downloaded as a pdf file (so you could copy/paste command lines from it):
\begin{verbatim}
wget https://lmdz.lmd.jussieu.fr/pub/Training/Tutorials/Tutorial_Aerosols.pdf
\end{verbatim}

\section{Prerequisites}

If you have already installed the model with the script \verb+install_lmdz.sh+ as described in Tutorial \#1, then go directly to Section 2 \textbf{"Activating aerosols}".\\Otherwise, start by installing the model, as follows (same steps as in Tutorial \#1) :\\

If you don't have a working folder named \verb+LMDZ+ in your \verb+home+ directory, then you create it:
\begin{verbatim}
cd 
mkdir LMDZ
\end{verbatim}

Go in this \verb+~/LMDZ+ folder. Download the script \verb+install_lmdz.sh+,  and run it to install the model in sequential mode (default option "parallel=none" in install\_lmdz.sh), in a folder named LMDZseq. The default resolution is 32x32x39 (equivalent to running \verb+install_lmdz.sh+ with the option \verb+"-d 32x32x39"+).

\begin{verbatim}
cd ~/LMDZ
wget https://lmdz.lmd.jussieu.fr/pub/install_lmdz.sh
chmod +x install_lmdz.sh
./install_lmdz.sh -name LMDZseq
\end{verbatim}

%\noindent
The LMDZ model is now installed in your folder \verb+~/LMDZ/LMDZseq/modipsl/modeles/LMDZ+.
A "benchmark" simulation was automatically run therein, in the folder \verb+BENCH32x32x39+ that can be useful for other exercices. 
Here you'll work with another Bench archive for the regular resolution 48x36x39, containing appropriate aerosol files. 

\section{Activating aerosols}

\noindent 

\textbf{ATTENTION} : The input aerosol files must have \textbf{the same horizontal grid (resolution, zoom if any) as the simulation} you want to run. The vertical interpolation will be done online by the model.\\

For this training session, aerosol files on regular 48x36x39 grid are included in the archive you will work with : \verb+bench_lmdz_48x36x39.tar.gz+.\\

In the \verb+~/LMDZ/LMDZseq/modipsl/modeles/LMDZ+ folder, download and unpack the archive \\\verb+bench_lmdz_48x36x39.tar.gz+ :
\begin{verbatim} 
cd ~/LMDZ/LMDZseq/modipsl/modeles/LMDZ
wget https://lmdz.lmd.jussieu.fr/pub/3DBenchs/bench_lmdz_48x36x39.tar.gz
tar -xvf bench_lmdz_48x36x39.tar.gz
 \end{verbatim}

Go in the new folder  BENCH48x36x39 (created in \verb+modipsl/modeles/LMDZ+) and compile the model at the 48x36x39 resolution, using the script compilegcm.sh. At the end, check that you have in your folder the executable \verb+gcm.e+ :
\begin{verbatim} 
cd BENCH48x36x39
./compilegcm.sh
ll gcm.e
 \end{verbatim}
\noindent


\subsection{Switching on tropospheric aerosol effects}

\noindent
Aerosols are switched off by default in the basic LMDZ configuration. To switch on aerosols, you need to change some flags in
\begin{verbatim} modipsl/modeles/LMDZ/BENCH48x36x39/config.def \end{verbatim}

\noindent
Specifically the following changes should be made: 
\begin{itemize}
\item \verb|flag_aerosol=6| or any other relevant number
\item \verb|ok_ade=y| to activate aerosol-radiation interactions
\item \verb|ok_aie=y| to activate aerosol-cloud interactions
\end{itemize}

\noindent
As \verb|aer_type=actuel|, only these two aerosol files are required for the simulation:
\begin{itemize}
\item \verb|aerosols1980.nc|  : "present-day" aerosol file
\item \verb|aerosols.nat.nc|   : preindustrial (year 1850) aerosol file
\end{itemize}

\noindent
No need to recompile the model. You may just rerun the benchmark experiment. 
\begin{verbatim}
./gcm.e
\end{verbatim}

\noindent
This returns an error message as one additional flag needs to be activated. Return to \verb|config.def|
and change the following flag (or add it if it's missing) : 
\begin{itemize}
\item \verb|ok_cdnc=y|  to activate the computation of cloud droplet number concentrations as required for \verb|ok_aie=y|. 
\end{itemize}

\noindent
This time, the model runs, and 3 output files are created : histhf.nc, histday.nc and histmth.nc . As you run by default for 1 day only (nday=1 in run.def),  histmth.nc will be "empty" (the variables are listed in it, but no values; \verb+time_counter+ contains 0 timesteps ; a minimum of 5 days of run are needed for histmth.nc to be filled in ).\\

\noindent
The following diagnostics for tropospheric aerosols can be made available in the different output files :
\begin{itemize}
\item \verb+topswad+ : top-of-atmosphere shortwave aerosol direct forcing
\item \verb+topswad0+  : top-of-atmosphere shortwave aerosol direct forcing in clear-sky
\item \verb+topswai+  : top-of-atmosphere shortwave aerosol indirect forcing
\item \verb+od550aer+  : aerosol optical depth at 550 nm
\item \verb+od550lt1aer+  : aerosol optical depth at 550 nm for the fine aerosol mode
\item \verb+od550*****+ : optical depth for the different aerosol tracers, named according to their mode (Accumulation/Coarse/Super-coarse) + Soluble/Insoluble + Name (BC/POM/SO4/NO3/SS/DUST) + M for "mode" (Ex : CIDUSTM= Coarse Insoluble DUST Mode).
\end{itemize}

\noindent
With the default settings in the \verb+BENCH48x36x39+ folder (see \verb+phys_out_filelevels+ in  \verb+config.def+), all aerosol diagnostics are available in  \verb+histday.nc+, none of them in  \verb+histhf.nc+
To be sure that a given diagnostic (ex: " \verb+topswad+") will be present in all output files, you can insert in the \verb|config.def| file this type of lines :

\verb|flag_topswad=0 0 0 0 0| \\
\noindent
and then rerun the model.\\

\noindent
You may visualise the variables that are available in your output files.


\subsection{Switching on stratospheric aerosol effects}

\noindent
You need to link the stratospheric aerosol input files to the sample file:
\begin{verbatim}
ln -s tauswstrat.2D.1991.nc tauswstrat.2D.nc 
ln -s taulwstrat.2D.1991.nc taulwstrat.2D.nc 
\end{verbatim}
Year 1991 was chosen because it is the year of Mount Pinatubo eruption.\\

\noindent
In order to activate the stratospheric aerosols in the model, you need the following flags :
\begin{itemize}
\item \verb|iflag_rrtm=1| to activate RRTM (radiative transfer scheme) (flag to be changed in \verb|physiq.def|)
\item \verb|NSW=6| to select 6 wavebands in the SW in (flag to be added in \verb|physiq.def|)
\item \verb|flag_aerosol_strat=2| to select CMIP6 stratospheric aerosols (flag to be added in \verb|config.def|)
\end{itemize}

\noindent
You may also add in \verb+config.def+ the flag \verb|ok_volcan=y| to calculate aerosol forcing diagnostics \verb+topswad+ and \verb+topswad0+ (via double radiation calls) for stratospheric instead of anthropogenic aerosols.
The \verb+topswai+ diagnostic, for aerosol-cloud interaction, has no interest for stratospheric aerosols, because the stratosphere is very dry, there are no (or very few) clouds (see also the last note in section 2.3 below).\\

\noindent
You can run the model again with \verb+./gcm.e.+ \\

\noindent
In the output, you can visualise these 2 diagnostics : 
\begin{itemize}
\item \verb+od550_STRAT+ : stratospheric aerosol optical depth at 550 nm
\item \verb+od_10um_STRAT+ : stratospheric aerosol optical depth at 10 um
\end{itemize}

\textbf{NOTE:} If you want to see the effects of Pinatubo in June 1991, you should run the model for at least 6 months. 
In this case you may want to redo the exercices in Section 2 (i) by running in parallel mode, and (ii) using a configuration able to chain successive months (don't hesitate to ask us for help !). \\
For the point (i), follow these instructions :
\begin{verbatim}
# Re-install and compile the model in parallel mode, 
# with compilation and execution of Bench directly at resolution 48x36x39 : 
# Note : you can use the netcdf  library already compiled in ~/LMDZ/LMDZseq, 
#  with option "-netcdf ~/LMDZ/LMDZseq/netcdf4_hdf5_seq/"
# to save the netcdf compilation time (10-16min depending on your computer)
cd ~/LMDZ
./install_lmdz.sh -name LMDZpar -parallel mpi_omp -d 48x36x39 \ 
    -netcdf ~/LMDZ/LMDZseq/netcdf4_hdf5_seq/
#Go to the Bench folder 
cd ~/LMDZ/LMDZpar/modipsl/modeles/LMDZ/BENCH48x36x39
#
#change the *.def files as indicated to activate the aerosol effects ;
# also change the frequency of output of histmth from 5 to 30 days in config.def
#
#use bench.sh to run the model; 
#  it automatically identifies if your setup is sequential or parallel:
./bench.sh
\end{verbatim}
\noindent
(You may also want to see the Tutorial\_Parallel exercice at : \\
\verb+https://lmdz.lmd.jussieu.fr/pub/Training/Tutorials/Tutorial_Parallel.pdf+ ) \\

For the point (ii) (chaining successive months) you should use tutorial.tar as in Tutorial \#2, adapting it to running in parallel (instead of sequential), and for a regular grid (instead of default zoom factor 2 - remember that you only have aerosol files for the regular 48x36x39 grid! ). Then you will use the folder PROD0 created by init.sh in TUTORIAL. In PROD0, you will run the model using the script \verb+enchaine.sh+, in which you only need to modify the variables "stopsim" (ex : stopsim=200003 to stop at the end of Feb. 2000, for a run starting by default on 1st of January, 2000). You should deactivate "histhf" output files. 


\subsection{Notes about the interaction between the different flags concerning strato- vs tropospheric aerosols}
\begin{itemize}
\item If \verb+ok_ade=n+ and \verb+ok_aie =n+, then the topswa* variables for stratospheric aerosols will NOT be calculated, even if the other conditions are fulfilled (i.e., \verb+ok_volcan=y+, and the output of \verb+topswa*+ variables is activated).
\item If \verb+ok_ade=y+ or \verb+ok_aie=y+, then \verb+flag_aerosols+ different of 0 is required, so at least one tropospheric aerosol must be activated.
\item If both tropospheric and stratospheric aerosols are activated, and \verb+ok_ade=ok_aie=y+, then \verb+ok_volcan=y+ will redirect topswad* calculation from tropo- to stratospheric aerosols ; topswai (which would be 0 for strato) is still calculated for tropospheric aerosols.
\end{itemize}

\end{document}
