\documentclass[a4paper]{article}

                                % Packages

\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 \#2}, pdfauthor={LMDZ team},
  hypertexnames=false, pdfstartview=FitBH}
\fi

\author{LMDZ team}
\title{Hands on tutorial \#2: Setting up a simulation}
\date{December 13th, 2018}


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


                                %---------------

\begin{document}

\maketitle
%\tableofcontents
%\medskip

This tutorial focuses on the various steps required
to set up a 3D simulation, and in particular for a
zoomed configuration of LMDZ.

%This tutorial makes use of a zoomed configuration of LMDZ. Section
%\ref{sec:setting-up-case} is an initialization phase. In section
%\ref{sec:experiments}, you can either take a closer look at tracers,
%or the Orchidee model or switch some parameterizations of the physics
%part of the program. The three experiments in section
%\ref{sec:experiments} are independent. In section \ref{sec:nudging},
%you will nudge the model toward analyzed wind fields.

If you have already installed the model with the script \verb+install_lmdz.sh+  
in tutorial \#1, go directly below to \textbf{"Setting up a simulation...}". 
Otherwise, start by installing the model as follows :


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

then download and run the script \verb+install_lmdz.sh+  : 

\begin{verbatim}
wget http://www.lmd.jussieu.fr/~lmdz/pub/install_lmdz.sh
chmod +x install_lmdz.sh
./install_lmdz.sh -d 32x32x39 -v 20181204.trunk
\end{verbatim}

\textbf{Setting up a simulation with a (regular or) zoomed grid}
\label{sec:setting-up-case}

\begin{itemize}
\item Go to the directory \verb+LMDZ20181204.trunk/modipsl/modeles/LMDZ+,
  which contains the files \verb+makelmdz_fcm+, \verb+libf+ etc. In this
  directory, download and unpack the following tar file, then go in the resulting \verb+TUTORIAL+ folder :
\begin{verbatim}
wget http://www.lmd.jussieu.fr/~lmdz/pub/Training/tutorial.tar
tar -xf tutorial.tar
cd TUTORIAL
\end{verbatim}
\item Examine the content of the \verb+TUTORIAL+ folder : there are some scripts and a DEF directory, all briefly described in there \verb+Readme+ file.
  In the \verb+DEF+ directory, edit the file \verb+gcm.def+ and examine the 
  different parameters defining the grid. 
  
  By default, the defined grid has a zoom factor = 3 both in longitude and latitude 
  
  (\verb+grossismx=3., grossismy=3. +), 
  with the zoomed area centered at (0E,45N) (\verb+clon=0., clat=45.+). 
  
  In order to place the center of the zoom at your preferred location, you just need to change the 
longitude and latitude of the zoom center, \verb+clon+ and \verb+clat+.

	If you want to use a regular grid, set \verb+grossismx=1. and grossismy=1. + .

\item For the time being, you will run LMDZ without the surface scheme
  Orchidee: in the \verb+init.sh+ file, check that you have the option
  \verb+veget=0+.
  The model will be run with a simplified scheme for surface hydrology: the ``bucket'' scheme.
\item As you installed the model in sequential mode, in \verb+init.sh+ you must also have \verb+parallel=0+.
\item Skip this step if you run locally :
	
	
	You may increase the stack memory you can use by typing the following
  command:
\begin{verbatim}
ulimit -Ss unlimited
\end{verbatim}
  or, even better, add this command in you shell start-up file (if you
  use Bash, your start-up file can be \verb+.profile+ or
  \verb+.bash_profile+).
\item Run the script :
\begin{verbatim}
./init.sh
\end{verbatim}

  The script \verb+init.sh+ does the following :
  
  	- compiles the model (\verb+gcm.e+) again, with a different resolution than before : 48x36x39 ;
  
  	- compiles the program \verb+ce0l.e+, needed to create initial state and boundary conditions ; 
  
  	- downloads input files for \verb+ce0l.e+ (NetCDF files containing surface orography, sea-surface temperature etc.),
  	as well as 3D meteorological files from ECMWF analyses at a particular date, to be used with the nudging option; 
  
  	- runs \verb+ce0l.e+ , which creates files \verb+start.nc+, \verb+startphy.nc+ and
  \verb+limit.nc+ in a directory called \verb+INITIAL+. These files will be used to initialize 
a new simulation in a newly-created directory called \verb+SIMU1+. 

Please check that these 3 files have been created in the directory \verb+SIMU1+. If not, ask for our help.  

\item Now edit the file \verb+config.def+, and look at the section "Controle des sorties" (Eng. "Output control").
In the high-frequency NetCDF output file \#3, \verb+histhf.nc+., you'll want to include the variable \verb+pres+, 
containing the pressure at model levels.
To do that, add the following line :
\begin{verbatim}
flag_pres__00003 =           4
\end{verbatim}

\item You can now go in the SIMU1 directory and run the model by executing the command  
\verb+./gcm.e+ (output on screen) or  \verb+./gcm.e > listing1+ (output in file listing1). 
The simulation should end with the message ``Everything is cool'' and the 
output files \verb+histday.nc+, \verb+histmth.nc+ and \verb+histhf.nc+ should be created. 
Make some plots from one of these files.

\end{itemize}

\end{document}
