% $Id: user_defined_code.tex 1080 2012-12-13 13:39:39Z hoffmann $ \input{header_tmp.tex} %\input{../header_lectures.tex} \usepackage[utf8]{inputenc} \usepackage{ngerman} \usepackage{pgf} \usetheme{Dresden} \usepackage{subfigure} \usepackage{units} \usepackage{multimedia} \usepackage{hyperref} \newcommand{\event}[1]{\newcommand{\eventname}{#1}} \usepackage{xmpmulti} \usepackage{tikz} \usetikzlibrary{shapes,arrows,positioning} \usetikzlibrary{decorations.markings} %neues paket \usetikzlibrary{decorations.pathreplacing} %neues paket \def\Tiny{\fontsize{4pt}{4pt}\selectfont} \usepackage{amsmath} \usepackage{amssymb} \usepackage{multicol} \usepackage{pdfcomment} \usepackage{graphicx} \usepackage{listings} \lstset{showspaces=false,language=fortran,basicstyle= \ttfamily,showstringspaces=false,captionpos=b} \institute{Institut für Meteorologie und Klimatologie, Leibniz Universität Hannover} \date{last update: \today} \event{PALM Seminar} \setbeamertemplate{navigation symbols}{} \setbeamertemplate{footline} { \begin{beamercolorbox}[rightskip=-0.1cm]& {\includegraphics[height=0.65cm]{imuk_logo.pdf}\hfill \includegraphics[height=0.65cm]{luh_logo.pdf}} \end{beamercolorbox} \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex, leftskip=.3cm,rightskip=0.3cm plus1fil]{title in head/foot} {\leavevmode{\usebeamerfont{author in head/foot}\insertshortauthor} \hfill \eventname \hfill \insertframenumber \; / \inserttotalframenumber} \end{beamercolorbox} \begin{beamercolorbox}[colsep=1.5pt]{lower separation line foot} \end{beamercolorbox} } %\logo{\includegraphics[width=0.3\textwidth]{luhimuk_logo.pdf}} \title[The PALM User-Interface]{The PALM User-Interface} \author{Siegfried Raasch} \begin{document} % Folie 1 \begin{frame} \titlepage \end{frame} \section{The PALM User-Interface} \subsection{The PALM User-Interface} % Folie 2 \begin{frame} \frametitle{Purpose of the User-Interface} \scriptsize \begin{itemize} \item<2-> The standard (default) PALM code cannot account for every specific demand of a user. In order to include these specific demands, the user would have to modify the standard code. \end{itemize} \vspace{2mm} \onslide<3-> \textbf{Problem:} \begin{itemize} \item<3-> If a new PALM version is released (current release is 3.8) and the user wants to use it, he would have to add his modifications to the new release again. \end{itemize} \vspace{3mm} \onslide<4-> \textbf{Solution:} \begin{itemize} \item<4-> PALM offers a \grqq user-interface\grqq, i.e. a set of subroutines, where the user can add his modifications and which can be re-used for future releases of the standard PALM code. \item<5-> By using the user-interface, the standard code does not have to be modified by the user in most of all cases. \item<6-> The user-interface subroutines are almost \grqq empty\grqq\, by default. They are called from the standard PALM code but (with some very minor exceptions) do not contain any executable code. \end{itemize} \end{frame} % Folie 3 \begin{frame} \frametitle{General Structure of the User-Interface} \scriptsize \begin{itemize} \item<1-> All routines can be found under \texttt{.../trunk/SOURCE}. \item<2-> There is one file for each routine. Filenames are \texttt{user\underline{ }*.f90}.\\ Example: \texttt{user\underline{ }last\underline{ }actions.f90} \end{itemize} \onslide<3-> \centering \includegraphics[scale=0.3]{user_defined_code_figures/user_last_actions.png}\\ \end{frame} % Folie 4 \begin{frame} \frametitle{Embedding of User-Interface Routines} \scriptsize \begin{itemize} \item<1-> The user-interface routines are called from specific, well-defined locations in the standard PALM code.\\ \ \\ Example from \texttt{palm.f90}: \end{itemize} \onslide<2-> \centering \includegraphics[scale=0.33]{user_defined_code_figures/embedding.png}\\ \end{frame} % Folie 5 \begin{frame} \frametitle{Embedding of User-Interface Routines\\ Flow Chart Overview (I): Initial Steps} \scriptsize \begin{tikzpicture}[scale=0.8, transform shape] % Define colours \tikzstyle{green} = [draw, fill=green!30, text width=7.1em, text centered, minimum height=1.6em] \tikzstyle{yellow} = [draw, fill=yellow!30, text width=7.1em, text centered, minimum height=1.6em] \tikzstyle{orange} = [draw, fill=orange!60, text width=7.1em, text centered] % Define coordinates and draw nodes \node[green, text width=5em] (PALM) at (0,0.1) {PALM}; \coordinate (A) at (0,-0.7); \node[green, right=0.6cm of A] (parin) {parin}; \coordinate[below=0.3cm of parin] (B); \coordinate[below=0.9cm of parin] (C); \coordinate[below=1.5cm of parin] (D); \node[green, right=0.6cm of B] (read) {read\_var\_list}; \node[green, right=0.6cm of C] (package) {package\_parin}; \node[yellow, right=0.6cm of D] (userparin) {user\_parin}; \coordinate[below=3cm of PALM] (E); \coordinate[below=3.6cm of PALM] (F); \coordinate[below=4.2cm of PALM] (G); \coordinate[below=4.8cm of PALM] (H); \coordinate[below=5.6cm of PALM] (I); \coordinate[below=7.4cm of PALM] (J); \node[green, right=0.6cm of E] (initpegrid) {init\_pegrid}; \node[green, right=0.6cm of F] (initgrid) {init\_grid}; \node[yellow, right=0.9cm of initgrid] (userinitgrid) {user\_init\_grid}; \node[green, right=0.6cm of G] (checkparameters) {check\_parameters}; \node[yellow, right=0.9cm of checkparameters, text width=9.5em] (usercheckdataoutput) {user\_check\_data\_output}; \node[green, right=0.6cm of H] (header) {header}; \node[green, right=0.6cm of I] (init3dmodel) {init\_3d\_model}; \node[yellow, right=0.9cm of header] (userheader) {user\_header}; \node[orange, right=0.6cm of J] (timeint) {time\_integration}; \coordinate[below=0.3cm of init3dmodel] (K); \coordinate[below=0.9cm of init3dmodel] (L); \node[green, right=0.6cm of K] (initparticles) {init\_particles}; \node[yellow, right=0.9cm of initparticles] (userinitparticles) {user\_init\_particles}; \node[yellow, right=0.6cm of L] (userinit) {user\_init}; % Draw lines \draw[-, thick] (PALM) -- (0,-7.8); \draw[dotted, thick] (0,-8.2) -- (0,-7.8); \draw[-, thick] (A) -- (parin); \draw[-, thick] (parin) -- (D); \draw[dashed, thick] (B) -- (read); \draw[dashed, thick] (C) -- (package); \draw[-, thick] (D) -- (userparin); \draw[-, thick] (E) -- (initpegrid); \draw[-, thick] (F) -- (initgrid); \draw[-, thick] (G) -- (checkparameters); \draw[-, thick] (H) -- (header); \draw[-, thick] (I) -- (init3dmodel); \draw[-, thick] (J) -- (timeint); \draw[dotted, thick] (init3dmodel) -- (K); \draw[-, thick] (K) -- (L); \draw[dashed, thick] (K) -- (initparticles); \draw[-, thick] (L) -- (userinit); \draw[-, thick] (initgrid) -- (userinitgrid); \draw[-, thick] (checkparameters) -- (usercheckdataoutput); \draw[-, thick] (header) -- (userheader); \draw[-, thick] (initparticles) -- (userinitparticles); \end{tikzpicture} \end{frame} % Folie 6 \begin{frame} \frametitle{Embedding of User-Interface Routines\\ Flow Chart Overview (II): Time Integration Loop} \scriptsize \begin{tikzpicture}[scale=0.7, transform shape] % Define colours \tikzstyle{green} = [draw, fill=green!30, text width=7.1em, text centered, minimum height=1.6em] \tikzstyle{yellow} = [draw, fill=yellow!30, text width=7.1em, text centered, minimum height=1.6em] \tikzstyle{orange} = [draw, fill=orange!60, text width=7.1em, text centered] \tikzstyle{orange1} = [draw, fill=orange!80, text width=11em, text centered] \definecolor{grey}{rgb}{0.25,0.25,0.25} % Define coordinates and draw nodes \node[draw, text width=25em,minimum height=4.0em,fill=black!15] (progframe) at (5.75,-1.5) {}; \coordinate (A) at (0,0); \node[orange, right=0.6cm of A] (timeint) {time\_integration}; \coordinate[below=0.3cm of timeint] (B); \coordinate[below=0.8cm of timeint] (C); \coordinate[right=2cm of C] (D); \coordinate[right=3.8cm of D] (E); \node[yellow, right=0.6cm of B, text width=14em] (useractions1) {\textcolor{blue}{user\_actions\_(\textit{'before\_timestep'})}}; \node[orange1, below=0.2cm of D] (progeq) {prognostic\_equations}; \node[orange1, below=0.2cm of E] (progeqfast) {prognostic\_equations\_fast}; \node[draw, fill=red, text width=4em] at (8.6,-0.8) {\textcolor{white}{standard advection}}; \node[yellow, right=0.3cm of progframe, text width=14em] (useractions2) {\textcolor{blue}{user\_actions\_(\textit{'*\_tendency'})}}; \coordinate[below=2.3cm of timeint] (F); \coordinate[below=2.9cm of timeint] (G); \coordinate[below=3.5cm of timeint] (H); \coordinate[below=4.1cm of timeint] (I); \node[green, right=0.6cm of F] (advecparticles) {advec\_particles}; \node[yellow, right=0.9cm of advecparticles, text width=10em] (userparticlesattributes) {user\_particles\_attributes}; \node[green, right=0.6cm of G] (exchangehoriz) {exchange\_horiz}; \node[green, right=0.0cm of exchangehoriz] (asselin) {asselin\_filter}; \node[green, right=0.6cm of H] (swaptimelevel) {swap\_timelevel}; \node[green, right=0.6cm of I] (pres) {pres}; \coordinate[below=0.3cm of pres] (J); \coordinate[below=5.1cm of timeint] (K); \coordinate[below=5.7cm of timeint] (L); \coordinate[below=6.3cm of timeint] (M); \coordinate[below=6.9cm of timeint] (N); \coordinate[below=8.2cm of timeint] (O); \coordinate[below=8.8cm of timeint] (P); \node[green, right=0.6cm of K] (prandtlfluxes) {prandtl\_fluxes}; \node[yellow, right=0.6cm of L, text width=14em] (useractions3) {\textcolor{blue}{user\_actions\_(\textit{'after\_integration'})}}; \node[green, right=0.6cm of M] (diffusivities) {diffusivities}; \node[green, right=0.0cm of diffusivities] {check\_for\_restart}; \node[green, right=0.6cm of N] (flowstat) {flow\_statistics}; \node[green, right=0.0cm of flowstat] (runcontrol) {run\_control}; \node[yellow, below=0.2cm of flowstat] (userstat) {user\_statistics}; \node[yellow, right=0.6cm of O, text width=14em] (useractions4) {\textcolor{blue}{user\_actions\_(\textit{'after\_timestep'})}}; \node[green, right=0.6cm of P] (timestep) {timestep}; \node[green, right=0.2cm of runcontrol] (dataoutput) {data\_output\_***}; \node[yellow, right=0.2cm of dataoutput] (userdvrpcoltab) {user\_dvrp\_coltab}; \coordinate[below=0.2cm of dataoutput] (Q); \coordinate[right=0.4cm of Q] (R); \coordinate[right=3.0cm of R] (S); \node[yellow, below=0.2cm of R, text width=9em] (output2d) {user\_data\_output\_2d}; \node[yellow, below=0.2cm of S, text width=9em] (output3d) {user\_data\_output\_3d}; \draw[dotted, thick] (0,0.05) -- (0,0.3); \draw[-, thick] (0,0.05) -- (0,-8.8); \draw[dotted, thick] (0,-9.2) -- (0,-8.8); \draw[-, thick] (A) -- (timeint); \draw[-, thick] (timeint) -- (P); \draw[-, thick] (B) -- (useractions1); \draw[-, thick] (C) -- (D); \draw[-, thick] (progeq) -- (D); \draw[-, thick, color=red] (D) -- (E); \draw[->, thick, color=red] (E) -- (progeqfast); \draw[-, thick] (progframe) -- (useractions2); \draw[-, thick] (F) -- (advecparticles); \draw[-, thick] (userparticlesattributes) -- (advecparticles); \draw[-, thick] (G) -- (exchangehoriz); \draw[-, thick] (H) -- (swaptimelevel); \draw[-, thick] (I) -- (pres); \draw[dotted, thick] (pres) -- (J); \draw[-, thick] (K) -- (prandtlfluxes); \draw[-, thick] (L) -- (useractions3); \draw[-, thick] (M) -- (diffusivities); \draw[-, thick] (N) -- (flowstat); \draw[-, thick] (userstat) -- (flowstat); \draw[-, thick] (O) -- (useractions4); \draw[-, thick] (P) -- (timestep); \draw[-, thick] (dataoutput) -- (Q); \draw[-, thick] (S) -- (Q); \draw[-, thick] (R) -- (output2d); \draw[-, thick] (S) -- (output3d); \end{tikzpicture} \end{frame} % Folie 7 \begin{frame} \frametitle{Embedding of User-Interface Routines\\ Flow Chart Overview (III): Final Steps} \scriptsize \begin{tikzpicture}[scale=0.8, transform shape] % Define colours \tikzstyle{green} = [draw, fill=green!30, text width=7.1em, text centered, minimum height=1.6em] \tikzstyle{yellow} = [draw, fill=yellow!30, text width=7.1em, text centered, minimum height=1.6em] \tikzstyle{orange} = [draw, fill=orange!60, text width=7.1em, text centered] % Define coordinates and draw nodes \node[green, text width=5em] (PALM) at (0,0.1) {PALM}; \coordinate (A) at (0,-0.7); \node[orange, right=0.6cm of A] (timeint) {time\_integration}; \coordinate[below=0.5cm of timeint] (B); \coordinate[below=1.0cm of timeint] (C); \coordinate[below=2.5cm of PALM] (D); \node[green, right=0.6cm of D] (write3dbinary) {write\_3d\_binary}; \node[green, right=0.9cm of write3dbinary] (writevarlist) {write\_var\_list}; \coordinate[below=3.5cm of PALM] (E); \coordinate[below=4.1cm of PALM] (F); \coordinate[below=4.7cm of PALM] (G); \node[green, right=0.6cm of E] (header) {header}; \node[yellow, right=0.6cm of F] (userlastactions) {user\_last\_actions}; \node[green, right=0.6cm of G] (cpustat) {cpu\_statistics}; % Draw lines \draw[-, thick] (PALM) -- (G); \draw[-, thick] (A) -- (timeint); \draw[-, thick] (B) -- (timeint); \draw[dotted, thick] (B) -- (C); \draw[dashed, thick] (D) -- (write3dbinary); \draw[-, thick] (write3dbinary) -- (writevarlist); \draw[-, thick] (E) -- (header); \draw[-, thick] (F) -- (userlastactions); \draw[-, thick] (G) -- (cpustat); \end{tikzpicture} \end{frame} % Folie 8 \begin{frame} \frametitle{Complete List of User-Interface Routines (I)} \tiny \begin{tabular}{|p{2.5cm}|p{2.4cm}|p{2.1cm}|p{3cm}|} \hline \textbf{Name} & \textbf{Arguments} & \textbf{Called from} & \textbf{Task}\\ \hline \texttt{user\_3d\_data\_averaging} & \texttt{mode}, \texttt{variable} & \texttt{sum\_up\_3d\_data} & temporal averaging for user-defined quantities\\ \hline \texttt{user\_actions} \texttt{user\_actions} & \texttt{location} \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, \texttt{i}, \texttt{j}, \texttt{location} & \texttt{time\_integration} + \texttt{prognostic\_equations} & e.g. additional forces to be included in the prognostic equations\\ \hline \texttt{user\_dummy (user\_additional \_routines.f90)} & - - - & - - - & for additional subroutines defined by the user\\ \hline \texttt{user\_advec\_particles} & - - - & \texttt{advec\_particles} & modification of particles after advection\\ \hline \texttt{user\_check\_data\_output} & \texttt{variable}, \texttt{unit} & \texttt{check\_parameters} & check the user-defined output quantities\\ \hline \texttt{user\_check\_data\_output\_pr} & \texttt{variable}, \texttt{var\_count}, \texttt{unit} & \texttt{check\_parameters} & check the user-defined profile output quantities\\ \hline \texttt{user\_check\_parameters} & - - - & \texttt{check\_parameters} & check user-defined variables\\ \hline \texttt{user\_data\_output\_2d} & \texttt{av}, \texttt{variable}, \texttt{found}, \texttt{grid}, \texttt{local\_pf} & \texttt{data\_output\_2d} & output/calculation of additional user-defined quantities\\ \hline \texttt{user\_data\_output\_3d} & \texttt{av}, \texttt{variable}, \texttt{found}, \texttt{local\_pf}, \texttt{nz\_do} & \texttt{data\_output\_3d} & output/calculation of additional user-defined quantities\\ \hline \texttt{user\_data\_output\_dvrp} & \texttt{output\_variable}, \texttt{local\_pf} & \texttt{data\_output\_dvrp} & output of additional user-defined quantities\\ \hline \texttt{user\_data\_output\_mask} & \texttt{av}, \texttt{variable}, \texttt{found}, \texttt{local\_pf} & \texttt{data\_output\_mask} & output of additional masked user-defined quantities\\ \hline \texttt{user\_define\_netcdf\_grid} & \texttt{variable}, \texttt{found}, \texttt{grid\_x}, \texttt{grid\_y}, \texttt{grid\_z} & \texttt{netcdf} & defining the grid for additional output quantities\\ \hline \texttt{user\_dvrp\_coltab} & \texttt{mode}, \texttt{variable} & \texttt{data\_output\_dvrp} & defining color tables for particles\\ \hline \end{tabular} \end{frame} % Folie 9 \begin{frame} \frametitle{Complete List of User-Interface Routines (II)} \tiny \ \\ \begin{tabular}{|p{2.5cm}|p{2.4cm}|p{2.1cm}|p{3cm}|} \hline \textbf{Name} & \textbf{Arguments} & \textbf{Called from} & \textbf{Task}\\ \hline \texttt{user\_header} & \texttt{io} & \texttt{header} & output user variables to header\\ \hline \texttt{user\_init} & - - - & \texttt{init\_3d\_model} & e.g. reading from restart file\\ \hline \texttt{user\_init\_3d\_model} & - - - & \texttt{init\_3d\_model} & special initializations\\ \hline \texttt{user\_init\_grid} & \texttt{gls}, \texttt{nzb\_local} & \texttt{init\_grid} & defining a special topography\\ \hline \texttt{user\_init\_particles} & - - - & \texttt{init\_particles} & defining initial particle sources\\ \hline \texttt{user\_init\_plant\_canopy} & - - - & \texttt{init\_3d\_model} & setting of leaf area density and canopy drag coefficient\\ \hline \texttt{user\_last\_actions} & - - - & \texttt{palm} & e.g. output for restart runs\\ \hline \texttt{MODULE user (user\_module.f90)} & - - - & - - - & contains user defined variables\\ \hline \texttt{user\_parin} & & \texttt{parin} & reading user variables\\ \hline \texttt{user\_particle\_attributes} & - - - & \texttt{advec\_particles} & defining particles attributes\\ \hline \texttt{user\_read\_restart\_data} & \texttt{i}, \texttt{nxlfa}, \texttt{nxl\_on\_file}, \texttt{nxrfa}, \texttt{nxr\_on\_file}, \texttt{nynfa}, \texttt{nyn\_on\_file}, \texttt{nysfa}, \texttt{nys\_on\_file}, \texttt{offset\_xa}, \texttt{offset\_ya}, \texttt{overlap\_count}, \texttt{tmp\_2d}, \texttt{tmp\_3d} & \texttt{read\_3d\_binary} & reading user-defined 2d/3d-arrays from the restart file\\ \hline \texttt{user\_spectra} & \texttt{mode}, \texttt{m}, \texttt{pr} & \texttt{data\_output\_spectra} & output/calculation of additional user-defined quantities\\ \hline \texttt{user\_statistics} & \texttt{mode}, \texttt{sr}, \texttt{tn} & \texttt{flow\_statistics} & calculating additional horizontal averages + time series quantities\\ \hline \end{tabular} \ \\ \ \\ See PALM online documentation under \\ \textbf{http://palm.muk.uni-hannover.de/wiki/doc/app/userint}\\ for detailed explanations. \end{frame} % Folie 10 \begin{frame} \frametitle{Data Access / Exchange} \footnotesize \begin{itemize} \item<2-> \textbf{Between the standard PALM code and the user-interface:}\\ \begin{itemize} \scriptsize \item<3-> by including the respective PALM modules in the user-interface subroutines.\\ \begin{center} \includegraphics[scale=0.3]{user_defined_code_figures/data_access_exchange.png} \end{center} \end{itemize} \item<4-> \textbf{Within the user-interface:} \begin{itemize} \scriptsize \item by the module \texttt{\textcolor{red}{user}} (file \texttt{user\underline{ }module.f90}), which is used in every subroutine included in the interface.\\ \textbf{This module is (and should be) never used in the standard PALM code, in order to avoid data flow from the user interface to the\\ PALM default code!} \end{itemize} \end{itemize} \end{frame} % Folie 11 \begin{frame} \frametitle{Usage of \texttt{user\underline{ }actions} (I)} \scriptsize \begin{itemize} \item<1-> \texttt{user\underline{ }actions} is designed to add additional terms to the prognostic equations or to carry out special actions at the beginning or the end of each timestep. \vspace{2mm} \item<2-> Therefore, several calls of \texttt{user\underline{ }actions} can be found in the default PALM routines \texttt{time\underline{ }integration} and \texttt{prognostic\underline{ }equations}. The place from which it is called is communicated to the routine by a string-argument, e.g.\\ \ \\ \quad \texttt{CALL user\underline{ }actions ( 'u-tendency' )}\\ \ \\ \onslide<3-> It means that this call is from a place within \texttt{prognostic\underline{ }equations}, where the tendencies for the u-component are calculated and integrated: \end{itemize} \vspace{-2mm} \begin{center} \includegraphics[scale=0.33]{user_defined_code_figures/user_actions_1.png} \end{center} \end{frame} % Folie 12 \begin{frame} \frametitle{Usage of \texttt{user\underline{ }actions} (II)} \scriptsize \begin{itemize} \item Additional tendencies have to be included by the user at the respective code line in \texttt{user\underline{ }actions}: \end{itemize} \begin{center} \includegraphics[scale=0.35]{user_defined_code_figures/user_actions_2.png} \end{center} \end{frame} % Folie 13 \begin{frame}[t] \frametitle{Usage of \texttt{user\underline{ }actions} (III)} \scriptsize \begin{columns}[T] \begin{column}{1.15\textwidth} \begin{itemize} \item<1-> The different versions of \texttt{prognostic\underline{ }equations} (\texttt{prognostic\underline{ }equations\underline{ }cache}, \texttt{prognostic\underline{ }equations\underline{ }vector}) contain different calls of \texttt{user\underline{ }actions}: \item<2-> From \texttt{prognostic\underline{ }equations\underline{ }vector}: \hspace{0.6em}\texttt{CALL user\underline{ }actions ( 'u-tendency' )} \item<3-> From \texttt{prognostic\underline{ }equations},\\ \texttt{prognostic\underline{ }equations\underline{ }cache}:\hspace{4em}\texttt{CALL user\underline{ }actions ( i, j, 'u-tendency' )} \vspace{3mm} \item<4-> In case that \texttt{prognostic\underline{ }equations}\\ \texttt{prognostic\underline{ }equations\underline{ }cache} are\\ used, the user has to add his code in\\ the interface routine\\ \texttt{user\underline{ }actions\underline{ }ij}: \vspace{3mm} \item<5-> Here, only the \texttt{k}-loop (vertical direction)\\ has to be used, because loops over\\ i and j are carried out in\\ \texttt{prognostic\underline{ }equations\underline{ }cache}. \end{itemize} \end{column} \end{columns} \uncover<4->{% \begin{tikzpicture}[remember picture, overlay] \node [shift={(8.3 cm,3.0cm)}] at (current page.south west) {% \begin{tikzpicture}[remember picture, overlay] \node[text width=14em] at (0,0) {\includegraphics[scale=0.3]{user_defined_code_figures/user_actions_3.png}}; \end{tikzpicture} }; \end{tikzpicture}} \end{frame} % Folie 14 \begin{frame} \frametitle{Steering the User-Interface} \scriptsize \begin{columns}[T] \begin{column}{1.1\textwidth} For steering the user-interface code, the user may want to add some additional variables and set their respective values within the parameter-file (e.g. \texttt{example\underline{ }cbl\underline{ }p3d}). This requires the following actions (example for a variable named \texttt{foo}): \end{column} \end{columns} \vspace{1mm} \begin{enumerate} \item<1-> Add the variable name to module \texttt{user} in order to define it and to make it available in all user-interface subroutines. Set a default value for this variable. \begin{center} \includegraphics[scale=0.3]{user_defined_code_figures/steering_1.png} \end{center} \vspace{1mm} \item<2-> Add the variable to the NAMELIST \texttt{/userpar/}. This NAMELIST already contains four predefined variables. \begin{center} \includegraphics[scale=0.3]{user_defined_code_figures/steering_2.png} \end{center} \vspace{1mm} \item<3-> Add the NAMELIST \texttt{\&userpar} to the parameter file (e.g. \texttt{example\underline{ }cbl\underline{ }p3d}) and assign a value to this variable. \begin{center} \includegraphics[scale=0.3]{user_defined_code_figures/steering_3.png} \end{center} \vspace{1mm} \item<4-> Output the variable's value using \texttt{user\underline{ }header}. \end{enumerate} \end{frame} % Folie 15 \begin{frame} \frametitle{User-Defined Output} \scriptsize \begin{itemize} \item<2-> A very typical request of users is the calculation and output of quantities which are not part of PALM's standard output (e.g. a 3D-array of the resolved-scale vertical heat (temperature) flux). \vspace{2mm} \item<3-> The default user interface includes a number of subroutines which allow the calculation of user-defined quantities and output of these quantities as profiles, timeseries, 2d cross section or 3d volume data. These are e.g.\\ \texttt{user\underline{ }check\underline{ }data\underline{ }output}, \texttt{user\underline{ }check\underline{ }data\underline{ }output\underline{ }pr},\\ \texttt{user\underline{ }define\underline{ }netcdf\underline{ }grid}, \texttt{user\underline{ }statistics},\\ \texttt{user\underline{ }3d\underline{ }data\underline{ }averaging}, \texttt{user\underline{ }data\underline{ }output\underline{ }2d},\\ \texttt{user\underline{ }data\underline{ }output\underline{ }3d}. \vspace{2mm} \item<4-> The respective subroutines contain, as an example, code lines (written as comment lines) for calculating and output the square of the u-component velocity. \vspace{2mm} \item<5-> These quantities are output to PALM‘s standard netCDF files, i.e.\\ \texttt{DATA\underline{ }1D\underline{ }PR\underline{ }NETCDF}, \texttt{DATA\underline{ }1D\underline{ }TS\underline{ }NETCDF}, \texttt{DATA\underline{ }2D\underline{ }XY\underline{ }NETCDF} or \texttt{DATA\underline{ }3D\underline{ }NETCDF}. \vspace{2mm} \item<6-> The online documentation gives very detailed instructions about how to modify the interface in order to output user-defined quantities under\\ \vspace{1mm} \textbf{http://palm.muk.uni-hannover.de/wiki/doc/app/userint/output} \end{itemize} \end{frame} % Folie 16 \begin{frame} \frametitle{User-Defined Data for Restart Runs (I)} \scriptsize \begin{itemize} \item It might be neccessary to save the values of user-defined variables at the end of a model run in order to use them for a restart run.\\ \ \\ This can be done using the routine \texttt{user\underline{ }last\underline{ }actions}.\\ \grqq \texttt{14}\grqq\, is the file-id for the restart file (local filename \texttt{BINOUT}): \end{itemize} \begin{center} \includegraphics[scale=0.3]{user_defined_code_figures/restart_1.png} \end{center} \end{frame} % Folie 17 \begin{frame} \frametitle{User-Defined Data for Restart Runs (II)} \scriptsize \begin{itemize} \item Additionally, these variables have to be read from the restart file (file-id \grqq \texttt{13}\grqq\,, local filename \texttt{BININ}) by adding code to the routine \texttt{user\underline{ }read\underline{ }restart\underline{ }data}: \end{itemize} \begin{center} \includegraphics[scale=0.3]{user_defined_code_figures/restart_2.png} \end{center} \end{frame} % Folie 18 \begin{frame} \frametitle{Using the User-Interface with \texttt{mrun}} \scriptsize \begin{columns}[T] \begin{column}{1.1\textwidth} \vspace{-1mm} \textbf{Users can add their own (modified) user-interface to a PALM-run by carrying out the following steps:} \begin{enumerate} \item<2-> Copy the default (empty) user-interface files that you need (e.g. user\underline{ }module.f90, user\underline{ }parin.f90, user\underline{ }actions.f90) to a directory of your choice, e.g.:\\ \tiny \quad \texttt{cd \~{ }/palm/current\underline{ }version}\\ \quad \texttt{mkdir -p USER\underline{ }CODE/example\underline{ }cbl}\\ \quad \texttt{cp trunk/SOURCE/user\underline{ }module.f90 USER\underline{ }CODE/example\underline{ }cbl/user\underline{ }module.f90}\\ \quad \texttt{cp trunk/SOURCE/user\underline{ }parin.f90\hspace{1em}USER\underline{ }CODE/example\underline{ }cbl/user\underline{ }parin.f90}\\ \quad \texttt{...} \scriptsize \vspace{-1mm} \item<3-> Set an additional path in the configuration file \texttt{.mrun.config} to allow \texttt{mrun} to find and include this file:\\ \tiny \quad \texttt{\%add\underline{ }source\underline{ }path \hspace{1em} \$base\underline{ }directory/USER\underline{ }CODE/\$fname} \scriptsize \item<4-> Modify the interface routines according to your needs. \item<5-> Start a PALM run by executing\\ \tiny \quad \texttt{mrun -d example\underline{ }cbl ...}\\ \scriptsize The files user\underline{ }*.f90 will be automatically compiled within the job / interactive run and will replace the respective PALM default user-interface files. \end{enumerate} \vspace{-2mm} \begin{itemize} \item<6-> \textbf{The modified user-interface file cannot be pre-compiled by using} \texttt{mbuild}! \item<7-> The above method allows to use different user-interfaces for different runs. Just store the respective interface-files in subdirectories \texttt{USER\underline{ }CODE/abcd}, \texttt{USER\underline{ }CODE/cdef}, etc. and start \texttt{mrun} with option \grqq \texttt{-d abcd}\grqq, \grqq \texttt{-d cdef}\grqq, etc. \end{itemize} \end{column} \end{columns} \end{frame} \end{document}