| 1 | % $Header: /u/gcmpack/mitgcmdoc/part3/getting_started.tex,v 1.3 2001/10/11 19:18:41 adcroft Exp $ | 
| 2 | % $Name:  $ | 
| 3 |  | 
| 4 | %\section{Getting started} | 
| 5 |  | 
| 6 | In this section, we describe how to use the model. In the first | 
| 7 | section, we provide enough information to help you get started with | 
| 8 | the model. We believe the best way to familiarize yourself with the | 
| 9 | model is to run the case study examples provided with the base | 
| 10 | version. Information on how to obtain, compile, and run the code is | 
| 11 | found there as well as a brief description of the model structure | 
| 12 | directory and the case study examples.  The latter and the code | 
| 13 | structure are described more fully in chapters | 
| 14 | \ref{chap:discretization} and \ref{chap:sarch}, respectively. Here, in | 
| 15 | this section, we provide information on how to customize the code when | 
| 16 | you are ready to try implementing the configuration you have in mind. | 
| 17 |  | 
| 18 | \section{Where to find information} | 
| 19 | \label{sect:whereToFindInfo} | 
| 20 |  | 
| 21 | A web site is maintained for release 1 (Sealion) of MITgcm: | 
| 22 | \begin{verbatim} | 
| 23 | http://mitgcm.org/sealion | 
| 24 | \end{verbatim} | 
| 25 | Here you will find an on-line version of this document, a | 
| 26 | ``browsable'' copy of the code and a searchable database of the model | 
| 27 | and site, as well as links for downloading the model and | 
| 28 | documentation, to data-sources and other related sites. | 
| 29 |  | 
| 30 | There is also a support news group for the model that you can email at | 
| 31 | \texttt{support@mitgcm.org} or browse at: | 
| 32 | \begin{verbatim} | 
| 33 | news://mitgcm.org/mitgcm.support | 
| 34 | \end{verbatim} | 
| 35 | A mail to the email list will reach all the developers and be archived | 
| 36 | on the newsgroup. A users email list will be established at some time | 
| 37 | in the future. | 
| 38 |  | 
| 39 |  | 
| 40 | \section{Obtaining the code} | 
| 41 | \label{sect:obtainingCode} | 
| 42 |  | 
| 43 | If CVS is available on your system, we strongly encourage you to use it. CVS | 
| 44 | provides an efficient and elegant way of organizing your code and keeping | 
| 45 | track of your changes. If CVS is not available on your machine, you can also | 
| 46 | download a tar file. | 
| 47 |  | 
| 48 | Before you can use CVS, the following environment variable has to be set in | 
| 49 | your .cshrc or .tcshrc: | 
| 50 | \begin{verbatim} | 
| 51 | % setenv CVSROOT :pserver:cvsanon@mitgcm.org:/u/u0/gcmpack | 
| 52 | % cvs login ( CVS password: cvsanon ) | 
| 53 | \end{verbatim} | 
| 54 |  | 
| 55 | You only need to do ``cvs login'' once. To obtain the source for the release: | 
| 56 | \begin{verbatim} | 
| 57 | % cvs co -d directory -P -r release1 MITgcmUV | 
| 58 | \end{verbatim} | 
| 59 |  | 
| 60 | This creates a directory called \textit{directory}. If \textit{directory} | 
| 61 | exists this command updates your code based on the repository. Each | 
| 62 | directory in the source tree contains a directory \textit{CVS}. This | 
| 63 | information is required by CVS to keep track of your file versions with | 
| 64 | respect to the repository. Don't edit the files in \textit{CVS}! To obtain a | 
| 65 | different \textit{version} that is not the latest source: | 
| 66 | \begin{verbatim} | 
| 67 | % cvs co -d directory -P -r version MITgcm | 
| 68 | \end{verbatim} | 
| 69 | or the latest development version: | 
| 70 | \begin{verbatim} | 
| 71 | % cvs co -d directory -P MITgcm | 
| 72 | \end{verbatim} | 
| 73 |  | 
| 74 | \paragraph*{Conventional download method} | 
| 75 | \label{sect:conventionalDownload} | 
| 76 |  | 
| 77 | If you do not have CVS on your system, you can download the model as a | 
| 78 | tar file from the reference web site at: | 
| 79 | \begin{verbatim} | 
| 80 | http://mitgcm.org/download/ | 
| 81 | \end{verbatim} | 
| 82 | The tar file still contains CVS information which we urge you not to | 
| 83 | delete; even if you do not use CVS yourself the information can help | 
| 84 | us if you should need to send us your copy of the code. | 
| 85 |  | 
| 86 | \section{Model and directory structure} | 
| 87 |  | 
| 88 | The ``numerical'' model is contained within a execution environment support | 
| 89 | wrapper. This wrapper is designed to provide a general framework for | 
| 90 | grid-point models. MITgcmUV is a specific numerical model that uses the | 
| 91 | framework. Under this structure the model is split into execution | 
| 92 | environment support code and conventional numerical model code. The | 
| 93 | execution environment support code is held under the \textit{eesupp} | 
| 94 | directory. The grid point model code is held under the \textit{model} | 
| 95 | directory. Code execution actually starts in the \textit{eesupp} routines | 
| 96 | and not in the \textit{model} routines. For this reason the top-level | 
| 97 | \textit{MAIN.F} is in the \textit{eesupp/src} directory. In general, | 
| 98 | end-users should not need to worry about this level. The top-level routine | 
| 99 | for the numerical part of the code is in \textit{model/src/THE\_MODEL\_MAIN.F% | 
| 100 | }. Here is a brief description of the directory structure of the model under | 
| 101 | the root tree (a detailed description is given in section 3: Code structure). | 
| 102 |  | 
| 103 | \begin{itemize} | 
| 104 | \item \textit{bin}: this directory is initially empty. It is the default | 
| 105 | directory in which to compile the code. | 
| 106 |  | 
| 107 | \item \textit{diags}: contains the code relative to time-averaged | 
| 108 | diagnostics. It is subdivided into two subdirectories \textit{inc} and | 
| 109 | \textit{src} that contain include files (*.\textit{h} files) and fortran | 
| 110 | subroutines (*.\textit{F} files), respectively. | 
| 111 |  | 
| 112 | \item \textit{doc}: contains brief documentation notes. | 
| 113 |  | 
| 114 | \item \textit{eesupp}: contains the execution environment source code. Also | 
| 115 | subdivided into two subdirectories \textit{inc} and \textit{src}. | 
| 116 |  | 
| 117 | \item \textit{exe}: this directory is initially empty. It is the default | 
| 118 | directory in which to execute the code. | 
| 119 |  | 
| 120 | \item \textit{model}: this directory contains the main source code. Also | 
| 121 | subdivided into two subdirectories \textit{inc} and \textit{src}. | 
| 122 |  | 
| 123 | \item \textit{pkg}: contains the source code for the packages. Each package | 
| 124 | corresponds to a subdirectory. For example, \textit{gmredi} contains the | 
| 125 | code related to the Gent-McWilliams/Redi scheme, \textit{aim} the code | 
| 126 | relative to the atmospheric intermediate physics. The packages are described | 
| 127 | in detail in section 3. | 
| 128 |  | 
| 129 | \item \textit{tools}: this directory contains various useful tools. For | 
| 130 | example, \textit{genmake} is a script written in csh (C-shell) that should | 
| 131 | be used to generate your makefile. The directory \textit{adjoint} contains | 
| 132 | the makefile specific to the Tangent linear and Adjoint Compiler (TAMC) that | 
| 133 | generates the adjoint code. The latter is described in details in part V. | 
| 134 |  | 
| 135 | \item \textit{utils}: this directory contains various utilities. The | 
| 136 | subdirectory \textit{knudsen2} contains code and a makefile that | 
| 137 | compute coefficients of the polynomial approximation to the knudsen | 
| 138 | formula for an ocean nonlinear equation of state. The \textit{matlab} | 
| 139 | subdirectory contains matlab scripts for reading model output directly | 
| 140 | into matlab. \textit{scripts} contains C-shell post-processing | 
| 141 | scripts for joining processor-based and tiled-based model output. | 
| 142 |  | 
| 143 | \item \textit{verification}: this directory contains the model examples. See | 
| 144 | section \ref{sect:modelExamples}. | 
| 145 | \end{itemize} | 
| 146 |  | 
| 147 | \section{Example experiments} | 
| 148 | \label{sect:modelExamples} | 
| 149 |  | 
| 150 | Now that you have successfully downloaded the model code we recommend that | 
| 151 | you first try to run the examples provided with the base version. You will | 
| 152 | probably want to run the example that is the closest to the configuration | 
| 153 | you will use eventually. The examples are located in subdirectories under | 
| 154 | the directory \textit{verification} and are briefly described below (a full | 
| 155 | description is given in section 2): | 
| 156 |  | 
| 157 | \subsection{List of model examples} | 
| 158 |  | 
| 159 | \begin{itemize} | 
| 160 | \item \textit{exp0} - single layer, ocean double gyre (barotropic with | 
| 161 | free-surface). | 
| 162 |  | 
| 163 | \item \textit{exp1} - 4 layers, ocean double gyre. | 
| 164 |  | 
| 165 | \item \textit{exp2} - 4x4 degree global ocean simulation with steady | 
| 166 | climatological forcing. | 
| 167 |  | 
| 168 | \item \textit{exp4} - flow over a Gaussian bump in open-water or channel | 
| 169 | with open boundaries. | 
| 170 |  | 
| 171 | \item \textit{exp5} - inhomogenously forced ocean convection in a doubly | 
| 172 | periodic box. | 
| 173 |  | 
| 174 | \item \textit{front\_relax} - relaxation of an ocean thermal front (test for | 
| 175 | Gent/McWilliams scheme). 2D (Y-Z). | 
| 176 |  | 
| 177 | \item \textit{internal wave} - ocean internal wave forced by open boundary | 
| 178 | conditions. | 
| 179 |  | 
| 180 | \item \textit{natl\_box} - eastern subtropical North Atlantic with KPP | 
| 181 | scheme; 1 month integration | 
| 182 |  | 
| 183 | \item \textit{hs94.1x64x5} - zonal averaged atmosphere using Held and Suarez | 
| 184 | '94 forcing. | 
| 185 |  | 
| 186 | \item \textit{hs94.128x64x5} - 3D atmosphere dynamics using Held and Suarez | 
| 187 | '94 forcing. | 
| 188 |  | 
| 189 | \item \textit{hs94.cs-32x32x5} - 3D atmosphere dynamics using Held and | 
| 190 | Suarez '94 forcing on the cubed sphere. | 
| 191 |  | 
| 192 | \item \textit{aim.5l\_zon-ave} - Intermediate Atmospheric physics, 5 layers | 
| 193 | Molteni physics package. Global Zonal Mean configuration, 1x64x5 resolution. | 
| 194 |  | 
| 195 | \item \textit{aim.5l\_XZ\_Equatorial\_Slice} - Intermediate Atmospheric | 
| 196 | physics, 5 layers Molteni physics package. Equatorial Slice configuration. | 
| 197 | 2D (X-Z). | 
| 198 |  | 
| 199 | \item \textit{aim.5l\_Equatorial\_Channel} - Intermediate Atmospheric | 
| 200 | physics, 5 layers Molteni physics package. 3D Equatorial Channel | 
| 201 | configuration (not completely tested). | 
| 202 |  | 
| 203 | \item \textit{aim.5l\_LatLon} - Intermediate Atmospheric physics, 5 layers | 
| 204 | Molteni physics package. Global configuration, 128x64x5 resolution. | 
| 205 |  | 
| 206 | \item \textit{adjustment.128x64x1} | 
| 207 |  | 
| 208 | \item \textit{adjustment.cs-32x32x1} | 
| 209 | \end{itemize} | 
| 210 |  | 
| 211 | \subsection{Directory structure of model examples} | 
| 212 |  | 
| 213 | Each example directory has the following subdirectories: | 
| 214 |  | 
| 215 | \begin{itemize} | 
| 216 | \item \textit{code}: contains the code particular to the example. At a | 
| 217 | minimum, this directory includes the following files: | 
| 218 |  | 
| 219 | \begin{itemize} | 
| 220 | \item \textit{code/CPP\_EEOPTIONS.h}: declares CPP keys relative to the | 
| 221 | ``execution environment'' part of the code. The default version is located | 
| 222 | in \textit{eesupp/inc}. | 
| 223 |  | 
| 224 | \item \textit{code/CPP\_OPTIONS.h}: declares CPP keys relative to the | 
| 225 | ``numerical model'' part of the code. The default version is located in | 
| 226 | \textit{model/inc}. | 
| 227 |  | 
| 228 | \item \textit{code/SIZE.h}: declares size of underlying computational grid. | 
| 229 | The default version is located in \textit{model/inc}. | 
| 230 | \end{itemize} | 
| 231 |  | 
| 232 | In addition, other include files and subroutines might be present in \textit{% | 
| 233 | code} depending on the particular experiment. See section 2 for more details. | 
| 234 |  | 
| 235 | \item \textit{input}: contains the input data files required to run the | 
| 236 | example. At a mimimum, the \textit{input} directory contains the following | 
| 237 | files: | 
| 238 |  | 
| 239 | \begin{itemize} | 
| 240 | \item \textit{input/data}: this file, written as a namelist, specifies the | 
| 241 | main parameters for the experiment. | 
| 242 |  | 
| 243 | \item \textit{input/data.pkg}: contains parameters relative to the packages | 
| 244 | used in the experiment. | 
| 245 |  | 
| 246 | \item \textit{input/eedata}: this file contains ``execution environment'' | 
| 247 | data. At present, this consists of a specification of the number of threads | 
| 248 | to use in $X$ and $Y$ under multithreaded execution. | 
| 249 | \end{itemize} | 
| 250 |  | 
| 251 | In addition, you will also find in this directory the forcing and topography | 
| 252 | files as well as the files describing the initial state of the experiment. | 
| 253 | This varies from experiment to experiment. See section 2 for more details. | 
| 254 |  | 
| 255 | \item \textit{results}: this directory contains the output file \textit{% | 
| 256 | output.txt} produced by the simulation example. This file is useful for | 
| 257 | comparison with your own output when you run the experiment. | 
| 258 | \end{itemize} | 
| 259 |  | 
| 260 | Once you have chosen the example you want to run, you are ready to compile | 
| 261 | the code. | 
| 262 |  | 
| 263 | \section{Building the code} | 
| 264 | \label{sect:buildingCode} | 
| 265 |  | 
| 266 | To compile the code, we use the {\em make} program. This uses a file | 
| 267 | ({\em Makefile}) that allows us to pre-process source files, specify | 
| 268 | compiler and optimization options and also figures out any file | 
| 269 | dependancies. We supply a script ({\em genmake}), described in section | 
| 270 | \ref{sect:genmake}, that automatically creates the {\em Makefile} for | 
| 271 | you. You then need to build the dependancies and compile the code. | 
| 272 |  | 
| 273 | As an example, let's assume that you want to build and run experiment | 
| 274 | \textit{verification/exp2}. The are multiple ways and places to actually | 
| 275 | do this but here let's build the code in | 
| 276 | \textit{verification/exp2/input}: | 
| 277 | \begin{verbatim} | 
| 278 | % cd verification/exp2/input | 
| 279 | \end{verbatim} | 
| 280 | First, build the {\em Makefile}: | 
| 281 | \begin{verbatim} | 
| 282 | % ../../../tools/genmake -mods=../code | 
| 283 | \end{verbatim} | 
| 284 | The command line option tells {\em genmake} to override model source | 
| 285 | code with any files in the directory {\em ./code/}. | 
| 286 |  | 
| 287 | If there is no \textit{.genmakerc} in the \textit{input} directory, you have | 
| 288 | to use the following options when invoking \textit{genmake}: | 
| 289 | \begin{verbatim} | 
| 290 | % ../../../tools/genmake  -mods=../code | 
| 291 | \end{verbatim} | 
| 292 |  | 
| 293 | Next, create the dependancies: | 
| 294 | \begin{verbatim} | 
| 295 | % make depend | 
| 296 | \end{verbatim} | 
| 297 | This modifies {\em Makefile} by attaching a [long] list of files on | 
| 298 | which other files depend. The purpose of this is to reduce | 
| 299 | re-compilation if and when you start to modify the code. {\tt make | 
| 300 | depend} also created links from the model source to this directory. | 
| 301 |  | 
| 302 | Now compile the code: | 
| 303 | \begin{verbatim} | 
| 304 | % make | 
| 305 | \end{verbatim} | 
| 306 | The {\tt make} command creates an executable called \textit{mitgcmuv}. | 
| 307 |  | 
| 308 | Now you are ready to run the model. General instructions for doing so are | 
| 309 | given in section \ref{sect:runModel}. Here, we can run the model with: | 
| 310 | \begin{verbatim} | 
| 311 | ./mitgcmuv > output.txt | 
| 312 | \end{verbatim} | 
| 313 | where we are re-directing the stream of text output to the file {\em | 
| 314 | output.txt}. | 
| 315 |  | 
| 316 |  | 
| 317 | \subsection{Building/compiling the code elsewhere} | 
| 318 |  | 
| 319 | In the example above (section \ref{sect:buildingCode}) we built the | 
| 320 | executable in the {\em input} directory of the experiment for | 
| 321 | convenience. You can also configure and compile the code in other | 
| 322 | locations, for example on a scratch disk with out having to copy the | 
| 323 | entire source tree. The only requirement to do so is you have {\tt | 
| 324 | genmake} in your path or you know the absolute path to {\tt genmake}. | 
| 325 |  | 
| 326 | The following sections outline some possible methods of organizing you | 
| 327 | source and data. | 
| 328 |  | 
| 329 | \subsubsection{Building from the {\em ../code directory}} | 
| 330 |  | 
| 331 | This is just as simple as building in the {\em input/} directory: | 
| 332 | \begin{verbatim} | 
| 333 | % cd verification/exp2/code | 
| 334 | % ../../../tools/genmake | 
| 335 | % make depend | 
| 336 | % make | 
| 337 | \end{verbatim} | 
| 338 | However, to run the model the executable ({\em mitgcmuv}) and input | 
| 339 | files must be in the same place. If you only have one calculation to make: | 
| 340 | \begin{verbatim} | 
| 341 | % cd ../input | 
| 342 | % cp ../code/mitgcmuv ./ | 
| 343 | % ./mitgcmuv > output.txt | 
| 344 | \end{verbatim} | 
| 345 | or if you will be making muliple runs with the same executable: | 
| 346 | \begin{verbatim} | 
| 347 | % cd ../ | 
| 348 | % cp -r input run1 | 
| 349 | % cp code/mitgcmuv run1 | 
| 350 | % cd run1 | 
| 351 | % ./mitgcmuv > output.txt | 
| 352 | \end{verbatim} | 
| 353 |  | 
| 354 | \subsubsection{Building from a new directory} | 
| 355 |  | 
| 356 | Since the {\em input} directory contains input files it is often more | 
| 357 | useful to keep {\em input} prestine and build in a new directory | 
| 358 | within {\em verification/exp2/}: | 
| 359 | \begin{verbatim} | 
| 360 | % cd verification/exp2 | 
| 361 | % mkdir build | 
| 362 | % cd build | 
| 363 | % ../../../tools/genmake -mods=../code | 
| 364 | % make depend | 
| 365 | % make | 
| 366 | \end{verbatim} | 
| 367 | This builds the code exactly as before but this time you need to copy | 
| 368 | either the executable or the input files or both in order to run the | 
| 369 | model. For example, | 
| 370 | \begin{verbatim} | 
| 371 | % cp ../input/* ./ | 
| 372 | % ./mitgcmuv > output.txt | 
| 373 | \end{verbatim} | 
| 374 | or if you tend to make multiple runs with the same executable then | 
| 375 | running in a new directory each time might be more appropriate: | 
| 376 | \begin{verbatim} | 
| 377 | % cd ../ | 
| 378 | % mkdir run1 | 
| 379 | % cp build/mitgcmuv run1/ | 
| 380 | % cp input/* run1/ | 
| 381 | % cd run1 | 
| 382 | % ./mitgcmuv > output.txt | 
| 383 | \end{verbatim} | 
| 384 |  | 
| 385 | \subsubsection{Building from on a scratch disk} | 
| 386 |  | 
| 387 | Model object files and output data can use up large amounts of disk | 
| 388 | space so it is often the case that you will be operating on a large | 
| 389 | scratch disk. Assuming the model source is in {\em ~/MITgcm} then the | 
| 390 | following commands will build the model in {\em /scratch/exp2-run1}: | 
| 391 | \begin{verbatim} | 
| 392 | % cd /scratch/exp2-run1 | 
| 393 | % ~/MITgcm/tools/genmake -rootdir=~/MITgcm -mods=~/MITgcm/verification/exp2/code | 
| 394 | % make depend | 
| 395 | % make | 
| 396 | \end{verbatim} | 
| 397 | To run the model here, you'll need the input files: | 
| 398 | \begin{verbatim} | 
| 399 | % cp ~/MITgcm/verification/exp2/input/* ./ | 
| 400 | % ./mitgcmuv > output.txt | 
| 401 | \end{verbatim} | 
| 402 |  | 
| 403 | As before, you could build in one directory and make multiple runs of | 
| 404 | the one experiment: | 
| 405 | \begin{verbatim} | 
| 406 | % cd /scratch/exp2 | 
| 407 | % mkdir build | 
| 408 | % cd build | 
| 409 | % ~/MITgcm/tools/genmake -rootdir=~/MITgcm -mods=~/MITgcm/verification/exp2/code | 
| 410 | % make depend | 
| 411 | % make | 
| 412 | % cd ../ | 
| 413 | % cp -r ~/MITgcm/verification/exp2/input run2 | 
| 414 | % cd run2 | 
| 415 | % ./mitgcmuv > output.txt | 
| 416 | \end{verbatim} | 
| 417 |  | 
| 418 |  | 
| 419 |  | 
| 420 | \subsection{\textit{genmake}} | 
| 421 | \label{sect:genmake} | 
| 422 |  | 
| 423 | To compile the code, use the script \textit{genmake} located in the \textit{% | 
| 424 | tools} directory. \textit{genmake} is a script that generates the makefile. | 
| 425 | It has been written so that the code can be compiled on a wide diversity of | 
| 426 | machines and systems. However, if it doesn't work the first time on your | 
| 427 | platform, you might need to edit certain lines of \textit{genmake} in the | 
| 428 | section containing the setups for the different machines. The file is | 
| 429 | structured like this: | 
| 430 | \begin{verbatim} | 
| 431 | . | 
| 432 | . | 
| 433 | . | 
| 434 | general instructions (machine independent) | 
| 435 | . | 
| 436 | . | 
| 437 | . | 
| 438 | - setup machine 1 | 
| 439 | - setup machine 2 | 
| 440 | - setup machine 3 | 
| 441 | - setup machine 4 | 
| 442 | etc | 
| 443 | . | 
| 444 | . | 
| 445 | . | 
| 446 | \end{verbatim} | 
| 447 |  | 
| 448 | For example, the setup corresponding to a DEC alpha machine is reproduced | 
| 449 | here: | 
| 450 | \begin{verbatim} | 
| 451 | case OSF1+mpi: | 
| 452 | echo "Configuring for DEC Alpha" | 
| 453 | set CPP        = ( '/usr/bin/cpp -P' ) | 
| 454 | set DEFINES    = ( ${DEFINES}  '-DTARGET_DEC -DWORDLENGTH=1' ) | 
| 455 | set KPP        = ( 'kapf' ) | 
| 456 | set KPPFILES   = ( 'main.F' ) | 
| 457 | set KFLAGS1    = ( '-scan=132 -noconc -cmp=' ) | 
| 458 | set FC         = ( 'f77' ) | 
| 459 | set FFLAGS     = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' ) | 
| 460 | set FOPTIM     = ( '-O5 -fast -tune host -inline all' ) | 
| 461 | set NOOPTFLAGS = ( '-O0' ) | 
| 462 | set LIBS       = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' ) | 
| 463 | set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F') | 
| 464 | set RMFILES    = ( '*.p.out' ) | 
| 465 | breaksw | 
| 466 | \end{verbatim} | 
| 467 |  | 
| 468 | Typically, these are the lines that you might need to edit to make \textit{% | 
| 469 | genmake} work on your platform if it doesn't work the first time. \textit{% | 
| 470 | genmake} understands several options that are described here: | 
| 471 |  | 
| 472 | \begin{itemize} | 
| 473 | \item -rootdir=dir | 
| 474 |  | 
| 475 | indicates where the model root directory is relative to the directory where | 
| 476 | you are compiling. This option is not needed if you compile in the \textit{% | 
| 477 | bin} directory (which is the default compilation directory) or within the | 
| 478 | \textit{verification} tree. | 
| 479 |  | 
| 480 | \item -mods=dir1,dir2,... | 
| 481 |  | 
| 482 | indicates the relative or absolute paths directories where the sources | 
| 483 | should take precedence over the default versions (located in \textit{model}, | 
| 484 | \textit{eesupp},...). Typically, this option is used when running the | 
| 485 | examples, see below. | 
| 486 |  | 
| 487 | \item -enable=pkg1,pkg2,... | 
| 488 |  | 
| 489 | enables packages source code \textit{pkg1}, \textit{pkg2},... when creating | 
| 490 | the makefile. | 
| 491 |  | 
| 492 | \item -disable=pkg1,pkg2,... | 
| 493 |  | 
| 494 | disables packages source code \textit{pkg1}, \textit{pkg2},... when creating | 
| 495 | the makefile. | 
| 496 |  | 
| 497 | \item -platform=machine | 
| 498 |  | 
| 499 | specifies the platform for which you want the makefile. In general, you | 
| 500 | won't need this option. \textit{genmake} will select the right machine for | 
| 501 | you (the one you're working on!). However, this option is useful if you have | 
| 502 | a choice of several compilers on one machine and you want to use the one | 
| 503 | that is not the default (ex: \texttt{pgf77} instead of \texttt{f77} under | 
| 504 | Linux). | 
| 505 |  | 
| 506 | \item -mpi | 
| 507 |  | 
| 508 | this is used when you want to run the model in parallel processing mode | 
| 509 | under mpi (see section on parallel computation for more details). | 
| 510 |  | 
| 511 | \item -jam | 
| 512 |  | 
| 513 | this is used when you want to run the model in parallel processing mode | 
| 514 | under jam (see section on parallel computation for more details). | 
| 515 | \end{itemize} | 
| 516 |  | 
| 517 | For some of the examples, there is a file called \textit{.genmakerc} in the | 
| 518 | \textit{input} directory that has the relevant \textit{genmake} options for | 
| 519 | that particular example. In this way you don't need to type the options when | 
| 520 | invoking \textit{genmake}. | 
| 521 |  | 
| 522 |  | 
| 523 | \section{Running the model} | 
| 524 | \label{sect:runModel} | 
| 525 |  | 
| 526 | If compilation finished succesfuully (section \ref{sect:buildModel}) | 
| 527 | then an executable called {\em mitgcmuv} will now exist in the local | 
| 528 | directory. | 
| 529 |  | 
| 530 | To run the model as a single process (ie. not in parallel) simply | 
| 531 | type: | 
| 532 | \begin{verbatim} | 
| 533 | % ./mitgcmuv | 
| 534 | \end{verbatim} | 
| 535 | The ``./'' is a safe-guard to make sure you use the local executable | 
| 536 | in case you have others that exist in your path (surely odd if you | 
| 537 | do!). The above command will spew out many lines of text output to | 
| 538 | your screen.  This output contains details such as parameter values as | 
| 539 | well as diagnostics such as mean Kinetic energy, largest CFL number, | 
| 540 | etc. It is worth keeping this text output with the binary output so we | 
| 541 | normally re-direct the {\em stdout} stream as follows: | 
| 542 | \begin{verbatim} | 
| 543 | % ./mitgcmuv > output.txt | 
| 544 | \end{verbatim} | 
| 545 |  | 
| 546 | For the example experiments in {\em vericication}, an example of the | 
| 547 | output is kept in {\em results/output.txt} for comparison. You can compare | 
| 548 | your {\em output.txt} with this one to check that the set-up works. | 
| 549 |  | 
| 550 |  | 
| 551 |  | 
| 552 | \subsection{Output files} | 
| 553 |  | 
| 554 | The model produces various output files. At a minimum, the instantaneous | 
| 555 | ``state'' of the model is written out, which is made of the following files: | 
| 556 |  | 
| 557 | \begin{itemize} | 
| 558 | \item \textit{U.00000nIter} - zonal component of velocity field (m/s and $> | 
| 559 | 0 $ eastward). | 
| 560 |  | 
| 561 | \item \textit{V.00000nIter} - meridional component of velocity field (m/s | 
| 562 | and $> 0$ northward). | 
| 563 |  | 
| 564 | \item \textit{W.00000nIter} - vertical component of velocity field (ocean: | 
| 565 | m/s and $> 0$ upward, atmosphere: Pa/s and $> 0$ towards increasing pressure | 
| 566 | i.e. downward). | 
| 567 |  | 
| 568 | \item \textit{T.00000nIter} - potential temperature (ocean: $^{0}$C, | 
| 569 | atmosphere: $^{0}$K). | 
| 570 |  | 
| 571 | \item \textit{S.00000nIter} - ocean: salinity (psu), atmosphere: water vapor | 
| 572 | (g/kg). | 
| 573 |  | 
| 574 | \item \textit{Eta.00000nIter} - ocean: surface elevation (m), atmosphere: | 
| 575 | surface pressure anomaly (Pa). | 
| 576 | \end{itemize} | 
| 577 |  | 
| 578 | The chain \textit{00000nIter} consists of ten figures that specify the | 
| 579 | iteration number at which the output is written out. For example, \textit{% | 
| 580 | U.0000000300} is the zonal velocity at iteration 300. | 
| 581 |  | 
| 582 | In addition, a ``pickup'' or ``checkpoint'' file called: | 
| 583 |  | 
| 584 | \begin{itemize} | 
| 585 | \item \textit{pickup.00000nIter} | 
| 586 | \end{itemize} | 
| 587 |  | 
| 588 | is written out. This file represents the state of the model in a condensed | 
| 589 | form and is used for restarting the integration. If the C-D scheme is used, | 
| 590 | there is an additional ``pickup'' file: | 
| 591 |  | 
| 592 | \begin{itemize} | 
| 593 | \item \textit{pickup\_cd.00000nIter} | 
| 594 | \end{itemize} | 
| 595 |  | 
| 596 | containing the D-grid velocity data and that has to be written out as well | 
| 597 | in order to restart the integration. Rolling checkpoint files are the same | 
| 598 | as the pickup files but are named differently. Their name contain the chain | 
| 599 | \textit{ckptA} or \textit{ckptB} instead of \textit{00000nIter}. They can be | 
| 600 | used to restart the model but are overwritten every other time they are | 
| 601 | output to save disk space during long integrations. | 
| 602 |  | 
| 603 | \subsection{Looking at the output} | 
| 604 |  | 
| 605 | All the model data are written according to a ``meta/data'' file format. | 
| 606 | Each variable is associated with two files with suffix names \textit{.data} | 
| 607 | and \textit{.meta}. The \textit{.data} file contains the data written in | 
| 608 | binary form (big\_endian by default). The \textit{.meta} file is a | 
| 609 | ``header'' file that contains information about the size and the structure | 
| 610 | of the \textit{.data} file. This way of organizing the output is | 
| 611 | particularly useful when running multi-processors calculations. The base | 
| 612 | version of the model includes a few matlab utilities to read output files | 
| 613 | written in this format. The matlab scripts are located in the directory | 
| 614 | \textit{utils/matlab} under the root tree. The script \textit{rdmds.m} reads | 
| 615 | the data. Look at the comments inside the script to see how to use it. | 
| 616 |  | 
| 617 | Some examples of reading and visualizing some output in {\em Matlab}: | 
| 618 | \begin{verbatim} | 
| 619 | % matlab | 
| 620 | >> H=rdmds('Depth'); | 
| 621 | >> contourf(H');colorbar; | 
| 622 | >> title('Depth of fluid as used by model'); | 
| 623 |  | 
| 624 | >> eta=rdmds('Eta',10); | 
| 625 | >> imagesc(eta');axis ij;colorbar; | 
| 626 | >> title('Surface height at iter=10'); | 
| 627 |  | 
| 628 | >> eta=rdmds('Eta',[0:10:100]); | 
| 629 | >> for n=1:11; imagesc(eta(:,:,n)');axis ij;colorbar;pause(.5);end | 
| 630 | \end{verbatim} | 
| 631 |  | 
| 632 | \section{Doing it yourself: customizing the code} | 
| 633 |  | 
| 634 | When you are ready to run the model in the configuration you want, the | 
| 635 | easiest thing is to use and adapt the setup of the case studies experiment | 
| 636 | (described previously) that is the closest to your configuration. Then, the | 
| 637 | amount of setup will be minimized. In this section, we focus on the setup | 
| 638 | relative to the ''numerical model'' part of the code (the setup relative to | 
| 639 | the ''execution environment'' part is covered in the parallel implementation | 
| 640 | section) and on the variables and parameters that you are likely to change. | 
| 641 |  | 
| 642 | \subsection{\protect\bigskip Configuration and setup} | 
| 643 |  | 
| 644 | The CPP keys relative to the ''numerical model'' part of the code are all | 
| 645 | defined and set in the file \textit{CPP\_OPTIONS.h }in the directory \textit{% | 
| 646 | model/inc }or in one of the \textit{code }directories of the case study | 
| 647 | experiments under \textit{verification.} The model parameters are defined | 
| 648 | and declared in the file \textit{model/inc/PARAMS.h }and their default | 
| 649 | values are set in the routine \textit{model/src/set\_defaults.F. }The | 
| 650 | default values can be modified in the namelist file \textit{data }which | 
| 651 | needs to be located in the directory where you will run the model. The | 
| 652 | parameters are initialized in the routine \textit{model/src/ini\_parms.F}. | 
| 653 | Look at this routine to see in what part of the namelist the parameters are | 
| 654 | located. | 
| 655 |  | 
| 656 | In what follows the parameters are grouped into categories related to the | 
| 657 | computational domain, the equations solved in the model, and the simulation | 
| 658 | controls. | 
| 659 |  | 
| 660 | \subsection{Computational domain, geometry and time-discretization} | 
| 661 |  | 
| 662 | \begin{itemize} | 
| 663 | \item dimensions | 
| 664 | \end{itemize} | 
| 665 |  | 
| 666 | The number of points in the x, y,\textit{\ }and r\textit{\ }directions are | 
| 667 | represented by the variables \textbf{sNx}\textit{, }\textbf{sNy}\textit{, }% | 
| 668 | and \textbf{Nr}\textit{\ }respectively which are declared and set in the | 
| 669 | file \textit{model/inc/SIZE.h. }(Again, this assumes a mono-processor | 
| 670 | calculation. For multiprocessor calculations see section on parallel | 
| 671 | implementation.) | 
| 672 |  | 
| 673 | \begin{itemize} | 
| 674 | \item grid | 
| 675 | \end{itemize} | 
| 676 |  | 
| 677 | Three different grids are available: cartesian, spherical polar, and | 
| 678 | curvilinear (including the cubed sphere). The grid is set through the | 
| 679 | logical variables \textbf{usingCartesianGrid}\textit{, }\textbf{% | 
| 680 | usingSphericalPolarGrid}\textit{, }and \textit{\ }\textbf{% | 
| 681 | usingCurvilinearGrid}\textit{. }In the case of spherical and curvilinear | 
| 682 | grids, the southern boundary is defined through the variable \textbf{phiMin}% | 
| 683 | \textit{\ }which corresponds to the latitude of the southern most cell face | 
| 684 | (in degrees). The resolution along the x and y directions is controlled by | 
| 685 | the 1D arrays \textbf{delx}\textit{\ }and \textbf{dely}\textit{\ }(in meters | 
| 686 | in the case of a cartesian grid, in degrees otherwise). The vertical grid | 
| 687 | spacing is set through the 1D array \textbf{delz }for the ocean (in meters) | 
| 688 | or \textbf{delp}\textit{\ }for the atmosphere (in Pa). The variable \textbf{% | 
| 689 | Ro\_SeaLevel} represents the standard position of Sea-Level in ''R'' | 
| 690 | coordinate. This is typically set to 0m for the ocean (default value) and 10$% | 
| 691 | ^{5}$Pa for the atmosphere. For the atmosphere, also set the logical | 
| 692 | variable \textbf{groundAtK1} to '.\texttt{TRUE}.'. which put the first level | 
| 693 | (k=1) at the lower boundary (ground). | 
| 694 |  | 
| 695 | For the cartesian grid case, the Coriolis parameter $f$ is set through the | 
| 696 | variables \textbf{f0}\textit{\ }and \textbf{beta}\textit{\ }which correspond | 
| 697 | to the reference Coriolis parameter (in s$^{-1}$) and $\frac{\partial f}{% | 
| 698 | \partial y}$(in m$^{-1}$s$^{-1}$) respectively. If \textbf{beta }\textit{\ }% | 
| 699 | is set to a nonzero value, \textbf{f0}\textit{\ }is the value of $f$ at the | 
| 700 | southern edge of the domain. | 
| 701 |  | 
| 702 | \begin{itemize} | 
| 703 | \item topography - full and partial cells | 
| 704 | \end{itemize} | 
| 705 |  | 
| 706 | The domain bathymetry is read from a file that contains a 2D (x,y) map of | 
| 707 | depths (in m) for the ocean or pressures (in Pa) for the atmosphere. The | 
| 708 | file name is represented by the variable \textbf{bathyFile}\textit{. }The | 
| 709 | file is assumed to contain binary numbers giving the depth (pressure) of the | 
| 710 | model at each grid cell, ordered with the x coordinate varying fastest. The | 
| 711 | points are ordered from low coordinate to high coordinate for both axes. The | 
| 712 | model code applies without modification to enclosed, periodic, and double | 
| 713 | periodic domains. Periodicity is assumed by default and is suppressed by | 
| 714 | setting the depths to 0m for the cells at the limits of the computational | 
| 715 | domain (note: not sure this is the case for the atmosphere). The precision | 
| 716 | with which to read the binary data is controlled by the integer variable | 
| 717 | \textbf{readBinaryPrec }which can take the value \texttt{32} (single | 
| 718 | precision) or \texttt{64} (double precision). See the matlab program \textit{% | 
| 719 | gendata.m }in the \textit{input }directories under \textit{verification }to | 
| 720 | see how the bathymetry files are generated for the case study experiments. | 
| 721 |  | 
| 722 | To use the partial cell capability, the variable \textbf{hFacMin}\textit{\ }% | 
| 723 | needs to be set to a value between 0 and 1 (it is set to 1 by default) | 
| 724 | corresponding to the minimum fractional size of the cell. For example if the | 
| 725 | bottom cell is 500m thick and \textbf{hFacMin}\textit{\ }is set to 0.1, the | 
| 726 | actual thickness of the cell (i.e. used in the code) can cover a range of | 
| 727 | discrete values 50m apart from 50m to 500m depending on the value of the | 
| 728 | bottom depth (in \textbf{bathyFile}) at this point. | 
| 729 |  | 
| 730 | Note that the bottom depths (or pressures) need not coincide with the models | 
| 731 | levels as deduced from \textbf{delz}\textit{\ }or\textit{\ }\textbf{delp}% | 
| 732 | \textit{. }The model will interpolate the numbers in \textbf{bathyFile}% | 
| 733 | \textit{\ }so that they match the levels obtained from \textbf{delz}\textit{% | 
| 734 | \ }or\textit{\ }\textbf{delp}\textit{\ }and \textbf{hFacMin}\textit{. } | 
| 735 |  | 
| 736 | (Note: the atmospheric case is a bit more complicated than what is written | 
| 737 | here I think. To come soon...) | 
| 738 |  | 
| 739 | \begin{itemize} | 
| 740 | \item time-discretization | 
| 741 | \end{itemize} | 
| 742 |  | 
| 743 | The time steps are set through the real variables \textbf{deltaTMom }and | 
| 744 | \textbf{deltaTtracer }(in s) which represent the time step for the momentum | 
| 745 | and tracer equations, respectively. For synchronous integrations, simply set | 
| 746 | the two variables to the same value (or you can prescribe one time step only | 
| 747 | through the variable \textbf{deltaT}). The Adams-Bashforth stabilizing | 
| 748 | parameter is set through the variable \textbf{abEps }(dimensionless). The | 
| 749 | stagger baroclinic time stepping can be activated by setting the logical | 
| 750 | variable \textbf{staggerTimeStep }to '.\texttt{TRUE}.'. | 
| 751 |  | 
| 752 | \subsection{Equation of state} | 
| 753 |  | 
| 754 | First, because the model equations are written in terms of perturbations, a | 
| 755 | reference thermodynamic state needs to be specified. This is done through | 
| 756 | the 1D arrays \textbf{tRef}\textit{\ }and \textbf{sRef}. \textbf{tRef }% | 
| 757 | specifies the reference potential temperature profile (in $^{o}$C for | 
| 758 | the ocean and $^{o}$K for the atmosphere) starting from the level | 
| 759 | k=1. Similarly, \textbf{sRef}\textit{\ }specifies the reference salinity | 
| 760 | profile (in ppt) for the ocean or the reference specific humidity profile | 
| 761 | (in g/kg) for the atmosphere. | 
| 762 |  | 
| 763 | The form of the equation of state is controlled by the character variables | 
| 764 | \textbf{buoyancyRelation}\textit{\ }and \textbf{eosType}\textit{. }\textbf{% | 
| 765 | buoyancyRelation}\textit{\ }is set to '\texttt{OCEANIC}' by default and | 
| 766 | needs to be set to '\texttt{ATMOSPHERIC}' for atmosphere simulations. In | 
| 767 | this case, \textbf{eosType}\textit{\ }must be set to '\texttt{IDEALGAS}'. | 
| 768 | For the ocean, two forms of the equation of state are available: linear (set | 
| 769 | \textbf{eosType}\textit{\ }to '\texttt{LINEAR}') and a polynomial | 
| 770 | approximation to the full nonlinear equation ( set \textbf{eosType}\textit{\ | 
| 771 | }to '\texttt{POLYNOMIAL}'). In the linear case, you need to specify the | 
| 772 | thermal and haline expansion coefficients represented by the variables | 
| 773 | \textbf{tAlpha}\textit{\ }(in K$^{-1}$) and \textbf{sBeta}\textit{\ }(in ppt$% | 
| 774 | ^{-1}$). For the nonlinear case, you need to generate a file of polynomial | 
| 775 | coefficients called \textit{POLY3.COEFFS. }To do this, use the program | 
| 776 | \textit{utils/knudsen2/knudsen2.f }under the model tree (a Makefile is | 
| 777 | available in the same directory and you will need to edit the number and the | 
| 778 | values of the vertical levels in \textit{knudsen2.f }so that they match | 
| 779 | those of your configuration). \textit{\ } | 
| 780 |  | 
| 781 | \subsection{Momentum equations} | 
| 782 |  | 
| 783 | In this section, we only focus for now on the parameters that you are likely | 
| 784 | to change, i.e. the ones relative to forcing and dissipation for example. | 
| 785 | The details relevant to the vector-invariant form of the equations and the | 
| 786 | various advection schemes are not covered for the moment. We assume that you | 
| 787 | use the standard form of the momentum equations (i.e. the flux-form) with | 
| 788 | the default advection scheme. Also, there are a few logical variables that | 
| 789 | allow you to turn on/off various terms in the momentum equation. These | 
| 790 | variables are called \textbf{momViscosity, momAdvection, momForcing, | 
| 791 | useCoriolis, momPressureForcing, momStepping}\textit{, }and \textit{\ }% | 
| 792 | \textbf{metricTerms }and are assumed to be set to '.\texttt{TRUE}.' here. | 
| 793 | Look at the file \textit{model/inc/PARAMS.h }for a precise definition of | 
| 794 | these variables. | 
| 795 |  | 
| 796 | \begin{itemize} | 
| 797 | \item initialization | 
| 798 | \end{itemize} | 
| 799 |  | 
| 800 | The velocity components are initialized to 0 unless the simulation is | 
| 801 | starting from a pickup file (see section on simulation control parameters). | 
| 802 |  | 
| 803 | \begin{itemize} | 
| 804 | \item forcing | 
| 805 | \end{itemize} | 
| 806 |  | 
| 807 | This section only applies to the ocean. You need to generate wind-stress | 
| 808 | data into two files \textbf{zonalWindFile}\textit{\ }and \textbf{% | 
| 809 | meridWindFile }corresponding to the zonal and meridional components of the | 
| 810 | wind stress, respectively (if you want the stress to be along the direction | 
| 811 | of only one of the model horizontal axes, you only need to generate one | 
| 812 | file). The format of the files is similar to the bathymetry file. The zonal | 
| 813 | (meridional) stress data are assumed to be in Pa and located at U-points | 
| 814 | (V-points). As for the bathymetry, the precision with which to read the | 
| 815 | binary data is controlled by the variable \textbf{readBinaryPrec}.\textbf{\ } | 
| 816 | See the matlab program \textit{gendata.m }in the \textit{input }directories | 
| 817 | under \textit{verification }to see how simple analytical wind forcing data | 
| 818 | are generated for the case study experiments. | 
| 819 |  | 
| 820 | There is also the possibility of prescribing time-dependent periodic | 
| 821 | forcing. To do this, concatenate the successive time records into a single | 
| 822 | file (for each stress component) ordered in a (x, y, t) fashion and set the | 
| 823 | following variables: \textbf{periodicExternalForcing }to '.\texttt{TRUE}.', | 
| 824 | \textbf{externForcingPeriod }to the period (in s) of which the forcing | 
| 825 | varies (typically 1 month), and \textbf{externForcingCycle }to the repeat | 
| 826 | time (in s) of the forcing (typically 1 year -- note: \textbf{% | 
| 827 | externForcingCycle }must be a multiple of \textbf{externForcingPeriod}). | 
| 828 | With these variables set up, the model will interpolate the forcing linearly | 
| 829 | at each iteration. | 
| 830 |  | 
| 831 | \begin{itemize} | 
| 832 | \item dissipation | 
| 833 | \end{itemize} | 
| 834 |  | 
| 835 | The lateral eddy viscosity coefficient is specified through the variable | 
| 836 | \textbf{viscAh}\textit{\ }(in m$^{2}$s$^{-1}$). The vertical eddy viscosity | 
| 837 | coefficient is specified through the variable \textbf{viscAz }(in m$^{2}$s$% | 
| 838 | ^{-1}$) for the ocean and \textbf{viscAp}\textit{\ }(in Pa$^{2}$s$^{-1}$) | 
| 839 | for the atmosphere. The vertical diffusive fluxes can be computed implicitly | 
| 840 | by setting the logical variable \textbf{implicitViscosity }to '.\texttt{TRUE}% | 
| 841 | .'. In addition, biharmonic mixing can be added as well through the variable | 
| 842 | \textbf{viscA4}\textit{\ }(in m$^{4}$s$^{-1}$). On a spherical polar grid, | 
| 843 | you might also need to set the variable \textbf{cosPower} which is set to 0 | 
| 844 | by default and which represents the power of cosine of latitude to multiply | 
| 845 | viscosity. Slip or no-slip conditions at lateral and bottom boundaries are | 
| 846 | specified through the logical variables \textbf{no\_slip\_sides}\textit{\ }% | 
| 847 | and \textbf{no\_slip\_bottom}. If set to '\texttt{.FALSE.}', free-slip | 
| 848 | boundary conditions are applied. If no-slip boundary conditions are applied | 
| 849 | at the bottom, a bottom drag can be applied as well. Two forms are | 
| 850 | available: linear (set the variable \textbf{bottomDragLinear}\textit{\ }in s$% | 
| 851 | ^{-1}$) and quadratic (set the variable \textbf{bottomDragQuadratic}\textit{% | 
| 852 | \ }in m$^{-1}$). | 
| 853 |  | 
| 854 | The Fourier and Shapiro filters are described elsewhere. | 
| 855 |  | 
| 856 | \begin{itemize} | 
| 857 | \item C-D scheme | 
| 858 | \end{itemize} | 
| 859 |  | 
| 860 | If you run at a sufficiently coarse resolution, you will need the C-D scheme | 
| 861 | for the computation of the Coriolis terms. The variable\textbf{\ tauCD}, | 
| 862 | which represents the C-D scheme coupling timescale (in s) needs to be set. | 
| 863 |  | 
| 864 | \begin{itemize} | 
| 865 | \item calculation of pressure/geopotential | 
| 866 | \end{itemize} | 
| 867 |  | 
| 868 | First, to run a non-hydrostatic ocean simulation, set the logical variable | 
| 869 | \textbf{nonHydrostatic} to '.\texttt{TRUE}.'. The pressure field is then | 
| 870 | inverted through a 3D elliptic equation. (Note: this capability is not | 
| 871 | available for the atmosphere yet.) By default, a hydrostatic simulation is | 
| 872 | assumed and a 2D elliptic equation is used to invert the pressure field. The | 
| 873 | parameters controlling the behaviour of the elliptic solvers are the | 
| 874 | variables \textbf{cg2dMaxIters}\textit{\ }and \textbf{cg2dTargetResidual }% | 
| 875 | for the 2D case and \textbf{cg3dMaxIters}\textit{\ }and \textbf{% | 
| 876 | cg3dTargetResidual }for the 3D case. You probably won't need to alter the | 
| 877 | default values (are we sure of this?). | 
| 878 |  | 
| 879 | For the calculation of the surface pressure (for the ocean) or surface | 
| 880 | geopotential (for the atmosphere) you need to set the logical variables | 
| 881 | \textbf{rigidLid} and \textbf{implicitFreeSurface}\textit{\ }(set one to '.% | 
| 882 | \texttt{TRUE}.' and the other to '.\texttt{FALSE}.' depending on how you | 
| 883 | want to deal with the ocean upper or atmosphere lower boundary). | 
| 884 |  | 
| 885 | \subsection{Tracer equations} | 
| 886 |  | 
| 887 | This section covers the tracer equations i.e. the potential temperature | 
| 888 | equation and the salinity (for the ocean) or specific humidity (for the | 
| 889 | atmosphere) equation. As for the momentum equations, we only describe for | 
| 890 | now the parameters that you are likely to change. The logical variables | 
| 891 | \textbf{tempDiffusion}\textit{, }\textbf{tempAdvection}\textit{, }\textbf{% | 
| 892 | tempForcing}\textit{,} and \textbf{tempStepping} allow you to turn on/off | 
| 893 | terms in the temperature equation (same thing for salinity or specific | 
| 894 | humidity with variables \textbf{saltDiffusion}\textit{, }\textbf{% | 
| 895 | saltAdvection}\textit{\ }etc). These variables are all assumed here to be | 
| 896 | set to '.\texttt{TRUE}.'. Look at file \textit{model/inc/PARAMS.h }for a | 
| 897 | precise definition. | 
| 898 |  | 
| 899 | \begin{itemize} | 
| 900 | \item initialization | 
| 901 | \end{itemize} | 
| 902 |  | 
| 903 | The initial tracer data can be contained in the binary files \textbf{% | 
| 904 | hydrogThetaFile }and \textbf{hydrogSaltFile}. These files should contain 3D | 
| 905 | data ordered in an (x, y, r) fashion with k=1 as the first vertical level. | 
| 906 | If no file names are provided, the tracers are then initialized with the | 
| 907 | values of \textbf{tRef }and \textbf{sRef }mentioned above (in the equation | 
| 908 | of state section). In this case, the initial tracer data are uniform in x | 
| 909 | and y for each depth level. | 
| 910 |  | 
| 911 | \begin{itemize} | 
| 912 | \item forcing | 
| 913 | \end{itemize} | 
| 914 |  | 
| 915 | This part is more relevant for the ocean, the procedure for the atmosphere | 
| 916 | not being completely stabilized at the moment. | 
| 917 |  | 
| 918 | A combination of fluxes data and relaxation terms can be used for driving | 
| 919 | the tracer equations. \ For potential temperature, heat flux data (in W/m$% | 
| 920 | ^{2}$) can be stored in the 2D binary file \textbf{surfQfile}\textit{. }% | 
| 921 | Alternatively or in addition, the forcing can be specified through a | 
| 922 | relaxation term. The SST data to which the model surface temperatures are | 
| 923 | restored to are supposed to be stored in the 2D binary file \textbf{% | 
| 924 | thetaClimFile}\textit{. }The corresponding relaxation time scale coefficient | 
| 925 | is set through the variable \textbf{tauThetaClimRelax}\textit{\ }(in s). The | 
| 926 | same procedure applies for salinity with the variable names \textbf{EmPmRfile% | 
| 927 | }\textit{, }\textbf{saltClimFile}\textit{, }and \textbf{tauSaltClimRelax}% | 
| 928 | \textit{\ }for freshwater flux (in m/s) and surface salinity (in ppt) data | 
| 929 | files and relaxation time scale coefficient (in s), respectively. Also for | 
| 930 | salinity, if the CPP key \textbf{USE\_NATURAL\_BCS} is turned on, natural | 
| 931 | boundary conditions are applied i.e. when computing the surface salinity | 
| 932 | tendency, the freshwater flux is multiplied by the model surface salinity | 
| 933 | instead of a constant salinity value. | 
| 934 |  | 
| 935 | As for the other input files, the precision with which to read the data is | 
| 936 | controlled by the variable \textbf{readBinaryPrec}. Time-dependent, periodic | 
| 937 | forcing can be applied as well following the same procedure used for the | 
| 938 | wind forcing data (see above). | 
| 939 |  | 
| 940 | \begin{itemize} | 
| 941 | \item dissipation | 
| 942 | \end{itemize} | 
| 943 |  | 
| 944 | Lateral eddy diffusivities for temperature and salinity/specific humidity | 
| 945 | are specified through the variables \textbf{diffKhT }and \textbf{diffKhS }% | 
| 946 | (in m$^{2}$/s). Vertical eddy diffusivities are specified through the | 
| 947 | variables \textbf{diffKzT }and \textbf{diffKzS }(in m$^{2}$/s) for the ocean | 
| 948 | and \textbf{diffKpT }and \textbf{diffKpS }(in Pa$^{2}$/s) for the | 
| 949 | atmosphere. The vertical diffusive fluxes can be computed implicitly by | 
| 950 | setting the logical variable \textbf{implicitDiffusion }to '.\texttt{TRUE}% | 
| 951 | .'. In addition, biharmonic diffusivities can be specified as well through | 
| 952 | the coefficients \textbf{diffK4T }and \textbf{diffK4S }(in m$^{4}$/s). Note | 
| 953 | that the cosine power scaling (specified through \textbf{cosPower }- see the | 
| 954 | momentum equations section) is applied to the tracer diffusivities | 
| 955 | (Laplacian and biharmonic) as well. The Gent and McWilliams parameterization | 
| 956 | for oceanic tracers is described in the package section. Finally, note that | 
| 957 | tracers can be also subject to Fourier and Shapiro filtering (see the | 
| 958 | corresponding section on these filters). | 
| 959 |  | 
| 960 | \begin{itemize} | 
| 961 | \item ocean convection | 
| 962 | \end{itemize} | 
| 963 |  | 
| 964 | Two options are available to parameterize ocean convection: one is to use | 
| 965 | the convective adjustment scheme. In this case, you need to set the variable | 
| 966 | \textbf{cadjFreq}, which represents the frequency (in s) with which the | 
| 967 | adjustment algorithm is called, to a non-zero value (if set to a negative | 
| 968 | value by the user, the model will set it to the tracer time step). The other | 
| 969 | option is to parameterize convection with implicit vertical diffusion. To do | 
| 970 | this, set the logical variable \textbf{implicitDiffusion }to '.\texttt{TRUE}% | 
| 971 | .' and the real variable \textbf{ivdc\_kappa }to a value (in m$^{2}$/s) you | 
| 972 | wish the tracer vertical diffusivities to have when mixing tracers | 
| 973 | vertically due to static instabilities. Note that \textbf{cadjFreq }and | 
| 974 | \textbf{ivdc\_kappa }can not both have non-zero value. | 
| 975 |  | 
| 976 | \subsection{Simulation controls} | 
| 977 |  | 
| 978 | The model ''clock'' is defined by the variable \textbf{deltaTClock }(in s) | 
| 979 | which determines the IO frequencies and is used in tagging output. | 
| 980 | Typically, you will set it to the tracer time step for accelerated runs | 
| 981 | (otherwise it is simply set to the default time step \textbf{deltaT}). | 
| 982 | Frequency of checkpointing and dumping of the model state are referenced to | 
| 983 | this clock (see below). | 
| 984 |  | 
| 985 | \begin{itemize} | 
| 986 | \item run duration | 
| 987 | \end{itemize} | 
| 988 |  | 
| 989 | The beginning of a simulation is set by specifying a start time (in s) | 
| 990 | through the real variable \textbf{startTime }or by specifying an initial | 
| 991 | iteration number through the integer variable \textbf{nIter0}. If these | 
| 992 | variables are set to nonzero values, the model will look for a ''pickup'' | 
| 993 | file \textit{pickup.0000nIter0 }to restart the integration\textit{. }The end | 
| 994 | of a simulation is set through the real variable \textbf{endTime }(in s). | 
| 995 | Alternatively, you can specify instead the number of time steps to execute | 
| 996 | through the integer variable \textbf{nTimeSteps}. | 
| 997 |  | 
| 998 | \begin{itemize} | 
| 999 | \item frequency of output | 
| 1000 | \end{itemize} | 
| 1001 |  | 
| 1002 | Real variables defining frequencies (in s) with which output files are | 
| 1003 | written on disk need to be set up. \textbf{dumpFreq }controls the frequency | 
| 1004 | with which the instantaneous state of the model is saved. \textbf{chkPtFreq }% | 
| 1005 | and \textbf{pchkPtFreq }control the output frequency of rolling and | 
| 1006 | permanent checkpoint files, respectively. See section 1.5.1 Output files for the | 
| 1007 | definition of model state and checkpoint files. In addition, time-averaged | 
| 1008 | fields can be written out by setting the variable \textbf{taveFreq} (in s). | 
| 1009 | The precision with which to write the binary data is controlled by the | 
| 1010 | integer variable w\textbf{riteBinaryPrec }(set it to \texttt{32} or \texttt{% | 
| 1011 | 64}). |