Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
User Documentation
Patrick Luyten
1. Charging any price for redistributing the original and/or the modified
versions of COHERENS.
The precise terms and conditions for copying, distributing and modifying
COHERENS are given in Annex.
Contents
I Introductory Manual 1
1 General Overview 3
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Description of the program . . . . . . . . . . . . . . . . . . . . 5
1.3 User experience . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3.1 Programming experience . . . . . . . . . . . . . . . . . 9
1.3.2 Scientific background . . . . . . . . . . . . . . . . . . . 9
1.4 Contents of the documentation . . . . . . . . . . . . . . . . . 10
1.4.1 Structure . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4.2 Suggestions for reading . . . . . . . . . . . . . . . . . . 12
2 Getting Started 15
2.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.1 compilers.cmp . . . . . . . . . . . . . . . . . . . . . . . 17
2.2.2 options.cpp . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2.3 Testing compilation . . . . . . . . . . . . . . . . . . . . 20
2.3 Installing and running a test case . . . . . . . . . . . . . . . . 20
2.4 Installing a user application . . . . . . . . . . . . . . . . . . . 24
2.5 Running an application with external libraries . . . . . . . . . 25
2.5.1 Parallel application . . . . . . . . . . . . . . . . . . . . 25
2.5.2 Using netCDF output format . . . . . . . . . . . . . . 25
2.6 Setting up a user application . . . . . . . . . . . . . . . . . . . 26
3 Graphical display 29
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.2 COHERENS output files . . . . . . . . . . . . . . . . . . . . . 30
3.3 Visualisation of model results . . . . . . . . . . . . . . . . . . 31
3.3.1 FERRET . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.3.2 NCView . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.3.3 MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . 33
i
ii CONTENTS
II Model description 35
4 Physical model 37
4.1 Model coordinates . . . . . . . . . . . . . . . . . . . . . . . . 37
4.1.1 Coordinate systems . . . . . . . . . . . . . . . . . . . . 37
4.1.2 Coordinate transforms in the horizontal . . . . . . . . . 38
4.1.3 Coordinate transforms in the vertical . . . . . . . . . . 40
4.1.3.1 σ-coordinates . . . . . . . . . . . . . . . . . . 40
4.1.3.2 generalised σ-coordinates . . . . . . . . . . . 41
4.1.3.3 normalised vertical coordinate . . . . . . . . . 44
4.2 Basic model equations . . . . . . . . . . . . . . . . . . . . . . 45
4.2.1 3-D mode equations . . . . . . . . . . . . . . . . . . . 45
4.2.1.1 Cartesian coordinates . . . . . . . . . . . . . 45
4.2.1.2 transformed coordinates . . . . . . . . . . . . 48
4.2.2 2-D mode equations . . . . . . . . . . . . . . . . . . . 51
4.2.3 Equation of state . . . . . . . . . . . . . . . . . . . . . 54
4.3 Model equations on reduced grids . . . . . . . . . . . . . . . . 57
4.3.1 Water column (1-D) mode . . . . . . . . . . . . . . . . 57
4.3.2 Depth-averaged (2-D) mode . . . . . . . . . . . . . . . 57
4.4 Turbulence schemes . . . . . . . . . . . . . . . . . . . . . . . . 58
4.4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . 58
4.4.2 Algebraic schemes . . . . . . . . . . . . . . . . . . . . . 62
4.4.2.1 Richardson number dependent formulations . 62
4.4.2.2 flow-dependent formulations . . . . . . . . . . 64
4.4.3 RANS models . . . . . . . . . . . . . . . . . . . . . . . 65
4.4.3.1 general form of the RANS equations . . . . . 66
4.4.3.2 parameterisation of the RANS equations . . 68
4.4.3.3 stability functions . . . . . . . . . . . . . . . 70
4.4.3.4 solution methods . . . . . . . . . . . . . . . . 76
4.4.3.5 mixing length formulations . . . . . . . . . . 79
4.4.3.6 background mixing . . . . . . . . . . . . . . . 80
4.5 Astronomical tidal force . . . . . . . . . . . . . . . . . . . . . 86
4.6 Solar radiation . . . . . . . . . . . . . . . . . . . . . . . . . . 94
4.7 Surface boundary conditions . . . . . . . . . . . . . . . . . . . 96
4.7.1 General form . . . . . . . . . . . . . . . . . . . . . . . 96
4.7.2 Currents . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.7.3 Temperature . . . . . . . . . . . . . . . . . . . . . . . . 97
4.7.4 Salinity . . . . . . . . . . . . . . . . . . . . . . . . . . 98
4.7.5 Turbulence . . . . . . . . . . . . . . . . . . . . . . . . 99
4.7.6 Water column mode . . . . . . . . . . . . . . . . . . . 101
4.8 Surface drag and exchange coefficients . . . . . . . . . . . . . 101
CONTENTS iii
Bibliography 644
9.1 CPU efficiency, defined as the CPU time for a serial run di-
vided by the one obtained for the parallel run, as function of
the number of processes. . . . . . . . . . . . . . . . . . . . . . 362
9.2 Examples of allowed and non-allowed domain decompositions. 364
9.3 Domain decomposition for the North Sea area with 128 pro-
cesses based on a 10×19 domain grid. . . . . . . . . . . . . . . 365
xvii
xviii LIST OF FIGURES
14.1 Example showing how to define the arrays no2dobc and in-
dex2dobc. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
14.2 Example how to define the open boundary specifier arrays. . . 460
14.3 Example definitions of open boundary zones for application of
the relaxation scheme. . . . . . . . . . . . . . . . . . . . . . . 463
19.1 Test case pycno. Time series of the mixed layer depth, the
surface current and the surface density difference ∆ρ(0, t). . . 551
19.2 Test case pycno. Vertical profiles of the current, the den-
sity minus its initial surface value, ρ(z, t) − ρ(0, 0) and the
Richardson number after one day. . . . . . . . . . . . . . . . . 552
19.3 Test case pycno. Vertical profile of the vertical diffusion co-
efficient λT after one day and time series of λT at 10 m depth
during the last hour of the simulation for experiment A. . . . 553
19.4 Test case csnsp. Time series (3-day average) of surface and
bottom temperatures. . . . . . . . . . . . . . . . . . . . . . . . 561
19.5 Test case csnsp.Time series (3-day average) of mixed layer
depth. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562
19.6 Test case csnsp. Temperature profile on August 4. . . . . . . 563
19.7 Test case csnsp. Time series (3-day average) of (upward)
non-solar heat flux and surface exchange coefficient . . . . . . 564
20.1 Initial position of the salinity front and evolution of the current
and salinity fields during the last tidal cycle for experiment
riverA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
20.2 Test case river. Residual salinity and current fields. . . . . . 569
20.3 Test case river. Distributions of current and salinity at the
end of the simulation. . . . . . . . . . . . . . . . . . . . . . . . 570
xx LIST OF FIGURES
20.4 Test case river. Time series of the distance to the left boun-
dary of the point where the front outcrops the surface. . . . . 571
20.5 The computational domain for the test case plume. . . . . . . 574
20.6 Test case plume. Surface distributions of currents and salinity 579
20.7 Test case plume. Residual surface distributions of currents
and salinity for the last tidal cycle . . . . . . . . . . . . . . . . 580
20.8 Test case plume. Residual distributions of currents and sali-
nity for the last tidal cycle along a cross-shore transect . . . . 581
20.9 Test case plume. Time series of the plume width and plume
length. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
20.10Test case plume. Surface and bottom ellipticity distributions. 582
20.11Test case plume. Major axis (m/s) of the tidal ellipse for the
depth-averaged current and amplitude of the surface elevation. 583
20.12Bathymetry of the Rhone plume area. . . . . . . . . . . . . . . 586
20.13Surface distributions for salinity and currents for Rhone plume
experiments A–C. . . . . . . . . . . . . . . . . . . . . . . . . 588
20.14Distribution of currents and salinity along a vertical transect
at 4.850 E through the river mouth for Rhone plume experi-
ments A–C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589
20.15Distribution of currents and salinity along a vertical transect
at 4.450 E for Rhone plume experiments A–C. . . . . . . . . . 590
20.16Surface distributions for salinity and currents for Rhone plume
experiments D–G. . . . . . . . . . . . . . . . . . . . . . . . . 591
20.17Distribution of currents and salinity along different vertical
transects for Rhone plume experiments D–G. . . . . . . . . . 592
20.18Plume area as defined as the area between the coast and the
34 PSU contour line. . . . . . . . . . . . . . . . . . . . . . . . 593
21.1 Bathymetry and initial water level for the two configurations
used in flood2d. . . . . . . . . . . . . . . . . . . . . . . . . . 598
21.2 Time series of currents and surface elevations during the first
tidal cycle and experiment flood2dB. . . . . . . . . . . . . . . 602
21.3 Time series of currents and surface elevations during the first
tidal cycle and experiment flood2dD. . . . . . . . . . . . . . 603
21.4 Time series of the dry area for the four flood2d experiments. . 604
21.5 Time series of the maximum and mean water depth error for
the flood2d experiments A and B. . . . . . . . . . . . . . . . 605
21.6 Bathymetry and water level for the three configurations used
in flood3d. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
21.7 Time series of currents and water depths along a transect for
experiment flood3dA. . . . . . . . . . . . . . . . . . . . . . . 609
LIST OF FIGURES xxi
21.8 Time series of horizontal depth mean currents and water depths
during the first tidal cycle and experiment flood3dA. . . . . . 610
21.9 Time series of currents and water depths along a transect for
experiment flood3dB. . . . . . . . . . . . . . . . . . . . . . . 611
21.10Time series of horizontal depth mean currents and water depths
during the first tidal cycle and experiment flood3dB. . . . . . 612
21.11Time series of currents and water depths along a transect for
experiment flood3dC. . . . . . . . . . . . . . . . . . . . . . . 613
21.12Time series of horizontal depth mean currents and water depths
during the first tidal cycle and experiment flood3dC. . . . . . 614
21.13Time series of horizontal depth mean currents and water depths
during the first tidal cycle and experiment flood3dD. . . . . . 615
21.14Time series of the dry area for the all flood3d experiments. . 616
21.15Time series of the maximum water depth error for all flood3d
experiments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
5.1 Upper bounds for the grid indices (i,j,k) as function of nodal
type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
5.2 Subscript and superscript notation used in the numerical dis-
cretisation formulae. . . . . . . . . . . . . . . . . . . . . . . . 138
5.3 Parameters and variables used in the numerical description.Global
and local FORTRAN names refer to the variables as defined on
respectively the global and local (parallel) grid. . . . . . . . . 141
5.4 Overview of the operators used in the numerical discretisations.152
5.5 Definitions of the fluxes used in the numerical discretisations. . 160
5.6 Discretisation schemes for each of the available surface and
bottom boundary conditions for turbulent variables. . . . . . . 228
xxiii
xxiv LIST OF TABLES
7.1 Key ids for error coding and associated error messages. . . . . 283
7.2 Timer key ids and their meaning. . . . . . . . . . . . . . . . . 285
7.3 Data contents for each type of input forcing file. In the last
column ‘R’, ‘I’, ‘C’, ‘D’ denote respectively real, integer, char-
acter and derived type data. . . . . . . . . . . . . . . . . . . . 301
11.1 Overview of all Usrdef files and usrdef routines in the program.406
11.2 List of usrdef routines which have a related read and write
routine for reading from or writing to a file in standard COHERENS
format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
18.1 Output values for the analytical solution of test case seich. . 532
19.1 Settings of the turbulence switches for the pycno experiments. 548
19.2 Output values for the parameters of test case pycno. . . . . . 550
19.3 Settings of the model switches for the csnsp experiments. . . 557
20.1 Settings of the model switches for the river experiments. . . . 566
E.1 Key ids of the variables which can be used for defining stan-
dard output variables. The variables denoted by a ∗ are W-
node variables for which the node variable attribute can be
reset to ‘W’. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641
Preface
Version 1.0
COHERENS is a three-dimensional multi-purpose numerical model, designed
for application in coastal and shelf seas, estuaries, lakes and reservoirs. The
model is available as a free source code for the scientific community and can
be considered as a tool for a better understanding of the physical and ecologi-
cal processes and for the prediction and monitoring of waste material in shelf
seas, the coastal zone and estuaries. The design, testing and validation of a
three-dimensional model required years of efforts. Its ease of implementation
across a range of computing platforms means that it is attractive to groups
who have a sufficient modelling expertise and have need for sophisticated
model products. Important advantages of the model are its transparency
due to its modular structure and its flexibility because of the possibility to
select different processes, specific schemes and different types of forcing for a
particular application. The program structure allows users to perform pro-
cess as well as predictive and operational setups without knowledge of the
detailed model structure.
The first version of the program, now denoted as COHERENS V1 was
developed over the period 1990-1998 by a multinational group, as part of
several European projects. The physical core part was written and coupled
with biological and resuspension modules during the PROFILE project. The
aim, at that time, was to apply the model for the study of coastal regions
of freshwater influence (ROFIs). A Lagrangian particle tracer and Eulerian
contaminant module were added as part of the model intercomparison exper-
iments conducted in NOMADS. The question arose at that time whether the
model could be released as a public domain community model. This was the
start of the COHERENS project. The objectives were to reshape the model
xxv
into portable code, develop verification tests, perform further validation and
provide an extensive documentation which covers all aspects of the program
so that users can make their setup independently. Partners in the project
were MUMM-RBINS (Brussels, Belgium), Proudman Oceanographic Labo-
ratory (POL, Liverpool, UK), Napier University (NU, Edinburgh, UK) and
the Britisch Oceanographic Data Centre (BODC, Liverpool, UK).
The model code and documentation have been made available for the
scientific community and management authorities in April 2000. Since then,
users can register on the COHERENS Web site
http://www.mumm.ac.be/coherens
The program was, in the first years after the release, distributed through
CD-ROMs, but can now easily be downloaded after electronic registration.
The registration list now counts more than thousand users.
Acknowledgements
Principal authors of COHERENS V1 are Patrick Luyten (MUMM-RBINS),
Eric Jones and Roger Proctor (POL), Paul Tett and Karen Wild-Allen (NU)
and Andy Tabor (BODC). The following persons, who made an important
contribution to the development of COHERENS V1 are acknowledged: : Ju-
dith Wolf (general concept of the program), Kevin Ruddick (circulation and
transport modules), Eric Deleersnijder (numerical methods), Claire Smith
(biology), Sarah Jones (resuspension and sediment module) and Kajo Mir-
bach (Lagrangian tracers). The work was funded by the European Union
under contracts MAST-0050-C (Profile I), MAST-900064, MAS2-CT93-0054
(Profile II) and MAS3-CT97-0088 (Coherens).
Version 2.0
More than 10 years passed since the official release of COHERENS V1. In the
mean time the computing power increased significantly by the introduction
of parallel clusters. Improvements and additions of new schemes (such as a
drying and wetting algorithm) have been suggested. Preparation for a new
version of COHERENS V2.0 started in 2003 during the European FP5 project
ODON (2003-2005) and continued in the FP6 project ECOOP (2007-2009).
The code has been completely rewritten in FORTRAN 90 and can be used
both in sequential and parallel mode using the MPI parallel communication
library. Output can (optionally) be provided in portable netCDF format
from within the program. Both curvilinear and generalised σ-coordinates
xxvi
(also called s-coordinates) are available for creating the model grid. A more
detailed listing of all new features is given in Chapter 1. Several years were
needed for debugging and testing of the code, in particular for all aspects of
the parallellisation.
The program is now ready for release as a free software and is given the
official name of COHERENS V2.0. Modules for biology, sediments and parti-
cle tracers are not yet implemented in the current version. Contrary however
to COHERENS V1 which has not been updated in more than ten years, V2.0
is a more dynamic version then V1. To this date several COHERENS users
provide regular updates in the framework of ongoing national and interna-
tional projects. Current activities include the implementation of a generic
biological model, a more extended sediment transport module which takes
account of different size classes, a particle tracer module, structures for engi-
neering applications in portuaries and water ways, an implicit scheme which
removes the mode splitting scheme, various inundation schemes, . . . .
Acknowledgements
February 2011
xxvii
Version 2.1.2
The following features have been implemented:
1. CIF (Central Input File) utility. An option is foreseen which permits to
define model parameters (switches, time parameters, grid parameters,
model constants, forcing attributes, definitions for user output) through
input from a CIF, instead of making calls to usrdef interface routines
(Sections 7.4, 12.1).
2. A large series of “standard” variables can be selected by the user for
output using their key id value. In that case, the variable’s attributes
and output values are automatically generated by the program (Chap-
ter 16).
3. Additional boundary conditions for the baroclinic current can be se-
lected (Sections 4.10.2.1 and 5.3.16.1).
November 2011
Version 2.2.1
This is technical version, intended for future implementation of structures
(thin dams, current deflection walls, weires, groines).
December 2011
Version 2.3
• The existing drying and wetting algorithm has been extended by the
implementation of additional mask criteria.
• The program can be used to simulate the inundation of land areas by
(e.g.) an incoming tide or storm surge.
• Two new test cases for drying and wetting have been implemented.
Developers are the ANTEA Group in collaboration with RBINS-MUMM.
April 2012
xxviii
xxix
Part I
Introductory Manual
1
Chapter 1
General Overview
1.1 Introduction
During the last 25 years several two- and three-dimensional numerical model
codes have been developed and made available for applications in the global
ocean, shelf and regional seas, the coastal zones and estuaries. Without be-
ing complete we can mention public domain codes such as the global ocean
MOM model (Modular Ocean Model; Pacanowski & Griffies, 2000), the POM
(Princeton Ocean Model; Blumberg & Mellor, 1987) and ROMS (Regional
Ocean Model System) models for regional seas, FVCOM (Chen et al., 2006)
and GETM (Burchard & Bolding, 2002) for application in coastal and es-
tuarine environments. Besides these free software codes there exist several
licensed commercial softwares like TELEMAC, MIKE, Delft3d. The advan-
tage of a public domain code is that the source code is freely available and
can be modified by an experienced user. This is obviously not the case for
commercial codes. On the other hand, developers of free codes have no obli-
gation for providing user support which should, obviously, be the case for
the commercial ones. However, the lack of a substantial support can be com-
pensated by providing a detailed manual and model documentation to the
users.
A special category of the open source codes are the integrated “Com-
munity Models” which couple a core physical component with modules for
biology, sediments, waves, . . . . The construction of such models is a multi-
disciplinary task which requires the collaboration of a variety of specialists
and consumes a substantial number of years of scientific and programming
effort for designing, developing and testing the model code and to validate
the model against observational data.
COHERENS (coupled hydrodynamical-ecological model for regional and
3
4 CHAPTER 1. GENERAL OVERVIEW
The program was written in FORTRAN 77 and has four major compo-
nents:
http://www.mumm.ac.be/coherens
1
The original version number 8.4 has been replaced by V1 to be compatible with the
currently adopted versioning system.
1.2. DESCRIPTION OF THE PROGRAM 5
1. Model code
2. Model grid
3. Numerics
(see Part V). A more specific scientific background is required if for ex-
ample the user intends to perform experiments with different turbulence or
numerical schemes or with alternative settings of model parameters. It is
then recommended to read first the appropriate chapters of Part II (Model
Description).
I. Introductory manual.
Instructions for installing, preparing and running a pre-defined test case
and a user application are given in Chapter 2. The graphical interface
program and visualisation of model output with netCDF are discussed
in Chapter 3.
V. Test cases.
The test cases experiments which are provided with the distribution of
the source code, are presented. The aim is to test the portability of the
code, to illustrate how model setup is performed and to show different
types of applications.The results are briefly discussed and illustrated
with figures and tables which may be used by the user for comparison.
• Chapter 17: purpose of the test cases, CPU time table obtained
on different computing platforms
• Chapter 18: numerical tests for advection schemes
• Chapter 19: turbulence schemes and heat flux formulations
• Chapter 20: density fronts in a channel, river plumes
• Chapter 22: application in a shelf sea
2. Select a few test cases from Part V to test the portability of the model.
Have a look at the source code files used to set up the selected test
cases.
3. Read those sections of Part IV which are of interest for the intended
application.
4. Create the source files for the application using the setup of an anal-
ogous test case. For more information about the model setup or the
name of certain variables for model output consult the reference ma-
nual.
On the other hand, if the user wants to learn about the full model’s
capacities or has the intention to extend the code with a new implementation
it is recommended to read this manual in more detail, especially Part III and
Chapter 5 about the discretisation methods used in the program.
• sans serif style for the FORTRAN names of program variables and spe-
cific keywords
Getting Started
The aims of this chapter are to explain program installation and compilation,
how to run one of the built-in test cases and to summarise the different steps
for setting up a user-defined application. It is assumed that the operating
system is either UNIX or LINUX1 .
This chapter is organised as follows:
• Instructions for installation and a description of the program’s file sys-
tem are given in Section 2.1.
• Compilation is explained in Section 2.2.
• The different steps needed to run a test case are explained in Sec-
tion 2.3. For a detailed description of all test cases the reader is referred
to Part V.
• An example for installing and running a user-defined application is
given in Section 2.4.
• Implementation of external libraries is discussed in Section 2.5.
• A general outline explaining how to set up a realistic application of the
model, is presented in Section 2.6. For a complete description the user
is referred to the User Manual (Part IV).
2.1 Installation
In the following it is assumed that the compressed file with the model code,e.g.
coherensV20.tar is downloaded on the user’s home directory. To retrieve the
1
Installation and compilation of COHERENS under a WINDOWS platform is not ex-
cluded a priori but is beyond the scope of this User Documentation.
15
16 CHAPTER 2. GETTING STARTED
files use:
1. code
2. setups
The file install test is a script, primarily intended for installing a test
case. Its purpose is further explained below.
2.2 Compilation
To compile the COHERENS source code, the following tools are essential:
• FORTRAN 90 compiler.
The first two files are portable and should not be changed unless the main
source code in source has been modified by the user. The last two are user
dependent. They are further discussed below.
2.2.1 compilers.cmp
A new target is defined by inserting the following lines, using the format
below, in compilers.cmp:
target\_name:
\$(MAKE) \$(EXEFILE) "MAINFILE=\$(MAINFILE)" "VPATH=\$(VPATH)" \
"CMPDIR=\$(CMPDIR)" \
"FC=" "FCOPTS=" "FCDEFS=" "FCDEBUG=" \
"FCIFLAGS=" "FLIBS="\
"CPP=" "CPPF=" "CPPOPTS=" "CPPDEFS="
FC
name of the Fortran 90 compiler, eventually preceded by its directory
path, such as f90, /usr/bin/gfortran, mpif90 for parallel runs using
MPICH). This macro has to be defined always.
FCOPTS
Optimisation options for the Fortran compiler.
FCDEFS
Set to $(CPPDFLAGS) if the C-preprocessor is implicitly invoked by
the Fortran compiler, or left undefined otherwise.
FCDEBUG
Debugging options for the FORTRAN compiler, e.g. -g (optional).
FCIFLAGS
Search path for (pre-compiled or source code) module files. This is
only needed for modules linked to external libraries (e.g. -I/usr/include
which is the default used by the netCDF installation procedure).
FLIBS
Options to link the source code to an external library (e.g., -L/usr/lib
-lnetcdf which is the default used by the netCDF installation procedure).
CPP
Name of the C-preprocessor including options (except -D options), such
as gcc -E, if invoked implicitly by the Fortran compiler, undefined other-
wise.
CPPF
Name of the C-preprocessor, if not invoked by the Fortran compiler or
set to @cp otherwise.
CPPOPTS
Options for the C-preprocessor, excluding -D options, in case that the
C-preprocessor is defined by CPPF, undefined otherwise.
CPPDEFS
Undefined if FCDEFS is defined, set to $(CPPDFLAGS) otherwise.
A number of standard targets are already defined such linux-gfort for the
gfortran and linux-iforts, linux-ifortp for compilation with the INTEL compiler
in serial, respectively parallel mode.
2.2. COMPILATION 19
2.2.2 options.cpp
The macro CPPDFLAGS is defined in the file options.cpp. The syntax is
CPPDFLAGS = -Dname1 -Dname2 ...
where name corrsponds to a C-language statement in the source code of the
form
#ifdef name
...
#endif
or
#ifdef name
...
#elseif
...
#endif
If name is defined in CPPDFLAGS, the C-preprocessor retains all statements
between #ifdef and #endif (first form) or between #ifdef and #else (second
form) and removes all statements between #else and #endif (second form).
If name is not defined, all statements are removed between #ifdef and #endif
(first form) or between #ifdef and #else (second form) and all statements are
retained between #else and #endif (second form). Finally, the lines starting
with # are removed. The remaining code is then passed to the FORTRAN
compiler.
The following values of name are implemented:
MPI
Needed for parallel execution of the program. An error is issued by
the compiler if the MPI library is not installed and linked to the main
source code.
CDF
Needed for data input/output in netCDF format. An error occurs if the
netCDF library is not installed and linked to the main source code.
ALLOC
Option for allocation of most local arrays in the model. This will
provide a more efficient memory management, but may have a negative
impact on CPU performance.
In the default version of options.cpp, supplied with the source code, CPPDFLAGS
is left undefined.
20 CHAPTER 2. GETTING STARTED
cd /home/models/work
COHERENS/install test
4. Compile
The Makefile script reads the options.cpp file residing in the working
directory, which, by default, includes no compiler options. Implementation
of the MPI or netCDF library can be tested by inserting the appropriate
compiler options (see Section 2.5 below).
• show how model results are affected by different setups (e.g. numerical
schemes, turbulence closures, different kinds of processes, . . . )
Table 2.1 provides a list of all test cases. Each case is composed of a series of
experiments. The first five represent idealistic cases, the others are examples
of more realistic simulations. Each experiment has a name given by the name
of the test case followed by an upper case letter. For examples, the cones
test consists of four experiments each representing a separate simulation:
conesA, conesB, conesC, conesD. A total of 57 experiments are defined
in this way.
The procedure for installing and running a specific test case is analogous
to the one presented in Section 2.2.3. The complete procedure, including
running the application, is as follows.
22 CHAPTER 2. GETTING STARTED
cd /home/models/work
where path name is the path name of the coherens/V2.1.2 root di-
rectory, e.g. /home/models/coherens/V2.1.2.
where test name is the name of the test case (e.g. cones). This
creates links to subtrees of coherens/V2.1.2, copies the Makefile and
options.cpp files, all the files in the scr subdirectory and the setup files
in setups/test name to the current directory.
4. Compile
./Run
or equivalently,
./coherens
Instead of running all test cases at once, the user can make a selection by
editing the file defruns. This file contains the names of all experiments for
the specific test case on different lines. If a ‘!’ is inserted at the beginning of
a line, the corresponding experiment will be skipped.
To illustrate the use of the CIF utility, the test case runs can be set up
in two modes, depending on different choices for the defruns file. In the first
case, the defruns file located in the test case directory is taken and the setup
is as before. In the second case, instructions for installation are the same as
before except that the following copy has to be made in the working directory
2.3. INSTALLING AND RUNNING A TEST CASE 23
cp cifruns defruns
2. The test is run again. The program reads all model setup parameters
and forcing data from the previously created CIF and standard forcing
files.
The CIF utility is further discussed in Sections 7.4 and 12.1.
The following checks can be made for a succesfull run:
It is clear that even when the program terminates without any noticeable
error, the results can still be incorrect. This can easily be verified. Each
experiment produces a file with suffix .tst (e.g. conesA.tst). The file contains
values of some critical parameters produced by the simulation. These can be
compared to the ones obtained from a reference run and listed in a file with
the same name located in the setups/examples subdirectory.2
2
The parameter sdev defined in some test cases is only used as a measure of rounding
errors and should not be considered as critical.
24 CHAPTER 2. GETTING STARTED
cd /tmp/user/mytest
3. Create a link with the COHERENS root directory where path name is
the path name of the coherens/V2.1.2 root directory, e.g. /home/models/
coherens/V2.1.2.
./Run
or equivalently,
./coherens
2.5. RUNNING AN APPLICATION WITH EXTERNAL LIBRARIES 25
4. The parameter nprocs, defined in the routine usrdef mod params (file
Usrdef Model.f90) must be set to the number of processes used in the
parallel application.
5. Edit the Run script according to the guidelines for running a MPI ap-
plication on the user machine, e.g.
mpirun - np 4 ./coherens
1. Make sure that the netCDF library (Version 3.6 or later) is properly
installed.
4. In subroutine usrdef tsr params within the file Usrdef Time Series.f90,
change the values of the parameters(s) ending with %form to ‘N’. When
the run is completed, all time series output will be available in netCDF
format.
26 CHAPTER 2. GETTING STARTED
Remarks
1. It is clear that the user only needs to define what is needed for the
application.
3. Options are provided to write all parameters and forcing data to files
in a standard COHERENS format. These files can be used for model
setup in subsequent runs.
1. The simplest way is to copy the setup (Usrdef files) of a suitable test
case and make the necessary adaptations. The method is recommended
for applications which do not require a too complicated setup.
Graphical display
The aim of this chapter is to describe model output from COHERENS and
to illustrate how model output can be visualised.
3.1 Introduction
The ability to view the results from COHERENS, and to subsequently ma-
nipulate the output data, is an important requirement of the model sys-
tem. Since there exist many free and commercial software packages for dis-
playing model results, the objective is to provide access to the model data
in an internationally recognised format, allowing ease of transfer from one
platform to another, and access to a wide range of software for data dis-
play/manipulation.
The data format selected for standardisation of COHERENS model data
is netCDF (network Common Data Form). This is widely accepted in the
meteorological/oceanographic community as a standard data format, both
for observational data and model data, and many software packages support
a netCDF interface. NetCDF is freely available.
The netCDF software was developed at the Unidata Program Center in
Boulder, Colorado, USA. NetCDF (network Common Data Form) is an in-
terface for array-oriented data access and a freely-distributed collection of
software libraries for C, FORTRAN, C++, and perl that provide implemen-
tations of the interface. The netCDF software was developed at the Unidata
Program Center in Boulder, Colorado (Pincus & Rew, 2008) and augmented
by contributions from other netCDF users. The netCDF libraries define a
machine-independent format for representing scientific data. Together, the
interface, libraries, and format support the creation, access, and sharing of
scientific data.
29
30 CHAPTER 3. GRAPHICAL DISPLAY
NetCDFdata are:
http://www.unidata.ucar.edu/software/netcdf/
‘A’ ASCII
‘U’ unformatted binary data
‘N’ netCDF data.
‘I’ information file with metadata information in ASCII format
Whilst commercial packages are widely used in the marine science com-
munity, it is apparent that no single package is preferred to the others. It
therefore makes more sense to recommend the use of software which is freely
available and which can easily be obtained. It might be argued that commer-
cial software is a better option in so much as it is (usually) well documented,
well maintained and with regular upgrades, and covers a wide range of gene-
ral use.
3.3.1 FERRET
FERRET has produced and made available by PMEL (Pacific Marine En-
vironmental Laboratory) in the United States. The package has been con-
structed over many years to visualise 4-D (three space and time) meteoro-
logical and oceanographic data, is freely available over the internet, has good
documentation, a user group and help facilities. It primarily expects datasets
to be input in netCDF form but also allows data to be input in ASCII or bi-
nary form. FERRET is a recommended package for the display of COHERENS
data. One advantage for COHERENS users (apart from being simple to use)
is that the package is primarily oriented towards “real world” datasets and
installs with global coastlines. As it is envisaged that most COHERENS users
will develop real world applications, a visualisation package which supports
this makes model development much easier. However it is a simple matter
within FERRET to display data in Cartesian coordinates.
FERRET is found to be the best of the available freeware packages, it
fulfils many of the requirements of the COHERENS user: time series (single
point, space/time), contours (line and fill), vectors, surfaces (wire frame),
overlays and movie generation, both in “real world” (longitude/latitude) as
in Cartesian coordinates. FERRET can be implemented by the user for visu-
alisation or writing of data into netCDF format.
http://ferret.wrc.noaa.gov/Ferret/
3.3.2 NCView
Another visual browser for netCDF data format files is NCView. NCView
displays a 2-dimensional, color representation of data in a netCDF file and
this in a quick and easy way. This GUI-based tool makes it possible to
show simple movies of the data, to view along various dimensions, to take
a look at raw data values, to change color maps, to invert the data, . . . .
3.3. VISUALISATION OF MODEL RESULTS 33
Although easier to use than FERRET, the number of available plot types is
more limited.
The home page of the author, David W. Pierce contains useful information
and links on how to visualise COHERENS output format with NCView. It is
located at
3.3.3 MATLAB
As mentioned in this section MATLAB version 7.7 and later contains the
ability to read data from and write data to netCDF files (known as datasets
in netCDF terminology). For earlier versions a MATLAB/netCDFinterface is
necessary (i.e. NetCDF Toolbox, MexEPS, CSIRO, fanmat, etc). A MAT-
LAB script can be used to enable generate numerical data, figures and tables
from netCDF data, through more than 30 functions.
This and other info on the visualisation of model results with MATLAB
can be found at
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/netcdf.html
34 CHAPTER 3. GRAPHICAL DISPLAY
Part II
Model description
35
Chapter 4
Physical model
37
38 CHAPTER 4. PHYSICAL MODEL
Implementation
Coordinate systems are selected in the model with the switch iopt grid sph:
0 : Cartesian
1 : spherical
∆d2 = ∆x2 + ∆y 2
!2 !2 !2 !2
∂F1 ∂F2 ∆ξ 2 +
∂F1 ∂F2 ∆ξ 2
= + 1 + 2
∂ξ1 ∂ξ1 ∂ξ2 ∂ξ2
!
∂F1 ∂F1 ∂F2 ∂F2
+ 2 + ∆ξ1 ∆ξ2 (4.5)
∂ξ1 ∂ξ2 ∂ξ1 ∂ξ2
If
∂F1 ∂F1 ∂F2 ∂F2
+ =0 (4.6)
∂ξ1 ∂ξ2 ∂ξ1 ∂ξ2
then
∆d2 = h21 ∆ξ12 + h22 ∆ξ22 (4.7)
and (ξ1 , ξ2 ) are then called orthogonal curvilinear coordinates. This means
geometrically that the coordinate curve along which ξ1 is a constant, inter-
sects the curve along which ξ2 is constant orthogonally.
Note that spherical coordinates can be considered as “pseudo”-curvilinear
coordinates with respect to Cartesian coordinates with h1 = R cos φ and
h2 = R where R is the mean radius of the Earth, defined as the radius of a
sphere having the same volume as the Earth or 6371 km (see Appendix 2 of
Gill, 1982)
4.1. MODEL COORDINATES 39
In practice ∆ξ1 , ∆ξ2 are both normalised to 1, so that the metric coeffi-
cients h1 , h2 now become the grid spacings along the curvilinear coordinate
lines.
Once the curvilinear coordinates are defined, a computational grid can
be constructed in the horizontal by drawing a sequency of coordinate lines.
Some example grids are shown in Figure 4.1.
(a) Uniform Cartesian grid (b) Cartesian non−uniform rectangular grid
Implementation
The type of horizontal grid is selected with the switch iopt grid htype:
z+h z+h
σ= = (4.8)
H h+ζ
where σ varies between 0 at the bottom and 1 at the surface1 . The reverse
formula is obviously
z = σH − h (4.9)
so that the grid spacing in the vertical becomes
∆z = H∆σ (4.10)
Advantages are:
where F and G are increasing functions and σ̂ equals 0 at the bottom and
1 at the surface. Davies & Jones (1991) defined the following logarithmic
transformations " #
1 σ̂ σ̂
σ= ln(1 + ) + (4.12)
α σ0 σ∗
" #
1 1 − σ̂ 1 − σ̂
σ =1− ln(1 + )+ (4.13)
α σ0 σ∗
where
1 1
α = ln(1 + )+ (4.14)
σ0 σ∗
The first (second) form provides a more refined resolution at the bottom (sur-
face). The extent of the logarithmic grid is set by the tunable parameter σ∗ .
Burchard & Bolding (2002) considered a formulation with refined resolu-
tions near both the bottom and surface
tanh [(dl + du )σ − dl ] + tanh dl
σ̂ = (4.15)
tanh dl + tanh du
Increasing the values of the (positive) parameters dl or du will provide a
higher resolution in respectively the bottom or surface layer at the expense
of a coarser resolution in the remaining parts of the water column.
A vertical grid is then constructed by firstly taking a series of uniformly
spaced σ-levels, i.e. σk = (k − 1)/N, k = 1, N + 1 where N is the number of
vertical layers. In the case of a non-uniform grid, the corresponding values
of σ̂k are obtained from the transformation formula. Examples are given in
Figure 4.2a-b. The first one shows that the vertical grid positions are more
densily packed and the grid spacings are smaller in the bottom (surface)
layer for a logarithmic transformation concentrated at the bottom (surface).
The Burchard & Bolding (2002) formulation (with dl = du ) has enhanced
resolutions both near the surface as near the bottom but a coarser resolution
in the middle of the water column.
(a) (b)
Figure 4.2: Transformed coordinate σ̂ = F (σ) (a) and vertical grid spacing
normalised to the total water depth ∆σ̂ = ∂F/∂σ/N (b): formulation (4.12)
with σ∗ = 0.25, s0 = 0.1 (solid), (4.13) with the same parameter values
(dots), (4.15) with dl = du = 1.5 (dashes).
a) b)
compares the distribution of vertical levels for a uniform σ-spacing with the
s-coordinate levels obtained from (4.24), using b = 1, hc = 200 and θ = 8,
for a transect across the Norwegian trench in the North Sea. While the σ-
coordinate provides an accurate resolution in the shallow waters near the
Danish coast (left side of the figure), the layer thickness is ∼30 m in the
44 CHAPTER 4. PHYSICAL MODEL
s = G∗ (σ, x, y, t) (4.26)
where
h (σ̂ − σ̂
k k−1 ) − (σk − σk−1 )hc /h
i
α = min ,1 (4.28)
(σ̂k − σ̂k−1 ) − (σk − σk−1 )
and σ̂ is obtained from (4.15) with hc a critical water depth below which
s = σ.
H∆σ = h3 ∆s (4.29)
Implementation
The type of vertical grid is selected with the switch iopt grid vtype
1 : uniform σ-grid
4.2. BASIC MODEL EQUATIONS 45
∂u ∂u ∂u ∂u
+u +v +w − fv
∂t ∂x ∂y ∂z
1 ∂p ∂ ∂u ∂ ∂
=− + Fxt + νT + τxx + τxy (4.33)
ρ0 ∂x ∂z ∂z ∂x ∂y
∂v ∂v ∂v ∂v
+u +v +w + fu
∂t ∂x ∂y ∂z
1 ∂p ∂ ∂v ∂ ∂
=− + Fyt + νT + τyx + τyy (4.34)
ρ0 ∂y ∂z ∂z ∂x ∂y
46 CHAPTER 4. PHYSICAL MODEL
∂p
= −ρg (4.35)
∂z
∂T ∂T ∂T ∂T
+u +v +w
∂t ∂x ∂y ∂z
1 ∂I ∂ ∂T ∂ ∂T ∂ ∂T
= + λT + λH + λH (4.36)
ρ0 cp ∂z ∂z ∂z ∂x ∂x ∂y ∂y
∂S ∂S ∂S ∂S
+u +v +w
∂t ∂x ∂y ∂z
∂ ∂S ∂ ∂S ∂ ∂S
= λT + λH + λH (4.37)
∂z ∂z ∂x ∂x ∂y ∂y
where (u,v) are the horizontal components of the current, w the vertical cur-
rent, f the Coriolis frequency given by 2Ω sin φ where Ω = π/43082 radians/s
is the Earth’s rotation frequency, p the pressure, ρ the density, ρ0 a uniform
reference density, g the acceleration of gravity, (Fxt ,Fyt ) the components of
the astronomical tidal force, νT and λT the vertical turbulent diffusion co-
efficients, τij the horizontal friction tensor, T potential temperature, I the
solar irradiance within the water column, cp the specific heat capacity of sea
water at constant pressure, and S salinity.
Note that T is not the in situ temperature but potential temperature,
defined as the temperature of a fluid parcel, moved adiabatically to a certain
level (usually taken at or near the surface). The reason is that (4.36) is
derived from the conservation equation of heat. This equation contains an
extra term due to compresssibility, which vanishes if T is interpreted as
potential temperature (Gill, 1982).
Since the model does not allow for the formation of sea ice at the surface,
the temperature must stay above the freezing point of seawater, i.e.
T > αf S , αf = −0.0575 0 C/PSU (4.38)
The horizontal diffusion tensor is introduced to represent horizontal sub-
grid scale processes not resolved by the model and is parameterised as follows
τxx = −τyy = νH DT , τxy = τyx = νH DS (4.39)
∂u ∂v ∂u ∂v
DT = − DS = + (4.40)
∂x ∂y ∂y ∂x
where DT and DS are called the horizontal tension and shearing strain and νH
denotes the horizontal diffusion coefficient which is either given as a constant
or taken as proportional to the local rate of strain
q
νH = Cm ∆x∆y DT2 + DS2 (4.41)
4.2. BASIC MODEL EQUATIONS 47
The first two terms on the right of (4.45) represent the barotropic, the third
one the baroclinic component.
where R represents the absorption of the red end of the solar spectrum
in the upper (1–2) meters of the water column, 1 − R the absorption of
blue-green light over larger depths and Qrad the solar radiance incident
on the surface. Since turbidity effects are not explicitly taken into
account by the physical model, values of R, λ1 , λ2 ≫ λ1 depend on the
optical properties of the water masses and can be selected following
e.g. the optical classification scheme of Jerlov (1968). Solar radiance
is further discussed in Section 4.6.
• The astronomical force is only relevant in deep ocean waters and can
be neglected on the shelf and in the coastal zone. Expressions for its
components are given as a sum of tidal harmonics (see Section 4.5).
1 ∂
Dmh1 (F ) = 2
(h22 h3 F ) (4.56)
h1 h2 h3 ∂ξ1
1 ∂
Dmh2 (F ) = 2 (h2 h3 F ) (4.57)
h1 h2 h3 ∂ξ2 1
!
1 ∂ νT ∂F
Dmv (F ) = (4.58)
h3 ∂s h3 ∂s
The parameterised form of the horizontal shear stress tensor in orthogonal
curvilinear coordinates is given by Pacanowski & Griffies (2000); Griffies
(2004)
τ11 = −τ22 = νH DT , τ12 = τ21 = νH DS (4.59)
50 CHAPTER 4. PHYSICAL MODEL
h2 ∂ u h1 ∂ v
DT = −
h1 ∂ξ1 h2 h2 ∂ξ2 h1
h1 ∂ u h2 ∂ v
DS = + (4.60)
h2 ∂ξ2 h1 h1 ∂ξ1 h2
The quantity ω in (4.49) and (4.55) is the transformed vertical current
normal to the s-coordinate surfaces. Physical and transformed vertical cur-
rent are related by
!
∂s u ∂s v ∂s
w = ω − h3 + + (4.61)
∂t h1 ∂ξ1 h2 ∂ξ2
An alternative form, more useful for numerical discretisation, is
1 ∂
w= (h3 z) + Ah1 (z) + Ah2 (z) + Av (z) (4.62)
h3 ∂t
The horizontal vector Fit represents the components of the astronomical tidal
force, discussed in Section 4.5. The expression for the baroclinic pressure
gradient now contains two terms as a consequence of the vertical coordinate
transformation
" !#
1 ∂ ∂ ∂z
Fib =− (h3 q) − q (4.63)
hi h3 ∂ξi ∂s ∂ξi
where Z 1
q=− bh3 ds (4.64)
s
The equations for potential temperature and salinity can, in the absence of
a particle sinking term, be cast in a more general form, representing the
transport of an arbitrary concentration ψ (T , S, sediment, contaminant,
biological state variable)
1 ∂
(h3 ψ) + Ah1 (ψ) + Ah2 (ψ) + Av (ψ)
h3 ∂t
= P(ψ) − S(ψ) + Dsv (ψ) + Dsh1 (ψ) + Dsh2 (ψ) (4.65)
where P(ψ), S(ψ) represent all source, respectively sinks terms. Two-dimensional
diffusion of scalars is taken along constant s-surfaces. This gives
1 ∂ h2 h3 ∂ψ
Dsh1 (ψ) = λH (4.66)
h1 h2 h3 ∂ξ1 h1 ∂ξ1
1 ∂ h1 h3 ∂ψ
Dsh2 (ψ) = λH (4.67)
h1 h2 h3 ∂ξ2 h2 ∂ξ2
ψ
1 ∂ λT ∂F
Dsv (ψ) = (4.68)
h3 ∂s h3 ∂s
4.2. BASIC MODEL EQUATIONS 51
1 ∂
(h3 T ) + Ah1 (T ) + Ah2 (T ) + Av (T )
h3 ∂t
1 ∂I
= + Dsv (T ) + Dsh1 (T ) + Dsh2 (T ) (4.71)
ρ0 cp h3 ∂s
1 ∂
(h3 S)+Ah1 (S)+Ah2 (S)+Av (S) = Dsv (S)+Dsh1 (S)+Dsh2 (S) (4.72)
h3 ∂t
The 2-D mode equations consists of three equations for the surface elevation
and the depth-integrated currents, defined by
Z1
(U, V ) = (u, v)h3 ds (4.73)
0
The same vertical diffusion coefficient is taken for temperature and salinity, i.e. λTT =
2
λST = λT .
52 CHAPTER 4. PHYSICAL MODEL
The equations are then obtained by integrating (4.49)–(4.51) over the verti-
cal. This gives
" #
∂ζ 1 ∂ ∂
+ (h2 U ) + (h1 V ) = 0 (4.74)
∂t h1 h2 ∂ξ1 ∂ξ2
!
∂U V ∂h1 ∂h2
+ Ah1 (U ) + Ah2 (U ) + U− V − 2ΩV sin φ
∂t Hh1 h2 ∂ξ2 ∂ξ1
gH ∂ζ H ∂Pa
= − − + F1b + HF1t + τs1 − τb1
h1 ∂ξ1 ρ0 h1 ∂ξ1
+ Dmh1 (τ11 ) + Dmh2 (τ12 ) − δAh1 + δDh1 (4.75)
!
∂V U ∂h2 ∂h1
+ Ah1 (V ) + Ah2 (V ) + V − U + 2ΩU sin φ
∂t Hh1 h2 ∂ξ1 ∂ξ2
gH ∂ζ H ∂Pa
= − − + F2b + HF2t + τs2 − τb2
h2 ∂ξ2 ρ0 h2 ∂ξ2
+ Dmh1 (τ21 ) + Dmh2 (τ22 ) − δAh2 + δDh2 (4.76)
Z1
νH = νH h3 ds (4.84)
0
h2 ∂ U h1 ∂ V
DT = −
h1 ∂ξ1 Hh2 h2 ∂ξ2 Hh1
h1 ∂ U h2 ∂ V
DS = + (4.85)
h2 ∂ξ2 Hh1 h1 ∂ξ1 Hh2
The last two terms on the right of (4.75)–(4.76) only contain the baroclinic
part of the 3-D current
U V
(δu, δv) = u − , v − (4.86)
H H
The explicit forms are
1"
1 Z ∂ ∂
δAh1 = h2 h3 δu2 + (h1 h3 δuδv)
h1 h2 ∂ξ1 ∂ξ2
0
#
∂h1 ∂h2 2
+ h3 δuδv − h3 δv ds (4.87)
∂ξ2 ∂ξ1
1"
1 Z ∂ ∂
δAh2 = (h2 h3 δuδv) + h1 h3 δv 2
h1 h2 ∂ξ1 ∂ξ2
0
#
∂h2 ∂h1 2
+ h3 δuδv − h3 δu ds (4.88)
∂ξ1 ∂ξ2
1 1
1 1 ∂ 2Z 1 ∂ 2Z
δDh1 = h2 νH δDT h3 ds + h1 νH δDS h3 ds
h1 h2 h2 ∂ξ1 h1 ∂ξ2
0 0
(4.89)
1 1
1 1 ∂ 2Z 1 ∂ 2Z
δDh2 = h2 νH δDS h3 ds −
h1 νH δDT h3 ds
h1 h2 h2 ∂ξ1 h1 ∂ξ2
0 0
(4.90)
where δDT and δDS are given by (4.60) with (u,v) replaced by (δu,δv).
The 3-D and 2-D continuity equations involve either the 3-D and 2-D
current. An alternative form, involving the baroclinic and depth-integrated
currents, can be derived by multiplying (4.49) by h3 and substracting (4.74)
54 CHAPTER 4. PHYSICAL MODEL
Implementation
The solution method of the previous set of equations is controlled by the
following model switches
iopt mode 2D Switch to enable (1) or disable (0) the solution of the 2-D
mode equations. It is advised not to switch off the 2-D mode unless for
1-D water column applications (see Section 4.3.1 below) or for carefully
designed applications.
iopt mode 3D Switch to enable (1) or disable (0) the solution of the 3-D
hydrodynamic equations (4.49)–(4.51). It is recommended not to disable
the 3-D mode unless for purely 2-D (depth-averaged) applications (in
which case the switch is automatically disabled by the program).
iopt temp Type of update for the temperature field.
0 : Temperature is uniform in space and time.
1 : Temperature is uniform in time, but non-uniform in space.
2 : Temperature is non-uniform in space and time and obtained by
solving equation (4.71).
iopt sal Type of update for the salinity field.
0 : Salinity is uniform in space and time.
1 : Salinity is uniform in time, but non-uniform in space.
2 : Salinity is non-uniform in space and time and obtained by solving
equation (4.72).
gradient and the turbulent diffusion coefficients νT , λT (see Section 4.4 be-
low), is known. Contrary to temperature and salinity, the density is not
obtained by an additional transport equation but by means of an equation
of state (EOS).
The International EOS (Millero et al., 1980), adopted in the previous ver-
sion of COHERENS relates the density to the three state variables T , S and
p where T is the in situ temperature. A more appropriate formulation still
based on the International EOS, but with in situ temperature replaced by
potential temperature was considered by Jacket & McDougall (1995). More
recently, McDougall et al. (2003) proposed an EOS using potential tempera-
ture, which according to the authors is more accurate than the International
EOS and computationally more efficient. The latter formulation has there-
fore been implemented in COHERENS V2.0.
With a precision of 0.003 kg/m3 the density is given by
P1 = a0 + a1 T + a2 T 2 + a3 T 3 + a4 S + a5 ST + a6 S 2
+ a7 p + a8 pT 2 + a9 pS + a10 p2 + a11 p2 T 2
P2 = 1 + b1 T + b2 T 2 + b3 T 3 + b4 T 4 + b5 S + b6 ST + b7 ST 3
+ b8 S 3/2 + b9 S 3/2 T 2 + b10 p + b11 p2 T 3 + b12 p3 T (4.93)
ρ = ρ0 (1 + βS (S − Sr ) − βT (T − Tr )) (4.97)
where Tr and Sr are constant reference values, and (ρ0 ,βT ,βS ) are obtained
from (4.92)–(4.93) with T = Tr , S = Sr , p = 0.
56 CHAPTER 4. PHYSICAL MODEL
Table 4.1: Values of the empirical parameters in the McDougall et al. (2003)
equation of state.
a0 999.843699 b1 7.28606739×10−3
a1 7.3521284 b2 -4.60835542×10−5
a2 -5.45928211×10−2 b3 3.68390573×10−7
a3 3.98476704×10−4 b4 1.80809186×10−10
a4 2.96938239 b5 2.14691708×10−3
a5 -7.23268813×10−3 b6 -9.27062484×10−6
a6 2.12382341×10−3 b7 -1.78343643×10−10
a7 1.04004591×10−2 b8 4.76534122×10−6
a8 1.03970529×10−7 b9 1.63410736×10−9
a9 5.1876188×10−6 b10 5.30848875×10−6
a10 -3.24041825×10−8 b11 -3.03175128×10−16
a11 -1.2386936×10−11 b12 -1.27934137×10−17
Implementation
The following switches, used for the evaluation of density and density gradi-
ents, are available:
iopt dens grad Selects the numerical algorithm for discretisation of the baro-
clinic pressure gradient (see Section 5.3.12 for details).
In the absence of an horizontal grid, the model equations can be written using
Cartesian coordinates in the horizontal and σ-coordinates in the vertical. The
momentum equations (4.50), (4.51) then reduce to
1 ∂ ∂ζ 1 ∂ νT ∂u
(h3 u) − 2f v = −g + F1t + (4.98)
h3 ∂t ∂x h3 ∂s h3 ∂s
1 ∂ ∂ζ 1 ∂ νT ∂v
(h3 v) + 2f u = −g + F2t + (4.99)
h3 ∂t ∂y h3 ∂s h3 ∂s
where
• the surface slope and the surface elevation ζ, needed to calculate the
total water depth H and the vertical grid spacing h3 are specified as
external “surface” forcing conditions
where Fsψ and Fbψ are the fluxes at respectively the surface and the bottom.
The vertically integrated horizontal diffusion coefficients take the form
q q
2 2 2 2
νH = Cm h1 h2 H D T + D S , λH = C s h 1 h 2 H D T + D S (4.103)
∂Ui
=0 (4.105)
∂xi
∂T ∂T X ∂ 2T
+ Ui = S(T ) + kT 2
(4.106)
∂t ∂xi i ∂xi
where the fluctuating parts have zero means. The averages can be considered
as ensemble averages over a large number of turbulent states or as a statistical
mean over the full turbulence spectrum. Since the fluctuations of density can
3
In the absence of double-diffusive mixing, which is not implemented in the current
model code, the procedure is similar if temperature is replaced by salinity.
4
The dynamic pressure is defined as the pressure minus its homogeneous hydrostatic
part, i.e. P = p + ρ0 g(z − ζ) − Pa .
60 CHAPTER 4. PHYSICAL MODEL
be taken as small with respect to their mean value, β and θ can be related
by the linearised equation of state
β = gβT θ (4.108)
The mean flow equations are obtained by substituting (4.107) into (4.104-
4.106) and taking the average. This gives
∂Ui ∂Ui 1 ∂P X ∂ 2 Ui ∂
+ Uj + ǫijk fj Uk = − + δi3 b + ν 2
− ui uj (4.109)
∂t ∂xj ρ0 ∂xi j ∂xj ∂xj
∂Ui
=0 (4.110)
∂xi
∂T ∂T X ∂ 2T ∂
+ Ui = P(T ) + kT 2
− ui θ (4.111)
∂t ∂xi i ∂xi ∂xi
since P(T ) = P(T ) in view of (4.71). Equations (4.109)–(4.111) are the
same as (4.104)–(4.106) except for the last terms in the momentum and
temperature equations which represent the exchange of momentum and heat
between the mean and turbulent flows. The two terms appear as a divergence
of fluxes of momentum ui uj and temperature ui θ.
It remains to find suitable parameterisations for these turbulent fluxes.
The oldest approach — dating back from the time of Boussinesq in 1877 —
and also the most commonly used, is to model the momentum fluxes like the
viscous stresses in laminar flows
!
∂Ui ∂Uj 2
− ui u j = ν T + − kδij (4.112)
∂xj ∂xi 3
where
1
k = (u2 + v 2 + w2 ) (4.113)
2
is the kinetic energy of turbulent motions and νT is called the eddy viscosity
(diffusion) coefficient. In analogy with (4.112) the temperature fluxes are
usually parameterised using the down-gradient diffusion hypothesis
∂T
− ui θ = λ T (4.114)
∂xi
Despite the similarity with laminar flows, there are fundamental differences
between turbulent and laminar diffusion
• For fully developed turbulence, νT and λT are larger than their laminar
counterparts by several orders of magnitude.
4.4. TURBULENCE SCHEMES 61
∂ 2 ∂ ∂ ∂ ∂ ∂U
− u − uv − uw ≃ − uw ≃ νT
∂x ∂y ∂z ∂z ∂z ∂z
∂ ∂ 2 ∂ ∂ ∂ ∂V
− uv − v − vw ≃ − vw ≃ νT (4.115)
∂x ∂y ∂z ∂z ∂z ∂z
∂ ∂ ∂ ∂ ∂ ∂T
− uθ − vθ − wθ ≃ − wθ ≃ λT
∂x ∂y ∂z ∂z ∂z ∂z
since
∂U ∂V
− uw ≃ νT , −vw ≃ νT (4.116)
∂z ∂z
by application of the shallow water approximation to (4.112). A similar
expression applies for the diffusion of salinity. It is clear that (u,v,T ,S) in
(4.32)–(4.34), (4.36)–(4.37) are now interpreted as statistical averages.
The turbulence, as stated in the beginning of this subsection, is now
reduced to the implementation of suitable expressions for the turbulent dif-
fusion coefficients. A large number of schemes, applied for hydraulic en-
gineering and in the geophysical context, are available from the scientific
literature. For detailed overviews, the reader is referred to the text books
of Kantha & Clayson (2000a); Pope (2001) and the reviews by Rodi (1984);
Burchard (2002).
The turbulence models, implemented in COHERENS, fall in three cate-
gories of increasing complexity
where νc and λc are set be the user. Despite its simplicity, it is rec-
ommended not to use this form. Turbulence usuallly occurs in the
surface and bottom boundary layers, which requires spatially varying
coefficients.
Implementation
The general type of turbulence scheme is selected with the switch iopt vdif coef:
N2
Ri = (4.118)
M2
where
1 ∂b g ∂T ∂S
N2 = = βT − βS (4.119)
h3 ∂s h3 ∂s ∂s
1 h ∂u 2 ∂v 2 i
M2 = 2 + (4.120)
h3 ∂s ∂s
are the squared buoyancy and shear frequencies. The first one measures the
degree of stratification which is stable if N 2 > 0 (Ri > 0) and unstable if
N 2 < 0 (Ri < 0). The formulations below are based on theoretical and ob-
servational evidence that turbulence decreases in the first case and increases
in the second one.
4.4. TURBULENCE SCHEMES 63
The upper bounds for νT and λT are then given by 0.03, respectively 0.052.
The scheme has been primarily developed for application in global ocean
models (e.g. Semtner & Chervin, 1988). It has the advantage of being less
sensitive to vertical resolution than the more advanced turbulence closures
discussed in Section 4.4.3. In the absence of stratification the coefficients take
uniform values which makes the scheme less reliable for the study of neutral
tidal and wind-driven flows. Test simulations in the Rhine plume (Ruddick
et al., 1995) showed that the results are sensitive to a calibration of the model
constants. Peters et al. (1988) derived a similar formulation using different
values of the parameters calibrated from microstructure measurements in the
Pacific Ocean.
The second scheme use the historical empirical relations proposed by
Munk & Anderson (1948):
with
where
1 1
D = 1 + δ1 (r1 − 1) + δ2 (r2 − 1) (4.133)
2 2
is a normalisation factor such that the depth-integral of Φ(σ) equals 1. The
parameters δ1 , δ2 are the fractional depths of the bottom and surface layers,
and r1 , r2 the ratios of the bottom and surface values of Φ with respect to
the interior value. Default values for the parameters are
δ 1 = δ 2 = 0 , r1 = r2 = 1 (4.134)
νw = λ⋆ u∗s (4.135)
The last terms on the right of (4.130)–(4.131) are the uniform background
eddy viscosity νb and diffusivity λb .
The following three formulations for the flow factor α can be selected
α = K1 (U 2 + V 2 )1/2 (4.137)
α = K2 (U 2 + V 2 )/(H 2 ω1 ) (4.138)
α = K1 (U 2 + V 2 )1/2 ∆b /H (4.139)
Implementation
An algebraic scheme is taken if iopt vdif coef=2. The type of scheme is further
selected by the switch iopt turb alg:
1 : Pacanowski-Philander
2 : Munk-Anderson
3 : Flow dependent scheme with α given by (4.137)
4 : Flow dependent scheme with α given by (4.138)
5 : Flow dependent scheme with α given by (4.139)
∂ui ∂ ∂π ∂ X ∂ 2 ui
+ (Ui uj + ui Uj + ui uj ) + ǫijk fj uk = − + βδi3 + ui u j + ν 2
∂t ∂xj ∂xi ∂xj j ∂xj
(4.143)
∂ui
=0 (4.144)
∂xi
∂β ∂ X ∂ 2β ∂ui β
+ (Ui β + gβT T ui + ui β) = kT 2
+ (4.145)
∂t ∂xi i ∂xi ∂xi
where the overbar has been omitted for convenience above mean quantities
and the temperature equation is converted to an equation for the perturbed
buoyancy β by multiplication with the factor gβT .
Adding the i-component of (4.143) multiplied by uj and the j-component
multiplied by ui and taking the average, the following system of equations
is obtained for the Reynolds stresses ui uj , making use of the zero divergence
condition (4.144)
d ∂
ui u j + ui uj uk + fk (ǫikl ul uj + ǫjkl ul ui ) =
dt ∂xk
∂ ∂ ∂Uj ∂Ui
− uj π − u i π − ui u k − u j uk
∂xi ∂xj ∂xk ∂xk
∂2
!
∂ui ∂uj ∂ui ∂uj
+ δi3 uj β + δj3 ui β + π + +ν u u − 2ν
2 i j
∂xj ∂xi ∂xk ∂xk ∂xk
(4.146)
4.4. TURBULENCE SCHEMES 67
where use is made of the zero divergence condition (4.144) and the total
derivative is defined by
d ∂ ∂
= + Uk (4.147)
dt ∂t ∂xk
The transport equation for the buoyancy fluxes ui β is derived by multiplying
(4.143) by β, (4.145) by ui adding and making the average
d ∂
ui β + ui uj β + ǫijk fj uk β =
dt ∂xj
∂ ∂b ∂Ui ∂β
− βπ − ui uj − uj β + δi3 β 2 + π
∂xi ∂xj ∂xj ∂xi
∂ ∂ui ∂ ∂β ∂ui ∂β
+ν β + kT ui − (ν + kT ) (4.148)
∂xj ∂xj ∂xj ∂xj ∂xj ∂xj
where summation is taken over all indices. The terms on the right have the
following meaning:
• All Coriolis terms are set to zero. The main reason is that rotation
introduces a large level of complexity. The simplification can be con-
sidered as reasonable when the Coriolis period is much larger than the
decay time of turbulence or f ε/k ≪ 1. For an account of Coriolis
effects see Galperin et al. (1989); Kantha et al. (1989).
• Pressure-strain correlation
!
∂ui ∂uj ε 2 2
π + = −c1 (ui uj − δij k) − c21 (Pij − δij P )
∂xj ∂xi k 3 3
!
∂Ui ∂Uj 2
−c22 k + − c23 (Dij − δij P )
∂xj ∂xi 3
2
−c3 (Gij − δij G) (4.151)
3
The first term represents the Rotta (1951) hypothesis of return to
isotropy. The tensors in the remaining terms are defined by
∂Uj ∂Ui
Pij = −ui uk − u j uk (4.152)
∂xk ∂xk
∂Uk ∂Uk
Dij = −ui uk − uj u k (4.153)
∂xj ∂xi
Gij = δi3 uj β + δj3 ui β (4.154)
1 ∂Ui
P = Pii = −ui uk (4.155)
2 ∂xk
1
G = Gii = δi3 ui β = wβ (4.156)
2
∂β ε ∂Ui ∂Uk
π = −c1β ui β + c21β uk β − c22β uk β − c3β δi3 β 2 (4.157)
∂xi k ∂xk ∂xi
4.4. TURBULENCE SCHEMES 69
• Dissipation terms
∂ui ∂uj 2
2ν = δij ε (4.158)
∂xk ∂xk 3
!2
∂β ε β2
2kT = χ= (4.159)
∂xi k Rβ
∂ ∂ui ∂ ∂β ∂ui ∂β
ν β = kT ui = (ν + kT ) = 0 (4.160)
∂xj ∂xj ∂xj ∂xj ∂xj ∂xj
Since the laminar diffusion scales are much smaller than the scales of
the largest eddies, the laminar terms can be neglected
∂2 ∂ 2β 2
ν u i uj = 0 , kT =0 (4.161)
∂x2k ∂x2i
Equation(4.158) states that turbulence energy is dissipated isotropi-
cally. Equation(4.159) assumes that the dissipation time scale of tur-
bulence kinetic enery k/ε is proportional to the one for the buoyancy
variance β 2 /χ. The ratio is given by the parameter Rβ .
• Pressure transport is neglected
∂ ∂
uj π = 0 , βπ = 0 (4.162)
∂xi ∂xi
The expressions for the pressure-strain and pressure-buoyancy gradient are
compiled from different sources and presented in their most general form.
The parameterisations contain 10 parameters c1 , c21 , c22 , c23 , c3 , c1β , c21β ,
c22β , c3β , Rβ . The values used in COHERENS are taken from different sources:
Mellor & Yamada (1982); Kantha & Clayson (1994); Burchard & Baumert
(1995); Hossain & Rodi (1982) and two schemes taken from Canuto et al.
(2001). The six models are further denoted by MY82, KC94, BB95, HR82,
CA01 and CB01. Values of the parameters are listed in Table 4.2. For
readers, familiar with the Ai , Bi , Ci parameters used in MY82 and KC94,
the following conversion rules apply
B1
c1 = , c21 = 0 , c22 = −2C1 , c23 = 0 , c3 = 0
6A1
B1 B2
c1β = , c21β = C2 , c22β = 0 , c3β = C3 , Rβ = (4.163)
6A2 B1
Different schemes are available for the modelisation of the third-order
correlations, total derivative (i.e. time derivative and advective terms) in
(4.146)–(4.150). They are based on the classification scheme introduced by
Mellor & Yamada (1974, 1982) and Galperin et al. (1988).
70 CHAPTER 4. PHYSICAL MODEL
Table 4.2: Values of the turbulence constants in the RANS equations accor-
ding to the different models implemented in COHERENS.
c1 c21 c22 c23 c3 c1β c21β c22β c3β Rβ
MY82 3.01 0 -0.16 0 0 3.74 0 0 0 0.61
KC94 3.01 0 -0.16 0 0 3.74 0.7 0 0.2 0.61
BB95 1.8 0.6 0 0 0.6 3.0 0.33 0 0.333 0.8
HR82 2.2 0.55 0 0 0.55 3.0 0.5 0 0.5 0.8
CA01 2.49 0.777 0.256 0.207 0.402 5.95 0.8 0.2 0.333 0.72
CA02 2.1 0.803 0.257 0.183 0.576 5.6 0.8 0.2 0.333 0.477
Non-equilibrium method
The following system of linear equations is obtained where a vertical deriva-
tive is denoted by a subscript z and bz = N 2 by its definition (4.119)
2h k i
u2 = k− (2 − 2c21 + c23 )uwUz − (1 − c21 − c23 )vwVz + (1 − c3 )wβ
3 εc1
2 h k i
v2 = k+ (1 − c21 − c23 )uwUz − (2 − 2c21 + c23 )vwVz − (1 − c3 )wβ
3 εc1
2h k i
w2 = k+ (1 − c21 + 2c23 )(uwUz + vwVz ) + 2(1 − c3 )wβ
3 εc1
k
uv = − (1 − c21 )(uwVz + vwUz )
εc1
k h i
uw = − (1 − c21 )w2 Uz + c22 kUz − c23 (u2 Uz + uvVz ) − (1 − c3 )uβ
εc1
k h i
vw = − (1 − c21 )w2 Vz + c22 kVz − c23 (v 2 Vz + uvUz ) − (1 − c3 )vβ
εc1
k h i
uβ = − uwN 2 + (1 − c21β )wβUz
εc1β
k h i
vβ = − vwN 2 + (1 − c21β )wβVz
εc1β
k h 2 2 i
wβ = − w N + c22β (uβUz + vβVz ) − (1 − c3β )β 2
εc1β
k
β2 = −2 Rβ N 2 wβ
ε
(4.166)
The solutions for the vertical fluxes of momentum and buoyancy can be
written as
k 2 ∂U k 2 ∂V k2
− uw = Su , −vw = Su , −wβ = Sb N 2 (4.167)
ε ∂z ε ∂z ε
Comparing with (4.116) and (4.114) the eddy viscosity and diffusivity are
given by
k2 k2
ν T = Su , λ T = Sb (4.168)
ε ε
Note that these expressions are obtained from the RANS theory and not
postulated a priori.
The coefficients Su and Sb are the so-called stability functions and can be
expressed as function of the stability parameters
k2 2 k2 2
αM = M , αN = N (4.169)
ε2 ε2
72 CHAPTER 4. PHYSICAL MODEL
The two parameters are the squares of the ratio of respectively the shear and
buoyancy frequency with respect to the turbulence frequency and represent
the influence of shear and density gradients on the turbulent fluxes. The
solutions for Su and Sb can be written as
Explicit expressions for the coefficients Cai as function of the RANS parame-
ters are given in Appendix B.
When applying the boundary layer approximation, the diffusion term
(4.165) in the k-equation can be written as
∂ k ∂k ∂ k 2 ∂k ∂ ∂k
csk uj uk ≃ csk w = νk (4.171)
∂xj ε ∂xk ∂z ε ∂z ∂z ∂z
k2 w2 k2
νk = csk = Sk (4.172)
ε k ε
The stability coefficient for turbulent energy diffusion is given by
w2 2 h 1 i
Sk = csk = csk 1 − (1 − c21 + 2c23 )αM Su + 2(1 − c3 )αN Sb (4.173)
k 3 c1
Quasi-equilibrium method
The equations for the second order correlations are the same as in (4.166)
except for the components of turbulent energy
2 1 − c21 − c23 2k h 1 i
u2 = k 1− − (1 − c21 )uwUz + (c21 + c23 − c3 )wβ
3 c1 εc1 3
2 1 − c21 − c23 2k h 1 i
v2 = k 1− − (1 − c21 )vwVz + (c21 + c23 − c3 )wβ
3 c1 εc1 3
2 1 − c21 + 2c23 2k
w2 = k 1− + (3 − c21 + 223 − 2c3 )wβ
3 c1 3εc1
(4.174)
The solutions for the vertical fluxes can be written in the form (4.167)–
(4.169), obtained with the non-equilibrium method. Difference is that the
stability functions now only depend on αN . Two cases can be distinguished
4.4. TURBULENCE SCHEMES 73
1. Case c22β = 0.
Cb1 + Cb2 αN
Su =
(1 + Cb3 αN )(1 + Cb4 αN )
Cb5
Sb = (4.175)
1 + Cb3 αN
2. Case c22β 6= 0.
Cc1 + Cc2 αN Sb
Su = (4.176)
1 + Cc3 αN
Sb is obtained as solution of the quadratic equation
giving
w2 2csk
Sk = csk = c1 − 1 + c21 − 2c23 − (3 − c21 + 2c23 − 2c3 )αN Sb (4.179)
k 3c1
Equilibrium method
In this case equilibrium between production and dissipation of turbulent
energy is assumed in all second moment equation and in the equation of
turbulent energy. This means that
since
P +G uwUz + vwVz wβ k2 k2
=− + = Su 2 M 2 − Sb 2 N 2 = Su α M − Sb α N
ε ε ε ε ε
(4.181)
Using (4.180) and the expressions for Su and Sb , the following relation be-
tween the stability parameters can be derived
2 2
1 + Cd1 αM + Cd2 αN + Cd3 αM + Cd4 αM αN + Cd5 αN =0 (4.182)
74 CHAPTER 4. PHYSICAL MODEL
which can be rewritten as a quadratic equation for the squared inverse time
scale κ2 = ε2 /k 2
Alternative methods
Besides the expressions given above, the COHERENS program allows to use
simpler formulations for the stability coefficients. In the first one the quasi-
equilibrium expressions (4.175)–(4.178) are reset to their constant neutral
values obtained in the absence of stratification (αN = 0)
Values of Su0 and Sb0 are given in Table 4.36 . In the second form, Su and
Sb are set to their neutral values, multiplied by the Munk-Anderson damp-
ing/amplification factors, defined by (4.127) and (4.128) or
The latter scheme resembles the one adopted in the earlier standard version
of the k − ε model (Rodi, 1984).
6
Node that Su0 is the same as the parameter cµ used in the standard k − ε theory
(Rodi, 1984).
4.4. TURBULENCE SCHEMES 75
It is remarked that these schemes are physically less robust, but have
been implemented in the code for historical reasons or to perform sensitivity
experiments related to specific details of the turbulence schemes.
Besides the general expressions (4.173) or (4.179) for the diffusion of tur-
bulent energy, the following simpler alternative options for the stability co-
efficient Sk are implemented
Sk = Sk0 (4.188)
and
Sk = Su /σk (4.189)
where Sk0 and σk are model constants. The first form was introduced in k − l
model of Mellor & Yamada (1982), the second in the “standard” k − ε model
(Rodi, 1984), further discussed below. In the former case Sk0 is related to
the Mellor-Yamada parameter Sq by
Sk0 = 21/2 ǫ0 Sq (4.190)
3/4
with ǫ0 = Su0 (see equation (4.191) below).
k − ε models
The schemes are divided into three categories depending on the number of
transport equations which need to be solved.
with ε given by (4.191) and the advection and diffusion operators de-
fined by (4.53)–(4.55), (4.66)–(4.67). The last two terms represent hori-
zontal diffusion of k. It is noted that advection and horizontal diffusion
are usually neglected. This is achieved in the model by the settings of
two switches (see below).
1 ∂ 1 ∂ νk ∂ε
(h3 ε) + Ah1 (ε) + Ah2 (ε) + Av (ε) =
h3 ∂t h3 ∂s h3 σε ∂s
2
ε ε
+ c1ε νT M 2 − c3ε λT N 2 − c2ε + Dsh1 (ε) + Dsh2 (ε)
k k
(4.193)
κ2 Sk0
c1ε − c2ε = − (4.194)
ǫ20 σε
k − l models
In k − l theory all equations are written explicitly as function of k and l.
This is achieved by substituting l for ε through the relation (4.191). The
expressions for the eddy viscosity and diffusion coefficients then take the
form
νT = Sm k 1/2 l , λT = Sh k 1/2 l , νk = S̃k k 1/2 l (4.195)
where the stability functions (Sm , Sh , S˜k ) = (Su , Sb , Sk )/ǫ0 are function of
the stability parameters (Gm , Gh ) = (M 2 , N 2 ) l2 /k = ǫ20 (αM , αN ). Equations
(4.170), (4.175), (4.176)–(4.178) and (4.182) remain valid with (αM , αN ) re-
placed by (Gm , Gh ), (Su , Sb ) by (Sm , Sh ), κ by κ̃ and (Cai , Cbi , Cci , Cdi ) re-
placed by (C̃ai , C̃bi , C̃ci , C̃di ) using
1
(C̃a1 , C̃a4 ) = ǫ0 (Ca1 , Ca4 ) , (C̃a2 , C̃a3 , C̃a5 , C̃a6 ) = (Ca2 , Ca3 , Ca5 , Ca6 )
ǫ0
1 1
(C̃a7 , C̃a8 ) = (Ca7 , Ca8 ) , (C̃a9 , C̃a10 , C̃a11 ) = (Ca9 , Ca10 , Ca11 )
ǫ20 ǫ40
Cb2 1
(C̃b1 , C̃b5 ) = ǫ0 (Cb1 , Cb5 ) , C̃b2 = , (C̃b3 , C̃b4 ) = (Cb3 , Cb4 )
ǫ0 ǫ20
(C̃c1 , C̃c8 ) = ǫ0 (Cc1 , Cc8 ) , C̃c6 = Cc6
1 1 1
(C̃c2 , C̃c3 , C̃c7 ) = (Cc2 , Cc3 , Cc7 ) , C̃c4 = Cc4 , C̃c5 = Cc5
ǫ20 ǫ30 ǫ50
4.4. TURBULENCE SCHEMES 79
1 1
(C̃d1 , C̃d2 ) = (Cd1 , Cd2 ) , (C̃d3 , C̃d4 , C̃d5 ) = (Cd3 , Cd4 , Cd5 ) (4.196)
ǫ20 ǫ40
In case of a two-equation model, the ǫ-equation is replaced by an equation
for the quantity kl obtained from the Mellor-Yamada q 2 l-equation by setting
q 2 = 2k:
1 ∂ 1 ∂ νk ∂
(h3 kl) + Ah1 (kl) + Ah2 (kl) + Av (kl) = (kl)
h3 ∂t h3 ∂s h3 σkl ∂s
1 1
+ l E1 νT M 2 − E3 λT N 2 − ǫ0 k 3/2 W̃ + Dsh1 (kl) + Dsh2 (kl)
2 2
(4.197)
where z0s and z0b are roughness lengths at the surface, respectively the bot-
tom (see below). In analogy with the ε-equation the parameters in (4.197)–
(4.198) satisfy the constraint
2κ2 Sk0
E2 − E1 + 1 = (4.199)
ǫ20 σkl
where z0s and z0b are the surface and bottom roughness lengths.
The first and simplest expression is the parabolic law
1 1 1
= + (4.201)
l l1 l2
having a maximum at σ ≃ 0.5.
The second is the “quasi-parabolic” law given by
1 1 l1 + l2 1/2
= (4.202)
l l1 l2
80 CHAPTER 4. PHYSICAL MODEL
which differs from the first one in that l has a maximum at σ ≃ 2/3 closer
to the surface.
The third, recommended by Xing & Davies (1996) has the same form as
(4.201) but with l1 replaced by
allowing for a larger reduction of the mixing length in the lower parts of the
water column.
The fourth formulation, initially proposed by Blackadar (1962), has the
form
1 1 1 1
= + + (4.204)
l l1 l2 la
so that l → la far from the boundaries. Mellor & Yamada (1974) defined la
as the ratio of the first to the zeroth moment of the vertical profile of the
turbulent velocity scale k 1/2 . Hence
Z 1 Z 1
1/2
la = α 1 (1 − σ)k H dσ / k 1/2 H dσ (4.205)
0 0
where νbT and λbT are background mixing coefficients added to the eddy
coefficients calculated by the model. The first terms on the right hand side
represent mixing due to unresolved internal shear, the second one mixing due
to internal wave braking. The parameters have the following default values
The reason for adopting this lower limits is to prevent that unrealistically
large eddy coefficients are created by rounding errors within the intermittent
zone. With the above values and taking Su ∼ Sb ∼ 0.1 the values of νT
and λT are of the order of ∼ 10−17 which are clearly much smaller than the
corresponding laminar viscosity and diffusivity coefficients.
Implementation
A RANS model is selected if iopt vdif coef=3. A series of additional switches
are implemented to determine the specifications of the model.
iopt turb param Selects mixing length or dissipation rate as model variable.
4.4. TURBULENCE SCHEMES 83
1 : k − l scheme
2 : k − ε scheme
iopt turb ntrans Selects number of transport equations.
0 : zero-equation model (equilibrium method and prescribed mixing length)
1 : one-equation model (k-equation and prescribed mixing length)
2 : two-equation model (k-equation and either ε or kl-equation)
iopt turb stab form Selects general form for the stability functions
1 : constant value
2 : Munk-Anderson formulation
3 : as obtained from RANS model
iopt turb stab mod Selects type of RANS scheme
1 : MY82-model (Mellor & Yamada, 1982)
2 : KC94-model (Kantha & Clayson, 1994)
3 : BB95-model (Burchard & Baumert, 1995)
4 : HR82-model (Hossain & Rodi, 1982)
5 : CA01-model (Canuto et al., 2001)
6 : CA02-model (Canuto et al., 2001)
iopt turb stab lev Selects the form of stability functions if iopt turb stab form=3.
1 : quasi-equilibrium (level 2.5) method
2 : non-equilibrium (level 3) method
iopt turb stab tke Selects the formulation for the diffusion coefficient in the
k-equation.
1 : constant stability coefficient (4.188)
2 : stability coefficient proportional to the one for momentum as given by
(4.189)
3 : using the Daly & Harlow (1970) formulation (4.173) or (4.179)
iopt turb lmix Selects the formulation for the mixing length.
1 : parabolic law
2 : quasi-parabolic law
3 : after Xing & Davies (1996)
84 CHAPTER 4. PHYSICAL MODEL
Table 4.4 gives an overview of all parameters used in the different schemes
and their default values.
Table 4.4: Parameters used in different turbulence schemes (except those listed in
Tables 4.2 and 4.3) and their default values.
limiting conditions
klim 10−6 J/kg background limit for k (see equation (4.214))
kmin 10−14 J/kg numerical lower limit for k
lmin 1.7×10−10 m numerical lower limit for l
εmin 10−12 W/kg numerical lower limit for ε
background mixing
Ri0 0.7 – critical Richardson number in the Large et al. (1994) back-
ground mixing scheme (4.215)
λT 0 5×10−5 m2 /s internal wave breaking diffusion coefficient for scalars in the
Large et al. (1994) background mixing scheme (4.215)
νT 0 10−4 m2 /s internal wave breaking diffusion coefficient for momentum in
the Large et al. (1994) background mixing scheme (4.215)
s 2
ν0 0.005 m /s maximum mixing due to unresolved vertical shear in the Large
et al. (1994) background mixing scheme (4.215)
boundary conditions
cw 0.0 – surface wave factor used in the surface flux condition (4.271)
for turbulent energy
z0b 0.0 m bottom roughness length in the mixing length formulation
(4.200)
z0s 0.0 m surface roughness length in the mixing length formulation
(4.200)
mixing length formulations
α1 0.2 – constant in the Blackadar (1962) mixing length formulation
(4.205)
β1 2.0 – attenuation factor in the Xing & Davies (1996) mixing length
formulation (4.203)
algebraic schemes
np 2.0 – Pacanowski & Philander (1981) scheme (4.121)–(4.123)
αp 5.0 – Pacanowski & Philander (1981) scheme (4.121)–(4.123)
−5 2
λbp 10 m /s Pacanowski & Philander (1981) scheme (4.121)–(4.123)
νbp 10−4 m2 /s Pacanowski & Philander (1981) scheme (4.121)–(4.123)
νmax 3.0 – Pacanowski & Philander (1981) scheme (4.121)–(4.123)
ν0p 0.01 m2 /s Pacanowski & Philander (1981) scheme (4.121)–(4.123)
n1 0.5 – Munk & Anderson (1948) scheme (4.125)–(4.128)
n2 1.5 – Munk & Anderson (1948) scheme (4.125)–(4.128)
αm 10.0 – Munk & Anderson (1948) scheme (4.125)–(4.128)
βm 3.33 – Munk & Anderson (1948) scheme (4.125)–(4.128)
λmax 4.0 – Munk & Anderson (1948) scheme (4.125)–(4.128)
(Continued)
86 CHAPTER 4. PHYSICAL MODEL
N0
Φtid 3
= ζe = ( cos2 φ − 1)
X
A0n (t) cos V0n (t) + u0n (t)
g 2 n=1
N1
X
+ sin 2φ A1n (t) cos λ + V1n (t) + u1n (t)
n=1
N2
+ cos2 φ
X
A2n (t) cos 2λ + V2n (t) + u2n (t)
n=1
N3
+ cos3 φ
X
A3n (t) cos 3λ + V3n (t) + u3n (t)
n=1
3 Nq
X X
= Gq (φ) Aqn (t) cos qλ + Vqn (t) + uqn (t) (4.218)
q=0 n=1
where ζe is the so-called equilibrium tide, i.e. the change of sea level due
to the tidal attraction only, i.e. in absence of all other forces (pressure,
Coriolis, ...), N0 , N1 , N2 , N3 are the number of respectively long-period,
diurnal, semi-diurnal and terdiurnal tides and q is the species index. Higher
order harmonics can shown to be negligible and are therefore not included
in the expansion. Once the tidal potential is known, the components of the
4.5. ASTRONOMICAL TIDAL FORCE 87
The first factor aqn is the astronomical tidal amplitude due to the lunar and
solar attractive forces. The Earth can be considered as an elastic body and is
deformed by the tidal force as well. The effect of the Earth tide is to reduce
the astronomical tide and is represented by the second factor αqn . Values
are taken from Foreman et al. (1993). The third term is the so-called nodal
factor and arises from modulations of the the lunar orbit. The term is always
close to 1 and varies with a period of 18.6 years.
The tidal phases are the sum of the geographical factor qλ, the astro-
nomical argument Vqn and the nodal correction factor uqn (further discussed
below). The astronomical phase is evaluated at the longitude of Greenwich
(λ = 0). Its time dependence is given by the astronomical ephemerides7
Since the six astronomical parameters are almost linear time, one can write
Vqn (t) ≃ Vqn (t0 ) + (t − t0 )ωqn (4.222)
where t0 is the time of the previous mid-night at Greenwich8 and ωqn the
frequency of the tidal constituent. The mean lunar time τ is related to the
mean solar time (H) by
τ =H −s+h (4.223)
From (4.221) one obtains therefore
Vqn (t0 ) = (j − i)s0 + (k + i)h0 + lp0 + mN0 + nps0 (4.224)
ωqn = iτ̇0 + j ṡ0 + k ḣ0 + lṗ0 + mṄ0 + nṗs0 (4.225)
where a ˙ (dot) represents a time derivative and the subscript 0 evaluation
at midnight (GMT). The astronomical ephemerides are calculated in time
using the reference values at the first of January 0h (GMT) of the year 1900.
Explicit expressions (in degrees), taken from Kantha & Clayson (2000b), are
s0 = 270.434358 + 481267.88314137T − 0.001133T 2 + 1.9.10−6 T 3
h0 = 279.69668 + 36000.768925485T + 3.03.10−4 T 2
p0 = 334.329653 + 4069.0340329575T − 0.10325T 2 − 1.2.10−5 T 3
N0 = −259.16 + 1934.14T − 0.0021T 2
ps0 = 281.22083 + 1.71902T + 0.00045T 2 + 3.0.10−6 T 3 (4.226)
The number of Julian centuries T is given as function of the current year y
and the day number within the current year d (between 1 and 366) and the
current year y:
T = (27393.500528 + 1.0000000356D)/36525
D = d + 365(y − 1975) + INT(y − 1973)/4 (4.227)
if the current year is 1975 or later, or
T = (0.5 + D)/36525
D = d + 365(y − 1900) + INT(y − 1901)/4 (4.228)
for years before 1975. The rate of change of the astronomical ephemerides
are obtained from the above equations (e.g. Schureman, 1941)
τ̇0 = 14.4920520 /h , ṡ0 = 0.5490170 /h , ḣ0 = 0.0410680 /h
ṗ0 = 0.0046420 /h , Ṅ0 = −0.0022060 /h , ṗs0 = 0.0000020 /h
(4.229)
8
The time t must be referenced with respect to Greenwich mean time (GMT). An
automatic conversion is made by the program if needed.
4.5. ASTRONOMICAL TIDAL FORCE 89
Defining X X
ρ1 = 1 + εk cos ∆θk , ρ2 = εk sin ∆θk (4.232)
k k
and making a first order Taylor expansion with respect to εk . Values of ank
are taken from the tables given by Cartwright & Tayler (1971); Cartwright
& Edden (1973).
When the tidal forcing is included in the momentum equations, the tidal
solutions for currents and elevations contain additional higher frequencies
components. These so-called “overtides” are produced by non-linearities in
the model equations and do not appear in the expansion of the tidal potential.
For applications in shelf seas, where the astronomical force becomes negligible
90 CHAPTER 4. PHYSICAL MODEL
Table 4.5: Doodson numbers, frequencies (degrees/h), amplitudes (cm) and Green-
wich arguments (degrees) of the tidal constituents which can be used for astronom-
ical and open boundary forcing.
Implementation
The following switches are available
iopt astro tide Disables (0) or enables (1) the inclusion of the tidal force in
the momentum equations.
iopt astro pars Selects the type of astronomical forcing (tidal force and at
open boundaries)
0: The astronomical argument is set to zero, the nodal factors are set
to 1.
1: The astronomical arguments are calculated from (4.224) at Green-
wich or at a user-defined reference longitude, the nodal factors are
4.5. ASTRONOMICAL TIDAL FORCE 93
set to 1.
2: The astronomical arguments are determined from (4.224) at Green-
wich or at a user-defined reference longitude, the nodal factors are
calculated as function of the astronomical ephemerides
Table 4.6: Doodson numbers, origin, frequencies (degrees/h) and Greenwich argu-
ments (degrees) of the overtides which can be used for the open boundary forcing.
where Q0 = 1367.0 W/m2 is the solar constant, γ⊙ the altitude of the sun
and H the Heaviside function (H(x) = 0 for x < 0 and = x otherwise). The
factor pcor represents a correction term due to the elliptical orbit of the earth
and is usually expressed as a function of the day number of the year J:
J ′ = 0.9856J (4.236)
The altitude of the sun is calculated from
where δ⊙ is the declination of the sun, H⊙ the sun’s hour angle and φ the
latitude. The angle δ⊙ , measured in degrees, is obtained from the series
expansion
3
(an cos nJ ′ + bn sin nJ ′ )
X
δ⊙ = δ0 + (4.238)
n=1
with
δ0 = 0.33281
(a1 , a2 , a3 ) = (−22.984, −0.34990, −0.13980)
(b1 , b2 , b3 ) = (3.7872, 0.03205, 0.07187) (4.239)
H⊙ = th − 12 + T E + λh (4.240)
where th is the hour of the day, λh the longitude (expressed in hours) and
T E the equation of time which can be written as
3
(cn cos nJ ′ + dn sin nJ ′ )
X
TE = (4.241)
n=1
4.6. SOLAR RADIATION 95
with
They considered the value of 0.09 for the water vapor and ozone absorption
coefficient Aα . The total radiation flux at the ocean surface under clear sky
conditions is then given by
1
Qcs = Qdir + Qdif = Qs (e−τ + 1 − Aα ) (4.249)
2
The clear sky value (4.249) must be corrected for cloud coverage and reflec-
tion by the ocean surface. The empirical formula, derived by Reed (1977),
appears to have a better agreement with observational data compared to
other formulations (Katsaros, 1990). The short-wave radiation flux at the
sea surface then finally takes the form
where γ⊙,max is the solar altitude at noon. A constant value of 0.06 is assumed
for the sea surface albedo As . Variations of the albedo as function of the
solar altitude and atmospheric transmittance have been tested using the
empirical fits derived by Payne (1972). No appreciable difference was found
with the formulation (4.250). The only parameter, which needs to be supplied
externally, is the fractional cloud cover fc also used in the expression (4.263)
for the long-wave radiation flux.
4.7.2 Currents
The surface condition for the horizontal current is as usual obtained by spec-
ifying the surface stress as function of the wind components
νT ∂u ∂v
ρ0 , = (τs1 , τs2 ) = ρa Cds W10 (U10 , V10 ) (4.253)
h3 ∂s ∂s
4.7. SURFACE BOUNDARY CONDITIONS 97
where (U10 , V10 ) are the components of the wind vector at a reference height
2
of 10 m, W10 = (U10 + V102 )1/2 is the wind speed, ρa = 1.2 kg/m3 the air
density and Cds the surface drag coefficient discussed in Section 4.8. The
boundary condition for the transformed vertical velocity takes the simple
form
ω=0 (4.254)
4.7.3 Temperature
The surface boundary condition for temperature can either be taken as a
Dirichlet condition in which case Ts is specified directly at (or near) the
surface or a Neumann condition in which case the surface flux of temperature
is given as
ρ0 cp ∂T
λT = Qs (4.255)
h3 ∂s
where Qs is the downwards directed heat flux at the surface and cp the
specific heat of seawater at constant pressure. The net total heat flux into
the water column is composed of a term −Qnsol of all non-solar contributions
plus the radiative flux Qrad . Only the former contributes to the surface flux
of temperature, since solar radiance is absorbed within the water column.
The (upwards directed) non-solar heat flux has three components, i.e.
where Qla is the latent heat flux released by evaporation, Qse the sensible heat
flux due to the turbulent transport of temperature across the air/sea interface
and Qlw the net long-wave radiation emitted at the sea surface. The first
two terms are related to the turbulent fluxes of humidity and temperature
the specific heat of air at constant pressure. The latent heat of vaporization
is given as a function of the sea surface temperature
The sea surface and air humidities qs and qa are calculated using
ǫR e
q= (4.261)
Pa0 − (1 − ǫR )e
where Pa is the atmospheric pressure (in mbar) and ǫR = 0.62197 the ratio of
molecular weight of dry water to dry air. The vapour pressure e is obtained
in mb from the empirical relation (Gill, 1982)
0.7859 + 0.03477T
log10 e = log10 RH + (4.262)
1 + 0.00412T
where RH is the relative humidity (between 0 and 1). In equations (4.261)
and (4.262) the humidity q, the vapour pressure e and the temperature T
(in 0 C) either represent sea surface or atmospheric values at the reference
height. Note that a relative humidity of 100% is taken at the sea surface.
The long-wave radiation flux term is parameterised following Gill (1982):
Qlw = ǫs σrad (Ts + 273.15)4 (0.39 − 0.05e1/2 2
a )(1 − 0.6fc ) (4.263)
where ǫs = 0.985 is the emissivity at the sea surface, σrad = 5.67 × 10−8 W
m−2 K−4 Stefan’s constant, fc the fractional cloud cover (between 0 and 1)
and ea the vapour pressure evaluated by (4.262).
The surface fluxes of momentum and heat involve the surface drag coef-
ficient Cds and two dimensionless parameters Ce , Ch sometimes referred as
the Dalton and Stanton number. Various empirical schemes for these trans-
fer coefficients have been presented in the literature (see e.g. Blanc, 1985;
Geernaert, 1990). A few formulations are available in the program. They are
further discussed in Section 4.8.
Implementation
The type of surface condition for temperature is selected with the switch
iopt temp sbc:
1: Neumann (flux) condition
2: Dirichlet condition at the first grid point below the surface
3: Dirichlet condition at the surface itself
4.7.4 Salinity
The surface salinity flux is determined using the formula given by Steinhorn
(1991):
λT ∂S Ss (Evap − Rpr )
ρ0 = (4.264)
h3 ∂s 1 − 0.001Ss
4.7. SURFACE BOUNDARY CONDITIONS 99
where Evap = Qla /Lν and Rpr are the evaporation and precipitation rates
in kg m−2 s−1 and Ss the surface salinity in PSU. The evaluation of the
surface salinity flux requires the input of precipitation data as an additional
meteorological parameter.
Implementation
The switch iopt sal sbc enables (1) or disables (0) the surface flux condition
(4.264).
4.7.5 Turbulence
The surface boundary conditions for turbulence variables are derived by mak-
ing the “wall”- (or “log”-) layer approximation. The following assumptions
are made
1. The layer is neutrally stratified (N 2 = 0).
2. The shear stress is taken as vertically uniform. Neglecting the Coriolis
force, taking the X-axis along the flow direction and using equation
(4.167) one has
q k 2 ∂U
u2⋆s = 2
τs1 2
+ τs2 = −Su0 = constant (4.265)
ε ∂z
From (4.265)–(4.268) the following Dirichlet type surface conditions are de-
rived for the k, ε and kl transport equations
u2⋆s u3⋆s
k= 1/2
, ε= , l = κds (4.269)
Su0 κds
νk ∂k
= cw u3⋆s (4.271)
h3 ∂s
νk ∂ε νk ǫ0 k 3/2
= (4.272)
h3 σε ∂s h3 σε κd2s
The first condition was proposed by Craig & Banner (1994) with cw ∼ 100
and a non-zero surface roughness to represent the energy input of breaking
surface waves. The second one, introduced by Burchard & Petersen (1999),
can be derived from the Dirichlet conditions and has, according to these au-
thors, a better numerical performance for applications with a coarse vertical
resolution. A modification of the flux condition for ε which takes account
of wave breaking, was considered by Burchard (2001) but is currently not
implemented in the code.
Implementation
The surface boundary condition for turbulence are selected by the following
switches:
where q e represents the external value of ∂ζ/∂x, ∂ζ/∂y or ζ, (fn , un ) are the
nodal amplitude and phase factors, Vn (t) the astronomical phases at Green-
wich and (An , ϕn ) the amplitudes and phases with respect to Greenwich9 .
Table 4.7: Empirical parameters used in the Kondo (1975) formulations for
the neutral surface drag and exchange coefficients.
ad , b d , p d ae , b e , c e , p e ah , b h , c h , p h
W10 < 2.2 0.0, 1.08, -0.15 0.0, 1.23, 0.0, -0.16 0.0, 1.185, 0.0, -0.157
2.2 ≤ W10 < 5 0.771, 0.0858, 1.0 0.969, 0.0521, 0.0, 1.0 0.927, 0.0546, 0.0, 1.0
5 ≤ W10 < 8 0.867, 0.0667, 1.0 1.18, 0.0, 0.0, 1.0 1.15, 0.01, 0.0, 1.0
8 ≤ W10 < 25 1.2, 0.025, 1.0 1.196, 0.008, -0.0004, 1.0 1.17, 0.0075, -0.00045, 1.0
25 ≤ W10 0.0, 0.073, 1.0 1.68, -0.016, 0.0, 1.0 1.652, -0.017, 0.0, 1.0
4. Kondo (1975)
pd
Cds = 10−3 (ad + bd W10 ) (4.277)
where ad , bd and pd are function of wind speed and given in Table 4.7.
5. Wu (1980)
Cds = 0.0012Rw0.15
log10 Rw = 0.137W10 − 0.616 (4.278)
z0s g/u2∗s = a
κ 2
Cds = (4.279)
ln(z0s /10)
where z0s is the surface roughness length, u∗ the surface friction veloc-
ity and a=0.014 Charnock’s constant. Since u2∗s = Cds W10 2
, equation
(4.279) has to be solved by iteration.
Neutral values for Ce and Ch are obtained from one of the following
schemes.
Ce = 0.00115
Ch = 0.00113 if Ta < Ts
= 0.00066 if Ta ≥ Ts (4.280)
4.8. SURFACE DRAG AND EXCHANGE COEFFICIENTS 103
3. Kondo (1975)
pe
Ce = 10−3 ae + be W10 + ce (W10 − 8)2
ph
Ch = 10−3 ah + bh W10 + ch (W10 − 8)2 (4.282)
where the coefficients ae , ah , be , bh , ce , ch and pe , ph are function of the
wind speed and given in Table 4.7.
4. Wu (1980)
Ce = Ch = 0.001Rw0.11
log10 Rw = 0.137W10 − 0.616 (4.283)
u∗ T∗ = −hw′ T ′ i (4.290)
u∗ q∗ = −hw′ q ′ i (4.291)
where (u′ , v ′ , w′ ), T ′ and q ′ are the turbulent fluctuations of the wind velocity,
temperature and humidity, and h i denotes an ensemble average. The vertical
gradient of the wind speed U is written as the ratio of u∗ to a mixing length,
or
∂U u∗
= (4.292)
∂z l
where z is the height above the sea surface. For neutral stratification one
has
l = κz (4.293)
Since l decreases or increases with respect to its neutral value, according as
the stratification is stable or unstable, equation (4.292) can be rewritten in
the more general form
∂U u∗
= φm (4.294)
∂z κz
The dimensionless function φm describes the effect of stratification and is
smaller (or larger) than 1 for unstable (stable) stratification. In a similar
way, the gradients of temperature and relative humidity are given by
∂T T∗
= φh (4.295)
∂z κz
∂q q∗
= φq (4.296)
∂z κz
4.8. SURFACE DRAG AND EXCHANGE COEFFICIENTS 105
and
ψh = 2 ln(1 + φ−1
h ) − 2 ln 2 for ξ < 0
(4.307)
ψ h = 1 − φh for ξ > 0
Parameterisations for u∗ , T∗ , q∗ are given by rewriting (4.301)–(4.303):
z
u2∗ = κ2 (ln − ψm )−2 U 2 = Cds U 2 (4.308)
z0U
z z
u∗ T∗ = κ2 (ln − ψm )−1 (ln − ψh )−1 U (T − Ts ) = Ch U (T − Ts ) (4.309)
z0U z0T
z z
u∗ q∗ = κ2 (ln − ψm )−1 (ln − ψh )−1 U (q − qs ) = Ce U (q − qs ) (4.310)
z0U z0q
where Cds , Ch and Ce are the drag coefficient, the Stanton and the Dalton
numbers. The z-dependence of the coefficients is usually eliminated by eval-
uating them at the standard height z = za = 10 m. Suitable expressions are
required for z0U , z0T , z0q . Parameterisations exist for the roughness length
as function of the wave state (e.g. Janssen, 1991). However, since little infor-
mation is available concerning the form of z0T and z0q , the simpler approach
described in Geernaert (1990) is used. This consists in defining a drag co-
efficient Cdn valid for a neutral stratification. In analogy with (4.308) one
has
−1/2 u∗n z
U = Cdn u∗n = ln (4.311)
κ z0n
where z0n is the value of z0U for neutral conditions. Eliminating z between
(4.308) and (4.311) yields the following relation between Cds and Cdn :
−1/2 z0n
Cds = [Cdn + (ln − ψm )/κ]−2 (4.312)
z0U
Following Charnock (1955) one further assumes that the roughness length
scales with the wind stress or
so that
z0U u2 Cds
= 2∗ = (4.314)
z0n u∗n Cdn
Hence
−1/2
Cds = [Cdn + (ln(Cdn /Cds ) − ψm )/κ]−2 (4.315)
The neutral Stanton and Dalton numbers are defined in a similar way
z z −1
Chn = κ2 (ln ln ) (4.316)
z0n z0T
4.8. SURFACE DRAG AND EXCHANGE COEFFICIENTS 107
z z −1
Cen = κ2 (ln ln ) (4.317)
z0n z0q
Expressions for Ch and Ce in terms of their neutral counterparts are then
obtained by combining (4.316)–(4.317) with (4.309)–(4.310) (taking z0U ≃
z0n for simplicity) and (4.311). This gives
1/2 −1/2
Ch = Chn [1 − (ψm Cdn + ψh Chn Cdn )/κ + Chn ψm ψh /κ2 ]−1 (4.318)
1/2 −1/2
Ce = Cen [1 − (ψm Cdn + ψh Cen Cdn )/κ + Cen ψm ψh /κ2 ]−1 (4.319)
The neutral coefficients are obtained from one of the formulations given in
Section 4.8.1.
Since the functions ψm and ψh depend on the dimensionless height ξ, a
further equation needs to be added. Eliminating u∗ , T∗ and q∗ in (4.297)
after substituting (4.290)–(4.291), by using (4.308)–(4.310) and evaluating
at the reference height, one has
gκza Ch (Ta − Ts ) + 0.61Tk Ce (qa − qs )
ξ= 2
(4.320)
Tv W10 (Cds )3/2
In summary, the coefficients Cds , Ch and Ce are obtained by solving the
system consisting of the four equations (4.315), (4.318), (4.319) and (4.320)
using an iteration scheme. Input parameters are the wind speed W10 , the air
temperature Ta , the sea surface temperature Ts , the relative humidity RH
and the atmospheric pressure pa . The last two are needed to evaluate qa , qs
through (4.261)–(4.262).
The various schemes introduced in this section are compared in Figure 4.5.
The following observations can be made
• The Smith & Banke (1975) and Charnock (1955) formulations are
highly similar. Larger diferences between the different schemes, up
to a factor 2, are seen for the surface drag coefficient in the case of high
wind speeds.
• Stratification effects measured by the air-sea temperature difference
are important at wind speeds below 10 m/s. A significant decrease
of the exchange coefficients is observed in case of a stable (Ta > Ts )
stratification, whereas the cofficients increase in the unstable (Ta < Ts )
case.
• The Kondo and Monin-Obukhov formulations are qualitatively similar.
• The effect of relative humidity is less significant compared to the one
produced by stratification.
108 CHAPTER 4. PHYSICAL MODEL
(a) (b)
(c) (d)
Figure 4.5: (a) Surface drag coefficient Cds as function of wind speed accor-
ding to (4.274) (solid), (4.275) (dots), (4.276) (dashes), (4.277) (dash-dots),
(4.278) (dash and 3 dots), (4.279) (long dashes). (b) Surface exchange coeffi-
cient Ce as function of wind speed according to the Kondo (1975) formulation
and ∆T =Ta −Ts =00 C (solid), -50 C (dots), -2.50 C (dashes), 2.50 C (dash-dots),
50 C (dash and 3 dots). (c) Surface exchange coefficient Ce as function of wind
speed according to Monin-Obukhov theory, using RH=75%, Ts =120 C and
∆T =Ta − Ts =00 C (solid), -50 C (dots), -2.50 C (dashes), 2.50 C (dash-dots),
50 C (dash and 3 dots). (d) Surface exchange coefficient Ce as function of
wind speed according to Monin-Obukhov theory, using Ta =Ts =120 C and
RH=100% (solid), 90% (dots), 80% (dashes), 70% (dash-dots), 60% (dash
and 3 dots), 50% (long dashes).
4.9. BOTTOM BOUNDARY CONDITIONS 109
Implementation
Evaluation of the surface drag and exchange coefficients is selected with the
following switches
iopt sflux cds Formulation for the neutral surface drag coefficient Cds .
iopt sflux cehs Formulation for the neutral surface (heat) exchange coeffi-
cients Ce , Ch .
iopt sflux strat Selects dependence of the surface drag and exchange coeffi-
cients on atmospheric stratification effects.
0 : no dependence
1 : using the Kondo (1975) parameterisation (Section 4.8.2)
2 : using Monin-Obukhov similarity theory (Section 4.8.3)
λψT ∂ψ
= Fbψ (4.321)
h3 ∂s
λψT ∂ψ
= Cbψ (ψbi − ψbe ) (4.322)
h3 ∂s
where Cbψ is the transfer rate (with the dimension of a velocity) and
ψbe , ψbi are the values of ψ just below and above the sea bed.
For example, the bottom conditions (4.324) and (4.328) for u and v are
of the form (4.322) with
4.9.2 Currents
A slip boundary condition is applied for the horizontal current at the bottom
which takes the form
νT ∂u ∂v
, = (τb1 , τb2 ) (4.324)
h3 ∂s ∂s
The following formulations have been implemented
or
(τb1 , τb2 ) = klin (u, v) (4.327)
4.9. BOTTOM BOUNDARY CONDITIONS 111
or
(τb1 , τb2 ) = Cdb (u2 + v 2 )1/2 (u, v) (4.329)
where the bottom currents (ub , vb ) are evaluated at the grid point nearest
to the bottom and (u,v) are the depth-mean currents. A constant value is
taken for the linear friction coefficient klin .
In the boundary layer approximation a vertically uniform shear stress is
assumed yielding a logarithmic profile for the current. The quadratic bottom
drag coefficient can then be expressed as a function of the roughness length
z0 and the vertical grid spacing. This gives
2
Cdb = κ/ ln(zr /z0 ) (4.330)
where zr is a reference height taken at the grid centre of the bottom cell.
The value of z0 which may vary in the horizontal directions, depends on
the geometry and composition of the seabed. Values of z0 , measured from
logarithmic current profiles can be found in Heathershaw (1981); Soulsby
(1983) for various bed type forms. Note that (4.330) can only be applied
when the program is used in 3-D mode. For purely 2-D mode applications
Cdb has to be defined externally by the user.
It is clear that in case of an application in depth-averaged (2-D) mode,
the only allowed formulations for the bottom stress are (4.327) and (4.329).
In analogy with the surface condition (4.254) the bottom value of the
transformed vertical velocity equals zero, i.e.
ω=0 (4.331)
Implementation
Evaluation of the bottom stress is controlled by the following switches
4.9.4 Turbulence
The bottom boundary conditions are obtained using the same boundary layer
assumptions as for the surface case. Equations (4.265)–(4.268) are replaced
by equations (4.333)–(4.336) below. The bottom friction velocity is defined
by
q k 2 ∂U
u2⋆b = τb1
2 2
+ τb2 = Su0 = constant (4.333)
ε ∂z
The mixing length is proportional to the distance db from the “wall” boun-
dary as given by equation (4.200):
l = l1 = κdb = κ(h + z + z0b ) = κ Hσ + z0b (4.334)
∂U k 3/2
P = u2⋆b = ε = ǫ0 (4.336)
∂z κdb
The following Dirichlet conditions are derived from the previous equations
u2⋆b u3⋆b
k= 1/2
, ε= , l = κdb (4.337)
Su0 κdb
In analogy with the surface case the conditions for k and ε can be replaced
by conditions for the bottom flux
νk ∂k
= 0 (4.338)
h3 ∂s
νk ∂ε νk ǫ0 k 3/2
= (4.339)
h3 σε ∂s h3 σε κd2b
The first condition states that there is no energy flux across the bottom.
Implementation
Bottom boundary condition for turbulence are selected by the following
switches:
the domain which involves all three parameters and should therefore include
ζ as well.
The implemented schemes can be divided in four categories10 :
initial conditions (zero transports and elevations). In that case the exterior
data function ψ e (ξ1 , ξ2 , t) is multiplied by the factor
αr (t) = min((t − t0 )/Tr , 1) (4.342)
where Tr is the relaxation period and t0 the initial time. The method avoids
the development of discontinuities during the initial propagation of (e.g.) a
tidal wave into the domain.
All available schemes for 2-D open boundary conditions are briefly des-
cribed below. Details are not given but can be found in the appropriate
references. Comparison of different schemes are discussed in e.g. Palma &
Matano (1998); Jensen (1998); Røed & Cooper (1987). Note that the con-
ditions are applied after solving the 2-D mode equations for U , V , ζ at all
interior points.
The following notations are adopted
• ± or ∓: upper (lower) sign applies at western/southern (eastern/northern)
boundaries
√
• the gravity wave speed c is defined by c = gH
• s equals 1 if ζ e is defined at an exterior node or 2 if ζ e is defined at the
open boundary (U- or V-) node
0. Clamped.
The transports are uniform in time and determined by the initial con-
ditions.
∂U ∂V
=0, =0 (4.343)
∂t ∂t
This is the default condition.
1. Zero slope.
The 2-D momentum equations are solved without surface slope, advec-
tion, horizontal diffusion, pressure gradient and astronomical force.
∂U ∂V
= f V + HF1t + τs1 − τb1 , = −f U + HF2t + τs2 − τb2 (4.344)
∂t ∂t
2. Zero volume flux.
This is a reflective boundary condition whereby the transport is set
equal to its nearest interior value.
∂U ∂V
=0, =0 (4.345)
∂ξ1 ∂ξ2
116 CHAPTER 4. PHYSICAL MODEL
3. Specified elevation.
The 2-D momentum equations are solved without advection, horizontal
diffusion, atmospheric and baroclinic pressure gradient.
∂U c2 ∂ζ
= − + f V + HF1t + τs1 − τb1
∂t h1 ∂ξ1
∂V c2 ∂ζ
= − − f U + HF2t + τs2 − τb2 (4.346)
∂t h2 ∂ξ2
4. Specified transport.
U = Ue , V =Ve (4.347)
This is the simplest and most appropriate condition to be used at river
boundaries.
∂ψ C ∂ψ
∓ =0 (4.348)
∂t hi ∂ξi
∂U c ∂U ∂V c ∂V
∓ =0, ∓ =0 (4.349)
∂t h1 ∂ξ1 ∂t h2 ∂ξ2
∂ψ/∂t
C = cr = h i (4.350)
∂ψ/∂ξi
4.10. LATERAL BOUNDARY CONDITIONS 117
so that
!
∂U cr ∂U ∂U . 1 ∂U
∓ = 0, cr = ±
∂t h1 ∂ξ1 ∂t h1 ∂ξ1
!
∂V cr ∂V ∂V . 1 ∂V
∓ = 0, cr = ± (4.351)
∂t h2 ∂ξ2 ∂t h2 ∂ξ2
where
∂ζ L 1 ∂ ∂ζ L 1 ∂
=− (h1 V ) , =− (h2 U ) (4.355)
∂t h1 h2 ∂ξ2 ∂t h1 h2 ∂ξ1
∂Rou c ∂Rou
!
c ∂ ∂h2
∓ =± (h1 V ) + U + f V + HF1t + τs1 − τb1
∂t h1 ∂ξ1 h1 h2 ∂ξ2 ∂ξ1
(4.357)
and
∂Rov c ∂Rov
!
c ∂ ∂h1
∓ =± (h2 U ) + V − f U + HF2t + τs2 − τb2
∂t h2 ∂ξ2 h1 h2 ∂ξ1 ∂ξ2
(4.358)
The equations are obtained by adding the continuity equation (4.74),
multiplied by ∓c, to the two momentum equations (4.75)–(4.76), where
(for convenience) the advective and horizontal diffusion terms, the baro-
clinic and atmospheric pressure gradient are neglected. These equations
are solved using values of the involved parameters evaluated inside the
domain.
The incoming characteristic is prescribed by
∂Riu
!
c ∂ ∂h2
=∓ (h1 V ) + U + f V + HF1t + τs1 − τb1 (4.361)
∂t h1 h2 ∂ξ2 ∂ξ1
∂Riv
!
c ∂ ∂h1
=∓ (h2 U ) + V − f U + HF2t + τs2 − τb2 (4.362)
∂t h1 h2 ∂ξ1 ∂ξ2
0. Zero gradient.
1 ∂ 1 ∂
(h2 h3 δu) = 0 , (h1 h3 δv) = 0 (4.363)
h1 ∂ξ1 h2 ∂ξ2
This is the default condition.
δu = δue , δv = δv e (4.364)
3. Local solution. The equation is derived from the 3-D and 2-D momen-
tum equations without advection and horizontal diffusion:
5. Orlanski condition.
!
∂δu 1 ∂δu ∂δu ∂δu
∓ cr = 0, cr = ± / h1
∂t h1 ∂ξ1 ∂t ∂ξ1
!
∂δv 1 ∂δv ∂δv ∂δv
∓ cr = 0, cr = ± / h2 (4.369)
∂t h2 ∂ξ2 ∂t ∂ξ2
0. Zero gradient.
1 ∂ 1 ∂
(h2 h3 ψ) = 0 , (h1 h3 ψ) = 0 (4.370)
h1 ∂ξ1 h2 ∂ξ2
This is the default condition.
∂ψ 1 ∂ψ ∂ψ 1 ∂ψ
∓ ci =0, ∓ ci =0 (4.372)
∂t h1 ∂ξ1 ∂t h2 ∂ξ2
3. Orlanski condition.
!
∂ψ 1 ∂ψ ∂ψ ∂ψ
∓ cr = 0, cr = ± / h 1
∂t h1 ∂ξ1 ∂t ∂ξ1
!
∂ψ 1 ∂ψ ∂ψ ∂ψ
∓ cr = 0, cr = ± / h 2 (4.373)
∂t h2 ∂ξ2 ∂t ∂ξ2
where ψe is the open boundary value, ψ̃i the calculated interior value, prior
to relaxation, and α a weighting factor which varies between 1 at the open
boundary and 0 at the inner edge of the relaxation zone. Martinsen & En-
gedahl (1987) showed for a simplified case that the procedure is equivalent
to add a relaxation term α(ψ − ψe )/∆t/(1 − α) to the right hand side of the
122 CHAPTER 4. PHYSICAL MODEL
transport equation where ∆t is the model time step. In this way, ψ relaxes
to its open boundary value if α → 1 and to the internal solution if α → 0.
The method can be applied in the program for temperature, salinity and
baroclinic currents, but is not implemented for the 2-D mode. The following
interpolation schemes can be selected
1. linear
d
α=1− (4.375)
D
2. quadratic
d 2
α= 1− (4.376)
D
3. hyperbolic
d
α = 1 − tanh (4.377)
2∆h
where d is the distance to the boundary, D the width of the relaxation
zone and ∆h the grid spacing. Note that the interpolation assumes a
uniform grid spacing within the relaxation zone.
U = 0, δu = 0 , uψ = 0 (4.378)
V = 0, δv = 0 , vψ = 0 (4.379)
• 2-D hydrodynamics
U = 0, V = 0, ζ=0 (4.380)
• 3-D hydrodynamics
u=v=0 (4.381)
4.12. HARMONIC ANALYSIS 123
• scalars
T = Tref , S = Sref (4.382)
where Tref , Sref are uniform values selected by the user. These are also
the values taken over time if iopt temp=0 or iopt sal=0.
• turbulence
k = 10−6 J/kg (4.383)
for turbulent energy while l is obtained from one of the mixing length
prescriptions given in Section 4.4.3.5 and ε from (4.191).
M Nh Nh
bn sin(ωn k∆t)]2
X X X
R= [Fk − a0 − an cos(ωn k∆t) − (4.386)
k=−M n=1 n=1
M
X Nh
X Nh
X
[Fk − a0 − an cos(ωn k∆t) − bn sin(ωn k∆t)] = 0 (4.387)
k=−M n=1 n=1
M
X Nh
X Nh
X
[Fk − a0 − an cos(ωn k∆t) − bn sin(ωn k∆t)] cos(ωm k∆t) = 0
k=−M n=1 n=1
(4.388)
M
X Nh
X Nh
X
[Fk − a0 − an cos(ωn k∆t) − bn sin(ωn k∆t)] sin(ωm k∆t) = 0
k=−M n=1 n=1
(4.389)
with 1 ≤ m ≤ Nh . The system can be simplified with the aid of known sum-
mation rules for trigonometric functions (see Gradshteyn & Ryzhik, 1981).
The final result can be written as
Nh
X
Xmn an = Rm (4.390)
n=1
Nh
X
Ymn bn = Sm (4.391)
n=1
M Nh
1 h X X 2M + 1 ωn ∆t i
a0 = Fk − an sin( ωn ∆t) csc( ) (4.392)
2M + 1 k=−M n=1 2 2
where
1 2M + 1 ∆t
Xmn = sin (ωm + ωn )∆t csc (ωm + ωn )
2 2 2
1 2M + 1 ∆t
+ sin (ωm − ωn )∆t) csc (ωm − ωn )
2 2 2
1 2M + 1 ωm ∆t 2M + 1 ωn ∆t
− sin( ωm ∆t) csc( ) sin( ωn ∆t) csc( )
2M + 1 2 2 2 2
(4.393)
4.12. HARMONIC ANALYSIS 125
1 2M + 1 ∆t
Ymn = sin (ωm − ωn )∆t csc (ωm − ωn )
2 2 2
1 2M + 1 ∆t
− sin (ωm + ωn )∆t csc (ωm + ωn ) (4.394)
2 2 2
M M
X 1 2M + 1 ωm ∆t X
Rm = Fk cos(ωm k∆t) − sin( ωm ∆t) csc( ) Fk
k=−M 2M + 1 2 2 k=−M
(4.395)
M
X
Sm = Fk sin(ωm k∆t) (4.396)
k=−M
where the residual A0 , the amplitudes An and the phases ϕnc (with respect
to the central time tc ) are obtained from
The actual phase ϕn can be obtained in the program with respect to either
One has
ωn (t − tc ) − ϕnc ≃ Vn (t) + un (t) − ϕn (4.402)
where ∆ref is time difference between the initial date of the simulation
and the reference date. Letting
one obtains
ωn (t − tc ) − ϕnc = ωn tref − ϕn (4.405)
once the harmonic parameters of the current are available using the analysis
of the preceding section. The “nth” harmonic component of the horizontal
current can be written as
where the subscript n has been omitted for simplicity, the complex current
can then be decomposed into a cyclonically and an anticyclonically rotating
component
1 i
u + iv = (U eiωt + Ũ e−iωt ) + (V eiωt + Ṽ e−iωt )
2 2
iωt −iωt
= S+ e + S̃− e (4.408)
The inclination Θ of the ellipse with respect to the ξ1 -axis and the elliptic
angle Φ, i.e. the angle between the initial current at t = 0 and its position
when the current achieves its first maximum, are obtained using
Implementation
The following switches are available for harmonic analysis
iopt out anal Switch to enable (1) or disable (0) harmonic analysis
iopt astro anal If iopt astro anal=1 and cdate timeref is not defined, the har-
monic phases ϕn are calculated with respect to the astronom-
ical phase at Greenwich. Otherwise the phases are obtained
with respect to a given reference date or to the central time,
depending on whether cdate timeref is defined or not (see Sec-
tion 16.3.1).
Chapter 5
Numerical methods
5.1 Introduction
The numerical methods described in this chapter are based to a large extent
upon previous work described in the COHERENS V1 manual (Luyten et al.,
1999).
Conservative finite differences (equivalent to a finite volume technique for
the Cartesian mesh) are used to discretise the mathematical model in space.
The grid chosen for horizontal discretisation is the well known Arakawa
“C” grid (Mesinger & Arakawa, 1976) which staggers the currents and pres-
sure/elevation nodes to give a good representation of the crucial gravity waves
and provides simple representations of open and coastal boundaries. As dis-
cussed in Section 4.1 the model equations are solved on a rectangular or
curvilinear grid in the horizontal and a σ- or extended σ-coordinate grid in
the vertical, whereby varying surface and bottom boundaries are transformed
into constant surfaces. This provides for accurate representation of surface
and bottom boundary processes. It also results in an equal number of cells
in each vertical water column.
The momentum equations are solved with the mode-splitting technique
as in the model of Blumberg & Mellor (1987). The method consists in solving
the depth-integrated momentum and continuity equations for the “external”
or barotropic mode with a small time step to satisfy the stringent CFL sta-
bility criterium for surface gravity waves, and the 3-D momentum and scalar
transport equations for the “internal” or “baroclinic” mode with a larger time
step. A “predictor” and a “corrector” step are applied for the horizontal mo-
mentum equations to satisfy the basic requirement that the depth-integrated
currents obtained from the the 2-D and 3-D mode equations, have identical
values.
129
130 CHAPTER 5. NUMERICAL METHODS
Much effort has been made to implement suitable schemes for the advec-
tion of momentum and scalars. A variety of schemes are available from the lit-
erature, e.g. second and higher order central and upwind schemes (see Hirsch,
1990, for a review), Flux Corrected Transport (FCT; Boris & Book, 1979),
Total Variation Diminishing (TVD; Roe, 1986; Sweby, 1984), Quadratic Up-
stream Interpolation for Convective Kinematics (QUICK; Leonard, 1979),
Second Order Moments (SOM; Prather, 1986; Hofmann & Maqueda, 2006),
Piecewise Parabolic Method (PPM; Colella & Woodward, 1984; James, 1996).
Implementing different schemes within the same model code is a tedious task
since most higher order schemes impose a coupling between space and time
discretisation. The basic choice in the program will therefore be limited to
the upwind and the TVD scheme to reduce the programming and compu-
tational overhead. The latter scheme is implemented with the symmetrical
operator splitting method for time integration and can be considered as a
useful tool for the simulation of frontal structures and areas with strong cur-
rent gradients. The upwind scheme, on the other hand, is only first order
accurate and therefore more diffusive, and should be used if CPU time is
considered of more importance than accuracy.
{
ξ2 {
nr dummy land row
11
00 1
0 00
11 1
0 1
0 00
11 1
0 11
00 00
11 1
0
00
11 0
1
0 11
00 0
1 0
1
0 11
00 0
1
0 11
00
00 00
11 0
1
00
11 1 00
11 0
1 1 00
11 1 11 00
11 0
1
11
00 1
0 11
00 1
0 1
0 11
00 1
0 11
00 11
00 1
0
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
11
00 1
0 11
00 1
0 1
0 11
00 1
0 11
00 11
00 1
0
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
3
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
2
11
00 1
0 11
00 1
0 1
0 11
00 1
0 11
00 11
00 1
0
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
1
00
11
00
11 0
1
0
1 00
11
00
11 0
1
0
1 0
1
0
1 00
11
00
11 0
1
0
1 00
11
00
11 00
11
00
11 0
1
0
1
00
11 0
1 00
11 0
1 0
1 00
11 0
1 00
11 00
11 0
1
1 2 3 nc
ξ1
C−node quantities: scalars
U−node quantities: X−component of vectors
Horizontal
UV(i,j+1) V(i,j+1) UV(i+1,j+1)
U(i,j) U(i+1,j)
C(i,j)
• U-nodes (horizontal bars): at the centers of the left (West) and right
(East) cell faces, used for the X-components of vectors except the sur-
face wind (transports, depth-mean currents, bottom stress, ...)
• V-nodes (vertical bars): at the centers of the lower (South) and upper
(North) cell faces, used for the Y-components of vectors except the
surface wind (transports, depth-mean currents, bottom stress, ...)
• UV-nodes (solid circles): at the corners of the grid cells, used for the
horizontal coordinate arrays which determine the geographical location
of the grid
Each horizontal grid cell has an index, generally denoted by “i”, in the X-
direction between 1 and nc and an index (“j”) in the Y-direction between 1
and nr. The indices refer to the position of a variable at its “natural” node
(C-, U-, V-, UV-node). This is illustrated in Figure 5.2.
As shown in Figure 5.1, the last column (to the East) and the last row (to
the North) are open ended. In this way the domain contains the same number
of C-, U-, V- and UV-nodes. This was not implemented in COHERENS V1
but introduced in the new version to allow a more efficient domain decom-
position in case of a parallel application. The drawback is that the C-node
5.2. MODEL GRID AND DISCRETISATIONS 133
Vertical
sea surface
s W nz+1
C nz
W
C
W
C
W
C
W
C 2
W 2
C 1
W 1
seabed
Figure 5.3: Layout of the computational grid in the vertical.
VW(i,j+1,k+1)
UVW(i,j+1,k+1) UVW(i+1,j+1,k+1)
V(i,j+1,k)
UV(i,j+1,k) UV(i+1,j+1,k)
UVW(i,j,k+1) UVW(i+1,j,k+1)
VW(i,j,k+1)
U(i,j,k) U(i+1,j,k)
C(i,j,k)
VW(i,j+1,k)
UVW(i,j+1,k) UVW(i+1,j+1,k)
UV(i,j,k) UV(i+1,j,k)
V(i,j,k)
UVW(i,j,k) UVW(i+1,j,k)
VW(i,j,k)
Z
Y
5.2.3 Conventions
A quantity taken at a grid point on its natural node is written as Qij for a
2-D or Qijk for a 3-D variable. To simplify the notations, the indices i, j, k
are omitted if no confusion is possible. This means e.g. that Qi,j+1,k (3-D
quantity) can be written as Qj+1 or that Qi−1 (2-D quantity) is the same as
Qi−1,j .
If a quantity needs to be evaluated at a point, different from its natural
position, its value is determined by taking an average over the neighbouring
points. This is indicated by one of the superscripts c , u , v , w , . . . referring to
the point at which the quantity is interpolated. The program allows to use
uniform averaging with equal weight factors or non-uniform averaging with
unequal weights (see Section 8.2). To illustrate the convention, uniform av-
eraging is assumed here for simplicity. The Coriolis terms in the momentum
equations require a 4-point interpolation of the u and v velocities:
1
uvijk = (uijk + ui,j−1,k + ui+1,jk + ui+1,j−1,k )
4
136 CHAPTER 5. NUMERICAL METHODS
Table 5.1: Upper bounds for the grid indices (i,j,k) as function of nodal type.
Node Computational Physical
X-index Y-index Z-index X-index Y-index Z-index
C nc nr nz nc-1 nr-1 nz
U nc nr nz nc nr-1 nz
V nc nr nz nc-1 nr nz
UV nc nr nz nc nr nz
W nc nr nz+1 nc-1 nr-1 nz+1
UW nc nr nz+1 nc nr-1 nz+1
VW nc nr nz+1 nc-1 nr nz+1
UVW nc nr nz+1 nc nr nz+1
X nc nr nz nc nr nz
Y nc nr nz nc nr nz
u 1
vijk = (vijk + vi−1,jk + vi,j+1,k + vi−1,j+1,k )
4
(5.1)
The next example is a centered quantity Q evaluated at respectively the U-,
V-, W-, UW- and VW-node with the same index values:
1
Quijk = (Qi−1,jk + Qijk )
2
1
Qvijk = (Qi,j−1,k + Qijk )
2
1
Qw
ijk = (Qij,k−1 + Qijk )
2
1
Quw
ijk = (Qij,k−1 + Qijk + Qi−1,j,k−1 + Qi−1,j,k )
4
1
Qvw
ijk = (Qij,k−1 + Qijk + Qi,j−1,k−1 + Qi,j−1,k ) (5.2)
4
A double index notation of the form i1 : i2 or j1 : j2 is sometimes in-
troduced in expressions related to open boundary conditions, where the first
index i1 (j1 ) is used at western (southern) boundaries and the second index
i2 (j2 ) at eastern (northern) boundaries, such as in the following example
expressions
ui+1:i−1,jk , vi,j:j−1,k
As discussed in Sections 4.1.2-4.1.3, the grid spacings ∆x1 , ∆x2 , ∆z are set
equal to respectively the metric coefficients h1 , h2 , h3 by normalisation. The
latter notation will be used for convenience in the following.
Spatial differences in the x1 -, x2 - or vertical direction are represented
respectively by the operators ∆x , ∆y , ∆z . The superscript c , u , v , w , uw , vw
or uv indicates the grid (nodal) location of the result. This is illustrated with
the following examples (where Q represents a centered quantity in the third
example):
Grid spacings are “naturally” evaluated at the cell centre. Conforming the
previous rules interpolated values at other grid locations are indicated by a
superscript, e.g. hu1;ij , hw
3;ijk . Note that the grid indices on the left hand side
of the expressions (5.3) refer to the destination node and not the source node
of the interpolation. An overview of all subscript and superscript notations,
used in this chapter, is given in Table 5.2.
Table 5.2: Subscript and superscript notation used in the numerical discreti-
sation formulae.
Type Purpose
subscripts
i X-index of the variable on the model grid (between 1 and either
nc-1 or nc)
j Y-index of the variable on the model grid (between 1 and either
nr-1 or nr)
k vertical index of the variable on the model grid (between 1 and
either nz or nz+1)
i1 :i2 expression used in the spatial discretisation of open boundary
conditions, whereby the first index is taken at the western and
the second index at the eastern boundary
j1 :j2 expression used in the spatial discretisation of open boundary
conditions, whereby the first index is taken at the southern and
the second index at the northern boundary
superscripts
c quantity evaluated or interpolated at the cell centre
u quantity evaluated or interpolated at the U-node
v quantity evaluated or interpolated at the V-node
uv quantity evaluated or interpolated at the UV-node
w quantity evaluated or interpolated at the W-node
uw quantity evaluated or interpolated at the UW-node
vw quantity evaluated or interpolated at the VW-node
n quantity evaluated at the old baroclinic time tn
n+1 quantity evaluated at the new baroclinic time tn+1
m quantity evaluated at the old barotropic time tm
m+1 quantity evaluated at the new barotropic time tm+1
p “predicted” value
f “filtered” value
5.2. MODEL GRID AND DISCRETISATIONS 139
Table 5.3: Parameters and variables used in the numerical description.Global and
local FORTRAN names refer to the variables as defined on respectively the global
and local (parallel) grid.
ṽ p − v n un;v
= −f un − Ah1 (v n ) − Ah2 (v n ) − v v (v n ∆vx huv 2 −u
n;v v c
∆y h1 )
∆t h1 h2
−θa Av (ṽ p ) − (1 − θa )Av (v n ) + θv Dmv (ṽ p ) + (1 − θv )Dmv (v n )
∆v ζ n ∆v Pa
−g yv − y v + F2b;n + F2t;n+1 + Dmh1 (τ21 n n
) + Dmh2 (τ22 )
h2 ρ0 h 2
(5.8)
where (ũp , ṽ p ) are the “predicted” currents before implicit Coriolis
correction, f = 2Ω sin φ is the Coriolis frequency, Ahi , Av are the ho-
rizontal and vertical advection operators defined by (4.53)–(4.55) and
Dmhi , Dmv the horizontal and vertical diffusion operators defined by
(4.56)–(4.58).
3. The predictor currents are obtained by adding an implicit Coriolis cor-
rection:
f θc ∆t(∆v u − f θc ∆t∆u)
up = ũp +
1 + (f θc ∆t)2
p p f θc ∆t(∆uv + f θc ∆t∆v)
v = ṽ − (5.9)
1 + (f θc ∆t)2
where
∆u = ũp − un , ∆v = ṽ p − v n (5.10)
For details see Appendix C.
4. The “predicted” values for the depth-integrated current are obtained
by integrating up and v p over the vertical
Nz Nz
Up = upk hn;u Vp = vkp hn;v
X X
3;k , 3;k (5.11)
k=1 k=1
Ũ m+1 − U m u
kb2
+ m;u Ũ m+1 = f V m;u − Ah1 (U m ) − Ah2 (U m )
∆τ H
v m;u gH m+1;u u m+1
− u u (U m ∆uy huv 1 − H m+1;u m;u u c
v ∆ h
x 2 ) − ∆x ζ
h1 h2 hu1
H m+1;u u b;n m+1;u t;m+1 u u p Up
− ∆ x Pa + F 1 + H F 1 + τ s1 − k (u
b1 b − )
ρ0 hu1 H n;u
n n
+Dmh1 (τ11 )m + Dmh2 (τ12 )m − δAh1 + δDh1 (5.13)
Ṽ m+1 − V m v
kb2
+ m;v Ṽ m+1 = −f U m;v − Ah1 (V m ) − Ah2 (V m )
∆τ H
um;v gH m+1;v v m+1
− v v (V m ∆vx huv2 − H m+1;v m;v v c
u ∆ h
y 1 ) − ∆y ζ
h1 h2 hv2
H m+1;v v b;n m+1;v t;m+1 v v p Vp
− ∆ P
y a + F 2 + H F 2 + τ s2 − k (v
b1 b − )
ρ0 hv2 H n;v
n n
+Dmh1 (τ21 )m + Dmh2 (τ22 )m − δAh2 + δDh2 (5.14)
where
(u, v) = (U/H u , V /H v ) (5.15)
are the depth-mean currents and Ahi , Dmhi are the 2-D advective and
diffusion operators defined by (4.79)–(4.82).
A quasi-implicit formulation is used for the bottom stress in the U -
equation of the form
Up u Ũ
m+1
u
τb1 u
= kb1 upb − + kb2 (5.16)
H n;u H m;u
5.3. MOMENTUM EQUATIONS 145
The friction velocities kb1 and kb2 depend on the formulation for the
bottom stress (see equations (4.325)–(4.329)).
u u
no bottom stress : kb1 = kb2 =0
u u
linear bottom stress : kb1 = 0 , kb2 = klin
1/2
3-D quadratic law u
: kb1 u
= kb2 u
= Cdb (unb )2 + (vbn;u )2
1/2
u u u
2-D quadratic law : kb1 = 0 , kb2 = Cdb (um )2 + (v m;u )2
(5.17)
u
The bottom drag coefficient Cdb is either calculated from (4.330), giving
h i−2
u
Cdb;ij = κ2 ln max(0.5hu3;ij1 /z0;ij
u
), 1.5 (5.18)
f θc ∆τ (∆V u − f θc ∆τ ∆U )
U m+1 = Ũ m+1 +
1 + (f θc ∆τ )2
f θc ∆τ (∆U v + f θc ∆τ ∆V )
V m+1 = Ṽ m+1 − (5.19)
1 + (f θc ∆τ )2
where
∆U = Ũ m+1 − U m , ∆V = Ṽ m+1 − V m (5.20)
5. The 2-D open boundary conditions are applied (see Section 5.3.15.1).
Mt Mt
1 X 1 X
Uf = Um , Vf = Vm (5.21)
Mt m=1 Mt m=1
H n;u up + U n+1 − U p
un+1 = (5.23)
H n+1;u
H n;v v p + V n+1 − V p
v n+1 = (5.24)
H n+1;v
3. The “filtered” advective velocities uf and vf , used for the advection of
scalar quantities (see Section 5.5), are obtained by adding the depth-
integrated current averaged over the baroclinic time step to the baro-
clinic part of the 3-D corrected current:
H n;u up + Uf − U p
un+1
f = (5.25)
H n+1;u
H n;v v p + Vf − V p
vfn+1 = (5.26)
H n+1;v
For details of the procedures see Ruddick (1995).
ω1n+1 = 0
1 h i
Fk = ∆c hu hn+1;u (un+1 − un+1 ) + ∆cy hv1 hn+1;v (vkn+1 − v n+1 )
h1 h2 x 2 3;k
c c k k 3;k k
n+1;u n+1;v
U n+1;c c h3;k V n+1;c c h3;k
+ ∆x + ∆y
hc1 H n+1;u hc2 H n+1;v
n+1
ωk+1 = ωkn+1 − Fk for 2 ≤ k ≤ Nz
n+1
ωNz +1 = 0 (5.27)
5.3. MOMENTUM EQUATIONS 147
n+1
The procedure guarantees that ωN z +1
= 0.
The physical vertical current w is computed at the C-nodes from (4.62):
where
ψ n+1 − ψ n Fi+1 − Fi
+ =0 (5.32)
∆t ∆x
where ∆t is the time step and ∆x a uniform grid spacing. The quantities
ψ and Fi are evaluated on a uniform staggered grid (see Figure 5.5) with
ψ-points located halfway between the F -points. Boundary conditions at xa
and xb are needed to determine the fluxes F1 and FN +1 . At interior points,
i.e. for 2 ≤ i ≤ N + 1, the fluxes Fi are then written as a weighting between
the upwind and Lax-Wendroff fluxes Fup;i and Flw;i :
Fi = (1 − Ω(ri ))Fup;i + Ω(ri )Flw;i (5.33)
where
1
Fup;i = a (1 + si )ψi−1 + (1 − si )ψi (5.34)
2
1
Flw;i = a (1 + ci )ψi−1 + (1 − ci )ψi (5.35)
2
where si and ci are the sign and CFL number of the advecting current
a∆t
si = Sign(a) , ci = (5.36)
∆x
The weight function Ω depends on the type of advection scheme:
• upwind
Ω(r) = 0 (5.37)
• Lax-Wendroff
Ω(r) = 1 (5.38)
5.3. MOMENTUM EQUATIONS 149
F ψ F ψ F ψ F
1 1 2 2 3 Ν N+1
xa xb
r + |r|
Ω(r) = (5.40)
1 + |r|
(1 + si )∆Fi−1 + (1 − si )∆Fi+1
ri =
2∆Fi
∆Fi = Flw;i − Fup;i (5.41)
1
Fce;k = a(ψk−1 + ψk ) (5.42)
2
• non-uniform grids
2
The central scheme is second accurate in time if θa = 0.5.
152 CHAPTER 5. NUMERICAL METHODS
Type Purpose
difference operators
advective operators
(Continued)
3
Note that (uf ,vf ) is replaced by (u,v) if F represents u, v or a turbulent transport
variable (k,ε,kl).
5.3. MOMENTUM EQUATIONS 153
diffusion operators
(Continued)
154 CHAPTER 5. NUMERICAL METHODS
τ11 = −τ22 = νH DT
τ12 = τ21 = νH DS
h2 ∂ u h1 ∂ v
DT = −
h1 ∂ξ1 h2 h2 ∂ξ2 h1
h1 ∂ u h2 ∂ v
DS = +
h2 ∂ξ2 h1 h1 ∂ξ1 h2
(Continued)
5.3. MOMENTUM EQUATIONS 155
τ11 = −τ22 = νH DT
τ12 = τ21 = νH DS
h2 ∂ u h1 ∂ v
DT = −
h1 ∂ξ1 h2 h2 ∂ξ2 h1
h1 ∂ u h2 ∂ v
DS = +
h2 ∂ξ2 h1 h1 ∂ξ1 h2
other operators
f
Cs1 X-corrector term in the scalar transport equations
f ψ ∂
Cs1 (ψ) = (h2 h3 uf )
h1 h2 h3 ∂ξ1
f
Cs2 Y-corrector term in the scalar transport equations
f ψ ∂
Cs2 (ψ) = (h1 h3 vf )
h1 h2 h3 ∂ξ2
n+2/3
ũpA − uA n+2/3
= −θa Av (ũpA ) − (1 − θa )Av (uA )
∆t
n+2/3
+θv Dmv (ũpA ) + (1 − θv )Dmv (uA ) + O1 (5.45)
• Part B
n+1/3
uB − un n+1/3
= −θa Av (uB ) − (1 − θa )Av (un )
∆t
n+1/3
+θv Dmv (uB ) + (1 − θv )Dmv (un ) + O1 (5.46)
• Part A
n+1/3
vA − vn un;v v n ∆vx huv
2
= −Ah1 (v n ) − + Dmh1 (νH DS (un , v n )) (5.51)
∆t hv1 hv2
n+2/3 n+1/3
vA − vA n+1/3 (un;v )2 ∆vy hc1
= −Ah2 (vA ) +
∆t hv1 hv2
n+1/3
− Dmh2 (νH DT (un , vA )) (5.52)
n+2/3
ṽAp − vA n+2/3
= −θa Av (ṽAp ) − (1 − θa )Av (vA )
∆t
n+2/3
+θv Dmv (ṽAp ) + (1 − θv )Dmv (vA ) + O2 (5.53)
• Part B
n+1/3
vB − vn n+1/3
= −θa Av (vB ) − (1 − θa )Av (v n )
∆t
n+1/3
+θv Dmv (vB ) + (1 − θv )Dmv (v n ) + O2 (5.54)
n+2/3 n+1/3
vB − vB n+1/3 (un;v )2 ∆vy hc1
= −Ah2 (vB ) +
∆t hv1 hv2
n+1/3
− Dmh2 (νH DT (un , vB )) (5.55)
n+2/3 n+2/3
ṽBp − vB n+2/3 un;v vB ∆vx huv
2
= −Ah1 (vB ) − v v
∆t h1 h2
n+2/3
+ Dmh1 (νH DS (un , vB )) (5.56)
• Predictor value
1
ṽ p = (ṽAp + ṽBp ) (5.57)
2
The O2 -terms are defined by
∆vy ζ n ∆vy Pa
O2 = −f un;v − g − + F2b;n + F2t;n+1 (5.58)
hv2 ρ0 hv2
Once ũp and ṽ p are obtained, an implicit correction is applied as described
in Section 5.3.1.1.
Important to note again is that, compared to the simpler forward scheme,
the computation using symmetrical operator splitting increases the CPU time
for the circulation module by a factor two, but has the advantage of being
more accurate which is an important property in regions of strong horizontal
and vertical shear.
158 CHAPTER 5. NUMERICAL METHODS
m+2/3
ŨBm+1 − UB H m+1;u (v m;u )2 ∆ux hc2
= −Ah1 (U m+2/3 ) +
∆τ hu1 hu2
m+2/3
+ Dmh1 (νH DT (UB , V m )) (5.64)
• Part A
m+1/3
VA −Vm um;v V m ∆vx huv
2
= −Ah1 (V m ) −
∆τ hv1 hv2
+ Dmh1 (νH DT (U m , V m )) (5.67)
m+2/3 m+1/3
VA − VA m+1/3 H m;v (um;v )2 ∆vy hc1
= −Ah2 (VA )+
∆τ hv1 hv2
m+1/3
− Dmh2 (νH DS (U m , VA )) (5.68)
m+2/3
ṼAm+1 − VA v
kb2
+ Ṽ m+1 = O2 (5.69)
∆τ H m;v A
• Part B
m+1/3
VB −Vm v
kb2 m+1/3
+ m;v VB = O2 (5.70)
∆τ H
m+2/3 m+1/3
VB − VB m+1/3 H m;v (um;v )2 ∆vy hc1
= −Ah2 (VB )+
∆τ hv1 hv2
m+1/3
− Dmh2 (νH DS (U m , VB )) (5.71)
m+2/3
ṼBm+1 − VA m+2/3 um;v V m+2/3 ∆vx huv
2
= −Ah1 (V )− v v
∆τ h1 h2
m+2/3
+ Dmh1 (νH DT (U m , VB )) (5.72)
1
Ṽ m+1 = (ṼAm+1 + ṼBm+1 ) (5.73)
2
160 CHAPTER 5. NUMERICAL METHODS
Once Ũ m+1 and Ṽ m+1 are obtained, an implicit correction is applied as des-
cribed in Section 5.3.1.2.
Table 5.5: Definitions of the fluxes used in the numerical discretisations.
Type Purpose
advective fluxes
diffusive fluxes
(Continued)
162 CHAPTER 5. NUMERICAL METHODS
c c
where Fup;ij and Flw;ij are the upwind and Lax-Wendroff fluxes at the C-node:
c 1 c
Fup;ij = uij (1 + sij )uij + (1 − sij )ui+1,j (5.85)
2
c 1 c
Flw;ij = uij (1 + cij )uij + (1 − cij )ui+1,j (5.86)
2
where sij and cij are the sign and CFL number of the advecting current
ucij ∆t
sij = Sign(ucij ) , cij = (5.87)
hc1;ij
huv uv uv uv uv uv
1;i,j+1 h3;i,j+1 F12;i,j+1 − h1;ij h3;ij F12;ij
Ah2 (u)uij = (5.90)
hu1;ij hu2;ij hu3;ij
uv 1 uv
Fup;ij = vij (αij + sij )ui,j−1 + (βij − sij )uij (5.92)
2
uv 1 uv
Flw;ij = vij (αij + cij )ui,j−1 + (βij − cij )uij (5.93)
2
164 CHAPTER 5. NUMERICAL METHODS
where
vijuv ∆t
sij = Sign(vijuv ) , cij = uv (5.94)
h2;ij
hu2;ij hu2;i,j−1
αij = , βij = (5.95)
huv
2;ij huv2;ij
where sij and cij are the sign and CFL number of the advecting current
ucij ∆τ
sij = Sign(ucij ) , cij = (5.125)
hc1;ij
v cij ∆τ
sij = Sign(v cij ) , cij = c (5.148)
h2;ij
Nz
v
Ãh1 (v)vijk + Ãh2 (v)vijk hv3;ijk − Ãh1 (V )vij − Ãh2 (V )vij
X
δAh2;ij = (5.152)
k=1
uw 1 uw
Fup;ijk = ωijk (αijk + sijk )uij,k−1 + (βijk − sijk )uijk (5.157)
2
uw 1 uw
Fce;ijk = ω (αijk uij,k−1 + βijk uijk ) (5.158)
2 ijk
where
uw hu3;ijk hu3;ij,k−1
sijk = Sign(ωijk ), αijk = , βijk = (5.159)
huw
3;ijk huw3;ijk
5.3. MOMENTUM EQUATIONS 171
uw uw
uw (αijk + sijk )∆Fij,k−1 + (βijk − sijk )∆Fij,k+1
rijk = uw
2∆Fijk
uw uw uw
∆Fijk = Fce;ijk − Fup;ijk (5.160)
vw vw
F23;ij,k+1 − F23;ijk
Av (v)vijk = (5.161)
hv3;ijk
vw vw
where Fup;ijk and Fce;ijk are the upwind and central fluxes at the VW-node:
vw 1 vw
Fup;ijk = ωijk (αijk + sijk )vij,k−1 + (βijk − sijk )vijk (5.163)
2
vw 1 vw
Fce;ijk = ω (αijk vij,k−1 + βijk vijk ) (5.164)
2 ijk
where
vw hv3;ijk hv3;ij,k−1
sijk = Sign(ωijk ), αijk = vw , βijk = vw (5.165)
h3;ijk h3;ijk
vw vw
vw (αijk + sijk )∆Fij,k−1 + (βijk − sijk )∆Fij,k+1
rijk = vw
2∆Fijk
vw vw vw
∆Fijk = Fce;ijk − Fup;ijk (5.166)
172 CHAPTER 5. NUMERICAL METHODS
h hc u hc1;ij c vij i
c c 2;ij c ij
D11;ij = νH;ij hc2;ij ∆ − ∆ (5.172)
hc1;ij x hu2;ij hc2;ij y hv1;ij
huv uv uv uv uv uv
1;i,j+1 h3;i,j+1 D12;i,j+1 − h1;ij h3;ij D12;ij
Dmh2 (τ12 )uij = (5.173)
(hu1;ij )2 hu2;ij hu3;ij
h huv u huv
ij 2;ij uv vij
i
uv uv 1;ij uv
D12;ij = νH;ij huv
1;ij ∆y + ∆ x (5.174)
huv
2;ij hu1;ij huv
1;ij hv2;ij
huv uv uv uv uv uv
2;i+1,j h3;i+1,j D21;i+1,j − h2;ij h3;ij D21;ij
Dmh1 (τ21 )vij = (5.175)
hv1;ij (hv2;ij )2 hv3;ij
h huv u huv
ij uv vij
i
1;ij uv
uv
D21;ij = uv
νH;ij huv
2;ij ∆y + 2;ij ∆ x (5.176)
huv
2;ij hu1;ij huv
1;ij hv2;ij
5.3. MOMENTUM EQUATIONS 173
h hc v hc2;ij c uij i
c c 1;ij c ij
D22;ij = νH;ij hc1;ij ∆ − c ∆x u (5.178)
h2;ij y
c
hv1;ij h1;ij h2;ij
c
h hc u hc1;ij c v ij i
2;ij c ij
D11;ij = νH cij hc2;ij ∆ − c ∆y v (5.184)
h1;ij x
c
hu2;ij h2;ij h1;ij
h huv u huv
uv ij uv v ij
i
1;ij uv
D12;ij = νH uv uv
ij h1;ij ∆ + 2;ij ∆ (5.186)
h2;ij y
uv
hu1;ij huv
1;ij
x
hv2;ij
174 CHAPTER 5. NUMERICAL METHODS
h huv u huv
uv ij uv v ij
i
1;ij uv
D21;ij = νH uv uv
ij h2;ij ∆ + 2;ij ∆ (5.188)
h2;ij y
uv
hu1;ij huv
1;ij
x
hv2;ij
c
h hc v hc2;ij c uij i
1;ij c ij
D22;ij = νH cij hc1;ij ∆ − c ∆x u (5.190)
h2;ij y
c
hv1;ij h1;ij h2;ij
Nz
u
Dmh1 (τ11 )uijk + Dmh2 (τ12 )uijk hu3;ijk − Dmh1 (τ11 )uij − Dmh2 (τ12 )uij
X
δDh1;ij =
k=1
(5.191)
Nz
v
Dmh1 (τ21 )vijk + Dmh2 (τ22 )vijk hv3;ijk − Dmh1 (τ21 )vij − Dmh2 (τ22 )vij
X
δDh2;ij =
k=1
(5.192)
uv huv
1;ij uv uijk
huv
2;ij uv vijk
DS;ijk = uv ∆y + ∆ x (5.201)
h2;ij hu1;ij huv
1;ij hv2;ij
The discretised values of the horizontal diffusion coefficient at the C- and
corner nodes are obtained by applying (4.41)
r
2 2
c
νH;ijk = Cm hc1;ij hc2;ij DTc ;ijk c
+ DS;ijk (5.202)
r
2 2
uv
νH;ijk = Cm huv uv
1;ij h2;ij DTuv;ijk uv
+ DS;ijk (5.203)
Note that the (5.202) and (5.203) only require the interpolation of either DS
at the C-node or DT at the UV-node but not both.
176 CHAPTER 5. NUMERICAL METHODS
where
2 βTw;ijk (Tijk
c c
− Tij,k−1 w
) − βS;ijk c
(Sijk c
− Sij,k−1 )
Ñijk = (5.207)
hw 3;ijk
Note that the currents are interpolated first at the C-nodes before the
vertical derivative is taken.
5.3. MOMENTUM EQUATIONS 177
• The two terms on the right hand side of (4.63) may have the same
magnitude and different signs. Significant rounding errors may arise,
especially in case of large bathymetric gradients.
For further discussion and examples are found in Haney (1991); Kliem &
Pietrzak (1999).
Several solutions have been proposed: fourth order (McCalpin, 1994)
or sixth order (Chu & Fan, 1997) discretisations, “z”-level based methods
(Beckmann & Haidvogel, 1993; Stelling & Van Kester, 1994; Slørdal, 1997),
second order method using unequal weighting (Song, 1998), cubic polyno-
mial interpolation using harmonic averaging (Shchepetkin & McWilliams,
2003). Three algorithms are implemented in the code: the “traditional”
second-order discretisation, a simple z-level method and the Shchepetkin &
McWilliams (2003) approach.
Before discussing the implemented algorithms, the baroclinic pressure
gradient is rewritten in a more convenient form. In Cartesian coordinates,
178 CHAPTER 5. NUMERICAL METHODS
T giju u
FijN = β ∆u (TijNz )hu3;ijNz
z
2hu1;ij T ;ijNz x
gu
T
Fij,k−1 T
= Fijk + uij βTuw;ijk huw uw w uw u uw w
3;ijk ∆x (Tijk ) − ∆z (Tijk )∆x (zijk )
h1;ij
(5.212)
for Nz ≥ k ≥ 2.
T giju u R L
FijN = u
βT ;ijNz (Tijk − Tijk )hu3;ijNz
z
2h1;ij
gu
T
Fij,k−1 T
= Fijk + uij βTuw;ijk (Tijk
R
− TijkL
)huw
3;ijk (5.213)
h1;ij
L R
• If the vertical position of Tijk or Tijk is below the lowest grid point, its
value is set to Tij1 .
L R
• If the vertical position of Tijk or Tijk is above the highest grid point,
its value is set to TijNz .
Despite its simplicity and the fact that it avoids the truncation problem of the
σ-grid, the scheme may produce unrealistic results near the bottom (surface)
or adjacent to a sloping boundary.
The “cube-H” algorithm is probably the most robust scheme, but at the
expense of a larger CPU time. The method uses a cubic spline formalism
together with harmonic averaging. Details of the scheme are not given here
but can be found in the paper of Shchepetkin & McWilliams (2003).
giving
1
F Wi,Nz +1 = TiNz hc3;iNz (5.215)
2
180 CHAPTER 5. NUMERICAL METHODS
i−1
i
T i−1,k+1
L R
T i,k+1 T i−1,k+1
T i−1,k
T i,k+1
R
L T i−1,k
T i,k
T i−1,k−1 T i,k
L R
T i,k−1 T i−1,k−1
T i,k−1
1 c c
F Wik = (Ti,k−1 + Tik )(zik − zi,k−1 )
2
1h
c c 1 c c
− (dz Tik − dz Ti,k−1 ) zik − zi,k−1 − (dz zi,k−1 + dz zik )
10 12
c c
1 i
− (dz zik − dz zi,k−1 ) Tik − Ti,k−1 − (dz Ti,k−1 + dz Tik )
12
(5.216)
where 2 ≤ k ≤ Nz .
2. Evaluate the integral at the UW-nodes
c
Z ξ1;i+1,k ∂z
F Uik = T dξ1 (5.217)
c
ξ1;ik ∂ξ1
giving
F Ui,Nz +1 = 0 (5.218)
5.3. MOMENTUM EQUATIONS 181
1 c c
F Uik = (Ti−1,k + Tik )(zik − zi−1,k )
2
1h
c c 1 c c
− (dx Tik − dx Ti−1,k ) zik − zi−1,k − (dx zi−1,k + dx zik )
10 12
c c
1 i
− (dx zik − dx zi−1,k ) Tik − Ti−1,k − (dx Ti−1,k + dx Tik )
12
(5.219)
where 2 ≤ k ≤ Nz .
3. The algorithms for the derivatives in (5.216) and (5.219) are given by:
• Vertical derivatives
2(fi,k+1 − fik )(fik − fi,k−1 )
dz fik = if (fi,k+1 − fik )(fik − fi,k−1 ) > 0
fi,k+1 − fi,k−1
dz fik = 0 otherwise
(5.220)
Values at the boundaries are
6 7
dz fi1 = (fi2 − fi1 ) − dz fi2
5 15
6 7
dz fiNz = (fiNz − fi,Nz −1 ) − dz fi,Nz −1 (5.221)
5 15
• Horizontal derivatives
2(fi+1,k − fik )(fik − fi−1,k )
dx fik = if (fi+1,k − fik )(fik − fi−1,k ) > 0
fi+1,k − fi−1,k
dx fik = 0 otherwise
(5.222)
Boundary conditions are
i − 1 dry, i+1 wet : dx fik = 65 (fi+1,k − fik ) − 7
d f
15 x i+1,k
i − 1 wet, i+1 dry : dx fik = 65 (fik − fi−1,k ) − 7
d f
15 x i−1,k
i − 1 dry, i+1 dry : dx fik = 0
(5.223)
4. Evaluate the “temperature Jacobian” at the UW-node
1 ∂T ∂z 1 ∂T ∂z
I(T, z) = − (5.224)
h1 ∂ξ1 σ ∂σ h1 ∂σ ∂ξ1 σ
giving
uw giu βTuw;ik
Iik = (F Wik − F Wi−1,k − F Uik + F Ui,k−1 ) (5.225)
hu1;i
for 2 ≤ k ≤ Nz .
182 CHAPTER 5. NUMERICAL METHODS
FikT = uw
Iik ′ (5.226)
k′ =k+1
for 1 ≤ k ≤ Nz , or
T giu u
FiN = β ∆u (TiNz )hu3;iNz
z
2hu1;i T ;iNz x
T
Fi,k−1 = FikT + Iik (5.227)
for 2 ≤ k ≤ Nz .
• The components of the tidal force are determined using (4.219) and
(4.218)
t;u giju h 3 u u c
N0
X
F1;ij = − u sin(2φij )∆x (φij ) A0n cos(P0n;ij )
h1;ij 2 n=1
N1
sin(2φuij )∆ux (λcij ) A1n sin(λuij + P1n;ij )
X
+
n=1
4
The astronomical tidal force can only be taken into account if a spherical grid is
selected.
5
Time is converted to GMT if necessary.
6
Equation (5.228) is applied in double precision arithmetic to avoid truncation errors.
5.3. MOMENTUM EQUATIONS 183
N1
− 2 cos(2φuij )∆ux (φcij ) A1n cos(λuij + P1n;ij )
X
n=1
N2
+ (1 + cos(2φuij ))∆ux (λcij ) A2n sin(2λuij + P2n;ij )
X
n=1
N2
+ sin(2φuij )∆ux (φcij ) A2n cos(2λuij + P2n;ij )
X
n=1
N3
3
+ (3 cos φuij + cos(3φuij ))∆ux (λcij ) A3n sin(3λuij + P3n;ij )
X
4 n=1
N3
3 i
+ (sin φuij + sin(3φuij ))∆ux (φcij ) A3n cos(3λuij + P3n;ij )
X
4 n=1
(5.229)
and
t;v gijv h 3 v v c
N0
X
F2;ij = − sin(2φ ij )∆ y (φ ij ) A0n cos(P0n;ij )
hv2;ij 2 n=1
N1
sin(2φvij )∆vy (λcij ) A1n sin(λvij + P1n;ij )
X
+
n=1
N1
− 2 cos(2φvij )∆vy (φcij ) A1n cos(λvij + P1n;ij )
X
n=1
N2
cos(2φvij ))∆vy (λcij ) A2n sin(2λvij + P2n;ij )
X
+ (1 +
n=1
N2
+ sin(2φvij )∆vy (φcij ) A2n cos(2λvij + P2n;ij )
X
n=1
N3
3
+ (3 cos φvij + cos(3φvij ))∆vy (λcij ) A3n sin(3λvij + P3n;ij )
X
4 n=1
N3
3 i
+ (sin φvij + sin(3φvij ))∆vy (φcij ) A3n cos(3λvij + P3n;ij )
X
4 n=1
(5.230)
and
u v
D13;ij,Nz +1 = τs1;ij , D23;ij,Nz +1 = τs2;ij (5.232)
for respectively the vertical advective and diffusive fluxes of momentum at
the surface.
The components of the surface stress are calculated as function of me-
teorological variables. Different options are available and discussed in Sec-
tion 4.8.
The following steps are taken
• The surface drag coefficient Cds and the components of the surface
stress are determined at the C-nodes.
In the case that the surface drag and exchange are calculated using the
Monin-Obukhov formulation, described in Section 4.8.3, the system of four
equations (4.315), (4.318), (4.319) and (4.320) needs to solved at each model
grid point and time step using a time-consuming iteration procedure. The
following simplifying procedure is taken in the program
∆Tmax − ∆Tmin
∆T = ∆Tmin + mδ(∆T ) for m = 0, NT ; NT =
δ(∆T )
RHmax − RHmin
RH = RHmin + nδRH for n = 0, NR ; NR =
δR
(5.233)
The lower limit Wmin =3 m/s is taken since the equations diverge in the
case of the free-convection limit W → 0 and ∆T > 0. The computed
values are stored in 3-D arrays.
• The values of the drag and exchange coefficients are then obtained at
a specific time by a tri-linear inperpolation from the discretised values.
Extrapolation is used if necessary.
If the bottom stress is parameterised using the bottom values of the 3-D
current, vertical diffusion is treated implicitly. The flux bottom boundary
conditions (4.328) are then discretised as
n;u n+1 n;u n
D13;ij1 = θv kb;ij uij1 + (1 − θv )kb;ij uij1 (5.236)
n;v n+1 n;v n
D23;ij1 = θv kb;ij vij1 + (1 − θv )kb;ij vij1 (5.237)
where θv is the implicity factor for vertical diffusion and the friction velocities
are defined by
u v
no bottom stress (4.325) : kb;ij = kb;ij =0
u v
linear bottom stress (4.326) : kb;ij = kb;ij = klin
1/2
u u n;u 2
3-D quadratic law (4.328) : kb;ij = Cdb;ij (unij1 )2 + (vij1 )
1/2
v
: kb;ij v
= Cdb;ij (un;v 2 n 2
ij1 ) + (vij1 )
(5.238)
186 CHAPTER 5. NUMERICAL METHODS
If the bottom stress is expressed in terms of the depth mean current, the
bottom flux is discretised explicitly
n;u n
D13;ij1 = kb;ij uij (5.239)
n;v n
D23;ij1 = kb;ij v ij (5.240)
1/2
v
kb;ij v
= Cdb;ij (un;v 2 n 2
ij ) + (v ij ) (5.241)
where ωl are the tidal frequencies. Note that (5.242) is evaluated in double
precision to avoid truncation errors for long integration periods.
• Uije , Vije , ζije denote externally specified values (harmonic or time series
data).
u ∆τ cuij v ∆τ cvij
αij = , αij = (5.244)
hc1;i:i−1,j hc2;i,j:j−1
hc1;i:i−1,j hc2;i,j:j−1
riju = , rijv = (5.245)
hu1;ij hv2;ij
Note that the bottom stress components are evaluated at the old time
tn .
Uijm+1 = Ui+1:i−1,j
m+1
, Vijm+1 = Vi,j+1:j−1
m+1
(5.249)
188 CHAPTER 5. NUMERICAL METHODS
Vijm+1 = VijL;m+1
= VijL;m ∓ svij αij
v v v m+1
cij rij (ζi,j:j−1 − ζije )
m+1;c m;c
− ∆τ fijv (θc Ui,j:j−1 + (1 − θc )Vi,j:j−1 )
− Hijm+1;v F2;ij
t;m+1 c
− τs2;ij n;v
+ τb2;ij
(5.251)
Uijm+1 = Ui+1:i−1,j
m m
if Ui+1:i−1,j m−1
≥ Ui+2:i−2,j
(5.259)
Uijm+1 = Uijm otherwise
Vijm+1 = Vi,j+1:j−1
m m
if Vi,j+1:j−1 m−1
≥ Vi,j+2:j−2
(5.260)
Vijm+1 = Vijm otherwise
1
Uijm+1 = Uije ∓ suij cuij (ζi:i−1,j
m+1
− ζije )
2
1
Vijm+1 = Vije ∓ svij cvij (ζi,j:j−1
m+1
− ζije ) (5.261)
2
1
Uijm+1 = UijL;m+1 ∓ suij cuij (ζi:i−1,j
m+1
− ζije )
2
m+1 L;m+1 1 v v m+1
Vij = Vij ∓ sij cij (ζi,j:j−1 − ζije ) (5.262)
2
where U L , V L are the local solutions obtained from (5.250) and (5.251).
∆τ (hv1;i:i−1,j+1 Vi:i−1,j+1
m
− hv1;i:i−1,j Vi:i−1,j
m
)
ζijL;m+1 = ζijL;m − c c
(5.263)
h1;i:i−1,j h2;i:i−1,j
at U-nodes, and
∆τ (hu2;i+1,j:j−1 Ui+1,j:j−1
m
− hu2;i,j:j−1 Ui,j:j−1
m
)
ζijL;m+1 = ζijL;m − c c
(5.264)
h1;i,j:j−1 h2;i,j:j−1
at V-nodes.
190 CHAPTER 5. NUMERICAL METHODS
where the local solutions UijL;m+1 , UijL;m+1 are given by (5.250) and
(5.251).
1 m+1;u m+1;u
Uijm+1 = (Ri;ij + Ro;ij )
2
1 m+1;v m+1;v
Vijm+1 = (Ri;ij + Ro;ij ) (5.267)
2
The incoming characteristic Ri is defined by equations (4.359) using
prescribed values for transports and elevations
m+1;u 1
Ri;ij = Uije ± cuij suij ζije + (2 − suij )ζi:i−1,j
m+1
2
m+1;v 1
Ri;ij = Vije ± cvij svij ζije + (2 − svij )ζi,j:j−1
m+1
(5.268)
2
The outgoing characteristic Ri is obtained by solving the discretised
versions of equations (4.357)–(4.358):
3 u u m+1;u m;u
(1 + αij rij )Ro;ij = Ro;ij
2
u u m+1 1 m+1;u
+ αij rij (Ui+1:i−1,j + Ri;ij ∓ 2cuij ζi:i−1,j
m+1
)
2
u
αij
+ c ±(hv1;i:i−1,j+1 Vi:i−1,j+1
m
− hv1;i:i−1,j Vi:i−1,j
m
)
h2;i:i−1,j
m;c
+ Ui:i−1,j (hu2;i+1:i−1,j − hu2;ij )
m+1;c m;c
+∆τ fiju (θc Vi:i−1,j + (1 − θc )Vi:i−1,j ) + Hijm+1;u F1;ij
t;m+1 c
+ τs1;ij n;u
− τb1;ij
(5.269)
and
3 v v m+1;v m;v
(1 + αij rij )Ro;ij = Ro;ij
2
5.3. MOMENTUM EQUATIONS 191
v v m+1 1 m+1;v
+ αij rij (Vi,j+1:j−1 + Ri;ij ∓ 2cvij ζi,j:j−1
m+1
)
2
αv
+ c ij ±(hu2;i+1,j:j−1 Ui+1,j:j−1
m
− hu2;i,j:j−1 Ui,j:j−1
m
)
h1;i,j:j−1
m;c
+ Vi,j:j−1 (hv1;i,j+1:j−1 − hv1;ij )
m+1;c m;c
−∆τ fijv (θc Ui,j:j−1 + (1 − θc )Ui,j:j−1 ) − Hijm+1;v F2;ij
t;m+1 c
− τs2;ij n;v
+ τb2;ij
(5.270)
Note that the propagation term is integrated fully implicitly and Uijm+1 ,
Vijm+1 have been eliminated in (5.269)–(5.270) by substituting for Rim+1;u
and Rim+1;v from (5.268).
and
m+1;v m;v
Ri;ij = Ri;ij
v
αij
− c ±(hu2;i+1,j:j−1 Ui+1,j:j−1
m
− hu2;i,j:j−1 Ui,j:j−1
m
)
h1;i,j:j−1
c;m
+ Vi,j:j−1 (hv1;i,j+1:j−1 − hv1;ij )
m+1;c m;c
− ∆τ fijv (θc Ui,j:j−1 + (1 − θc )Ui,j:j−1 ) − Hijm+1;v F2;ij
t;m+1 c
− τs2;ij n;v
+ τb2;ij
(5.272)
192 CHAPTER 5. NUMERICAL METHODS
2. The flux is determined using the upwind scheme (where possible). This
means that
uv 1 uv
F 12;ij = v ij (1 + sij )Ui,j−1:j + (1 − sij )Ui,j:j−1 or
2
uv 1 uv
F 21;ij = uij (1 + sij )Vi−1:i,j + (1 − sij )Vi:i−1,j (5.274)
2
where sij = 1 in case of an inflow condition and either
at coastal boundaries.
Likewise all fluxes for the cross-advective and diffusive terms are set to
zero at closed Y- or X-node boundaries:
uv uv uv uv
F 12;ij = 0.0 , D12;ij = 0.0 , F 21;ij = 0.0 , D21;ij = 0.0 (5.281)
hu2;i+1:i−1,j hn+1;u
3;i+1:i−1,jk
δun+1
ijk = u n+1;u δun+1;u
i+1:i−1,jk (5.282)
h2;ij h3;ijk
n+1
hv1;i,j+1:j−1 hn+1;v
3;i,j+1:j−1,k n+1;v
δvijk = δvi,j+1:j−1,k (5.283)
hv1;ij hn+1;v
3;ijk
δun+1
ijk = δueijk (5.284)
n+1 e
δvijk = δvijk (5.285)
(5.286)
3. Local solution
hn+1;v n+1;c
3;jk δvjk − hn;v n;c
3;jk δvjk
= −f θc un+1;c
jk − (1 − θc )un;c
jk (5.291)
hn+1;v
3;jk
b;n vw vw
b;n F 2;j+1:j−1,k D23;j,k+1 − D23;jk τb2;j − τs2;j
+ F2;j+1:j−1,k − n+1;v + +
Hj+1:j−1 v
h3;jk Hjn+1;v
The diffusive fluxes are obtained from (5.197), (5.199) using the condi-
tion (5.232) at the surface and the bottom stress formulations given in
Section 5.3.14.2.
4. Radiation condition using the baroclinic wave speed (see equation (4.368)).
δun+1
ijk
u
= (1 − wijk )δunijk + wijk
u
δuni+1:i−1,jk (5.292)
n+1 v n v n
δvijk = (1 − wijk )δvijk + wijk δvi,j+1:j−1,k (5.293)
R∆t q
u
wijk = ± gc H n+1;c
hc1;i:i−1,j i:i−1,j i:i−1,j
R∆t q c
v
wijk = ± c g H n+1;c (5.294)
h2;i,j:j−1 i,j:j−1 i,j:j−1
(5.295)
n+1 v v v n v v v n
δvijk = 1−OR (r1;ijk , r2;ijk , r3;ijk ) δvijk +OR (r1;ijk , r2;ijk , r3;ijk )δvi,j+1:j−1,k
(5.296)
196 CHAPTER 5. NUMERICAL METHODS
Once the baroclinic and mean components are known, the full 3-D cur-
rents are determined by adding the two components
n+1;c n+1;c
un+1 n+1 n+1
ijk = Uij /Hi+1:i−1,j + δuijk ,
n+1
vijk = Vijn+1 /Hi,j+1:j−1 n+1
+ δvijk (5.299)
at coastal boundaries.
Likewise all fluxes for the cross-advective and diffusive terms are set to
zero at closed Y- or X-node boundaries:
uv uv uv uv
F12;ijk = 0.0 , D12;ijk = 0.0 , F21;ijk = 0.0 , D21;ijk = 0.0 (5.301)
where X old and X new are the values of the values of the current (u or v) at
the “old” and “new” time step. Equations (5.302) form a tridiagonal matrix
system in the vertical, which has to be solved at each horizontal grid point
(i,j).
Omitting the i and j indices for simplicity, the elements Ak , Bk and Ck
can be written as the sum of different components, each representing partic-
ular term(s) in the corresponding momentum equation. Explicit expressions
are given below for the update of u at the predictor step without operator
splitting, as given by equation (5.7) so that X old = un and X new = up . They
are easily extended to the case for v-equation.
When operator splitting is used, four of the six steps are explicit inte-
grations in which case the solution is straigtforward. The two steps (5.45),
(5.46) involving implicit terms are treated in a similar way.
The discretised 2-D equations for transports are written as
Bij Xijnew = Dij Xijold (5.303)
The composition of the B- and D-matrices is readily obtained from the dis-
cretisation formulae in the preceding sections and is not given here. The
solution of (5.303) is straightforward.
uw
and αijk , βijk , sijk , rijk are defined by (5.159) and (5.160).
The terms arising from the flux above the k-level, are
a
Ak+ = 0
a
B k + = θa c +
k (αk+1 + fk+1 )
a+ +
Ck = θa ck (βk+1 − fk+1 )
a
Dk + = −(1 − θa )c+ n n
k (αk+1 + fk+1 )uk + (βk+1 − fk+1 )uk+1
(5.307)
where 1 ≤ k ≤ Nz − 1 and
uw
∆tωk+1
c+
k = (5.308)
2hu3;k
3. Vertical diffusion.
As for vertical advection the fluxes below and above a k-level are taken
separately. The former are given by
d ∆tνTuw;k
Ak− = −θv
hu3;k huw
3;k
uw
d ∆tν ;k
Bk − = θv u Tuw
h3;k h3;k
d
Ck − = 0
d ∆tνTuw;k n
Dk− = −(1 − θv ) (uk − unk−1 ) (5.309)
hu3;k huw
3;k
where 2 ≤ k ≤ Nz .
The terms taken from the flux above the k-level, are
d
Ak+ = 0
d ∆tνTuw;k+1
B k + = θv
hu3;k huw
3;k+1
d ∆tνTuw;k+1
Ck + = −θv u uw
h3;k h3;k+1
d ∆tν uw;k+1 n
Dk + = (1 − θv ) u Tuw (u − unk ) (5.310)
h3;k h3;k+1 k+1
where 1 ≤ k ≤ Nz − 1.
5.3. MOMENTUM EQUATIONS 199
d d d d ∆tkbu un
A1− = B1 − = C1 − = 0 , D1 − = − (5.315)
hu3;1
5. Equation (5.18) shows that the bottom drag coefficient and hence the
bottom friction increases exponentially at small water depths. This will
slow down the water flow at water depths close to the minimum value.
Note that this effect is only present when the bottom drag coefficient
is calculated as function of a roughness length.
• Land cells which are always dry and where no calculation is performed.
They are defined by the user as cells where the mean water depth equals
zero7 .
The “mask functions” are defined as criteria for “masking” grid cells
according to their condition (dry or wet). When the criterium evaluates
as .TRUE. at a particular grid cell, the mask function will “mask in” the
cell. Hence, they will be considered for the solution of the hydrodynamic
equations. On the other hand, if grid cells become dry, the mask criterium
will “mask out” such grid cells and updates of quantitites defined at these
cells will be suspended. Dry cells are also excluded from the interpolation of
model variables on the model grid (see Section 8.2.2). The process is repeated
at the start of each predictor time step. Once a cell is set to a “dry” status,
the adjacent velocity nodes are blocked and the all currents at these nodes
are set to zero to prevent further drying of the grid cell. The criteria are
applied at the start of each predictor time step. If the criterium at a dry cell
evaluates as .FALSE. at a later time, the cell is reactivated again and water
is allowed to enter through the side faces.
Eleven mask functions are defined and can be used in combined form.
They can be divided in four groups. The first group compares the water
depths of a cell and its neighbours with a threshold value dth and is composed
of the following six criteria:
where “mean” denotes an averaged value (excluding land cells which are
permanently dry).
A second group of criteria verifies the “status” of the neighbouring cells.
The status is defined by the function N which evaluates to 0 at dry and 1 at
sea cells8 . The following criteria, used to prevent the formation of isolated
dry or wet cells, have been implemented:
The third group is a variant of the previous one and checks, in addition,
whether the total water depth of the grid cell is lower than the threshold
value:
The last scheme is intended for channel flows and overflowing dykes. The
criterium uses the total and mean water depths at the grid cell and its neigh-
bours
min(hi−1,j − Hi−1,j , hi+1,j − Hi+1,j ) > hij (5.333)
or
min(hi,j−1 − Hi,j−1 , hi,j+1 − Hi,j+1 ) > hij (5.334)
depending on whether the along-channel direction is along the X- or Y-axis.
The above criteria can be in applied in combination. This means that,
if several criteria have been activated by the user, the cell becomes dry if at
least one of them turns .TRUE. The cell becomes wet again if all of them
evaluate to .FALSE.
The flooding of initially dry land areas can be simulated using the follo-
wing procedure at the initial time
1. Define the topographic height (e.g. hmax ) of the highest points on land
which can potentially be flooded by a rising sea level.
2. Define an initial bathymetry. Note that grid points with a zero mean
water depth are considered by the model as permanently dry land
points and cannot be flooded. Negative depth values are not allowed.
3. Increase the reference mean sea level by adding hmax to the initial
bathymetry (with respect to the standard mean sea level).
4. Reset the initial surface elevation to take account of the changed refer-
ence level
new old
ζin = ζin − hmax (5.335)
old
where ζin is the sea level with respect to the old standard level. If,
by this procedure, the total water depth becomes negative (more pre-
cisely lower than dmin ) the total depth will be reset to dmin . In case a
dynamic mask is applied, these grid cells may be (temporarily) set to
dry (depending on the type of mask function) at the initial time9 .
9
If residual (non-harmonic) elevation data are used as open boundary forcing, the
previous change in mean sea level must be taken into account.
5.5. SCALAR TRANSPORT EQUATIONS 205
• In the 3-D case, the mask cannot be changed during a 3-D (baroclinic)
time step. This means that the mask criteria are tested after the last
corrector step and before the next predictor time step and not at each
barotropic time step. When a purely 2-D grid has been selected, the
criteria are obviously applied at each (barotropic) time step.
• The advecting current (uf ,vf ) used for horizontal advection is composed
of the baroclinic current at the “predictor” step plus a filtered depth-
independent component obtained by averaging over the more rapidly
varying 2-D mode (see equations (5.25)–(5.26)).
2. Making use of the continuity equation (4.49), the time derivative term
is written as
1 ∂ ∂ψ ψ ∂h3
(h3 ψ) = +
h3 ∂t ∂t h3 ∂t
∂ψ f f
= − Cs1 (ψ) − Cs2 (ψ) − Cs3 (ψ) (5.336)
∂t
where the “corrector” terms are defined by
f ψ ∂
Cs1 (ψ) = (h2 h3 uf ) (5.337)
h1 h2 h3 ∂ξ1
f ψ ∂
Cs2 (ψ) = (h1 h3 vf ) (5.338)
h1 h2 h3 ∂ξ2
ψ ∂ω
Cs3 (ψ) = (5.339)
h3 ∂s
3. For reasons of conservation the source and sink are both discretised
explicitly. The operation is not without risk since the method may
produce negative concentrations (Burchard et al., 2003). To simplify
the notations the following operator is defined
T (ψ) = P(ψ) − S(ψ) (5.340)
An alternative method is the Patankar scheme, discussed in Section 5.6
below, which is monotone but does not guarantee conservation.
The new form of the scalar transport equation then becomes
∂ψ
+ Afh1 (ψ) + Afh2 (ψ) + Av (ψ) − Cs1
f f
(ψ) − Cs2 (ψ) − Cs3 (ψ)
∂t
= T (ψ) + Dsv (ψ) + Dsh1 (ψ) + Dsh2 (ψ) (5.341)
where Afhi are the horizontal advective operators using the filtered currents
1 ∂
Afh1 (ψ) = (h2 h3 uf ψ) (5.342)
h1 h2 h3 ∂ξ1
1 ∂
Afh2 (ψ) = (h1 h3 vf ψ) (5.343)
h1 h2 h3 ∂ξ2
(5.344)
• Part B
n+1/3
ψB − ψn n+1/3
= −θa Av (ψB ) − (1 − θa )Av (ψ n ) + Cs3 (ψ n )
∆t
n+1/3
+ θv Dv (ψB ) + (1 − θv )Dsv (ψ n ) + T (ψ n )
(5.350)
5.5. SCALAR TRANSPORT EQUATIONS 209
n+2/3 n+1/3
ψB − ψB n+1/3 n+1/3
= −Afh2 (ψB f
) + Cs2 (ψ n ) + Dsh2 (ψB ) (5.351)
∆t
n+2/3
ψBn+1 − ψB n+2/3 f n+2/3
= −Ah1 (ψB ) + Cs1 (ψ n ) + Dsh1 (ψB ) (5.352)
∆t
• Updated value
1
ψ n+1 = (ψAn+1 + ψBn+1 ) (5.353)
2
1 ∂ 1 ∂
Afh1 (ψ) = h 2 h 3 uf ψ = h2 h3 F1 (5.354)
h1 h2 h3 ∂ξ1 h1 h2 h3 ∂ξ1
1 ∂ 1 ∂
Afh2 (ψ) = h 1 h 3 vf ψ = h1 h3 F2 (5.355)
h1 h2 h3 ∂ξ2 h1 h2 h3 ∂ξ2
1 ∂ 1 ∂F3
Av (ψ) = (ωψ) = (5.356)
h3 ∂s h3 ∂s
u u
where Fup;ijk and Flw;ijk are the upwind and Lax-Wendroff fluxes at the U-
node:
u 1
Fup;ijk = uf ;ijk (αij + sijk )ψi−1,jk + (βij − sijk )ψijk (5.359)
2
u 1
Flw;ijk = uf ;ijk (αij + cijk )ψi−1,jk + (βij − cijk )ψijk (5.360)
2
where sijk and cijk are the sign and CFL number of the advecting current
uf ;ijk ∆t
sijk = Sign(uf ;ijk ) , cijk = (5.361)
hu1;ij
hc1;ij hc1;i−1,j
αij = , βij = (5.362)
hu1;ij hu1;ij
The form of the weighting function is given by (5.37)–(5.40), depending on
the type of advection scheme, selected by the switch iopt adv scal. The ar-
gument r of the weight function is defined by
u u
u (αij + sijk )∆Fi−1,jk + (βij − sijk )∆Fi+1,jk
rijk = u
2∆Fijk
u u u
∆Fijk = Flw;ijk − Fup;ijk (5.363)
hc2;ij hc2;i,j−1
αij = , βij = (5.369)
hv2;ij hv2;ij
The vertical advective term is obtained by differencing the flux F3w at the
C-node
Fw w
− F3;ijk
Av (ψ)cijk = 3;ij,k+1c (5.371)
h3;ijk
The flux is calculated from
w w w w w
F3;ijk = 1 − Ω(rijk ) Fup;ijk + Ω(rijk )Fce;ijk (5.372)
w w
where Fup;ijk and Fce;ijk are the upwind and central fluxes at the W-node:
w 1 w
Fup;ijk = ωijk (αijk + sijk )ψij,k−1 + (βijk − sijk )ψijk (5.373)
2
w 1 w
Fce;ijk = ωijk αijk ψij,k−1 + βijk ψijk (5.374)
2
where
w hc3;ijk hc3;ij,k−1
sijk = Sign(ωijk ), αijk = , βijk = (5.375)
hw
3;ijk hw 3;ijk
1 ∂ h2 h3 ∂ψ 1 ∂
Dsh1 (ψ) = λH = h2 h3 D1 (5.380)
h1 h2 h3 ∂ξ1 h1 ∂ξ1 h1 h2 h3 ∂ξ1
1 ∂ h1 h3 ∂ψ 1 ∂
Dsh2 (ψ) = λH = h1 h3 D2 (5.381)
h1 h2 h3 ∂ξ2 h2 ∂ξ2 h1 h2 h3 ∂ξ2
ψ
1 ∂ λT ∂ψ
1 ∂D3
Dsv (ψ) = = (5.382)
h3 ∂s h3 ∂s h3 ∂s
w λψ;w
T (ψijk − ψij,k−1 )
D3;ijk = (5.388)
hw
3;ijk
ψ;w
1. Neumann condition with a prescribed (downward) surface flux Fs;ij
w ψ;w
D3;ijN z
= Fs;ij (5.391)
w
4. Dirichlet condition with a prescribed external value ψs;ij at the surface
itself. In that case the value at the first node below the surface is
determined by interpolation
n+1
n+1 2hw w c
3;ijNz ψs;ij + h3;ijNz ψij,nz −1
ψijN = (5.394)
z
2hw c
3;ijNz + h3;ij,Nz
Note that the second Neumann condition is semi-implicit whereas both Dirich-
let conditions use a fully implicit formulation.
c
3. Dirichlet condition with a prescribed external value ψb;ij at the first
C-node above the bottom
n+1 c
ψij1 = ψb;ij (5.398)
w
4. Dirichlet condition with a prescribed external value ψb;ij at the bottom
itself. In that case the value at the first node above the sea bed is
determined by interpolation
n+1
n+1 2hw w c
3;ij2 ψb;ij + h3;ij1 ψij2
ψij1 = (5.399)
2hw c
3;ij2 + h3;ij1
Note that the second Neumann condition is semi-implicit whereas both Dirich-
let conditions use a fully implicit formulation.
u 1
e
F1;ijk = uf ;ijk (1 ± sijk )ψijk + (1 ∓ sijk )ψi:i−1,jk (5.401)
2
at U-boundaries and
v 1
e
F2;ijk = vf ;ijk (1 ± sijk )ψijk + (1 ∓ sijk )ψi,j:j−1,k (5.402)
2
at V-boundaries, where the upper (lower) sign applies at western/southern
(eastern/northern) boundaries, the flow sign sijk is defined by (5.361) or
e
(5.368) and ψijk denotes an external profile of ψ at one-half grid distance
outside the open boundary. The open boundary problem then consists in
determining the external profile ψ e . The following four methods are available
u R∆t q u n+1;c
wijk = ± gij Hi:i−1,j
hu1;ij
v R∆t q v n+1;c
wijk = ± v gij Hi,j:j−1 (5.407)
h2;ij
e;u;n+1 u u u e;u;n
ψijk = 1 − OR (r1;ijk , r2;ijk , r3;ijk ) ψijk
u u u n
+ OR (r1;ijk , r2;ijk , r3;ijk )ψi:i−1,jk (5.408)
e;v;n+1 v v v e;v;n
ψijk = 1 − OR (r1;ijk , r2;ijk , r3;ijk ) ψijk
v v v n
+ OR (r1;ijk , r2;ijk , r3;ijk )ψi,j:j−1,k (5.409)
This means that k below varies between kmin and kmax where kmin equals 1
for a Neumann (flux) condition and 2 for a Dirichlet condition at the bottom.
Likewise, kmax equals Nz for a Neumann and Nz − 1 for a Dirichlet condition
at the surface.
For simplicity, the i and j indices are omitted.
1. Time derivative.
The contribution of the time derivative is given by
2. Vertical advection.
The vertical advection term is split up into two contributions arising
from the fluxes below and above a k-level. The former are given by
a
Ak− = −θa c−
k (αk + fk )
a− −
Bk = −θa ck (βk − fk )
a
Ck − = 0
a n n
Dk − = (1 − θa )c−
k (αk + fk )ψk−1 + (βk − fk )ψk (5.413)
where 2 ≤ k ≤ kmax ,
∆tωkw
c−
k = , fk = 1 − Ω(rkw ) sk (5.414)
2hc3;k
w
and αijk , βijk , sijk , rijk are defined by (5.375) and (5.376).
The terms arising from the flux above the k-level, are
a
Ak+ = 0
a
B k + = θa c +
k (αk+1 + fk+1 )
a+ +
Ck = θa ck (βk+1 − fk+1 )
a
Dk + = −(1 − θa )c+ n n
k (αk+1 + fk+1 )ψk + (βk+1 − fk+1 )ψk+1
(5.415)
3. Vertical diffusion.
As for vertical advection the fluxes below and above a k-level are taken
separately. The former are given by
d ∆tλψ;w
Ak− = −θv c Tw;k
h3;k h3;k
d ∆tλψ;w
Bk − = θv c Tw;k
h3;k h3;k
d
Ck − = 0
d ∆tλψ;w
Dk − = −(1 − θv ) c Tw;k (ψkn − ψk−1
n
) (5.417)
h3;k h3;k
where 2 ≤ k ≤ kmax .
The terms taken from the flux above the k-level, are
d
Ak+ = 0
d ∆tλψ;w
Bk + = θv c Tw;k+1
h3;k h3;k+1
d ∆tλψ;w
Ck + = −θv c Tw;k+1
h3;k h3;k+1
d ∆tλψ;w T ;k+1 n
Dk+ = (1 − θv ) (ψk+1 − ψkn ) (5.418)
hc3;k hw3;k+1
where kmin ≤ k ≤ Nz − 1.
∆tFsψ;w
s
AsNz = BN = CNs z = 0 , s
DN = (5.420)
z z
hc3;Nz
AsNz = CNs z = 0 , s
BN z
= 1, s
DN z
= ψsc (5.422)
∆tFbψ;w
Ab1 = B1b = C1b = 0, D1b = (5.424)
hc3;1
∆tCbψ ∆tCbψ w
Ab1 = C1b = 0, B1b = θv c , D1b = c ψb − (1 − θv )ψ1n
h3;1 h3;1
(5.425)
• Dirichlet condition with a prescribed external value ψbc at the first
node above the sea bed.
Ab1 = 0 , B1b = 1
hc3;1
C1b = − w
2h3;2 + hc3;1
2hw 3;2 ψb
w
D1b = (5.427)
2hw3;2 + h3;1
c
• Production terms are taken explicitly at the old time step tn , whereas
the sink terms are discretised in time using the “quasi-implicit” ap-
proach, proposed by Patankar (1980), or
ψ n+1
P(ψ) = P(ψ n ) , S(ψ) = P(ψ n ) (5.428)
ψn
• Since the turbulent equations are solved before the momentum equa-
tions, the horizontal advective terms are discretised using the non-
filtered current (u,v).
• The discretisation algorithms for advection and diffusion are the same
as for C-node scalar quantities, except that all quantities are displaced
in the vertical. This means that 3-D variables (fluxes, advective veloci-
ties, diffusion coefficients, . . . ), previously evaluated at (C,U,V,W,UW,
VW)-nodes are now taken at respectively (W,UW,VW,C,U,V)-nodes.
∂ψ
+ Ah1 (ψ) + Ah2 (ψ) + Av (ψ) − Cs1 (ψ) − Cs2 (ψ) − Cs3 (ψ)
∂t
= P(ψ) − S(ψ) + Dsv (ψ) + Dsh1 (ψ) + Dsh2 (ψ) (5.429)
5.6. TURBULENCE TRANSPORT EQUATIONS 221
where the corrector and horizontal advective operators Csi and Ahi are given
by (5.337)–(5.339) and (5.342)–(5.343) with (uf ,vf ) replaced by (u,v).
Despite the similarities with the previous section, the discretisation me-
thods are described in detail below, to avoid any confusion.
hn+1;w
3 ψ n+1;w − hn;w
3 ψ
n;w
ψ n+1;w − ψ n;w
= −Ah1 (ψ n;w ) + Cs1 (ψ n;w ) − Ah2 (ψ n;w ) + Cs2 (ψ n;w )
∆t
− θa Av (ψ n+1;w ) − (1 − θa )Av (ψ n;w ) + Cs3 (ψ n;w )
+ θv Dsv (ψ n+1;w ) + (1 − θv )Dsv (ψ n;w ) + P(ψ n;w )
ψ n+1;w
− S(ψ n;w ) n;w + Dsh1 (ψ n;w ) + Dsh2 (ψ n;w ) (5.431)
ψ
• Part A
n+1/3;w
ψA − ψ n;w
= −Ah1 (ψ n;w ) + Cs1 (ψ n;w ) + Dsh1 (ψ n;w ) (5.432)
∆t
222 CHAPTER 5. NUMERICAL METHODS
n+2/3;w n+1/3;w
ψA − ψA n+1/3;w
= −Ah2 (ψA ) + Cs2 (ψ n:w )
∆t
n+1/3;w
+ Dsh2 (ψA ) (5.433)
n+2/3;w
ψAn+1;w − ψA n+2/3;w
= −θa Av (ψAn+1;w ) − (1 − θa )Av (ψA )
∆t
+ Cs3 (ψ n;w ) + θv Dsv (ψAn+1;w )
n+2/3;w
+ (1 − θv )Dsv (ψA ) + P(ψ n;w )
ψ n+1;w
− S(ψ n+2/3;w ) n+2/3;w (5.434)
ψ
• Part B
n+1/3;w
ψB − ψ n;w n+1/3;w
= −θa Av (ψB ) − (1 − θa )Av (ψ n;w )
∆t
n+1/3;w
+ Cs3 (ψ n;w ) + θv Dsv (ψB )
n;w n;w
+ (1 − θv )Dsv (ψ ) + P(ψ )
ψ n+1/3;w
− S(ψ n;w ) (5.435)
ψ n;w
n+2/3;w n+1/3;w
ψB − ψB n+1/3;w n+1/3;w
= −Ah2 (ψB ) + Cs2 (ψ n;w ) + Dsh2 (ψB )
∆t
(5.436)
n+2/3;w
ψBn+1;w − ψB n+2/3;w n+2/3;w
= −Ah1 (ψB ) + Cs1 (ψ n;w ) + Dsh1 (ψB )
∆t
(5.437)
• Updated value
1
ψ n+1;w = (ψAn+1;w + ψBn+1;w ) (5.438)
2
As before, the implicity factors are given by θa = 0.501, θv = 1.
where sijk and cijk are the sign and CFL number of the advecting current
vw
vw vijk ∆t
sijk = Sign(vijk ), cijk = v (5.450)
h2;ij
hc2;ij hc2;i,j−1
αij = , βij = (5.451)
hv2;ij hv2;ij
The form of the weighting function is given by (5.37)–(5.40), depending on
the type of advection scheme, selected by the switch iopt adv turb. The
argument r of the weight function is defined by
vw vw
vw (αij + sijk )∆Fi,j−1,k + (βij − sijk )∆Fi,j+1,k
rijk = vw
2∆Fijk
vw vw vw
∆Fijk = Flw;ijk − Fup;ijk (5.452)
c 1 c w w
Fup;ijk = ωijk (1 + sijk )ψijk + (1 − sijk )ψij,k+1 (5.455)
2
c 1 c
Fce;ijk = ω (ψ w + ψij,k+1
w
) (5.456)
2 ijk ij,k
where
c
sijk = Sign(ωijk ) (5.457)
The form of the weighting function is given by (5.37)–(5.40), depending on
the type of advection scheme, selected by the switch iopt adv scal. The ar-
gument r of the weight function is defined by
c c
w (1 + sijk )∆Fij,k−1 + (1 − sijk )∆Fij,k+1
rijk = c
2∆Fijk
c c c
∆Fijk = Fce;ijk − Fup;ijk (5.458)
5.6. TURBULENCE TRANSPORT EQUATIONS 225
uw λuw w w
H (ψijk − ψi−1,jk )
D1;ijk = (5.463)
hu1;ij
vw λvw w w
H (ψijk − ψi,j−1,k )
D2;ijk = (5.465)
hv2;ij
λψ;c w
(ψij,k+1 w
− ψijk )
c
D3;ijk = T c
(5.467)
h3;ijk
one has
P(k) = νT M 2 + λT N−2
5.6. TURBULENCE TRANSPORT EQUATIONS 227
ǫ
P(ε) = c1ε νT M 2 + c3ε λT N−2
k
1
P(kl) = l E1 νT M 2 + E3 λT N−2 (5.469)
2
and
S(k) = λT N+2 + ε
ε2
S(ε) = c1ε c3ε λT N+2 + c2ε
k
1
S(kl) = lE3 λT N+2 + ǫ0 k 3/2 W̃ (5.470)
2
The discretisation of M 2 , N±2 , νT and λT is discussed in Section 5.3.11.2.
Production terms are taken explicit in time using values of all quantities at
time tn . Sink terms are discretised quasi-implictly using (5.428):
k n+1
S(k) = (λT N+2 + εn )
kn
εn+1 εn εn+1
S(ε) = c1ε c3ε λT N+2 + c 2ε
εn kn
√
1 λT N+2 (kl)n+1 k n W̃
S(kl) = E 3 n + ǫ0 (5.471)
2 k ln
The flux at the first C-node below the surface is then determined by
interpolating the surface value and the calculated flux at the second
C-node below the surface
ψ;w
c 2hw c c
3;ijNz Fs;ij,Nz +1 + h3;ijNz D3;ij,Nz −1
D3;ijN =
z
2hw c
3;ijNz + h3;ijNz
ψ;w
2hw
3;ijNz Fs;ij,Nz +1 hc3;ijNz λψ;c w w
T ;ij,Nz −1 (ψijNz − ψij,Nz −1 )
= +
2hw c
3;ijNz + h3;ijNz hc3;ij,Nz −1 (2hw c
3;ijNz + h3;ijNz )
(5.473)
228 CHAPTER 5. NUMERICAL METHODS
Table 5.6: Discretisation schemes for each of the available surface and bottom
boundary conditions for turbulent variables.
variable equation discretisation scheme
k (4.269) Dirichlet at the surface
ε (4.269) Dirichlet at the first W-node below the surface
l (4.269) Dirichlet at the first W-node below the surface
k (4.271) prescribed flux at the surface
ε (4.272) prescribed flux at the first C-node below the surface
k (4.337) Dirichlet at the bottom
ε (4.337) Dirichlet at the first W-node above the sea bed
l (4.337) Dirichlet at the first W-node above the sea bed
k (4.338) prescribed flux at the bottom
ε (4.339) prescribed flux at the first C-node above the sea bed
with
w
3. Dirichlet condition with a prescribed value ψs;ij,N z +1
at the surface
w
ψij,Nz +1 = ψs;ij,N z +1
(5.476)
w
4. Dirichlet condition with a prescribed value ψs;ijN z
at the first W-node
below the surface
w
ψijNz = ψs;ijN z
(5.477)
In analogy with the scalar case two Neumann and two Dirichlet type of
bottom boundary conditions are available in the program.
ψ;w
1. Neumann condition with a prescribed flux Fb;ij1 at the bottom
w ψ;w
D3;ij1 = Fb;ij1 (5.478)
The flux at the first C-node above the sea bed is then determined by
interpolating the bottom value and the calculated flux at the second
C-node above the sea bed
ψ;w
c
2hw c c
3;ij2 Fb;ij + h3;ij1 D3;ij2
D3;ij1 =
2hw c
3;ij2 + h3;ij1
ψ;w
2hw3;ij2 Fb;ij hc3;ij1 λψ;c w w
T ;ij2 (ψij3 − ψij2 )
= +
2hw c
3;ij2 + h3;ij1 hc3;ij2 (2hw c
3;ij2 + h3;ij1 )
(5.479)
with
ψ;c
2. Neumann using a prescribed flux Fb;ij1 at the first C-node above the
bottom
c ψ;c
D3;ij1 = Fb;ij1 (5.481)
w
3. Dirichlet condition with a prescribed value ψb;ij1 at the bottom
w
ψij1 = ψb;ij1 (5.482)
w
4. Dirichlet condition with a prescribed value ψb;ij2 at the first W-node
above the bottom
w
ψij2 = ψb;ij2 (5.483)
1. Time derivative.
The contribution of the time derivative is given by
w
and sijk , rijk are defined by (5.457) and (5.458).
The terms arising from the flux above the k-level, are
a
Ak+ = 0
a
B k + = θa c +
k (1 + fk )
a+ +
Ck = θa ck (1 − fk )
a n;w n;w
Dk + = −(1 − θa )c+
k (1 + fk )ψk + (1 − fk )ψk+1
(5.489)
3. Vertical diffusion.
As for vertical advection the fluxes below and above a k-level are taken
separately. The former are given by
d ∆tλψ;c
Ak− = −θv c T ;k−1
h3;k−1 hw
3;k
d ∆tλψ;cT ;k−1
B k − = θv
hc3;k−1 hw3;k
d
Ck − = 0
d ∆tλψ;cT ;k−1
Dk− = −(1 − θv ) (ψkn;w − ψk−1
n;w
) (5.491)
hc3;k−1 hw3;k
where klo ≤ k ≤ kmax and klo equals 2 for a Dirichlet condition at the
bottom and 3 otherwise.
The terms taken from the flux above the k-level, are
d
Ak+ = 0
d ∆tλψ;c
Bk + = θv c Tw;k
h3;k h3;k
232 CHAPTER 5. NUMERICAL METHODS
d ∆tλψ;c T ;k
Ck + = −θv
hc3;k hw3;k
d ∆tλψ;cT ;k n;w
Dk+ = (1 − θv ) c w
(ψk+1 − ψkn;w ) (5.492)
h3;k h3;k
where kmin ≤ k ≤ kup and kup equals Nz for a Dirichlet condition at
the surface and Nz -1 otherwise.
4. Sink terms.
S(ψ n;w )k
ASk = CkS = DkS = 0 , BkS = (5.493)
ψkn;w
where kmin ≤ k ≤ kmax .
5. Other explicit terms.
All other terms are explicit. Their contributions can be written as
θv ∆thc3;Nz λψ;c
T ;Nz −1
AsNz = w
h3;Nz (2h3;Nz + h3;Nz ))hc3;Nz −1
w c
s θv ∆thc3;Nz λψ;c
T ;Nz −1
BN = − w
z
h3;Nz (2h3;Nz + h3;Nz ))hc3;Nz −1
w c
CNs z = 0
s ∆t
ψ;w
DN = 2Fs;N z +1
z
2hw
3;Nz + h c
3;Nz
ψ;c
• Neumann using a prescribed flux Fs;N z
at the first C-node below
the surface
ψ;c
∆tFs;N
AsNz = s
BN = CNs z = 0, s
DN = z
(5.496)
z z
hw
3;Nz
w
• Dirichlet condition with a prescribed value ψs;N z +1
at the surface
AsNz +1 = CNs z +1 = 0 , s
BN z +1
= 1, s
DN z +1
w
= ψs;N z +1
(5.497)
w
• Dirichlet condition with a prescribed value ψs;N z
at the first W-
node below the surface
AsNz = CNs z = 0 , s
BN z
= 1, s
DN z
w
= ψs;N z
(5.498)
7. Bottom boundary conditions.
Contributions from the bottom boundary conditions depends on the
type of condition as described in Section 5.6.6.2.
ψ;w
• Neumann condition with a prescribed bottom flux Fb;1 at the
bottom
Ab2 = 0
θv ∆thc3;1 λψ;c
T ;2
B2b = −
hw
3;2 (2h w
3;2 + h c c
3;1 ))h3;2
θv ∆thc3;1 λψ;c
T ;2
C2b =
hw
3;2 (2h w
3;2 + h c c
3;1 ))h3;2
∆t
ψ;w hc3;1 λψ;c
T ;2 (ψ3
n;w
− ψ2n;w )
D2b = − w 2Fb;1 + (1 − θv )
2h3;2 + hc3;1 hw c
3;2 h3;2
(5.499)
ψ;c
• Neumann using a prescribed flux Fb;1 at the first C-node above
the bottom
ψ;c
∆tFb;1
Ab2 = B2b = C2s = 0 , D2b = − (5.500)
hw
3;2
w
• Dirichlet condition with a prescribed value ψb;1 at the bottom
Ab1 = C1b = 0 , B1b = 1 , D1b = ψb;1
w
(5.501)
w
• Dirichlet condition with a prescribed value ψb;2 at the first W-node
above the bottom
Ab2 = C2b = 0 , B2b = 1 , D2b = ψb;2
w
(5.502)
234 CHAPTER 5. NUMERICAL METHODS
2. Momentum equations
ũp − un ∂ζ n+1
= f v n + θv Dmv (ũp ) + (1 − θv )Dmv (un ) − g + F1t;n+1
∆t ∂x
(5.503)
p n n+1
ṽ − v ∂ζ
= −f un + θv Dmv (ṽ p ) + (1 − θv )Dmv (v n ) − g + F2t;n+1
∆t ∂y
(5.504)
An implicit correction is added for the Coriolis force giving (up ,
v p ) by equations (5.9). “Corrected” values are obtained by
where the surface slopes and the elevations used to calculate the
vertical grid spacing hn+1
3;k = (h + ζ
n+1
)∆σk are prescribed exter-
nally by expressions of the form (4.273).
• The vertical diffusion terms and coefficients are discretised using
the formulations given in Sections 5.3.10 and 5.3.11.2.
• Once the currents are updated, the depth-mean currents u and v
are evaluated (for user output only).
3. Scalar equations
uf = u = U/H = u
vf = v = V /H = v (5.506)
2. Scalar equations
• Scalar transport is discretised in exactly the same way as in the
3-D case with the larger 3-D time step ∆t.
• The vertical diffusion term is retained and discretised using (5.388)
except that the upper and lower fluxes are located at the respec-
tively the surface and the bottom and therefore obtained by the
surface and bottom boundary conditions which must obviously be
of the Neumann type.
3. No turbulence transport equations need to be solved.
Note that
239
Chapter 6
• Basic aspects of the model code such as the principle of key ids, time
formats, data flags and the units of program variables are discussed in
Section 6.2.
241
242 CHAPTER 6. PROGRAM CONVENTIONS AND TECHNIQUES
• The column position is irrelevant. The adopted rule is that all pro-
gram lines start at column 1, with exceptions of statements within
control constructs such as IF blocks, DO loops and SELECT CASE
constructs, which are intended by one TAB position to the right.
Lines within a nested construct are intended with respect to the
previous one. For clarity no indentation is applied if the DO/ENDDO
statement of a nested loop is located just below/above the DO/ENDDO
of the parent loop. This is illustrated with the following example.
idesc 360: DO idesc=1,MaxIOTypes
ifil 360: DO ifil=1,MaxIOFiles
SELECT CASE (idesc)
CASE (io mppmod,io modgrd,io metgrd,io sstgrd,io biogrd,&
& io nstgrd,io biospc,io rlxobc,io nstspc)
modfiles(idesc,ifil,:)%nocoords = 0
CASE (io 1uvsur,io 2uvobc,io 3uvobc,io salobc,io tmpobc,&
& io bioobc)
IF (ifil.EQ.1) THEN
modfiles(idesc,ifil,:)%nocoords = 0
ELSE
modfiles(idesc,ifil,:)%nocoords = 1
ENDIF
CASE (io inicon,io 2uvnst,io 3uvnst,io salnst,io tmpnst,&
& io bionst,io metsur,io sstsur,io biosur)
modfiles(idesc,ifil,:)%nocoords = 1
END SELECT
ENDDO ifil 360
ENDDO idesc 360
• Although the free format allows line lengths upto 132 characters,
a length of 80 characters is taken for clarity since this is the maxi-
mum length on standard X-windows on UNIX/LINUX machines.
6.1. IMPLEMENTATION OF FORTRAN 90 243
Statements longer than this limit are continued on the next line
by appending a ‘&’ character at the end of the line and at the
start of the (possibly) intended line, as shown in Example 6.1.
• Comments lines start with a ‘!’ in the first column. Although
allowed by the FORTRAN 90 standard, the common practice is,
for reason of clarity, not to use comments after the first column
(i.e. in the middle of a line).
• Short statements may be written on one line by inserting a ‘;’
before each next statement.
• Statements labels always start at the first column.
4. The program uses explicit typing. This means that the type of each
variable, parameter or function result needs to declared explicitly in
the declaration part of a program unit. This part must be preceded by
the line:
IMPLICIT NONE
the second one, the values of the array expression on the right are as-
signed element-wise to the corrsponding elements of the array variable
on the left. The convention, adopted in COHERENS, is to use array
assignments where possible, e.g.
k 434: DO k=1,nz
WHERE (maskatc int)
psic A(1:ncloc,1:nrloc,k) = tridcfc(:,:,k,4)
END WHERE
ENDDO k 434
The array maskatc int is .TRUE. or .FALSE. for grid points located at
sea or on land and has the same shape as the array assignment(s) within
the WHERE block. In this way calculations are restricted to sea points
only.
7. Scalar and array variables must be initialised. More precisely, each
scalar or array element must have a value assigned to it, before it can
appear within an expression on the right of an assignment statement.
The standard initialisation value for variables which have no useful
default value is 0.0 for REAL, 0 for INTEGER, .FALSE. for LOGICAL
and ” (empty string) for CHARACTER variables. In this way a model
grid array is always defined at all grid points. Values at sea points
are usually re-defined within the program whereas values in land areas
remain equal to the initial (zero or .FALSE.) value.
8. As explained in Section 10.1, there are four types of program units:
main program, external routines, module routines and modules where
the main variables used in the program are declared. The following
rules are applied in the code:
6.1. IMPLEMENTATION OF FORTRAN 90 245
where name and dimids are the names of dummy optional argu-
ments.
• Module routines are declared in a sub-program with a USE state-
ment of the form given in Section 6.1.5.
• The last lines of a SUBROUTINE or FUNCTION consist of a RE-
TURN statement followed either by an empty line, one or more
specification or errror code lines, followed by a END proc name
statement where proc name is the name of the routine.
• Since all variables (scalars and arrays) are to be initialised, they
must be defined with a value before they can be used as an actual
argument with the INTENT(IN) or INTENT(INOUT) attribute.
This is of importance, since, for example, passing an undefined
value as argument in a read or MPI call may produce unexpected
side effects.
informs the routine error alloc that the variable ’depmeanatc’ is of type
REAL.
• COMPLEX variables are currently only used for fast Fourier analysis
(file fft library.f90).
Type declaration statements have the following general FORTRAN 90
syntax:
type [, att,...] :: var name
where
type : the data type of the variable
6.1. IMPLEMENTATION OF FORTRAN 90 247
att : one or more attribute(s) of the variable, which can take the following
forms
SAVE: the value of the variable is saved after the routines is exited
INTENT: used to declare dummy arguments only. Takes one of the
forms: INTENT(IN) if the actual argument is defined in the calling
routine and not re-defined in the called routine, INTENT(OUT) of
the variable is assumed to be undefined in the calling routine and
becomes defined within the called routine, INTENT(INOUT) if the
actual argument is defined in the calling routine and can be re-
defined in the called routine. Note that the INTENT attribute is
always given in declaration statements of dummy arguments (al-
though this is not required by the FORTRAN 90 standard).
DIMENSION: used to define the shape of an array variable. The array
shape is added in parentheses.
ALLOCATABLE: to declare an allocatable array (see Section 6.1.3)
PARAMETER: a named constant whose value cannot be changed by the
program
var name name of the variable
It is remarked that
• CHARACTER variables have an additional attribute LEN=len where len
is the length of the character string.
• Variables, sharing the same attributes are (preferentially) declared on
the same line.
248 CHAPTER 6. PROGRAM CONVENTIONS AND TECHNIQUES
For example
• In parallel mode, different bounds can be defined for the same array on
different process domains.
Disadvantages are:
6.1. IMPLEMENTATION OF FORTRAN 90 249
• Arrays, that have not been allocated yet, cannot be passed as argu-
ments to a routine call.
• Errors are difficult to debug. For example, it may occur that values are
assigned to an array which is allocated with a zero size. This causes a
memory fault which is often difficult to detect, since it usually causes
a crash at a different location within the program.
• Although this has not been observed from the performance tests per-
formed with COHERENS V2.0, an intensive use of allocation/deallocation
may decrease the performance of the program.
The error alloc routine is called by the program after each ALLOCATE state-
ment to check whether an allocation error occurred.
• “Global arrays”, i.e. arrays which are accessible to all program units
such as temperature, currents, . . . , are (almost) always declared with
the ALLOCATE and SAVE attribute2 . Note that in case of a parallel
mode, the shapes of model grid arrays depend on the size of the sub-
domain.
SUBROUTINE ....
!---declare
#ifdef ALLOC
REAL, SAVE, ALLOCATABLE, DIMENSION(:,:,:) :: source
#else
REAL, DIMENSION(ncloc,nrloc,nz) :: source
#endif /*ALLOC*/
...
!---allocate
#ifdef ALLOC
ALLOCATE (source(ncloc,nrloc,nz),STAT=errstat)
CALL error alloc(’source’,3,(/ncloc,nrloc,nz/),real_type)
#endif /*ALLOC*/
.....
!---deallocate
#ifdef ALLOC
DEALLOCATE (source)
#endif /*ALLOC*/
END SUBROUTINE
Example 6.5: allocation/deallocation of local arrays.
If the ALLOC option is set, the local array source is declared as ALLO-
CATABLE, allocated at the beginning of the routine and deallocated
before exiting the routine. Otherwise, it is declared as an automatic
array. The first case has to be taken if there is no sufficient mem-
ory available, the second if the allocation/deallocation procedures have
a negative impact on CPU time. The choice is obviously machine-
dependent.
TYPE :: VariableAtts
CHARACTER (LEN=lenname) :: f90 name
6.1. IMPLEMENTATION OF FORTRAN 90 251
• varatts%data type: the data type of the variable as given in the second
column of Table 6.1
• ...
TYPE :: FileParams
LOGICAL :: defined, info, opened, time regular
CHARACTER (LEN=1) :: form, status
CHARACTER (LEN=leniofile) :: filename, pathname
CHARACTER (LEN=lendesc) :: filedesc
INTEGER :: endfile, header type, iostat, iunit, lenrec, maxrecs, &
& nocoords, nodim, novars, timeid, timerec, tskips, &
& varid, zetaid
INTEGER, DIMENSION(3) :: tlims
END TYPE FileParams
!---open file
CALL open filepars(filepars)
The next example describes how the relative coordinates of a 2-D external
grid are obtained and stored. These type of coordinates are used to perform
interpolation of model data to each point of the data grid and are further
discussed in Sections 8.3 and 8.4.2. The following TYPEs are defined
!---attributes of surface grids
TYPE :: GridParams
6.1. IMPLEMENTATION OF FORTRAN 90 253
Assume that the external grid is rectangular with uniform grid spacings in
either direction. The grid can then be completely defined using the attributes
stored in a variable of type GridParams. In particular the attributes n1dat
and n2dat are the dimensions of the data grid in the X- and Y-direction.
The relative coordinates of each data point are stored in a 2-D array of type
HRelativeCoords using the following procedure
!---declare
TYPE (GridParams) :: surfacegrid
TYPE (HRelativeCoords), SAVE, ALLOCATABLE, DIMENSION(:,:) :: &
& gridcoords
!---define the external data grid
surfacegrid%n1dat = ...; surfacegrid%n2dat = ...
...
!---allocate
n1dat = surfacegrid%n1dat; n2dat = surfacegrid%n2dat
ALLOCATE (gridcoords(n1dat,n2dat),STAT=errstat)
6.1.5 Modules
Modules are program units which can be used within a FORTRAN 90 pro-
gram in two ways. Firstly, variables which need to be accessible in different
254 CHAPTER 6. PROGRAM CONVENTIONS AND TECHNIQUES
program routines can be declared within a module. These types are further
denored as “declaration modules”. In COHERENS V1, all variables with a
global scope were stored in a COMMON block located in a .inc file and are
made accessible with a INCLUDE statement. In COHERENS V2.0 there are
no COMMON blocks any more, since the declarations are made within a mo-
dule and become accessible to a program unit by putting the appropriate
USE statement.
As an example, the example below shows the declarations given in the
module currents for all arrays related to currents
MODULE currents
IMPLICIT NONE
SAVE
If one or more of these arrays are used in a program unit, a USE statement
must appear in the declaration part:
USE currents
Other types of application of the FORTRAN 90 module concept are the so-
called “module routines”. These routines have the same form and purpose as
the usual external SUBROUTINE and FUNCTION subprograms, except that:
where module name is the name of the module and routine name the name
of the (non)-generic routine. Consider the following example in the file
Grid Arrays.F90:
initialisation
• lines 99–101: write information to the log-file
• lines 102–121: allocate local arrays in case -DALLOC is defined.
Note that each ALLOCATE statement is checked for errors.
• lines 122–161: initialise parameters and arrays
main code
• lines 162–279: calculation of the vertical diffusion term in a scalar
transport equation (including boundary conditions)
finalisation
• lines 280–289: deallocation of local arrays if -DALLOC is defined.
• line 290: write information to the log-file
258 CHAPTER 6. PROGRAM CONVENTIONS AND TECHNIQUES
sectioning
The actual code, i.e. excluding the declaration part, is divided into
numbered sections, subsections, subsubsections. DO loop blocks within
one of these sections has a label composed of the name of the iteration
counter followed by , followed by the section number. An extra num-
ber is attached is there are more than one DO loops within a section,
subsection, . . . . For example the k-loop which starts on line 218, is the
second one in subsection 3.3 and has the label k 332.
6.1. IMPLEMENTATION OF FORTRAN 90 259
124:!-------------
125:!
126:!---fluxes
127:IF (iopt vdif impl.NE.2) THEN
128: WHERE (maskatc int)
129: difflux(:,:,1) = 0.0
130: difflux(:,:,nz+1) = 0.0
131: END WHERE
132:ENDIF
133:
134:!---work space arrays
135:WHERE (maskatc int)
136: array2dc1 = deptotatc(1:ncloc,1:nrloc)**2
137:END WHERE
138:k 201: DO k=2,nz
139: WHERE (maskatc int)
140: array3d(:,:,k) = vdifcoefatw(:,:,k)&
141: & /(array2dc1*delsatw(1:ncloc,1:nrloc,k))
142: END WHERE
143:ENDDO k 201
144:
145:IF (ibcsur.LE.2) THEN
146: WHERE (maskatc int)
147: array2dc2 = deptotatc(1:ncloc,1:nrloc)*delsatc(1:ncloc,1:nrloc,nz)
148: END WHERE
149:ENDIF
150:
151:IF (ibcbot.LE.2) THEN
152: WHERE (maskatc int)
153: array2dc3 = deptotatc(1:ncloc,1:nrloc)*delsatc(1:ncloc,1:nrloc,1)
154: END WHERE
155:ENDIF
156:
157:!---time factors
158:xexp = delt3d*(1.0-theta vdif)
159:ximp = delt3d*theta vdif
160:theta vdif1 = 1.0-theta vdif
161:
162:!
163:!3. Diffusion terms
164:!------------------
6.1. IMPLEMENTATION OF FORTRAN 90 263
165:!
166:
167:ivar 300: DO ivar=1,novars
168:
169:!
170:!3.1 Explicit fluxes
171:!-------------------
172:!
173:
174: IF (iopt vdif impl.NE.2) THEN
175: k 310: DO k=2,nz
176: WHERE (maskatc int)
177: difflux(:,:,k) = xexp*array3d(:,:,k)*&
178: & (psic(1:ncloc,1:nrloc,k,ivar)-&
179: & psic(1:ncloc,1:nrloc,k-1,ivar))
180: END WHERE
181: ENDDO k 310
182: ENDIF
183:
184:!
185:!3.2 Explicit terms
186:!-----------------
187:!
188:
189: IF (iopt vdif impl.NE.2) THEN
190: k 320: DO k=kbounds(1),kbounds(2)
191: WHERE (maskatc int)
192: tridcfc(:,:,k,4,ivar) = tridcfc(:,:,k,4,ivar) + &
193: & (difflux(:,:,k+1)-difflux(:,:,k))&
194: & /delsatc(1:ncloc,1:nrloc,k)
195: END WHERE
196: ENDDO k 320
197: ENDIF
198:
199:!
200:!3.3 Implicit terms
201:!------------------
202:!
203:
204: IF (iopt vdif impl.NE.0) THEN
205:
264 CHAPTER 6. PROGRAM CONVENTIONS AND TECHNIQUES
288:#endif /*ALLOC*/
289:
290:CALL log timer out(npcc,itm vdif)
291:
292:
293:RETURN
294:
295:END SUBROUTINE Zdif at C
Example 6.15: example layout and internal documentation of a COHERENS
routine.
MODULE density
!************************************************************************
!
! *density* Density arrays
!
! Author - Patrick Luyten
!
! Version - @(COHERENS)density.f90 V2.0
!
! Description -
!
!************************************************************************
!
IMPLICIT NONE
REAL, ALLOCATABLE, DIMENSION(:,:,:) :: beta sal, beta temp, dens, sal, temp
SAVE
!
! Name Type Purpose
!--------------------------------------------------------------------------
!*beta sal* REAL Salinity expansion coefficient [1/PSU]
!*beta temp*REAL Temperature expansion coefficient [1/deg C]
6.2. SPECIFIC PROGRAM FEATURES 267
• Examples
CHARACTER (LEN=lentime) :: CDateTime, CEndDateTime, &
& CStartDatetime
where the first variable represents the current date (updated at
each 2-D time step), the next two respectively the end and start
date of the simulation, defined by the user, e.g.
CStartDatetime = ’2009/06/15;05:09:00:000’
CEndDatetime = ’2009/07/01;15:45:06:000’
• These time formats are part of the model setup and are used to
calculate the solar altitude for evaluation of surface solar irradi-
ance and as date/time stamp in all time series input/output.
• Precision is 1 millisecond.
• The separators need to be at the correct positions, their values
are unimportant.
• Examples
INTEGER, DIMENSION(7) :: IDateTime, IEndDateTime, &
& IStartDatetime
which have the same meaning as above.
6.2. SPECIFIC PROGRAM FEATURES 269
• log file
- Writes “tracing” information during the simulation.
- Informs about progress of the run upto a user-defined level.
A zero level means that the log file is not created. Note that
this is the default setting.
- For parallel runs a log file can be created by each process.
- The utility is useful for debugging the model code or for trac-
ing errors in model setup.
• error file
- Writes error messages.
- If an error is detected by an error checking routine, an error
message is written. In most cases the program aborts immedi-
ately afterwards while in other cases several checks are made
before the program aborts.
- For parallel runs an error file is created by each process.
• warning file
- Writes “warning” messages about suspicious values of setup
parameters or variables.
- The program will not abort.
273
274 CHAPTER 7. MODEL INPUT AND OUTPUT
• timer report
This is a file with information about the total execution time and
the percentages of time spent by different model “compartments”
(e.g. advection, 2-D mode, I/O, parallel communications, ...).
• This is a file with a complete list of parameter values used for the
setup of the application. This includes all the parameters which
can be defined by the user in the routines
usrdef init params, usrdef mod params, usrdef tsr params,
usrdef avr params, usrdef anal freqs, usrdef anal params
For further details see Chapters 12 and 16.
• The file is created on request by the user and can be used as input
to the program in a subsequent run.
• If the CIF is used for input, the above routines are no longer called
by the program.
3. Forcing files
• Those files include data arrays used for model setup, e.g. model
grid data, type of open boundary conditions, initial conditions,
forcing data (open boundaries and meteorological). The files with
open boundary data for nested sub-grids also fall within this cat-
egory.
• All files are used as input to the model, except the open boundary
data files for nested sub-grids which are defined as output files.
• All input files may be given in any user-defined format, but can
optionally be converted to a COHERENS standard format. The
output files are always in COHERENS standard format. The for-
cing file can be made “virtual”, if the forcing data are directly
defined by the user without using an external data file.
• Output specifications are defined in the user-defined routines usrdef tsr params
for time series, usrdef avr params for time averaged and usrdef anal params,
usrdef anal freqs for harmonic data output.
title//’.’//filedesc//filenum//form//pid
for monitoring files, central input file(s) and forcing files, and
title//’_’//filenum//’.’//freqnum//filedesc//dim//form
for output files, where title is a simulation-specific title, filedesc the file de-
scriptor (representative for the type of the data in the file), filenum the file
number in case there is more than one file with the same descriptor, form
the format of the file, pid the process id number, dim the dimension of out-
put data and freqnum the frequency number. Values of these sub-strings are
discussed below.
7.2.1 title
Possible values are
runtitle Simulation title defined in defruns. This is the value used for moni-
toring files and CIF(s)(Categories 1 and 2).
intitle User-defined parameter used as prefix name for forcing files (Cate-
gory 3). Default value is runtitle.
outtitle User-defined parameter used as prefix name for user output files (Cat-
egory 4). Default value is runtitle.
7.2.2 pid
Process id number, used only for log and error files in parallel mode, empty
otherwise.
276 CHAPTER 7. MODEL INPUT AND OUTPUT
7.2.3 form
The file format can take the following values:
‘A’ ASCII format. This format is portable and readable but unsuitable for
large data sets because of its great comsumption of disk space and its
use of sequential storage.
‘U’ Unformatted binary format. Advantage is a more efficient use of disk
space. Disadvantages are that the file is (mainly) non-portable, not di-
rectly readable and uses sequential storage.
‘N’ NetCDF format (recommended). This format is portable, directly read-
able (with the netCDF ncdump utility). Data can be accessed directly by
specifying the appropriate record number. Only (possible) disadvantage
is that the netCDF library needs to be compiled first.
‘I’ This does not represent a specific data format but indicates that the
file is an ASCII information file containing the metadata of a forcing or
output data file.
Monitoring and central input files are always in ‘A’-format. Forcing and
output files may be in any of the first three formats.
7.2.4 filedesc
The string filedesc, further denoted as the “file descriptor”, is a character
string taking one of the values below.
1. Monitoring files
inilog log file with tracing information during the initialisation phase
of the simulation
runlog log file with tracing information during the main (time loop)
phase of the simulation
errlog error file
warlog warning file
timing timer report file
3. Forcing files. The string filedesc refers to the contents of the file.
7.2. DEFAULT FILE NAMES 277
4. Output files.
7.2.5 filenum
1. If the file descriptor equals 1uvsur, 2uvobc, 3uvobc, salobc or tmpobc,
the contents of the file depends on the value of filenum:
2. In case the file descriptor equals 2uvnst, 3uvnst, salnst or tmpnst, the file
contains nested data and filenum equals the number of the associated
sub-grid (between 1 and nonestsets).
3. In all other cases (including surface forcing data) the file number is not
used.
The maximum allowed file number is given by the system parameter Max-
IOFiles, defined in syspars.f90.
7.2.6 freqnum
Frequency number only used for output of amplitudes, phases and elliptic
parameters. Empty otherwise.
7.2.7 dim
The file dimension is only used for files of Category 4:
• A line starting with a number followed by ‘:’ and the name of a routine
means that the program entered this routine. The number denotes the
program routine level. Main program is at level 1, a routine called by
the main program has level 2, a routine called by another routine at
level n is at level n+1, . . . .
• The maximum number of levels traced by the log file, is defined by the
user. Note that large log files may be written if this maximum equals
or exceeds a value larger than 5. A value of 3 is recommended for
normal runs, a value of 7 if the log file is used for debugging. When the
program returns to the previous level (at the end of the called routine),
a line is written with the same level number followed by ‘:R’.
• Two separate log files can be written by the program: the inilog file
which traces information during the initialisation phase and is closed
when the program enters the time loop and the runlog file which is
active during the time loop only. The two program phases are discussed
in Section 10.2.
• If the maximum level for tracing is set to zero (default), no log file is
written.
– The tracing level of the inilog and runlog files. In parallel mode,
different values can be selected for different sub-domains. Note
that, by default, all levels are set to zero so that no log file is
created.
– The names of the log files. In parallel mode, all inilog or runlog
files have the same standard name (which can be redefined by the
user) appended by a suffix with the process id number.
– A number of time steps can be defined after which the runlog
file is overwritten. Default is the total number of time steps (i.e.
information is written at all time steps and the file is never over-
written).
280 CHAPTER 7. MODEL INPUT AND OUTPUT
3:R
3:deallocate mod arrays
3:R
2:End of simulation: fredyA
Close file fredyA.warlogA on unit 3 (A)
Close file fredyA.errlogA on unit 2 (A)
Close file fredyA.runlogA on unit 1 (A)
Example 7.1: Part of the runlog file written by running test case fredyA.
Tracer level is 3.
The tracing information in the log files is implemented within the code by
defining the name of the routine and calling the routine log timer in on entry
and log timer out just before exiting the routine, e.g.
The first line is the name of the routine which has been entered and will be
written to the log file. Routine log timer in sets the current program level by
increasing the counter pglev by 1 and writes the entry message. The call to
log timer out decreases pglev by 1. Note that if the first call is programmed
in the code, the second one must be inserted as well just before the RETURN
statement.
The first line gives a description of the error. When more than one error is
found, a message line is written for each error. The second line gives the name
of the routine where the error is found. The third line writes a message code
describing the general type of the error(s). Each message code is presented
in the program by a key id of the form ierrno *. A list of available key ids
is given in Table 7.1. The last line in example 7.2 is standard for all errlog
files.
The error code is programmed as follows:
• The number of detected errors is given by the parameter nerrs. Its
initial value is zero.
• A series of routines are implemented for checking setup variables. For
example, the model parameters, defined in
usrdef mod params, are checked in check mod params. These routines
are located in check model.f90 and fully described in Section 23.3. Er-
ror checking is also performed when a file is opened or closed, metadata
7.3. FORMATS OF MONITORING FILES 283
Table 7.1: Key ids for error coding and associated error messages.
key id message
ierrno fopen Not possible to open file
ierrno fclose Unable to close file
ierrno read Read error
ierrno write Write error
ierrno fend End of file condition
ierrno input Wrong input values
ierrno inival Invalid initial values for model parameters or arrays
ierrno runval Invalid values for variables at run time
ierrno alloc Not possible to allocate arrays
ierrno arg Missing or invalid argument in a routine call
ierrno comms Communication error
ierrno MPI Error in a MPI call
ierrno CDF Error in a netCDF call
• Within these “checking” routines, calls are made to one or more rou-
tines, defined in error routines.F90. For example, error limits var to
verify whether a switch has allowed values between certain limits. If
the routine detects an error, the error message is written and nerrs is
increased. These routines in error routines.f90 are fully described in
Section 23.8.
• The routine error abort is called with a typical error code, in the form of
a key id. If nerrs>0, lines 2–4 of the previous example are written with
an error message which corresponds to the given key id (see Table 7.1),
and the program aborts immediately afterwards. In parallel mode, the
error message will only be written by the processes where error(s) were
detected.
For example
...
CALL error limits var(dlat ref,’dlat ref’,-90.0,90.0)
...
CALL error abort(’check mod params’,ierrno inival)
Example 7.3: Excerpts of routine check mod params illustrating the use of
error coding.
The first four calls are error checking routines. The first tests whether nc is
positive, the second whether the switch iopt grid htype has a value between
1 and 3, the third whether the end date is later than the start date, the
fourth whether the reference latitude is between -900 and 900 . If a test turns
.FALSE., an error message is written. The routine error abort is called with
the key id ierrno inival, representative for invalid setup parameters.
• The name of the warning file. In parallel mode, only one file is permit-
ted, written by the master process.
Example 7.4: Contents of the warlog file produced by running test case
pycnoA.
7.3. FORMATS OF MONITORING FILES 285
• The name of the timer report file. In parallel mode, only one file is
permitted, written by the master process.
• The unit of time for writing the total execution can be written in sec-
onds, minutes, hours or days. Default is seconds.
The utility is useful for testing the CPU efficiency of a parallel decomposition.
An example of such test is given in Figure 9.1. Two examples are given below
using the same test case plumeC. The first shows the contents of the timer
report obtained from a serial run:
plume1C: 392s.822
Hydrodynamics : 39.152
2D mode : 12.125
3D mode : 27.939
Density : 26.150
Salinity : 22.338
Initialisation : 0.025
Transport : 50.284
Advection : 25.721
Horizontal diffusion: 13.541
Vertical diffusion : 18.450
Baroclinic pressure : 3.118
7.3. FORMATS OF MONITORING FILES 287
Input : 0.001
Output : 1.762
Input/output : 1.763
Array interpolation : 12.917
User calls : 14.979
Library calls : 4.284
Boundary conditions : 0.660
Example 7.5: Timer report for test case plumeC on a serial machine.
The second example is for the same test case now obtained on a parallel
machine with four processors and full timer information. For each timer
process there are now two lines. The first one gives statistical information
(maximum, minimum, mean and master). The second gives the times for
each individual processor. The report now contains additional information
about parallel communication calls, given by the compartments ‘Combine
comms’, ..., ‘MPI calls’. Note that the numbers given in ‘Parallel comms’ are
the sum of the corresponding ones for the combine, copy, exchange and utility
operations. This information is not given in the serial case since the times
related to parallel communications are, obviously zero, and zero times are
not printed in the table.
plume1C: 169s.783
Hydrodynamics : 44.064 44.009 44.037 44.044
44.044 44.064 44.009 44.039
2D mode : 18.971 18.889 18.939 19.172
19.172 18.958 18.889 18.971
3D mode : 25.648 25.584 25.620 25.568
25.568 25.648 25.584 25.627
Density : 27.339 27.210 27.285 27.176
27.176 27.339 27.210 27.306
Salinity : 23.711 23.659 23.677 23.677
23.677 23.711 23.659 23.660
Initialisation : 0.094 0.088 0.092 0.088
0.088 0.088 0.094 0.094
Transport : 45.924 45.189 45.574 45.046
45.046 45.189 45.610 45.924
Advection : 28.831 28.505 28.639 28.648
28.648 28.505 28.582 28.831
Horizontal diffusion: 12.218 11.796 12.077 12.074
12.074 11.796 12.218 12.216
288 CHAPTER 7. MODEL INPUT AND OUTPUT
Example 7.6: Timer report for test case plumeC on a parallel machine
with four processors.
stores the current clock count value of the processor clock in the optional
argument npcc. The value is obtained by calling the FORTRAN 90 intrinsic
routine SYSTEM CLOCK. The call to log timer out is made at the last line
of the subprogram. The routine calls SYSTEM CLOCK again and subtracts
the new clock count from the previous one. This gives the time spent in the
routine, measured in clock counts. The result is added to the value stored
in the corresponding element of the “timer” vector array. The array index is
given by the timer key id itm adv. At the end of the program the array values
are converted to seconds, divided by the total execution time and multiplied
by 100. This gives the computation times associated with different timer key
ids in percentage.
• If the variable is a derived type scalar variable, the data strings rep-
resent the components in the order given by the TYPE definition in
datatypes.f90. Derived type arrays are initialised element-wise, i.e. a
separate line for each array element. The first data string(s) are the
array indices of the first, . . . , last array dimension.
• The first array index for the variable modfiles (see Section 12.7) is not
given by a numeric value but by its file descriptor in string format, e.g.
the string modgrid corresponds to the key id io modgrd whose numeric
value is set by the program to 3.
• If a data string contains only blanks or equals the null string, the value
of the corresponding model parameter is undefined, in which case its
default value is retained. When the CIF is written by the program, all
variables (even defaults) are defined in the data strings.
• The characters in the string varname are case insentitive. If the CIF
is written by the program, the names are always given in upper case
characters.
• When a CIF is written by the program, all setup parameters are in-
cluded in the file. The values are either the default settings or the
re-defined values from a call to the appropriate usrdef routine or the
ones reset by the program after a call to a reset routine. Only excep-
tion to this rule is the parameter cold start which is always written as
.FALSE. and can only be changed by editing the CIF manually.
• A block may be empty but the separator lines must always be there.
This means that the file must contain 6 lines (including the last one)
starting with a ‘#’. An empty block is represented by two consecutive
separator lines.
• On the other hand, the above blocks may be non-empty even when the
appropriate switch is zero. In that case the input lines are read by the
program, but no assignment is made.
NORLXZONES = 0
NPROCS = 1
NPROCSX = 1
NPROCSY = 1
IDMASTER = 0
CSTARTDATETIME = 2003/01/03;00:00:00:000
CENDDATETIME = 2003/01/06;00:00:00:000
DELT2D = 30.
IC3D = 10
ICNODAL = 0
TIME_ZONE = 0.
NTOBCRLX = 0
ATMPRES REF = 101325.
BDRAGCOEF CST = 0.
BDRAGLIN = 0.
...
NCONOBC = 1
INDEX OBC = 46
NCONASTRO = 0
ALPHA BLACK = 0.2
ALPHA MA = 10.
ALPHA PP = 5.
BETA MA = 3.33
BETA XING = 2.
...
NORESTARTS = 1
NTRESTART = 8640
INTITLE = plume1A
OUTTITLE = plumeA
MAXWAITSECS = 3600
NOWAITSECS = 0
NRECUNIT = 4
NOSETSTSR = 4
NOSTATSTSR = 0
NOVARSTSR = 9
NOSETSAVR = 0
NOSTATSAVR = 0
NOVARSAVR = 0
NOSETSANAL = 1
NOFREQSANAL = 1
NOSTATSANAL = 0
294 CHAPTER 7. MODEL INPUT AND OUTPUT
NOVARSANAL = 7
MODFILES = inicon,1,1,U,R,plumeA.phsicsU,0,0,0,0,F,F,
MODFILES = modgrd,1,1,A,R,plumeA.modgrdA,0,0,0,0,F,F,
MODFILES = 2uvobc,1,1,U,R,plume1A.2uvobc1U,0,0,0,0,F,F,
MODFILES = 3uvobc,1,1,A,R,plume1A.3uvobc1A,0,0,0,0,F,F,
MODFILES = salobc,1,1,A,R,plume1A.salobc1A,0,0,0,0,F,F,
MODFILES = 2uvobc,2,1,U,R,plume1A.2uvobc2U,0,0,1,0,F,F,
MODFILES = 3uvobc,2,1,A,R,plume1A.3uvobc2A,0,0,1,0,F,F,
MODFILES = salobc,2,1,A,R,plume1A.salobc2A,0,0,1,0,F,F,
SURFACEGRIDS = 1,1,0,0,1000.,1000.,0.,0.
#
TSRVARS = 1,0,0,0,0,0.,C,width,Plume width,km,
TSRVARS = 2,0,0,0,0,0.,C,hfront,Plume length,km,
TSRVARS = 3,92,2,0,0,0.,C,umvel,X-component of depth-mean current,m/s,
Depth-mean current
TSRVARS = 4,101,2,0,0,0.,C,vmvel,Y-component of depth-mean current,m/s,
Depth-mean current
TSRVARS = 5,81,2,0,0,0.,C,zeta,Surface elevation,m,
TSRVARS = 6,93,3,0,0,0.,C,uvel,X-component of current,m/s,Current
TSRVARS = 7,102,3,0,0,0.,C,vvel,Y-component of current,m/s,Current
TSRVARS = 8,106,3,0,0,0.,C,wphys,Physical vertical velocity,m/s,
Physical current
TSRVARS = 9,111,3,0,0,0.,C,sal,Salinity,PSU,
IVARSTSR = 1,6,7,8,9
IVARSTSR = 2,6,7,8,9
IVARSTSR = 3,6,7,8,9
IVARSTSR = 4,1,2,3,4,5
TSR3D = 1,T,U,plumeA_1.tsout3U,T,,2
TSR3D = 2,T,U,plumeA_2.tsout3U,T,,2
TSR3D = 3,T,U,plumeA_3.tsout3U,T,,2
TSR0D = 4,T,A,plumeA_4.tsout0A,T,,2
TSR2D = 4,T,U,plumeA_4.tsout2U,T,,2
TSRGPARS = 1,T,F,F,F,2003/01/03;00:00:00:000,3,0,0,1,120,1,1,40,1,20,20,1,0,
8640,360
TSRGPARS = 2,T,F,F,F,2003/01/03;00:00:00:000,3,0,0,30,30,1,1,40,1,1,20,1,0,
8640,360
TSRGPARS = 3,T,F,F,F,2003/01/03;00:00:00:000,3,0,0,1,120,1,5,5,1,1,20,1,0,
8640,360
TSRGPARS = 4,T,F,F,F,2003/01/03;00:00:00:000,2,0,0,30,30,1,1,1,1,1,1,1,0,
8640,12
#
7.5. FORCING FILES 295
#
INDEX ANAL = 46
NOFREQSHARM = 1
IFREQSHARM = 1,1
#
ANALVARS = 1,92,2,0,0,0.,C,umvel,X-component of depth-mean,current,m/s,
Depth-mean current
ANALVARS = 2,101,2,0,0,0.,C,vmvel,Y-component of depth-mean,current,m/s,
Depth-mean current
ANALVARS = 3,81,2,0,0,0.,C,zeta,Surface elevation,m,
ANALVARS = 4,93,3,0,0,0.,C,uvel,X-component of current,m/s,Current
ANALVARS = 5,102,3,0,0,0.,C,vvel,Y-component of current,m/s,Current
ANALVARS = 6,106,3,0,0,0.,C,wphys,Physical vertical velocity,m/s,
Physical current
ANALVARS = 7,111,3,0,0,0.,C,sal,Salinity,PSU,
IVARSANAL = 1,1,2,3,4,5,6,7
IVARSELL = 1,1,10
IVECELL2D = 1,1,2
IVECELL3D = 1,1,2
RES2D = 1,T,A,plumeA_1.resid2A,T,,2
RES3D = 1,T,A,plumeA_1.resid3A,T,,2
AMP2D = 1,1,T,A,plumeA_1.1amplt2A,T,,2
PHA2D = 1,1,T,A,plumeA_1.1phase2A,T,,2
ELL2D = 1,1,T,A,plumeA_1.1ellip2A,T,,2
ELL3D = 1,1,T,A,plumeA_1.1ellip3A,T,,2
ANALGPARS = 1,T,F,F,F,2003/01/03;06:00:00:000,3,0,0,1,120,1,1,40,1,1,20,1,0,
8640,1440
#
Example 7.7: (Parts) of the CIF produced for test case plumeA.
2. Time series files provide forcing data at one or more specific times,
given as a sequence of time record(s).
• initial conditions1
• open boundary data
• 1-D water column forcing data
• 2-D and 3-D open boundary data written for nested sub-grids
• data defined on a 2-D external (meteorological, SST) grid.
• a data section with the values of the data. The time coordinate (if
present) is considered as an additional data variable.
The general structure of the file is then2
Attributes of variable n
[First data time]
Values of variables 1
...
Values of variables n
[Second data time
...]
The time coordinate and data time(s) need, obviously, only to be present
in case of time series files. Note that the data times must be stored in
chronological order, but may be given at non-regular time intervals. The
detailed formats of forcing files are discussed in the subsections below.
As mentioned in Section 6.1.4, the properties (or attributes) of data files
are stored into the derived type variable FileParams (see Example 6.7 for a
full list of file attributes). The attributes of the forcing files are stored into
the 3-D derived type array modfiles:
where
iddesc denotes the file descriptor key id. The program name of the key id has
the form io filedesc where filedesc is one of the descriptor strings given
in Section 7.2.4. For example, io 2uvobc is the key id for all forcing
files related to 2-D open boundary conditions.
ifil is the file number. In some cases, this number is always 1. For exam-
ple, the input data for defining the model grid are stored in one file
with key id io modgrd. On the other hand, if a main grid contains sev-
eral nested sub-grids, a data file has to be written for each requested
parameter and each sub-grid. The parameter is represented by its key
id, while the file number denotes the number of the sub-grid. A sim-
ilar approach is followed for open boundary data. For example, the
temperature profiles at open boundaries can be obtained from several
data files having the same key id io tmpobc.
298 CHAPTER 7. MODEL INPUT AND OUTPUT
iotype equals 1 for an input and 2 for an output file. All forcing files used by
the model are input files, except for the files written for sub-grid nest-
ing. However, the program provides the possibility to re-write the data
obtained from an input file to a separate output file in COHERENS
format. This is further discussed in Section 12.7.
In the current implementation, the global attributes of the files are defined
by components of the derived type variable modfiles and are given below. A
(∗ ) at the end of the description means that the attribute can be defined by
the user.
status∗ Status of the file
‘0’ : The file is not activated.
‘N’ : The file is activated but its contents are defined by the user
in a usrdef routine. The user needs to decide whether the
data are obtained from some external file or that the file only
exists virtually and the data are defined without making a
file connection. The option is only available for input files.
‘R’ : The file is activated and its contents are read from a data file
in COHERENS standard format. The option is only allowed
for input data (iotype=1).
‘W’: The data are written in COHERENS standard format. This
is always the case for nesting data. The option can be used
to re-write data, previously obtained in a user format. The
file can then be used in a subsequent simulation with the ‘R’
status. Since the file is created for output, the iotype index
must be 2.
form∗ Format of the data file.
‘A’: ASCII
‘U’: unformatted binary
‘N’: netCDF
filename∗ Name of the file. If the file status is ‘R’ or ‘W’ and the name of
the file is not defined by the user, a default name is given (see
Section 7.2). If the status is ‘N’, the name is either defined by
the user or unknown. In the latter case the file name is set to ‘N’
(unknown) which may mean that the data are not obtained from
a file.
info∗ An info (‘I’) file is produced with the metadata information only.
7.5. FORCING FILES 299
end type∗ Switch to decide what action needs to be taken when an end of file
condition occurs during a read. See Section 12.7.2 for details.
The variable attributes are stored into a temporary derived type array
where nocoords and novars are the global attributes stored in the modfiles
array. The following attributes are defined:
300 CHAPTER 7. MODEL INPUT AND OUTPUT
f90 name A string with the FORTRAN name of the variable as used in
the program. Maximum length is set by the system parameter
lenname.
long name A string with a description of the variable. Maximum length is
set by the system parameter lendesc.
vector name If the variable represents a vector component, a string with a
description of the vector. Its value must be the same for all
components of the same vector. Maximum length is set by the
system parameter lendesc.
units A string describing the variable’s unit. The string has a format
recognised by UNIDATA’s Udunits package (UDUNITS, 1997)
which can be considered as an internationally recognised stan-
dard. Maximum length is set by the system parameter lenunit.
data type The type of variable as given in the second column of Table 6.1
(e.g. real type for a REAL variable).
ivarid The variable’s key id.
nrank If the variable is an array, the rank of the array. Otherwise, the
variable is a scalar and the rank is zero.
shape If the variable is an array, a vector with the array size(s) in each
dimension. In case of a scalar the shape vector has one element
with the value 1.
Table 7.3: Data contents for each type of input forcing file. In the last column ‘R’,
‘I’, ‘C’, ‘D’ denote respectively real, integer, character and derived type data.
tke (1-nhalo:ncloc+nhalo,
1-nhalo:nrloc+nhalo,nz+1) R
zlmix (1-nhalo:ncloc+nhalo,
1-nhalo:nrloc+nhalo,nz+1) R
dissip (1-nhalo:ncloc+nhalo,
1-nhalo:nrloc+nhalo,nz+1) R
bdragcoefatc (0:ncloc,0:nrloc) R
zroughatc (0:ncloc,0:nrloc) R
fnode obc nconobc R
phase obc nconobc R
fnode astro nconastro R
phase astro nconastro R
obcsalatu (0:nobu,nz,0:2) R
obcsalatv (0:nobv,nz,0:2) R
obctmpatu (0:nobu,nz,0:2) R
obctmpatv (0:nobv,nz,0:2) R
obc2uvatu (nobu,2) R
obc2uvatv (nobv,2) R
obc3uvatu (nobu,nz,2) R
obc3uvatv (nobv,nz,2) R
io modgrd 1 gxcoordglb (nc,nr) R
gycoordglb (nc,nr) R
gscoordglb (nc-1,nr-1,nz+1) R
depmeanglb (nc-1,nr-1) R
iobu nobu I
jobu nobu I
iobv nobv I
jobv nobv I
io metgrd 1 xcoord (n1dat,n2dat) R
ycoord (n1dat,n2dat) R
or surfgridglb (nc,nr) D
io sstgrd 1 xcoord (n1dat,n2dat) R
ycoord (n1dat,n2dat) R
or surfgridglb (nc,nr) D
io nstgrd 1:nonestsets xcoord nhdat R
ycoord nhdat R
or hnests (nhdat,nonodes) D
zcoord (nhdat,nzdat) R
(Continued)
7.5. FORCING FILES 303
itypobv nobv I
iprofobv nobv I
noprofsd 2:nofiles I
indexprof (nobu+nobv,2:nofiles) I
iprofrlx norlxzones I
2:nofiles ciodatetime – C
psiprofdat (nz,numprofs,1) R
io tmpobc 1 itypobu nobu I
iprofobu nobu I
itypobv nobv I
iprofobv nobv I
noprofsd 2:nofiles I
indexprof (nobu+nobv,2:nofiles) I
iprofrlx norlxzones I
2:nofiles ciodatetime – C
psiprofdat (nz,numprofs,1) R
io rlxobc 1 inodesrlx 2 I
idirrlx norlxzones I
ityprlx norlxzones I
iposrlx norlxzones I
jposrlx norlxzones I
ncrlx norlxzones I
nrrlx norlxzones I
io nstspc 1 nestcoords nonestsets I
nohnstglbc nonestsets I
nohnstglbu nonestsets I
nohnstglbv nonestsets I
novnst nonestsets I
inst2dtype nonestsets I
io metsur 1 ciodatetime – C
surdata (n1dat,n2dat,novars) R
io sstsur 1 ciodatetime – C
surdata (n1dat,n2dat,1) R
7.5. FORCING FILES 305
1 : 1
2 :V2.0
3 :2010/06/17;09:22:34
4 :Type of open boundary conditions for 2-D mode
5 : 0
6 : 17
7 : 620 3 1 29
8 :ityp2dobu
9 :Type of 2-D open boundary condition at U-nodes
10:-
11: 607 3 1 29
12:iloczobu
13:Position of elevation points with respect to U-open boundaries
14:-
15: 616 3 1 29
16:itypintobu
17:Switch to allow momentum advection near U-open boundaries
18:-
19: 621 3 1 111
20:ityp2dobv
21:Type of 2-D open boundary condition at V-nodes
22:-
23: 608 3 1 111
24:iloczobv
25:Position of elevation points with respect to V-open boundaries
26:-
27: 617 3 1 111
28:itypintobv
29:Switch to allow momentum advection near V-open boundaries
30:-
31: 624 3 1 2
32:no2dobc
306 CHAPTER 7. MODEL INPUT AND OUTPUT
72:zetobv pha
73:Phase of surface elevation at V-open boundaries
74:m
ityp2dobu
11 11 ...
iloczobu
1 1 ...
itypintobu
0 0 ...
ityp2dobv
11 11 ...
iloczobv
1 1 ...
itypintobv
0 0 ...
no2dobc
127 13
iobc2dtype
1 3
index2dobc
1 2 ...
ud2obu amp
0.4421976 0.5311887 ...
zetobu amp
0.3082999E-01 0.3055999E-01 ...
ud2obu pha
4.054574 4.223073 ...
zetobu pha
5.249485 5.269729 ...
vd2obv amp
0.5446934 0.7153571 ...
zetobv amp
0.4053500E-01 0.3966500E-01 ...
vd2obv pha
2.541209 2.624729 ...
zetobv pha
0.2956865 0.3112219 ...
Example 7.9: Contents of the file nsp89.2uvobc1A in standard ASCII
COHERENS format.
header type the type of header which (in the current version) is
always 1 for a forcing file
coherens version the current program version number, which is the same
for all forcing files
creation date the exact date and time when the file was created
filedesc a description of the file
nocoords the number of coordinate variables (as defined in
modfiles)
novars the number of (non-coordinate) variables (as defined
in modfiles)
• In case of a time series file, the next four lines list the attributes of the
time coordinate (see Example 7.10).
• The remaining lines 7–74 show the attributes of the data variables.
– line 1: the attributes ivarid, data type, nrank, shape, giving 3+nrank
integer parameters on the input line
– line 2: the f90 name attribute
– line 3: the long name attribute
– line 4: the units attribute
• The data section gives the values of the variables in the order in whichv
they have been defined in the header section.
The contents of an ASCII forcing file are to be read sequentially, i.e. line
by line.
7.5. FORCING FILES 309
• The lines in the header either contain a character string or integer pa-
rameters which makes it easier to read them using the character (‘A’)
format (strings) or free (∗ ) format (integers). The header information
does not provide additional information for the program, since the at-
tributes are already known internally, but are used for error checking
only. For users who like to read the data from some external program,
the metadata provides useful information (number, rank and shape of
the data variables).
• The data values (except the date/time string in time series files) are
either of type INTEGER or REAL and are read in FORTRAN array order,
e.g.
IntegerFormat=’(50I11)’; RealFormat=’(50G16.7)’
It is advised not to change these values (except for the repeat specifi-
cation) since they allow to represent the data with the highest possible
precision.
1 : 1
2 :V2.0
3 :2010/06/17;09:22:34
4 :Meteo input surface data
5 : 1
6 : 7
7 : 952 1 2 23 -1
8 :time
9 :Time
10:date/time
11: 410 5 2 50 28
12:uwindatc
13:X-component of surface wind
14:m/s
15: 411 5 2 50 28
16:vwindatc
310 CHAPTER 7. MODEL INPUT AND OUTPUT
The program provides an utility (using the info file attribute) to view the
metadata contents of a binary file without additional programming tools.
If the info attribute is set to .TRUE., the program will create an additional
“info” file with all metadata information in ASCII. An example is given below
for the rhone test case.
header type: 1
coherens version: V2.0
creation date: 2010/06/18;16:49:53
file description: Model grid
nocoords: 0
novars: 6
32 5 1 31
gsigcoord
Sigma coordinates on uniform grid
-
105 5 2 108 50
depmeanglb
Global mean water depth at C-nodes
m
43 3 1 65
iobu
Global X-index of U-open boundaries
-
51 3 1 65
jobu
Global Y-index of U-open boundaries
-
45 3 1 110
iobv
Global X-index of V-open boundaries
-
53 3 1 110
jobv
Global Y-index of V-open boundaries
-
• An alias (starting with cf 90) is defined in the code for each netCDF
routine call (starting with NF90 ). The aim is a more efficient imple-
mentation of future netCDF versions.
ncdump file.cdf
ncdump -h file.cdf
ncdump -v var file.cdf
The first form rewrites the file file.cdf to standard output in ASCII
format. The second rewrites the metadata section only, the third form
rewrites the metadata section and the values of the variable var.
.
Example 7.12 shows the metadata file in CDL format of the initial con-
dition file for the North Sea case study. Differences with the ASCII a binary
formats are:
• The f90 name, nrank and shape attributes are no longer explicitly de-
fined, but provided implicitly when a netCDF variable is defined with
the NF 90 def var library call.
• Global attributes are the same as before except for the cdfversion at-
tribute giving the current netCDF version used by the model and the
timerec attribute giving the number of time records in the file.
Reading and writing of netCDF metadata and data is performed using the
routines of the netCDF library. A detailed description is found in the netCDF
FORTRAN 90 manual (Pincus and Rew, 2008).
netcdf nsp89
dimensions:
tlendim = 23 ;
T = UNLIMITED ; // (2 currently)
X002 = 141 ;
Y002 = 128 ;
...
Z020 = 2 ;
variables:
char time(T, tlendim) ;
time:ivarid = 952 ;
time:long name = "Time" ;
time:units = "date/time" ;
float udvel(T, Y002, X002) ;
udvel:ivarid = 157 ;
udvel:long name = "X-component of depth-integrated current" ;
udvel:units = "m^2/s" ;
float vdvel(T, Y003, X003) ;
vdvel:ivarid = 166 ;
vdvel:long name = "Y-component of depth-integrated current" ;
vdvel:units = "m^2/s" ;
float zeta(T, Y004, X004) ;
zeta:ivarid = 113 ;
zeta:long name = "Surface elevation" ;
zeta:units = "m" ;
float uvel(T, Z005, Y005, X005) ;
uvel:ivarid = 162 ;
uvel:long name = "X-component of current" ;
uvel:units = "m/s" ;
float vvel(T, Z006, Y006, X006) ;
7.5. FORCING FILES 315
vvel:ivarid = 171 ;
vvel:long name = "Y-component of current" ;
vvel:units = "m/s" ;
float wvel(T, Z007, Y007, X007) ;
wvel:ivarid = 176 ;
wvel:long name = "Transformed vertical velocity" ;
wvel:units = "m/s" ;
float temp(T, Z008, Y008, X008) ;
temp:ivarid = 205 ;
temp:long name = "Temperature" ;
temp:units = "degC" ;
float sal(T, Z009, Y009, X009) ;
sal:ivarid = 204 ;
sal:long name = "Salinity" ;
sal:units = "PSU" ;
float tke(T, Z010, Y010, X010) ;
tke:ivarid = 304 ;
tke:long name = "Turbulent kinetic energy" ;
tke:units = "J/kg" ;
float fnode obc(T, X011) ;
fnode obc:ivarid = 353 ;
fnode obc:long name = "Nodal factors of tidal constituents at open boundaries" ;
fnode obc:units = "-" ;
float phase obc(T, X012) ;
phase obc:ivarid = 360 ;
phase obc:long name = "Astronomical phases at open boundaries" ;
phase obc:units = "radian" ;
float obcsalatu(T, Z013, Y013, X013) ;
obcsalatu:ivarid = 625 ;
obcsalatu:long name = "Storage array for salinity at U-open boundaries" ;
obcsalatu:units = "PSU" ;
float obcsalatv(T, Z014, Y014, X014) ;
obcsalatv:ivarid = 626 ;
obcsalatv:long name = "Storage array for salinity at V-open boundaries" ;
obcsalatv:units = "PSU" ;
float obctmpatu(T, Z015, Y015, X015) ;
obctmpatu:ivarid = 627 ;
obctmpatu:long name = "Storage_array_for_temperature_at_U-open_boundaries" ;
obctmpatu:units = "degC" ;
float obctmpatv(T, Z016, Y016, X016) ;
obctmpatv:ivarid = 628 ;
316 CHAPTER 7. MODEL INPUT AND OUTPUT
// global attributes:
:header type = 1 ;
:coherens version = "V2.0" ;
:creation date = "2010/06/21;17:49:36" ;
:filedesc = "Physical initial conditions" ;
:cdfversion = "3̈.6.2¨ of" ;
:nocoords = 1 ;
:novars = 19 ;
:timerec = 2 ;
data:
time =
"1989/01/01;00:00:00,000",
"1989/12/25;00:00:00,000" ;
udvel =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.08447912, 0.3973033, 0, ...
vdvel =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
zeta =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.607709, 1.618565, 1.631894, 0, ...
uvel =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.006357468, 0.006396886, 0, ...
7.6. USER OUTPUT FILES 317
vvel =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
wvel =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
temp =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10.34, 10.34, 10.34, 0, 0, 0, ...
sal =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35.4, 35.4, 35.4, 0, 0, 0, 35.33, ...
tke =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.114186e-05, 5.660635e-06, ...
fnode obc =
1.165938, 1.165991, 1.10667, 0.9655771, 0.9624547, 0.9655771, ...
phase obc =
5.17733, 2.496852, 0.2368603, 5.49324, 5.436536, 2.75393, 3.223492, ...
obcsalatu =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
obcsalatv =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
obctmpatu =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
obctmpatv =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
obc2uvatu =
-20.18008, -20.35524, -18.70897, -17.60509, -17.31932, -16.37582, ...
obc2uvatv =
-0.6839569, 2.442981, 1.570055, 0.996551, 1.981653, 2.819804, ...
obc3uvatu =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
obc3uvatv =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
Example 7.12: Metadata of the initial condition file for the North Sea test
case in netCDF CDL format.
• 2-D file: 2-D (horizontal) data without a vertical dimension (e.g. water
levels)
• 3-D file: 3-D data having both horizontal and vertical dimensions
The attributes iunit, iostat, nocoords, novars and timeid are defined internally
and have the same meaning as for forcing files (see Section 7.5.1).
The user is free to choose the output grid which may be the full model
grid, a subsection of the model grid or a completely irregular grid as is the
7.6. USER OUTPUT FILES 319
case for data at station locations. In case of a 2-D or 3-D grid, the horizontal
grid may be taken as one point so that the 2-D data reduce to one data value
and the 3-D data to one vertical profile per variable and time step.
The attributes of the output grid are stored in a derived type variable
of TYPE(OutGridParams). The definitions of its attributes are given in Sec-
tion 16.1.1.3, but repeated here for clarity.
gridded If .TRUE. (default), the output data are defined on a sub-grid of
the model grid (or the whole model grid). If .FALSE., the data
are taken at a number of irregularly spaced locations (“station”
data) defined by the user.
grid file If .TRUE., the coordinates of the output grid will be written on
a separate output file. Otherwise, they are written within the
data file itself (default).
land mask A land mask will be applied if .TRUE. and gridded=.TRUE.. This
means that the gridded data will be stored as a vector excluding
land points. Advantage may be a significant reduction in disk
space. Disadvantage is that the data need to be restored on the
original output grid by a postprocessing program. Default is
.FALSE.
time grid If .TRUE., the data grid is taken as time-dependent (since the
vertical positions in a σ-grid depend on time). Surface elevations
will be written as an additional coordinate variable at each time
step. Default is .FALSE., in which case the vertical positions are
referred to the mean water level. This option is only available
for time series output.
time format Format of the time coordinate.
0: date/time in string format (default value)
1: seconds
2: minutes
3: hours
4: days
5: months
6: years
7: date in years
Cases 1-6 are numerical formats. Cases 0 and 7 are absolute
times, while the others are times relative to the reference date/time
refdate.
320 CHAPTER 7. MODEL INPUT AND OUTPUT
Attributes of variables and coordinate arrays of the output grid are stored
in a derived type variable of TYPE(VariableAtts) (see Section 7.5.1). The
program makes distinction between two types of variables:
The procedures for defining time series output can be summarised as follows.
2. Define the attributes of all variables used for time series output. At-
tributes can be automatically generated if the ivarid attribute is defined
by the user.
• Select which files are to be written (0-D, 2-D, 3-D) using the define
attribute.
• Define the file attributes form, filename, info, header type. Defaults
are available.
• Select the variables for each output file.
• Define the attributes of the output grid. Defaults are available.
The procedures for time averaged output are the same, except that an
averaging period needs to be defined instead of an output time interval.
For harmonic output additional parameters need to be defined. Assume
then that N frequencies are selected within one set. The following output
files may be defined within that set:
• In the case of a 2-D output only xout, yout, depout and time are in-
cluded.
• Elevation data are only included if the user selects a time varying 3-D
output grid using the time grid attribute.
The first four arrays have no associated time dimension. The last two are
stored within the file in chronological order at regular time intervals. In the
ASCII and unformatted binary format, storage is sequential. In the netCDF
format, data are stored with increasing record numbers at subsequent times.
1 : 2
2 :V2.0
3 :2010/06/23;12:19:42
4 :Time series data: plume1A
5 : 3
6 :F
7 : T F F
8 : 0 1 1
9 : 1 40 20 0 0 25
10: 10800.00
324 CHAPTER 7. MODEL INPUT AND OUTPUT
11:2003/01/03;00:00:00,000
12:2003/01/06;00:00:00,000
13:2003/01/03;00:00:00,000
14: 0
15: 5
16: 5
17: 4
18: 957 5 2 1 40
19:xout
20:X-coordinate
21: m
22: 962 5 2 1 40
23:yout
24:Y-coordinate
25: m
26: 968 5 3 1 40 20
27:zout
28:Z-coordinate
29: m
30: 951 5 2 1 40
31:depout
32:Mean water depth
33: m
34: 952 5 2 23 25
35:time
36:Time
37: date/time
38: 162 5 4 1 40 20 25
39:uvel
40:X-component of current
41:m/s
42:Current
43: 171 5 4 1 40 20 25
44:vvel
45:Y-component of current
46:m/s
47:Current
48: 175 5 4 1 40 20 25
49:wphys
50:Physical vertical velocity
51:m/s
7.6. USER OUTPUT FILES 325
52:Physical current
53: 204 5 4 1 40 20 25
54:sal
55:Salinity
56:PSU
57:
[xout]
29500.00 29500.00 ...
[yout]
500.0000 1500.000 ...
[zout]
-19.50000 -19.50000 ...
[depout]
20.00000 20.00000 ...
2003/01/03;00:00:00,000
[uvel]
-0.2228398 -0.2281678 ...
[vvel]
-0.8393249E-02 -0.1428325E-01 ...
[wphys]
0.000000 0.000000 ...
[sal]
33.00000 33.00000 ...
2003/01/03;03:00:00,000
...
Example 7.14: Contents of the output data file plumeA 2.tsout3A from the
plume test case.
• Line 2: the coherens version attribute with the currently used COHERENS
version.
• Line 3: the creation date giving the exact date and time when the file
was created.
• Line 5: the nodim attribute giving the spatial dimension of the output
grid.
326 CHAPTER 7. MODEL INPUT AND OUTPUT
• Line 6: the grid file attribute. If .TRUE. (.FALSE.), grid data and
metadata are (are not) written to a separate data file.
• Line 8: values of the switches of iopt grid sph, iopt grid htype and
iopt grid vtype which define the type of grid (see Section 12.4.1).
• Line 9: the attributes ncout, nrout, nzout, which define the size of the
output grid (gridded case), nowetout, giving the number of sea points in
the output grid (if the land mask attribute is .TRUE., zero otherwise),
nostats (the number of stations in the non-gridded case) and nstepout
(number of time records).
• Line 15: the nocoords attribute giving the number of grid coordinates.
• Line 16: the timeid attribute giving the variable id of the time coordi-
nate. This attribute is only used for reading the time coordinate in a
netCDF file.
• In case of a time varying grid (only), the zetaid attribute giving the vari-
able id of the zetout coordinate, used for reading the surface elevation
coordinate in a netCDF file.
• Line 17: the novars attribute giving the number of data variables.
• In case of station data, the labels and names of the stations are written
on subsequent lines with one line per station.
• Lines: 18-37: attributes of each coordinate variable using four lines per
variable.
• Lines 38–57: attributes of each data variable using five lines per variable
• The total number of header lines in the current example is then given
by 17+4*nocoords+5*novars.
• The remaining lines in the example form the data section, which is
composed of two parts:
– The first part lists (if the time grid attribute is .TRUE.) the values
of the time-independent coordinate arrays, preceded by an empty
line and written in the same order as defined in the header.
– The second lists (if the time grid attribute is .TRUE.) the values of
the time-dependent coordinate arrays (and data variables in the
following order:
∗ time coordinate
∗ zetout variable (if time grid is .TRUE. and preceded by an
empty line)
∗ values of each data variable in the same order as defined in
the header. Each variable list is preceded by an empty line.
∗ For clarity, the name of the variable is substituted in [ ] within
the example.
328 CHAPTER 7. MODEL INPUT AND OUTPUT
The contents of an ASCII forcing file are to be read sequentially, i.e. line
by line.
• The parameters listed on each line all have the same data type (except
for the station parameters) which makes it easy to read them using
the character (‘A’) format (strings) or in free (∗ ) format (integer, real,
logical data).
• The data values (except the date/time string if the time coordinate is
given in a non-numeric format) are all of type REAL, read in FORTRAN
array order. Format specifications are the same as for forcing files (see
Section 7.5.3.1), i.e. ‘(A)’ for the date/time string and RealFormat for
the other variables.
If grid file is set to .TRUE., all coordinate information and data are moved
to a separate grid file (i.e. lines 7–16, 18–37 and the values of the coordinate
arrays).
The next example is a 0-D output file from the test case fredyA.
2
V2.0
2010/06/24;14:07:32
Time series data: fredyA
0
F
T F F
0 1 1
0 0 0 0 0 865
600.0000
2003/01/01;00:00:00,000
2003/01/07;00:00:00,000
2003/01/01;00:00:00,000
0
1
1
8
952 5 2 23 865
time
Time
date/time
7.6. USER OUTPUT FILES 329
0 5 1 60
ekin
Kinetic energy
GJ
0 5 1 60
epot
Available potential energy
GJ
0 5 1 60
theta
Energy ratio
0 5 1 60
enstr
Enstrophy
m^3/s^2
0 5 1 60
a1pt
A1%
10^8 m^2
0 5 1 60
salmin
Minimum salinity
PSU
0 5 1 60
salmax
Maximum salinity
PSU
0 5 1 60
smean
Mean salinity deviation
PSU
2003/01/01;00:00:00,000
330 CHAPTER 7. MODEL INPUT AND OUTPUT
• The ivarid attribute is zero for all data variables. This means that the
f90 name, long name and units attributes are non-standard and defined
by the user.
netcdf plumeA 1
dimensions:
xdim = 120 ;
ydim = 40 ;
zdim = 20 ;
tlendim = 23 ;
tdim = UNLIMITED ; // (6 currently)
variables:
float xout(ydim, xdim) ;
xout:ivarid = 957 ;
xout:long name = "X-coordinate" ;
xout:units = "m" ;
float yout(ydim, xdim) ;
yout:ivarid = 962 ;
yout:long name = "Y-coordinate" ;
yout:units = "m" ;
float zout(zdim, ydim, xdim) ;
zout:ivarid = 968 ;
zout:long name = "Z-coordinate" ;
zout:units = "m" ;
float depout(ydim, xdim) ;
depout:ivarid = 951 ;
depout:long name = "Mean water depth" ;
depout:units = "m" ;
char time(tdim, tlendim) ;
time:ivarid = 952 ;
time:long name = "Time" ;
time:units = "date/time" ;
float ellmin3d(tdim, zdim, ydim, xdim) ;
ellmin3d:ivarid = 0 ;
ellmin3d:long name = "M2-Ellipticity" ;
ellmin3d:units = "-" ;
ellmin3d:vector name = "_" ;
// global attributes:
:header type = 2 ;
:coherens version = "V2.0" ;
:creation date = "2010/06/23;12:19:42" ;
:filedesc = "Elliptic parameters" ;
:cdfversion = "3̈.6.2¨ of" ;
:iopt CDF fill = 0 ;
332 CHAPTER 7. MODEL INPUT AND OUTPUT
:grid dimension = 3 ;
:grid file = 0 ;
:gridded = 1 ;
:land mask = 0 ;
:time grid = 0 ;
:grid type = 0, 1, 1 ;
:dimensions = 120, 40, 20, 0, 0, 6 ;
:time step = 43200.f ;
:startdate = "2003/01/03;06:00:00,000" ;
:enddate = "2003/01/05;18:00:00,000" ;
:refdate = "2003/01/03;06:00:00,000" ;
:time format = 0 ;
:nocoords = 5 ;
:timeid = 5 ;
:novars = 1 ;
:timerec = 6 ;
data:
xout =
500, 1500, ...
yout =
500, 500, ...
zout =
-19.5, -19.5, ...
depout =
20, 20, ...
time =
"2003/01/03;06:00:00,000",
"2003/01/03;18:00:00,000",
"2003/01/04;06:00:00,000",
"2003/01/04;18:00:00,000",
"2003/01/05;06:00:00,000",
"2003/01/05;18:00:00,000" ;
ellmin3d =
0.03929285, 0.03556633, ...
-0.1459797, -0.1480648, -0.1499712, -0.1511258, -0.1511276, -0.1443668 ;
7.6. USER OUTPUT FILES 333
Example 7.16: Contents of the output data file plumeA 1.ellip3N from the
plumeA test case.
The attributes are similar to the ones listed in the ASCII format. Some are
defined with a different name (e.g. the dimensions attribute which combines
the values of the previous parameters ncout, nrout, nzout, nowetout, nostats,
nstepout into one vector). Other attributes are defined implicitly such as
f90 name, nrank and shape. The timerec giving the current number of (time)
records and cdfversion with the current version of netCDF, do not exist in the
ASCII and unformatted binary formats.
The second example is the same as Example 7.17 now given in CDL
format.
netcdf fredyA 2
dimensions:
tlendim = 23 ;
tdim = UNLIMITED ; // (865 currently)
variables:
char time(tdim, tlendim) ;
time:ivarid = 952 ;
time:long name = "Time" ;
time:units = "date/time" ;
float ekin(tdim) ;
ekin:ivarid = 0 ;
ekin:long name = "Kinetic energy" ;
ekin:units = "GJ" ;
ekin:vector name = "_" ;
float epot(tdim) ;
epot:ivarid = 0 ;
epot:long name = "Available potential energy" ;
epot:units = "GJ" ;
epot:vector name = "_" ;
float theta(tdim) ;
theta:ivarid = 0 ;
theta:long name = "Energy ratio" ;
theta:units = "_" ;
theta:vector name = "_" ;
float enstr(tdim) ;
enstr:ivarid = 0 ;
enstr:long name = "Enstrophy" ;
334 CHAPTER 7. MODEL INPUT AND OUTPUT
enstr:units = "m^3/s^2" ;
enstr:vector name = "_" ;
float a1pt(tdim) ;
a1pt:ivarid = 0 ;
a1pt:long name = "A1%" ;
a1pt:units = "10^8_m^2" ;
a1pt:vector name = "_" ;
float salmin(tdim) ;
salmin:ivarid = 0 ;
salmin:long name = "Minimum salinity" ;
salmin:units = "PSU" ;
salmin:vector name = "_" ;
float salmax(tdim) ;
salmax:ivarid = 0 ;
salmax:long name = "Maximum salinity" ;
salmax:units = "PSU" ;
salmax:vector name = "_" ;
float smean(tdim) ;
smean:ivarid = 0 ;
smean:long name = "Mean salinity deviation" ;
smean:units = "PSU" ;
smean:vector name = "_" ;
// global attributes:
:header type = 2 ;
:coherens version = "V2.0" ;
:creation date = "2010/06/24;09:55:22" ;
:filedesc = "Time series data: fredyA" ;
:cdfversion = "3̈.6.2¨ of" ;
:iopt CDF fill = 0 ;
:grid dimension = 0 ;
:grid file = 0 ;
:gridded = 1 ;
:land mask = 0 ;
:time grid = 0 ;
:grid type = 0, 1, 1 ;
:dimensions = 0, 0, 0, 0, 0, 865 ;
:time step = 600.f ;
:startdate = "2003/01/01;00:00:00,000" ;
:enddate = "2003/01/07;00:00:00,000" ;
:refdate = "2003/01/01;00:00:00,000" ;
7.6. USER OUTPUT FILES 335
:time format = 0 ;
:nocoords = 1 ;
:timeid = 1 ;
:novars = 8 ;
:timerec = 865 ;
data:
time =
"2003/01/01;00:00:00,000",
...
"2003/01/07;00:00:00,000" ;
Example 7.17: Contents of fredyA 2.tsout0N output data file from the
fredyA test case in CDL format.
Contrary to the ASCII case, a separate netCDF call has to be made to read
each of the 0-D output data, i.e. the data are not stored in vector form but
as separate records in the netCDF file.
336 CHAPTER 7. MODEL INPUT AND OUTPUT
Chapter 8
1. The parallel code is based upon non-shared memory between the pro-
cesses. This means that model grid arrays are only defined locally. The
local array shape then depends on the dimensions of the local process
domains. The local dimensions in the X- and Y-direction are given by
the process-dependent parameters ncloc and nrloc, whereas the vertical
dimension is still given by nz.
337
338 CHAPTER 8. MODEL GRID AND SPATIAL INTERPOLATION
The first array has a full size halo of two rows and columns in each direction,
the second a halo of one row and column in each direction, the third a one
column halo attached on its western boundary, whereas the last one is defined
without halo.
In Section 5.2.1 it was explained that the last array column at the eastern
boundary and the last row at the northern boundary of the computational
grid consist of dummy land points. Important to note that this is mostly
not the case for local array definitions, i.e. the horizontal grid points with
index (ncloc,j) and i,nrloc are physical points unless one of the edges of the
sub-domain extends into one of these two dummy boundary areas.
Local arrays usually have no global equivalent in the program. However,
in case that a global array has to be defined, then it must be declared, for
consistency, with the same halo sizes as its local equivalent. For example,
the arrays
gxcoord(0:ncloc+1,0:nrloc+1), gxcoordglb(0:nc+1,0:nr+1)
are the local and global representations of the same array.
A more detailed account of parallel grids is presented in Chapter 9.
• The bounds of the global array are obtained from the local one by
replacing (nc,nr) with (ncloc,nrloc).
The locations of the X- and Y-open boundaries are defined within the pro-
gram and do not need to be supplied by the user.
A list of all grid parameters and arrays is given in Table 8.2.
• Local (global) means that the parameter or array is defined on the local
sub-domain (global computational grid). In case of a serial application,
local and global definitions coincide (e.g. nosbuloc=nosbu).
• The bounds of the global array are obtained from the local one by
replacing the local dimension by the global one (e.g. nobuloc by nobu).
0: dry (land) cell face or bottom cell (1) or surface cell (nz+1)
1: coastal boundary
2: interior wet UW-node
3: open sea boundary
4: river open boundary
0: dry (land) cell face or bottom cell (1) or surface cell (nz+1)
1: coastal boundary
2: interior wet VW-node
3: open sea boundary
4: river open boundary
• The values of the pointer arrays are obtained from the bathymetry
(zero water depths at land, positive depths at sea) and the positions of
the open boundaries as given by the user.
• Model grid arrays are undefined at land points. Land mask can be used
to eliminate these points from the interpolation.
U to C interpolation C to U interpolation
W(i−1,j,k+1) W(i,j,k+1)
Y Z
1/2 1/2
C(i−1,j−1) C(i,j−1)
W(i−1,j,k) W(i,j,k)
X X
C to UV interpolation W to U interpolation
Examples
1. interpolation from U- to C-node:
1
X c (i, j) = (X u (i, j) + X u (i + 1, j)) (8.5)
2
2. (non-uniform) interpolation from C- to U-node:
w(i, j)X c (i − 1, j) + w(i − 1, j)X c (i, j)
X u (i, j) =
w(i − 1, j) + w(i, j)
1 c
w(i, j) = h (i, j) (8.6)
2 1
8.2. INTERPOLATION OF MODEL ARRAYS AT A DIFFERENT NODE 347
where sn equals 0 for flagged and 1 for non-flagged grid points. The program
foresees the following options
1: Land cells and cell faces at or near coastal boundaries (except open sea
boundaries) are flagged.
348 CHAPTER 8. MODEL GRID AND SPATIAL INTERPOLATION
2: Land cells and cell faces at or near coastal boundaries (including open
boundaries) are flagged.
3: Only cell faces at open sea boundaries are flagged (allowing the inclu-
sion of coastal boundaries in the interpolation).
ξ2
(i,j)
(1,1)
(0,0) ξ1
(i,j+1) (i+1,j+1)
(i,j) (i+1,j)
x
Figure 8.3: Interpolation of external data to the model grid. The solid
(dashed) lines represent the external (model) grid.
• The model points are principally taken at C-nodes, although the method
can be applied to other nodes as well.
• The weight factors in (8.11) only depend on the locations of the external
grid and do not take account of possible land points, which should be
excluded from the interpolation. The following options are available:
8.4.2 Implementation
The method can currently be applied for interpolation of surface meteoro-
logical data or (satellite) surface temperature data. Future extensions are
planned for surface wave data.
As a first step the type of the 2-D external data grid is defined via the
following derived type definition:
TYPE :: GridParams
INTEGER :: nhtype, n1dat, n2dat
REAL :: delxdat, delydat, x0dat, y0dat
END TYPE GridParams
where
nhtype Type of the surface data grid.
0: single grid point
1: uniform rectangular grid
2: non-uniform rectangular grid
3: non-rectangular (curvilinear or non-structured) grid
4: the same as the model grid
n1dat number of grid cells in the X-direction
n2dat number of grid cells in the Y-direction
delxdat grid spacings in the X-direction (m or fractional degrees longitude)
when nhtype=1
delydat grid spacings in the Y-direction (m or fractional degrees latitude)
when nhtype=1
x0dat X-coordinate (Cartesian or longitude) of the lower left corner when
nhtype=1
y0dat Y-coordinate (Cartesian or latitude) of the lower left corner when
nhtype=1
Note that nhtype has to be supplied always if the value is different from its
default one (0). The n1dat, n2dat attributes have to be given if nhtype> 0.
All surface grid attributes are stored into the array surfacegrids
TYPE (GridParams), DIMENSION(MaxGridTypes,2) :: surfacegrids
where MaxGridTypes is the maximum number of external grids. A key id of
the form igrd * is used as index for the first dimension. The following values
are currently implemented
352 CHAPTER 8. MODEL GRID AND SPATIAL INTERPOLATION
1. The following parameters are defined by the user in usrdef mod params:
• Set the appropriate switch which is iopt meteo for meteo input or
iopt temp sbc for SST input.
• Define the attributes of the external grid(s) in surfacegrids.
• The attributes of the following files have or may be defined:
modfiles(io metgrd,1,1): grid locations of the meteorological grid
in case nhtype>1
modfiles(io sstgrd,1,1) : grid locations of the SST grid in case nhtype>1
modfiles(io metsur,1,1) : meteorological data file
modfiles(io sstsur,1,1) : SST data file
2. If nhtype>0, define the locations of the external grid. Two options are
available depending on the value of nhtype:
3. Define data input by calling the user-defined routines usrdef surface data.
Note that a usrdef * routine is not called if the corresponding status attribute
of the associated file is set to ‘R’ in which case a corrsponding read * routine
is called where the data are read from a file in standard COHERENS format.
Detailed descriptions of the procedures are given in Chapter 12 and Sec-
tion 15.2.
main grid
subgrid
C−node subgrid
U−node subgrid
V−node subgrid
Figure 8.4: Illustration of the nesting procedure in the horizontal plane. Solid
lines mark the main (coarser) grid, dashed lines the (finer) sub-grids. The
empty circles and (light colour) line segments mark the points on the main
grid used in the interpolation, the filled circles and (thick) line segments the
points on the sub-grid to which interpolation needs to be performed.
j, x, y) where k is the vertical index level of the W-, UW- or VW-node point
just below the data point at the which interpolation has to be performed
and z is (here) the normalised vertical distance (between 0 and 1) to the W-,
UW-, VW-node level. The definition is illustrated in Figure 8.5.
nz+1 surface
1 bottom
8.5.2 Implementation
The program provides the following derive type definition for storing vertical
relative coordinates
TYPE :: VRelativeCoords
INTEGER :: kcoord
REAL :: zcoord
END TYPE VRelativeCoords
Details of the code implementation are more complex than the ones in Sec-
tion 8.4.2. To simplify the discussion below, it is assumed that the program
is set up in serial mode.
1. The following parameters are defined by the user in usrdef mod params:
• The program switch iopt nests is set to 1.
• The parameter nonestsets is set to the number of nested sub-grids.
• The attributes of the following files have or may be defined:
modfiles(io nstspc,1,1) parameters to be defined in usrdef nstgrd spec
modfiles(io nstgrd,1:nonestsets,1) locations of the sub-grid open boun-
dary points in absolute or relative coordi-
nates for each sub-grid
modfiles(io 2uvnst,1:nonestsets,2) output data files with interpo-
lated values of U , V , ζ for each sub-grid
modfiles(io 3uvnst,1:nonestsets,2) output data files with interpo-
lated values of δu, δv
modfiles(io salnst,1:nonestsets,2) output data files with interpolated
values of S
modfiles(io tmpnst,1:nonestsets,2) output data files with interpo-
lated values of T
Note that output will be written only when the status attribute of
the respective output data file is set to ’W’.
2. The following arrays are defined in usrdef nstgrd spec
The first three arrays represent, for each sub-grid, the number of sub-
grid open boundary points at C-, U- and V-nodes. The last gives the
number of vertical levels for each sub-grid.
358 CHAPTER 8. MODEL GRID AND SPATIAL INTERPOLATION
3. The locations of the open boundary locations are determined for each
sub-grid. The relative coordinates for each type of interpolation are
stored in the following derived type arrays
where
These locations are to be defined in the user. Two options are available:
• The user supplies, within usrdef nstgrd abs, the horizontal posi-
tions in absolute (geographical) and the vertical positions, taken
as the positive distance from the mean sea level. The relative
coordinate arrays hnstctoc, . . . , vnstvtov are determined by the
program.
• The user supplies, within usrdef nstgrd rel, the horizontal positions
in relative coordinates and the vertical positions, taken as the po-
sitive distance from the mean sea level. The horizontal coordinates
are stored in hnstctoc, hnstctou, hnstctov, hnstutou, hnstvtov, the
vertical relative coordinates are calculated by the program and
stored in vnstctoc, vnstutou, vnstvtov.
where
5. Model data are interpolated and written to the appropriate output file.
Time resolution is determined by the tlims file attribute.
Note that a usrdef * routine is not called if the corresponding status attribute
of the associated file is set to ‘R’ in which case a corrsponding read * routine
is called where the data are read from a file in standard COHERENS format.
Detailed descriptions of the procedures are given in Chapter 12 and Sec-
tion 15.3.
360 CHAPTER 8. MODEL GRID AND SPATIAL INTERPOLATION
Chapter 9
Aspects of parallellisation
Advantages are:
• Land areas can be removed from the global domain by taking a suffi-
ciently large number of processes.
Disadvantages are:
• Increasing Np decreases the work load per process but increases the
number of communications and % of time spent in communications. A
maximum effficiency will be attained when Np = Nmax depending on
the application. The effect is illustrated in Figure 9.1.
361
362 CHAPTER 9. ASPECTS OF PARALLELLISATION
14
12
10
serial/parallel CPU time
8 OPTOS-CSM
OPTOS-NOS
OPTOS-BCZ
0
0 5 10 15 20
Number of processes
Figure 9.1: CPU efficiency, defined as the CPU time for a serial run di-
vided by the one obtained for the parallel run, as function of the number of
processes for the three optos test cases.
MPI routine calls are only found in the file comms MPI.F90 1 . Each
MPI routine call (starting with MPI ) has a corresponding alias (starting
with comms ). This allows a more efficient implementation of future MPI
versions.
1
Sole exception is the MPI abort call in error routines.F90. Since MPI is based upon
FORTRAN 77, MPI parameters are declared and defined in an “include” file instead of a
module file. Instead of a USE a INCLUDE mpif.h statement has to be made inside the
code, contrary to the programming rules stated in Section 6.1.1. This will be removed in
future MPI implementations.
9.2. DOMAIN DECOMPOSITION 363
local either defined on each sub-domain but with different values or defined
on one or more (but not all) sub-domains
A specific aspect of parallellisation is that different effects are or may be
procuced by the model code on different domains:
• A variable may be defined on one and non-defined on another domain.
not allowed !
• The local grid dimensions are now ncloc and nrloc, instead of nc and
nr.
• The most eastern column and most northern row are no longer com-
posed of dummy land points (except when they are located at the edges
of the global computational domain).
The local grid dimensions and indices are related to the global ones
through the following definitions:
9.2. DOMAIN DECOMPOSITION 365
Figure 9.3: Domain decomposition for the North Sea area with 128 processes
based on a 10×19 domain grid.
ξ2
nrloc
1
0 1
0 1
0 1
0 1
0 11
00 00
11 00
11 11
00 00
11
0
1 0
1 0
1 0
1 0
1
0 11
00
00 00
11
00 11
00
11 11
00
00 00
11
0
1 0
1 0
1 0
1 1 11 11 00 11 00
11
1
0 1
0 1
0 1
0 1
0
0 00
11
00 11
00
11 00
11
00 11
00
11 11
00
0
1 0
1 0
1 0
1 1 11 00 11 00 00
11
1
0 1
0 1
0 1
0 1
0
0 00
11
00 11
00
11 00
11
00 11
00
11 11
00
0
1 0
1 0
1 0
1 1 11 00 11 00 00
11
1
0 1
0 1
0 1
0 1
0
0 00
11
00 11
00
11 00
11
00 11
00
11 11
00
0
1 0
1 0
1 0
1 1 11 00 11 00 00
11
1
0 1
0 1
0 1
0 1
0
0 00
11
00 11
00
11 00
11
00 11
00
11 11
00
0
1 0
1 0
1 0
1 1 11 00 11 00 00
11
3
1
0 1
0 1
0 1
0 1
0
0 00
11
00 11
00
11 00
11
00 11
00
11 11
00
0
1 0
1 0
1 0
1 1 11 00 11 00 00
11
2
1
0 1
0 1
0 1
0 1
0
0 00
11
00 11
00
11 00
11
00 11
00
11 11
00
0
1 0
1 0
1 0
1 1 11 00 11 00 00
11
1
1
0 1
0 1
0 1
0 1
0
0 00
11
00 11
00
11 00
11
00 11
00
11 11
00
0
1 0
1 0
1 0
1 1 11 00 11 00 00
11
1 2 3 ncloc
ξ1
9.3 Halos
Numerical discretisations in the horizontal and horizontal averaging may re-
quire the availability of values of a model grid array located at grid points
within a neighbouring sub-domain. These values are calculated, not inside
the domain itself, but within its neighbours. They are obtained by estab-
lishing MPI communications between the domain and its neighbours. Each
of its neighbours sends an internal section of the array which is received and
stored by the domain in one of the local array’s halo sections (see Figure 9.5
and Figure 9.6).
A halo is created by adding extra columns and rows to the model array.
Most arrays have halo sizes which are all equal to the parameter nhalo = 2,
e.g.
uvel(1-nhalo:ncloc+nhalo,1-nhalo:nrloc+nhalo,nz)
Other arrays may have smaller halos or asymmetric halos, e.g.
368 CHAPTER 9. ASPECTS OF PARALLELLISATION
gxcoord(0:ncloc+1,0:nrloc+1), atmpres(0:ncloc,0:nrloc)
Halo sizes of a model array are the same on all sub-domains. The cor-
responding global arrays (i.e. defined over the whole domain) are declared
with the same halo sizes as their local counterparts. Halos of sub-domains
which are located at the edge of the (full) computational domain, extend to
the outside of the computational domain. These outside points are taken as
dummy land points belonging to a dummy outside sub-domain with NULL
process id.
9.4 Communications
9.4.1 Send and receive in MPI
A MPI communication consist of a send operation on one process (say A)
and a receive operation on another process (say B). COHERENS uses only
so-called “blocking” send and receive operations. The implementation in
COHERENS is based upon the following communication modes:
9.4. COMMUNICATIONS 369
1. Synchronous send.
2. Bufffered send.
3. Standard send.
In the COHERENS code, send and receive operations are performed using the
comms send * and comms recv * routines defined in comms MPI.F90.
• Copies (the same) data from a root (usually the master) process
to all other processes.
• The operation involves Np −1 sends from the root and 1 receive at
each other process.
• This is called a “one-to-all” operation and therefore asymmetric.
9.4. COMMUNICATIONS 371
• Used to copy data read by the root process from a data file (not
needed if shared read = .TRUE.).
2. Distribute operations.
3. Combine operations.
4. Combine-all operations.
372 CHAPTER 9. ASPECTS OF PARALLELLISATION
• The same as the combine operation except that the global data
are made available to all processes.
• The operation involves Np −1 sends and Np −1 receives on each
process.
• This is called a “all-to-all” operation and therefore symmetric.
Note that work load is (about) the same for each sub-domain so
that the CPU time for a combine-all is about the same as for a
corresponding combine operation.
5. Exchange operations.
• Stores all local arrays into one global array with an extra dimen-
sion of size nprocs.
• The operation involves Np −1 sends and Np −1 receives on each
domain.
• This is a “all-to-all” operation and therefore symmetric.
• The operation is not frequently used.
Remarks:
• The root process is by default the master process.
• The communication routines are programmed using the MPI send and
MPI recv routines either in standard or synchronous mode.
9.4. COMMUNICATIONS 373
• There are options to use MPI collective calls instead for some opera-
tions: MPI bcast for copy and MPI allgather for collect operations.
9.4.3 Implementation
The main difficulty in programming MPI communications is to prevent so-
called dead locks, i.e. a send/receive operation cannot terminate because one
of the processes is engaged in another communication which cannot terminate
as well and so on. The problem does not arise for the asymmetric “one-to-all”
and “all-to-one” operations since each process is engaged in either a send or
a receive operation but not both. The problem is more severe for “all-to-all”
and exchange operations. Implementation of these two type of operations is
discussed below.
where each column (except the first) is obtained by shifting the previous one
donwwards by 1 position. The first column represents the type and order of
the communications performed by process 0, the second by process 1 and so
on. The numbers present the kind of the operations to be performed:
0: The process “communicates” with itself, the local data are stored di-
rectly into the global array.
374 CHAPTER 9. ASPECTS OF PARALLELLISATION
1: Send operation.
2: Receive operation.
R3 R3 R3 −1
where the first column aplies to process 0, the second column to process 1
and so on. The numbers 0 and -1 have the same meaning as before, Si means
send to process i and Ri receive from process i. For example, process 2 (third
column) performs the following operations : receive from process 0, receive
from 1, internal storage, send to 3, send to 0, send to 1, nothing, receive
from 3. It can easily be shown that the order of communications, defined
in this way, can never produce a dead lock, since for each send/receive the
destination/source process will always be available to receive/send the data.
The actual number of communications depends on the sizes of the halo. For
example, an array with halo size (0,2,2,2) has no western halo so that steps
3, 4, 11, 12, 13, 14 become unnecessary. There is also an option foreseen in
the exchange call to skip all corner communications (steps 9 to 16).
1 2
1
3
2
3
1
4
2
2 5
3 1
Figure 9.8: Example of index mapping between global and local arrays.
There are 6 data points in total of which 3 are located in the domain
with process number 1, 2 in domain 2, 1 in domain 3 and none in domain
9.5. LOCAL VERSUS GLOBAL ARRAY INDEXING 377
4. The 3 elements of domain 1 map into elements (2,3,5) of the global array,
the 2 elements of domain 2 into (1,4), the element from domain 3 into global
element 6. No mapping is obviously needed for domain 4. The mapping can
be programmed as follows
nostatsglb = 6
nostatsprocs = (/3,2,1,0/)
iproc 110: DO iproc = 1,nprocs
IF (idloc.EQ.idprocs(iproc)) THEN
nostatsloc = nostatsprocs(iproc)
ENDIF
ENDDO iproc 110
maxstats = MAXVAL(nostatsprocs)
ALLOCATE (lstatsprocs(nprocs,maxstats))
lstatsprocs(1,1:3) = (/2,3,5/)
lstatsprocs(2,1:2) = (/1,4/)
lstatsprocs(3,1) = 6
where nostatsloc, nostatsglb are the local and global number of data points,
nostatsprocs an array with the number of data points per process and lstat-
sprocs the array defining the index mapping. If, for example, the data points
represent stations used for output, the local data must be combined first into
the global array using the index mapping array. The situation is more com-
plex in practice since the number of points per domain are unknown initially.
Usually, these points have corresponding geographical positions which allows
to determine their distribution over the different sub-domains.
The second example is related to the indexing of open boundary locations.
The following definitions are made
nobu number of global U-open boundary points (global)
nobuloc number of local U-open boundary points (local)
westobu(nobu) .TRUE. (.FALSE.) for U-open boundary points
at western (eastern) boundaries (global)
iobuloc(nobuloc) local X-index of U-open boundary points on the
local grid (local)
jobuloc(nobuloc) local Y-index of U-open boundary points on the
local grid (local)
378 CHAPTER 9. ASPECTS OF PARALLELLISATION
The parameter nobuloc and the last 3 arrays are defined in routine
open boundary arrays (file Grid Arrays.F90). Consider the following code
Index mapping is used in the program for local versus global indexing of:
• Files with suffix .f90 are FORTRAN source code files, files with .F90
are FORTRAN files containing C-language code (#ifdef) statements.
• Files whose name start with a lower case character and include no
underscore character, contain “declaration modules” with declarations
of variables and arrays as described in Section 6.1.5.
• Files whose name start with a lower case character and include an
underscore character, contain module routines, as described in Sec-
tion 6.1.5. The routines are often generic and of a general nature.
• Files whose name start with an upper case character (except Usrdef *
files) are external subprograms with “actual” code.
• Files whose name start with Usrdef , contain routines for user setup.
(The ones in the source directory are empty and intended for proper
compilation only, user-defined versions are defined elsewhere).
379
380 CHAPTER 10. STRUCTURE OF THE MODEL CODE
• The second (inner) loop within the smaller rectangle denotes the time-
stepping.
initialise MPI
End of File
read title
Structure of the physical model
initialise model
meteorological
meteorological
data
data
surface elevation
optical module
density
bottom stress gradients
solar radiation
advection−diffusion
module
finalise model
finalise MPI
exit
outside the outer loop. This means that, although multiple simulations can
be performed within one run, they must all be conducted either in serial or
in parallel mode.
The advection-diffusion module forms the central “core” part of the time-
loop section. The module is coded in a generic way and solves the advective-
diffusive transport equations of any scalar variable, 3-D and 2-D currents,
and turbulence tranport equations. The inputs for the routine are prepared
in separate routines for each variable (temperature, salinity, 3-D currents,
2-D currents, turbulent energy, . . . ) and are composed of source terms, open
boundary and surface forcing data. The boundary data are obtained via
general routine calls. For example, there is one program module (discussed
10.2. STRUCTURE DIAGRAMS 385
in Section 10.2.4 below) dealing with reading and updating of open boundary
profile data for any 3-D quantity.
8. Type and form of open boundary conditions for the 2-D mode (Sec-
tion 14.1.1), baroclinic currents and 3-D scalars (Section 14.2.1).
10. Parameters for setting up user defined output (see Chapter 16).
Open boundary and surface forcing data are usually given as time series.
If the first data time coincides with the initial time, the data file is opened and
the first and (eventually second) time records are read from the file during the
initialisation phase of the program. This has the further advantage that error
checking can be performed (existence of the file, data formats, ...) before the
program enters the time loop.
Each section of the initialisation contains (or may contain) the following
sub-tasks:
main section
• update open boundary data
• apply open boundary conditions
• apply surface and bottom boundary conditions (3-D variables only)
• calculate source terms
• solve the transport equations by calling the appropriate transport
routine
• exchange array sections with neighbouring sub-domains (parallel
mode only)
• write interpolated data for nested sub-grids (if requested)
• The 3-D current calculations are split over two routines called at diffe-
rent (predictor and corrector) time steps: surface and bottom boundary
conditions are applied, source terms calculated and transport equations
solved in current pred; open boundary conditions and corrector step are
applied, vertical currents calculated and nested output written in cur-
rent corr.
• Meteorological forcing data are defined by a separate call to meteo input
from the main program.
The update of a 2-D or 3-D quantity is performed by one of the trans-
port at * routines, which integrate the model equations in time. Exceptions
are surface elevation and vertical current which are obtained from the 2-D
and 3-D continuity equations. The procedures closely follow the numerical
descriptions given in Chapter 5 so that no diagrams need to be given here.
• The new data (if any), representing the ψ0e term in equation (4.340),
are stored in the appropriate open boundary arrays and interpo-
lated in time (if requested).
• Harmonic tidal expansions are evaluated. If needed (which is
usually the case at the initial time), astronomical arguments and
nodal factors are calculated by calling astro params. The harmonic
terms are added to the data values.
2. The open boundary conditions are applied by calling open boundary conds 2d.
1. At the initial time the routine define profobc spec is called from the
“main” routine (current corr, temperature equation, . . . ):
• It is checked first for each data file, whether the data are still up
to date, which means that the last date and time for which data
are available is later than the current one. If this is not the case
(such as at the initial time), define profobc data is called where:
– New data are obtained by calling either the user-defined rou-
tine usrdef profobc data or as input from a standard COHERENS
file by calling read profobc data. If requested, the arrays are
written to a standard file by calling write profobc data.
– If an end of file condition occurs, further action is deter-
mined by the endfile attribute. This is further discussed in
Section 12.7.2.
• The new data (if any) are stored in the appropriate open boundary
profile arrays and interpolated in time (if requested).
390 CHAPTER 10. STRUCTURE OF THE MODEL CODE
3. The open boundary conditions are applied by calling open boundary conds 3d
for baroclinic currents or open boundary conds prof for scalars.
User-defined setup for baroclinic open boundary conditions is further dis-
cussed in Section 14.2.
The application of 2-D external data requires firstly the definition of the
data grid, which is implemented as follows (no diagram shown):
1. A derived type “grid” array is created by allocation in the “main”
routine (meteo input for the meteo or temperature equation for the SST
grid), for storing the relative coordinates of the data grid with respect
to the model grid (see Section 6.1.4).
2. The grid is defined by calling define surface input grid. Definition de-
pends on the value nhtype grid attribute (see Section 8.4.2):
routines can be used for meteorological, SST, wave, . . . data. The routine
update surface data is called from the “main” routine (meteo input for the
meteo or temperature equation for the SST grid):
1. It is checked first for each data file, whether the data are still up to date,
which means that the last date and time for which data are available is
later than the current one. If this is not the case (such as at the initial
time), define surface data is called where:
• All files, which are still open with exception of monitoring files, are
closed.
• A new input line is read from the defruns file. If there is an end of
file condition, the program checks whether MPI was switched on at
the start, finalises MPI if needed and terminates. Otherwise, a new
392 CHAPTER 10. STRUCTURE OF THE MODEL CODE
simulation starts and all model parameters and arrays are reset to
their default values as part of the re-initialisation procedures discussed
in Section 10.2.2.
10.2. STRUCTURE DIAGRAMS 393
Model initialisation
domain decomposition
communication parameters default read, usrdef, write check
equation of state
astronomical tides
time loop
nt = 0
nt = nt+1
update_time
meteo_input
nt−1 multiple of ic3d
predictor store_old_depths
step
mask_function
equation_of_state
vertical_diff_coefs
baroclinic_gradient
horizontal_diff_coefs
current_2d
nt multiple of ic3d
corrector temperature_equation
step
salinity_equation
user output
final conditions
nt < nstep
current_2d
initialise
atmospheric pressure
surface slope
baroclinic pressure
bottom stress
surface stress
coriolis (explicit)
coriolis (implicit)
exchange_mod exchange
mean currents
finalise
exit
Figure 10.4: Diagram of routine current 2d which solves the 2-D mode equa-
tions.
396 CHAPTER 10. STRUCTURE OF THE MODEL CODE
current_pred current_corr
initialise yes
nt=0
atmospheric pressure
define open boundary define_profobc_spec
surface slope conditions
no
baroclinic pressure sub−grid data update_nest_data_3d
corrector scheme
coriolis (implicit)
relaxation_at_U
exchange_mod exchange relaxation scheme relaxation_at_V
transf_vertical_current
vertical current transf_physical_current
exchange_mod
finalise
exit
Figure 10.5: Diagrams of the routines current pred and current corr which
solve the 3-D momentum equation at the predictor and corrector step.
10.2. STRUCTURE DIAGRAMS 397
temperature_equation salinity_equation
yes yes
nt=0 nt=0
first open boundary data update_profobc_data first open boundary data update_profobc_data
no
update open boundary data update_profobc_data update open boundary data update_profobc_data
impose lower
solve transport limit
equations transport_at_C_3d
exchange exchange_mod
exchange exchange_mod
sub−grid data update_nest_data_prof
sub−grid data update_nest_data_prof
finalise
finalise
exit
exit
update_2dobc_data
allocate/initialise
no
check update yes check latest yes define new data read, usrdef, write
time data time
no
no
time interpolation
finalise
exit
Figure 10.7: Diagrams of the routines used for defining and updating 2-D
open boundary conditions and data.
define_profobc_data
initialise
check update check latest define new data read, usrdef, write
time data time
define
read_profobc_spec usrdef_profobc_spec
time interpolation
reset
check
copy copy_vars
exit
Figure 10.8: Diagrams of the routines used for defining and updating 3-D
open boundary conditions and data.
10.2. STRUCTURE DIAGRAMS 399
update_surface_data
yes yes
check update check latest define new data read, usrdef, write
time data time
no
no
time interpolation
space interpolation
exit
Figure 10.9: Diagram of the routines used for defining and updating data
from an external 2-D grid.
400 CHAPTER 10. STRUCTURE OF THE MODEL CODE
Part IV
User manual
401
Chapter 11
Introduction
This part of the documentation explains how model setup is defined for a
user application. As explained in Section 2.6 a number of Usrdef files with
FORTRAN 90 code need to created by the user. These files provide the
following information to the program:
• values of an extensive series of model parameters (settings for monitor-
ing files, parallel setup, switches, time parameters, physical parameters,
definition of parameters for model forcing)
• model grid and bathymetry
• initial conditions
• open boundary conditions and input of open boundary data
• surface forcing grids and input of forcing data
• location of sub-grids for nesting
• definition of parameters and variables for creating time series and time-
averaged output
• definition of parameters and variables for performing harmonic analysis
and output of residuals, amplitudes, phases and elliptic parameters
• user-formatted output
All this information has to be defined within specific usrdef routines, located
in one of the Usrdef files. A complete listing of all usrdef routines is given
in Table 11.1.
Writing these usrdef routines from scratch may be a big task, especially
for a beginning user. The next alternative procedures can be followed.
403
404 CHAPTER 11. INTRODUCTION
2. A second way for making a setup is to copy a Usrdef file from one of
the test cases defined in a setups directory and make the necessary
adaptations.
3. Use can be made of the CIF utility, in which case all parameters needed
for model setup (excluding forcing data) and user-defined output are
obtained from a central input file. An option is foreseen to create a
CIF by the program. For details see Sections 7.4 and 12.1.
4. Once a setup has been created, all forcing data (e.g. bathymetry, me-
teorological data,. . . ) can be written to a number of files in standard
COHERENS format. These files can be used in subsequent simulations
for model setup. This requires only to change a few options in the pro-
gram so that the usrdef routines are no longer called by the program.
3. Standard output variables are selected through their key id (see Chap-
ter 16)
Table 11.1: Overview of all Usrdef files and usrdef routines in the program.
Table 11.2: List of usrdef routines which have a related read and write
routine for reading from or writing to a file in standard COHERENS format.
Control parameters
The parameters, discussed in this chapter (except the first section), are de-
fined in the following routines of the file Usrdef Model.f90:
• usrdef init params: setup of monitoring parameters (Section 12.2)
409
410 CHAPTER 12. CONTROL PARAMETERS
Defaults are taken (except for runtitle which must always be given) when the
value is an empty string, one blank or several blanks. All blanks are ignored
on the input line.
Consider the following example
conesA,,
conesA,R,
conesA,W,myciffile
In the example the first line initiates the run conesA without CIF, the second
one reads the setup from the file conesA.cifmodA, the third writes the CIF
data to the file myciffile.
Lines can be commented if the first character is a ‘!’. This replaces, for
compatibility with the CIF syntax below, the ‘#’ character used in previous
versions.
The procedure is used to combine multiple simulations within one run:
4. When the simulation ends, a next line is read giving a new title and a
next simulation initiates.
5. When there are no more lines to be read, the file is closed and the
program terminates.
• nprocsx and nprocsy are needed by the program for making a “simple”
domain decomposition when the switch iopt MPI partit = 1. Otherwise,
if iopt MPI partit=2, these parameters are determined by the program.
In case of a simple decomposition, each (but not all) of these three parameters
may be zero. However, their values must be between 0 and npworld which
is the number of processes in the MPI communicator MPI comm world or,
equivalently, the number of processes defined in the script launching the
program.
The program follows the following procedures
2. both nprocsx and nprocsy are zero: both values are set internally so
that nprocsx×nprocsy = nprocs and |nprocsx-nprocsy| is minimal
Remarks
12.4.2 Interpolation
iopt arrint hreg Disables/enables (0/1) the use of non-uniform weighted aver-
ages for interpolation in the horizontal of arrays on the model
grid (0).
iopt arrint vreg Disables/enables (0/1) the use of non-uniform weighted av-
erages for interpolation in the vertical of arrays on the model
grid (0).
It is recommended to set these switches only for grids with highly irregular
grid spacings.
12.4. MODEL SWITCHES 415
12.4.3 Hydrodynamics
iopt mode 2D Disables/enables (0/1) the 2-D hydrodynamical mode, i.e. up-
dates of transports and surface elevations (1).
iopt mode 3D Disables/enables (0/1) the 3-D hydrodynamical mode, i.e. up-
dates of 3-D currents (1).
It is recommended to keep these defaults except for very special tests like
the test cases cones and front.
12.4.4 Density
iopt dens Evaluation of the density and expansion coefficients (0).
0 : uniform density, zero expansion coefficients
1 : density from the linear equation of state (4.97), expan-
sion coefficients are uniform
2 : from the McDougall et al. (2003) general equation of
state (4.92)–(4.96) without pressure effects
3 : from the McDougall et al. (2003) general equation of
state (4.92)–(4.96) with pressure effects included
iopt dens grad Selects numerical algorithm for discretisation of the baroclinic
pressure gradient (1).
0 : gradient set to zero
1 : traditional σ-coordinate (second order) method
2 : z-level method
3 : method of Shchepetkin & McWilliams (2003)
iopt sal Salinity update (0).
0 : uniform (space and time) salinity field
1 : salinity field initialised but not updated in time
2 : salinity field initialised and updated in time
iopt sal sbc Type of surface boundary condition for salinity (0).
0 : zero surface flux
1 : surface flux given by (4.264)
iopt temp Temperature update (0).
416 CHAPTER 12. CONTROL PARAMETERS
12.4.5 Biology
iopt biolgy Disables/enables (0/1) the biological module (not available) (0).
Since no biological module is implemented in the current version,
this default cannot be changed.
iopt bstres nodim Type of currents in the (linear or quadratic) bottom stress
formulation (3).
2 : depth-mean currents
3 : 3-D current taken at the bottom grid cell
12.4.7 Advection
iopt adv scal Type of scheme for the advection of scalar quantities (3).
0 : advection disabled
1 : upwind scheme
2 : Lax-Wendroff (explicit) in the horizontal, central (semi-
implicit) in the vertical
3 : TVD scheme
iopt adv 2D Type of scheme for the advection of 2-D transports (1).
0 : advection disabled
1 : upwind scheme
2 : Lax-Wendroff (explicit) in the horizontal, central (semi-
implicit) in the vertical
3 : TVD scheme
iopt adv 3D Type of scheme for the advection of 3-D currents (1).
0 : advection disabled
1 : upwind scheme
2 : Lax-Wendroff (explicit) in the horizontal, central (semi-
implicit) in the vertical
3 : TVD scheme
iopt adv turb Type of scheme for the advection of turbulence quantities (0).
0 : advection disabled
1 : upwind scheme
2 : Lax-Wendroff (explicit) in the horizontal, central (semi-
implicit) in the vertical
3 : TVD scheme
iopt adv tvd Type of limiting function for TVD scheme (1).
418 CHAPTER 12. CONTROL PARAMETERS
1 : superbee limiter
2 : monotone limiter
Comments
• The TVD scheme has the ability to retain sharp gradients, but con-
sumes more CPU time compared to the upwind scheme.
• The same limiting function applies for all transport equations solved
with the TVD scheme.
iopt turb stab mod Selects type of closure (RANS) model (4).
iopt turb stab tke Formulation for the turbulent diffusion coefficient νk (or
stability coefficient Sk ) of turbulent energy (2).
iopt turb tke bcc Type of bottom boundary condition for turbulence
energy (2).
iopt turb tke sbc Type of surface boundary condition for turbulence
energy (2).
0 : Drying/wetting disabled
1 : Drying/wetting algorithm without dynamic masks
2 : Drying/wetting algorithm using dynamic masks
422 CHAPTER 12. CONTROL PARAMETERS
iopt obc bio (General) type of open boundary conditions for biological
variables (0). Currently not implemented.
Note that the open boundary conditions automatically reduce to their de-
faults (see Section 4.10) and input of open boundary data is disabled if the
appropriate switch is not set.
12.4.13 Tides
iopt astro tide Disables/enables (0/1) the inclusion of the astronomical tidal
force in the momentum equations (0). This requires that the
model uses a spherical grid (iopt grid sph=1).
424 CHAPTER 12. CONTROL PARAMETERS
Note that all meteorological surface forcing is disabled if iopt meteo=0. This
means that all surface fluxes are automatically set to zero and the input of
any meteorological data is disabled.
0 : no dependence
1 : using the Kondo (1975) parameterisation (Section 4.8.2)
2 : using Monin-Obukhov similarity theory (Section 4.8.3)
12.4.17 Nesting
iopt nests Disables/enables (0/1) the writing of open boundary data for nested
sub-grids (0).
iopt MPI comm scat Communication type for “one to all” scatter (distribute
and copy) operations (2).
1 : blocking, standard send
2 : blocking, synchronous send
3 : non-blocking, standard send
4 : non-blocking, synchronous send
iopt MPI comm coll Disables/enables (0/1) the use of MPI collective calls
(0).
iopt MPI abort 0: If an error is detected in a MPI routine, an error
message will be written, but the program will not
abort immediately.
1: If an error is detected in a MPI routine, an error
message will be written and the program will abort
immediately afterwards.
iopt MPI sync Disables/enables (0/1) synchronisation calls at the end
of a series of blocking or non-blocking operations (0).
Remarks
• The non-blocking options are not yet tested and should not be used in
the current version of COHERENS.
• Synchronisation of communication calls may lower the CPU perfor-
mance.
12.4.20 NetCDF
iopt CDF abort 0: If an error is detected in a netCDF routine, an error mes-
sage will be written, but the program will not abort im-
mediately.
1: If an error is detected in a netCDF routine, an error mes-
sage will be written and the program will abort immedi-
ately afterwards.
428 CHAPTER 12. CONTROL PARAMETERS
iopt CDF fill Disables/enables (0/1) the use of fill values (0).
iopt CDF format Selects the type netCDF file format (1).
1: classic format
2: 64-bit offset format
The different netCDF file formats are discussed in the netCDF User Manual.
Remarks
• If the 2-D time step is lower than 1000 seconds, its precision is 1 mil-
lisecond and decimal numbers from the fourth position after the decimal
point will be discarded. If the time step is larger than 1000 seconds,
its precision is 1 second and its decimal part is ignored. The 2-D time
step is limited by the CFL condition (5.4) for surface gravity waves.
The maximum allowed 2-D time step is written to the “log” file.
12.5. MODEL PARAMETERS 429
• The last row and the last column of the computational domain rep-
resent dummy (land) points. The “phyical” (horizontal) dimension of
the domain is therefore (nc-1)×(nr-1).
• norestarts must not exceed the value of the system parameter MaxRestarts
defined in syspars.f90.
bdragcoef cst Constant bottom drag coefficient Cdb when iopt bstres drag=1
[-] (0.0).
bdraglin Bottom friction velocity klin used in the linear bottom fric-
tion law if iopt bstres form=1 [m/s] (0.0).
ccharno* Charnock’s constant a used in Charnock’s relation (4.279)
[-] (0.014).
cds cst Constant surface drag coefficient Cds when iopt sflux cds=0
[-] (0.0013).
ces cst Constant surface exchange coefficient Ce when iopt sflux cehs=0
[-] (0.0013).
chs cst Constant surface exchange coefficient Ch when iopt sflux cehs=0
[-] (0.0013).
ckar* von Karman’s constant κ [-] (0.4).
dcrit fld Critical water depth dcrit used in the drying/wetting algo-
rithm [m] (0.1).
depmean cst Constant water depth used to set up a default bathymetry
[m] (0.0).
distrlx obc Maximum distance dmax (from the open boundaries) used
in the relaxation factor (5.279) for momentum advection
dlat ref Reference latitude to be used for the Coriolis frequency in
the case of a Cartesian grid [decimal degrees] (0.0).
dlon ref Reference longitude to be used for solar irradiance in the
case of a Cartesian grid [decimal degrees] (0.0).
dlon ref anal If iopt astro pars>0, harmonically analysed phases are taken
with respect to the astronomical argument for this refer-
ence longitude at the central time [decimal degrees, positive
East] (0.0).
dlon ref obc If iopt astro pars > 0, phases at open boundaries are as-
sumed to be taken with respect to the astronomical argu-
ment at this reference value [decimal degrees]. If zero, the
reference longitude is taken at Greenwich (0.0).
dmin fld Minimum water depth dmin used in the drying/wetting al-
gorithm [m] (0.02).
dthd fld Threshold water depth dth used in the mask criteria for
drying and flooding (see Section 5.4.2) [m] (0.1).
gacc ref If different from real fill, the acceleration of gravity, taken as
432 CHAPTER 12. CONTROL PARAMETERS
the “file number”. The file number can take the value of 1 for external data
intended for input and 2 for data written by the model to the external grid.
The latter is intended for future applications and currently not implemented.
All parameters of this section are defined in usrfdef mod params.
Identifying the model grid as an external grid seems rather strange at first
sight. The intention is to provide the possibility to define a uniform rectan-
gular grid using the parameters below.
• In case of the model grid (grid type igrd=igrd model) the value of nhtype
equals the value of the switch iopt grid htype.
• The corner coordinates x0dat, y0dat and the grid spacings delxdat,
delydat are given in meters or degrees longitude and latitude depending
on whether iopt grid sph equals 0 or 1.
TYPE :: FileParams
LOGICAL :: defined, info, opened, time regular
CHARACTER (LEN=1) :: form, status
CHARACTER (LEN=leniofile) :: filename, pathname
CHARACTER (LEN=lendesc) :: filedesc
INTEGER :: endfile, header type, iostat, iunit,lenrec, &
& maxrecs, nocoords, nodim, novars,timeid, &
& timerec, tskips, varid, zetaid
INTEGER, DIMENSION(3) :: tlims
END TYPE FileParams
TYPE (FileParams), DIMENSION(MaxIOTypes,MaxIOFiles,2) :: &
& modfiles
Only the underlined parameters can be defined by the user, the others
are used internally in the program (e.g. iunit giving the FORTRAN file unit
number).
An element of the array modfiles can be generically represented as mod-
files(idesc,ifil,iotype) where idesc is the “file descriptor”, ifil the “file number”
and iotype represents input (output) data if 1 (2).
438 CHAPTER 12. CONTROL PARAMETERS
The meaning of the third index iotype is as follows. Almost all forcing data
(except nesting) are input data, i.e. represented by an element of modfiles
with iotype=1. By defining a corresponding output file with iotype=2 one has
the possibility to re-write the same input data now in a COHERENS standard
format. This file can be used as input within a subsequent run. The user
then needs to change only the status atrtribute from ‘N’ to ‘R’ (see below).
In case of nested output, iotype must take the value of 2.
Input data can be spread over multiple files for a given descriptor by
specifying different file numbers. This is further discussed below. The ma-
ximum value of ifil is given by the system parameter MaxIOFiles defined in
syspars.f90.
io 3uvnst 3-D (baroclinic current) open boundary data for nested sub-grids
(one file per sub-grid)
io salnst salinity open boundary data for nested sub-grids (one file per
sub-grid)
io tmpnst temperature open boundary data for nested sub-grids (one file
per sub-grid)
io bionst biological open boundary data for nested sub-grids (one file per
sub-grid). Currently not implemented.
io metsur meteorological data (ifil=1)
io sstsur SST data (ifil=1)
• Important to note that the status attribute equals ‘0’ by default which
means that the corresponding usrdef routine is not called by the pro-
gram.
iunit File unit. This parameter is set internally and cannot be defined by
the user.
iostat File I/O status
-1: open error occurred
0 : file not opened
1 : file is open and file pointer is located at the start or before the
end of the file
2 : file pointer is located at the end of the file (i.e. an EOF condition
will occur on a next read)
3 : an end of file condition did occur
nosetstsr number of time series file sets if iopt out tsers=1 (0)
nostatstsr number of time series output stations if iopt out tsers=1 (0)
novarstsr number of time series variables if iopt out tsers=1 (0)
nosetsavr number of time averaged file sets if iopt out avrgd=1 (0)
nostatsavr number of time averaged output stations if iopt out avrgd=1 (0)
novarsavr number of time averaged variables if iopt out avrgd=1 (0)
nosetsanal number of harmonic file sets if iopt out anal=1 (0)
nofreqsanal number of harmonic frequencies if iopt out anal=1 (0)
442 CHAPTER 12. CONTROL PARAMETERS
The chapter explains the setup of model grid, bathymetry and physical initial
conditions, defined in the Usrdef Model.f90 routines:
• usrdef grid: model grid and bathymetry
The list below specifies all arrays which could be defined here.
gxcoordglb(1:nc,1:nr) X-coordinates (Cartesian or spherical) at the UV-nodes
(corner points) [m or fractional degrees]. Definition depends on
the value of iopt grid htype:
1 : No definition is needed. The coordinates are generated by
the program using the attributes of surfacegrid(igrd model,1)
defined in usrdef mod params.
2 : Define only gxcoordglb(1:nc,1), the other rows are automat-
ically generated by the program.
3 : The grid is curvilinear and the full array has to be defined
here.
443
444 CHAPTER 13. MODEL GRID AND INITIAL CONDITIONS
• nobu and nobv are the total (open sea and river) number of open boun-
dary points at U- and V-nodes. They are obtained from the values of
nosbu, nrvbu, nosbv, nrvbv defined in usrdef mod params.
• If the model is applied to simulate the inundation of land areas (iopt fld=2),
the bathymetry should include the land topography of the areas which
can potentially be flooded. For details see Section 5.4.2.
2-D mode
3-D currents
density arrays
turbulence arrays
Turbulence arrays can be defined if a RANS model (see Section 4.4.3)
is selected (iopt vdif coef=3).
tke Turbulent kinetic energy [J/kg].
zlmix Mixing length [m]. Define only for a two-equation k − l model
(iopt turb ntrans=2 and iopt turb param=1).
dissip Dissipation of turbulent energy [W/kg]. Define only for a two-
equation k−ε model (iopt turb ntrans=2 and iopt turb param=2).
bdragcoefatc Bottom drag coefficient [-]. Define only when iopt bstres drag=2.
zroughatc Bottom roughness length [m]. Define only when iopt bstres drag=4.
tidal arrays
The phases need to be defined if iopt astro pars=0, the nodal factors
if iopt astro pars=0,1. Otherwise, the phases and nodal factors will be
automatically initialised by the program itself.
The meaning of the last index in the open boundary arrays depends on
the type of open boundary condition1, 2 .
6 : Orlanski
1: U or V at the interior point nearest to the open boundary
2: U or V at the interior point second nearest to the open boundary
7 : Camerlengo-O’Brien
2: U or V at the interior point second nearest to the open boundary
9 : Flather with specified elevation
2: U L or V L at the previous time step
10: Flather
1: ζ L at the previous time step
2: U L or V L at the previous time step
11: Røed and Smedstad
1: outgoing characteristic
12: characteristic method with specified elevation
1: outgoing characteristic
1
The number in the main list below refers to the value of ityp2dobu or ityp2dobv defined
in Section 14.1.1.1 or to the description list in Section 4.10.1.
2
The number in the list refers to the index in the last dimension of the array.
448 CHAPTER 13. MODEL GRID AND INITIAL CONDITIONS
The following additional arrays are used for application of the open
boundary conditions of scalar quantitities (baroclinic currents, T , S),
denoted by ψ below
The index of the last dimension in the array has the following meaning
The open boundary arrays are usually not created by the user but
obtained from a previous run in which case the data are read from an
external file.
remarks
defaults If a variable is not defined, the following defaults are assumed (see
Section 4.11):
This chapter deals with the setup of the open boundary conditions for the
2-D and 3-D mode. The following routines, located in Usrdef Model.90, are
discussed in the next four sections:
• usrdef 2dobc spec: specifies the type of conditions for the 2-D mode
• usrdef 2dobc data: defines the input of open boundary data for the 2-D
mode
• usrdef profobc spec: specifies the type of conditions for the 3-D mode
• usrdef profobc data: defines the input of open boundary data for the
3-D currents and scalars
• usrdef rlxobc spec: setup for applying the relaxation open boundary
scheme
451
452 CHAPTER 14. OPEN BOUNDARY CONDITIONS
time series input from a data file. The amplitudes An and phases ϕn are
time-independent and must be defined in usrdef 2dobc spec together with
the arrays discussed below.
The procedure is illustrated in Figure 14.1. The filled circles represent open
boundary points. The data are spread over 4 data files. The number in
parentheses denotes the number of the data file (between 2 and 5), the second
number to the right the open boundary index ranging from 1 to nobu at U-
nodes and nobu+1 to nobu+nobv at V-nodes. In the example, nobu=11 and
nobv=8. Each file contains data for the following points:
(2) 8
(2) 7
(2) 6 (3) 11
(2) 5 (3) 10
(2) 4 (3) 9
(2) 3
(2) 2 (6) 19
(2) 1
Figure 14.1: Example showing how to define the arrays no2dobc and in-
dex2dobc.
nofiles = 6
no2dobc = (/8,3,3,4,1/)
index2dobc(1:8,2) = (/1,2,3,4,5,6,7,8/)
index2dobc(1:3,3) = (/9,10,11/)
index2dobc(1:3,4) = (/12,13,14/)
index2dobc(1:4,5) = (/15,16,17,18/)
index2dobc(1,6) = 19
If iobc2dtype(ifil)=1, each data location in file ifil contains two data values
(one for the depth-integrated current and one for the surface elevation).
Otherwise, only one data is defined (either depth-integrated current of el-
evation).
14.1. 2-D MODE 455
By default, the program uses zero values for amplitudes and phases. In
that case, the program will (obviously) not make an harmonic expansion of
harmonic constituents, even when the tidal frequencies index obc are defined
in usrdef mod params.
where
iddesc The file descriptor key id of the 3-D quantity which may take the
following values
io 3uvobc baroclinic currents
io salobc salinity
io tmpobc temperature
io bioobc biological variables (currently not implemented)
nofiles the number of data files plus 1 (the file index for data files ranges
from 2 to nofiles)
novars the number of variables for which open boundary conditions are de-
fined. Value in the current implementation is 1.
The routine is called if the appropriate switch (iopt obc 3D, iopt obc sal,
iopt obc temp) is set to 1 and modfiles(iddesc,1,1)%status=‘N’.
Remarks
• The method allows to use the same profile at different open boundary
points.
• The data profiles itself are defined as time series in usrdef profobc data.
• ifil=3: profile 3
• ifil=4: profile 4
• ifil=5: profile 5
novarsd number of variables per data file. If there is only one data file (nofiles
= 2), the program sets novarsd(2) to novars by default.
iobctype Mapping array for variable indices.
(2) 2
(2) 2
(2) 2 0
(2) 2 0
(2) 1 0
(2) 1
(2) 1 (5) 5
(2) 1
Figure 14.2: Example how to define the open boundary specifier arrays.
14.3. SPECIFIERS FOR RELAXATION OPEN BOUNDARY CONDITIONS 461
iddesc The file descriptor key id of the 3-D quantity which may take the
following values:
io 3uvobc baroclinic currents
io salobc salinity
io tmpobc temperature
io bioobc biological variables (currently not implemented)
ifil file number index of the data file (>1)
numprofs The number of profiles which must be equal to noprofsd(ifil).
Values in the data array which are lower than or equal to the flag value
real min are considered as flagged. In that case the open boundary condition
at that specific vertical location (only) is changed from an external data pro-
file to a zero gradient condition. This may be used e.g. to prevent unrealistic
data input below a pycnocline depth. Note that the vertical profile data of
baroclinic currents must be either all flagged or all non-flagged.
This chapter discusses the setup of the surface forcing needed for the applica-
tion of surface boundary conditions and the procedures for defining nesting.
The following routines are described in the next sections:
• usrdef 1dsur spec: specifies the setup of boundary forcing for water col-
umn applications (1-D mode)
• usrdef 1dsur data: defines the input of surface forcing data for water
column applications
• usrdef surface absgrd: defines a surface data grid using absolute coordi-
nates
• usrdef surface relgrd: defines a surface data grid using relative coordi-
nates
• usrdef surface data: defines the input of surface data for a specific data
grid
• usrdef nstgrd spec: general definitions for nesting (e.g. number of sub-
grid data points)
The first two routines are contained in Usrdef Model.f90, the next three in
Usrdef Surface Data.f90 and the last three in Usrdef Nested Grids.f90 (see
Table 11.1).
465
466 CHAPTER 15. SURFACE FORCING AND NESTING
where
• the switch iopt temp sbc equals 2 or 3 in the case of a SST (sea surface
temperature) grid
iddesc The file descriptor of the corresponding data file. The key id in paren-
theses below is the associated grid key id (idgrd).
io metgrd surface meteo grid (igrd meteo)
io sstgrd surface grid for sea surface temperature (SST, igrd sst)
ifil file index. In the current version its value is 1.
n1dat X-dimension of the data grid equal to surfacegrids(idgrd,ifil)%n1dat
n2dat Y-dimension of the data grid equal to surfacegrids(idgrd,ifil)%n2dat
• The switch iopt temp sbc equals 2 or 3 in the case of a SST grid
15.2. 2-D SURFACE FORCING 469
The relative coordinates are stored in a DERIVED TYPE array of type HRel-
ativeCoords:
TYPE :: HRelativeCoords
INTEGER :: icoord, jcoord
REAL :: xcoord, ycoord
END TYPE HRelativeCoords
where icoord, jcoord are the indices in the X- and Y-direction of the grid
cell containing the data point and xcoord, ycoord the normalised Cartesian
coordinates (between 0 and 1) with respect to axes along the cell faces and
origin at the lower left corner.
The routine is declared as
where
iddesc The file descriptor of the corresponding data file. The key id in
parentheses below is the associated grid key id (idgrd).
• The switch iopt temp sbc equals 2 or 3 in the case of a SST (sea surface
temperature) grid.
where
The number and type of meteorological data depends on the values of the
switches iopt meteo stres, iopt meteo heat and iopt meteo salflx (see Section
12.4.15).
The data, to be defined, are:
15.3 Nesting
The objective of nesting is to interpolate values of specific model arrays to
external data points, which constitute the open boundaries of one or more
sub-grids nested within the model grid. The interpolated data are written
to output files in standard COHERENS format. A different file is used for
each type of variable and each subgrid. Writing of a file is enabled by setting
modfiles(iddesc,iset,2)%status=‘W’ in usrdef mod params where
iddesc the file descriptor which can take the following values:
io 2uvnst 2-D mode variables (transport and surface elevation)
io 3uvnst 3-D baroclinic current
io salnst salinity
io tmpnst temperature
io bionst biological state variables (currently not implemented)
iset number of the nested sub-grid (between 1 and nonestsets)
It is assumed that the variables on the subdomain are defined on a C-
grid like the main grid. The following five types of horizontal interpolation
(depending on the type of variable) need to be considered:
• from model C-nodes to sub-grid C-nodes: 3-D scalars
• from model C-nodes to sub-grid U- or V-nodes: elevations
• from model U-nodes to sub-grid U-nodes: X-components of transports
and currents
• from model V-nodes to sub-grid V-nodes: Y-components of transports
and currents
To summarise, the nesting procedure is defined as follows:
1. Set iopt nests to 1.
2. Define nonestsets as the number of nested sub-grids.
3. Define the number of data points in usrdef nstgrd spec.
4. Define the positions of the data points in usrdef nstgrd abs and/or
usrdef nstgrd rel.
5. Enable the interpolation and writing of specific model variables by
setting modfiles(iddesc,iset,2)%status=‘W’.
472 CHAPTER 15. SURFACE FORCING AND NESTING
• modfiles(io nstspc,1,1)%status=‘N’
• modfiles(io nstgrd,iset,1)%status=‘N’
• nestcoords(iset)=1
where
Provided that the conditions above are fullfilled, the routine is called for each
sub-grid at most 3 times with respectively cnode=‘C’,‘U’,‘V’.
The following coordinate arrays are to be defined:
• modfiles(io nstgrd,iset,1)%status=‘N’
• nestcoords(iset)=2
As for the case of a surface data grid, the horizontal relative coordinates are
stored in a DERIVED TYPE array of type HRelativeCoords:
474 CHAPTER 15. SURFACE FORCING AND NESTING
TYPE :: HRelativeCoords
INTEGER :: icoord, jcoord
REAL :: xcoord, ycoord
END TYPE HRelativeCoords
where icoord, jcoord are the indices in the X- and Y-direction of the grid
cell containing the data point and xcoord, ycoord the normalised Cartesian
coordinates (between 0 and 1) with respect to axes along the cell faces and
origin at the lower left corner.
The routine is declared as follows:
hnests relative coordinates of the sub-grid (‘C’, ‘U’, ‘V’) locations with re-
spect to either the C-, U- or V-node model grid
zcoord Z-coordinates of the sub-grid locations, taken as the negative distance
to the mean surface level (only when nzdat>0) [m].
Provided that nhdat> 0 and the other conditions above apply, the routine
is called successively with cnode=‘C’,‘U’,‘V’. The value of nonodes and the
meaning of hnests depends on cnode:
15.3. NESTING 475
User output
1. The source file Usrdef Time Series.f90 defines setup parameters and
data for time series output. Time series output is enabled when
iopt out tsers=1 (default value).
2. The source file Usrdef Time Averages.f90 defines setup parameters and
data for time averaged output. Time averaged output is enabled when
iopt out avrgd=1.
The usrdef routines for each type are discussed in Sections 16.1-16.4. The
output files not only contain the model data and metadata but also the coor-
dinates of the output grid. In this way each output file can be considered
as self-consistent and used by independent postprocessing programs for dis-
play and analysis. Coordinates of the output data grid are the subject of
Section 16.5.
• usrdef tsr params: defines the output variables, file attributes, the space-
time resolution of the output grid and other metadata
477
478 CHAPTER 16. USER OUTPUT
The array dimensions are previously defined in usrdef mod params and have
the following meaning
TYPE :: VariableAtts
CHARACTER (LEN=lenname) :: f90 name
CHARACTER (LEN=lendesc) :: long name, vector name
CHARACTER (LEN=lenunit) :: units
CHARACTER (LEN=lennode) :: node
INTEGER :: ivarid, klev, nrank, oopt
REAL :: dep
END TYPE VariableAtts
Output variables and their attributes are then selected with the following
arrays:
ivarstsr Each file set contains a sub-set of the variables defined in tsrvars.
The element ivarstsr(iset,ivar) maps, for set iset, the local variable
index ivar into the corresponding array index in tsrvars.
In case of a standard variable (non-zero ivarid attribute), the following
attributes may optionally be defined:
oopt If the rank of the result is different from the one implemented by
the variable’s rank, the rank attribute must be set to the rank of
the result. For example, the domain average of a 3-D variable
has a rank of 0. The attribute has one of the following values
oopt null No operator is applied (default).
oopt mean Result depends on the rank of the model variable
and the rank of the output data.
- If the rank of the result is 0, the output value
is the domain average in case of a 3-D or the
surface average in case of a 2-D variable. Land
areas are excluded in the averaging.
- If the rank of the output value is 2, the result is
the depth averaged value.
oopt int Result depends on the rank of the model variable
and the rank of the output data.
- If the rank of the result is 0, the output value
is the domain integrated value in case of a 3-
D or the surface integrated value in case of a
2-D variable. Land areas are excluded in the
integration.
- If the rank of the output value is 2, the result is
the depth integrated value.
oopt max Result depends on the rank of the model variable
and the rank of the output data.
- If the rank of the result is 0, the output value is
the domain maximum in case of a 3-D or the sur-
face maximum in case of a 2-D variable. Land
areas are excluded.
- If the rank of the output value is 2, the result is
the maximum over the water depth.
oopt min Result depends on the rank of the model variable
and the rank of the output data.
16.1. TIME SERIES OUTPUT 481
The arrays tsr0d, tsr2d, tsr3d are used for output of respectively 0-D, 2-D,
3-D output. They will contain metadata output if header type is set to its
default value or in case of a netCDF file. By default, the data file will contain
the coordinates of the output grid and the times of output. The coordinate
and time data can also be written to a separate “grid” file whose attributes
are stored in tsrgrd. A selection can be made with the grid file attribute
described below.
TYPE :: OutGridParams
LOGICAL :: gridded, grid file, land mask, time grid
CHARACTER (LEN=lentime) :: refdate
INTEGER :: nodim, nostats, time format
INTEGER, DIMENSION(3) :: tlims, xlims, ylims, zlims
END TYPE OutGridParams
TYPE (OutGridParams), DIMENSION(nosetstsr) :: tsrgpars
time grid If .TRUE., the data grid is taken as time-dependent (since the
vertical positions in a σ-grid depend on time). Surface elevations
will be written as an additional coordinate variable at each time
step. Default if .FALSE., in which case the vertical positions are
referred to the mean water level.
time format Format of the time coordinate (0).
TYPE :: StationLocs
INTEGER :: ipos, jpos
CHARACTER (LEN=lenname) :: name
END TYPE StationLocs
TYPE (StationLocs), DIMENSION(nostatstsr) :: tsrstatlocs
INTEGER, DIMENSION(nosetstsr,nostatstsr) :: lstatstsr
where
16.1. TIME SERIES OUTPUT 485
where
where
• usrdef avr params: defines the output variables, file attributes, the space-
time resolution of the output grid and other metadata
Time averaged output is defined in almost the exact way as time series out-
put. Only differences are
• The third element of the vector attribute tlims(3) is now used also to
determine the averaging period.
The array dimensions are previously defined in usrdef mod params and have
the following meaning
as ivarid. This means that the variables in the array avrvars must
be defined in the following order: first 0-D (if any), next 2-D (if
any) and finally the 3-D variables (if any).
ivarsavr Each file set contains a sub-set of the variables defined in avr-
vars. The element ivarsavr(iset,ivar) maps, for set iset, the local
variable index ivar into the corresponding array index in avrvars.
oopt If the rank of the result is different from the one implemented by
the variable’s rank, the rank attribute must be set to the rank of
the result. For example, the domain average of a 3-D variable
has a rank of 0. The attribute has one of the following values
oopt null No operator is applied (default).
oopt mean Result depends on the rank of the model variable
and the rank of the output data.
- If the rank of the result is 0, the output value
is the domain average in case of a 3-D or the
surface average in case of a 2-D variable. Land
areas are excluded in the averaging.
- If the rank of the output value is 2, the result is
the depth averaged value.
oopt int Result depends on the rank of the model variable
and the rank of the output data.
- If the rank of the result is 0, the output value
is the domain integrated value in case of a 3-
D or the surface integrated value in case of a
2-D variable. Land areas are excluded in the
integration.
- If the rank of the output value is 2, the result is
the depth integrated value.
oopt max Result depends on the rank of the model variable
and the rank of the output data.
- If the rank of the result is 0, the output value is
the domain maximum in case of a 3-D or the sur-
face maximum in case of a 2-D variable. Land
areas are excluded.
16.2. TIME AVERAGED OUTPUT 489
defined The output file will be written only if this parameter is set to
.TRUE.. Default is .FALSE..
490 CHAPTER 16. USER OUTPUT
The arrays avr0d, avr2d, avr3d are used for output of respectively 0-D, 2-D,
3-D output. They will contain metadata output if header type is set to its
default value or in case of a netCDF file. By default, the data file will contain
the coordinates of the output grid and the times of output. The coordinate
and time data can also be written to a separate “grid” file whose attributes
are stored in avrgrd. A selection can be made with the grid file attribute
described below.
where
where
where
• usrdef anal freqs: defines the frequencies for harmonic analysis and their
attributes
• usrdef anal params: defines the output variables, file attributes, the
space-time resolution of the output grid and other metadata
The array sizes are defined in usrdef mod params and have the following
meaning:
nosetsanal number of output “sets” as defined in usrdef mod params
nofreqsanal total number of frequencies as defined in usrdef mod params
The arrays provide the following information
index anal Key ids of the constituents used in harmonic analysis (as de-
fined in tide.f90). If positive, harm freq names and harm freq
do not need to be defined. Default is 0.
nofreqsharm number of frequencies per set
harm freq values of the frequencies [rad/s]
harm freq names names of the frequencies names (e.g. ‘M2’)
16.3. HARMONIC ANALYSIS 495
nosetsanal are the number of output “sets” as defined in usrdef mod params
novarsanal are the total number of output variables as defined in usrdef mod params
nostatsanal are the total number of stations as defined in usrdef mod params
oopt If the rank of the result is different from the one implemented by
the variable’s rank, the rank attribute must be set to the rank of
the result. For example, the domain average of a 3-D variable
has a rank of 0. The attribute has one of the following values
oopt null No operator is applied (default).
oopt mean Result depends on the rank of the model variable
and the rank of the output data.
- If the rank of the result is 0, the output value
is the domain average in case of a 3-D or the
surface average in case of a 2-D variable. Land
areas are excluded in the averaging.
498 CHAPTER 16. USER OUTPUT
node Used for 3-D variables defined at W-nodes on the model grid. If
node is set to ‘C’ (default), the vertical profile of the variable is
first interpolated at the C-node before the operator is applied.
If set to ‘W’, the output variable must be defined at the W-node
and no interpolation is performed.It is remarked that quantities
defined at U- or V-nodes are always interpolated at the C-nodes
before the operator is applied.
The elliptic parameters, available for output are: major axis and minor
axis of the tidal ellipse, ellipticity, inclination of the ellipse, elliptic phase and
magnitude of the cyclonic and anticyclonic current. The values of the elliptic
parameters do not need to be specified by the user, but are automatically
determined by the program using the variables’s key id. A list of all key ids
for elliptic variables is given in Table 16.1, including the dimension of the
corresponding “current” vector, which may in principle be any kind of vector
and whose components are known to the program through the arrays ivecell2d
and ivecell3d. Since they can be defined both in 2-D and 3-D mode, there
are 14 key ids available. This explains why the second dimension of ivarsell
equals 14. Note that the f90 name, long name, units of elliptic parameters are
pre-defined by the program and cannot be reset by the user in the current
implementation.
defined The output file will be written only if this parameter is set to
.TRUE.. Default is .FALSE..
form Format of the data file.
‘A’: ASCII
‘U’: unformatted binary
‘N’: netCDF
500 CHAPTER 16. USER OUTPUT
5: months
6: years
7: date in years
Cases 1–6 are numerical formats. Cases 0 and 7 are absolute
times, the other ones relative to the reference date/time.
refdate Reference date/time for calculating relative times. If not given,
refdate equals the first output date/time, rounded to the nearest
minute, hour, ... depending on the value of time format.
tlims The first two elements of this vector are the start and end time
indices for data output and determine the start and end output
date/times. The period of the harmonic analysis is defined by
tlims(3). This means in practice that output will be written
atregular intervals of delt2d*tlims(3) seconds which is the same
as the period of the analysis. Output times are defined in the
middle of each period (central time) of analysis.
nodim Dimension of the output grid (0/2/3). For example, the dimen-
sion must be set to 3 to enable 3-D output.
nostats Number of data stations in case of non-gridded (station) data.
xlims Start/end/step X-index in case of gridded data. This defines
the output sub-grid in the X-direction. (Option not available
for 0-D output). Default values are (1,nc-1,1).
ylims Start/end/step Y-index in case of gridded data. This defines
the output sub-grid in the Y-direction. (Option not available
for 0-D output). Default values are (1,nr-1,1).
zlims Start/end/step Z-index in case of gridded data. This defines the
output sub-grid in the Z-direction and applies for gridded and
non-gridded output. (Option only available for 3-D output).
Default values are (1,nz,1).
where
5. time: Output times written at each output time. Units are absolute
(in string format) or numerical depending on the value of the attribute
time format (see above).
The arrays depout and zetout are included for the following reasons:
• If output is written with land mask=.TRUE., the data are not written
in gridded format, but as a vector array excluding land points. The
output grid can be recovered by a postprocessing program knowing the
positions of the land areas where depout>0.
506 CHAPTER 16. USER OUTPUT
where z, h and ζ are obtained from the data file. An easier alternative
would be to write z at all times, but this would require the output of a
3-D array at each time, while in the present formulation only one 2-D
array (ζ) is needed, giving a saving of disk space.
IMPLICIT NONE
Most variables within a usrdef routine have a non-local scope and are
already declared in a MODULE file. They are made accessible in the
usrdef routine via a USE X statement at the head of the routine where
X is the name of the module. The name of a module always appears
on the first line of the a module file. These are the files in the source
directory whose names start with a lower case character and contain
no “ ” (underscore) character. The file names have a close relation
with their contents (like currents.f90 which contains the modules with
all declarations concerning currents). A description of all program va-
riables is given in Chapter 25. Module routines used within a usrdef
routine need to be declared with a
USE X, ONLY: Y
statement where X is the name of the module and Y the name of the
module routine. Module routine file names start with a lower case
letter and have an “ ” character in their name. The routine name can
be found within the routine. A full description of modules and module
routines is found in Chapters 25 and 23. The following is an example
of USE statements
507
508 CHAPTER 16. USER OUTPUT
USE currents
USE inout routines, ONLY: close file, open file
1. Use open filepars to open and close filepars to close files. The
first argument of these routines is a derived type variable of type
FileParams. Besides opening and closing, the routines set or reset
a number of file attributes.
2. Use open file and close file. The routines are similar to the classical
OPEN and CLOSE FORTRAN routines.
1. On first call, the file is opened and the iostat attribute is reset
from 0 to 1. No data are read.
2. A second call is made, immediately after the first one (i.e. at
the same model time step) to read the date/time and first series
of data. These calls are repeated until the date/time of the last
input is later than the actual model time.
3. When during program execution, the model date equals or be-
comes later than the one obtained from the last input, the usrdef
routine is called again, until the date/time in the file becomes later
than the actual model time.
4. If an end of file condition occurs or the user knows that this will
occur on a next read, the user must set the iostat number to 2. The
program will no longer call the routine. Further action (decided
by the program) now depends on the value of the endfile attribute
(see Section 12.7.2).
5. At the end of the simulation the program automatically closes all
open files whose attributes are stored in an element of the array
modfiles. Otherwise, the user has to close the file when the last
data record has been read.
IF (modfiles(iddesc,ifil,1)%iostat.EQ.0) THEN
CALL open filepars(modfiles(iddesc,ifil,1))
RETURN
ENDIF
...
IF (modfiles(iddesc,ifil,1)%iostat.EQ.0) THEN
modfiles(iddesc,ifil,1)%iostat = 1
RETURN
ENDIF
...
if the file does not exist and the data are defined without reading from
an external data file. The third point could be implemented as follows
iunit = modfiles(iddesc,ifil,1)%iunit
READ (iunit,..,END=99)
...
99 modfiles(iddesc,ifil,1)%iostat= 2
...
510 CHAPTER 16. USER OUTPUT
Part V
Test cases
511
Chapter 17
Introduction
A total of 12 test cases has been implemented. The first eight are adapted
versions of the ones made available with the release of the COHERENS V1
source code and discussed in the COHERENS V1 manual. The files, used for
the setup (including the Usrdef * files), are located in subdirectories of the
setups folder. The main objectives for implementing the test cases are to
cones
advection in a closed basin of an initially coned-shaped contami-
nant distribution rotating around the basin’s centre. Four exper-
iments are defined using different values of the model switch for
scalar advection.
513
514 CHAPTER 17. INTRODUCTION
front
advection (on a σ-grid) of a front by a tidal current over a sloping
bottom in an open channel without “physical” diffusion (James,
1996). Four experiments are defined using different values of the
model switch for scalar advection.
seich
adjustment to equilibrium of an initial horizontal density gradient
in a closed channel, through the propagation of internal waves.
The numerical results are compared with an analytical solution.
Five experiments are defined using different values of the model
switches for scalar and momentum advection.
fredy
development of 3-D baroclinic eddies in a closed basin. This test
case was previously considered in the NOMADS project (Proctor,
1997). Four experiments are defined using different values of the
model switches for scalar and momentum advection. Results are
compared with those described in Tartinville et al. (1998).
pycno
a 1-D test describing the evolution of a wind-driven surface layer
without rotation. An initial linear stratification is assumed and
advection is neglected. The results are compared with analytical
theory (Kundu, 1981; Luyten et al., 1996). Seven experiments are
defined using different values of the turbulent switches.
csnsp
a 1-D simulation of the seasonal evolution of thermal stratifica-
tion at station CS in the North Sea. Nine experiments are defined
using different values of the turbulence switches, different param-
eterisations for the surface exchange coefficients, or disabling the
attenuation of light.
river
evolution of an estuarine salinity front advected by a tidal cur-
rent and the corresponding estuarine circulation in an open non-
rotating channel. Four experiments are defined using different
values of the switches for turbulence and momentum advection.
515
plume
formation and evolution of a tidally modulated river plume front.
Some comparison is made with the theory of tidal plumes pre-
sented in Visser et al. (1994). Seven experiments are defined test-
ing the role and form of horizontal diffusion, the scheme for mo-
mentum advection, the type of open boundary condition and the
effects of the tide.
rhone
simulation of the Rhone plume in the Gulf of Lions (Mediterranean
Sea) with a real bathymetry. Seven experiments are defined with
different river discharges, turbulence schemes and directions of the
wind forcing.
flood2d
simulation of flooding and subsequent drying in a 2DV channnel.
Four experiments are defined using two different bathymetries and
two different drying/wetting formulations.
flood3d
simulation of flooding and drying in a 3-D rectangular basin. Four
experiments are defined using different bathymetries.
bohai
simulation of the tides in the Bohai Sea (northern part of the
Yellow Sea). Six experiments are defined using different types of
open boundary conditions either in 2-D (depth-averaged) and 3-D
mode.
The instructions for installing and running a test case are already ex-
plained Section 2.3. A simulation is performed using the Run script with an
argument in the form of a capital letter. The argument informs the program
which experiment is simulated (see Table 2.1).
Further information about the setup of a test case can be obtained by
inspecting the FORTRAN source files in the corresponding /setups subdi-
rectory. A series of output parameters, which are described in the chapters
below, are defined for each test case. If no run-time error occurred during the
execution of an experiment, a file is produced at the end of the simulation.
Its name is composed of 10 characters:
516 CHAPTER 17. INTRODUCTION
• characters 1–5: name of the test case (as given in the first column of
Table 2.1)
Simulations were performed for all test cases on different machines and
compilers. The corresponding .tst-files for different compilers are found in
the different subdirectories of the /setups/ptests folder. These files are
a useful tool to test the portability of the model code. The test cases are
described in Chapters 18–22. The values of the test parameters, given in
tabular form within the text, and the figures in the text were obtained from
simulations, performed on a LINUX machine with a gfortran compiler.
Calculation times for all test case experiments are listed in Table 17.1.
The simulations are permormed on a LINUX PC in serial mode and a parallel
cluster at ECMWF (European Center for Medium Range Weather Forecast-
ing, UK) using different number of processors.
517
Table 17.1: Calculation times (in seconds) for test case experiments on a LINUX
serial PC using gfortran and a parallel cluster using XL Fortran at ECMWF. The
number after the ’-’ sign denotes the number of processes.
Advection schemes
519
520 CHAPTER 18. ADVECTION SCHEMES
∂C ∂ ∂
+ (Cu) + (Cv) = 0 (18.3)
∂t ∂x ∂y
A series of parameters are defined in the program and written to the .tst
output files at t = 0.5T , T , 1.5T , 2T where T is the rotation period.
xmin The cone radius measured in the negative X-direction (m). This is
taken as the distance between the cone centre and the point to the left
where C becomes less than 0.01 along a line parallel to the X-axis2 .
xplus The cone radius measured in the positive X-direction (m). This is taken
as the distance between the cone centre and the point to the right where
C becomes less than 0.01 along a line parallel to the X-axis2 .
ymin The cone radius measured in the negative Y-direction (m). This is
taken as the distance between the cone centre and the point below
where C becomes less than 0.01 along a line parallel to the Y-axis2 .
yplus The cone radius measured in the positive Y-direction (m). This is taken
as the distance between the cone centre and the point above where C
becomes less than 0.01 along a line parallel to the Y-axis2 .
cmin Minimum value of the concentration over the entire domain.
cmax Maximum value of the concentration over the entire domain.
Exact values are 5 for the four radii, 0 for cmin and 1 for cmax.
18.1.3 Results
• It is clear that scheme C which is also the default scheme of the pro-
gram, gives the best performance both in preserving the original shape
as in maintaining the gradient of the contaminant concentration.
• The upwind scheme A is only first order accurate and therefore highly
diffusive. This is clearly observed in Figure 18.2a where the original
distribution has been smeared out over the entire basin.
Figure 18.2: Test case cones. Surface concentrations after two periods of
revolution for scheme A (a), B (b), C (c), D (d).
18.1. TEST CASE CONES 523
Figure 18.3: Test case cones. Surface concentrations at the end of the
simulation along a transect through the cone centre parallel to the X-axis (a)
and the Y-axis (b) for the exact case (solid) schemes A (dots), B (dashes),
C (dash-dots) and D (dash plus 3 dots).
524 CHAPTER 18. ADVECTION SCHEMES
ua = 2 if zs + ∆z/2 < 30
ua = 0 if zs − ∆z/2 > 30 (18.7)
ua = 2(30 − zs + ∆z/2)/∆z otherwise
where ∆z is the vertical grid spacing. The model uses a σ-coordinate system
with 20 vertical levels so that the vertical grid spacing ∆z, following (18.4)
varies horizontally 2.5 m in the deepest part to 1.5 m in the shallowest part
of the domain.
The program only solves two equations: the transport equation for the
contaminant concentration without diffusion and the continuity equation for
the vertical velocity. The latter is non-zero only along the slope where the
prescribed velocity field has a non-zero horizontal gradient. The channel
length is set to 50 km. All cross-channel variations are neglected.
18.2. TEST CASE FRONT 525
A : upwind scheme
B : Lax-Wendroff scheme
The simulations are performed for 36 hours, i.e. 3 semi-diurnal tidal cycles.
The contaminant distributions and current field are displayed in Figures 18.4
at the initial time and at 3 h intervals during the last cycle for scheme C
which is also the default scheme of the program. The distributions after 27
hours are compared for the four experiments in Figures 18.5. The concentra-
tions at 5 m below the surface and a vertical profile at 30 km from the left
boundary are shown in Figures 18.6 after 27 hours of simulation.
Values for the exact case are 1 (gradh, hleng), 0.8 (gradv), 0 (cmin), 2 (cmax).
18.2.3 Results
• After an initial broadening due to numerical diffusion, the shape of
the fronts remains unchanged after a tidal cycle as can be seen by
comparing Figures 18.4b and f.
526 CHAPTER 18. ADVECTION SCHEMES
Figure 18.4: Test case front. Contaminant distribution and current field for
experiment C at t = 0 h (a), t = 24 h (b), t = 27 h (c), t = 30 h (d), t = 33
h (e), t = 36 h (f).
18.2. TEST CASE FRONT 527
Figure 18.5: Test case front. Contaminant concentration after 27 hours for
scheme A (a), B (b), C (c), D (d). Contour lines are at 0.2 intervals.
528 CHAPTER 18. ADVECTION SCHEMES
Figure 18.6: Test case front. Contaminant concentration after 27 hours for
scheme A (solid), B (dots), C (dashes) and D (dash-dots): horizontal profile
at 5 m below the surface (a), vertical profile at 30 km from the left boundary
(b).
18.3. TEST CASE SEICH 529
• Comparing the test results for the different experiments shows that the
default scheme C not only produces the sharpest (lateral) front (para-
meter gradh) but also the smallest frontal width (parameter hleng).
ρ1 = ρ2 (1 + βS (S1 − S2 )) (18.8)
where ρ1 , ρ2 are the densities in the upper, respectively lower layer and βS
is the uniform salinity expansion coefficient. The initial state is shown in Fi-
gure 18.7. The resulting horizontal (baroclinic) pressure gradient creates, in
530 CHAPTER 18. ADVECTION SCHEMES
hleft The distance (km) of the leftward moving front with respect to the
centre of the channel. The position of the front is taken at the
location where the vertical current in the upper layer attains its
largest negative value.
hright The distance (km) of the rightward moving front with respect to
the centre of the channel. The position of the front is taken at
the location where the vertical current in the lower layer attains its
largest positive value.
v2up The value of the horizontal current (m/s) in the upper layer averaged
between the two fronts.
v2lo The value of the horizontal current (m/s) in the lower layer averaged
between the two fronts.
wmaxup Maximum value of the vertical current (mm/s) in the upper layer.
wmaxlo Maximum value of the vertical current (mm/s) in the lower layer.
wminup Minimum value of the vertical current (mm/s) in the upper layer.
wminlo Minimum value of the vertical current (mm/s) in the lower layer.
sdev The relative difference between the volume averaged salinity and its
initial value, defined by
where a h i denotes the averaged value over the whole width and
depth of the channel. Since the salinity fluxes are zero at the surface,
the bottom and along the solid side walls, the exact value of SDEV
is zero. Since the numerical schemes for the advection of salinity are
conservative, non-zero values are only produced by rounding errors.
This parameter is therefore useful to test the machine accuracy.
In the definition of the above parameters the upper and lower layer are conve-
niently taken at respectively 5.5 below the surface and 4.5 above the bottom.
Values for the analytical solution are given in Table 18.1.
532 CHAPTER 18. ADVECTION SCHEMES
Table 18.1: Output values for the analytical solution of test case seich.
time (h) 1 2 3 4 5 6
hleft 2.750 5.250 7.250 9.750 11.75 13.75
hright 2.750 5.250 7.250 9.750 11.75 13.75
v2up -0.1188 -0.1273 -0.1358 -0.1355 -0.1392 -0.1417
v2lo 0.1316 0.1401 0.1486 0.1483 0.1520 0.1545
wmaxup 0.4180 0.4180 0.4180 0.4179 0.4180 0.4180
wmaxlo 0.3432 0.3433 0.3432 0.3433 0.3433 0.3432
wminup -0.4185 -0.4185 -0.4185 -0.4186 -0.4185 -0.4185
wminlo -0.3431 -0.3431 -0.3431 -0.3431 -0.3431 -0.3431
sdev 0 0 0 0 0 0
Figure 18.8: Evolution of the current field, salinity and the frontal system
for the seich test case after 1, 3, and 6 hours according to the analytical
theory (a, b, c) and experiment C (d, e, f).
534 CHAPTER 18. ADVECTION SCHEMES
Figure 18.9: Current field and salinity distribution for the seich test case
after 4 hours using scheme A (a), B (b), C (c), D (d) and E (e).
18.3. TEST CASE SEICH 535
18.3.4 Results
• It should be remarked first that contrary to the numerical setup the an-
alytical derivation assumes that the channel has open ends allowing the
perturbation to propagate towards infinity. This explains the (barely
visible) small perturbation in the current field outside the fronts caused
by the barotropic mode which already attains the edges of the channel
after 17 min and bounces off the solid walls. The model appears in
good agreement with the analytical theory. A notable difference is the
initial occurrence of spurious oscillations of the current field gradually
attenuating in time. Note also that the interface which separates the
upper and lower layer between the two fronts is spread over 3–4 m (or
grid cells). The interface thickness remains however uniform in time.
• The numerical oscillations of the current field are more clearly observed
in the case of scheme A which does not advect momentum, whereas
they are almost absent in the other runs due to numerical diffusion by
the advection scheme. Note also the larger thickness of the interface
when the salinity is advected by the upwind scheme (experiments B
and D).
• Comparing the values of the parameters hleft and hright for the ana-
lytical case and the four experiments it is seen that the fronts advance
more slowly to the left and the right in the model results. This indi-
cates that the internal wave speed ci is somewhat underestimated by
the model. Best agreement is found for experiments C and E using the
TVD scheme for salinity.
• The vertical velocity is non-zero only above and below the points where
the interface has a non-zero gradient. The maximum and minimum
values within the upper and lower layer are time-independent in the
analytical solution which is not the case in the model results where
the magnitude of the vertical current decreases with time both in the
upper and the lower layer. This may be due to numerical diffusion.
Best agreement is for experiment E.
ρ = ρ0 (1 + βS (S − S0 )) (18.11)
3
For convenience, the outer 15 km of the basin are not displayed in Figures 18.10–18.13.
18.4. TEST CASE FREDY 537
C : upwind scheme for momentum, TVD for salinity (default schemes of the
program)
A series of figures is produced showing the state at the end of the simulation
for the four experiments: surface distributions of current and salinity (Figure
18.11), surface distributions of the vertical vorticity (Figure 18.12), current
and salinity along a lateral transect parallel to the X-axis and through the
axis of the cylinder (Figure 18.13).
In analogy with Tartinville et al. (1998) the volume-integrated kinetic
energy, available potential energy and enstrophy are defined by
1 Z
Ekin = ρ0 (u2 + v 2 ) dV (18.12)
2 V (t)
Z Z
Epot = ρgx3 dV − ρ0 gx3 dV0
V (t) V0
1 Z
2
Z
= gρ0 ζ dS − ρ0 bx3 dV (18.13)
2 S(t) V (t)
Z ∂v ∂u 2
Estr = − dV (18.14)
V (t) ∂x1 ∂x2
538 CHAPTER 18. ADVECTION SCHEMES
where V (t) is the volume of the basin, V0 its initial value, S(t) the surface,
ζ the surface elevation and b = −g(ρ − ρ0 )/ρ0 the buoyancy. A fourth quan-
tity a1% is defined as the surface area bounded by the contour line where
the salinity is 0.01 PSU less than the ambient value of 34.85 PSU. This is
determined by the number of surface grid cells where the salinity is less than
34.839 PSU multiplied by the area of a surface grid cell. Time series of these
four quantities are plotted in Figures 18.14.
The following output parameters are defined for this test case:
ekin Volume integrated kinetic energy (109 J) as defined by (18.12).
epot Volume integrated available potential energy (109 J) as defined by
(18.13).
enstr Volume integrated vorticity (m3 /s2 ) as defined by (18.14).
a1pt Value of a1% (108 m2 ).
salmin The minimum salinity value (PSU) inside the domain.
salmax The maximum salinity value (PSU) inside the domain.
sdev In analogy with the test case seich this parameter represents the
relative difference between the volume averaged salinity and its initial
value and is, defined by
18.4.3 Results
The following conclusions are made:
• A four-lobed structure is obtained. This is clearly observed in Figu-
res 18.11d and 18.12d for scheme D and in a much weaker form for the
other experiments.
• In analogy with the experimental results of Griffiths & Linden (1981)
four cyclonic vortex rings develop at the points where the unstable
displacements are directed inwards. The vortices are separated by ar-
eas with a weaker anticyclonic vorticity. The phenomenon is again
18.4. TEST CASE FREDY 539
most clearly observed for scheme D. This shows the ability of the TVD
scheme to simulate highly sheared density fronts.
• During the first hours of the simulation the kinetic energy increases at
the expense of potential energy representing the outward expansion of
the core region. As soon as a quasi-geostrophic balance is achieved and
the eddies start to grow, both Ekin and Epot oscillate with the inertial
period and opposite phases. This quasi-equilibrium state is most clearly
attained for experiment D, whereas Ekin and Epot gradually increase in
the case of experiments A and B. Note also that the vorticity, measured
by the parameter Estr , is stronger in experiments B and D which use
the TVD scheme for the advection of momentum. On the other hand,
the surface area of the patch increases more rapidly for schemes A and
B. This is due to the larger numerical diffusion produced by the upwind
scheme for salinity.
• According to Tartinville et al. (1998) the form and growth of the eddies
is related to the ratio Θ of the kinetic to the available potential energy
(represented here by the output parameter theta). Firstly, the number
of baroclinic eddies given by the wavenumber n scales as n ∼ Θ−1/2 .
Simulations using the PPM advection scheme both for salinity and cur-
rents (James, 1996) yield a value of Θ of ∼0.5 and a 2-lobed instability.
This is comparable to the value obtained with scheme D in which case,
however, a 4-lobed instability is found. Secondly, the growth rate of
the instability increases with Θ1/2 . This is, at least qualitatively, in
agreement with the present results, as can be seen by comparing the
development of the eddies in Figures 18.11 and 18.12 for experiments
A, C, B and D which corresponds to increasing values of Θ.
540 CHAPTER 18. ADVECTION SCHEMES
Figure 18.10: Initial salinity distribution for the fredy test case along the
surface (a) and along a transect parallel to the X-axis and through the patch
(b).
18.4. TEST CASE FREDY 541
Figure 18.11: Test case fredy. Surface current and salinity after 6 days for
experiment A (a), B (b), C (c), D (d).
542 CHAPTER 18. ADVECTION SCHEMES
Figure 18.12: Test case fredy. Surface vorticity normalised by the Coriolis
frequency for experiment A (a), B (b), C (c), D (d).
18.4. TEST CASE FREDY 543
Figure 18.13: Test case fredy. Current and salinity along a transect parallel
to the X-axis and through the centre of the patch after 6 days for experiment
A (a), B (b), C (c), D (d).
544 CHAPTER 18. ADVECTION SCHEMES
Figure 18.14: Test case fredy. Time series of the kinetic energy Ekin in 109 J
(a), the available potential energy Epot in 109 J (b), the enstrophy Estr in
m3 /s2 (c) and the fresh water area A1% in units of 108 m2 (d) for experiment
A (solid), B (dots), C (dashes), D (dash-dots).
Chapter 19
545
546CHAPTER 19. TURBULENCE AND HEAT FLUX FORMULATIONS
for a simulated period of 1 day. The total water depth is set to 100 m which
is more than 2 times larger than the simulated mixed layer depths. The
density equation (19.2) is transformed into an equivalent salinity equation
using a linear equation of state. The initial salinity field is given by
N02
S = S0 − (z + H) (19.13)
gβS
Table 19.1: Settings of the turbulence switches for the pycno experiments.
A “-” means that the value of the switch is irrelevant.
switch A B C D E F G
iopt turb ntrans 0 1 1 1 1 2 2
iopt turb param 1 1 1 2 2 1 2
iopt turb stab form 3 2 2 3 3 3 3
iopt turb lmix 4 4 4 1 4 - -
iopt turb stab mod 1 - 1 4 4 1 4
iopt turb iwlim 0 0 1 1 1 1 1
Values of the corresponding turbulence switches are listed in Table 19.1. Note
that experiment E corresponds to the default scheme of the program (except
for the inclusion of limiting conditions). All schemes, except B and C, yield
a critical Richardson number so that the first criterion for self-similarity is
satisfied. It can be demonstrated that none of the schemes complies with the
second criterion. As shown by Luyten et al. (1996) the latter condition is of
minor importance.
Time series of the mixed layer depth h(t), the surface current u(0, t)
and the surface density difference ∆ρ(0, t) are shown in Figures 19.1a–f. The
mixed layer depth is determined as the surface distance of the first grid point
below the surface where the current is lower than 1% of its surface value.
Vertical profiles of the current u, the density ρ minus the initial surface value
ρ(0, 0) and the Richardson number at the end of the simulation period are
plotted in Figure 19.2.
A number of output parameters are defined. Their intention is primarily
to compare the results with the self-similarity theory. Equations (19.8)–
(19.11) for the surface current, the surface value of ∆ρ, h(t) and Ri are then
written in the form
ln h = αh + βh ln(tN0 ) (19.14)
ln u(0, t) = αu + βu ln(tN0 ) (19.15)
ln ∆ρ(0, t) = αd + βd ln(tN0 ) (19.16)
ln Ri = αr + βr ln(tN0 ) (19.17)
where, according to the self-similarity theory,
βh = βu = βd = 1/2 , βr = 0 (19.18)
and
1 u
⋆s
αh = ln(2Ri) + ln (19.19)
4 N0
19.1. TEST CASE PYCNO 549
The eight coefficients (αh ,αu ,αd ,αr ), (βh ,βu ,βd ,βr ) in (19.14)–(19.17) are de-
termined from the model results by applying a linear regression analysis. To
remove the influence of initial conditions and adjustments the analysis is re-
stricted to the last 14 hours. A description of all output parameters is given
below.
rvmean The value of Ri defined by (19.11) and averaged over the last 14
hours.
brv The coefficient βr in the linear relation (19.17) for Ri.
corrv The squared correlation coefficient r2 for the linear relation (19.17).
A zero value indicates that Ri is uncorrelated with time.
rvmean2 The value of Ri as determined from (19.19).
bh The coefficient βh in the linear relation (19.14) for h(t) (log(m)).
corrh The squared correlation coefficient r2 for the linear relation (19.14).
bu2 The coefficient βu in the linear relation (19.15) for u(0, t) (log(m/s)).
corru2 The squared correlation coefficient r2 for the linear relation (19.15).
bdr0 The coefficient βd in the linear relation (19.16) for ∆ρ(0, t) (log(kg/m3 )).
corrdr0 The squared correlation coefficient r2 for the linear relation (19.16).
vedmax The maximum value of the eddy viscosity coefficient νT over the
whole water depth (m2 /s) at the end of the simulation.
difmax The maximum value of the eddy diffusion coefficient λT over the
whole water depth (m2 /s ) at the end of the simulation.
tkemax The maximum value of the turbulence energy k over the whole water
depth (J/kg) at the end of the simulation .
tmld The value of h at the end of the simulation (m).
usur The value of the surface velocity at the end of the simulation (m/s).
drosur The value of the surface density difference ∆ρ at the end of the
simulation (kg/m3 ).
sdev The relative difference between the depth-averaged salinity and its
initial value, defined by
sdev = 105 (S(t) − S(0))/S(0) (19.20)
where an overbar denotes a depth-averaged value. Since there are no
bottom and surface salinity fluxes, the exact value of sdev is zero. A
conservative scheme is applied in the model for the vertical diffusion
of salinity so that non-zero values are only due to rounding errors.
This parameter is therefore useful to test the machine accuracy.
Values for all experiments are given in Table 19.2.
550CHAPTER 19. TURBULENCE AND HEAT FLUX FORMULATIONS
Table 19.2: Output values for the parameters of test case pycno.
parameter A B C D E F G
Figure 19.1: Test case pycno. Time series of the mixed layer depth (a–b),
the surface current (c–d) and the surface density difference ∆ρ(0, t) (e–f).
Test runs A, B, C, are represented in Figures a, c, e by the solid, dotted
and dashed curves respectively. Test runs D, E, F, G are shown in Figures
b, d, f by the solid, dotted, dashed and dash-dotted curves respectively.
552CHAPTER 19. TURBULENCE AND HEAT FLUX FORMULATIONS
Figure 19.2: Test case pycno. Vertical profiles of the current (a–b), the den-
sity minus its initial surface value, ρ(z, t) − ρ(0, 0) (c–d) and the Richardson
number (e–f) after one day. Experiments A, B, C are represented in (a),
(c), (e) by the solid, dotted and dashed-dotted curves respectively. Experi-
ments D, E, F, G are shown in (b), (d), (f) by the solid, dotted, dashed
and dash-dotted curves respectively.
19.1. TEST CASE PYCNO 553
Figure 19.3: Test case pycno. Vertical profile of the vertical diffusion coef-
ficient λT after one day (a) and time series of λT at 10 m depth during the
last hour of the simulation (b) for experiment A.
554CHAPTER 19. TURBULENCE AND HEAT FLUX FORMULATIONS
19.1.4 Results
The results can be summarised as follows:
• The time-averaged bulk Richardson number Ri (parameter rvmean) is
much higher for the schemes B and C which use the Munk-Anderson
formulation for the stability functions compared to the other schemes
using a RANS model.
• The general time dependence of Ri (not shown) consists of an oscilla-
tion around a mean value which increases in time. The amplitude of the
oscillations and the growth rate of the mean value of Ri remain small
in all cases except B. This explains why brv is larger for B compared
to the other experiments.
• The parameter rvmean2 is mostly lower than rvmean. The former is
obtained from the linear regression analysis and (19.19) whereas the
latter is evaluated using its definition (19.11). The difference is larger
for the schemes A–C indicating that the self-similarity hypothesis is
less valid for this type of schemes. The laboratory data of Kato &
Phillips (1969) calibrated by Price (1979) yield a value of Ri close to 0.6
which agrees more with the values predicted by the RANS schemes D,
E, F, G than the ones obtained from the Munk-Anderson formulations
B, C.
• The parameters βh and βd are close to 0.5 in agreement with the value
predicted by the self-similarity theory whereas βu ≃ 0.4 (except for
case A) which is lower than the theoretical value of 0.5.
• For larger values of Ri (parameter rvmean) the surface current tends to
decrease whereas the surface density and the mixed layer depth tend
to increase in agreement with equations (19.8)–(19.10).
• The schemes D to G produce larger shears near the surface and much
shallower mixed layer depths compared to the B and C schemes. Note
the remarked difference between the zero-equation and two-equation
models A and F which are physically nearly the same. The discrepancy
is most clearly observed in the profiles of the current (Figures 19.2a–b
and the density (Figures 19.2c–d).
• From Figures 19.2e–f one observes that the Richardson number ap-
proaches its critical value in the stratified zone just below the surface
mixed layer (except in the runs A and B). Note that Ri ≃ Ric at the
base of the turbulent layer for the schemes C–G which use a limiting
19.2. TEST CASE CSNSP 555
condition (iopt turb iwlim=1). The highly oscillating curve for run A
is due to a numerical instability (see below).
∂u ∂ζ ∂ ∂u
− f v = −g + νT (19.21)
∂t ∂x ∂z ∂z
556CHAPTER 19. TURBULENCE AND HEAT FLUX FORMULATIONS
∂v ∂ζ ∂ ∂v
+ f u = −g + νT (19.22)
∂t ∂y ∂z ∂z
∂T 1 ∂I ∂ ∂T
= + λT (19.23)
∂t ρ0 cp ∂z ∂z ∂z
where f = 2Ω sin φ is the Coriolis frequency, φ the latitude, ζ the surface
elevation, T the temperature, cp the specific heat of seawater at constant
pressure and I(z, t) solar irradiance. Neglecting the baroclinic component of
the pressure gradient the surface slope terms are written as
∂ζ ∂ζ
g = F cos(ω2 t − ϕx ) , g = G cos(ω2 t − ϕy ) (19.24)
∂x ∂y
where ω2 is the frequency of the dominant M2 -tide and F , G the specified
amplitudes of the surface slope term.
The boundary conditions are
∂u ∂v ∂T
ρ0 ν T , = (τs1 , τs2 ) , ρ0 cp λT = −Qnsol (19.25)
∂z ∂z ∂z
at the surface, and
∂u ∂v ∂T
ρ0 ν T , = ρ0 Cdb (u2b + vb2 )1/2 (ub , vb ) , ρ0 cp λT
=0 (19.26)
∂z ∂z ∂z
at the bottom where (ub ,vb ) are the velocities at the grid point nearest to the
bottom. Different formulations are used for the surface stress and non-solar
heat flux Qnsol (see below). The bottom drag coefficient Cdb is expressed as
a function of the roughness length z0 . The solar irradiance in the tempera-
ture equation is decomposed into a near-infrared part absorbed in a shallow
surface layer, and a non-infrared part which attenuates exponentially within
a larger surface layer.
The simulation is performed from the beginning of January until the end
of October 1989. As initial temperature the observed vertical profile from
the North Sea Project is taken. The meteorological data are obtained from
the UK Met Office.
Table 19.3: Settings of the model switches for the csnsp experiments. A “-”
means that the value of the switch is irrelevant.
switch A B C D E F G H I
iopt vdif coef 3 3 3 2 3 3 3 3 3
iopt turb alg - - - 2 - - - - -
iopt turb stab form 3 3 2 - 3 3 3 3 3
iopt turb iwlim 1 0 0 - 1 1 1 1 1
iopt temp optic 1 1 1 1 1 1 1 1 0
iopt sflux cds 6 6 6 6 4 6 5 0 6
iopt sflux cehs 0 0 0 0 3 0 4 0 0
iopt sflux strat 2 2 2 2 1 0 2 0 2
19.2.3 Results
turbulence schemes Time series of surface and bottom temperature, and
mixed layer depth for experiments A, B, C, D are compared in Figu-
res 19.4a, 19.5a. Vertical profiles on August 4 are shown in Figure 19.6a.
• Surface, bottom and mean temperature are not much different
between experiments A and B. The schemes are almost identical
except that the former uses a background mixing scheme based on
limiting conditions for turbulence parameters (see Section 4.4.3.6)
which results in a deeper thermocline and a less sharper tempera-
ture gradient in the thermocline.
• Comparing schemes A, C and D it is observed that the first (last
two) produce(s) larger (lower) surface temperatures, lower (larger)
bottom temperature and larger (lower) temperature gradients in
the thermocline. This shows that A is the least diffusive scheme.
This can be explained by the absence of a critical Richardson
number for the turbulence schemes used in C and D.
• The more diffusive scheme D produces an almost vertically mixed
water column at the end of October whereas a significant surface-
bottom temperature difference remains in the latter experiments.
This is clearly observed in Figure 19.4a.
• Less differences are observed for the depth-mean temperature, al-
though there seems to be a tendency for a higher mean tempera-
ture in case of tests C, D compared to A.
• An additional difference between schemes A, B and C, D is that
the mixed layer increases smoothly for the former cases whereas
19.2. TEST CASE CSNSP 559
an abrupt increase in mixed layer depth occurs for the latter cases
each time the surface temperature drops after a wind event during
summer.
drag and exchange coefficients Time series of surface and bottom tem-
perature, mixed layer depth, (upward) non-solar surface heat flux and
the exchange coefficient CE for experiments H, A, E, F, G are com-
pared in Figures 19.4b, 19.5b and 19.7a–b. Vertical profiles on August
4 are shown in Figure 19.6b.
• The differences between the five experiments are most easily seen
in the time series of the surface exchange coefficient. Compared
to the reference case H with constant values and the formulation
F, which does not include a dependence on air-sea temperature
difference, the CE coefficient increases by 50% in experiments A,
G and even by 100% (and occasionally 400%) in test E.
• Contrary to what one may expect intuitively, the differences are
inversely correlated with the behaviour seen in the evolution of the
heat fluxes. For example, experiment G which shows the lowest
time variability for CE , produces the largest maxima and lowest
minima for the heat fluxes. This is explained by a kind of relax-
ation effect. When CE increases, the heat flux will first increase
as well, so that the air-sea temperature difference is reduced. This
occurs quite rapidly and is not seen in the figures showing 3-day
averaged values. Once the difference is reduced the heat flux re-
laxes towards a lower value and CE rapidly decreases again. If
the initial increase of CE is lower, the time of relaxation becomes
longer. This behaviour can be deduced by a close inspection of
Figures 19.7.
• Despite the relaxation mechanism, the use of a stratification de-
pendent scheme for the exchange coefficients has an important
impact on the evolution of surface temperature in summer by de-
creasing its value by 20 C.
• Since all schemes use the same turbulence formulation, the impact
on diffusion, thermocline depth and stratification is less.
light attenuation When all solar light is absorbed at the surface itself and
no longer within the water column, a strong stratification is produced
in a shallow surface layer during periods of strong solar heating and
low winds. The result is a damping of turbulence and less downard
diffusion, yielding significantly larger surface temperatures (upto 50 C)
560CHAPTER 19. TURBULENCE AND HEAT FLUX FORMULATIONS
and shallower thermocline as seen in Figures 19.4 and 19.5. The ef-
fect on surface temperature is only temporary since the extra surface
stratification is removed once the wind increases again.
Figure 19.4: Test case csnsp. Time series (3-days average) of surface and
bottom temperatures: (a) experiment A (solid), B (dots), C (dashes), D
(dash-dots), I (dash and 3 dots); (b) experiment H (solid), A (dots), E
(dashes), F (dash-dots), G (dash and 3 dots).
562CHAPTER 19. TURBULENCE AND HEAT FLUX FORMULATIONS
Figure 19.5: Test case csnsp. Time series (3-days average) of mixed layer
depth. Legend is as in Figure 19.4.
19.2. TEST CASE CSNSP 563
Figure 19.7: Test case csnsp. Time series (3-days average) of (upward) non-
solar heat flux (a) and surface exchange coefficient CE (b) for experiment H
(solid), A (dots), E (dashes), F (dash-dots), G (dash and 3 dots).
Chapter 20
565
566 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
Table 20.1: Settings of the model switches for the river experiments. A “-”
means that the value of the switch is irrelevant.
switch A B C D
iopt adv 2D 1 1 1 3
iopt adv 3D 1 1 1 3
iopt vdif coef 3 2 2 3
iopt turb alg - 1 3 -
A the forcing amplitude taken as 0.8 m. At the right boundary, the nor-
mal gradient of the incoming Riemann variable R− is assumed to vanish, i.e.
∂R− /∂x = 0. This allows the tidal wave to propagate freely from left to
right. Since salinity remains vertically and horizontally homogeneous near
the channel ends during the entire simulation, a zero normal gradient condi-
tion is selected for salinity at the two open boundaries.
The tidal current field within the simulated domain is initialised by split-
ting the simulation in two phases. During a first spin-up phase of 2 days the
model is run without salinity. The salinity front is introduced at the start of
the second run which takes 3 days.
D : default scheme for turbulence, TVD scheme for the advection of mo-
mentum.
In all experiments the TVD scheme is applied for salinity. The values of the
model switches, used for setting up each experiment are given in Table 20.1.
The final run is performed for 6 tidal cycles. The evolution of the front
and the current field is shown in Figures 20.1b–f for the last cycle and the
scheme A at intervals of 3 hours. Use is made of the program’s utility for
20.1. TEST CASE RIVER 567
hfront The location of the point where the front outcrops the surface, mea-
sured by the distance in km of the 34 PSU contour line (taken at the
first grid cell below the surface) to the left boundary.
pdep The depth of the halocline measured 5 km to the left of the surface
front. This is determined as the depth in m of the point where the
salinity first equals 34.5 PSU.
hgrad This parameter measures the strength of the horizontal salinity gra-
dient below the surface layer and is defined as the maximum value of
|dS/dx| in PSU/km along a layer halfway between the surface and the
bottom. Note that the initial value, according to (20.1), is given by
0.25 PSU/km.
vgrad This parameter measures the sharpness of the halocline and is defined
as the maximum value of |dS/dz| in PSU/m along a vertical profile
at 5 km to the left of the surface front.
Figure 20.1: Test case river. Initial position of the salinity front (a). Evolu-
tion of the current and salinity fields during the last tidal cycle for experiment
A at intervals of 3 hours (b–f).
20.1. TEST CASE RIVER 569
Figure 20.2: Test case river. Residual salinity and current field for experi-
ment A analysed for day 1 (a), 2 (b), 3 (c). The same now for day 3 and
experiment B (d), C (e), D (f).
570 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
Figure 20.3: Test case river. Distributions of current and salinity at the end
of the simulation for experiment A (a), B (b), C (c), D (d).
20.1. TEST CASE RIVER 571
Figure 20.4: Test case river. Time series of the distance to the left boundary
of the point where the front outcrops the surface for experiment A (solid),
B (dots), C (dashes), D (dash-dots).
20.1.3 Results
The evolution of the frontal system for experiment A can be described as fol-
lows. The initial configuration represents a non-equilibrium state. Although
the model setup is different from the seich problem, where turbulent dif-
fusion is absent, there is some similarity. A circulation is generated with
a surface flow to the right, a bottom flow to the left, downwelling at the
right edge and upwelling at the left edge of the front. Contrary to the seich
test, the current is generated by a balance between the baroclinic pressure
gradient and the vertical diffusion term, induced by tidal friction (Officer,
1976). The initial evolution therefore consists of a slight displacement of the
surface front to the right and the bottom front to the left. The circulation
pattern is modulated by the tide so that at the end of the cycle the front al-
most returns to its original position. The turbulent diffusion term, however,
varies with the tide. This means that turbulence is suppressed during the
phases where the current reverses sign and the shear is low. At that time
the balance in the momentum equation is now mainly between the baroclinic
pressure and inertia terms as in the seich problem giving a net displace-
ment of the surface layer to the right. The surface and bottom layer are
separated by a halocline of increasing strength. The vertical stratification
572 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
reduces the turbulence even further and enhances the motion of the surface
layer to the right. Figure 20.4 shows that the front moves with an almost
uniform mean speed on which tidal modulations are superimposed. As the
front moves further out downwelling at the front due to frontal convergence,
first increases and then decreases. The main aspects of the physical analysis
can be observed in Figures 20.1b–f and Figure 20.4.
The results for the other three experiments can be summarised as follows:
• Experiment B uses the Paconowski-Philander scheme. Contrary to the
default scheme, turbulence is less reduced in the case of a strong stable
stratification. The result is a more diffusive halocline and a slower
outward expansion of the front.
emerging from these studies, is that the fresh water released at the river
mouth, first expands seawards and then turns anticyclonically (i.e. to the
right looking seawards in the northern hemisphere). Before reaching the
coast again, the plume water deflects in the cyclonic sense forming a buoy-
ancy driven coastal jet. The general form of the plume then consists of an
anticyclonic bulge with a coastal plume to the right (in the northern hemi-
sphere). The width of the plume is of the order of the baroclinic Rossby
radius (∼5–10 km).
The aim of the test case plume is to simulate the evolution of a tidally
modulated river plume using the idealised conditions of a uniform water
depth and no wind forcing. The computational domain has the form of a
rectangle enclosed by a coastal (solid) boundary and three open sea bounda-
ries. For convenience, the former will be denoted by the southern boundary,
the latter by the western, eastern cross-shore boundaries and the northern
alongshore boundary. The basin has a length of 120 km, a width of 40 km
and a depth of 20 m. The horizontal resolution is 1 km and 20 levels are used
in the vertical. The area is filled initially with seawater having a uniform sali-
nity of 33 PSU. The simulations are performed in Cartesian coordinates with
the x-axis taken alongshore and the y-axis across-shore (see Figure 20.5).
Tidal forcing is imposed in the form of a frictionless Kelvin wave entering
at the western boundary and propagating along the coast (Ruddick et al.,
1995). The incoming Riemann variable, specified at the western boundary,
then takes the form
ζ = Ae−y/c cos(ωt) , U = cζ (20.3)
where the Coriolis frequency is evaluated at a latitude of 52◦ , ω is the M2
tidal frequency, A = 0.8 m and U , c, ζ are as before the depth-integrated
alongshore current, the barotropic wave speed and the surface elevation. The
amplitude of the wave decreases exponentially with distance to the coast with
a decay scale given by the barotropic Rossby radius c/f ≃ 120 km.
The characteristic method with a zero normal gradient condition for the
incoming characteristic is selected at the eastern and northern boundaries.
The condition is justified by the fact that the width of the basin is much
smaller than the external Rossby radius c/f .
In a first phase the model is run for a period of two days (almost four tidal
cycles) without any stratification to initialise the current field and the sea
surface elevation. At the start of the the final run fresh water of 10 PSU is
released through an inlet at the southern boundary located 25.5 km from the
western boundary. The evolution of the plume is then simulated for a period
of three days. The procedures are the same as outlined in Section 20.1.1 for
the river test case.
574 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
Figure 20.5: The computational domain for the test case plume. The solid
line(s) indicate the coastal (southern) boundary, the dashed lines the open sea
boundaries and the dotted lines the two cross-shore transects AA′ (x = 30),
BB ′ (x = 50) and the two alongshore transects CC ′ (y = 2) and DD′ (y = 5).
The inlet is located at O. Points P and Q are used for the evaluation of a
number of output parameters (see text).
Since the value of ζ is unknown at the river mouth, the open boundary
condition at the inlet is no longer defined in terms of the incoming Riemann
variable but by specifying the cross-shore component of the depth-integrated
current. This is given as the sum of a residual value, representing the river
discharge, and a tidal component
V = Qd /W + Ar H cos(ωt − ϕr ) (20.4)
where Qd = 1500 m3 /s is the river discharge, W = 1 km the width of the
inlet and Ar = 0.6 m/s the amplitude of the tidal current at the mouth of
the river. The phase ϕr is determined by
ϕr = ωDr /c − π/2 (20.5)
where Dr = 25.5 km so that Dr /c represents the time travelled by the Kelvin
wave from the western boundary to the river mouth. Observations in the
20.2. TEST CASE PLUME 575
Rhine plume show that the alongshore and cross-shore component are in
anti-phase which explains the use of the factor π/2.
In addition to the previous conditions for the 2-D mode, open boundary
conditions have to be imposed during the final run for the horizontal baro-
clinic currents (δu, δv)1 and the salinity S. At the open sea boundaries a
zero normal gradient (default) condition is taken for all quantities. In the
case of salinity this procedure is a reasonable approximation since the plume
never intersects the western and northern boundary while the cross-boundary
gradient in the non-tidal case (experiment G below) is much smaller than
the along-boundary gradient at the eastern boundary.
The default conditions are no longer applicable at the river mouth where
δv and S are specified in the form of a two-layer stratification
S = 10 , δv = 0.6 if z > −δ
(20.6)
δv = −0.2 if −H ≤ z ≤ −δ
where δ = 5 m is the specified depth of the plume layer at the mouth. In this
way fresh water is released through the surface layer whereas saltier seawater
flows into the estuary through the bottom layer. A zero gradient condition
is applied for salinity in the bottom layer.
A series of output parameters are defined. The first four are evaluated
at intervals of 6 hours. For a location of the transects and points see Fi-
gure 20.5.
hbulge The width of the plume bulge. This is measured by the maximum
distance in km of the 32 PSU surface contour line from the coast.
20.2. TEST CASE PLUME 577
hwidth The width of the coastal plume measured by the distance from the
coast in km of the point where the 32 PSU surface contour line in-
tersects the transect BB ′ .
pdep Depth of the surface plume at point P measured by the distance to
the surface in m of the 30 PSU contour line.
hfront The length of the plume measured by the alongshore distance in km
between the river mouth and the point where the 32 PSU surface
contour line intersects the transect CC ′ .
sures
Surface value of the residual u-current at P (m/s).
svres
Surface value of the residual v-current at P (m/s).
selmaj
Surface value of the tidal ellipse’s major axis at P (m/s).
sellip
Ellipticity of the surface ellipse at P .
bures
Value of the residual u-current at P and 10 m depth (m/s).
bvres
Value of the residual v-current at P and 10 m depth (m/s).
belmaj
Value of the tidal ellipse’s major axis at P and 10 m depth (m/s).
bellip
Ellipticity of the tidal ellipse at P and 10 m depth.
dures
Residual value of the depth-averaged u-current at Q (m/s).
duamp
Amplitude of the depth-averaged u-current at Q (m/s).
dupha
Phase of the depth-averaged u-current at Q (degrees).
zetres
Residual surface elevation at Q (m).
578 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
zetamp
Amplitude of the sea surface elevation at Q (m).
zetpha
Phase of the sea surface elevation at Q (degrees).
The residual values for experiment G are obtained by taking averaged values
over the last 12 hours.
20.2.3 Results
• Figures 20.6 clearly show how the plume evolves during a tidal cycle.
At the time when the alongshore current reverses sign and the outflow
reaches its maximum, a new blob of fresh water enters the basin, moving
seawards. As the eastward directed tidal wave becomes stronger, the
fresh water patch is deflected to the right. During this phase of the
tide both the bulge and the coastal plume expand seawards. When
the tidal current reverses sign again and turns to the west, the current
inside the plume is first southeastwards pushing the bulge towards the
coast and finally southwestwards reducing the extent of the bulge and
the coastal plume. Since the tidal current enforces the anticyclonic
motion inside the bulge, the results are similar to the ones obtained for
non-tidal plumes. The main difference here is that the bulge and the
coastal plume oscillate with the tide.
• After a few tidal cycles (Figures 20.7) the structure of tidal and non-
tidal plumes are manifestly different. While in the latter case the tran-
sition between the bulge and the coastal plume is clearly observed, no
clear distinction can be made in the former case. This effect is due to
increased turbulent diffusivity which reduces the anticyclonic vorticity
inside the bulge and the strength of the coastal current. The effect be-
comes more pronounced when more horizontal diffusion is introduced
in the simulation either by using the upwind scheme for momentum
advection or by adding horizontal diffusion terms in the momentum
and salinity equations.
• The residual fields along the two transects AA′ and DD′ (Figures 20.8)
show the presence of an estuarine-type circulation. In the cross-shore
transect upwelling takes place at the coast while downwelling occurs
at the edge of the plume by the convergence of the surface outflow
current. A similar phenomenon is seen in the coastal jet where down-
welling motions are created by the convergence of the coastal jet. In the
case of a non-tidal plume the plume layer is shallower and the frontal
20.2. TEST CASE PLUME 579
Figure 20.6: Test case plume. Surface distributions of currents and salinity
for experiment A at 24 h (a), 27 h (b), 30 h (c) 33 h (d), 36 h (e).
580 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
Figure 20.7: Test case plume. Residual surface distributions of currents and
salinity for the last tidal cycle and experiment A (a), B (b), C (c), D (d),
E (e), G (f).
20.2. TEST CASE PLUME 581
Figure 20.8: Test case plume. Residual distributions of currents and salinity
for the last tidal cycle along the cross-shore transect AA′ for experiment A
(a), G (b), and at the alongshore transect DD′ for experiment A (c), G (d).
Figure 20.9: Test case plume. Time series of the plume width taken as the
cross-shore distance of the 32 PSU contour line from the mouth (a) and of
the plume length at the transect CC ′ (b) for experiments A (solid), B (dots),
D (dashes), E (dash-dots) and G (dash and 2 dots).
582 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
Figure 20.10: Test case plume. Ellipticity of the tidal ellipses for experiment
A: surface (a) and bottom (b) distributions. Negative and positive values
are drawn by dashed, respectively solid lines. The analysis is performed for
the last tidal cycle.
gradients are stronger compared to the tidal case where turbulent dif-
fusion increases the depth of the surface layer and reduces the vertical
stratification.
• The oscillations of the plume shape induced by the tide are clearly ob-
served in Figures 20.9. In the absence of tides the width of the bulge
first grows in time levelling off after 10–12 hours which is comparable
to the inertial period of ∼ 15 h. A somewhat similar behaviour can
be deduced for the tidal case where the mean growth curve is strongly
modulated by the tide. The length of the plume increases linearly in the
non-tidal case. In the presence of tides the growth is strongly reduced
as found previously and seems to decrease asymptotically. The exper-
iments with horizontal diffusion show a slower growth of the coastal
plume.
Figure 20.11: Test case plume. Distributions of the major axis (m/s) of the
tidal ellipse for the depth-averaged current and A (a), E (b), F (c) and of
the M2 surface elevation amplitude and A (d), E (e), F (f).
584 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
major axis of the tidal current is clearly stronger inside the plume due
to the reduction of the turbulence and the bottom shear stress. No
significant change is found for the amplitude of the surface elevation.
• Figures 20.11 compare the three different formulations for the tidal for-
cing at the western boundary, represented by experiments A, E and
F. Although the results are qualitatively the same, there are important
quantitative differences. On the other hand, the results shown in Figu-
res 20.10, 20.11a and 20.11d are practically the same for experiments
A, B, C and D suggesting that horizontal diffusion has no significant
influence on the tidal currents (at least for this idealised test case).
on the other hand confines the plume even more to the coast while the fresh
water spreads in eastward direction and may attain the Gulf of Fos.
The frontal boundary of a river plume is not only characterised by strong
gradients of salinity but also by front convergence, i.e. a strong negative
gradient of the current towards to the front. Forget et al. (1990) used a
VHF radar technique to determine the plume boundary by measuring the
current in the direction of the radar beam. The frontal boundary can easily
be identified by a jump (∼20 cm/s) in the current field. Inside the plume
values of 50 cm/s were measured.
The river plume can be identified in the salinity field by two frontal
regimes.When the low salinity water (10–15 PSU) of the Rhone river dis-
charges into the the Gulf of Lions (∼ 38 PSU), the fresh water spreads out-
wards in the form of a highly stratified (∼10 PSU/m) surface layer with low
turbulence and a thickness of a few meters, floating above a mixed bottom
layer. Flow convergence occurs at the edge of the plume. This area, often
visible by foam, has a width of only a few hundred meters and acts as a
source for the accumulation of dissolved material, sediments and nutrients.
At the lateral frontal boundary the horizontal gradient is of the order of 7
PSU/km. Salinity measurements in the Rhone plume are reported by e.g.
Sournia et al. (1990); Naudin et al. (1992).
The domain of the simulations, covers the area between 430 05′ – 430 30′ N
and 40 07′ – 50 28′ E. The X- and Y-axis are directed respectively along the
West-East and South -North directions. The horizontal resolutions are given
by ∆φ = 30′′ in latitude and ∆λ = 45′′ in longitude which corresponds
approximatively to a 1×1 km grid.
The bathymetry of the area is displayed in Figure 20.12. The estuary
of the Rhone river is approximated by a straight channel having a width of
1 km and a length of 6.5 km (7 grid cells). Fresh water (salinity of 10 PSU)
is discharged at the head of the channel. The bathymetry in front of the
river mouth is characterised by a strong seaward bottom slope with a water
depth increasing from 10 m at the mouth upto 100 m at distance of ∼10 km
from the coast. The strongest gradient occurs within a distance of only 1 km
from the mouth. To represent this effect in the model a seaward bottom
slope is introduced inside the channel allowing the water depth to increase
from 5 m at the head of the channel to 20 m at the mouth. Other areas of
interest for the plume study are the Gulf of Fos, located at the East of the
river mouth which is a shallow area with depths between 5 and 20 m, and
the Camargue coast to the West where the water depth increases less rapidly
with the distance to the coast.
• Time steps are 10 s for the 2-D and 180 s for the 3-D mode and the
simulations are performed for a period of 4 days.
• The simulations start with zero initial currents and a uniform salinity
of 38.1 PSU.
• The river discharge at the river mouth is taken as uniform in time and
over the vertical which means that the baroclinic current at the mouth
is set to zero. The salinity of the fresh water release is set to 10 PSU.
In all wind experiments the wind is set to zero during the first two days.
Figure 20.13: Test case rhone. Surface distributions for salinity and currents
for experiment A (a), B (b), C (c). The arrows on the southern boundary
locate the positions of the South-North transects shown in Figures 20.14 and
20.15.
20.3.3 Results
The following series of figures are produced for all experiments at the end
of simulation. Surface plume and currents are shown for all epxeriments in
Figures 20.13 and 20.16, salinity and current distributions are displayed along
different vertical transects in Figures 20.14, 20.15 and 20.17. Time series of
the plume area, as defined by the test parameter area34 are displayed in
Figures 20.18.
1. No wind experiments.
Figure 20.14: Test case rhone. Distribution of currents and salinity along a
vertical transect at 4.850 E through the river mouth for experiment A (a), B
(b), C (c).
590 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
Figure 20.15: Test case rhone. Distribution of currents and salinity along a
vertical transect at 4.450 E for experiment A (a), B (b), C (c).
20.3. TEST CASE RHONE 591
Figure 20.16: Test case rhone. Surface distributions for salinity and cur-
rents for experiment D (a), E (b), F (c), G (d). The arrow on the southern
boundary locates the position of the South-North transects shown in Figu-
res 20.17.
592 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
Figure 20.17: Test case rhone. Distribution of currents and salinity along a
vertical transect for experiment D at 4.850 E (a), E at 50 E (b), F at 4.70 (c)
and G at 4.70 E (d).
20.3. TEST CASE RHONE 593
Figure 20.18: Test case rhone. Plume area as defined as the area between
the coast and the 34 PSU contour line: (a) experiment A (solid), B dots),
C (dashes); (b) experiment D (solid), E (dots), F (dashes), G (dash-dots).
594 CHAPTER 20. DENSITY FRONTS AND RIVER PLUMES
2. Wind experiments.
Outside the surface plume, the direction of the surface flow is deter-
mined by surface and bottom friction. In the shallow parts where the
surface current “feels” the bottom friction, the current flows predom-
inantly in the direction of the wind. In the deeper parts the surface
current turns to the right by Ekman drift. Within the plume the wind-
and plume-driven currents interact in a more complex way. As can be
seen in Figures 20.16 and is known from satellite images, the wind has
a large impact on size and direction of the plume. Each experiment is
further discussed below.
∼5 m (Figure 20.17d).
Chapter 21
Inundation schemes
ζ = ζa cos(ωt − π) (21.1)
597
598 CHAPTER 21. INUNDATION SCHEMES
Figure 21.1: Test case flood2d. Bathymetry (solid) and initial water level
(dots) for configuration 1 (a) and 2 (b) used in flood2d. Also shown are the
three areas used for the definition of test case parameters.
21.1. TEST CASE FLOOD2D 599
δV m+1 = δV m + ∆2 m+1 m
X
(Hi1 − Hi1 ) − Ub W δτ (21.4)
i
21.1.3 Results
• Comparison of the test case parameters and time series of the currents
and elevations (not shown for tests A and C) reveal that the differences
between the two drying/wetting algorithms are small. Only noticeable
difference is that the dry area is slightly larger for the second scheme.
The main difference is mass conservation, further discussed below.
• In the sloping bottom experiment, the flow of the rising water retards
when the water mass reaches the edge of the shelf at 1.4 m depth.
Flow divergence, followed by convergence, is observed when the tidal
wave moves over the shallower area in the middle of the channel. This
shallowing effect is reduced with the approach of the flood tide. The
reverse effect occurs when the water recedes from the coast. As the
water depth over the outer shelf approaches its minimal value, the flow
retards by bottom friction. This explains why water is still falling from
the edge into the deeper basin at the ebb tide even when the water
level in the deeper part is already 0.6 m below the shelf.
21.1. TEST CASE FLOOD2D 601
• The second experiment with the large obstacle in the middle of the
channel, is a similar, but more extreme case. As the water mass moves
past the obstacle, the water forms a thin layer and falls abruptly into
the coastal basin (Figure 21.3a). The wave, generated by the falling
water masses downhill of the slope, reflects at the coast1 . The re-
flected wave opposes the tidal current (Figure 21.3b) and even creates
a temporarily flow reserval. At the approach of the maximum flood,
the wave decreases in amplitude and the tidal current reappears (Fi-
gure 21.3c). Some similar wave behaviour is observed at ebb tide when
the layer above the obstacle thins and water falls downhill into the west-
ern deeper part of the channel. The wave does not propagate entirely
through the open boundary which could explain the vertical oscillations
at ebb tide (Figure 21.3f). The oscillation gradually damps out at the
start of the next tidal cycle and disappears about one hour after the
onset of the flood tide (not shown).
1
It is remarked that the hydrostatic assumption may no longer be valid in this case.
602 CHAPTER 21. INUNDATION SCHEMES
Figure 21.2: Test case flood2d. Time series of currents and surface elevations
during the first tidal cycle and experiment flood2dB.
21.1. TEST CASE FLOOD2D 603
Figure 21.3: Test case flood2d. Time series of currents and surface elevations
during the first tidal cycle and experiment flood2dD.
604 CHAPTER 21. INUNDATION SCHEMES
Figure 21.4: Test case flood2d. Time series of the dry area fraction and
experiment A (solid), B (dots), C (dashes) and D (dash-dots).
21.1. TEST CASE FLOOD2D 605
Figure 21.5: Test case flood2d. Time series of the maximum water depth
error for experiment A (solid), B (dots), and the mean depth error for ex-
periment A (dashes) and B (dash-dots).
606 CHAPTER 21. INUNDATION SCHEMES
B : Flow over a gently sloped “crater” rim in the center of the domain
(second bathymetry).
All experiment use the same drying/wetting scheme with the default mask
function.
Time series of currents and water levels for the first tidal cycle are shown
in Figures 21.7, 21.9, 21.11 for respectively experiments A,B,C. Depth mean
currents and total water depths are displayed as time series for the first cycle
in Figures 21.8, 21.10, 21.12, 21.13 for respectively experiments A, B, C,
D. Time series of the dry area fraction, and the maximum depth error ∆he ,
as defined in Section 5.4.1, are given in Figures 21.14, respectively 21.15.
The following output parameters are defined:
21.2. TEST CASE FLOOD3D 607
Figure 21.6: Test case flood3d. Bathymetry (solid) and initial water level
(dots) along a transect normal to the open boundary and through the center
of the basin for the three different configurations used in flood3d (left). Top
view of the bathymetry (right).
608 CHAPTER 21. INUNDATION SCHEMES
21.2.3 Results
• It is readily observed that all solutions are symmetric with respect to
the vertical transect in the X-direction passing through the center of
the basin.
• In the case of an isolated hill (experiment A), the flooding and drying
process proceeds smoothly. During the rising tide, the incoming east-
ward flow in the central part deflects in the along-hill direction when
it approaches the hill boundary. In the more southern (northern) parts
the water flows unimpeded until it reaches the solid eastern boundary
where it deflects to the left (right). The result is a cyclonic (anticy-
clonic) circulation below (above) the center line during the rising tide.
The circulation reverses with the onset of the ebb tide. At first, the
top of the hill is still inundated and the flow is mainly westward. As
soon as the drying starts on the top of the hill, the water masses close
to the dry area start to flow both along and away from the hill.
21.2. TEST CASE FLOOD3D 609
Figure 21.7: Test case flood3d. Time series of currents and elevations during
the first tidal cycle and along a transect normal to the open boundary and
through the center of the basin for experiment flood3dA.
610 CHAPTER 21. INUNDATION SCHEMES
Figure 21.8: Test case flood3d. Time series of horizontal depth mean cur-
rents and water depths during the first tidal cycle and experiment flood3dA.
21.2. TEST CASE FLOOD3D 611
Figure 21.9: Test case flood3d. Time series of currents and elevations during
the first tidal cycle and along a transect normal to the open boundary and
through the center of the basin for experiment flood3dB.
612 CHAPTER 21. INUNDATION SCHEMES
Figure 21.10: Test case flood3d. Time series of horizontal depth mean cur-
rents and water depths during the first tidal cycle and experiment flood3dB.
21.2. TEST CASE FLOOD3D 613
Figure 21.11: Test case flood3d. Time series of currents and elevations
during the first tidal cycle and along a transect normal to the open boundary
and through the center of the basin for experiment flood3dC.
614 CHAPTER 21. INUNDATION SCHEMES
Figure 21.12: Test case flood3d. Time series of horizontal depth mean cur-
rents and water depths during the first tidal cycle and experiment flood3dC.
21.2. TEST CASE FLOOD3D 615
Figure 21.13: Test case flood3d. Time series of horizontal depth mean cur-
rents and water depths during the first tidal cycle and experiment flood3dD.
616 CHAPTER 21. INUNDATION SCHEMES
Figure 21.14: Test case flood3d. Time series of the dry area fraction and
experiment A (solid), B (dots), C (dashes) and D (dash-dots).
21.2. TEST CASE FLOOD3D 617
Figure 21.15: Test case flood3d. Time series of the maximum water depth
error for experiment A (solid), B (dots), C (dashes) and D (dash-dots).
618 CHAPTER 21. INUNDATION SCHEMES
• The maximum depth error, which occurs at the top of the mountain
(experiment A) or at the crater rim (B, C), is of the order of 1 cm per
cycle. Note that error in case of the 2-D test D is negligible small, which
may be related to the observation in Figure 21.14 that no “effective
drying” (as defined by the mask criterium) seems to occur.
2
It is remarked that the hydrostatic assumption may no longer be valid in this case.
Chapter 22
The aim of this test case is to illustrate the use of COHERENS for tidal
prediction studies, to show how an harmonic analysis can be performed and
how an analysis can be made of the distribution, propagation and dissipation
of tidal energy. The Bohai Sea is situated in the northern part of the Yellow
Sea between the Northeast coast of China and the Korean peninsula. The
simulated area is between 1170 5′ E–1250 35′ E and 370 –410 5′ N. Water depths,
shown in Figure 22.1, are lower than 50 m in the western and between 60–
85 m in the central eastern part.
The tides enter the domain through the southern boundary. Two tidal
constituents (M2 and S2 ) are imposed in harmonic form, as given by equa-
tion (4.340) without the first (residual) term. The grid has an horizontal
resolution of 5′ in longitude and latitude. The time step for the barotropic
(2-D) mode is 30 s. The simulations are performed either in depth-averaged
mode or using a full 3-D grid. In the former case, the bottom stress is cal-
culated using the 2-D quadratic law (4.329) and a constant bottom drag
coefficient Cdb =0.00237. In the latter case, the 3-D quadratic law (4.328)
is taken, the bottom drag coefficient is calculated from (4.330) using a con-
stant roughness length z0 =0.0035 m, the baroclinic time step is set to 5 min
and 20 uniform σ-levels are taken in the vertical. The simulated period is 16
days, covering a full spring-neap cycle. Results are harmonically analysed for
the two tidal constituents. Analysed output consists of the amplitudes and
phases of water levels and currents, parameters of tidal ellipses and energy
parameters (kinetic and potential energy, energy dissipation and fluxes).
619
620 CHAPTER 22. SHELF SEA MODELLING
Figure 22.1: Bathymetry of the Bohai Sea. The diamond symbols locate the
position of the 4 four stations used in the definition of the output parameters.
A series of output parameters are defined. The first five are global resid-
uals obtained from the harmonic analysis.
ekin The domain integrated kinetic energy hE k i (in 1015 J) with E k defined
by (D.8) in the 2-D and (D.11) in the 2-D case.
epot The domain integrated potential energy hEp i (in 1015 J) with Ep de-
fined by (D.3).
etot The domain integrated total energy (in 1015 J) given as the sum of
ekin and epot.
bdissip The domain integrated negative energy dissipation -hDi with D de-
fined by (D.13) in the 2-D or (D.10) in the 3-D case.
The next series of parameters gives the location of the four amphidromic
points (two for the M2 and two for the S2 tide) which are determined as
local minima of ζ.
The last series of parameters are the amplitudes and phases of the surface
elevation, and the elliptic parameters obtained from harmonic analysis for
the two tidal constituents at 4 stations.
22.1.2 Results
The following figures are produced for experiment A.
• Amplitudes and phases of the sea surface elevation, major axis and
ellipticity of the tidal ellipse are shown in Figures 22.2 for the M2 and
22.3 for the S2 tide.
• Figure 22.4 displays time series of the domain averaged kinetic, poten-
tail, total energy and energy dissipation.
• Spatial distributions of the residual depth-mean tidal energy, energy
dissipation and tidal energy flux, as defined by equations (D.11), (D.13)
and (D.12) are given in Figure 22.5.
The results can be summarised as follows
• Both the M2 and S2 tide show the same two amphidromic points located
respectively in the Southwest and Southeast parts of the domain. The
positions are the same for all experiments.
• From figures 22.2 and 22.3 one infers that the M2 amplitudes for ele-
vation and currents are 2 to 2.5 times higher than the ones obtained
from the S2 tide. The tides themselves show a strong variability over
the domain with much larger amplitudes for elevations and currents
(up to a factor 5) in the eastern compared to the western parts. From
the distributions of tidal ellipticity one observes rapid changes from
nearly circular to rectilinear ellipses and from cyclonic to anticyclonic
motions.
• There is no difference between the tests using the open boundary condi-
tion with the local solution and the one with the characteristic method
and a very small difference with the test using the Flather condition,
both for the 2-D as for the 3-D case. Larger differences are seen be-
tween the 2-D and 3-D runs. Although these can be still be considered
as small for the amplitudes, a phase difference of a few degrees can
be observed. Since the tidal flow is mainly barotropic with no shear,
except at the bottom (not shown), this can only be explained by the
different formulation for the bottom stress.
• The residual and domain-averaged kinetic and potential are nearly the
same, in analogy with linear surface waves. The time series of the non-
analysed energy parameters exhibits a strong spring-neap cycle since
the amplitude ratio equals the square of the ones obtained for elevations
and currents.
22.1. TEST CASE BOHAI 623
Figure 22.4: Time series of (a) the domain-integrated kinetic energy (1015 J),
(b) potential energy (1015 J), (c) total energy (1015 J) and (d) energy dissipa-
tion (109 W) for experiment bohaiA.
626 CHAPTER 22. SHELF SEA MODELLING
627
628 APPENDIX A. TRANSFORMED MODEL EQUATIONS
∗ ∗
+Dmh1 (τ11 ) + Dmh2 (τ12 )
(A.5)
!
∂v u ∂v v ∂v ∂v u ∂h2 ∂h1
+ + +w + v −u + 2Ωu sin φ
∂t h1 ∂ξ1 h2 ∂ξ2 ∂z h1 h2 ∂ξ1 ∂ξ2
!
g ∂ζ 1 ∂Pa 1 ∂q t ∂ ∂v
=− − − + F2 + νT
h1 ∂ξ2 ρo h2 ∂ξ2 h2 ∂ξ2 ∂z ∂z
∗ ∗
+Dmh1 (τ21 ) + Dmh2 (τ22 )
(A.6)
!
∂ψ u ∂ψ v ∂ψ ∂ψ ∂ ∂ψ
+ + +w = S(ψ) + λT
∂t h1 ∂ξ1 h2 ∂ξ2 ∂z ∂z ∂z
" ! !#
1 ∂ h2 ∂ψ ∂ h1 ∂ψ
+ λH + λH (A.7)
h1 h2 ∂ξ1 h1 ∂ξ1 ∂ξ2 h2 ∂ξ2
where the derivatives on the left hand side in the first two relations are taken
along constant z-surfaces and the first ones on the right side along constant
s-surfaces. The following useful relations can be derived from (A.11)–(A.13)
∂s 1 ∂z
= , = h3 (A.14)
∂z h3 ∂s
∂z ∂s
+ h3 =0 (A.15)
∂ ξ˜i ∂ξi
∂h3 ∂s ∂h3
+ =0 (A.16)
∂ t̃ ∂t ∂s
! ! !
∂h3 ∂ ∂z ∂ ∂z ∂ ∂s
= = =− h3 (A.17)
∂ ξ˜i ∂ ξ˜i ∂s ∂s ∂ ξ˜i ∂s ∂ξi
∂z ∂s ∂z ∂s
=− = −h3 (A.18)
∂ t̃ ∂t ∂s ∂t
A new vertical velocity is defined by
ds
ω = h3
dt !
∂s u ∂s v ∂s ∂s
= h3 + + +w
∂t h1 ∂ξ1 h2 ∂ξ2 ∂z
!
∂s u ∂s v ∂s
= h3 + + +w (A.19)
∂t h1 ∂ξ1 h2 ∂ξ2
from which (4.61) is obtained.
The continuity equation (A.4) is rewritten in the transformed coordinate
system with the aid of the previous relations
" #
1 ∂ ∂ ∂w
0 = (h2 u) + (h1 v) +
h1 h2 ∂ξ1 ∂ξ2 ∂z
" #
1 ∂ ∂ ∂s ∂ ∂s ∂ 1 ∂w
= (h2 u) + (h1 v) + (uh2 ) + (vh1 ) +
h1 h2 ∂ ξ˜1 ∂ ξ˜2 ∂ξ1 ∂s ∂ξ2 ∂s h3 ∂s
1 ∂ ∂ ∂s ∂ ∂h3
= (h2 h3 u) + (h1 h3 v) + h3 (uh2 ) − uh2
h1 h2 h3 ∂ ξ˜1 ∂ ξ˜2 ∂ξ1 ∂s ∂ ξ˜1
∂s ∂ ∂h3 1 ∂w
+ h3 (vh1 ) − vh1 +
∂ξ2 ∂s ∂ ξ˜2 h3 ∂s
!
1 ∂ ∂ ∂s ∂ ∂ ∂s
= (h2 h3 u) + (h1 h3 v) + h3 (uh2 ) + uh2 h3
h1 h2 h3 ∂ ξ˜1 ∂ ξ˜2 ∂ξ1 ∂s ∂s ∂ξ1
!
∂s ∂ ∂ ∂s 1 ∂w
+ h3 (vh1 ) + vh1 h3 +
∂ξ2 ∂s ∂s ∂ξ2 h3 ∂s
630 APPENDIX A. TRANSFORMED MODEL EQUATIONS
" !#
1 ∂ ∂ ∂ ∂s ∂s 1 ∂w
= (h2 h3 u) + (h1 h3 v) + h2 h3 u + h1 h3 v +
˜
h 1 h 2 h 3 ∂ ξ1 ˜
∂ ξ2 ∂s ∂ξ1 ∂ξ2 h3 ∂s
" # " #
1 ∂ ∂ 1 ∂ h3 ∂s h3 ∂s
= (h2 h3 u) + (h1 h3 v) + w+ u + v
h1 h2 h3 ∂ ξ˜1 ∂ ξ˜2 h3 ∂s h1 ∂ξ1 h2 ∂ξ2
" # !
1 ∂ ∂ 1 ∂ ∂s
= (h2 h3 u) + (h1 h3 v) + ω − h3
h1 h2 h3 ∂ ξ˜1 ∂ ξ˜2 h3 ∂s ∂t
" # !
1 ∂ ∂ 1 ∂ω 1 ∂h3 ∂s ∂ ∂s
= (h2 h3 u) + (h1 h3 v) + − −
h1 h2 h3 ∂ ξ˜1 ∂ ξ˜2 h3 ∂s h3 ∂s ∂t ∂s ∂t
" #
1 ∂h3 1 ∂ ∂ 1 ∂ω
= + (h2 h3 u) + (h1 h3 v) + (A.20)
h3 ∂ t̃ ˜
h 1 h 2 h 3 ∂ ξ1 ˜
∂ ξ2 h3 ∂s
∂ψ u ∂ψ v ∂ψ ω ∂ψ
= + + +
∂ t̃ h1 ∂ ξ˜1 h2 ∂ ξ˜2 h3 ∂s
" #
1 ∂ 1 ∂ ∂ 1 ∂
= (h3 ψ) + (h2 h3 uψ) + (h1 h3 vψ) + (ψω)
h3 ∂ t̃ h1 h2 h3 ∂ξ1 ∂ξ2 h3 ∂s
" #
ψ ∂h3 ψ ∂ ∂ ψ ∂ω
− − (h2 h3 u) + (h1 h3 v) −
h3 ∂ t̃ h1 h2 h3 ∂ξ1 ∂ξ2 h3 ∂s
" #
1 ∂ 1 ∂ ∂ 1 ∂
= (h3 ψ) + (h2 h3 uψ) + (h1 h3 vψ) + (ψω)
h3 ∂ t̃ h1 h2 h3 ∂ξ1 ∂ξ2 h3 ∂s
(A.23)
by virtue of (A.20).
The horizontal gradient of a vertically independent quantity obviously
does not change. For a 3-D quantity one has
" #
1 ∂ψ 1 ∂ψ ∂s ∂ψ
= +
hi ∂ξi hi ∂ ξ˜i ∂ξi ∂s
" #
1 1 ∂ ψ ∂h3 ∂s ∂ψ
= (h3 ψ) − +
hi h3 ∂ ξ˜i h3 ∂ ξ˜i ∂ξi ∂s
" ! #
1 1 ∂ ψ ∂ ∂s ∂s ∂ψ
= (h3 ψ) + h3 +
hi h3 ∂ ξ˜i h3 ∂s ∂ξi ∂ξi ∂s
" !#
1 1 ∂ 1 ∂ ∂s
= (h3 ψ) + h3 ψ
hi h3 ∂ ξ˜i h3 ∂s ∂ξi
" !#
1 ∂ ∂ ∂z
= (h3 ψ) − ψ (A.24)
˜
h i h 3 ∂ ξi ∂s ∂ ξ˜i
h2 i h
c1β (1 − c21 + 2c23 ) − c22β c1 αM Su + c1 c21β − c1 c22β (1 − c21β )αM
3
633
634 APPENDIX B. SOLUTIONS OF THE RANS EQUATIONS
2 i 2
+ 2c1β c1 Rβ⋆ + (1 − c3 ) αN Sb = c1 c1β
3 3
(B.3)
The solution can be written in the form, given by (4.170). The coefficients
Ca1 –Ca11 take the following values
2α1
Ca1 =
3c1
2α1 (1 − c21β )c22β
Ca2 = −
3c1 c21β
2 h 2(c − c ) 1 − c21β
23 22
i
Ca3 = − (1 − c3 ) + − 2Rβ⋆ α1
3c1 c1β c1 c1β
2
Ca4 =
3c1β
2 h 2 c22β i
Ca5 = α2 − α1 (1 − c21 + 2c23 ) + α1
3c1 c1β 3c1 c1β
2(1 − c3 )
Ca6 =
3c1 c21β
2α2 c22β (1 − c21β )
Ca7 = −
3c21 c21β
" #
1 7(1 − c3 )
Ca8 = + 2Rβ⋆
c1β 3c1
2c22β (1 − c21β )α2
Ca9 = −
3c21 c21β
2 n h 2c
23
Ca10 = 2
(1 − c 3 ) (1 − c21 )
3c1 c1β c1
1 i o
+ c22β (2 − 2c21 + c23 ) − (1 − c21β )(1 − c21 + 2c23 ) + 2Rβ⋆ α2
c1β
" #
2(1 − c3 ) 2(1 − c3 )
Ca11 = + Rβ⋆
c1 c21β 3c1
(B.4)
h 2 i
c1 c21β − c1 (1 − c21β )c22β αM + (2c1 c1β Rβ⋆ + c1β α3 − c1 c22β )αN Sb
3
2
= c1β (c1 − 1 + c21 − 2c23 ) + c1 c22β (B.6)
3
If c22β = 0, the solutions can be cast in the form (4.175) where
2α5
Cb1 =
3c1
2 h 2 2α6
Cb2 = (α3 α5 − α6 ) + 2 (1 − c21 + 2c23 )
3c1 c1β 3c1 3c1
(1 − c3 )(1 − c21β ) 1 i
− 1 − (1 − c21 + 2c23 ) + 2α5 Rβ⋆
c1β c1
2 α3
Cb3 = Rβ⋆ +
c1β 3c1
1 − c3
Cb4 =
c1 c1β
2 1
Cb5 = 1 − (1 − c21 + 2c23 ) (B.7)
3c1β c1
If c22β 6= 0 the solutions are given by (4.176)–(4.177) with
2α5
Cc1 =
3c1
" #
1 2α6 (1 − c3 )(1 − c21β )
Cc2 = − +
c1 3c1 c1β
1 − c3
Cc3 =
c1 c1β
!
h 2α
6 1 − c21β c22β 1 − c3 i
Cc4 = − + +
3c21 c1β c1β c1
!
2 h α6 2α3 c22β (1 − c3 )(1 − c21β ) α3 i
⋆ ⋆
Cc5 = − 2Rβ + − + 3Rβ +
3c1 c1β c1 3c1 c1β c1β c1
2α5 (1 − c21β )c22β
Cc6 = −
3c1 c21β
636 APPENDIX B. SOLUTIONS OF THE RANS EQUATIONS
2 h 2 α3 α5 + α6 α6 (1 − c21 + 2c23 )
Cc7 = −
3c1 c1β 3 c1 c21
(1 − c3 )(1 − c21β ) 1 − c21 + 2c23 c22β α6 i
+ 1− − (α5 − ) + 2α5 Rβ⋆
c1β c1 c1β c1
2α5 2 2 c22β
Cc8 = − − (1 − c21 + 2c23 ) + (B.8)
3c1 c1β 3 3c1 c1β
The Coriolis terms in the 2-D and 3-D momentum equations are discretised
in time using a “quasi”-implicit formulation. The time discretised equations
are written as
un+1 − un
− f θc v n+1 + (1 − θc )v n = F1 (C.1)
∆t
v n+1 − v n
+ f θc un+1 + (1 − θc )un = F2 (C.2)
∆t
where Fi represent all other (explicit and implicit) terms (pressure gradient,
advection, diffusion, tidal force). The solution proceeds in two steps
1. Equations (C.1–(C.2) are solved explicitly for the Coriolis force (θc =
0). This gives
u∗ = un + ∆t(F1 + f v n ) (C.3)
v ∗ = v n + ∆t(F2 − f un ) (C.4)
637
638 APPENDIX C. DISCRETISATION OF THE CORIOLIS FORCE
where
∆u = u∗ − un , ∆v = v ∗ − v n (C.9)
• The forcing terms Fi on the right hand side of (C.1)–(C.2) contain both
explicit and implicit terms. A simplification has been made since the
latter one are taken at level ∗ and not at the new time tn+1 .
• In the 3-D case the new time level tn+1 is replaced by the predictor step
tp .
1 ∂ 1 ∂Ep 1 h ∂ ∂ i
(h3 Ek ) + + (h2 h3 F1 ) + (h1 h3 F2 ) = D (D.1)
h3 ∂t H ∂t h1 h2 h3 ∂ξ1 ∂ξ2
where
1
Ek = ρ0 (u2 + v 2 ) (D.2)
2
is the kinetic energy,
1
Ep = ρ0 gζ 2 (D.3)
2
the potential energy,
1
(F1 , F2 ) = ρ0 (u2 + v 2 ) + ρ0 gζ (u, v, ω) (D.4)
2
the energy flux vector and
u ∂D v ∂D2
1
D = ρ0 + (D.5)
h3 ∂s h3 ∂s
the dissipation of energy by turbulent diffusion. The diffusion fluxes are given
by
ν ∂u ν ∂v
T T
(D1 , D2 )= , inside the water column
h3 ∂s h3 ∂s
= (τs1 , τs2 ) at the surface (D.6)
= (τb1 , τb2 ) at the bottom
639
640 APPENDIX D. ENERGY BALANCE EQUATION
∂ 1 h ∂ ∂ i
(E k + Ep ) + (h2 F 1 ) + (h1 F 2 ) = D (D.7)
∂t h1 h2 ∂ξ1 ∂ξ2
where
1 Z Nz
E k = ρ0 h3 (u2 + v 2 ) ds (D.8)
2 0
Z Nz h
1 i
(F1 , F 2 ) = h3 ρ0 (u2 + v 2 ) + ρ0 gζ (u, v) ds (D.9)
0 2
Z Nz
νT h ∂u 2 ∂v 2 i
D = ρ0 (us τs1 + vs τs2 − ub τb1 − vb τb2 ) − ρ0 + ds (D.10)
0 h3 ∂s ∂s
where (us ,vs ) and (ub ,vb ) are the velocities at respectively the surface and
the bottom.
In case of a pure 2-D application, u ≃ u and v ≃ v in which case (D.7)–
(D.10) reduce to
1
E k = ρ0 H(u2 + v 2 ) (D.11)
2
h1 i
(F1 , F 2 ) = H ρ0 (u2 + v 2 ) + ρ0 gζ (u, v) (D.12)
2
D = ρ0 (us τs1 + vs τs2 − ub τb1 − vb τb2 ) (D.13)
Finally, the domain integrated forms are obtained by integrating (D.7)
over the 2-D horizontal domain. This gives
∂ Z
hE k i + hEp i + (F 1 n1 + F 2 n2 ) dℓ = hDi (D.14)
∂t
with Z Nx Z Ny
h· · ·i = (· · ·)h1 h2 dξ1 dξ2 (D.15)
0 0
The second integral is taken along the 2-D boundary of the domain where
(n1 ,n2 ) is the outwards pointing unit normal along the boundary.
Appendix E
Table E.1: Key ids of the variables which can be used for defining standard output
variables. The variables denoted by a ∗ are W-node variables for which the node
variable attribute can be reset to ‘W’.
641
642 APPENDIX E. LIST OF STANDARD OUTPUT VARIABLES
Albérola, C., Rousseau, S., Millot, C., Astraldi, M., Font, J., Garcia-
Lafuente, J.M., Gasparin, G.P., Send, U., & Vangriesheim, A. 1995. Tidal
currents in the western Mediterranean Sea. Oceanologica Acta, 18, 273–
284.
Anderson, R.J., & Smith, S.D. 1981. Evaporation coefficient for the sea
surface from eddy flux measurements. Journal of Geophysical Research,
86, 449–456.
Beckmann, A., & Haidvogel, D.B. 1993. Numerical simulation of flow around
a tall isolated seamount. Part I: Problem formulation and model accuracy.
Journal of Physical Oceanography, 23, 1736–1753.
Blackadar, A.K. 1962. The vertical distribution of wind and turbulent ex-
change in a neutral atmosphere. Journal of Geophysical Research, 67,
3095–3102.
Blanc, T.V. 1985. Variation of bulk-derived surface flux, stability, and rough-
ness results due to the use of different transfer coefficient schemes. Journal
of Physical Oceanography, 15, 650–669.
Boris, J.P., & Book, D.L. 1979. Flux corrected transport: I.SHASTA, a fluid
transport algorithm that works. Journal of Computational Physics, 11,
38–69.
645
646 BIBLIOGRAPHY
Businger, J.A., Wyngaard, J.C., Izumi, Y., & Bradley, E.F. 1971. Flux-profile
relationships in the atmospheric surface layer. Journal of the Atmospheric
Sciences, 28, 181–189.
Camerlengo, A.L., & O’Brien, J.J. 1980. Open boundary conditions in ro-
tating fluids. Journal of Computational Physics, 35, 12–35.
Canuto, V.M., Howard, A., Cheng, Y., & Dubovikov, M.S. 2001. Ocean
turbulence. Part I: One-point closure model – Momentum and heat vertical
diffusivities. Journal of Physical Oceanography, 31, 1413–1426.
Cartwright, D.E., & Edden, A.C. 1973. Corrected tables of tidal harmonics.
Geophysical Journal of the Royal Astronomical Society, 33, 253–264.
Cartwright, D.E., & Tayler, R.J. 1971. New computations of the tide-
generating potential. Geophysical Journal of the Royal Astronomical So-
ciety, 23, 45–74.
Chao, S.-Y., & Boicourt, W.C. 1986. Onset of estuarine plumes. Journal of
Physical Oceanography, 16, 2137–2149.
Charnock, H., Dyer, K.R., Huthnance, J.M., Liss, P.S., Simpson, J.H., &
Tett, B. 1994. Understanding the North Sea System. The Royal Society,
Chapman & Hall.
Chen, C., Beardsley, R.C, & Cowles, G. 2006. An unstructured Grid, Finite-
Volume Coastal Ocean Model. Tech. rept. School for Marine Science and
Technology, Univ. of Massaschusetts-Dartmouth, New Bedford, Massa-
schusetts, US.
Chu, P.C., & Fan, C. 1997. Sixth-order difference scheme for sigma coordinate
ocean models. Journal of Physical Oceanography, 27, 2064–2071.
Colella, P., & Woodward, P.R. 1984. The piecewise parabolic method (PPM)
for gas-dynamical simulations. Journal of Computational Physics, 54, 174–
201.
Daly, B.J., & Harlow, F.H. 1970. Transport equations in turbulence. Physics
of Fluids, 13, 2634–2649.
Davies, A.M. 1990. On extracting tidal current profiles from vertically in-
tegrated two-dimensional hydrodynamic models. Journal of Geophysical
Research, 95, 18317–18342.
Davies, A.M., & Jones, J.E. 1991. On the numerical solution of the turbu-
lence energy equations for wave and tidal flows. International Journal for
Numerical Methods in Fluids, 12, 17–41.
Davies, A.M., & Jones, J.E. 1992. A three-dimensional wind driven circula-
tion model of the Celtic and Irish Seas. Continental Shelf Research, 12,
159–188.
648 BIBLIOGRAPHY
Demarcq, H., & Wald, L. 1984. Surface dynamics of the Rhone plume inferred
from infrared imagery. Oceanologica Acta, 7, 159–162.
Ferziger, J. 2005. Turbulence: its origins and structure. Pages 4–13 of:
Baumert, H.Z., Simpson, J., & Sündermann, J. (eds), Marine Turbulence.
Theories, Observations and Models. Cambridge University Press.
Foreman, M.G.G., Henry, R.F., Walters, R.A., & Ballantyne, V.A. 1993.
A finite element model for tides and resonance along the north coast of
British Columbia. Journal of Geophysical Research, 98, 2509–2532.
Forget, P., Devenon, J.L., De Maistre, J.C., & Broche, P. 1990. VHF remote
sensing for mapping plume circulation. Geophysical Research Letters, 17,
1097–1100.
Galperin, B., Kantha, L.H., Hassid, S., & Rosati, A. 1988. A quasi-
equilibrium turbulent energy model for geophysical flows. Journal of the
Atmospheric Sciences, 45, 55–62.
Galperin, B., A., Rosati, Kantha, L.H., & Mellor, G.L. 1989. Modeling
rotating stratified turbulent flows with application to oceanic mixed layers.
Journal of Physical Oceanography, 19, 901–916.
Geernaert, G.L.. 1990. Bulk parameterizations for the wind stress and heat
fluxes. Pages 91–172 of: Geernaert, G.L., & Plant, W.J. (eds), Surface
Waves and Fluxes, Vol. 1 – Current theory.
Geernaert, G.L., Katsaros, K.B., & Richter, K. 1986. Variation of the drag
coefficient and its dependence on sea state. Journal of Geophysical Re-
search, 91, 7667–7679.
Glorioso, P.D., & Davies, A.M. 1995. The influence of eddy viscosity formu-
lation, bottom topography, and wind wave effects upon the circulation of
a shallow bay. Journal of Physical Oceanography, 25, 1243–1264.
Gradshteyn, I.S., & Ryzhik, I.M. 1981. Table of integrals, series and products.
Academic Press.
Griffiths, R.W., & Linden, P.F. 1981. The stability of vortices in a rotating,
stratified fluid. Journal of Fluid Mechanics, 105, 283–316.
Haney, R.L. 1991. On the pressure gradient force over steep topography in
sigma coordinate ocean models. Journal of Physical Oceanography, 21,
610–619.
650 BIBLIOGRAPHY
Heaps, N.S. 1972. Estimation of density currents in the Liverpool Bay area
of the Irish Sea. Geophysical Journal of the Royal Astronomical Society,
30, 415–432.
Hossain, M.S., & Rodi, W. 1982. A turbulence model for buoyant flows and
its application to vertical buoyant jets. Pages 121–178 of: Rodi, W. (ed),
Turbulent buoyant jets and plumes. HMT-Series, vol. 6. Oxford: Pergamon
Press.
James, I.D. 1996. Advection schemes for shelf sea models. Journal of Marine
Systems, 8, 237–254.
Kantha, L.H., & Clayson, C.A. 1994. An improved mixed layer model for
geophysical applications. Journal of Geophysical Research, 99, 25235–
25266.
BIBLIOGRAPHY 651
Kantha, L.H., & Clayson, C.A. 2000a. Small Scale Processes in Geophysical
Fluid Flows. San Diego, California: Academic Press.
Kantha, L.H., & Clayson, C.A. 2000b. Numerical Models of Oceans and
Oceanic Processes. San Diego, California: Academic Press.
Kantha, L.H., Rosati, A., & Galperin, B. 1989. Effect of rotation on vertical
mixing and associated turbulence in stratified fluids. Journal of Geophy-
sical Research, 94, 4843–4854.
Kato, H., & Phillips, O.M. 1969. On the penetration of a turbulent layer
into stratified fluid. Journal of Fluid Mechanics, 37, 643–655.
Kliem, N., & Pietrzak, J.D. 1999. On the pressure gradient error in sigma
coordinate ocean models: A comparison with a laboratory experiment.
Journal of Geophysical Research, 104, 29781–29799.
Kourafalou, V.H., Oey, L.-Y., Wang, J.D., & Lee, T.N. 1996. The fate of
river discharge on the continental shelf - 1. Modeling the river plume and
the inner shelf coastal current. Journal of Geophysical Research, 101,
3415–3434.
Large, W.G., & Pond, S. 1981. Open ocean momentum flux measurements in
moderate to strong winds. Journal of Physical Oceanography, 11, 324–336.
Large, W.G., & Pond, S. 1982. Sensible and latent heat flux measurements
over the ocean. Journal of Physical Oceanography, 12, 464–482.
Large, W.G., McWilliams, J.C., & Doney, S.C. 1994. Oceanic vertical mixing:
A review and a model with a nonlocal boundary layer parameterization.
Reviews of Geophysics, 32, 363–403.
652 BIBLIOGRAPHY
Luyten, P.J. 1996. An analytical and numerical study of surface and bottom
boundary layers with variable forcing and application to the North Sea.
Journal of Marine Systems, 8, 171–189.
Luyten, P.J., Deleersnijder, E., Ozer, J., & Ruddick, K.G. 1996. Presentation
of a family of turbulence closure models for stratified shallow water flows
and preliminary application to the Rhine outflow region. Continental Shelf
Research, 16, 101–130.
Luyten, P.J., Jones, J.E., Proctor, R., Tabor, A., Tett, P., & Wild-Allen,
K. 1999. COHERENS – A coupled hydrodynamical-ecological model for
regional and shelf seas: User Documentation. Tech. rept. Management
Unit of the Mathematical Models of the North Sea (MUMM), Belgium.
Luyten, P.J., Jones, J.E., & Proctor, R. 2003. A numerical study of the
long- and short-term temperature variability and thermal circulation in
the North Sea. Journal of Physical Oceanography, 33, 37–56.
Luyten, P.J., Andreu-Burillo, I., Norro, A., Ponsar, S., & Proctor, R. 2006.
A new version of the European public domain code COHERENS. Pages
474–481 of: Dahlin, H., Flemming, N.C., Marchand, P., & Petersson, S.E.
(eds), European Operational Oceanography: Present and Future.
BIBLIOGRAPHY 653
Madec, G., Chartier, M., Delecluse, P., & Crépon, M. 1991. A three-
dimensional numerical study of deep-water formation in the northwestern
Mediterranean Sea. Journal of Physical Oceanography, 21, 1349–1371.
Martinsen, E.A., & Engedahl, H. 1987. Implementation and testing of a
lateral boundary scheme as an open boundary condition in a barotropic
ocean model. Coastal Engineering, 11, 603–627.
McCalpin, J.D. 1994. A comparison of second-order and fourth-order pres-
sure gradient algorithms in a σ-coordinate ocean model. International
Journal for Numerical Methods in Fluids, 18, 361–383.
McDougall, T.J., Jackett, D.R., Wright, D.G., & Feistel, R. 2003. Accurate
and computationally efficient algorithms for potential temperature and
density of seawater. Journal of Atmospheric and Oceanic Technology, 20,
730–741.
Mellor, G.L., & Yamada, T. 1974. A hierarchy of turbulence closure models
for planetary boundary layers. Journal of the Atmospheric Sciences, 31,
1791–1806.
Mellor, G.L., & Yamada, T. 1982. Development of a turbulence closure model
for geophysical fluid problems. Reviews of Geophysics and Space Physics,
20, 851–875.
Mesinger, F., & Arakawa, A. 1976. Numerical methods used in atmospheric
models. Tech. rept. Global Atmospheric Research Programme (GARP)
publication series.
Millero, F.J., Chen, C.-T., Bradshaw, A., & Schleicher, K. 1980. A new high
pressure equation of state for seawater. Deep-Sea Research, 27A.
Monin, A., & Obukhov, A. 1954. Basic turbulent mixing laws in the atmo-
spheric near-surface layer. Trans. Geophys. Inst. Akad. Nauk USSR, 151,
163–187.
MPI. 1995. A message-passing interface standard (version 1.1). Message
Passing Interface Forum, Univ. of Tennessee, Knoxville, Tennessee.
Munk, W.H., & Anderson, E.R. 1948. Notes on a theory of the thermocline.
Journal of Marine research, VII(3), 276–295.
Naimie, C.E., Loder, J.W., & Lynch, D.R. 1994. Seasonal variation of the
three-dimensional residual circulation on Georges Bank. Journal of Geo-
physical Research, 99, 15967–15989.
654 BIBLIOGRAPHY
Naudin, J.J., Cauwet, G., Leveau, M., Lochet, F., Pauc, H., Romano, J.-C.,
& Sempere, R. 1992. The bottom nepheloid layer off the Rhone River
mouth. Particulate transfer at the land-ocean interaction. Oceanologica
Acta, 15, 621–638.
Pacanowski, R., & Griffies, S.M. 2000. MOMM 3.0 Manual. Tech. rept.
Geophysical Fluid Dynamics Laboratory.
Palma, E.D., & Matano, R.P. 1998. On the implementation of passive open
boundary conditions for a general circulation model: The barotropic mode.
Journal of Geophysical Research, 103, 1319–1341.
Patankar, S.V. 1980. Numerical Heat Transfer and Fluid Flow. Lecture Notes
in Earth Sciences. New York: McGraw-Hill.
Paulson, C.A., & Simpson, J.J. 1977. Irradiance measurements in the upper
ocean. Journal of Physical Oceanography, 7, 952–956.
Payne, R.E. 1972. Albedo of the sea surface. Journal of the Atmospheric
Sciences, 29, 959–970.
Peters, H., Gregg, M.C., & Toole, J.M. 1988. On the parameterization of
equatorial turbulence. Journal of Geophysical Research, 93, 1199–1218.
Phillips, N.A. 1957. A coordinate system having some special advantages for
numerical forecasting. Journal of Meteorology, 14, 184–185.
Pincus, R., & Rew, R. 2008. The NetCDF Fortran 90 Interface Guide.
UNIDATA Program Center of the University Corporation for Atmospheric
Research.
Prandle, D. 1982. The vertical structure of tidal currents and other oscillatory
flows. Continental Shelf Research, 1, 191–207.
Press, W.H., Teukolsky, S.A., Vetterling, W.T., & Flannery, B.P. 1992. Nu-
merical Recipes. The art of scientific computing. 2 edn. Cambridge: Cam-
bridge University Press.
Proctor, R., & Davies, A.M. 1996. A three dimensional hydrodynamic model
of tides off the north-west coast of Scotland. Journal of Marine Systems,
7, 43–66.
Reed, R.K. 1977. On estimating insolation over the ocean. Journal of Physical
Oceanography, 7, 482–485.
Roe, P.L. 1986. Characteristic-based schemes for the Euler equations. Annual
Review of Fluid Mechanics, 18, 337–365.
Røed, L.P., & Cooper, C.K. 1987. A study of various open boundary condi-
tions for wind-forced barotropic numerical ocean models. Pages 305–335
of: Nihoul, J.C.J., & Jamart, B.M. (eds), Three-dimensional models of
marine and estuarine dynamics. Amsterdam: Elsevier.
Røed, L.P., & Smedstad, O.M. 1984. Open boundary conditions for forced
waves in a rotating fluid. SIAM J. Sci. Stat. Comput., 5, 414–426.
Rosati, A., & Miyakoda, K. 1988. A general circulation model for upper
ocean simulation. Journal of Physical Oceanography, 18, 1601–1626.
656 BIBLIOGRAPHY
Soulsby, R.L. 1983. The bottom boundary layers of shelf seas. Pages 189–266
of: Johns, B. (ed), Physical Oceanography of Coastal and Shelf Seas, vol.
35. Elsevier Oceanography Series.
Sournia, A., Brylinski, J.-M., Dallot, S., Le Corre, P., Leveau, M., Prieur,
L., & Froget, C. 1990. Fronts hydrologiques au large des côtes françaises:
Les sites-ateliers du programme Frontal. Oceanologica Acta, 13, 413–436.
Stelling, G.S., & Van Kester, J.A.T.M. 1994. On the approximation of ho-
rizontal gradients in sigma coordinates for bathymetry with steep bottom
slopes. International Journal for Numerical Methods in Fluids, 18, 915–
935.
Sweby, P.K. 1984. High resolution schemes using flux limiters for hyperbolic
conservation laws. SIAM Journal of Numerical Analysis, 21, 995–1011.
Takacs, L.L. 1985. A two-step scheme for the advection equation with min-
imized dissipation and dispersion errors. Monthly Weather Review, 1050–
1065.
Tartinville, B., Deleersnijder, E., Lazure, P., Proctor, R., Ruddick, K.G., &
Uittenbogaard, R.E. 1998. A coastal ocean model intercomparison study
for a three-dimensional idealised test case. Applied Mathematical Model-
ling, 165–182.
Tsimplis, M.N., Proctor, R., & Flather, R.A. 1995. A two-dimensional model
for the Mediterranean Sea. Journal of Geophysical Research, 100, 16223–
16239.
Visser, A.W., Souza, A.J., Hessner, K., & Simpson, J.H. 1994. The effect of
stratification on tidal current profiles in a region of freshwater influence.
Oceanologica Acta, 17, 369–381.
Wu, J. 1980. Wind stress coefficients over the sea surface near neutral con-
ditions – A revisit. Journal of Physical Oceanography, 10, 727–740.
658 BIBLIOGRAPHY
Xing, J., & Davies, A.M. 1996. Application of turbulence energy models
to the computation of tidal currents and mixing intensities in shelf edge
regions. Journal of Physical Oceanography, 26, 417–447.
Yanenko, N.N. 1971. The method of fractional steps. New York: Springer
Verlag.
Part VI
Reference manual
659
Appendix 22
Xadv at C
SUBROUTINE Xadv at C(psic,tridcfc,novars,iopt adv,nh,klo,kup,psiobu)
INTEGER, INTENT(IN) :: iopt adv, klo, kup, nh, novars
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psic
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz,4,novars) :: tridcfc
REAL, INTENT(IN), DIMENSION(nobu,nz,novars) :: psiobu
File
Advection Terms.F90
Type
Subroutine
Purpose
Advective term in the X-direction for one or more scalar quantities at
the C-nodes
Reference
Section 5.5.4.1
Arguments
661
662 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
transport at C 3d, transport at C 4d1, transport at C 4d2
Xadv at U 2d
SUBROUTINE Xadv at U 2d(psiu,xadvatu2d,nh,vintflag)
LOGICAL, INTENT(INOUT) :: vintflag
INTEGER, INTENT(IN) :: nh
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo) :: psiu
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc) :: xadvatu2d
File
Advection Terms.F90
Type
Subroutine
Purpose
Alongstream advective term for the X-component of the depth-integrated
current U at the U-nodes
Reference
Section 5.3.4.1
Arguments
psiu U-node quantity to be advected [m2 /s]
xadvatu2d Advective term (times ∆τ ) [m2 /s]
22.1. ADVECTION TERMS.F90 663
Calling procedures
transport at U 2d
Xadv at U 3d
SUBROUTINE Xadv at U 3d(psiu,xadvatu3d,nh,vintflag)
LOGICAL, INTENT(IN) :: vintflag
INTEGER, INTENT(IN) :: nh
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiu
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,nz) :: xadvatu3d
File
Advection Terms.F90
Type
Subroutine
Purpose
Alongstream advection term for the 3-D current u at the U-nodes
Reference
Section 5.3.3.1
Arguments
Calling procedures
transport at U 3d
664 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Xadv at V 2d
SUBROUTINE Xadv at V 2d(psiv,xadvatv2d,nh,vintflag)
LOGICAL, INTENT(INOUT) :: vintflag
INTEGER, INTENT(IN) :: nh
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo) :: psiv
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc) :: xadvatv2d
File
Advection Terms.F90
Type
Subroutine
Purpose
Cross-stream advective term in the X-direction for the Y-component
of the depth-integrated current V at the V-nodes
Reference
Section 5.3.4.3
Arguments
psiv V-node quantity to be advected [m2 /s]
xadvatv2d Advective term (times ∆τ ) [m2 /s]
nh Halo size of local arrays
vintflag Add the result to the third (2-D barotropic) part of equa-
tion (5.152) if set to .TRUE. at predictor time steps.
Calling procedures
transport at V 2d
Xadv at V 3d
SUBROUTINE Xadv at V 3d(psiv,xadvatv3d,nh,vintflag)
LOGICAL, INTENT(IN) :: vintflag
INTEGER, INTENT(IN) :: nh
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiv
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,nz) :: xadvatv3d
File
Advection Terms.F90
22.1. ADVECTION TERMS.F90 665
Type
Subroutine
Purpose
Cross-stream advective term for the 3-D current v at the V-nodes
Reference
Section 5.3.3.3
Arguments
psiv V-node quantity to be advected [m/s]
xadvatv3d Advective term (times hv3 ) [m2 /s2 ]
nh Halo size of local arrays
vintflag Add the result to the second (3-D) part of equation (5.152)
if set to .TRUE. at predictor time steps.
Calling procedures
transport at V 3d
Xadv at W
SUBROUTINE Xadv at W(psiw,tridcfw,uadvatuw,nh,klo,kup)
INTEGER, INTENT(IN) :: klo, kup, nh
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz+1) :: psiw
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz+1,4) :: tridcfw
REAL, INTENT(IN), DIMENSION(2-nhalo:ncloc+nhalo,&
& nrloc,2:nz) :: uadvatuw
File
Advection Terms.F90
Type
Subroutine
Purpose
Advective term in the X-direction for a quantity at the W-nodes
Reference
Section 5.6.2.1
Arguments
666 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
transport at W
Yadv at C
SUBROUTINE Yadv at C(psic,tridcfc,novars,iopt adv,nh,klo,kup,psiobv)
INTEGER, INTENT(IN) :: iopt adv, klo, kup, nh, novars
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psic
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz,4,novars) :: tridcfc
REAL, INTENT(IN), DIMENSION(nobv,nz,novars) :: psiobv
File
Advection Terms.F90
Type
Subroutine
Purpose
Advective term in the Y-direction for one or more scalar quantities at
the C-nodes
Reference
Section 5.5.4.2
Arguments
psic C-node quantity or quantities to be advected [psic]
tridcfc Tridiagonal matrix for storing explicit and implicit (at
open boundaries) parts of advective term [psic]
22.1. ADVECTION TERMS.F90 667
Calling procedures
transport at C 3d, transport at C 4d1, transport at C 4d2
Yadv at U 2d
SUBROUTINE Yadv at U 2d(psiu,yadvatu2d,nh,vintflag)
LOGICAL, INTENT(INOUT) :: vintflag
INTEGER, INTENT(IN) :: nh
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo) :: psiu
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc) :: yadvatu2d
File
Advection Terms.F90
Type
Subroutine
Purpose
Cross-stream advective term for the X-component of the depth-integrated
current U at the U-nodes
Reference
Section 5.3.4.2
Arguments
psiu U-node quantity to be advected [m2 /s]
yadvatu2d Advective term (times ∆τ ) [m2 /s]
nh Halo size of local arrays
vintflag Add the result to the fourth (2-D barotropic) part of equa-
tion (5.151) if set to .TRUE. at predictor time steps.
668 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
transport at U 2d
Yadv at U 3d
SUBROUTINE Yadv at U 3d(psiu,yadvatu3d,nh,vintflag)
LOGICAL, INTENT(IN) :: vintflag
INTEGER, INTENT(IN) :: nh
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiu
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,nz) :: yadvatu3d
File
Advection Terms.F90
Type
Subroutine
Purpose
Cross-stream advective term for the 3-D current u at the U-nodes
Reference
Section 5.3.3.2
Arguments
psiu U-node quantity to be advected [m/s]
yadvatu3d Advective term (times hu3 ) [m2 /s2 ]
nh Halo size of local arrays
vintflag Add the result to the second (3-D) part of equation (5.151)
if set to .TRUE. at predictor time steps.
Calling procedures
transport at U 3d
Yadv at V 2d
SUBROUTINE Yadv at V 2d(psiv,yadvatv2d,nh,vintflag)
LOGICAL, INTENT(INOUT) :: vintflag
INTEGER, INTENT(IN) :: nh
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo) :: psiv
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc) :: yadvatv2d
22.1. ADVECTION TERMS.F90 669
File
Advection Terms.F90
Type
Subroutine
Purpose
Alongstream advective term for the Y-component of the depth-integrated
current V at the V-nodes
Reference
Section 5.3.4.4
Arguments
psiv V-node quantity to be advected [m2 /s]
yadvatv2d Advective term (times ∆τ ) [m2 /s]
nh Halo size of local arrays
vintflag Add the result to the fourth (2-D barotropic) part of equa-
tion (5.152) if set to .TRUE. at predictor time steps.
Calling procedures
transport at V 2d
Yadv at V 3d
SUBROUTINE Yadv at V 3d(psiv,yadvatv3d,nh,vintflag)
LOGICAL, INTENT(IN) :: vintflag
INTEGER, INTENT(IN) :: nh
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiv
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,nz) :: yadvatv3d
File
Advection Terms.F90
Type
Subroutine
Purpose
Alongstream advective term for the 3-D current v at the V-nodes
Reference
Section 5.3.3.4
670 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Arguments
psiv V-node quantity to be advected [m/s]
yadvat3d Advective term (times hv3 ) [m2 /s2 ]
nh Halo size of local arrays
vintflag Add the result to the second (3-D) part of equation (5.152)
if set to .TRUE. at predictor time steps.
Calling procedures
transport at V 3d
Yadv at W
SUBROUTINE Yadv at W(psiw,tridcfw,vadvatvw,nh,klo,kup)
INTEGER, INTENT(IN) :: klo, kup, nh
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz+1) :: psiw
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz+1,4) :: tridcfw
REAL, INTENT(IN), DIMENSION(ncloc,2-nhalo:nrloc+nhalo,&
& 2:nz) :: vadvatvw
File
Advection Terms.F90
Type
Subroutine
Purpose
Advective term in the Y-direction for a quantity at the W-nodes
Reference
Section 5.6.2.2
Arguments
psiw W-node quantity to be advected [psiw]
tridcfw Tridiagonal matrix for storing explicit and implicit (at
open boundaries) parts of the advective term [psiw]
vadvatvw Advective velocity at the VW-nodes [m/s]
nh Halo size of local arrays
klo 2 for a Neumann or a Dirichlet condition at the bottom,
3 for a Dirichlet condition at the first W-node above the
bottom
22.1. ADVECTION TERMS.F90 671
Zadv at C
SUBROUTINE Zadv at C(psic,tridcfc,wadvatw,novars,iopt adv,klo,kup)
INTEGER, INTENT(IN) :: iopt adv, klo, kup, novars
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psic
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz,4,novars) :: tridcfc
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz+1,novars) :: wadvatw
File
Advection Terms.F90
Type
Subroutine
Purpose
Advective term in the vertical direction for one or more scalar quantities
at the C-nodes
Reference
Section 5.5.4.3
Arguments
psic C-node quantity or quantities be advected [psic]
tridcfc Tridiagonal matrix for storing implicit and explicit terms
[psic]
wadvatw Advective velocity at the W-nodes [m/s]
novars Number of variables to be advected
iopt adv Switch to select the vertical advection scheme
klo 1 for a Neumann, 2 for a Dirichlet condition at the bottom
kup nz for a Neumann, nz-1 for a Dirichlet condition at the
surface
Calling procedures
transport at C 3d, transport at C 4d1, transport at C 4d2
672 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Zadv at U
SUBROUTINE Zadv at U(psiu,tridcfu,wadvatuw)
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiu
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz,4) :: tridcfu
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz+1) :: wadvatuw
File
Advection Terms.F90
Type
Subroutine
Purpose
Vertical advective term for the 3-D current u at the the U-nodes
Reference
Section 5.3.6.1
Arguments
psiu U-node quantity to be advected [m/s]
tridcfu Tridiagonal matrix for storing implicit and explicit terms
[m/s]
wadvatuw Advective velocity at the UW-nodes [m/s]
Calling procedures
transport at U 3d
Zadv at V
SUBROUTINE Zadv at V(psiv,tridcfv,wadvatvw)
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiv
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz,4) :: tridcfv
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz+1) :: wadvatvw
File
Advection Terms.F90
Type
Subroutine
22.1. ADVECTION TERMS.F90 673
Purpose
Vertical advective term for the 3-D current v at the V-nodes
Reference
Section 5.3.6.2
Arguments
psiv V-node quantity to be advected [m/s]
tridcfv Tridiagonal matrix for storing implicit and explicit terms
[m/s]
wadvatvw Advective velocity at the VW-nodes [m/s]
Calling procedures
transport at V 3d
Zadv at W
SUBROUTINE Zadv at W(psiw,tridcfw,wadvatc,klo,kup)
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz+1) :: psiw
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz+1,4) :: tridcfw
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz) :: wadvatc
File
Advection Terms.F90
Type
Subroutine
Purpose
Vertical advective term for a quantity at the W-nodes
Reference
Section 5.6.2.3
Arguments
psiw W-node quantity to be advected [psiw]
tridcfw Tridiagonal matrix for storing implicit and explicit terms
[psiw]
wadvatw Advective velocity at the W-nodes [m/s]
674 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
transport at W
File
Allocate Arrays.f90
Type
Subroutine
Purpose
Allocate grid arrays on the global (parallel) grid.
Calling procedures
initialise model
File
Allocate Arrays.f90
Type
Subroutine
22.3. BOTTOM FLUXES.F90 675
Purpose
Allocate model arrays on the local sub-domain (mostly including an
halo) with a “global” scope in the program, i.e. arrays used in different
program routines. The arrays are declared as allocatable arrays in
MODULE units of the program.
Reference
Sections 8.1.1
Arguments
None
Calling procedures
initialise model ,
simulation end
File
Allocate Arrays.f90
Type
Subroutine
Purpose
Deallocate all model arrays with a “global” scope at the end of a sim-
ulation.
Calling procedures
simulation end
bottom stress
SUBROUTINE bottom stress
File
Bottom Fluxes.f90
676 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Type
Subroutine
Purpose
Base program unit for the evaluation of the bottom stress.
Reference
Sections 4.9.2, 5.3.1.2 and 5.3.14.2
Called internal procedures
bottom currents, bottom drag coef1, bottom drag coef2,
bottom stress linear, bottom stress quadr
Calling procedures
current corr, current corr 1d, current 2d, initialise model
bottom currents
SUBROUTINE bottom currents
File
Bottom Fluxes.f90
Type
Internal subroutine
Purpose
Magnitude of the current at the bottom level of the model grid
Calling procedures
bottom stress
File
Bottom Fluxes.f90
Type
Internal subroutine
Purpose
Interpolate the externally imposed bottom drag coefficient at the U-
and the V-nodes when iopt bstres drag≤2.
22.3. BOTTOM FLUXES.F90 677
Calling procedures
bottom stress
File
Bottom Fluxes.f90
Type
Internal subroutine
Purpose
Update the bottom drag coefficients using imposed roughness lengths
when iopt bstres drag>2.
Reference
Equation (5.18)
Calling procedures
bottom stress
File
Bottom Fluxes.f90
Type
Internal subroutine
Purpose
Evaluate the bottom stress using a linear friction law.
Reference
Equation (4.326) or (4.327)
Calling procedures
bottom stress
678 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
File
Bottom Fluxes.f90
Type
Internal subroutine
Purpose
Evaluate the bottom stress using a quadratic friction law.
Reference
Equation (4.328) or (4.329)
Calling procedures
bottom stress
File
Coherens Program.f90
Type
Main program
Purpose
Main program unit of COHERENS
Xcorr at C
SUBROUTINE Xcorr at C(psic,ucorratc,novars,klo,kup)
INTEGER, INTENT(IN) :: klo, kup, novars
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psic
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,klo:kup,novars) :: ucorratc
File
Corrector Terms.F90
Type
Subroutine
Purpose
Corrector term in the X-direction for a quantity at the C-nodes
Reference
Equation (5.377)
Arguments
psic C-node quantity or quantities to be advected [psic]
ucorratc Corrector term (times ∆t) [psic]
novars Number of variables to be advected
klo 1 for a Neumann, 2 for a Dirichlet condition at the bottom
kup nz for a Neumann, nz-1 for a Dirichlet condition at the
surface
Calling procedures
transport at C 3d, transport at C 4d1, transport at C 4d2
Xcorr at W
SUBROUTINE Xcorr at W(psiw,ucorratw,uvelatuw,klo,kup)
INTEGER, INTENT(IN) :: klo, kup
680 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
File
Corrector Terms.F90
Type
Subroutine
Purpose
Corrector term in the X-direction for a quantity at the W-nodes
Reference
Equation (5.459)
Arguments
psiw W-node quantity to be advected [psiw]
ucorratw Corrector term (times ∆t) [psiw]
uvelatuw X-component of the current u at the UW-nodes [m/s]
klo 2 for a Neumann or a Dirichlet condition at the bottom,
3 for a Dirichlet condition at the first W-node above the
bottom
kup nz for a Neumann condition or a Dirichlet condition at the
surface, nz-1 for a Dirichlet condition at the first W-node
below the surface
Calling procedures
transport at W
Ycorr at C
SUBROUTINE Ycorr at C(psic,vcorratc,novars,klo,kup)
INTEGER, INTENT(IN) :: klo, kup, novars
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psic
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,klo:kup,novars) :: vcorratc
File
Corrector Terms.F90
22.5. CORRECTOR TERMS.F90 681
Type
Subroutine
Purpose
Corrector term in the Y-direction for a quantity at the C-nodes
Reference
Equation (5.378)
Arguments
psic C-node quantity or quantities to be advected [psic]
vcorratc Corrector term (times ∆t) [psic]
novars Number of variables to be advected
klo 1 for a Neumann, 2 for a Dirichlet condition at the bottom
kup nz for a Neumann, nz-1 for a Dirichlet condition at the
surface
Calling procedures
transport at C 3d, transport at C 4d1, transport at C 4d2
Ycorr at W
SUBROUTINE Ycorr at W(psiw,vcorratw,vvelatvw,klo,kup)
INTEGER, INTENT(IN) :: klo, kup
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz+1) :: psiw
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,klo:kup) :: vcorratw
REAL, INTENT(IN), DIMENSION(ncloc,&
& 2-nhalo:nrloc+nhalo,2:nz) :: vvelatvw
File
Corrector Terms.F90
Type
Subroutine
Purpose
Corrector term in the Y-direction for a quantity at the W-nodes
Reference
Equation (5.460)
Arguments
682 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
transport at W
Zcorr at C
SUBROUTINE Zcorr at C(psic,wcorratc,novars,klo,kup)
INTEGER, INTENT(IN) :: klo, kup, novars
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psic
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,klo:kup,novars) :: wcorratc
File
Corrector Terms.F90
Type
Subroutine
Purpose
Corrector term in the Z-direction for a quantity at the C-nodes
Reference
Equation (5.379)
Arguments
psic C-node quantity or quantities to be advected [psic]
wcorratc Corrector term (times ∆t) [psic]
novars Number of variables to be advected
klo 1 for a Neumann, 2 for a Dirichlet condition at the bottom
kup nz for a Neumann, nz-1 for a Dirichlet condition at the
surface
22.5. CORRECTOR TERMS.F90 683
Calling procedures
transport at C 3d, transport at C 4d1, transport at C 4d2
Zcorr at W
SUBROUTINE Zcorr at W(psiw,wcorratw,wvelatc,klo,kup)
INTEGER, INTENT(IN) :: klo, kup
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz+1) :: psiw
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,klo:kup) :: wcorratw
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz) :: wvelatc
File
Corrector Terms.F90
Type
Subroutine
Purpose
Corrector term in the Z-direction for a quantity at the W-nodes
Reference
Equation (5.461)
Arguments
Calling procedures
transport at W
684 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
baroclinic gradient
SUBROUTINE baroclinic gradient
File
Density Equations.F90
Type
Subroutine
Purpose
Evaluate the baroclinic pressure gradient using different formulations
selected by iopt dens grad.
Reference
Section 5.3.12
Calling procedures
coherens main
equation of state
SUBROUTINE equation of state
File
Density Equations.F90
Type
Subroutine
Purpose
Evaluate the density and temperature/salinity expansion/contraction
coefficients using different versions of the equation of state.
22.6. DENSITY EQUATIONS.F90 685
Reference
Section 4.2.3
Calling procedures
initialise model
hcube deriv
SUBROUTINE hcube deriv(psi,dpsi,cdir)
CHARACTER (LEN=1), INTENT(IN) :: cdir
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psi
REAL, INTENT(OUT), DIMENSION(0:ncloc+1,0:nrloc+1,nz) :: dpsi
File
Density Equations.F90
Type
Subroutine
Purpose
Evaluate the horizontal or vertical derivative terms in the cube-H method
for the baroclininic pressure gradient using the discretisations (5.220)–
(5.223).
Reference
Section 5.3.12.3
Arguments
psi Input array
dpsi Array of derivatives
cdir Direction of derivative (‘X’,‘Y’,‘Z’)
Calling procedures
baroclinic gradient
hcube fluxes
SUBROUTINE hcube fluxes(psi,zcoord,dpsi,dzcoord,fcube,cdir)
CHARACTER (LEN=1), INTENT(IN) :: cdir
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psi, zcoord
686 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
File
Density Equations.F90
Type
Subroutine
Purpose
Evaluate the integrals F U , F V , F W in the cube-H method for the
baroclinic pressure gradient using the discretisations (5.215)–(5.219).
Reference
Section 5.3.12.3
Arguments
psi Density (temperature or salinity) array
zcoord Array of Z-coordinates
dpsi Array of psi-derivatives
dzcoord Array of Z-derivatives
fcube Pseudo fluxes
cdir Direction of derivative (‘X’,‘Y’,‘Z’)
Calling procedures
baroclinic gradient
heat optics
SUBROUTINE heat optics
File
Density Equations.F90
Type
Subroutine
Purpose
Evaluate the solar radiance within the water column using the optical
formulation (4.48).
Reference
Section 4.2.1.1
22.6. DENSITY EQUATIONS.F90 687
Calling procedures
temperature equation
salinity equation
SUBROUTINE salinity equation
File
Density Equations.F90
Type
Subroutine
Purpose
Solve the salinity equation (4.72).
Reference
Section 4.2.1.2
Called external procedures
define profobc spec, open boundary conds prof, salinity flux,
transport at C 3d, update nest data prof, update profobc data
Calling procedures
initialise model
temperature equation
SUBROUTINE temperature equation
File
Density Equations.F90
Type
Subroutine
Purpose
Solve the temperature equation (4.71).
Reference
Section 4.2.1.2
Called external procedures
define profobc spec, define surface input grid, heat flux, heat optics,
open boundary conds prof, solar irradiance, transport at C 3d,
update nest data prof, update profobc data, update surface data
688 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
initialise model
File
Diffusion Coefficients.F90
Type
Subroutine
Purpose
Set the horizontal diffusion coefficients to a constant value on first call
if iopt hdif coef=1. If iopt hdif coef=2, the coefficients are determined
using the Smagorinsky formulation.
Reference
Sections 5.3.11.1 and 5.5.6.1
Calling procedures
coherens main
File
Diffusion Coefficients.F90
Type
Subroutine
Purpose
Calculate the vertical diffusion coefficients νT and λT using the turbu-
lence model selected by the user. The actual calculation is performed
by the routines in Turbulence Equations.F90.
22.8. DIFFUSION TERMS.F90 689
Reference
Section 4.4
Calling procedures
coherens main
Xdif at C
SUBROUTINE Xdif at C(psic,tridcfc,hdifcoefatu,novars,klo,kup)
INTEGER, INTENT(IN) :: klo, kup
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psic
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz,4,novars) :: tridcfc
REAL, INTENT(IN), DIMENSION(ncloc+1,nrloc,nz) :: hdifcoefatu
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Diffusion term in the X-direction for one or more scalar quantities at
the C-nodes
Reference
Section 5.5.5.1
Arguments
psic C-node quantity or quantitites to be diffused [psic]
tridcfc Tridiagonal solution matrix. The result is stored as an
explicit term. [psic]
690 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
transport at C 3d, transport at C 4d1, transport at C 4d2
Xdif at U 2d
SUBROUTINE Xdif at U 2d(psiu,xdifatu2d,hdifcoefatc,vintflag)
LOGICAL, INTENT(INOUT) :: vintflag
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo) :: psiu
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc) :: xdifatu2d
REAL, INTENT(IN), DIMENSION(0:ncloc,0:nrloc) :: hdifcoefatc
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Alongstream diffusion term for the X-component of the depth current-
integrated current U at the U-nodes
Reference
Section 5.3.8
Arguments
psiu U-node quantity to be diffused [m2 /s]
xdifatu2d Diffusion term times ∆τ [m2 /s]
hdifcoefatc Horizontal diffusion coefficient at the C-nodes [m2 /s]
vintflag Add the result to the third (2-D barotropic) part of equa-
tion (5.191) if set to .TRUE. at predictor time steps.
Calling procedures
transport at U 2d
22.8. DIFFUSION TERMS.F90 691
Xdif at U 3d
SUBROUTINE Xdif at U 3d(psiu,xdifatu3d,hdifcoefatc,vintflag)
LOGICAL, INTENT(IN) :: vintflag
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiu
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,nz) :: xdifatu3d
REAL, INTENT(IN), DIMENSION(0:ncloc,0:nrloc,nz) :: hdifcoefatc
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Along-stream diffusion term in the X-direction for the X-component of
the current u at the U-nodes
Reference
Section 5.3.7
Arguments
psiu U-node quantity to be diffused [m/s]
xdifatu3d Diffusion term (times hu3 ) [m2 /s2 ]
hdifcoefatc Horizontal diffusion coefficient at the C-nodes [m2 /s]
vintflag Add the result to the first (3-D) part of equation (5.191)
if set to .TRUE. at predictor time steps.
Calling procedures
transport at U 3d
Xdif at V 2d
SUBROUTINE Xdif at V 2d(psiv,xdifatv2d,hdifcoefatuv,vintflag)
LOGICAL, INTENT(INOUT) :: vintflag
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo) :: psiv
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc) :: xdifatv2d
REAL, INTENT(IN), DIMENSION(ncloc+1,nrloc+1) :: hdifcoefatuv
File
Diffusion Terms.F90
692 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Type
Subroutine
Purpose
Diffusion term in the X-direction for the 2-D current V at the V-nodes
Reference
Section 5.3.8
Arguments
psiv V-node quantity to be diffused [m2 /s]
xdifatv2d Diffusion term (times ∆τ ) [m2 /s]
hdifcoefatuv Horizontal diffusion coefficient at the UV-nodes [m2 /s]
vintflag Add the result to the third (2-D barotropic) part of equa-
tion (5.152) if set to .TRUE. at predictor time steps.
Calling procedures
transport at V 2d
Xdif at V 3d
SUBROUTINE Xdif at V 3d(psiv,xdifatv3d,hdifcoefatuv,vintflag)
LOGICAL, INTENT(IN) :: vintflag
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiv
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,nz) :: xdifatv3d
REAL, INTENT(IN), DIMENSION(ncloc+1,nrloc+1,nz) :: hdifcoefatuv
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Cross-stream advection term for the 3-D current v at the V-nodes
Reference
Section 5.3.7
Arguments
psiv V-node quantity to be diffused [m/s]
22.8. DIFFUSION TERMS.F90 693
Calling procedures
transport at V 3d
Xdif at W
SUBROUTINE Xdif at W(psiw,tridcfw,hdifcoefatuw,klo,kup)
INTEGER, INTENT(IN) :: klo, kup
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz+1):: psiw
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz+1,4) :: tridcfw
REAL, INTENT(IN), DIMENSION(ncloc+1,nrloc,2:nz) :: hdifcoefatuw
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Diffusion term in the X-direction for a quantity at the W-nodes
Reference
Section 5.6.3.1
Arguments
psiw W-node quantity to be diffused [psiw]
tridcfw Tridiagonal solution matrix. The result is stored as an
explicit term. [psiw]
hdifcoefatuw Horizontal diffusion coefficient at the UW-nodes
klo 2 for a Neumann or a Dirichlet condition at the bottom,
3 for a Dirichlet condition at the first W-node above the
bottom
kup nz for a Neumann condition or a Dirichlet condition at the
surface, nz-1 for a Dirichlet condition at the first W-node
below the surface
694 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
transport at W
Ydif at C
SUBROUTINE Ydif at C(psic,tridcfc,hdifcoefatv,novars,klo,kup)
INTEGER, INTENT(IN) :: klo, kup, novars
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psic
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz,4,novars) :: tridcfc
REAL, INTENT(IN), DIMENSION(ncloc,nrloc+1,nz) :: hdifcoefatv
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Diffusion term in the Y-direction for one or more scalar quantities at
the C-nodes
Reference
Section 5.5.5.2
Arguments
Calling procedures
transport at C 3d, transport at C 4d1, transport at C 4d2
22.8. DIFFUSION TERMS.F90 695
Ydif at U 2d
SUBROUTINE Ydif at U 2d(psiu,ydifatu2d,hdifcoefatuv,vintflag)
LOGICAL, INTENT(INOUT) :: vintflag
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo) :: psiu
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc) :: ydifatu2d
REAL, INTENT(IN), DIMENSION(ncloc+1,nrloc+1) :: hdifcoefatuv
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Cross-stream diffusion term for the X-component of the depth current-
integrated current U at the U-nodes
Reference
Section 5.3.8
Arguments
psiu U-node quantity to be diffused [m2 /s]
ydifatu2d Diffusion term (times ∆τ ) [m2 /s]
hdifcoefatuv Horizontal diffusion coefficient at the UV-nodes [m2 /s]
vintflag Add the result to the fourth (2-D barotropic) part of equa-
tion (5.191) if set to .TRUE. at predictor time steps.
Calling procedures
transport at U 2d
Ydif at U 3d
SUBROUTINE Ydif at U 3d(psiu,ydifatu3d,hdifcoefatuv,vintflag)
LOGICAL, INTENT(IN) :: vintflag
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiu
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,nz) :: ydifatu3d
REAL, INTENT(IN), DIMENSION(ncloc+1,nrloc+1,nz) :: hdifcoefatuv
File
Diffusion Terms.F90
696 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Type
Subroutine
Purpose
Cross-stream diffusion term in the X-direction for the X-component of
the current u at the U-nodes
Reference
Section 5.3.7
Arguments
psiu U-node quantity to be diffused [m/s]
ydifatu3d Diffusion term (times hu3 ) [m2 /s2 ]
hdifcoefatuv Horizontal diffusion coefficient at the UV-nodes [m2 /s]
vintflag Add the result to the second (3-D) part of equation (5.191)
if set to .TRUE. at predictor time steps.
Calling procedures
transport at U 3d
Ydif at V 2d
SUBROUTINE Ydif at V 2d(psiv,ydifatv2d,hdifcoefatc,vintflag)
LOGICAL, INTENT(INOUT) :: vintflag
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo) :: psiv
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc) :: ydifatv2d
REAL, INTENT(IN), DIMENSION(0:ncloc,0:nrloc) :: hdifcoefatc
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Diffusion term in the Y-direction for the 2-D current V at the V-nodes
Reference
Section 5.3.8
Arguments
22.8. DIFFUSION TERMS.F90 697
Calling procedures
transport at V 2d
Ydif at V 3d
SUBROUTINE Ydif at V 3d(psiv,ydifatv3d,hdifcoefatc,vintflag)
LOGICAL, INTENT(IN) :: vintflag
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiv
REAL, INTENT(OUT), DIMENSION(ncloc,nrloc,nz) :: ydifatv3d
REAL, INTENT(IN), DIMENSION(0:ncloc,0:nrloc,nz) :: hdifcoefatc
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Along-stream diffusion term in the Y-direction for the Y-component of
the current v at the V-nodes
Reference
Section 5.3.7
Arguments
psiv V-node quantity to be diffused [m/s]
ydifatv3d Diffusion term (times hv3 ) [m2 /s2 ]
hdifcoefatc Horizontal diffusion coefficient at the C-nodes [m2 /s]
vintflag Add the result to the second (3-D) part of equation (5.192)
if set to .TRUE. at predictor time steps.
Calling procedures
transport at V 3d
698 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Ydif at W
SUBROUTINE Ydif at W(psiw,tridcfw,hdifcoefatvw,klo,kup)
INTEGER, INTENT(IN) :: klo, kup
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz+1)::psiw
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz+1,4) :: tridcfw
REAL, INTENT(IN), DIMENSION(ncloc,nrloc+1,2:nz) :: hdifcoefatvw
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Diffusion term in the Y-direction for a quantity at the W-nodes
Reference
Section 5.6.3.2
Arguments
psiw W-node quantity to be diffused [psiw]
tridcfw Tridiagonal solution matrix. The result is stored as an
explicit term. [psiw]
hdifcoefatvw Horizontal diffusion coefficient at the VW-nodes [m2 /s]
klo 2 for a Neumann or a Dirichlet condition at the bottom,
3 for a Dirichlet condition at the first W-node above the
bottom
kup nz for a Neumann condition or a Dirichlet condition at the
surface, nz-1 for a Dirichlet condition at the first W-node
below the surface
Calling procedures
transport at W
Zdif at C
SUBROUTINE Zdif at C(psic,tridcfc,vdifcoefatw,novars,ibcsur,&
& ibcbot,nbcs,nbcb,bcsur,bcbot,klo,kup)
INTEGER, INTENT(IN) :: ibcbot, ibcsur, klo, kup, nbcb, nbcs, novars
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
22.8. DIFFUSION TERMS.F90 699
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Vertical diffusion term for one or more scalar quantities at the C-nodes
Reference
Sections 5.5.5.3 and 5.5.7
Arguments
psic C-node quantity or quantities to be diffused [psic]
tridcfc Tridiagonal matrix to store implicit and explicit terms
[psic]
vdifcoefatw Vertical diffusion coefficient at the W-nodes [m2 /s]
novars Number of variables to be diffused
ibcsur Type of surface boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition (5.391)
2: Neumann condition using a transfer velocity (5.392)
3: Dirichlet condition at the first C-node below the surface
(5.393)
4: Dirichlet condition (5.394) at the surface
ibcbot Type of bottom boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition (5.396)
2: Neumann condition using a transfer velocity (5.397)
3: Dirichlet condition (5.398) at the first C-node above the
bottom
4: Dirichlet condition (5.399) at the bottom
700 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
transport at C 3d, transport at C 4d1, transport at C 4d2
Zdif at U
SUBROUTINE Zdif at U(psiu,tridcfu,vdifcoefatuw,ibcsur,ibcbot,&
& nbcs,nbcb,bcsur,bcbot)
INTEGER, INTENT(IN) :: ibcbot, ibcsur, nbcb, nbcs
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psiu
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz,4) :: tridcfu
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz+1) :: vdifcoefatuw
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nbcs) :: bcsur
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nbcb) :: bcbot
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Vertical diffusion term for the 3-D current u at the U-nodes
22.8. DIFFUSION TERMS.F90 701
Reference
Sections 5.3.10 and 5.3.14
Arguments
psiu U-node quantity to be diffused [m/s]
tridcfu Tridiagonal matrix to store implicit and explicit terms
[m/s]
vdifcoefatuw Diffusion coefficient at the UW-nodes [m2 /s]
ibcsur Type of surface boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition (5.232)
ibcbot Type of bottom boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition
2: Neumann condition using a transfer velocity (see equa-
tions (5.236), (5.238), (5.239))
nbcs Last dimension of the array bcsur
nbcb Last dimension of the array bcbot
bcsur Data for the surface boundary condition. The third index
determines the type of the data
1: prescribed surface flux or surface value
[m2 /s2 ] or [m/s]
2: transfer velocity [m/s]
bcbot Data for the bottom boundary condition. The third index
defines the type of the data
1: prescribed bottom flux or bottom value
[m2 /s2 ] or [m/s]
2: transfer velocity [m/s]
Calling procedures
transport at U 3d
Zdif at V
SUBROUTINE Zdif at V(psiv,tridcfv,vdifcoefatvw,ibcsur,ibcbot,&
& nbcs,nbcb,bcsur,bcbot)
702 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Vertical diffusion term for the 3-D current v at the V-nodes
Reference
Sections 5.3.10 and 5.3.14
Arguments
psiv V-node quantity to be diffused [m/s]
tridcfv Tridiagonal matrix to store implicit and explicit terms
[m/s]
vdifcoefatvw Diffusion coefficient at the VW-nodes [m2 /s]
ibcsur Type of surface boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition (5.232)
ibcbot Type of bottom boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition
2: Neumann condition using a transfer velocity (see equa-
tions (5.237), (5.238), (5.240))
nbcs Last dimension of array bcsur
nbcb Last dimension of array bcbot
bcsur Data for the surface boundary condition. The third index
determines the type of the data
1: prescribed surface flux or surface value
[m2 /s2 ] or [m/s]
22.8. DIFFUSION TERMS.F90 703
Calling procedures
transport at V 3d
Zdif at W
SUBROUTINE Zdif at W(psiw,tridcfw,vdifcoefatc,ibcsur,ibcbot,&
& bcsur,bcbot)
INTEGER, INTENT(IN) :: ibcbot, ibcsur
REAL, INTENT(IN), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz+1)::psiw
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz+1,4) :: tridcfw
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz) :: vdifcoefatc
REAL, INTENT(IN), DIMENSION(ncloc,nrloc) :: bcbot, bcsur
File
Diffusion Terms.F90
Type
Subroutine
Purpose
Vertical diffusion term for a quantity at the W-nodes
Reference
Sections 5.6.3.3 and 5.6.6
Arguments
psiw W-node quantity to be diffused [psiw]
tridcfw Tridiagonal matrix to store implicit and explicit terms
[psiw]
vdifcoefatc Diffusion coefficient at the C-nodes [m2 /s]
ibcsur Type of surface boundary condition
0: zero flux (Neumann) condition
704 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
transport at W
File
Grid Arrays.F90
Type
Subroutine
22.9. GRID ARRAYS.F90 705
Purpose
Define the global domain grid
Calling procedures
initialise model
File
Grid Arrays.F90
Type
Subroutine
Purpose
Define the coordinates and bathymetry of each local sub-domain.
Calling procedures
initialise model
depth at nodes
SUBROUTINE depth at nodes
File
Grid Arrays.F90
Type
Subroutine
Purpose
Interpolate mean water depths at different nodes
Calling procedures
initialise model
grid arrays
SUBROUTINE grid arrays
File
Grid Arrays.F90
706 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Type
Subroutine
Purpose
Define the arrays related to the model grid at different nodes: grid
spacings in the horizontal and vertical, transformed vertical coordina-
tes, Coriolis frequency, acceleration of gravity.
Reference
Section 8.1.2.3
Calling procedures
initialise model
pointer arrays
SUBROUTINE pointer arrays
File
Grid Arrays.F90
Type
Subroutine
Purpose
Cell pointers arrays at the different nodes, orientation of the cell faces
at open boundary locations.
22.9. GRID ARRAYS.F90 707
Reference
Section 8.1.2.4
Calling procedures
initialise model
read grid
SUBROUTINE read grid
File
Grid Arrays.F90
Type
Subroutine
Purpose
Read the model grid arrays, bathymetry and open boundary locations
from a file in standard COHERENS format.
Calling procedures
initialise model
File
Grid Arrays.F90
Type
Subroutine
Purpose
Store total dephts at the old (3-D) time level.
Calling procedures
coherens main, initialise physical arrays
708 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
water depths
SUBROUTINE water depths
File
Grid Arrays.F90
Type
Subroutine
Purpose
Update the total water depths at different nodes.
Calling procedures
default phsics, initialise model, initialise model, surface elevation,
update 1dsur data
write grid
SUBROUTINE write grid
File
Grid Arrays.F90
Type
Subroutine
Purpose
Write the model grid arrays, bathymetry and open boundary locations
to a file in standard COHERENS format.
Calling procedures
initialise model
ellips params
FUNCTION ellips params(uacoef,vacoef,ubcoef,vbcoef)
REAL, INTENT(IN) :: uacoef, ubcoef, vacoef, vbcoef
REAL, DIMENSION(7) :: ellips params
File
Harmonic Analysis.f90
Type
Function
Purpose
Parameters of tidal ellipses
Reference
Section 4.12.2
Arguments
uacoef Coefficient of the cosine-term in the harmonic expansion
for the X-component of the current vector
vacoef Coefficient of the cosine-term in the harmonic expansion
for the Y-component of the current vector
ubcoef Coefficient of the sine-term in the harmonic expansion for
the X-component of the current vector
vbcoef Coefficient of the sine-term in the harmonic expansion for
the Y-component of the current vector
Calling procedures
harmonic analysis data
harmonic analysis
SUBROUTINE harmonic analysis
File
Harmonic Analysis.f90
Type
Subroutine
Purpose
Base program unit for performing harmonic analysis
710 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Reference
Section 4.12.1
Called internal procedures
harmonic analysis data, harmonic analysis grid, harmonic analysis init,
harmonic analysis reset, harmonic analysis update
Calling procedures
coherens main
File
Harmonic Analysis.f90
Type
Internal subroutine
Purpose
Define the arrays for the setup of harmonic analysis and data output.
Write the metadata to the data file. Set up the matrices for solving
the linear systems (4.390)–(4.391)
Reference
Sections 16.3.1 and 16.3.2
Calling procedures
harmonic analysis
File
Harmonic Analysis.f90
Type
Internal subroutine
Purpose
Initialise buffers for storing temporary data
Calling procedures
harmonic analysis
712 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
File
Harmonic Analysis.f90
Type
Internal subroutine
Purpose
Update the sums Rm and Sm defined by equations( 4.395) and (4.396).
Reference
Section 4.12.1
Calling procedures
harmonic analysis
current corr
SUBROUTINE current corr
File
Hydrodynamic Equations.F90
Type
Subroutine
Purpose
Solve the 3-D momentum equations at the corrector step.
Reference
Section 5.3.1.3
22.11. HYDRODYNAMIC EQUATIONS.F90 713
Calling procedures
hydrodynamic equations, initialise model
current corr 1d
SUBROUTINE current corr 1d
File
Hydrodynamic Equations.F90
Type
Subroutine
Purpose
Evaluate the depth-mean and depth-integrated currents in case of a
1-D water column application.
Calling procedures
current corr
current pred
SUBROUTINE current pred
File
Hydrodynamic Equations.F90
Type
Subroutine
Purpose
Solve the 3-D momentum equations (4.50) and (4.51) for u and v at
the predictor step.
714 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Reference
Sections 4.2.1.2 and 5.3.1.1
Calling procedures
hydrodynamic equations
current 2d
SUBROUTINE current 2d
File
Hydrodynamic Equations.F90
Type
Subroutine
Purpose
Solve the 2-D momentum and continuity equations (4.74)–(4.76) for ζ,
U, V .
Reference
Sections 4.2.2, 5.3.1.2 and 5.3.2.2
Calling procedures
hydrodynamic equations
hydrodynamic equations
SUBROUTINE hydrodynamic equations
File
Hydrodynamic Equations.F90
Type
Subroutine
22.11. HYDRODYNAMIC EQUATIONS.F90 715
Purpose
Base program unit for solving the hydrodynamic equations
Called external procedures
current corr, current pred, current 2d
Calling procedures
coherens main
File
Hydrodynamic Equations.F90
Type
Subroutine
Purpose
Update the physical vertical current w using the discretised equa-
tion (5.28).
Reference
Sections 4.2.1.2 and 5.3.1.4
Calling procedures
current corr
surface elevation
SUBROUTINE surface elevation
File
Hydrodynamic Equations.F90
Type
Subroutine
Purpose
Solve the 2-D continuity equation (4.74) for the surface elevation ζ
using the discretised form (5.12).
Reference
Sections 4.2.2 and 5.3.1.2
716 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
current 2d
File
Hydrodynamic Equations.F90
Type
Subroutine
Purpose
Solve the baroclinic continuity equation (4.91) for the (transformed)
vertical current ω using the discretised form (5.27).
Reference
Sections 4.2.2 and 5.3.1.4
Calling procedures
current corr
drying factor
SUBROUTINE drying factor
File
Inundation Schemes.f90
Type
Subroutine
Purpose
Update the α-factor used by the drying/wetting algorithm.
22.12. INUNDATION SCHEMES.F90 717
Reference
Section 5.4.1 and equation (5.318)
Calling procedures
surface elevation
mask function
SUBROUTINE mask function
File
Inundation Schemes.f90
Type
Subroutine
Purpose
Evaluate the mask criteria for the flooding scheme, reset the pointer
arrays and set the currents to zero at blocked velocity nodes.
Reference
Section 5.4.2 and equations (5.323)–(5.334)
Calling procedures
coherens main
minimum depths
SUBROUTINE minimum depths
File
Inundation Schemes.f90
Type
Subroutine
Purpose
Evaluate the minimum depth criteria (5.319)–(5.321).
Reference
Section 5.4.1
Calling procedures
water depths
718 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
coherens end
SUBROUTINE coherens end
File
Model Finalisation.f90
Type
Subroutine
Purpose
Finalise the program after execution of all simulations. This is the last
routine called by the program after closing the defruns file.
Reference
Section 10.2.5
Calling procedures
coherens main
simulation end
SUBROUTINE simulation end
File
Model Finalisation.f90
Type
Subroutine
Purpose
Finalise the current simulation before starting an eventual new one.
Reference
Section 10.2.5
22.13. MODEL FINALISATION.F90 719
Calling procedures
coherens main
timer report
SUBROUTINE timer report
File
Model Finalisation.f90
Type
Subroutine
Purpose
Write the timer report file.
Reference
Section 7.3.4
Calling procedures
simulation end
write phsics
SUBROUTINE write phsics
File
Model Finalisation.f90
Type
Subroutine
Reference
Table 7.3
Purpose
Write the physical initial conditions to a file in standard COHERENS
format.
Calling procedures
coherens main
720 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
coherens start
SUBROUTINE coherens start
File
Model Initialisation.F90
Type
Subroutine
Purpose
Start-up procedure of the program beforing execution of the first sim-
ulation. This is the first routine called by the main program before
opening the defruns file.
Calling procedures
coherens main
default grid
SUBROUTINE default grid
File
Model Initialisation.F90
Type
Subroutine
Purpose
Set the default bathymetry using uniform water depths.
Calling procedures
initialise model
default phsics
SUBROUTINE default phsics
File
Model Initialisation.F90
22.14. MODEL INITIALISATION.F90 721
Type
Subroutine
Reference
Section 4.11
Purpose
Set the default initial conditions.
Calling procedures
initialise model
exchange phsics
SUBROUTINE exchange phsics
File
Model Initialisation.F90
Type
Subroutine
Purpose
Perform exchange communications which store the initial conditions
into the respective halos.
Calling procedures
initialise model
initialise model
SUBROUTINE initialise model
File
Model Initialisation.F90
Type
Subroutine
Purpose
Ensemble of routine calls for initialisation of a simulation
722 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Reference
Section 10.2.2
Calling procedures
coherens main
File
Model Initialisation.F90
Type
Subroutine
Purpose
Initialise a series of arrays, not obtained from the initial conditions file.
Calling procedures
initialise model
read phsics
SUBROUTINE read phsics
File
Model Initialisation.F90
22.15. MODEL PARAMETERS.F90 723
Type
Subroutine
Purpose
Read the physical initial conditions from a file in standard COHERENS
format.
Reference
Table 7.3
Calling procedures
initialise model
simulation start
SUBROUTINE simulation start(next simul)
LOGICAL, INTENT(OUT) :: next simul
File
Model Initialisation.F90
Type
Subroutine
Purpose
Read the title of the next simulation from the defruns file and define
the parameters for monitoring.
Arguments
next simul .TRUE. to start the next simulation, .FALSE. to exit the
program
Calling procedures
coherens main
Reference
Section 7.4
Arguments
fass File will be read with/without data assignment if .TRUE./.FALSE.
iddesc Key id of the CIF
Calling procedures
harmonic analysis, harmonic analysis init, initialise model, simula-
tion start, time averages, time averages init, time series, time series init
File
Model Parameters.f90
Type
Subroutine
Purpose
Write the CIF for physical model setup.
Reference
Section 7.4
Arguments
iddesc Key id of the CIF
Calling procedures
initialise model
File
Nested Grids.F90
Type
Subroutine
Purpose
Define the open boundary locations of all nested sub-grids. Absolute
coordinates are converted into relative ones if necessary.
Reference
Sections 8.5 and 15.3
Arguments
iset Index of the nested sub-grid
nhdat Number of sub-grid open boundary locations
nzdat Number of vertical levels
nonodes The number of nodes for which relative coordinates need
to be defined. Value is either 1 or 2.
hnests Relative coordinates of the sub-grid open boundary loca-
tions
zcoord Z-coordinates of the sub-grid open boundary locations
cnode Nodal type of the open boundary locations (‘C’, ‘U’, ‘V’)
Calling procedures
nest locations
22.16. NESTED GRIDS.F90 727
File
Nested Grids.F90
Type
Subroutine
Purpose
General specifications of all sub-grid nests (number of sub-grid open
boundary locations, number of vertical levels, type of required data)
Reference
Sections 8.5 and 15.3.1
Calling procedures
nest locations
nest locations
SUBROUTINE nest locations
File
Nested Grids.F90
Type
Subroutine
Purpose
Define the positions (in relative coordinates) of all open boundary lo-
cations on each sub-grid nest and a series of associated arrays.
Reference
Sections 8.5
Calling procedures
initialise model
728 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
File
Nested Grids.F90
Type
Subroutine
Purpose
Read the absolute coordinates of the open boundary locations on a
sub-grid from a file in standard COHERENS format.
Reference
Section 15.3.2
Arguments
iset Index of the nested sub-grid
nhdat Number of open boundary locations on the sub-grid
nzdat Number of vertical levels
xcoord X-coordinates of the sub-grid data points
[meters or longitude]
ycoord Y-coordinates of the sub-grid data points
[meters or latitude]
zcoord Z-coordinates of the sub-grid locations, defined as the posi-
tive distance to the mean water level (only when nzdat>0)
[m]
Calling procedures
define nstgrd locs
File
Nested Grids.F90
Type
Subroutine
Purpose
Read the relative coordinates of the open boundary locations on a sub-
grid from a file in standard COHERENS format.
Reference
Section 15.3.3
Arguments
iset Index of the nested sub-grid
nhdat Number of open boundary locations on the sub-grid
nzdat Number of vertical levels
nonodes Number of nodes for which relative coordinates need to be
provided. Its value equals 1 or 2 depending on the value
of cnode.
hnests Relative coordinates of the sub-grid data points
zcoord Z-coordinates of the sub-grid locations, defined as the posi-
tive distance to the mean water level (only when nzdat>0)
[m]
Calling procedures
define nstgrd locs
File
Nested Grids.F90
Type
Subroutine
Purpose
Read the general specifications of all sub-grid nests (number of sub-grid
open boundary locations, number of vertical levels, type of required
data) from a file in standard COHERENS format.
730 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Reference
Section 15.3.1
Calling procedures
define nstgrd spec
File
Nested Grids.F90
Type
Subroutine
Purpose
Interpolate 3-D scalar profile data from the model grid to the appropri-
ate open boundaries of each nested sub-grid and write the interpolated
data to the appropriate file(s).
Arguments
psic C-node scalar quantity used for the nesting
novars Total number of “state” variables (currently 1)
novarsnst Total number of “state” variables to be nested per sub-grid
(currentlty 1)
instvars Indices of the variables to be nested (currently 1)
iddesc Key id of the corresponding output file(s)
Calling procedures
salinity equation, temperature equation
22.16. NESTED GRIDS.F90 731
File
Nested Grids.F90
Type
Subroutine
Purpose
Interpolate 2-D model data (transports and/or elevations) from the
model grid to the appropriate open boundaries of each nested sub-grid
and write the interpolated data to the appropriate file(s).
Calling procedures
current 2d, initialise model
File
Nested Grids.F90
Type
Subroutine
Purpose
Interpolate 3-D baroclinic current data from the model grid to the
appropriate open boundaries of each nested sub-grid and write the in-
terpolated data to the appropriate file(s).
Calling procedures
current corr
File
Nested Grids.F90
Type
Subroutine
Purpose
Write 3-D scalar data interpolated at a specific sub-grid to a file in
standard COHERENS format.
Arguments
iddesc Key id of the corresponding output file(s)
iset Index (file number) of the nested sub-grid
outvals Output data
maxstats Second dimension of the array indexprocs
nzdat Number of data points in the vertical
nonst Number of “state” variables to be nested (currently 1)
nhdatloc Number of output locations in the horizontal on the local
domain grid
nostatsglb Number of output locations on the global grid
nhdatprocs Number of output locations per process
indexprocs Index mapping array (see Section 9.5)
Calling procedures
update nest data prof
File
Nested Grids.F90
Type
Subroutine
Purpose
Write the 2-D data interpolated at a specific sub-grid to a file in stan-
dard COHERENS format.
Arguments
iset Index (file number) of the nested sub-grid
ivar (netCDF) Id of the variable within the file
outvals Output data
maxstats Second dimension of the array indexprocs
nhdatloc Number of output locations in the horizontal on the local
domain grid
nostatsglb Number of output locations on the global grid
nhdatprocs Number of output locations per process
indexprocs Index mapping array (see Section 9.5)
Calling procedures
update nest data 2d
File
Nested Grids.F90
Type
Subroutine
734 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Purpose
Write 3-D baroclinic current data interpolated at a specific sub-grid to
a file in standard COHERENS format.
Arguments
iset Index (file number) of the nested sub-grid
outvals Output data
maxstats Second dimension of the array indexprocs
nzdat Number of data points in the vertical
nhdatloc Number of output locations in the horizontal on the local
domain grid
nostatsglb Number of output locations on the global grid
nhdatprocs Number of output locations per process
indexprocs Index mapping array (see Section 9.5)
Calling procedures
update nest data 3d
File
Nested Grids.F90
Type
Subroutine
Purpose
Write the absolute coordinates of the open boundary locations on a
sub-grid to a file in standard COHERENS format.
Reference
Section 15.3.2
Arguments
iset Index of the nested sub-grid
22.16. NESTED GRIDS.F90 735
File
Nested Grids.F90
Type
Subroutine
Purpose
Write the relative coordinates of the open boundary locations on a
sub-grid to a file in standard COHERENS format.
Reference
Section 15.3.3
Arguments
iset Index of the nested sub-grid
nhdat Number of open boundary locations on the sub-grid
nzdat Number of vertical levels
nonodes Number of nodes for which relative coordinates need to be
provided. Its value equals 1 or 2 depending on the value
of cnode.
736 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
define nstgrd locs
File
Nested Grids.F90
Type
Subroutine
Purpose
Write the general specifications of all sub-grid nests (number of sub-
grid open boundary locations, number of vertical levels, type of required
data) to a file in standard COHERENS format.
Reference
Section 15.3.1
Calling procedures
define nstgrd spec
File
Open Boundary Conditions.f90
Type
Subroutine
Purpose
Apply the open open boundary conditions for a 3-D scalar C-node
quantity.
Reference
Section 4.10.2.1, 5.5.7.3 and 14.2.1
Arguments
psi C-node scalar quantity defined on the 3-D model grid
psiobu Returned values of the scalar quantity at West/East open
boundaries. The data are flagged if a zero gradient condi-
tion is applied at the open boundary location.
psiobv Returned values of the scalar quantity at South/North
open boundaries. The data are flagged if a zero gradient
condition is applied at the open boundary location.
obcdata Time-interpolated external data profiles. A zero gradient
condition is substituted for data which are flagged.
obcpsiatu Storage array in case the open boundary condition at the
U-nodes uses values from previous time steps
obcpsiatv Storage array in case the open boundary condition at the
V-nodes uses values from previous time steps
itypobu Type of open boundary condition at the U-nodes
0: External data profile or zero gradient condition
1: Radiation condition using internal wave speed
738 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
salinity equation, temperature equation
File
Open Boundary Conditions.f90
Type
Subroutine
Purpose
Apply the open boundary conditions for the 2-D mode.
Reference
Sections 4.10.1, 5.3.15.1 and 14.1
Calling procedures
current 2d
File
Open Boundary Conditions.f90
Type
Subroutine
Purpose
Apply the open open boundary conditions for the 3-D baroclinic cur-
rent.
Reference
Sections 4.10.2.1, 5.3.16.1 and 14.2.1
Arguments
psiobu Returned values of the baroclinic current at West/East
open boundaries. The data are flagged if a zero gradient
condition is applied without external data.
psiobv Returned values of the baroclinic current at South/North
open boundaries. The data are flagged if a zero gradient
condition is applied without external data.
obcdata Time-interpolated external data profiles. A zero gradient
condition is substituted for data which are flagged.
itypobu Type of open boundary condition at the U-nodes
0: External data profile or first order zero gradient condi-
tion
1: Second order zero gradient condition
2: Local solution
3: Radiation condition using internal wave speed
4: Orlanski type of radiation condition
itypobv Type of open boundary condition at the V-nodes
0: External data profile or first order zero gradient condi-
tion
740 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
current corr
File
Open Boundary Data Prof.f90
Type
Subroutine
Purpose
Define open boundary profiles.
Reference
Section 14.2.2
Arguments
iddesc Key id of the corresponding forcing data file
ifil File index of the data file
22.18. OPEN BOUNDARY DATA PROF.F90 741
Calling procedures
update profobc data
File
Open Boundary Data Prof.f90
Type
Subroutine
Purpose
Provide the information needed for applying the open boundary con-
ditions for a 3-D quantity (baroclinic current, C-node scalar): type
of condition, profile number of each open boundary point, number of
profiles in each data file and index mapping arrays used to locate the
profiles and variables within each data file.
Reference
Sections 10.2.4 and 14.2.1
Arguments
742 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
current corr, salinity equation, temperature equation
File
Open Boundary Data Prof.f90
22.18. OPEN BOUNDARY DATA PROF.F90 743
Type
Subroutine
Purpose
Read the open boundary profile data in standard COHERENS format.
Arguments
iddesc Key id of the corresponding forcing data file
ifil File index of the data file
ciodatetime Returned date and time of the data
psiprofdat Returned profile data
numprofs Number of profiles in the data file
Calling procedures
define profobc data
File
Open Boundary Data Prof.f90
Type
Subroutine
Purpose
Read the information needed for applying the open boundary condi-
tions for a 3-D quantity (baroclinic current, C-node scalar) from a file
744 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Reference
Sections 10.2.4 and 14.2.1
Arguments
iddesc Key id of the corresponding forcing data file
itypobu Type of open boundary condition at the U-nodes (see Sec-
tion 14.2.1.1)
itypobv Type of open boundary condition at the V-nodes (see Sec-
tion 14.2.1.1)
iprofobu Profile number at the U-nodes for each data variable. If
set to zero, the type of condition is determined by the
value of itypobu.
iprofobv Profile number at the V-nodes for each data variable. If
set to zero, the type of condition is determined by the
value of itypobv.
iprofrlx Disables/enables relaxation in “relaxation” areas.
noprofsd Number of profiles per data file
indexprof Mapping array of the profile numbers in the data files to
the profile numbers assigned to the open boundaries. The
physical size of the first dimension equals the number of
profiles in a data file.
indexvar Defines the variable number of the profiles in a data file.
The physical size of the first dimension equals the number
of profiles in a data file.
novars Total number of (scalar) variables. Value is 1 in the cur-
rent implementation.
nofiles Number of data files (minus 1)
Calling procedures
define profobc spec
& indexvar,maxprofs,noprofs,novars,&
& nofiles,nosecsdat,iddesc)
INTEGER, INTENT(IN) :: iddesc, maxprofs, nofiles, noprofs, novars
INTEGER, INTENT(IN) , DIMENSION(2:nofiles) :: noprofsd
INTEGER, INTENT(IN), DIMENSION(maxprofs,2:nofiles) :: indexprof
INTEGER, INTENT(IN), DIMENSION(maxprofs,2:nofiles) :: indexvar
INTEGER (KIND=kndilong), INTENT(INOUT),&
& DIMENSION(2:nofiles,2) :: nosecsdat
REAL, INTENT(INOUT), DIMENSION(maxprofs,nz,2:nofiles,2) :: profdata
REAL, INTENT(INOUT), DIMENSION(0:noprofs,nz,novars) :: obcdata
File
Open Boundary Data Prof.f90
Type
Subroutine
Purpose
Update the open boundary profile data by reading new data (if needed).
Interpolate at the current simulation time (if requested).
Reference
Section 10.2.4
Arguments
profdata Profile data at the latest time earlier than the current
date/time and at the earliest time later than the current
date/time
obcdata Returned profile arrays interpolated at the current simu-
lation time
noprofsd Number of profiles per data file
indexprof Mapping array of the profile numbers in the data files to
the profile numbers assigned to the open boundaries. The
physical size of the first dimension equals the number of
profiles in a data file.
indexvar Defines the variable number of the profiles in a data file.
The physical size of the first dimension equals the number
of profiles in a data file.
maxprofs Maximum number of profiles in any data file
noprofs Total number of profiles
746 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
current corr, salinity equation, temperature equation
File
Open Boundary Data Prof.f90
Type
Subroutine
Purpose
Write the open boundary profile data in standard COHERENS format.
Arguments
iddesc Key id of the corresponding forcing data file
ifil File index of the data file
ciodatetime Date and time of the data
psiprofdat Profile data
numprofs Number of profiles in the data file
Calling procedures
define profobc data
22.18. OPEN BOUNDARY DATA PROF.F90 747
File
Open Boundary Data Prof.f90
Type
Subroutine
Purpose
Write the information needed for applying the open boundary condi-
tions for a 3-D quantity (baroclinic current, C-node scalar) to a file in
standard COHERENS format: type of condition, profile number of each
open boundary point, number of profiles in each data file and index
mapping array used to locate the profiles and variables within each
data file.
Reference
Sections 10.2.4 and 14.2.1
Arguments
iddesc Key id of the corresponding forcing data file
itypobu Type of open boundary condition at the U-nodes (see Sec-
tion 14.2.1.1)
itypobv Type of open boundary condition at the V-nodes (see Sec-
tion 14.2.1.1)
iprofobu Profile number at the U-nodes for each data variable. If
set to zero, the type of condition is determined by the
value of itypobu.
748 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Arguments
ifil File index of the data file
ciodatetime Returned date and time of the data
data2d Returned open boundary data
nodat Number of open boundary locations in the data file
novars Number of data variables in the data file
Called external procedures
read 2dobc data, usrdef 2dobc data, write 2dobc data
Calling procedures
update 2dobc data
File
Open Boundary Data 2D.f90
Type
Subroutine
Purpose
Read the 2-D open boundary data from a file in COHERENS standard
format.
Reference
Section 14.1.2
Arguments
ifil File index of the data file
ciodatetime Returned date and time of the data
data2d Returned input data
nodat Number of open boundary locations in the data file
novars Number of data variables in the data file (1 or 2)
Calling procedures
define 2dobc data
File
Open Boundary Data 2D.f90
Type
Subroutine
Purpose
Update the 2-D open boundary data by reading new data (if needed).
Interpolate at the current simulation time. Update the harmonic ex-
pansions (where needed) for U , V , ζ.
Reference
Section 10.2.4
Calling procedures
current 2d, initialise model
File
Open Boundary Data 2D.f90
Type
Subroutine
Purpose
Write the 2-D open boundary data to a file in COHERENS standard
format.
Arguments
ifil File index of the data file
ciodatetime Date and time of the data
752 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
define 2dobc data
File
Open Boundary Data 2D.f90
Type
Subroutine
Purpose
Write the arrays which specify the type of condition and data, the
location of the 2-D data within the data files, the amplitudes and phases
in case of an harmonic expansion is used. The file is written in standard
COHERENS format.
Reference
Section 14.1.1
Calling procedures
define 2dobc spec
File
Parallel Initialisation.f90
Type
Subroutine
22.20. PARALLEL INITIALISATION.F90 753
Purpose
Define the setup for exchange communications
Reference
Section 9.4.3.2
Calling procedures
domain decomposition
domain coords
SUBROUTINE domain coords
File
Parallel Initialisation.f90
Type
Subroutine
Purpose
Define the domain indices of each sub-domain in the decomposition.
Reference
Section 9.2.1
Calling procedures
domain decomposition
domain decomposition
SUBROUTINE domain decomposition
File
Parallel Initialisation.f90
Type
Subroutine
Purpose
Create a domain decomposition for parallel applications.
Reference
Section 9.2.1
754 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
initialise model
read partition
SUBROUTINE read partition
File
Parallel Initialisation.f90
Type
Subroutine
Purpose
Read the arrays defining the domain decomposition from a file in stan-
dard COHERENS format.
Reference
Section 9.2.1
Calling procedures
domain decomposition
regular partition
SUBROUTINE regular partition
File
Parallel Initialisation.f90
Type
Subroutine
Purpose
Define a “simple” domain decomposition using a partitioning into
nprocsx*nprocsy sub-domains.
Calling procedures
domain decomposition
22.20. PARALLEL INITIALISATION.F90 755
File
Parallel Initialisation.f90
Type
Subroutine
Purpose
Define the dimensions nprocxs, nprocsy of the domain decomposition in
case they are not supplied by the user.
Reference
Section 9.2.1
Arguments
np Number of processes
npx Returned X-dimension of the decomposition
npy Returned Y-dimension of the decomposition
Calling procedures
set procnums
set procnums
SUBROUTINE set procnums
File
Parallel Initialisation.f90
Type
Subroutine
Purpose
Define the values of nprocs, nprocsx, nprocsy.
Reference
Section 9.2.1
756 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
initialise model
File
Parallel Initialisation.f90
Type
Subroutine
Purpose
Separate active from idle processes. Define the comm work communi-
cator for all active processes.
Calling procedures
initialise model
write partition
SUBROUTINE write partition
File
Parallel Initialisation.f90
Type
Subroutine
Purpose
Write the arrays defining the domain decomposition to a file in standard
COHERENS format.
Reference
Section 9.2.1
Calling procedures
domain decomposition
22.21. RELAXATION ZONES.F90 757
File
Relaxation Zones.f90
Type
Subroutine
Purpose
Define the zones for application of the open boundary relaxation scheme.
Reference
Section 14.3
Called external procedures
read rlxobc spec, usrdef rlxobc spec, write rlxobc spec
Calling procedures
initialise model
File
Relaxation Zones.f90
Type
Subroutine
Purpose
Read the arrays which define the areas for application of the open
boundary relaxation scheme from a file in standard COHERENS format.
Reference
Section 14.3
Calling procedures
define rlxobc spec
758 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
relaxation at C
SUBROUTINE relaxation at C(psi,psiobu,psiobv,novars,iprofrlx)
INTEGER, INTENT(IN) :: novars
INTEGER, INTENT(IN), DIMENSION(norlxzones) :: iprofrlx
REAL, INTENT(INOUT), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psi
REAL, INTENT(INOUT), DIMENSION(nobu,nz,novars) :: psiobu
REAL, INTENT(INOUT), DIMENSION(nobv,nz,novars) :: psiobv
File
Relaxation Zones.f90
Type
Subroutine
Purpose
Apply the relaxation scheme for a quantity or quantities at C-nodes
Reference
Section 4.10.3
Arguments
psi Array of C-node quantity or quantities as defined on the
model grid [psi]
psiobu Vertical profiles of the C-node variable(s) at the U-open
boundaries [psi]
psiobv Vertical profiles of the C-node variable(s) at the V-open
boundaries [psi]
novars Number of C-node variables (currently 1)
iprofrlx Array which selects the zones for application of the scheme
Calling procedures
transport at C 3d, transport at C 4d1, transport at C 4d2
relaxation at U
SUBROUTINE relaxation at U(psi,psiobu,nzdim,iprofrlx)
INTEGER, INTENT(IN) :: nzdim
INTEGER, INTENT(IN), DIMENSION(norlxzones) :: iprofrlx
REAL, INTENT(INOUT), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nzdim) :: psi
REAL, INTENT(INOUT), DIMENSION(nobu,nzdim) :: psiobu
22.21. RELAXATION ZONES.F90 759
File
Relaxation Zones.f90
Type
Subroutine
Purpose
Apply the relaxation scheme for a quantity at the U-nodes
Reference
Section 4.10.3
Arguments
psi U-node variable as defined on the model grid [psi]
psiobu Vertical profiles of the U-node variables at the U-open
boundaries [psi]
nzdim Vertical dimension of the U-node variable
iprofrlx Array which selects the zones for application of the scheme
Calling procedures
current corr
relaxation at V
SUBROUTINE relaxation at V(psi,psiobv,nzdim,iprofrlx)
INTEGER, INTENT(IN) :: nzdim
INTEGER, INTENT(IN), DIMENSION(norlxzones) :: iprofrlx
REAL, INTENT(INOUT), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nzdim) :: psi
REAL, INTENT(INOUT), DIMENSION(nobv,nzdim) :: psiobv
File
Relaxation Zones.f90
Type
Subroutine
Purpose
Apply the relaxation scheme for a quantity at V-nodes
Reference
Section 4.10.3
760 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Arguments
psi V-node variable as defined on the model grid [psi]
psiobv Vertical profiles of the V-node variables at the V-open
boundaries [psi]
nzdim Vertical dimension of the V-node variable
iprofrlx Array which selects the zones for application of the scheme
Calling procedures
current corr
relaxation weights
SUBROUTINE relaxation weights
File
Relaxation Zones.f90
Type
Subroutine
Purpose
Define the weight factors for the interpolation scheme.
Reference
Section 4.10.3
Calling procedures
initialise model
File
Relaxation Zones.f90
Type
Subroutine
Purpose
Write the arrays which define the areas for application of the open
boundary relaxation scheme to a file in standard COHERENS format.
22.22. SURFACE BOUNDARY DATA 1D.F90 761
Reference
Section 14.3
Calling procedures
define rlxobc spec
File
Surface Boundary Data 1D.f90
Type
Subroutine
Purpose
Define the surface forcing data for 1-D applications.
Reference
Section 15.1.2
Arguments
ciodatetime Returned date and time of the data
data1d Returned surface forcing data
novars Number of data variables in the data file
Calling procedures
update 1dsur data
762 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
File
Surface Boundary Data 1D.f90
Type
Subroutine
Purpose
Define the amplitudes and phases of the forcing data (if any) and the
type of data in case there is an external data file.
Reference
Section 15.1.1
Calling procedures
update 1dsur data
File
Surface Boundary Data 1D.f90
Type
Subroutine
Purpose
Read the surface forcing data for 1-D applications from a file in stan-
dard COHERENS format.
Reference
Section 15.1.2
Arguments
22.22. SURFACE BOUNDARY DATA 1D.F90 763
Calling procedures
define 1dsur data
File
Surface Boundary Data 1D.f90
Type
Subroutine
Purpose
Read the amplitudes and phases of the forcing data (if any) and the
type of data in case there is an external data file from a file in standard
COHERENS format.
Reference
Section 15.1.1
Arguments
None
Calling procedures
define 1dsur spec
File
Surface Boundary Data 1D.f90
Type
Subroutine
764 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Purpose
Update the surface forcing data (surface slopes, elevations) by read-
ing new data (if needed). Interpolate at the current simulation time.
Update the harmonic expansions for the surface slopes and the water
elevation (if requested).
Calling procedures
current pred, initialise model
File
Surface Boundary Data 1D.f90
Type
Subroutine
Purpose
Write the surface forcing data to a file in standard COHERENS format.
Reference
Section 15.1.2
Arguments
Calling procedures
define 1dsur data
22.23. SURFACE DATA.F90 765
File
Surface Boundary Data 1D.f90
Type
Subroutine
Purpose
Write the amplitudes and phases of the forcing data (if any) and the
type of data in case there is an external data file to a file in standard
COHERENS format.
Reference
Section 15.1.1
Calling procedures
define 1dsur spec
File
Surface Data.f90
Type
Subroutine
Purpose
Define (2-D) surface forcing data.
Reference
Section 15.2.3
766 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Arguments
iddesc Key id of the corresponding forcing data file
ifil File index of the data file
ciodatetime Returned date and time of the data
surdata Returned array of surface forcing data
n1dat Dimension of the data grid in the X-direction
n2dat Dimension of the data grid in the Y-direction
novars Number of forcing data variables
Calling procedures
update surface data
File
Surface Data.f90
Type
Subroutine
Purpose
Read the (2-D) surface forcing data from a file in standard COHERENS
format.
Reference
Section 15.2.3
Arguments
iddesc Key id of the corresponding forcing data file
ifil File index of the data file
ciodatetime Returned date and time of the data
22.23. SURFACE DATA.F90 767
Calling procedures
define surface data
File
Surface Data.f90
Type
Subroutine
Purpose
Update surface input defined on an external 2-D data grid by reading
new data (if needed). Interpolate the data in space on the model grid
and in time at the current simulation time (if requested).
Reference
Section 10.2.4
Arguments
iddesc Key id of the corresponding forcing data file
ifil File index of the data file
surindat Array of surface data at the latest time earlier than the
current date/time and at the earliest time later than the
current date/time
768 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
meteo input, temperature equation
File
Surface Data.f90
Type
Subroutine
22.24. SURFACE FLUXES.F90 769
Purpose
Write the (2-D) surface forcing data to a file in standard COHERENS
format.
Reference
Section 15.2.3
Arguments
iddesc Key id of the corresponding forcing data file
ifil File index of the data file
ciodatetime Date and time of the data
surdata Array of surface forcing data
n1dat Dimension of the data grid in the X-direction
n2dat Dimension of the data grid in the Y-direction
novars Number of forcing data variables
Calling procedures
define surface data
heat flux
SUBROUTINE heat flux
File
Surface Fluxes.F90
Type
Subroutine
Purpose
Evaluate all non-solar surface heat fluxes.
Reference
Section 4.7.3
Calling procedures
initialise model, temperature equation
meteo input
SUBROUTINE meteo input
File
Surface Fluxes.F90
Type
Subroutine
Purpose
Update meteorological forcing data.
Calling procedures
coherens main, initialise model
salinity flux
SUBROUTINE salinity flux
File
Surface Fluxes.F90
Type
Subroutine
Purpose
Surface salinity flux
Reference
Section 4.7.4
Calling procedures
salinity equation
22.24. SURFACE FLUXES.F90 771
solar irradiance
SUBROUTINE solar irradiance
File
Surface Fluxes.F90
Type
Subroutine
Purpose
Solar radiation at the surface
Reference
Section 4.6
Calling procedures
temperature equation
File
Surface Fluxes.F90
Type
Subroutine
Purpose
Surface drag coefficient Cds
Reference
Section 4.8
Arguments
wind Magnitude of the wind speed [m/s]
Calling procedures
surface stress
772 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
File
Surface Fluxes.F90
Type
Subroutine
Purpose
Neutral surface drag coefficient Cdn as function of the wind speed
Reference
Section 4.8.1
Arguments
cdn Returned neutral surface drag coefficient
wind Magnitude of the wind speed [m/s]
Calling procedures
surface exchange MO
File
Surface Fluxes.F90
Type
Subroutine
Purpose
Surface exchange coefficients Ce and Ch used in the calculation of the
latent and sensible heat fluxes
Reference
Section 4.8
Arguments
22.24. SURFACE FLUXES.F90 773
Calling procedures
heat flux
File
Surface Fluxes.F90
Type
Subroutine
Purpose
Neutral surface exchange coefficients Cen and Chn as function of the
wind speed and the sea minus air temperature difference
Reference
Section 4.8.1
Arguments
cen Returned neutral exchange coefficient Cen for the latent
heat flux
chn Returned neutral exchange coefficient Chn for the sensible
heat flux
wind Magnitude of the wind speed [m/s]
temdif Sea surface minus air temperature difference [0 C]
Calling procedures
surface exchange MO
surface exchange MO
SUBROUTINE surface exchange MO
File
Surface Fluxes.F90
774 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Type
Subroutine
Purpose
Solve the equations for the surface drag and exchange coefficients using
the Monin-Obukhov similarity theory as function of wind speed, air
minus sea temperature difference and relative humidity. The values
are obtained for discretised values of the meteorological data. The
results stored in tabular form.
Reference
Section 4.8.3
Called external procedures
surface drag coef 0d, surface exchange coefs 0d
Calling procedures
meteo input
surface stress
SUBROUTINE surface stress
File
Surface Fluxes.F90
Type
Subroutine
Purpose
Evaluate the surface stress
Reference
Section 4.7.2
Called external procedures
surface drag coef
Calling procedures
current corr, current corr 1d, current 2d, initialise model
File
Surface Grids.f90
Type
Subroutine
Purpose
Define the relative coordinates of the model grid with respect to an
external surface data grid
Reference
Sections 8.4.2 and 15.2
Arguments
iddesc Key id of the surface grid file
ifil File index of the grid file
surfgrid Relative coordinates (on the local sub-domain) of the model
grid with respect to the data grid
Calling procedures
meteo input, temperature equation
File
Surface Grids.f90
Type
Subroutine
776 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Purpose
Define the relative coordinates of an external surface data grid with
respect to the model grid. Intended for (future implementation of)
coupling with surface wave and meteorological models.
Reference
Sections 8.5
Arguments
iddesc Key id of the surface grid file
ifil File index of the grid file
surfgridglb Relative coordinates of the model grid with respect to the
external grid. The second dimension denotes the nodal
type of the model grid coordinates.
1: C-nodes
2: U-nodes
3: V-nodes
nhdat Number of horizontal locations on the data grid
Called external procedures
read surface absgrd, read surface relgrd, usrdef surface absgrd,
usrdef surface relgrd, write surface absgrd, write surface relgrd
Calling procedures
Currently not implemented
File
Surface Grids.f90
Type
Subroutine
Purpose
Read the absolute coordinates of an external surface data grid from a
file in standard COHERENS format.
22.25. SURFACE GRIDS.F90 777
Reference
Section 15.2.1
Arguments
iddesc Key id of the surface grid file
ifil File index of the grid file
n1dat X-dimension of the surface data grid
n2dat Y-dimension of the surface data grid
xcoord X-coordinates of the data grid [m or degrees longitude]
ycoord Y-coordinates of the data grid [m or degrees latitude]
Calling procedures
define surface input grid, define surface output grid
File
Surface Grids.f90
Type
Subroutine
Purpose
Read the relative coordinates of the model grid with respect to an
external surface data grid from a file in standard COHERENS format.
Reference
Section 15.2.2
Arguments
iddesc Key id of the surface grid file
ifil File index of the grid file
surfgridglb Relative coordinates of the (global) model grid with re-
spect to the external surface data grid.
nx X-dimension of the external surface grid
778 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
define surface input grid, define surface output grid
File
Surface Grids.f90
Type
Subroutine
Purpose
Write the absolute coordinates of an external surface data grid to a file
in standard COHERENS format.
Reference
Section 15.2.1
Arguments
Calling procedures
define surface input grid, define surface output grid
22.26. TIDAL FORCING.F90 779
File
Surface Grids.f90
Type
Subroutine
Purpose
Write the relative coordinates of the model grid with respect to an
external surface data grid to a file in standard COHERENS format.
Reference
Section 15.2.2
Arguments
iddesc Key id of the surface grid file
ifil File index of the grid file
surfgridglb Relative coordinates of the (global) model grid with re-
spect to the external surface data grid.
nx X-dimension of the external surface grid
ny Y-dimension of the external surface grid
nonodes Number of nodes (currently set to 1)
Calling procedures
define surface input grid, define surface output grid
astro params
SUBROUTINE astro params(index tides,fnode tides,phase tides,&
& notides,dlonref phase,cdatetime tides)
CHARACTER (LEN=lentime), INTENT(IN) :: cdatetime tides
780 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
File
Tidal Forcing.F90
Type
Subroutine
Purpose
Calculate nodal factors and astronomical arguments at the given date
and time.
Reference
Section 4.5
Arguments
index tides Key ids of the tidal constituents
fnode tides Returned nodal correction factors
phase tides Returned astronomical arguments
notides Number of tidal constituents
dlonref phase Reference longitude to be used for the phases
cdatetime tides Calendar date and time. Time is converted to GMT if
time zone is non-zero.
Calling procedures
astronomical tides, harmonic analysis data, update 1dsur data,
update 2dobc data
astronomical tides
SUBROUTINE astronomical tides
File
Tidal Forcing.F90
Type
Subroutine
22.27. TIME AVERAGES.F90 781
Purpose
Components of the astronomical tidal force
Reference
Section 4.5
Calling procedures
coherens main, current 2d, initialise model
time averages
SUBROUTINE time averages
File
Time Averages.f90
Type
Subroutine
Purpose
Base program unit for time averaged output
Calling procedures
coherens main
File
Time Averages.f90
782 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Type
Internal subroutine
Purpose
Write the coordinates of the output grid to the data file
Calling procedures
time averages
File
Time Averages.f90
Type
Internal subroutine
Purpose
Define the arrays for the setup of time averaging. Write the metadata
to the data file.
Reference
Section 16.2.1
Calling procedures
time averages
File
Time Averages.f90
Type
Internal subroutine
Purpose
Initialise buffers for storing the averaged data.
22.28. TIME SERIES.F90 783
Calling procedures
time averages
File
Time Averages.f90
Type
Internal subroutine
Purpose
Add the current data to the buffers containing the current averages.
Calling procedures
time averages
File
Time Averages.f90
Type
Internal subroutine
Purpose
Write the time-averaged output to the appropriate data files.
Calling procedures
time averages
time series
SUBROUTINE time series
File
Time Series.f90
Type
Subroutine
Purpose
Write time series output to the appropriate output files.
Calling procedures
coherens main
File
Time Series.f90
Type
Internal subroutine
Purpose
Write the coordinates of the output grid to the data file
Calling procedures
time series
File
Time Series.f90
22.29. TRANSPORT EQUATIONS.F90 785
Type
Internal subroutine
Purpose
Define the arrays for the setup of time series output. Write the meta-
data to the data file.
Reference
Section 16.1.1
Called external procedures
usrdef tsr params
Calling procedures
time series
transport at C 3d
SUBROUTINE transport at C 3d(psic,source,wadvatw,vdifcoefatw,iopt hadv,&
& iopt vadv,iopt hdif,psiobu,psiobv,iprofrlx,&
& ibcsur,ibcbot,nbcs,nbcb,bcsur,bcbot,ivarid)
INTEGER, INTENT(IN) :: ibcbot, ibcsur, iopt hadv, iopt hdif, &
& iopt vadv, ivarid, nbcb, nbcs
INTEGER, INTENT(IN), DIMENSION(norlxzones) :: iprofrlx
REAL, INTENT(IN), DIMENSION(nobu,nz) :: psiobu
REAL, INTENT(IN), DIMENSION(nobv,nz) :: psiobv
REAL, INTENT(INOUT), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz) :: psic
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz) :: source
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz+1) :: vdifcoefatw, wadvatw
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nbcs) :: bcsur
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nbcb) :: bcbot
File
Transport Equations.F90
Type
Subroutine
786 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Purpose
Solve the advection-diffusion equation for a 3-D scalar quantity at the
C-nodes.
Reference
Section 5.5
Arguments
psic C-node quantity for which a transport equation needs to
be solved [psic]
source Source terms in the transport equation [psic/s]
wadvatw Transformed vertical current ω plus (eventually) sinking/swimming
vertical current at the W-nodes [m/s]
vdifcoefatw Vertical diffusion coefficient at the W-nodes [m2 /s]
iopt hadv Switch to select horizontal advection scheme
iopt vadv Switch to select vertical advection scheme
iopt hdif Switch to select horizontal diffusion scheme
psiobu Vertical profiles at the U-open boundaries (a zero gradient
condition is applied if flagged) [psic]
psiobv Vertical profiles at the V-open boundaries (a zero gradient
condition is applied if flagged) [psic]
iprofrlx Selects whether a relaxation scheme is applied at each of
the defined open boundary zones.
ibcsur Type of surface boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition (5.391)
2: Neumann condition using a transfer velocity (5.392)
3: Dirichlet condition (5.393) at the first C-node below the
surface
4: Dirichlet condition (5.394) at the surface
ibcbot Type of bottom boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition (5.396)
2: Neumann condition using a transfer velocity (5.397)
3: Dirichlet condition (5.398) at the first C-node above the
bottom
22.29. TRANSPORT EQUATIONS.F90 787
Calling procedures
salinity equation, temperature equation
transport at C 4d1
SUBROUTINE transport at C 4d1(psic,source,wadvatw,vdifcoefatw,novars,&
& iopt hadv,iopt vadv,iopt hdif,psiobu,&
& psiobv,iprofrlx,ibcsur,ibcbot,nbcs,nbcb,&
& bcsur,bcbot,ivarids)
INTEGER, INTENT(IN) :: ibcbot, ibcsur, iopt hadv, iopt hdif,&
& iopt vadv, nbcb, nbcs, novars
INTEGER, INTENT(IN), DIMENSION(novars) :: ivarids
INTEGER, INTENT(IN), DIMENSION(norlxzones) :: iprofrlx
REAL, INTENT(IN), DIMENSION(nobu,nz,novars) :: psiobu
REAL, INTENT(IN), DIMENSION(nobv,nz,novars) :: psiobv
REAL, INTENT(INOUT), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psic
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz,novars) :: source
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz+1) :: vdifcoefatw
788 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
File
Transport Equations.F90
Type
Subroutine
Purpose
Solve the advection-diffusion equation for one or more scalar quantities
at the C-node. The equations are solved sequentially.
Reference
Section 5.5
Arguments
psic C-node quantity or quantities for which transport equa-
tion(s) need(s) to be solved [psic]
source Source terms in the transport equation(s) [psic/s]
wadvatw Transformed vertical current ω plus (eventually) sinking/swimming
vertical current(s) at the W-nodes [m/s]
vdifcoefatw Vertical diffusion coefficient at the W-nodes [m2 /s]
novars Number of variables to be transported
iopt hadv Switch to select horizontal advection scheme
iopt vadv Switch to select vertical advection scheme
iopt hdif Switch to select horizontal diffusion scheme
psiobu Vertical profiles at the U-open boundaries (a zero gradient
condition is applied if flagged) [psic]
psiobv Vertical profiles at the V-open boundaries (a zero gradient
condition is applied if flagged) [psic]
iprofrlx Selects whether a relaxation scheme is applied at each of
the defined open boundary zones.
ibcsur Type of surface boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition (5.391)
2: Neumann condition using a transfer velocity (5.392)
22.29. TRANSPORT EQUATIONS.F90 789
Calling procedures
Currently not implemented
transport at C 4d2
SUBROUTINE transport at C 4d2(psic,source,wadvatw,vdifcoefatw,novars,&
& iopt hadv,iopt vadv,iopt hdif,psiobu,&
& psiobv,iprofrlx,ibcsur,ibcbot,nbcs,nbcb,&
790 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
& bcsur,bcbot,ivarid)
INTEGER, INTENT(IN) :: ibcbot, ibcsur, iopt hadv, iopt hdif,&
& iopt vadv, ivarid, nbcb, nbcs, novars
INTEGER, INTENT(IN), DIMENSION(norlxzones) :: iprofrlx
REAL, INTENT(IN), DIMENSION(nobu,nz,novars) :: psiobu
REAL, INTENT(IN), DIMENSION(nobv,nz,novars) :: psiobv
REAL, INTENT(INOUT), DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz,novars) :: psic
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz,novars) :: source
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz+1) :: vdifcoefatw
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz+1,novars) :: wadvatw
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nbcs,novars) :: bcsur
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nbcb,novars) :: bcbot
File
Transport Equations.F90
Type
Subroutine
Purpose
Solve the advection-diffusion equation for a vector of scalar quantities
at the C-node. The equations are solved simultaneously for all vector
components.
Reference
Section 5.5
Arguments
psic C-node vector of scalar quantities for which transport equa-
tions need to be solved [psic]
source Source terms in the transport equations [psic/s]
wadvatw Transformed vertical current ω plus (eventually) sinking/swimming
vertical current(s) at the W-nodes [m/s]
vdifcoefatw Vertical diffusion coefficient at the W-nodes [m2 /s]
novars Number of variables to be transported
iopt hadv Switch to select horizontal advection scheme
iopt vadv Switch to select vertical advection scheme
iopt hdif Switch to select horizontal diffusion scheme
22.29. TRANSPORT EQUATIONS.F90 791
transport at U 2d
SUBROUTINE transport at U 2d(source,sink)
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc) :: sink, source
File
Transport Equations.F90
Type
Subroutine
Purpose
Solve the 2-D momentum equation for the X-component U of the depth-
integrated current.
Reference
Section 5.3
Arguments
source Explicit source terms in the U -equation [m2 /s2 ]
sink Implicit sink terms in the U -equation arising from bottom
stress [s−1 ]
Called external procedures
Xadv at U 2d, Xdif at U 2d, Yadv at U 2d, Ydif at U 2d
Calling procedures
current 2d
transport at U 3d
SUBROUTINE transport at U 3d(source,ibcsur,ibcbot,nbcs,nbcb,&
& bcsur,bcbot)
INTEGER, INTENT(IN) :: ibcbot, ibcsur, nbcb, nbcs
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz) :: source
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nbcs) :: bcsur
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nbcb) :: bcbot
22.29. TRANSPORT EQUATIONS.F90 793
File
Transport Equations.F90
Type
Subroutine
Purpose
Solve the 3-D momentum equation for the X-component u of the 3-D
current.
Reference
Section 5.3
Arguments
source Source terms in the u-equation
ibcsur Type of surface boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition (5.232)
ibcbot Type of bottom boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition
2: Neumann condition using a transfer velocity (see equa-
tions (5.236), (5.238), (5.239))
nbcs Last dimension of the array bcsur
nbcb Last dimension of the array bcbot
bcsur Data for the surface boundary condition. The third index
defines the type of the data
1: prescribed surface flux or surface value
[m2 /s2 ] or [m/s]
2: transfer velocity [m/s]
bcbot Data for the bottom boundary condition. The third index
defines the type of the data
1: prescribed bottom flux or bottom value
[m2 /s2 ] or [m/s]
2: transfer velocity [m/s]
Called external procedures
Xadv at U 3d, Xdif at U 3d, Yadv at U 3d, Ydif at U 3d, Zadv at U,
Zdif at U
794 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Calling procedures
current pred
transport at V 2d
SUBROUTINE transport at V 2d(source,sink)
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc) :: sink, source
File
Transport Equations.F90
Type
Subroutine
Purpose
Solve the 2-D momentum equation for the Y-component V of the depth-
integrated current.
Reference
Section 5.3
Arguments
source Explicit source terms in the V -equation [m2 /s2 ]
sink Implicit sink terms in the V -equation arising from bottom
stress [s−1 ]
Calling procedures
current 2d
transport at V 3d
SUBROUTINE transport at V 3d(source,ibcsur,ibcbot,nbcs,nbcb,&
& bcsur,bcbot)
INTEGER, INTENT(IN) :: ibcbot, ibcsur, nbcb, nbcs
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,nz) :: source
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nbcs) :: bcsur
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nbcb) :: bcbot
File
Transport Equations.F90
22.29. TRANSPORT EQUATIONS.F90 795
Type
Subroutine
Purpose
Solve the 3-D momentum equation for the Y-component v of the 3-D
current.
Reference
Section 5.3
Arguments
source Source terms in the v-equation
ibcsur Type of surface boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition (5.232)
ibcbot Type of bottom boundary condition
0: zero flux (Neumann) condition
1: prescibed flux (Neumann) condition
2: Neumann condition using a transfer velocity (see equa-
tions (5.237), (5.238), (5.240))
nbcs Last dimension of the array bcsur
nbcb Last dimension of the array bcbot
bcsur Data for the surface boundary condition. The third index
defines the type of the data
1: prescribed surface flux or surface value
[m2 /s2 ] or [m/s]
2: transfer velocity [m/s]
bcbot Data for the bottom boundary condition. The third index
defines the type of the data
1: prescribed bottom flux or bottom value
[m2 /s2 ] or [m/s]
2: transfer velocity [m/s]
Called external procedures
Xadv at V 3d, Xdif at V 3d, Yadv at V 3d, Ydif at V 3d, Zadv at V,
Zdif at V
Calling procedures
current pred
796 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
transport at W
SUBROUTINE transport at W(psiw,source,sink,vdifcoefatw,&
& ibcsur,ibcbot,bcsur,bcbot,ivarid)
INTEGER, INTENT(IN) :: ibcbot, ibcsur, ivarid
REAL, INTENT(INOUT),DIMENSION(1-nhalo:ncloc+nhalo,&
& 1-nhalo:nrloc+nhalo,nz+1) :: psiw
REAL, INTENT(INOUT), DIMENSION(ncloc,nrloc,2:nz) :: sink, source
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nz+1) :: vdifcoefatw
REAL, INTENT(IN), DIMENSION(ncloc,nrloc) :: bcbot, bcsur
File
Transport Equations.F90
Type
Subroutine
Purpose
Solve the advection-diffusion equation for a 3-D scalar (turbulent) quan-
tity at the W-node.
Reference
Section 5.6
Arguments
psiw W-node quantity for which a transport equation needs to
be solved [psiw]
source Explicit source terms in the transport equation [psic/s]
sink Implicit sink terms in the transport equation [s−1 ]
vdifcoefatw Vertical diffusion coefficient at the W-nodes [m2 /s]
ibcsur Type of surface boundary condition
0: zero flux (Neumann) condition
1: prescibed (Neumann) flux at the surface (see equations
(5.472)–(5.474))
2: prescribed Neumann flux at the first C-node below the
surface (5.475)
3: Dirichlet condition (5.476) at the surface
4: Dirichlet condition (5.477) at the first W-node below
the surface
ibcbot Type of bottom boundary condition
22.30. TURBULENCE EQUATIONS.F90 797
File
Turbulence Equations.F90
Type
Subroutine
Purpose
Calculate the eddy coefficients νT and λT from an algebraic relation
Reference
Section 4.4.2
Calling procedures
vertical diff coefs
eddy coefs tc
SUBROUTINE eddy coefs tc
File
Turbulence Equations.F90
Type
Subroutine
Purpose
Calculate the eddy coefficients νT and λT from a RANS model.
Reference
Section 4.4.3
Calling procedures
vertical diff coefs
init turbulence
SUBROUTINE init turbulence
File
Turbulence Equations.F90
22.30. TURBULENCE EQUATIONS.F90 799
Type
Subroutine
Purpose
Initialise parameters for different turbulence closures schemes
Calling procedures
vertical diff coefs, default phsics
kl equation
SUBROUTINE kl equation
File
Turbulence Equations.F90
Type
Subroutine
Purpose
Solve the kl (q 2 l) equation (4.197).
Reference
Section 5.6
Calling procedures
vertical diff coefs
mixing length
SUBROUTINE mixing length
File
Turbulence Equations.F90
Type
Subroutine
Purpose
Algebraic mixing length formulations
800 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Reference
Section 4.4.3.5
Calling procedures
default phsics, vertical diff coefs
tke equation
SUBROUTINE tke equation
File
Turbulence Equations.F90
Type
Subroutine
Purpose
Solve the k-equation (4.192).
Reference
Section 5.6
Calling procedures
vertical diff coefs
tke equilibrium
SUBROUTINE tke equilibrium
File
Turbulence Equations.F90
Type
Subroutine
Purpose
Calculate the turbulent energy k using the equilibrium (level ”2”)
method.
Reference
Section 4.4.3.3
22.30. TURBULENCE EQUATIONS.F90 801
Calling procedures
vertical diff coefs
802 APPENDIX 22. DESCRIPTION OF EXTERNAL ROUTINES
Appendix 23
Carr at U
SUBROUTINE Carr at U(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1)+1:ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
803
804 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Interpolate a section of a model grid C-node array to the U-nodes.
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
xout Destination array at the U-nodes
intsrce Selects valid points at the source node
0: all points
1: wet points only
intdest Selects valid points at the destination node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
Carr at UV
SUBROUTINE Carr at UV(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
23.1. ARRAY INTERPOLATION 805
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid C-node array to the UV-nodes.
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
xout Destination array at the UV-nodes
intsrce Selects valid points at the source node
0: all points
1: wet points only
intdest Selects valid points at the destination node
0: all points
1: wet points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
806 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Carr at UW
SUBROUTINE Carr at UW(xin,xout,intdest,lbounds,ubounds,nosize,&
& ivarid,info,outflag,hregular,vregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular, vregular
INTEGER, INTENT(IN) :: intdest, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1)+1:ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3)+1:ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid C-node array to the UW-nodes.
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
xout Destination array at the UW-nodes
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
23.1. ARRAY INTERPOLATION 807
Carr at V
SUBROUTINE Carr at V(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2)+1:ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid C-node array to the V-nodes.
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
xout Destination array at the V-nodes
intsrce Selects valid points at the source node
0: all points
808 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Carr at VW
SUBROUTINE Carr at VW(xin,xout,intdest,lbounds,ubounds,nosize,&
& ivarid,info,outflag,hregular,vregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular, vregular
INTEGER, INTENT(IN) :: intdest, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2)+1:ubounds(2),&
& lbounds(3)+1:ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
23.1. ARRAY INTERPOLATION 809
Purpose
Interpolate a section of a model grid C-node array to the VW-nodes.
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
xout Destination array at the VW-nodes
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
vregular Flag to select uniform or area averaging in the vertical, if
present. Otherwise, the type of averaging is selected by
iopt arrint vreg.
Carr at W
SUBROUTINE Carr at W(xin,xout,lbounds,ubounds,nosize,ivarid,&
& info,outflag,vregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: vregular
INTEGER, INTENT(IN) :: ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
810 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid C-node array to the W-nodes.
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
xout Destination array at the W-nodes
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
vregular Flag to select uniform or area averaging in the vertical, if
present. Otherwise, the type of averaging is selected by
iopt arrint vreg.
Uarr at C
SUBROUTINE Uarr at C(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag)
LOGICAL, INTENT(IN) :: info
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
23.1. ARRAY INTERPOLATION 811
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid U-node array to the C-nodes.
Reference
Section 8.2
Arguments
xin Source array at the U-nodes
xout Destination array at the C-nodes
intsrce Selects valid points at the source node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
0: all points
1: wet points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
812 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Uarr at UV
SUBROUTINE Uarr at UV(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2)+1:ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid U-node array to the UV-nodes.
Reference
Section 8.2
Arguments
xin Source array at the U-nodes
xout Destination array at the UV-nodes
intsrce Selects valid points at the source node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
0: all points
1: interior points and open boundaries only
23.1. ARRAY INTERPOLATION 813
Uarr at UW
SUBROUTINE Uarr at UW(xin,xout,intsrce,intdest,lbounds,ubounds,nosize,&
& ivarid,info,outflag,vregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: vregular
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3)+1:ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid U-node array to the UW-nodes.
Reference
Section 8.2
Arguments
xin Source array at the U-nodes
xout Destination array at the UW-nodes
814 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Uarr at V
SUBROUTINE Uarr at V(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1)-1,&
& lbounds(2)+1:ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xout
23.1. ARRAY INTERPOLATION 815
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid U-node array to the V-nodes.
Reference
Section 8.2
Arguments
xin Source array at the U-nodes
xout Destination array at the V-nodes
intsrce Selects valid points at the source node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
816 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Uarr at W
SUBROUTINE Uarr at W(xin,xout,intsrce,lbounds,ubounds,nosize,&
& ivarid,info,outflag,vregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: vregular
INTEGER, INTENT(IN) :: intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1)-1,lbounds(2):ubounds(2),&
& lbounds(3)+1:ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid U-node array to the W-nodes.
Reference
Section 8.2
Arguments
xin Source array at the U-nodes
xout Destination array at the W-nodes
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
23.1. ARRAY INTERPOLATION 817
UVarr at C
SUBROUTINE UVarr at C(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag)
LOGICAL, INTENT(IN) :: info
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1)-1,lbounds(2):ubounds(2)-1,&
& lbounds(3):ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid UV-node array to the C-nodes.
Reference
Section 8.2
Arguments
xin Source array at the UV-nodes
xout Destination array at the C-nodes
intsrce Selects valid points at the source node
0: all points
1: wet points only
intdest Selects valid points at the destination node
0: all points
818 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
1: wet points
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
UVarr at U
SUBROUTINE UVarr at U(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag)
LOGICAL, INTENT(IN) :: info
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2)-1,&
& lbounds(3):ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid UV-node array to the U-nodes.
Reference
Section 8.2
Arguments
xin Source array at the UV-nodes
xout Destination array at the U-nodes
intsrce Selects valid points at the source node
0: all points
1: interior points and open boundaries only
23.1. ARRAY INTERPOLATION 819
UVarr at V
SUBROUTINE UVarr at V(xin,xout,intsrce,intdest,lbounds,ubounds,nosize,&
& ivarid,info,outflag)
LOGICAL, INTENT(IN) :: info
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1)-1,lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid UV-node array to the V-nodes.
Reference
Section 8.2
820 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Arguments
xin Source array at the UV-nodes
xout Destination array at the V-nodes
intsrce Selects valid points at the source node
0: all points
1: interior points and open boundaries only
2: interior points and UV-node open boundaries only
intdest Selects valid points at the destination node
0: all points
1: coastal boundaries, interior points and open
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
UWarr at U
SUBROUTINE UWarr at U(xin,xout,intsrce,intdest,lbounds,ubounds,nosize,&
& ivarid,info,outflag)
LOGICAL, INTENT(IN) :: info
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3)-1,nosize) :: xout
File
array interp.f90
23.1. ARRAY INTERPOLATION 821
Type
Module subroutine
Purpose
Interpolate a section of a model grid UW-node array to the U-nodes.
Reference
Section 8.2
Arguments
xin Source array at the UW-nodes
xout Destination array at the U-nodes
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
UWarr at W
SUBROUTINE UWarr at W(xin,xout,intsrce,lbounds,ubounds,nosize,&
& ivarid,info,outflag)
LOGICAL, INTENT(IN) :: info
822 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid UW-node array to the W-nodes.
Reference
Section 8.2
Arguments
Varr at C
SUBROUTINE Varr at C(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag)
LOGICAL, INTENT(IN) :: info
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2)-1,&
& lbounds(3):ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid V-node array to the C-nodes.
Reference
Section 8.2
Arguments
xin Source array at the V-nodes
xout Destination array at the C-nodes
intsrce Selects valid points at the source node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
0: all points
1: wet points only
lbounds Lower bounds of the source array
824 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Varr at U
SUBROUTINE Varr at U(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1)+1:ubounds(1),&
& lbounds(2):ubounds(2)-1,&
& lbounds(3):ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid V-node array to the U-nodes.
Reference
Section 8.2
Arguments
xin Source array at the V-nodes
xout Destination array at the U-nodes
intsrce Selects valid points at the source node
0: all points
1: coastal boundaries, interior points and open boundaries
only
23.1. ARRAY INTERPOLATION 825
Varr at UV
SUBROUTINE Varr at UV(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1)+1:ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xout
File
array interp.f90
826 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module subroutine
Purpose
Interpolate a section of a model grid V-node array to the UV-nodes.
Reference
Section 8.2
Arguments
Varr at VW
SUBROUTINE Varr at VW(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag,vregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: vregular
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3)+1:ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid V-node array to the VW-nodes.
Reference
Section 8.2
Arguments
xin Source array at the V-nodes
xout Destination array at the VW-nodes
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
828 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Varr at W
SUBROUTINE Varr at W(xin,xout,intsrce,lbounds,ubounds,nosize,&
& ivarid,info,outflag,vregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: vregular
INTEGER, INTENT(IN) :: intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2)-1,&
& lbounds(3)+1:ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid V-node array to the W-nodes.
Reference
Section 8.2
Arguments
xin Source array at the V-nodes
23.1. ARRAY INTERPOLATION 829
VWarr at V
SUBROUTINE VWarr at V(xin,xout,intsrce,intdest,lbounds,ubounds,&
& nosize,ivarid,info,outflag)
LOGICAL, INTENT(IN) :: info
INTEGER, INTENT(IN) :: intdest, intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3)-1,nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid VW-node array to the V-nodes.
830 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Reference
Section 8.2
Arguments
xin Source array at the VW-nodes
xout Destination array at the V-nodes
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
VWarr at W
SUBROUTINE VWarr at W(xin,xout,intsrce,lbounds,ubounds,nosize,&
& ivarid,info,outflag)
LOGICAL, INTENT(IN) :: info
INTEGER, INTENT(IN) :: intsrce, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2)-1,&
& lbounds(3):ubounds(3),nosize) :: xout
23.1. ARRAY INTERPOLATION 831
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid VW-node array to the W-nodes.
Reference
Section 8.2
Arguments
xin Source array at the VW-nodes
xout Destination array at the W-nodes
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
Warr at C
SUBROUTINE Carr at W(xin,xout,lbounds,ubounds,nosize,ivarid,&
& info,outflag)
LOGICAL, INTENT(IN) :: info
INTEGER, INTENT(IN) :: ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
832 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid W-node array to the C-nodes.
Reference
Section 8.2
Arguments
xin Source array at the W-nodes
xout Destination array at the C-nodes
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
Warr at U
SUBROUTINE
Warr at U(xin,xout,intdest,lbounds,ubounds,nosize,ivarid,&
& info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1)+1:ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3)-1,nosize) :: xout
23.1. ARRAY INTERPOLATION 833
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid W-node array to the U-nodes.
Reference
Section 8.2
Arguments
xin Source array at the W-nodes
xout Destination array at the U-nodes
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
Warr at UW
SUBROUTINE Warr at UW(xin,xout,intdest,lbounds,ubounds,nosize,&
& ivarid,info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, ivarid, nosize
834 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid W-node array to the UW-nodes.
Reference
Section 8.2
Arguments
xin Source array at the W-nodes
xout Destination array at the UW-nodes
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
info Disables/enables writing of a log info.
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
23.1. ARRAY INTERPOLATION 835
Warr at V
SUBROUTINE
Warr at V(xin,xout,intdest,lbounds,ubounds,nosize,ivarid,&
& info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2)+1:ubounds(2),&
& lbounds(3):ubounds(3)-1,nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid W-node array to the V-nodes.
Reference
Section 8.2
Arguments
xin Source array at the W-nodes
xout Destination array at the V-nodes
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
lbounds Lower bounds of the source array
ubounds Upper bounds of the source array
nosize Fourth dimension of the source array
ivarid Variable key id (used for log info only, zero for undefined)
836 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Warr at VW
SUBROUTINE Warr at VW(xin,xout,intdest,lbounds,ubounds,nosize,&
& ivarid,info,outflag,hregular)
LOGICAL, INTENT(IN) :: info
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: intdest, ivarid, nosize
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
REAL, INTENT(IN), DIMENSION(lbounds(1):ubounds(1),lbounds(2):ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),lbounds(2)+1:ubounds(2),&
& lbounds(3):ubounds(3),nosize) :: xout
File
array interp.f90
Type
Module subroutine
Purpose
Interpolate a section of a model grid W-node array to the VW-nodes.
Reference
Section 8.2
Arguments
xin Source array at the W-nodes
xout Destination array at the VW-nodes
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
23.1. ARRAY INTERPOLATION 837
Cvar at U
FUNCTION Cvar at U(xin,i,j,k,intsrce,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Cvar at U
File
array interp.f90
Type
Module function
Purpose
Interpolate a C-node variable to a U-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
i Lower X-index of the source array
j Y-index of the source array
k Vertical index of the source array
intsrce Selects valid points at the source node
0: all points
838 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Cvar at UV
FUNCTION Cvar at UV(xin,i,j,k,intsrce,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2,2) :: xin
REAL :: Cvar at UV
File
array interp.f90
Type
Module function
Purpose
Interpolate a C-node variable to a UV-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
i Lower X-index of the source array
j Lower Y-index of the source array
23.1. ARRAY INTERPOLATION 839
Cvar at UW
FUNCTION Cvar at UW(xin,i,j,k,intdest,outflag,hregular,&
& vregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular, vregular
INTEGER, INTENT(IN) :: i, intdest, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2,2) :: xin
REAL :: Cvar at UW
File
array interp.f90
Type
Module function
Purpose
Interpolate a C-node variable to a UW-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
i Lower X-index of the source array
j Y-index of the source array
840 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Cvar at V
FUNCTION Cvar at V(xin,i,j,k,intsrce,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Cvar at V
File
array interp.f90
Type
Module function
Purpose
Interpolate a C-node variable to a V-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
23.1. ARRAY INTERPOLATION 841
Cvar at VW
FUNCTION Cvar at VW(xin,i,j,k,intdest,outflag,hregular,&
& vregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular, vregular
INTEGER, INTENT(IN) :: i, intdest, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2,2) :: xin
REAL :: Cvar at VW
File
array interp.f90
Type
Module function
Purpose
Interpolate a C-node variable to a VW-nodal point.
842 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
i X-index of the source array
j Lower Y-index of the source array
k Lower vertical index of the source array
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal.
Otherwise, the type of averaging is selected by iopt arrint hreg.
vregular Flag to select uniform or area averaging in the vertical, if
present. Otherwise, the type of averaging is selected by
iopt arrint vreg.
Cvar at VW Interpolated value at the VW-node destination point
Cvar at W
FUNCTION Cvar at W(xin,i,j,k,outflag,vregular)
LOGICAL, INTENT(IN), OPTIONAL :: vregular
INTEGER, INTENT(IN) :: i, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Cvar at W
File
array interp.f90
Type
Module function
Purpose
Interpolate a C-node variable to a W-nodal point.
23.1. ARRAY INTERPOLATION 843
Reference
Section 8.2
Arguments
xin Source array at the C-nodes
i X-index of the source array
j Y-index of the source array
k Lower vertical index of the source array
outflag Output flag for invalid points, if present. Zero otherwise.
vregular Flag to select uniform or area averaging in the vertical, if
present. Otherwise, the type of averaging is selected by
iopt arrint vreg.
Cvar at W Interpolated value at the W-node destination point
Uvar at C
FUNCTION Uvar at C(xin,i,j,k,intsrce,intdest,outflag)
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Uvar at C
File
array interp.f90
Type
Module function
Purpose
Interpolate a U-node variable to a C-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the U-nodes
i Lower X-index of the source array
j Y-index of the source array
k Vertical index of the source array
844 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Uvar at UV
FUNCTION Uvar at UV(xin,i,j,k,intsrce,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Uvar at UV
File
array interp.f90
Type
Module function
Purpose
Interpolate a U-node variable to a UV-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the U-nodes
i X-index of the source array
j Lower Y-index of the source array
23.1. ARRAY INTERPOLATION 845
Uvar at UW
FUNCTION Uvar at UW(xin,i,j,k,intsrce,intdest,outflag,vregular)
LOGICAL, INTENT(IN), OPTIONAL :: vregular
INTEGER, INTENT(IN) :: i, intdest, intsrce,j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Uvar at UW
File
array interp.f90
Type
Module function
Purpose
Interpolate a U-node variable to a UW-nodal point.
Reference
Section 8.2
846 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Arguments
xin Source array at the U-nodes
i X-index of the source array
j Y-index of the source array
k Lower vertical index of the source array
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
vregular Flag to select uniform or area averaging in the vertical, if
present. Otherwise, the type of averaging is selected by
iopt arrint vreg.
Uvar at UW Interpolated value at the UW-node destination point
Uvar at V
FUNCTION Uvar at V(xin,i,j,k,intsrce,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2,2) :: xin
REAL :: Uvar at V
File
array interp.f90
Type
Module function
23.1. ARRAY INTERPOLATION 847
Purpose
Interpolate a U-node variable to a V-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the U-nodes
i Lower X-index of the source array
j Lower Y-index of the source array
k Vertical index of the source array
intsrce Selects valid points at the source node
0: all points!
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
Uvar at V Interpolated value at the V-node destination point
Uvar at W
FUNCTION Uvar at W(xin,i,j,k,intsrce,outflag,vregular)
LOGICAL, INTENT(IN), OPTIONAL :: vregular
INTEGER, INTENT(IN) :: i, intsrce, j, k
848 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
UVvar at C
FUNCTION UVvar at C(xin,i,j,k,intsrce,intdest,outflag)
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2,2) :: xin
REAL :: UVvar at C
23.1. ARRAY INTERPOLATION 849
File
array interp.f90
Type
Module function
Purpose
Interpolate a UV-node variable to a C-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the U-nodes
i Lower X-index of the source array
j Lower Y-index of the source array
k Vertical index of the source array
intsrce Selects valid points at the source node
0: all points
1: wet points only
intdest Selects valid points at the destination node
0: all points
1: wet points only
outflag Output flag for invalid points, if present. Zero otherwise.
UVvar at C Interpolated value at the C-node destination point
UVvar at U
FUNCTION UVvar at U(xin,i,j,k,intsrce,intdest,outflag)
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: UVvar at U
File
array interp.f90
Type
Module function
850 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Interpolate a UV-node variable to a U-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the UV-nodes
i X-index of the source array
j Lower Y-index of the source array
k Vertical index of the source array
intsrce Selects valid points at the source node
0: all points
1: interior points and open boundaries only
2: interior points and UV-node open boundaries only
intdest Selects valid points at the destination node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
UVvar at U Interpolated value at the U-node destination point
UVvar at V
FUNCTION UVvar at V(xin,i,j,k,intsrce,intdest,outflag)
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: UVvar at V
File
array interp.f90
Type
Module function
23.1. ARRAY INTERPOLATION 851
Purpose
Interpolate a UV-node variable to a V-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the UV-nodes
i Lower X-index of the source array
j Y-index of the source array
k Vertical index of the source array
intsrce Selects valid points at the source node
0: all points
1: interior points and open boundaries only
2: interior points and UV-node open boundaries only
intdest Selects valid points at the source node
0: all points
1: coastal boundaries, interior points and open
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
UVvar at V Interpolated value at the V-node destination point
UWvar at U
FUNCTION UWvar at U(xin,i,j,k,intsrce,intdest,outflag)
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: UWvar at U
File
array interp.f90
Type
Module function
852 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Interpolate a UW-node variable to a U-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the UW-nodes
i X-index of the source array
j Y-index of the source array
k Lower vertical index of the source array
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
UWvar at U Interpolated value at the U-node destination point
UWvar at W
FUNCTION UWvar at W(xin,i,j,k,intsrce,outflag)
INTEGER, INTENT(IN) :: i, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: UWvar at W
File
array interp.f90
23.1. ARRAY INTERPOLATION 853
Type
Module function
Purpose
Interpolate a UW-node variable to a W-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the UW-nodes
i Lower X-index of the source array
j Y-index of the source array
k Vertical index of the source array
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
UWvar at W Interpolated value at the W-node destination point
Vvar at C
FUNCTION Vvar at C(xin,i,j,k,intsrce,intdest,outflag)
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Vvar at C
File
array interp.f90
Type
Module function
Purpose
Interpolate a V-node variable to a C-nodal point.
854 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Reference
Section 8.2
Arguments
xin Source array at the V-nodes
i X-index of the source array
j Lower Y-index of the source array
k Vertical index of the source array
intsrce Selects valid points at the source node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
0: all points
1: wet points only
outflag Output flag for invalid points, if present. Zero otherwise.
Vvar at C Interpolated value at the C-node destination point
Vvar at U
FUNCTION Vvar at U(xin,i,j,k,intsrce,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2,2) :: xin
REAL :: Vvar at U
File
array interp.f90
Type
Module function
Purpose
Interpolate a V-node variable to a U-nodal point.
23.1. ARRAY INTERPOLATION 855
Reference
Section 8.2
Arguments
xin Source array at the V-nodes
i Lower X-index of the source array
j Lower Y-index of the source array
k Vertical index of the source array
intsrce Selects valid points at the source node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
0: all points
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
Vvar at U Interpolated value at the U-node destination point
Vvar at UV
FUNCTION Vvar at UV(xin,i,j,k,intsrce,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Vvar at UV
856 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
array interp.f90
Type
Module function
Purpose
Interpolate a V-node variable to a UV-nodal point.
Reference
Section 8.2
Arguments
Vvar at VW
FUNCTION Vvar at VW(xin,i,j,k,intsrce,intdest,outflag,vregular)
LOGICAL, INTENT(IN), OPTIONAL :: vregular
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Vvar at VW
File
array interp.f90
Type
Module function
Purpose
Interpolate a V-node variable to a VW-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the V-nodes
i X-index of the source array
j Y-index of the source array
k Lower vertical index of the source array
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
858 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Vvar at W
FUNCTION Vvar at W(xin,i,j,k,intsrce,outflag,vregular)
LOGICAL, INTENT(IN), OPTIONAL :: vregular
INTEGER, INTENT(IN) :: i, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2,2) :: xin
REAL :: Vvar at W
File
array interp.f90
Type
Module function
Purpose
Interpolate a V-node variable to a W-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the V-nodes
i X-index of the source array
j Lower Y-index of the source array
k Lower vertical index of the source array
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
23.1. ARRAY INTERPOLATION 859
VWvar at V
FUNCTION VWvar at V(xin,i,j,k,intsrce,intdest,outflag)
INTEGER, INTENT(IN) :: i, intdest, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: VWvar at V
File
array interp.f90
Type
Module function
Purpose
Interpolate a VW-node variable to a V-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the VW-nodes
i X-index of the source array
j Y-index of the source array
k Lower vertical index of the source array
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
860 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
VWvar at W
FUNCTION VWvar at W(xin,i,j,k,intsrce,outflag)
INTEGER, INTENT(IN) :: i, intsrce, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: VWvar at W
File
array interp.f90
Type
Module function
Purpose
Interpolate a VW-node variable to a W-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the VW-nodes
i X-index of the source array
j Lower Y-index of the source array
k Vertical index of the source array
intsrce Selects valid points at the source node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
VWvar at W Interpolated value at the W-node destination point
23.1. ARRAY INTERPOLATION 861
Wvar at C
FUNCTION Wvar at C(xin,i,j,outflag)
INTEGER, INTENT(IN) :: i, j
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Wvar at C
File
array interp.f90
Type
Module function
Purpose
Interpolate a W-node variable to a C-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the W-nodes
i X-index of the source array
j Y-index of the source array
outflag Output flag for invalid points, if present. Zero otherwise.
Wvar at C Interpolated value at the C-node destination point
Wvar at U
FUNCTION Wvar at U(xin,i,j,k,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2,2) :: xin
REAL :: Wvar at U
File
array interp.f90
Type
Module function
862 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Interpolate a W-node variable to a U-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the W-nodes
i Lower X-index of the source array
j Y-index of the source array
k Lower vertical index of the source array
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
Wvar at U Interpolated value at the U-node destination point
Wvar at UW
FUNCTION Wvar at UW(xin,i,j,k,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Wvar at UW
File
array interp.f90
Type
Module function
23.1. ARRAY INTERPOLATION 863
Purpose
Interpolate a W-node variable to a UW-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the W-nodes
i Lower X-index of the source array
j Y-index of the source array
k Vertical index of the source array
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
Wvar at UW Interpolated value at the UW-node destination point
Wvar at V
FUNCTION Wvar at V(xin,i,j,k,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2,2) :: xin
REAL :: Wvar at V
File
array interp.f90
Type
Module function
864 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Interpolate a W-node variable to a V-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the W-nodes
i X-index of the source array
j Lower Y-index of the source array
k Lower vertical index of the source array
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
Wvar at V Interpolated value at the V-node destination point
Wvar at VW
FUNCTION Wvar at VW(xin,i,j,k,intdest,outflag,hregular)
LOGICAL, INTENT(IN), OPTIONAL :: hregular
INTEGER, INTENT(IN) :: i, intdest, j, k
REAL, INTENT(IN), OPTIONAL :: outflag
REAL, INTENT(IN), DIMENSION(2) :: xin
REAL :: Wvar at VW
File
array interp.f90
Type
Module function
23.2. NETCDF ROUTINE LIBRARY 865
Purpose
Interpolate a W-node variable to a VW-nodal point.
Reference
Section 8.2
Arguments
xin Source array at the W-nodes
i X-index of the source array
j Lower Y-index of the source array
k Vertical index of the source array
intdest Selects valid points at the destination node
1: coastal boundaries, interior points and open boundaries
only
2: interior points only
3: interior points and open boundaries only
4: coastal boundaries and interior points only
outflag Output flag for invalid points, if present. Zero otherwise.
hregular Flag to select uniform or area averaging in the horizontal,
if present. Otherwise, the type of averaging is selected by
iopt arrint hreg.
Wvar at VW Interpolated value at the VW-node destination point
cf90 abort
SUBROUTINE cf90 abort(ncid)
INTEGER, INTENT(IN) :: ncid
866 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
cf90 routines.F90
Type
Module subroutine
Purpose
Aborts a netCDF routine call in case an error has been detected. This
will be followed by an abortion of the program.
Arguments
ncid netCDF file ID
netcdf call
NF90 abort
cf90 close
SUBROUTINE cf90 close(ncid)
INTEGER, INTENT(IN) :: ncid
File
cf90 routines.F90
Type
Module subroutine
Purpose
Closes an open netCDF data file.
Arguments
ncid netCDF file ID
netcdf call
NF90 close
File
cf90 routines.F90
23.2. NETCDF ROUTINE LIBRARY 867
Type
Module subroutine
Purpose
Copies the attribute of variable in a netCDF file to the attribute of
another variable attribute in another file.
Arguments
ncid in netCDF ID of the source file
varid in netCDF variable ID in the source file
name Atrribute name
ncid out netCDF ID of destination file
varid out netCDF variable ID in the destination file
netcdf call
NF90 copy att
cf90 create
SUBROUTINE cf90 create(path,cmode,ncid,initialsize,chunksize)
CHARACTER (LEN=*), INTENT(IN) :: path
INTEGER, INTENT(IN) :: cmode
INTEGER, INTENT(OUT) :: ncid
INTEGER, INTENT(IN), OPTIONAL :: initialsize
INTEGER, INTENT(INOUT), OPTIONAL :: chunksize
File
cf90 routines.F90
Type
Module subroutine
Purpose
Opens a new netCDF file.
Reference
NetCDF user manual (Pincus & Rew, 2008)
Arguments
path Name of the new netCDF file
cmode Creation mode
868 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
cf90 routines.F90
Type
Module subroutine
Purpose
Adds a new dimension to an open netCDF file.
Arguments
ncid netCDF file ID
name Name of the new dimension
len Value (length) of the new dimension
dimid Returned netCDF ID of the new dimension.
netcdf call
NF90 def dim
File
cf90 routines.F90
23.2. NETCDF ROUTINE LIBRARY 869
Type
Module subroutine
Purpose
Adds a new variable to an open netCDF file.
Arguments
ncid netCDF file ID
name Name of the new variable
xtype Variables’s netCDF data type
dimids The netCDF IDs of the variable’s dimensions.
varid Returned netCDF variable ID
netcdf call
NF90 def var
File
cf90 routines.F90
Type
Module subroutine
Purpose
Deletes a attribute from a netCDF file.
Arguments
ncid netCDF file ID
varid netCDF ID of the attribute’s variable, NF GLOBAL (global NF90)
for a global attribute
name Name of the attribute
netcdf call
NF90 del att
870 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
cf90 enddef
SUBROUTINE cf90 enddef(ncid,h minfree,v align,v minfree,r align)
INTEGER, INTENT(IN) :: ncid
INTEGER, INTENT(IN), OPTIONAL :: h minfree, r align, v align, v minfree
File
cf90 routines.F90
Type
Module subroutine
Purpose
Take an open netCDF dataset out of define mode.
Reference
NetCDF user manual (Pincus & Rew, 2008)
Arguments
ncid netCDF file ID
h minfree Size in bytes of the pad at the end of the header
v align Alignment of the start of the data section for fixed size
variables
v minfree Size in bytes of the pad at the end of the data section for
fixed size variables
r align Alignment of the start of the data section in case of an
unlimited dimension
netcdf call
NF90 enddef
cf90 error
SUBROUTINE cf90 error(cf90name)
CHARACTER (LEN=*), INTENT(IN) :: cf90name
File
cf90 routines.F90
Type
Module subroutine
23.2. NETCDF ROUTINE LIBRARY 871
Purpose
Report an error in a netCDF routine.
Arguments
cf90name Name of the netCDF routine where the error occurred.
netcdf call
NF90 strerror
File
cf90 routines.F90
Type
Generic module subroutine
Purpose
Get the string value of a scalar or vector character-valued attribute.
Arguments
ncid netCDF file ID
varid netCDF ID of the attribute’s variable, NF GLOBAL
(global NF90) for a global attribute
name Name of the attribute
lenstr Length of the scalar or vector string data
chardat Attribute values
Non-generic versions
cf90 get att chars 0d Scalar string values
cf90 get att chars 1d Vector string values
netcdf call
NF90 get att
872 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
cf90 routines.F90
Type
Generic module subroutine
Purpose
Read the numeric value of a scalar or vector attribute.
Arguments
ncid netCDF file ID
varid Id of the attribute’s variable, NF GLOBAL (global NF90)
for a global attribute
name Name of the attribute
values Attribute values
Non-generic versions
cf90 get att int 0d Scalar integer values
cf90 get att int 1d Vector integer values
cf90 get att real 0d Scalar real values
cf90 get att real 1d Vector real values
netcdf call
NF90 get att
File
cf90 routines.F90
23.2. NETCDF ROUTINE LIBRARY 873
Type
Module subroutine
Purpose
Read a string variable from an open netCDF file.
Arguments
ncid netCDF file ID
varid netCDF ID of the attribute’s variable, NF GLOBAL
(global NF90) for a global attribute
chardat Returned string value
timerec Time record number
netcdf call
NF90 get var
File
cf90 routines.F90
Type
Generic module subroutine
Purpose
Read an integer or real scalar or array (upto rank 4) variable from an
open netCDF file.
Arguments
ncid netCDF file ID
varid Variable ID
values Returned integer or real scalar of array data
timerec Time record number
874 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
The size of the optional start, count, stride arguments must be equal to
rank of the returned data array.
Non-generic versions
cf90 get var int 0d Scalar integer values. The optional arguments are
not available.
cf90 get var int 1d Vector integer values
cf90 get var int 2d 2-D array of integer values
cf90 get var int 3d 3-D array of integer values
cf90 get var int 4d 4-D array of integer values
cf90 get var real 0d Scalar real values. The optional arguments are not
available.
cf90 get var real 1d Vector real values
cf90 get var real 2d 2-D array of real values
cf90 get var real 3d 3-D array of real values
cf90 get var real 4d 4-D array of real values
netcdf call
NF90 get var
File
cf90 routines.F90
Type
Module subroutine
Purpose
Returns the name of an attribute given its variable ID and number.
Arguments
23.2. NETCDF ROUTINE LIBRARY 875
netcdf call
NF90 inq attname
File
cf90 routines.F90
Type
Module subroutine
Purpose
Returns the dimension ID given the dimension’s name.
Arguments
ncid netCDF file ID
name Dimension name
dimid Returned netCDF dimension ID
netcdf call
NF90 inq dimid
File
cf90 routines.F90
Type
Module function
876 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Returns the netCDF library version.
netcdf call
NF90 inq libvers
File
cf90 routines.F90
Type
Module subroutine
Purpose
Returns the ID of a netCDF variable given its name.
Arguments
ncid netCDF file ID
name Variable name
varid Returned netCDF variable ID
netcdf call
NF90 inq varid
cf90 inquire
SUBROUTINE cf90 inquire(ncid,ndimensions,nvariables,&
& nattributes,unlimiteddimid)
INTEGER, INTENT(IN) :: ncid
INTEGER, INTENT(OUT), OPTIONAL :: nattributes, ndimensions,&
& nvariables, unlimiteddimid
File
cf90 routines.F90
Type
Module subroutine
23.2. NETCDF ROUTINE LIBRARY 877
Purpose
Returns information about an open netCDF file given its netCDF file
ID.
Arguments
ncid netCDF file ID
ndimensions Returned number of dimensions
nvariables Returned number of variables
nattributes Returned number of global attributes
unlimiteddimid Returned netCDF ID of the unlimited dimension (if any)
netcdf call
NF90 inquire
File
cf90 routines.F90
Type
Module subroutine
Purpose
Returns information about a netCDF attribute.
Arguments
ncid netCDF file ID
varid netCDF ID of the associated variable
name Attribute name
xtype Returned netCDF data type of the attribute
len Returned number of values stored in the attribute
attnum Returned attribute number
netcdf call
NF90 inquire attribute
878 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
cf90 routines.F90
Type
Module subroutine
Purpose
Returns information about a netCDF dimension.
Arguments
ncid netCDF file ID
dimid netCDF dimension ID
name Returned dimension name
len Returned dimension length
netcdf call
NF90 inquire dimension
File
cf90 routines.F90
Type
Module subroutine
Purpose
Returns information about a netCDF variable.
23.2. NETCDF ROUTINE LIBRARY 879
Arguments
ncid netCDF file ID
varid netCDF variable ID
name Returned variable name
xtype Returned netCDF data type
ndims Returned variable rank
dimids Returned netCDF IDs of the variable’s dimensions
natts Returned number of associated attributes
netcdf call
NF90 inquire variable
cf90 open
SUBROUTINE cf90 open(path,mode,ncid,chunksize)
CHARACTER (LEN=*), INTENT(IN) :: path
INTEGER, INTENT(IN) :: mode
INTEGER, INTENT(OUT) :: ncid
INTEGER, INTENT(INOUT), OPTIONAL :: chunksize
File
cf90 routines.F90
Type
Module subroutine
Purpose
Opens an existing netCDF dataset.
Reference
NetCDF user manual (Pincus & Rew, 2008)
Arguments
path Name of the netCDF file
mode Access mode
ncid netCDF file ID
chunksize Chunksize
netcdf call
NF90 open
880 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
cf90 routines.F90
Type
Generic module subroutine
Purpose
Write or change the value of a scalar or vector character-valued at-
tribute.
Arguments
ncid netCDF file ID
varid netCDF ID of the attribute’s variable, NF GLOBAL
(global NF90) for a global attribute
name Name of the attribute
lenstr Length of the scalar or vector string data
chardat Attribute values
Non-generic versions
cf90 put att chars 0d Scalar string values
cf90 put att chars 1d Vector string values
netcdf call
NF90 put att
File
cf90 routines.F90
23.2. NETCDF ROUTINE LIBRARY 881
Type
Generic module subroutine
Purpose
Write the numeric value of a scalar or vector attribute to an open
netCDF file.
Arguments
ncid netCDF file ID
varid ID of the attribute’s variable, NF GLOBAL
(global NF90) for a global attribute
name Name of the attribute
values Attribute values
Non-generic versions
cf90 put att int 0d Scalar integer values
cf90 put att int 1d Vector integer values
cf90 put att real 0d Scalar real values
cf90 put att real 1d Vector real values
netcdf call
NF90 put att
File
cf90 routines.F90
Type
Module subroutine
Purpose
Write a string variable to an open netCDF file.
Arguments
ncid netCDF file ID
882 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
varid Variable ID
chardat Character output data
timerec Time record number
netcdf call
NF90 put var
File
cf90 routines.F90
Type
Generic module subroutine
Purpose
Write an integer or real scalar or array (upto rank 4) variable to an
open netCDF file.
Arguments
ncid netCDF file ID
varid Variable ID
values Integer or real, scalar or array output data
timerec Time record number
start Vector of spatial start indices
count Number of data along each array dimension
stride Sampling interval along each spatial direction
The size of the optional start, count, stride arguments must be equal to
rank of the output data array.
Non-generic versions
cf90 put var int 0d Scalar integer values. The optional arguments are
not available.
23.2. NETCDF ROUTINE LIBRARY 883
netcdf call
NF90 put var
cf90 redef
SUBROUTINE cf90 redef(ncid)
INTEGER, INTENT(IN) :: ncid
File
cf90 routines.F90
Type
Module subroutine
Purpose
Puts an open netCDF file in define mode.
Arguments
ncid netCDF file ID
netcdf call
NF90 redef
File
cf90 routines.F90
Type
Module subroutine
Purpose
Renames an existing attribute.
Arguments
ncid netCDF file ID
varid netCDF ID of the associated variable or NF GLOBAL
(global NF90) for a global attribute
curname current name of the attribute
newname new name of the attribute
netcdf call
NF90 rename att
File
cf90 routines.F90
Type
Module subroutine
Purpose
Renames an existing dimension.
Arguments
ncid netCDF file ID
dimid the dimension’s netCDF ID
name new dimension name
netcdf call
NF90 rename dim
23.2. NETCDF ROUTINE LIBRARY 885
cf90 sync
SUBROUTINE cf90 sync(ncid)
INTEGER, INTENT(IN) :: ncid
File
cf90 routines.F90
Type
Module subroutine
Purpose
Resets the fill mode for a netCDF dataset open for writing.
Arguments
netcdf call
NF90 sync
File
check model.f90
Type
Module subroutine
Purpose
Check model grid arrays, as e.g. defined in usrdef grid.
23.3. CHECKING OF MODEL SETUP 887
File
check model.f90
Type
Module subroutine
Purpose
Check an derived type array with the horizontal relative coordinates of
a number of data points with respect to the model grid.
Arguments
hcoords Derived type array containing the relative coordinates
nhdat Number of horizontal data locations.
varname Name of the derived type array
File
check model.f90
Type
Module subroutine
Purpose
Check initial condition arrays, as e.g. defined in usrdef phsics.
File
check model.f90
888 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module subroutine
Purpose
Check the attributes of model forcing files, as e.g. defined in usrdef mod params.
File
check model.f90
Type
Module subroutine
Purpose
Check the attributes of user-defined output grids.
Arguments
outgpars Derived type array of output grid attributes
arrname Name of the derived type array
maxstats Maximum number of output stations (as given by the user-
defined parameter nostatstsr, nostatsavr or nostatsanal)
check partition
SUBROUTINE check partition
File
check model.f90
Type
Module subroutine
Purpose
Check whether all wet and open boundary points are inside the domain
of a local process.
check statlocs
SUBROUTINE check statlocs(outlocs,arrname)
CHARACTER (LEN=*), INTENT(IN) :: arrname
TYPE (StationLocs), INTENT(IN), DIMENSION(:) :: outlocs
890 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
check model.f90
Type
Module subroutine
Purpose
Check whether the stations locations are inside the computational do-
main.
Arguments
outlocs Derived type array of output station attributes
arrname Name of the derived type array
File
check model.f90
Type
Generic module subroutine
Purpose
Check the relative coordinates of model grid points with respect to an
external data grid.
Arguments
surfgrid Derived type array containing the relative coordinates
n1dat X-dimension of the external data grid
n2dat Y-dimension of the external data grid
varname Name of the derived type array
Non-generic versions
check surface grid 1d Vector array
check surface grid 2d Two-dimensional array
23.4. CIF UTILITY ROUTINES 891
check variables
SUBROUTINE check variables(varatts,arrname)
CHARACTER (LEN=*), INTENT(IN) :: arrname
TYPE (VariableAtts), INTENT(IN), DIMENSION(:) :: varatts
File
check model.f90
Type
Module subroutine
Purpose
Check a derived type vector array with variable attributes.
Arguments
varatts Derived type array of variable attributes
arrname Name of the derived type array
File
cif routines.f90
Type
Module subroutine
Purpose
Check whether the number of parameters on the input line of a CIF is
not lower than a minimum limit.
Arguments
iddesc Key id of the CIF
novars Number of data values read from a line of the CIF
892 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
cif routines.f90
Type
Module subroutine
Purpose
Convert data values from the CIF to the components of a derived type
variable of type OutGridParams, representing a user-defined output grid.
Arguments
cvals CIF data in string format
gridpars Returned components in the appropriate numerical or non-
numerical format
iddesc Key id of the CIF
lvar Number of the variable on the CIF input line
File
cif routines.f90
Type
Module subroutine
Purpose
Convert data values from the CIF to the components of a derived type
variable of type FileParams, representing a model forcing file.
Arguments
cvals CIF data in string format
filepars Returned components in the appropriate numerical or non-
numerical format
iddesc Key id of the CIF
lvar Number of the variable on the CIF input line
894 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
cif routines.f90
Type
Module subroutine
Purpose
Convert data values from the CIF to the components of a derived type
variable of type FileParams, representing a user output file.
Arguments
cvals CIF data in string format
filepars Returned components in the appropriate numerical or non-
numerical format
iddesc Key id of the CIF
lvar Number of the variable on the CIF input line
File
cif routines.f90
Type
Module subroutine
Purpose
Convert data values from the CIF to the components of a derived type
variable of type StationLocs, representing output data stations.
23.4. CIF UTILITY ROUTINES 895
Arguments
cvals CIF data in string format
statlocs Returned components in the appropriate numerical or non-
numerical format
iddesc Key id of the CIF
lvar Number of the variable on the CIF input line
File
cif routines.f90
Type
Module subroutine
Purpose
Convert data values from the CIF to the components of a derived type
variable of type GridParams, representing a surface grid.
Arguments
cvals CIF data in string format
surfgrd Returned components in the appropriate numerical or non-
numerical format
iddesc Key id of the CIF
lvar Number of the variable on the CIF input line
File
cif routines.f90
Type
Module subroutine
Purpose
Convert data values from the CIF to the components of a derived type
variable of type VariableAtts.
Arguments
cvals CIF data in string format
varatts Returned components in the appropriate numerical or non-
numerical format
iddesc Key id of the CIF
lvar Number of the variable on the CIF input line
conv to chars
SUBROUTINE conv to chars(string,cifdat)
CHARACTER (LEN=*), INTENT(OUT) :: string
INTEGER, LOGICAL or REAL, [DIMENSION(:),] INTENT(IN) :: cifdat
File
cif routines.f90
Type
Generic module subroutine
Purpose
Convert a INTEGER, LOGICAL or REAL scalar or vector model variable
to a character string.
Arguments
string Returned data string
cifdat Scalar or vector data on input
Non-generic versions
conv to chars int 0d Integer scalar
conv to chars int 1d Integer vector
conv to chars log 0d Logical scalar
23.4. CIF UTILITY ROUTINES 897
File
cif routines.f90
Type
Module subroutine
Purpose
Convert the attributes of a user-defined output grid to a vector of string
data.
Arguments
cvals Returned data in string format
gridpars Attributes of the output grid
File
cif routines.f90
Type
Module subroutine
Purpose
Convert the attributes of a model forcing file to a vector of string data.
Arguments
cvals Returned data in string format
filepars Attributes of the forcing file
898 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
cif routines.f90
Type
Module subroutine
Purpose
Convert the attributes of a usder-defined output file to a vector of string
data.
Arguments
cvals Returned data in string format
filepars Attributes of the output file
File
cif routines.f90
Type
Module subroutine
Purpose
Convert the attributes of a user-defined output station to a vector of
string data.
Arguments
cvals Returned data in string format
statlocs Attributes of the output station
23.4. CIF UTILITY ROUTINES 899
File
cif routines.f90
Type
Module subroutine
Purpose
Convert the attributes of a surface grid to a vector of string data.
Arguments
File
cif routines.f90
Type
Module subroutine
Purpose
Convert the attributes of a model variable to a vector of string data.
Arguments
File
cif routines.f90
Type
Module subroutine
Purpose
Write one or more string data to a CIF
Arguments
iddesc Key id of the CIF
cvals Data value(s) in string format
cname Name of the data variable(s)
File
comms MPI.F90
902 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module subroutine
Purpose
Gather (collect) integer data on all processes in communicator comm.
Arguments
sendbuf Starting address of send buffer
count Number of data in send and receive buffers
nprocs Number of processes
recvbuf Starting address of receive buffer
comm Communicator id
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI allgather
File
comms MPI.F90
Type
Module subroutine
Purpose
Gather (collect) logical data on all processes in communicator comm.
Arguments
sendbuf Starting address of send buffer
count Number of data in send and receive buffers
nprocs Number of processes
recvbuf Starting address of receive buffer
comm Communicator id
23.5. MPI ROUTINE LIBRARY 903
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI allgather
File
comms MPI.F90
Type
Module subroutine
Purpose
Gather (collect) real data on all processes in communicator comm.
Arguments
sendbuf Starting address of send buffer
count Number of data in send and receive buffers
nprocs Number of processes
recvbuf Starting address of receive buffer
comm Communicator id
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI allgather
comms barrier
SUBROUTINE comms barrier(comm)
INTEGER, INTENT(IN) :: comm
File
comms MPI.F90
904 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module subroutine
Purpose
Synchronise processes in communicator comm.
Arguments
comm Communicator id
MPI call
MPI barrier
File
comms MPI.F90
Type
Module subroutine
Purpose
Broadcast (copy) character data from the root process to all other pro-
cesses in communicator comm.
Arguments
MPI call
MPI bcast
23.5. MPI ROUTINE LIBRARY 905
File
comms MPI.F90
Type
Module subroutine
Purpose
Broadcast (copy) integer data from the root process to all other pro-
cesses in communicator comm.
Arguments
ibuf Starting address of buffer
count Number of data in send and receive buffers
root Process id of root process
comm Communicator id
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI bcast
File
comms MPI.F90
Type
Module subroutine
Purpose
Broadcast (copy) logical data from the root process to all other pro-
cesses in communicator comm.
Arguments
906 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
MPI call
MPI bcast
File
comms MPI.F90
Type
Module subroutine
Purpose
Broadcast (copy) real data from the root process to all other processes
in communicator comm.
Arguments
rbuf Starting address of buffer
count Number of data in send and receive buffers
root Process id of root process
comm Communicator id
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI bcast
File
comms MPI.F90
Type
Module subroutine
Purpose
Deallocates (frees) communicator comm.
Arguments
comm Communicator id
MPI call
MPI comm free
File
comms MPI.F90
Type
Module subroutine
Purpose
Returns the rank (process id) of the calling process.
Arguments
comm Communicator id
rank Returned rank
MPI call
MPI comm rank
File
comms MPI.F90
Type
Module subroutine
Purpose
Returns the number of processes in communicator comm.
Arguments
comm Communicator id
rank Returned number of processes
MPI call
MPI comm size
File
comms MPI.F90
Type
Module subroutine
Purpose
Create a new communicator newcomm by partinioning of communicator
comm.
Arguments
comm Id of existing communicator
color Control parameter for subset assignment
key Control parameter for rank assignment
newcomm Id of new communicator
MPI call
MPI comm split
23.5. MPI ROUTINE LIBRARY 909
File
comms MPI.F90
Type
Module subroutine
Purpose
Create a Cartesian (parallel) grid of dimension ndims and a total of
nnodes nodes and store the domain dimensions in dims.
Arguments
ndims Dimension of the Cartesian grid
nnodes Number of nodes for creating the grid
dims Vector with the number of nodes (processes) per grid di-
rection
MPI call
MPI dims create
comms errhandler
SUBROUTINE comms errhandler(comm)
INTEGER, INTENT(IN) :: comm
File
comms MPI.F90
Type
Module subroutine
Purpose
Sets the error handler to MPI errors return.
Arguments
comm Communicator id
MPI calls
MPI errhandler free, MPI errhandler get, MPI errhandler set
910 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
comms finalize
SUBROUTINE comms finalize
File
comms MPI.F90
Type
Module subroutine
Purpose
Finalise MPI.
MPI call
MPI finalize
comms initialise
SUBROUTINE comms initialise
File
comms MPI.F90
Type
Module subroutine
Purpose
Initialise MPI.
MPI calls
MPI init, MPI initialized
File
comms MPI.F90
Type
Module subroutine
23.5. MPI ROUTINE LIBRARY 911
Purpose
Performs a non-blocking receive of character data from process source.
Arguments
cbuf Starting address of receive buffer
count Number of data in receive buffer
source Rank of source process
tag Message tag
comm Communicator id
request Communication request
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI irecv
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a non-blocking receive of integer data from process source.
Arguments
ibuf Starting address of receive buffer
count Number of data in receive buffer
source Rank of source process
tag Message tag
comm Communicator id
request Communication request
ivarid Variable key id (used for log info only, zero for undefined)
912 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
MPI call
MPI irecv
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a non-blocking receive of logical data from process source.
Arguments
lbuf Starting address of receive buffer
count Number of data in receive buffer
source Rank of source process
tag Message tag
comm Communicator id
request Communication request
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI irecv
File
comms MPI.F90
23.5. MPI ROUTINE LIBRARY 913
Type
Module subroutine
Purpose
Performs a non-blocking receive of real data from process source.
Arguments
rbuf Starting address of receive buffer
count Number of data in receive buffer
source Rank of source process
tag Message tag
comm Communicator id
request Communication request
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI irecv
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a non-blocking send of character data to process dest.
Arguments
cbuf Starting address of send buffer
count Number of data in send buffer
dest Rank of destination process
tag Message tag
914 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
comm Communicator id
mode Selects type of send
1: standard send
2: synchronous send
request Communication request
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI isend, MPI issend
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a non-blocking send of integer data to process dest.
Arguments
ibuf Starting address of send buffer
count Number of data in send buffer
dest Rank of destination process
tag Message tag
comm Communicator id
mode Selects type of send
1: standard send
2: synchronous send
request Communication request
ivarid Variable key id (used for log info only, zero for undefined)
23.5. MPI ROUTINE LIBRARY 915
MPI calls
MPI isend, MPI issend
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a non-blocking send of logical data to process dest.
Arguments
lbuf Starting address of send buffer
count Number of data in send buffer
dest Rank of destination process
tag Message tag
comm Communicator id
mode Selects type of send
1: standard send
2: synchronous send
request Communication request
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI isend, MPI issend
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a non-blocking send of real data to process dest.
Arguments
rbuf Starting address of send buffer
count Number of data in send buffer
dest Rank of destination process
tag Message tag
comm Communicator id
mode Selects type of send
1: standard send
2: synchronous send
request Communication request
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI isend, MPI issend
File
comms MPI.F90
Type
Module subroutine
23.5. MPI ROUTINE LIBRARY 917
Purpose
Performs a blocking receive of character data from process source.
Arguments
cbuf Starting address of receive buffer
count Number of data in receive buffer
source Rank of source process
tag Message tag
comm Communicator id
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI recv
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a blocking receive of integer data from process source.
Arguments
ibuf Starting address of receive buffer
count Number of data in receive buffer
source Rank of source process
tag Message tag
comm Communicator id
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI recv
918 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a blocking receive of logical data from process source.
Arguments
lbuf Starting address of receive buffer
count Number of data in receive buffer
source Rank of source process
tag Message tag
comm Communicator id
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI recv
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a blocking receive of real data from process source.
Arguments
23.5. MPI ROUTINE LIBRARY 919
MPI call
MPI recv
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a global reduction operation on integer data.
Arguments
sendbuf Address of send buffer
recvbuf Address of receive buffer
iop Type of reduce operation
1 : maximum (MPI max)
2 : minimum (MPI min)
3 : sum (MPI sum)
4 : product (MPI prod)
6 : logical and (MPI band)
8 : bit-wise or (MPI bor)
10: bot-wise xor (MPI bxor)
920 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
comm Communicator id
root Rank of root process to which the result is returned, if
present. Otherwise the result is returned to all processes.
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI reduce, MPI allreduce
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a global reduction operation on pairs of integer data.
Arguments
sendbuf Address of send buffer
recvbuf Address of receive buffer
iop Type of reduce operation
11: maximum value and location (MPI maxloc)
12: minimum value and location (MPI minloc)
comm Communicator id
root Rank of root process to which the result is returned, if
present. Otherwise the result is returned to all processes.
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI reduce, MPI allreduce
23.5. MPI ROUTINE LIBRARY 921
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a global reduction operation on logical data.
Arguments
sendbuf Address of send buffer
recvbuf Address of receive buffer
iop Type of reduce operation
5: logical and (MPI land)
7: logical or (MPI lor)
9: logical xor (MPI lxor)
comm Communicator id
root Rank of root process to which the result is returned, if
present. Otherwise the result is returned to all processes.
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI reduce, MPI allreduce
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a global reduction operation on real data.
Arguments
sendbuf Address of send buffer
recvbuf Address of receive buffer
iop Type of reduce operation
1: maximum (MPI max)
2: minimum (MPI min)
3: sum (MPI sum)
4: product (MPI prod)
comm Communicator id
root Rank of root process to which the result is returned, if
present. Otherwise the result is returned to all processes.
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI reduce, MPI allreduce
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a global reduction operation on pairs of real data.
23.5. MPI ROUTINE LIBRARY 923
Arguments
sendbuf Address of send buffer
recvbuf Address of receive buffer
iop Type of reduce operation
11: maximum value and location (MPI maxloc)
12: minimum value and location (MPI minloc)
comm Communicator id
root Rank of root process to which the result is returned, if
present. Otherwise the result is returned to all processes.
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI allreduce, MPI reduce
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a blocking send of character data to process dest.
Arguments
cbuf Starting address of send buffer
count Number of data in send buffer
dest Rank of destination process
tag Message tag
comm Communicator id
mode Selects type of send
1: standard send
2: synchronous send
924 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI send, MPI ssend
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a blocking send of integer data to process dest.
Arguments
ibuf Starting address of send buffer
count Number of data in send buffer
dest Rank of destination process
tag Message tag
comm Communicator id
mode Selects type of send
1: standard send
2: synchronous send
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI send, MPI ssend
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a blocking send of logical data to process dest.
Arguments
lbuf Starting address of send buffer
count Number of data in send buffer
dest Rank of destination process
tag Message tag
comm Communicator id
mode Selects type of send
1: standard send
2: synchronous send
ivarid Variable key id (used for log info only, zero for undefined)
MPI calls
MPI send, MPI ssend
File
comms MPI.F90
Type
Module subroutine
Purpose
Performs a blocking send of real data to process dest.
Arguments
rbuf Starting address of send buffer
926 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
MPI calls
MPI send, MPI ssend
File
comms MPI.F90
Type
Module subroutine
Purpose
Combines a send and a receive operation on character data.
Arguments
sendbuf Starting address of send buffer
sendcount Number of data in send buffer
dest Rank of destination process
sendtag Message tag of send operation
recvbuf Starting address of receive buffer
recvcount Number of data in receive buffer
23.5. MPI ROUTINE LIBRARY 927
File
comms MPI.F90
Type
Module subroutine
Purpose
Combines a send and a receive operation on logical data.
Arguments
sendbuf Starting address of send buffer
sendcount Number of data in send buffer
dest Rank of destination process
sendtag Message tag of send operation
recvbuf Starting address of receive buffer
recvcount Number of data in receive buffer
source Rank of source process
recvtag Message tag of receive operation
comm Communicator id
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI sendrecv
File
comms MPI.F90
Type
Module subroutine
Purpose
Combines a send and a receive operation on real data.
Arguments
sendbuf Starting address of send buffer
sendcount Number of data in send buffer
dest Rank of destination process
sendtag Message tag of send operation
recvbuf Starting address of receive buffer
recvcount Number of data in receive buffer
source Rank of source process
recvtag Message tag of receive operation
comm Communicator id
ivarid Variable key id (used for log info only, zero for undefined)
MPI call
MPI sendrecv
comms waitall
SUBROUTINE comms waitall(count,requests)
INTEGER, INTENT(IN) :: count
INTEGER, INTENT(INOUT), DIMENSION(count) :: requests
File
comms MPI.F90
Type
Module subroutine
930 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Complete communications associated with an array of requests.
Arguments
count Number of requests
requests Array of requests
MPI call
MPI waitall
error MPI
SUBROUTINE error MPI(mpiname,abort)
LOGICAL, INTENT(IN), OPTIONAL :: abort
CHARACTER (LEN=*), INTENT(IN) :: mpiname
File
comms MPI.F90
Type
Module subroutine
Purpose
Report an error in a MPI routine. The program is aborted either in
this routine or in the calling routine.
Arguments
mpiname Name of the MPI routine where the error occurred
abort Abort the program if present and .TRUE.. If not present,
abortion is executed only if iopt MPI abort is set to 1.
MPI calls
MPI error string
File
comms MPI.F90
23.6. INITIALISATION OF DERIVED TYPES VARIABLES 931
Type
Module subroutine
Purpose
Report an error in a MPI send or receive communication.
Arguments
mpiname Name of the MPI routine where the error occurred
idsrce Rank of the source (sending) process
iddest Rank of the destination (receiving) process
File
datatypes init.f90
Type
Module subroutine
Purpose
Initialise parameters for exchange communications.
Arguments
comms Derived type variable to be initialised
filepars init
SUBROUTINE filepars init(filepars)
TYPE (FileParams), INTENT(INOUT)[, DIMENSION(:[,:[,:]])] :: filepars
File
datatypes init.f90
932 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Generic module subroutine
Purpose
Initialise file attributes.
Arguments
filepars Derived type variable (scalar or array) to be initialised
Non-generic versions
filepars init 0d Derived type scalar
filepars init 1d Derived type vector
filepars init 2d Derived type 2-D array
filepars init 3d Derived type 3-D array
gridpars init
SUBROUTINE gridpars init(gridpars)
TYPE (GridParams), INTENT(OUT), DIMENSION(:,:) :: gridpars
File
datatypes init.f90
Type
Module subroutine
Purpose
Initialise attributes of 2-D external data grids.
Arguments
gridpars Derived type variable to be initialised
hrelativecoords init
SUBROUTINE hrelativecoords init(hgrid,flag undef)
LOGICAL, INTENT(IN) :: flag undef
TYPE (FileParams), INTENT(OUT)[, DIMENSION(:[,:])] :: hgrd
File
datatypes init.f90
23.6. INITIALISATION OF DERIVED TYPES VARIABLES 933
Type
Generic module subroutine
Purpose
Initialise the horizontal relative coordinates of one or more data (model
grid) locations.
Arguments
hgrid Derived type variable (scalar or array) to be initialised
flag undef If .TRUE., values are set to undefined values. Otherwise
they are set to zero.
Non-generic versions
hrelativecoords init 0d Derived type scalar
hrelativecoords init 1d Derived type vector
hrelativecoords init 2d Derived type 2-D array
outgpars init
SUBROUTINE outgpars init(outgpars)
TYPE (OutGridParams), INTENT(OUT), DIMENSION(:) :: outgpars
File
datatypes init.f90
Type
Module subroutine
Purpose
Initialise attributes of a user-defined output grid.
Arguments
outgpars Derived type array to be initialised
statlocs init
SUBROUTINE statlocs init(statlocs)
TYPE (StationLocs), INTENT(OUT), DIMENSION(:) :: statlocs
File
datatypes init.f90
934 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module subroutine
Purpose
Initialise attributes of user-defined output stations.
Arguments
outgpars Derived type array to be initialised
varatts init
SUBROUTINE varatts init(varatts)
TYPE (VariableAtts), INTENT(OUT)[, DIMENSION(:)] :: varatts
File
datatypes init.f90
Type
Generic module subroutine
Purpose
Initialise the attributes of program variables.
Arguments
varatts Derived type variable (scalar or vector) to be initialised
Non-generic versions
varatts init 0d Derived type scalar
varatts init 1d Derived type vector
vrelativecoords init
SUBROUTINE vrelativecoords init(vgrid,flag undef)
LOGICAL, INTENT(IN) :: flag undef
TYPE (VRelativeCoords), INTENT(OUT) &
& [,DIMENSION(:[,:[,:[,]]])] :: vgrid
File
datatypes init.f90
Type
Generic module subroutine
23.7. DEFAULT MODEL SETUP 935
Purpose
Initialise the vertical relative coordinates of one or more data (model
grid) locations.
Arguments
vgrid Derived type variable (scalar or array) to be initialised
flag undef If .TRUE., values are set to undefined values. Otherwise
they are set to zero.
Non-generic versions
vrelativecoords init 0d Derived type scalar
vrelativecoords init 1d Derived type vector
vrelativecoords init 2d Derived type 2-D array
vrelativecoords init 3d Derived type 3-D array
vrelativecoords init 4d Derived type 4-D array
default ellvars
SUBROUTINE default ellvars(ellvars)
TYPE (VariableAtts), INTENT(OUT), DIMENSION(14) :: ellvars
File
default model.f90
Type
Module subroutine
Purpose
Attributes of tidal ellipse variables
Arguments
ellvars Derived type array containing the attributes of the tidal
ellipse parameters. These defaults cannot be changed.
936 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
default model.f90
Type
Module subroutine
Purpose
Default settings of parameters for monitoring
File
default model.f90
Type
Module subroutine
Purpose
Default settings of model setup parameters (which can be re-defined in
usrdef mod params)
File
default model.f90
Type
Generic module subroutine
Purpose
Default attributes of user-defined output files
Arguments
23.7. DEFAULT MODEL SETUP 937
File
default model.f90
Type
Module subroutine
Purpose
Default settings for the attributes of an output grid file
Arguments
filepars Output grid file
file type Type of user output
‘TS’: time series
‘TA’: time averaged
‘HR’: harmonic residuals
‘HA’: harmonic amplitudes
‘HP’: harmonic phases
‘HE’: tidal ellipse parameters
938 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
error routines.F90
Type
Module subroutine
Purpose
Check the start/end/step values, stored in a component of a derived
type array, defining a spatial section on the model grid.
Arguments
slims Start/end/increment values defining the array section
arrname Name of the derived type array
compname Name of the derived type component
limmax Maximum allowed value for the end index
ndims Rank of the derived type array
indx Vector index of the derived type array
File
error routines.F90
Type
Module subroutine
Purpose
Check start/end/increment time index values.
940 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Arguments
tlims Start/end/increment values
arrname Name of the tlims variable
minstep Minimum allowed value for the start index
maxstep Maximum allowed value for the end index
File
error routines.F90
Type
Module subroutine
Purpose
Check the start/end/increment time index values, stored in a compo-
nent of a derived type array.
Arguments
tlims Start/end/increment values
arrname Name of the derived type array
compname Name of the derived type component
minstep Minimum allowed value for the start index
maxstep Maximum allowed value for the end index
ndims Rank of the derived type array
indx Vector index of the derived type array
error abort
SUBROUTINE error abort(prname,icode)
CHARACTER (LEN=*), INTENT(IN) :: prname
INTEGER, INTENT(IN) :: icode
23.8. ERROR CHECKING ROUTINES 941
File
error routines.F90
Type
Module subroutine
Purpose
If errors have been detected from a previous error checking routine or
by some error coding within a program routine, the error message as-
sociated with error code icode is displayed and the program is aborted.
Arguments
prname Name of the routines where the error occurred
icode Error code key id number
error alloc
SUBROUTINE error alloc(arrname,ndims,nshape,data type,lenstr,abort)
LOGICAL, INTENT(IN), OPTIONAL :: abort
CHARACTER (LEN=*), INTENT(IN) :: arrname
INTEGER, INTENT(IN) :: data type, ndims
INTEGER, INTENT(IN), OPTIONAL :: lenstr
INTEGER, INTENT(IN), DIMENSION(ndims) :: nshape
File
error routines.F90
Type
Module subroutine
Purpose
Write an appropriate error message when an error occurred during
allocation of an array.
Arguments
arrname Name of the array
ndims Rank of the array
nshape Shape of the array
data type COHERENS data type id
lenstr Length of the array strings if the array contains character
data
942 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
error routines.F90
Type
Module subroutine
Purpose
Write an appropriate error message when an error occurred during
allocation of a derived type array.
Arguments
arrname Name of the array
ndims Rank of the array
nshape Shape of the array
structype TYPE of the derived type array
abort Abort the program if present and .TRUE.. Otherwise the
program is aborted in the calling routine.
File
error routines.F90
Type
Generic module subroutine
23.8. ERROR CHECKING ROUTINES 943
Purpose
Checks whether argument val in a routine call equals fix. It is clear
that the two arguments must be of the same type and have the same
string length in case they are of type CHARACTER. Argument fix is
OPTIONAL only in case of CHARACTER arguments.
Arguments
val Value of the routine argument
argname FORTRAN name of the argument
fix Allowed value for val. If not present and val is of type
CHARACTER, its value is automatically taken as invalid.
Non-generic versions
error arg var char The arguments are of type CHARACTER
error arg var int The arguments are of type INTEGER
error arg var log The arguments are of type LOGICAL
File
error routines.F90
Type
Module subroutine
Purpose
Checks whether the value the index ival belonging to dimension ndim
of an array is between the bounds minval and maxval.
Arguments
ival Array index to be checked
arrname Name of the array
minval Lower array bound
maxval Upper array bound
ndim Array dimension to be checked
944 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
error routines.F90
Type
Module subroutine
Purpose
Checks if the elements of the vector ilist are all different. Zero values are
not allowed unless nozero is present and .TRUE.. The routine is called
to check the values along a certain array dimension of an INTEGER
array.
Arguments
ilist List of integer values to be checked
arrname Name of the array
ndims Rank of the array
idim Array dimension to which ilist applies
indx Array index vector with the index for dimension idim omit-
ted
nozero Zeros are allowed only if present and .TRUE.
File
error routines.F90
23.8. ERROR CHECKING ROUTINES 945
Type
Module subroutine
Purpose
Checks if the elements of the vector ilist are all different. Zero values
are not allowed unless nozero is present and .TRUE..
Arguments
ilist List of integer values to be checked
listname Name of the vector list
nozero Zeros are allowed only if present and .TRUE.
File
error routines.F90
Type
Module subroutine
Purpose
Checks whether an array has the rank given by nfix.
Arguments
nrank Rank of the array
arrname Name of the array
nfix Assumed rank of the array
error file
SUBROUTINE error file(ierr,iounit,filepars,abort)
LOGICAL, INTENT(IN), OPTIONAL :: abort
INTEGER, INTENT(IN) :: ierr
INTEGER, INTENT(IN), OPTIONAL :: iounit
TYPE(FileParams), INTENT(IN), OPTIONAL :: filepars
File
error routines.F90
946 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module subroutine
Purpose
Report an input/output error detected during a file read/write.
Arguments
ierr Error code (as given by its key id of the form ierrno *)
iounit File unit number (must be present if filepars is not present)
filepars File attributes (must be present if iounit is not present)
abort The program is aborted unless abort is present and .FALSE.
File
error routines.F90
Type
Generic module subroutine
Purpose
Checks whether the value val of an array element is greater than or equal
to minval if matchmin is .TRUE. or greater than minval if matchmin is
.FALSE..
Arguments
val Value of the array element
arrname Array name
minval Lower bound for val
matchmin If .TRUE., val may be equal to minval.
ndims Rank of the array
indx Vector index of the array element
23.8. ERROR CHECKING ROUTINES 947
Non-generic versions
error lbound arr int val and minval are of type INTEGER
error lbound arr real val and minval are of type REAL
File
error routines.F90
Type
Generic module subroutine
Purpose
Checks whether the value val of a component of a derived array element
is greater than or equal to minval if matchmin is .TRUE. or greater than
minval if matchmin is .FALSE..
Arguments
val Value of the component of the array element
arrname Name of the derived type array
compname Name of the derived type component
minval Lower bound for val
matchmin If .TRUE., val may be equal to minval.
ndims Rank of the array
indx Vector index of the array element
Non-generic versions
error lbound arr struc int val and minval are of type INTEGER
error lbound arr struc real val and minval are of type REAL
948 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
error routines.F90
Type
Generic module subroutine
Purpose
Checks whether val is greater than or equal to minval if matchmin is
.TRUE. or greater than minval if matchmin is .FALSE..
Arguments
val Value of the (scalar) variable
varname Variable name
minval Lower bound for val
matchmin If .TRUE., val may be equal to minval.
Non-generic versions
error lbound var int val and minval are of type INTEGER
error lbound var real val and minval are of type REAL
File
error routines.F90
Type
Generic module subroutine
23.8. ERROR CHECKING ROUTINES 949
Purpose
Checks whether the value val of an array element is not lower than
minval and not greater than maxval.
Arguments
val Value of the array element
arrname Array name
minval Lower bound for val
maxval Upper bound for val
ndims Rank of the array
indx Vector index of the array element
Non-generic versions
error limits arr int val, minval, maxval are of type INTEGER
error limits arr real val, minval, maxval are of type REAL
File
error routines.F90
Type
Generic module subroutine
Purpose
Checks whether the value val of a component of a derived array element
is not lower than minval and not greater than maxval.
Arguments
val Value of the component of the derived type array element
arrname Name of the derived type array
compname Name of the derived type component
950 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Non-generic versions
error limits arr struc int val, minval, maxval are of type INTEGER
error limits arr struc real val, minval, maxval are of type REAL
File
error routines.F90
Type
Generic module subroutine
Purpose
Checks whether val is not lower than minval and not greater than
maxval.
Arguments
Non-generic versions
error limits var int val, minval, maxval are of type INTEGER
error limits var real val, minval, maxval are of type REAL
23.8. ERROR CHECKING ROUTINES 951
error mult
SUBROUTINE error mult(ival,varname,multval)
CHARACTER (LEN=*), INTENT(IN) :: varname
INTEGER, INTENT(IN) :: ival, multval
File
error routines.F90
Type
Module subroutine
Purpose
Checks whether ival is a divisor of multval.
Arguments
ival Integer input variable
varname Variable name
multval Integer multiple of ival
error proc
SUBROUTINE error proc(ierr,abort)
LOGICAL, INTENT(IN), OPTIONAL :: abort
INTEGER, INTENT(IN) :: ierr
File
error routines.F90
Type
Module subroutine
Purpose
Write the number of the error code and the name of the routine where
the error occurred to the error file.
Arguments
ierr Number of the error code
abort Abort the program if present and .TRUE.
952 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
error shape
SUBROUTINE error shape(arrshape,arrname,fixshape,ndim)
CHARACTER (LEN=*), INTENT(IN) :: arrname
INTEGER, INTENT(IN) :: ndim
INTEGER, INTENT(IN) , DIMENSION(ndim) :: arrshape, fixshape
File
error routines.F90
Type
Module subroutine
Purpose
Check whether shape arrshape equals the vector shape.
Arguments
arrshape Shape of the array
arrname Array name
fixshape Vector to which arrshape should be equal
ndim Array rank
File
error routines.F90
Type
Generic module subroutine
Purpose
Check whether the value val of an array element is not greater than
maxval if matchmax is .TRUE. or lower than maxval if matchmax is
.FALSE..
23.8. ERROR CHECKING ROUTINES 953
Arguments
val Value of the array element
arrname Array name
maxval Upper bound for val
matchmax If .TRUE., val may be equal to maxval.
ndims Rank of the array
indx Vector index of the array element
Non-generic versions
error ubound arr int val and maxval are of type INTEGER
error ubound arr real val and maxval are of type REAL
File
error routines.F90
Type
Generic module subroutine
Purpose
Check whether the value val of a component of a derived type array
element is not greater than maxval if matchmax is .TRUE. or lower than
maxval if matchmax is .FALSE..
Arguments
val Value of the component of the array element
arrname Name of the derived type array
compname Name of the derived type component
maxval Upper bound for val
matchmax If .TRUE., val may be equal to maxval.
954 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Non-generic versions
error ubound arr struc int val and maxval are of type INTEGER
error ubound arr struc real val and maxval are of type REAL
File
error routines.F90
Type
Generic module subroutine
Purpose
Check whether val is not greater than maxval if matchmax is .TRUE. or
lower than maxval if matchmax is .FALSE..
Arguments
val Value of the (scalar) variable
varname Variable name
maxval Upper bound for val
matchmax If .TRUE., val may be equal to maxval.
Non-generic versions
error ubound var int val and maxval are of type INTEGER
error ubound var real val and maxval are of type REAL
File
error routines.F90
Type
Generic module subroutine
Purpose
Check whether the character string array element val (without trailing
blanks) is a substring of fixval or check whether the element val of an
integer array equals one of the values in the vector list fixval.
Arguments
val Character string or integer array element
arrname Array name
fixval Character string to which val should be equal or integer
vector list of allowed integer values.
ndims Array rank
indx Vector index of the array element
Non-generic versions
error vals arr char Checks character string
error vals arr int Checks integer array element
File
error routines.F90
Type
Generic module subroutine
956 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Check whether the string component val of a derived type array is
a substring of fixval or check whether the element val of an integer
component of a derived type array equals one of the values in the
vector list fixval.
Arguments
val Character string or integer component of the derived type
array
arrname Name of derived type array
compname Name of the derived type component
fixval Character string to which val should be equal or integer
vector list of allowed integer values.
ndims Array rank
indx Vector index of the array element
Non-generic versions
error vals arr struc char Checks character string component
error vals arr struc int Checks integer component
File
error routines.F90
Type
Generic module subroutine
Purpose
Check whether the string val is a substring of fixval or check whether
the integer val equals one of the values in the vector list fixval.
Arguments
val Character string or integer array element
varname Variable name
23.8. ERROR CHECKING ROUTINES 957
Non-generic versions
File
error routines.F90
Type
Generic module subroutine
Purpose
Check whether the integer or logical array element val equals the integer
or logical value fixval.
Arguments
Non-generic versions
error value arr int val and fixval are of type INTEGER
error value arr log val and fixval are of type LOGICAL
958 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
error routines.F90
Type
Generic module subroutine
Purpose
Check whether the value val of a component of a derived type array
element equals fixval.
Arguments
val Value of the component of the derived type array element
arrname Name of derived type array
compname Name of derived type component
fixval Value to which val should be equal
ndims Array rank
indx Vector index of the array element
Non-generic versions
error value arr struc int val and fixval are of type INTEGER
error value arr struc log val and fixval are of type LOGICAL
File
error routines.F90
Type
Generic module subroutine
23.8. ERROR CHECKING ROUTINES 959
Purpose
Check whether the integer or logical variable val equals the integer or
logical value fixval.
Arguments
val Integer or logical variable
varname Variable name
fixval Integer or logical value to which val should be equal
Non-generic versions
error value var int val and fixval are of type INTEGER
error value var log val and fixval are of type LOGICAL
File
error routines.F90
Type
Generic module subroutine
Purpose
Reset the array element val to set with a warning message if needed.
Arguments
val Character string, integer or logical array element
arrname Array name
set Value to which val should be reset
ndims Array rank
indx Vector index of the array element
Non-generic versions
warning reset arr char Resets a character string array element
960 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
error routines.F90
Type
Generic module subroutine
Purpose
Reset val to set with a warning message if needed.
Arguments
val Character string, integer, logical or real variable
varname Variable name
set Value to which val should be reset
Non-generic versions
warning reset var char Resets a character string variable
warning reset var int Resets an integer variable
warning reset var log Resets a logical variable
warning reset var real Resets a real variable
File
error routines.F90
Type
Module subroutine
Purpose
Writes a warning message if the real variable rval is not greater than
maxval if matchmax is .TRUE. or lower than maxval if matchmax is
.FALSE.
Arguments
rval Real variable to be checked
varname Variable name
962 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
grid interp.F90
Type
Module subroutine
Purpose
Returns the relative vertical coordinates of input data with respect to
a series of output data locations.
Arguments
zin Vertical coordinates (measured as the positive distance to
the sea surface) of the input data
23.9. GRID INTERPOLATION FROM AND TO THE MODEL GRID 963
File
grid interp.F90
Type
Module subroutine
Purpose
Returns the relative horizontal coordinates of a gridded array of exter-
nal data points with respect to the global model grid.
Arguments
xdat X-coordinates of the data points
ydat Y-coordinates of the data points
hcoords Returned array of relative coordinates
n1dat X-dimension of the external data grid
n2dat Y-dimension of the external data grid
964 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
cnode Nodal type of the model grid points used for interpolation
(‘C’, ‘U’, ‘V’)
intflag Type of flagging for invalid (land) points
1: all locations are valid, interpolation to nearest wet points
if necessary
2: locations are valid only if at least one neighbouring
point is wet
3: locations are only valid if all neighbouring points are
wet
File
grid interp.F90
Type
Module subroutine
Purpose
Returns the relative vertical coordinates of a 1-D vertical grid (with
horizontal position on the model grid) with respect to the model grid.
Arguments
zcoord Vertical coordinates (measured as the positive distance to
the sea surface) of the data locations
vcoords Returned array of vertical relative coordinates
i X-index of the data locations on the model grid
j Y-index of the data locations on the model grid
nzdat Number of vertical levels of the 1-D data grid
cnode Nodal type of the horizontal locations on the model grid
(‘C’, ‘U’, ‘V’)
23.9. GRID INTERPOLATION FROM AND TO THE MODEL GRID 965
File
grid interp.F90
Type
Module subroutine
Purpose
Returns the relative coordinates of a 3-D data grid with respect to the
model grid. The data grid is assumed to be positioned horizontally on
the model grid. Dry cells are not taken into account.
Arguments
zcoord Vertical coordinates (measured as the positive distance to
the sea surface) of the data locations
vcoords Returned array of vertical relative coordinates
nzdat Number of vertical levels in the data array
cnode Nodal type of the horizontal locations on the model grid
(‘C’, ‘U’, ‘V’)
File
grid interp.F90
966 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module subroutine
Purpose
Returns the relative coordinates of a 3-D data grid with respect to the
model grid. The horizontal grids are different. Since horizontal inter-
polation is performed after vertical one and vertical model grid points
with the same vertical index do not have the vertical Z-coordinate,
the vertical relative coordinates are to be taken at the four model grid
points surrounding the data point in the horizontal. This explains why
the first two dimensions of vcoords have a size of 2.
Arguments
zcoord Vertical coordinates (measured as the positive distance to
the sea surface) of the data grid
hcoords Horizontal relative coordinates of the data grid with re-
spect to the model grid.
vcoords Returned array of vertical relative coordinates. The first
two dimensions refer to the four adjacent model grid loca-
tions in the X- and Y-directions.
n1dat X-dimension of the data grid.
n2dat Y-dimension of the data grid.
n3dat Vertical dimension of the data grid.
cnode Nodal type of the horizontal locations on the model grid
(‘C’, ‘U’, ‘V’)
File
grid interp.F90
Type
Module subroutine
Purpose
Interpolate a 2-D gridded horizontal data array on the model grid.
Data and model grid are assumed to be different.
Arguments
invals Array of data values
outvals Returned data interpolated on the model grid
ncin X-dimension of the data grid
nrin Y-dimension of the data grid.
nosize Number of data variables
surfgrid Relative (horizontal) coordinates of the data grid with re-
spect to the model grid
datflag Enables flagging in case of invalid data points
0: flagging is disabled
1: flagging is enabled, no extrapolation is allowed
2: flagging is enabled, extrapolation is allowed
land Land points on the model grid are included if set to .TRUE.
inflag Flag for invalid input data which must be defined if datflag>0.
If not present, its value is set to the minimum value real min
used for flagged data.
outflag Replacement flag at model grid locations where no inter-
polation could be performed. If not present, its value is
set to the undefined value real fill.
File
grid interp.F90
Type
Module subroutine
Purpose
Interpolate a vertical model profile at a given depth
Arguments
invals Vertical input profile
outval Returned value interpolated at the specified depth
i (Local) X-index of the model grid location
j (Local) Y-index of the model grid location
dep Interpolation depth (positive distance from the free sur-
face)
cnode Vertical grid node where invals is defined (’C’ or ’W’)
nzmin Lowest physical vertical level in case invals is defined at
the W-nodes (1 otherwise)
nzmax Highest physical vertical level in case invals is defined at
the W-nodes (nz otherwise)
outflag Replacement flag if dep is larger than the water depth at
the given location
File
grid interp.F90
Type
Module subroutine
Purpose
Interpolate a 2-D gridded horizontal model array at a series of data
locations.
Arguments
invals 2-D model grid array
outvals Returned model data interpolated at the external data
locations
hcoords Relative (horizontal) coordinates of the data points with
respect to the model grid
nhdims Halo sizes of the model array (WESN directions)
nhdat Number of horizontal data locations
nosize Number of data variables for which interpolation is applied
(added as an extra array dimension)
cnode Nodal type of the variable(s) on the model grid (‘C’, ‘U’,
‘V’)
datvals Optional array of data values. If present, its values are
flagged at points where the relative coordinates are given
as undefined.
outflag Optional replacement flag at data locations where no in-
terpolation could be performed. Otherwise the flag is set
to the undefined value.
File
grid interp.F90
Type
Module subroutine
Purpose
Interpolate data vertically from a 3-D data array to another 3-D output
data array. The two grids share the same horizontal locations.
Arguments
invals Interpolating data array, defined on the input grid
outvals Returned interpolated data, defined on the output grid
vcoords Vertical relative coordinates of the data points with re-
spect to the output grid
nhdat Number of horizontal locations on both grids
nzdatin Vertical dimension of the input grid
nzdatout Vertical dimension of the output grid
nzeff “Effective” number of interpolated data along the vertical.
This means that interpolation is only performed for levels
1 to nzeff (equal or lower than nzdatout).
nosize Number of data variables for which interpolation is applied
(added as an extra array dimension)
outflag Optional replacement flag at data locations where no in-
terpolation could be performed. Otherwise the flag is set
to the undefined value.
File
grid interp.F90
Type
Module subroutine
Purpose
Interpolate model data vertically to an external (1-D) vertical grid.
Model and external grid are assumed to be defined along the same
horizontal grid, but the interpolation is taken at one horizontal location
only.
Arguments
invals Vertical profile on the model grid
outvals Returned profile of model data interpolated along the ex-
ternal vertical grid
vcoords Vertical relative coordinates of the model locations with
respect to the vertical external grid
nzdim Vertical dimension of the model grid
nzdat Vertical dimension of the external grid
nosize Number of data variables for which interpolation is applied
(added as an extra array dimension)
datvals Optional array of data values. If present, its values are
flagged at points where the relative coordinates are given
as undefined.
outflag Optional replacement flag at data locations where no in-
terpolation could be performed. Otherwise the flag is set
to the undefined value real fill.
File
grid interp.F90
Type
Module subroutine
Purpose
Interpolate model data (vertically) to an external 3-D grid. Model and
external grid are assumed to be defined along the same horizontal grid.
Arguments
invals Model grid array
outvals Returned model data interpolated on the external grid
vcoords Vertical relative coordinates of the model grid with respect
to the vertical external grid
nhdims Halo sizes of model array (WESN directions)
nzdim Vertical dimension of the model grid
nzdat Vertical dimension of the external grid
nosize Number of data variables for which interpolation is applied
(added as an extra array dimension)
datvals Optional array of data values. If present, its values are
flagged at points where the relative coordinates are given
as undefined.
outflag Optional replacement flag at data locations where no in-
terpolation could be performed. Otherwise the flag is set
to the undefined value.
23.9. GRID INTERPOLATION FROM AND TO THE MODEL GRID 973
File
grid interp.F90
Type
Module subroutine
Purpose
Returns the horizontal relative coordinates of the model grid with re-
spect to an external (2-D) grid.
Arguments
idgrd Key grid id of the external grid
ifil File number of the external data grid (currently 1)
surfgrid Returned horizontal relative coordinates of the model grid
with respect to the external grid
23.10. ROUTINES PERFORMING OPERATIONS ON THE MODEL GRID 975
File
grid routines.F90
Type
Module subroutine
Purpose
Construct a uniform rectangular grid kwowing its size, grid spacings
and the position of the Southwest corner.
Arguments
xstart X-coordinate of the Southwest corner at the (global) grid
location (1,1)
[m or fractional degrees longitude]
ystart Y-coordinate of the Southwest corner at the (global) grid
location (1,1)
[m or fractional degrees latitude]
delx Grid spacing in the X-direction
[m or fractional degrees longitude]
dely Grid spacing in the Y-direction
[m or fractional degrees latitude]
ncgrd Size of the grid in the X-direction
976 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
grid routines.F90
Type
Module function
Purpose
Returns a geographical location in string format (degrees, minutes,
seconds).
Arguments
xcoord X-coordinate of the geographical location
[fractional degrees longitude]
ycoord Y-coordinate of the geographical location
[fractional degrees latitude]
charloc Returned string format in degrees, minutes, seconds
distance minloc
SUBROUTINE distance minloc(x,y,xcoord,ycoord,nx,ny,iunit,distmin,locmin,mask)
INTEGER, INTENT(IN) :: iunit, nx, ny
INTEGER, INTENT(OUT), OPTIONAL, DIMENSION(2) :: locmin
REAL, INTENT(IN) :: x, y
LOGICAL, INTENT(IN), OPTIONAL, DIMENSION(nx,ny) :: mask
REAL, INTENT(IN), DIMENSION(nx,ny) :: xcoord, ycoord
REAL, INTENT(OUT), OPTIONAL :: distmin
File
grid routines.F90
23.10. ROUTINES PERFORMING OPERATIONS ON THE MODEL GRID 977
Type
Module function
Purpose
Returns the index positions of the location on a horizontal grid which
is closest to a given location.
Arguments
x X-coordinate of the given location
[m or fractional degrees longitude]
y Y-coordinate of the given location
[m or fractional degrees latitude]
xcoord X-coordinates of the grid
ycoord Y-coordinates of the grid
nx Size of the grid in the X-direction
ny Size of the grid in the Y-direction
iunit Units of xcoord, ycoord in case of spherical coordinates
1: radians
2: degrees
distmin If present, the returned minimum distance
locmin If present, the location of the nearest distance
mask Mask to exclude dry or invalid points if present and .TRUE.
distance pts
FUNCTION distance pts(x1,x2,y1,y2,inunit,outunit) RESULT(dist)
INTEGER, INTENT(IN) :: inunit, outunit
REAL, INTENT(IN) :: x1, x2, y1, y2
REAL :: dist
File
grid routines.F90
Type
Module function
Purpose
Returns the distance between two given locations.
Arguments
978 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
grid routines.F90
Type
Module function
Purpose
Returns the index of an open boundary point given its grid index lo-
cation.
Arguments
i X-index of the location
j Y-index of the location
cnode Type of open boundary node (‘U’, ‘V’, ‘X’, ‘Y’)
ierr Error code in case no match has been found. If zero, no
error occurred.
23.10. ROUTINES PERFORMING OPERATIONS ON THE MODEL GRID 979
File
grid routines.F90
Type
Module subroutine
Purpose
Rotate an array of vectors through a given angle.
Arguments
vxin X-component of the array vector
vyin Y-component of the array vector
vxout Returned X-component of the rotated array vector
vyout Returned Y-component of the rotated array vector
ndims Shape of the array
angle Rotation angle [radians]
File
grid routines.F90
Type
Module subroutine
Purpose
Rotate a vector through a given angle.
980 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Arguments
vxin X-component of the vector
vyin Y-component of the vector
vxout Returned X-component of the rotated vector
vyout Returned Y-component of the rotated vector
angle Rotation angle [radians]
global mask
SUBROUTINE global mask(maskglb,cnode,wetonly)
CHARACTER (LEN=lennode), INTENT(IN) :: cnode
LOGICAL, INTENT(IN) :: wetonly
LOGICAL, INTENT(OUT), DIMENSION(nc,nr) :: maskglb
File
grid routines.F90
Type
Module subroutine
Purpose
Combine a local grid mask to a global one (used for parallel applica-
tions).
Arguments
maskglb Returned global mask
cnode Grid node to which the mask should apply (‘C’, ‘U’, ‘V’,
‘X’, ‘Y’)
wetonly Considers open boundary points as land points if set to
.TRUE..
& lbounds(2):ubounds(2),&
& nzdim,nosize) :: vxin, vyin
REAL, INTENT(OUT), DIMENSION(lbounds(1):ubounds(1),&
& lbounds(2):ubounds(2),&
& nzdim,nosize) :: vxout, vyout
File
grid routines.F90
Type
Module subroutine
Purpose
Transform a vector array, defined on the model grid, from the reference
(Cartesian or spherical) coordinate system to the curvilinear grid if
idir=1. The inverse transformation is invoked if idir=-1. The vectors
are assumed to be defined at the C-nodes.
Arguments
vxin X-component of the array vector to be transformed
vyin Y-component of the array vector to be transformed
vxout Returned X-component of the transformed array vector
vyout Returned Y-component of the transformed array vector
lbounds Lower bounds of the first two array dimensions
ubounds Upper bounds of the first two array dimensions
nzdim Third (vertical) array dimension
nosize Fourth (variable) array dimension
mask Dry points are flagged if set to .TRUE..
idir Direction of the transformation
1 : from reference to transformed coordinates
-1: from transformed to reference
outflag Flag used for dry points. If not present, a zero is taken.
File
grid routines.F90
Type
Module subroutine
Purpose
Transform a (scalar) vector, defined at a given grid index position on
the model grid, from the reference (Cartesian or spherical) coordinate
system to the curvilinear grid if idir=1. The inverse transformation
is invoked if idir=-1. The vectors are assumed to be defined at the
C-nodes.
Arguments
vxin X-component of the vector to be transformed
vyin Y-component of the vector to be transformed
vxout Returned X-component of the transformed vector
vyout Returned Y-component of the transformed vector
i (Local) X-index of the grid point where the vector is de-
fined
j (Local) Y-index of the grid point where the vector is de-
fined
idir Direction of the transformation
1 : from the reference to the transformed coordinate sys-
tem
-1: from the transformed to the reference coordinate sys-
tem
outflag Flag used for dry points. If not present, a zero is taken.
grid spacings
SUBROUTINE grid spacings(dist,x1,x2,y1,y2,nx,ny,nhtype,&
& inunit,outunit,hdel,cdir)
CHARACTER (LEN=1), INTENT(IN), OPTIONAL :: cdir
INTEGER, INTENT(IN) :: inunit, nhtype, nx, ny, outunit
23.10. ROUTINES PERFORMING OPERATIONS ON THE MODEL GRID 983
File
grid routines.F90
Type
Module subroutine
Purpose
Calculate the (horizontal) grid spacings on a given (Cartesian or sphe-
rical) grid. The spacings are defined as distance between two arrays of
grid points.
Arguments
dist Returned grid spacings
x1 X-coordinates of the start locations
x2 X-coordinates of the end locations
y1 Y-coordinates of the start locations
y2 Y-coordinates of the end locations
nx X-dimension of the grid
ny Y-dimension of the grid
nhtype Type of the grid
1: uniform rectangular
2: non-uniform rectangular
3: curvilinear
inunit Units of the grid locations in case of a spherical grid
1: radians
2: fractional degrees
outunit Unit of the returned grid spacings in case of a spherical
grid
1: radians
2: fractional degrees
3: meters
hdel Grid spacings in case of a uniform rectangular grid
984 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
local proc
FUNCTION local proc(i,j,iproc)
INTEGER, INTENT(IN) :: i, j
INTEGER, INTENT(IN), OPTIONAL :: iproc
LOGICAL :: local proc
File
grid routines.F90
Type
Module function
Purpose
Returns .TRUE. if the point with local grid indices (i,j) belongs to the
domain of the local process calling the function. If iproc is present, (i,j)
are global indices and the function returns .TRUE. if the points belongs
to the domain with process number iproc.
Arguments
i X-index (local or global) of the grid point
j Y-index (local or global) of the grid point
iproc Process number in case (i,j) represent global indices. Must
be present if i and j are global indices.
mask array
FUNCTION mask array(idim,jdim,lims,node)
CHARACTER (LEN=1), INTENT(IN) :: node
INTEGER, INTENT(IN) :: idim, jdim
INTEGER, INTENT(IN), DIMENSION(3,2) :: lims
LOGICAL, DIMENSION(idim,jdim) :: mask array
File
grid routines.F90
23.10. ROUTINES PERFORMING OPERATIONS ON THE MODEL GRID 985
Type
Module function
Purpose
Define a local mask array on a sub-section of the model grid.
Arguments
idim X-dimension of the mask array
jdim Y-dimension of the mask array
lims Vector selecting the sub-grid indices in the X- and Y-
direction (start/end/step)
node Grid node to which the mask applies (‘C’, ‘U’, ‘V’, ‘W’)
num proc
FUNCTION num proc(i,j)
INTEGER, INTENT(IN) :: i, j
INTEGER :: num proc
File
grid routines.F90
Type
Module function
Purpose
Returns the number of the local process domain containing the point
with global indices (i,j).
Arguments
i X-index of the location
j Y-index of the location
Zcoord arr
SUBROUTINE Zcoord arr(zcoord,lbounds,ubounds,cnode,&
& meanlevel,outflag)
LOGICAL, INTENT(IN) :: meanlevel
CHARACTER (LEN=lennode), INTENT(IN) :: cnode
REAL, INTENT(IN), OPTIONAL :: outflag
INTEGER, INTENT(IN), DIMENSION(3) :: lbounds, ubounds
986 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
grid routines.F90
Type
Module subroutine
Purpose
Return the z-coordinates on a section of the model grid.
Arguments
zcoord Returned z-coordinates
lbounds Lower bounds of the grid section
ubounds Upper bounds of the grid section
cnode Type of grid node (‘C’, ‘U’, ‘V’, ‘W’, ‘UW’, ‘VW’)
meanlevel The z-coordinates are taken with respect to the mean or
total water level if set to .TRUE. or .FALSE.
outflag Output flag for dry points. If not present, a zero value is
taken.
Zcoord var
FUNCTION Zcoord var(i,j,k,cnode,meanlevel)
LOGICAL, INTENT(IN) :: meanlevel
CHARACTER (LEN=lennode), INTENT(IN) :: cnode
INTEGER, INTENT(IN) :: i, j, k
REAL :: Zcoord var
File
grid routines.F90
Type
Module function
Purpose
Returns the z-coordinate of a model grid point.
Arguments
23.11. ROUTINES COMBINING COMMUNICATION AND I/O OPERATIONS 987
Purpose
Combine local model grid arrays with real data into a global array and
write the resulting array to a file in standard COHERENS format. The
array has a rank between 2 and 4.
Arguments
values Local model grid array
filepars Derived type variable containing the attributes of the out-
put file
varid If positive, the id of the only variable written to the output
file (between 1 and the number of variables in the file). If
zero, the last dimension of values is considered as a variable
dimension.
lbounds Lower array bounds. The size must match the rank of the
array.
ubounds Upper array bounds. The size must match the rank of the
array.
rfill Fill value substituted at places in the global array where
no values are obtained from the combine operation.
varatts If present, the attributes of the data variable(s) (used only
for log info, error checking and a header line in the output
file)
vecids If present, list of the variable ids in the output file (i.e.
numbers between 1 and the number of variables in the file)
and the size of the vector must match the last dimension of
values. If not present, the last dimension is considered as
a variable dimension and the ids are defined as 1, 2, up to
the size of the last dimension. In case values is a 2-D array
or varid is defined with a positive value, the argument is
not allowed since only one data variable is present.
nowet If present and positive, a land mask is applied. The num-
ber present then equals the number of dry points.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type for the combine operation (between 1
and 4). If not present, its value is set to iopt MPI comm gath.
1: blocking, standard send
2: blocking, synchronous send
23.11. ROUTINES COMBINING COMMUNICATION AND I/O OPERATIONS 989
Non-generic versions
combine write mod real 2d Combine/write a 2-D real model grid array
combine write mod real 3d Combine/write a 3-D real model grid array
combine write mod real 4d Combine/write a 4-D real model grid array
File
inout paral.f90
Type
Generic module subroutine
Purpose
Perform a combine operation on a open boundary array which is defined
globally, but whose values are distributed among different processes and
write the array to a file in standard COHERENS format. The array has
a rank between 1 and 3.
Arguments
realglb Local section of the open boundary array
filepars Derived type variable containing the attributes of the out-
put file
varid If positive, variable id of the array within the output file.
cnode Type of open boundary node (‘U’, ‘V’, ‘X’, ‘Y’)
varatts If present, the attributes of the data variable(s) (used only
for log info, error checking and a header line in the output
file)
990 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Non-generic versions
combine write obc real 1d Combine/write a 1-D real open boundary ar-
ray
combine write obc real 2d Combine/write a 2-D real open boundary ar-
ray
combine write obc real 3d Combine/write a 3-D real open boundary ar-
ray
File
inout paral.f90
Type
Generic module subroutine
Purpose
Combine local real data at a number of stations on the model grid
onto a global array and write the resulting array to a file in standard
COHERENS format. The array has a rank between 1 and 3.
23.11. ROUTINES COMBINING COMMUNICATION AND I/O OPERATIONS 991
Arguments
realloc Array with the local station data
filepars Derived type variable containing the attributes of the out-
put file
varid If positive, the id of the only variable written to the output
file (between 1 and the number of variables in the file).
If zero, the last dimension of realloc is considered as a
variable dimension.
maxstats Second dimension of the array lstatprocs
nostatsglb Total number (over all sub-domains) of stations within the
global array
nostatprocs Vector array with the number stations on each sub-domain
lstatprocs Index mapping array of the local station indices to the
ones in the global array
varatts If present, the attributes of the data variable(s) (used only
for log info, error checking and a header line in the output
file)
vecids If present, list of the variable ids in the output file (i.e.
numbers between 1 and the number of variables in the file)
and the size of the vector must match the last dimension
of realloc. If not present, the last dimension is considered
as a variable dimension and the ids are defined as 1, 2, up
to the size of the last dimension. In case realloc is a vector
or varid is defined with a positive value, the argument is
not allowed since only one data variable is present.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type for the combine operation (between 1
and 4). If not present, its value is set to iopt MPI comm gath.
1: blocking, standard send
2: blocking, synchronous send
3: non-blocking, standard send
4: non-blocking, synchronous send
Non-generic versions
combine write stats real 1d Combine/write a vector of station data
combine write stats real 2d Combine/write a 2-D array of station data
combine write stats real 3d Combine/write a 3-D array of station data
992 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
inout paral.f90
Type
Generic module subroutine
Purpose
Combine local real model sub-grid arrays into a global (sub-grid) array
and write the resulting array to a file in standard COHERENS format.
The array has a rank between 2 and 4.
Arguments
realloc Local model sub-grid array
filepars Derived type variable containing the attributes of the out-
put file
varid If positive, the id of the only variable written to the output
file (between 1 and the number of variables in the file).
If zero, the last dimension of realloc is considered as a
variable dimension.
ndimsglb Shape of the global array. Size of the vector must match
the rank of realloc.
limprocs Location of a local array section within the global array
by means of lower and upper index bounds.
rfill Fill value substituted at places in the global array where
no values are obtained from the combine operation.
23.11. ROUTINES COMBINING COMMUNICATION AND I/O OPERATIONS 993
Non-generic versions
combine write submod real 2d Combine/write a 2-D real sub-grid array
combine write submod real 3d Combine/write a 3-D real sub-grid array
combine write submod real 4d Combine/write a 4-D real sub-grid array
File
inout paral.f90
Type
Generic module subroutine
Purpose
Read and copy an integer or real scalar or array (upto rank 4) from a
file in standard COHERENS format and copy to all other processes.
Arguments
realloc Returned array
filepars Derived type variable containing the attributes of the in-
put file
varid If positive, the id of the only variable read from the input
file (between 1 and the number of variables in the file).
If zero, the last dimension of realloc is considered as a
variable dimension.
lbounds Lower array bounds. The size must match the rank of the
array.
ubounds Upper array bounds. The size must match the rank of the
array.
nhdist Halo sizes used for the distribute operation (WESN direc-
tions)
fdist Data are distributed only if this argument is set to .TRUE.
land mask A land mask is applied if set to .TRUE.
rfill Fill value substituted at places in the local array where no
values can be obtained from the distribute operation.
varatts If present, the attributes of the data variable(s) (used only
for log info and error checking)
23.12. INPUT/OUTPUT OPERATIONS 995
vecids If present, list of the variable ids in the input file (i.e.
numbers between 1 and the number of variables in the file)
and the size of the vector must match the last dimension of
realloc. If not present, the last dimension is considered as
a variable dimension and the ids are defined as 1, 2, up to
the size of the last dimension. In case realloc is a 2-D array
or varid is defined with a positive value, the argument is
not allowed since only one data variable is present.
maskvals Array of mask values used in case a land mask is applied
shared The global array is known to (read by) all processes if
.TRUE., to the master process only if .FALSE.. If not
present, its value is set to shared read.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type for the distribute operation (between
1 and 4). If not present, its value is set to iopt MPI comm scat.
1: blocking, standard send
2: blocking, synchronous send
3: non-blocking, standard send
4: non-blocking, synchronous send
Non-generic versions
read distribute mod real 2d Read/distribute a real 2-D array
read distribute mod real 3d Read/distribute a real 3-D array
read distribute mod real 4d Read/distribute a real 4-D array
• read glbatts mod: read the global attributes from a forcing file in stan-
dard COHERENS format
996 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
• read varatts mod: read the variable attributes from a forcing file in
standard COHERENS format
• read glbatts out: read the global attributes from a user output file in
standard COHERENS format
• read varatts out: read the variable attributes from a user output file in
standard COHERENS format
• write atts mod: write the global and variable attributes to a forcing file
in standard COHERENS format
• inout atts out: write the global and variable attributes to a user output
file in standard COHERENS format
close file
SUBROUTINE close file(iounit,ioform,filename,fildel)
LOGICAL, INTENT(IN), OPTIONAL :: fildel
CHARACTER (LEN=1), INTENT(IN) :: ioform
CHARACTER (LEN=*), INTENT(IN), OPTIONAL :: filename
INTEGER, INTENT(INOUT) :: iounit
File
inout routines.f90
Type
Module subroutine
Purpose
Close a file connection.
Arguments
iounit File unit number
ioform File format
‘A’ ASCII
‘U’ unformatted binary
‘D’ direct access binary (currently not used in the pro-
gram)
‘N’ netCDF
filename File name
fildel If present and .TRUE., the file is deleted after closing.
23.12. INPUT/OUTPUT OPERATIONS 997
close filepars
SUBROUTINE close filepars(filepars,fildel)
LOGICAL, INTENT(IN), OPTIONAL :: fildel
TYPE(FileParams), INTENT(INOUT) :: filepars
File
inout routines.f90
Type
Module subroutine
Purpose
Closes a file connection and resets file attributes.
Arguments
filepars File attributes
fildel If present and .TRUE., the file is deleted after closing.
get unit
FUNCTION get unit()
INTEGER :: get unit
File
inout routines.f90
Type
Module function
Purpose
Returns the smallest available unit number not connected to a file.
File
inout routines.f90
Type
Module subroutine
998 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Define and write the global, coordinate and variable attributes to a
user-defined output file.
Arguments
file type Output type
‘TS’ time series
‘TA’ time averaged
‘HR’ harmonic residuals
‘HA’ harmonic amplitudes
‘HP’ harmonic phases
‘HE’ tidal ellipse parameters
monitor files
SUBROUTINE monitor files
File
inout routines.f90
Type
Module subroutine
Purpose
Set some parameters for monitoring, open and close the log, error and
warning files.
open file
SUBROUTINE open file(iounit,filename,iotype,ioform,lenrec)
CHARACTER (LEN=*), INTENT(IN) :: filename, ioform, iotype
INTEGER, INTENT(INOUT) :: iounit
INTEGER, INTENT(IN), OPTIONAL :: lenrec
File
inout routines.f90
Type
Module subroutine
23.12. INPUT/OUTPUT OPERATIONS 999
Purpose
Open a file connection.
Arguments
iounit Returned file unit number
filename File name
iotype Type of file access
‘IN’ for reading only
‘OUT’ for writing only
‘INOUT’ for reading and writing
ioform File format
‘A’ ASCII
‘U’ unformatted binary
‘D’ direct access binary (currently not used in the pro-
gram)
‘N’ netCDF
lenrec Length of a data record in case the file is opened for direct
access
open filepars
SUBROUTINE open filepars(filepars,iotype)
CHARACTER (LEN=*), INTENT(IN), OPTIONAL :: iotype
TYPE(FileParams), INTENT(INOUT) :: filepars
File
inout routines.f90
Type
Module subroutine
Purpose
Open a file connection and set file attributes.
Arguments
filepars File attributes
iotype If present, the file access (‘IN’, ‘OUT’, ‘INOUT’). Other-
wise, the access is defined through the status attribute of
filepars.
1000 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
inout routines.f90
Type
Module subroutine
Purpose
Read the global attributes of a standard forcing file. In case of a se-
quential file, the file pointer must be located at the start of the data
record.
Arguments
filepars File attributes
File
inout routines.f90
Type
Module subroutine
Purpose
Read the global attributes of a user output file. In case of a sequential
file, the file pointer must be located at the start of the data record.
Arguments
filepars Attributes of the user output file
gridpars Attributes of the file containing the output grid (equal to
filepars if outgpars%grid file=.FALSE.)
outgpars Attributes of the output grid
23.12. INPUT/OUTPUT OPERATIONS 1001
File
inout routines.f90
Type
Module subroutine
Purpose
Read the global and variable attributes and the coordinate data of a
user output file without storing the data. In case the file is opened for
sequential access, the file pointer is located at the first output time on
exit. The routine should not be called in case of a netCDF file.
Arguments
filepars Attributes of the user output file
File
inout routines.f90
Type
Module subroutine
Purpose
Read the names of data stations from a user output file. In case of se-
quential access, the file pointer must be located at the correct position.
Arguments
filepars Attributes of the user output file
station names Returned station names
nostats Number of stations
1002 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
read submod
SUBROUTINE read submod(realsub,filepars,varid,&
& land mask,varatts,vecids,maskvals)
LOGICAL, INTENT(IN) :: land mask
INTEGER, INTENT(IN) :: varid
TYPE(FileParams), INTENT(IN) :: filepars
LOGICAL, INTENT(IN), OPTIONAL, DIMENSION(:,:) :: maskvals
INTEGER, INTENT(IN), OPTIONAL, DIMENSION(:) :: vecids
REAL, INTENT(INOUT), DIMENSION(:,:[,:[,:)]]) :: realsub
TYPE (VariableAtts), INTENT(IN), OPTIONAL, DIMENSION(:) :: varatts
File
inout routines.f90
Type
Generic module subroutine
Purpose
Read a subgrid section of a model array defined on the global grid from
a file in COHERENS standard format. In case of a sequential file, the
file pointer must be located at the appropriate position.
Arguments
realsub Returned sub-grid array
filepars Derived type variable containing the attributes of the in-
put file
varid If positive, the id of the only variable read from the input
file (between 1 and the number of variables in the file).
If zero, the last dimension of realsub is considered as a
variable dimension.
land mask A (horizontal) land mask is applied if set to .TRUE..
varatts If present, the attributes of the data variable(s) (used only
for log info and error checking).
vecids If present, list of the variable ids in the input file (i.e.
numbers between 1 and the number of variables in the file)
and the size of the vector must match the last dimension of
realsub. If not present, the last dimension is considered as
a variable dimension and the ids are defined as 1, 2, up to
the size of the last dimension. In case realsub is a 2-D array
23.12. INPUT/OUTPUT OPERATIONS 1003
Non-generic versions
read submod real 2d Read a real 2-D sub-grid array
read submod real 3d Read a real 3-D sub-grid array
read submod real 4d Read a real 4-D sub-grid array
read time
SUBROUTINE read time(time,filepars,timerec)
CHARACTER (LEN=lentime) or REAL, INTENT(OUT) :: time
INTEGER, INTENT(IN), OPTIONAL :: timerec
TYPE(FileParams), INTENT(INOUT) :: filepars
File
inout routines.f90
Type
Generic module subroutine
Purpose
Read a time record from a file in standard COHERENS format.
Arguments
time Returned time either in the form of an absolute date/time
in string format or a relative time in numerical format.
filepars Derived type variable containing the attributes of the in-
put file
timerec If not present, the timerec global attribute is increased
by one. The iostat global attribute is set to 1 or 3 for a
sequential read or to 1, 2 or 3 in case of a non-sequential
read.
Non-generic versions
read time char Read the time in string format.
read time real Read the time in (real) numeric format.
1004 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
inout routines.f90
Type
Module subroutine
Purpose
Read the variable attributes from a forcing file in standard COHERENS
format. An information file is written if requested. In case of a sequen-
tial file, the file pointer must be located at the appropriate position.
Arguments
filepars Attributes of the input file
varatts If present, returned variable attributes. Otherwise the at-
tributes are read but not stored.
numvars Number of variables
File
inout routines.f90
Type
Module subroutine
Purpose
Read the variable attributes from a user output file in standard COHERENS
format. The routine can be called a first time to read the attributes
23.12. INPUT/OUTPUT OPERATIONS 1005
Arguments
filepars Attributes of the input file
varatts Returned variable attributes
novars Number of coordinate or data variables
bufid In case of a netCDF file, the netCDF variable id of the first
variable equals bufid+1. Otherwise, its value is irrelevant.
vector Reads the vector attribute of the variables (if needed).
read vars
SUBROUTINE read vars(values,filepars,varid,varatts,vecids)
INTEGER, INTENT(IN) :: varid
TYPE (FileParams), INTENT(IN) :: filepars
INTEGER, INTENT(IN), OPTIONAL, DIMENSION(:) :: vecids
INTEGER or REAL, INTENT(OUT) [, DIMENSION(:[,:[,:[,:]]])] :: values
TYPE (VariableAtts), INTENT(IN), OPTIONAL, DIMENSION(:) :: varatts
File
inout routines.f90
Type
Generic module subroutine
Purpose
Read scalar or array data from a file in standard COHERENS format.
In case of a sequential file, the file pointer must be located at the
appropriate position.
Arguments
values Returned scalar or array data
filepars Derived type variable containing the attributes of the in-
put file
1006 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
varid If positive, the id of the only variable read from the input
file (between 1 and the number of variables in the file). If
zero, the last dimension of values is considered as a variable
dimension.
varatts If present, the attributes of the data variable(s) (used only
for log info and error checking)
vecids If present, list of the variable ids in the input file (i.e.
numbers between 1 and the number of variables in the file)
and the size of the vector must match the last dimension
of values. If not present, the last dimension is considered
as a variable dimension and the ids are defined as 1, 2, up
to the size of the last dimension. In case values is a scalar
or varid is defined with a positive value, the argument is
not allowed since only one data variable is present.
Non-generic versions
read vars int 0d Integer scalar
read vars int 1d Integer vector
read vars int 2d Integer 2-D array
read vars int 3d Integer 3-D array
read vars int 4d Integer 4-D array
read vars real 0d Real scalar
read vars real 1d Real vector
read vars real 2d Real 2-D array
read vars real 3d Real 3-D array
read vars real 4d Real 4-D array
File
inout routines.f90
Type
Module subroutine
23.12. INPUT/OUTPUT OPERATIONS 1007
Purpose
Write all global and variable (coordinate and data) attributes to a
forcing file in standard COHERENS format.
Arguments
filepars Attributes of the output file
varatts Variable attributes
numvars Number of coordinate plus data variables
File
inout routines.f90
Type
Module subroutine
Purpose
Write the info file associated with a forcing file in standard COHERENS
format.
Arguments
filepars Attributes of the forcing file
varatts Variable attributes
numvars Number of (coordinate plus data) variables. Must be zero
if varatts is not present.
write time
SUBROUTINE write time(time,filepars,timerec)
CHARACTER (LEN=lentime) or REAL, INTENT(IN) :: time
INTEGER, INTENT(IN), OPTIONAL :: timerec
TYPE(FileParams), INTENT(INOUT) :: filepars
1008 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
inout routines.f90
Type
Generic module subroutine
Purpose
Write a time record to a file in standard COHERENS format.
Arguments
time Time record either in the form of an absolute date/time
in string format or a relative time in numerical format.
filepars Derived type variable containing the attributes of the in-
put file
timerec Time record for output to a netCDF file. If not present,
the time record attribute is increased by one and used as
the output time record.
Non-generic versions
write time char Write the time in string format.
write time real Write the time in (real) numeric format.
write vars
SUBROUTINE write vars(values,filepars,varid,varatts,vecids)
INTEGER, INTENT(IN) :: varid
TYPE (FileParams), INTENT(IN) :: filepars
INTEGER, INTENT(IN), OPTIONAL, DIMENSION(:) :: vecids
INTEGER or REAL, INTENT(IN)&
& [, DIMENSION(:[,:[,:[,:]]])] :: values
TYPE (VariableAtts), INTENT(IN), OPTIONAL, DIMENSION(:) :: varatts
File
inout routines.f90
Type
Generic module subroutine
Purpose
Write scalar or array data to a file in standard COHERENS format.
Arguments
23.13. LIBRARY OF MATHEMATICAL ROUTINES 1009
Non-generic versions
write vars int 0d Integer scalar
write vars int 1d Integer vector
write vars int 2d Integer 2-D array
write vars int 3d Integer 3-D array
write vars int 4d Integer 4-D array
write vars real 0d Real scalar
write vars real 1d Real vector
write vars real 2d Real 2-D array
write vars real 3d Real 3-D array
write vars real 4d Real 4-D array
File
math library.f90
Type
Module function
Purpose
Find the root of the function func using Brent’s method. The initial
guess is assumed to be in the interval [x1,x2].
Reference
Press et al. (1992)
Arguments
func Input function
varname Function name
ipars List of integer parameters used in the function call.
rpars List of real parameters used in the function call.
noint Size of the vector ipars which may be zero
noreal Size of the vector rpars which may be zero
x1 Lower bound of the initial interval
x2 Upper bound of the initial interval
23.13. LIBRARY OF MATHEMATICAL ROUTINES 1011
complex polar
SUBROUTINE complex polar(xreal,ximag,xamp,xpha,maskvals,outflag)
REAL, INTENT(IN), OPTIONAL :: outflag
LOGICAL, INTENT(IN), OPTIONAL, DIMENSION(:,:) :: maskvals
REAL, INTENT(IN) [, DIMENSION(:[,:])] :: ximag, xreal
REAL, INTENT(OUT), OPTIONAL [, DIMENSION(:[,:])] :: xamp, xpha
File
math library.f90
Type
Generic module subroutine
Purpose
Returns the aplitude and phase of a complex scalar, vector or 2-D array.
Arguments
xreal Real part of the complex scalar or array
ximag Imaginary part of the complex scalar or array
xamp If present, returned amplitude of the complex scalar or
array
xpha If present, returned phase of the complex scalar or array
[radians]
maskvals If present, 2-D mask array to exclude dry points. The
argument is only allowed for 2-D arrays.
outflag Output flag for invalid points, if present. Equal to real min
otherwise. The argument is only used when maskvals is
present.
1012 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Non-generic versions
complex polar 0d Complex scalars
complex polar 1d Complex vector
complex polar 2d Complex 2-D array
File
math library.f90
Type
Module function
Purpose
Returns the square root of the elements of a complex (4-D) array.
Reference
Press et al. (1992)
Arguments
z Complex input array
ndims Shape of the complex array
mask A mask is applied on the first two dimensions to exclude
invalid (land) points if set to .TRUE.
maskvals Values of the land mask. Must be present if mask =
.TRUE.
outflag Flag for land values. If not present, the flag is set to
real min
23.13. LIBRARY OF MATHEMATICAL ROUTINES 1013
File
math library.f90
Type
Module function
Purpose
Returns the square root of a complex scalar.
Reference
Press et al. (1992)
Arguments
z Complex input scalar
poly root
SUBROUTINE poly root(a,x,m,ierr)
INTEGER, INTENT(IN) :: m
INTEGER, INTENT(OUT) :: ierr
COMPLEX, INTENT(INOUT) :: x
REAL, INTENT(IN), DIMENSION(m+1) :: a
File
math library.f90
Type
Module subroutine
Purpose
Find the root of a polynomial with initial guess x using Laguerre’s
method.
Reference
Press et al. (1992)
Arguments
1014 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
math library.f90
Type
Module subroutine
Purpose
Returns the roots of a series second degree equations.
Reference
Press et al. (1992)
Arguments
coef Coefficients of the quadratic equation. The coefficients of
the zero, first and second power are given by respectively
the first, second and third index of the last dimension.
root1 First root
root2 Second root
23.14. OUTPUT DATA FOR STANDARD VARIABLES 1015
File
math library.f90
Type
Module subroutine
Purpose
Returns the roots of a second degree equation.
Reference
Press et al. (1992)
Arguments
coef The coefficients of the zero, first and second power in the
quadratic equation are given by respectively the first, sec-
ond and third index.
root1 First root
root2 Second root
outflag In the case that the solutions are complex, the roots are
set to this value.
• The routines replace the user-defined usrdef *vals routines if the key ids
of the output variables have been supplied by the user as part of the
setup.
File
model output.f90
Type
Module subroutine
Purpose
Define 0-D output data.
Arguments
outdat Returned output data
novars Number of output variables
outvars Attributes of the output variables (if ivarid is not defined)
ivarid Variables’s key ids (if outvars is not defined)
oopt Optional output operator applied for each variable. Al-
lowed values are:
oopt null no operator applied
oopt mean volume (3-D variable) or surface (2-D variable)
averaged value
oopt max volume (3-D variable) or surface (2-D variable)
maximum value
oopt min volume (3-D variable) or surface (2-D variable)
minimum value
23.14. OUTPUT DATA FOR STANDARD VARIABLES 1017
File
model output.f90
Type
Module subroutine
Purpose
Define 2-D output data at a given location.
Arguments
outdat Returned output data
i X-index of the output location
j Y-index of the output location
novars Number of output variables
outvars Attributes of the output variables (if ivarid is not defined)
ivarid Variables’s key ids (if outvars is not defined)
oopt Optional output operator applied for each variable. Al-
lowed values are:
oopt null no operator applied
oopt mean vertically averaged value (in case ivarid repre-
sents a 3-D variable)
oopt max maximum value over the vertical (in case ivarid
represents a 3-D variable)
oopt min minimum value over the vertical (in case ivarid
represents a 3-D variable)
oopt klev value at a vertical level (in case ivarid repre-
sents a 3-D variable)
1018 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
model output.f90
Type
Module subroutine
Purpose
Define 2-D output data at a given location.
Arguments
outdat Returned output data
i X-index of the output location
j Y-index of the output location
k vertical index of the output location
novars Number of output variables
outvars Attributes of the output variables (if ivarid is not defined)
ivarid Variables’s key ids (if outvars is not defined)
node defines the vertical node (’C’ (default if not present) or ’W’
where a W-node quantity is evaluated (see Section 16.1.1.1
for details)
23.15. STANDARD ATTRIBUTES FOR VARIABLES AND FORCING FILES 1019
File
modvars routines.f90
Type
Module subroutine
Purpose
Returns attributes of a model array variable given its variable key id.
Arguments
varid Variable key id
f90 name If present, returned FORTRAN 90 name attribute
long name If present, returned long name attribute
units If present, returned units attribute
node If present, returned grid node where the variable is defined
on the model grid
vector name If present, returned vector name attribute
data type If present, returned data type attribute
nodim If present, returned array rank
shape If present, returned array shape
dom dims If present, returned array shape without halo
halo size If present, returned halo sizes
1020 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
modvars routines.f90
Type
Module subroutine
Purpose
Define the global attributes of a forcing file.
Arguments
iddesc Forcing file key id
ifil File number of the forcing file
iotype I/O type of the forcing file
1: Input file
2: Output file
numvars Currently not used
File
modvars routines.f90
Type
Module subroutine
Purpose
Define the default name of a forcing file. The result is stored in the
filename attribute if no name has been defined by the user.
Arguments
23.15. STANDARD ATTRIBUTES FOR VARIABLES AND FORCING FILES 1021
File
modvars routines.f90
Type
Module subroutine
Purpose
Define the variable attributes of a forcing file.
Arguments
iddesc Forcing file key id
ifil File number of the forcing file
iotype I/O type of the forcing file
1: Input file
2: Output file
varatts Returned variable attributes
novars Number of data (excluding coordinate) variables in the
data file
noprofsd Number of open boundary data profiles in each data file.
The parameter is only used if the forcing contains speci-
fiers for 3-D open boundary conditions (iddesc = io 3uvobc,
io salobc or io tmpobc and ifil = 1).
1022 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
nla library.F90
Type
Module subroutine
Purpose
Perform a Cholesky decomposition on a symmetric positive definite
matrix.
23.16. LIBRARY ROUTINES FOR LINEAR ALGEBRA 1023
Reference
Press et al. (1992)
Arguments
a Symmetric, positive-definite matrix on input. On output,
the Cholesky matrix is returned in the lower triangular
and diagonal part.
n Physical dimensions of the square matrix a
ndim Array dimensions of the square matrix a
varname FORTRAN name of the variable a
ierr Returned error code
0: No error occurred
1: Error occurred
info Writes info to the log file if .TRUE.
cholesky solve
SUBROUTINE cholesky solve(a,b,n,ndim,varname,info)
LOGICAL, INTENT(IN) :: info
CHARACTER (LEN=*), INTENT(IN) :: varname
INTEGER, INTENT(IN) :: n, ndim
REAL, INTENT(INOUT), DIMENSION(ndim) :: b
REAL, INTENT(IN), DIMENSION(ndim,ndim) :: a
File
nla library.F90
Type
Module subroutine
Purpose
Solve a linear system of equations using Cholesky decomposition. The
coefficient matrix is obtained from a previous call to cholesky decomp.
Reference
Press et al. (1992)
Arguments
a Cholesky coefficient matrix
1024 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
LU decomp
SUBROUTINE LU decomp(a,indx,n,ndim,varname,ierr,info)
LOGICAL, INTENT(IN) :: info
CHARACTER (LEN=*), INTENT(IN) :: varname
INTEGER, INTENT(IN) :: n, ndim
INTEGER, INTENT(OUT) :: ierr
INTEGER, INTENT(OUT), DIMENSION(ndim) :: indx
REAL, INTENT(INOUT), DIMENSION(ndim,ndim) :: a
File
nla library.F90
Type
Module subroutine
Purpose
Decompose the matrix a into a lower (L) and upper (U) triangular part.
Reference
Press et al. (1992)
Arguments
a On input, the matrix to be decomposed. On output, L is
substituted below the diagonal, U at and above the diag-
onal.
indx Returned vector recording the row permutation effected by
partial pivoting. The vector must be given as argument to
a subsequent call to LU solve
n Physical dimensions of the square matrix a
ndim Array dimensions of the square matrix a
23.16. LIBRARY ROUTINES FOR LINEAR ALGEBRA 1025
LU solve
SUBROUTINE LU decomp(a,indx,b,n,ndim,varname,info)
LOGICAL, INTENT(IN) :: info
CHARACTER (LEN=*), INTENT(IN) :: varname
INTEGER, INTENT(IN) :: n, ndim
INTEGER, INTENT(IN), DIMENSION(ndim) :: indx
REAL, INTENT(INOUT), DIMENSION(ndim) :: b
REAL, INTENT(IN), DIMENSION(ndim,ndim) :: a
File
nla library.F90
Type
Module subroutine
Purpose
Solve a linear system of equations using LU decomposition
Reference
Press et al. (1992)
Arguments
a LU-decomposed coefficient matrix returned from a previ-
ous call to LU decomp
indx Vector recording the row permutation effected by partial
pivoting as returned from a previous call to LU decomp
b Right hand side of the linear system on input. Solution
vector on output.
n Number of linear equations (physical dimensions of the
square matrix a and size of the vector b)
ndim Array dimensions of the square matrix a and size of the
vector b
1026 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
svd decomp
SUBROUTINE svd decomp(a,w,v,m,n,varname,ierr,info)
LOGICAL, INTENT(IN) :: info
CHARACTER (LEN=*), INTENT(IN) :: varname
INTEGER, INTENT(IN) :: m,n
INTEGER, INTENT(OUT) :: ierr
REAL, INTENT(OUT), DIMENSION(n) :: w
REAL, INTENT(INOUT), DIMENSION(m,n) :: a
REAL, INTENT(OUT), DIMENSION(n,n) :: v
File
nla library.F90
Type
Module subroutine
Purpose
Performs a singular value decomposition on the matrix a, i.e. a = udt v
where u, v are unitary matrices and d a diagonal matrix. The diagonal
elements of w are the singular values of a.
Reference
Press et al. (1992)
Arguments
a Matrix to be decomposed on input, unitary matrix u on
output
w Returned vector of singular values (diagonal elements of
the diagonal matrix d). If n>m, the last n-m elements are
zero.
v Returned unitary matrix v
m Number of rows in a
n Number of columns in a
varname FORTRAN name of the variable a
ierr Returned error code
0: No error occurred
23.16. LIBRARY ROUTINES FOR LINEAR ALGEBRA 1027
1: Error occurred
info Writes info to the log file if .TRUE.
symm eigen
SUBROUTINE symm eigen(a,d,n,vectors,varname,ierr,info)
LOGICAL, INTENT(IN) :: info, vectors
CHARACTER (LEN=*), INTENT(IN) :: varname
INTEGER, INTENT(IN) :: n
INTEGER, INTENT(OUT) :: ierr
REAL, INTENT(OUT), DIMENSION(n) :: d
REAL, INTENT(INOUT), DIMENSION(n,n) :: a
File
nla library.F90
Type
Module subroutine
Purpose
Returns the eigenvalues and eigenvectors of a real symmetric matrix.
Reference
Press et al. (1992)
Arguments
a Real symmetric matrix on input. On output, the eigen-
vectors are stored in the columns of a if vectors is .TRUE..
If vectors is .FALSE., the matrix a is modified as well but
no longer contains useful information.
d Vector of eigenvalues in descending order
n Dimensions of the square matrix a
vectors Returns the eigenvectors if .TRUE.
varname FORTRAN name of the variable a
ierr Returned error code
0: No error occurred
1: Error occurred
info Writes info to the log file if .TRUE.
1028 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
tridiag reduce
SUBROUTINE tridiag reduce(a,d,e,n,vectors,varname,info)
LOGICAL, INTENT(IN) :: info
CHARACTER (LEN=*), INTENT(IN) :: varname
LOGICAL, INTENT(IN) :: vectors
INTEGER, INTENT(IN) :: n
REAL, INTENT(OUT), DIMENSION(n) :: d, e
REAL, INTENT(INOUT), DIMENSION(n,n) :: a
File
nla library.F90
Type
Module subroutine
Purpose
Performs a Householder reduction to a tridiagonal form on a real sym-
metric matrix.
Reference
Press et al. (1992)
Arguments
a Real symmetric matrix on input. On output, the orthog-
onal matrix effecting the transformation.
d Diagonal elements of the output tridiagonal matrix
e Off-diagonal elements of the output tridiagonal matrix (e(1)=0)
n Dimensions of the square matrix a
vectors No eigenvectors are needed if .FALSE.
varname FORTRAN name of the variable a
info Writes info to the log file if .TRUE.
tridiag vert
SUBROUTINE tridiag vert(tridcf,psi,nhdims,nzdim,novars,cnode)
CHARACTER (LEN=lennode), INTENT(IN) :: cnode
INTEGER, INTENT(IN) :: novars, nzdim
INTEGER, INTENT(IN), DIMENSION(4) :: nhdims
REAL, INTENT(IN), DIMENSION(ncloc,nrloc,nzdim,4,novars) :: tridcf
REAL, INTENT(INOUT), DIMENSION(1-nhdims(1):ncloc+nhdims(2),&
23.16. LIBRARY ROUTINES FOR LINEAR ALGEBRA 1029
& 1-nhdims(3):nrloc+nhdims(4),&
& nzdim,novars) :: psi
File
nla library.F90
Type
Module subroutine
Purpose
Update a 3-D variable or variables in time by solving a system of tridi-
agonal equations on each grid point in the horizontal.
Reference
Press et al. (1992)
Arguments
tridcf The first three dimensions correspond to respectively the
X-, Y- and vertical directions of the model grid. Index
elements 1, 2, 3 and 4 in the last dimension represent res-
pectively the coefficient matrices A, B, C, D in equations
(5.302).
psi Returned updated value of psi
nhdims Halo sizes of the model grid array psi (WESN directions)
nzdim Vertical array dimension
novars Number of model variables stored in psi
cnode Nodal type of the variables(s) psi
tridiag vert 1d
SUBROUTINE tridiag vert(tridcf,psi,nzdim,novars,info)
LOGICAL, INTENT(IN) :: info
INTEGER, INTENT(IN) :: novars, nzdim
REAL, INTENT(IN), DIMENSION(nzdim,4,novars) :: tridcf
REAL, INTENT(INOUT), DIMENSION(nzdim,novars) :: psi
File
nla library.F90
Type
Module subroutine
1030 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Update a variable or variables in time by solving a system of tridiagonal
equations in the vertical.
Reference
Press et al. (1992)
Arguments
tridcf The size of the first dimension represents the number of
vertical points. Index elements 1, 2, 3 and 4 in the second
dimension represents respectively the coefficient matrices
A, B, C, D in equations (5.302). The size of the third
dimension is the number of variables for which the linear
system has to be solved.
psi Returned updated value of psi
nzdim Vertical array dimension
novars Number of model variables stored in psi
info Writes log info if set to .TRUE.
File
paral comms.f90
Type
Generic module subroutine
Purpose
Performs a collect operation, i.e. copies local arrays of the same shape
23.17. PARALLEL COMMUNICATIONS 1031
into one globally defined array. The index of the last dimension corre-
sponds to the process number of each local array.
Reference
Section 9.4.3
Arguments
locvals Local scalar array. Can be of type INTEGER, LOGICAL,
REAL. Rank is between 0 and 2 for LOGICAL logical arrays
and between 0 and 4 otherwise.
procvals Array which collects the contributions of all local arrays.
The array is globally defined. Rank is between 1 and 3 for
LOGICAL logical arrays and between 1 and 5 otherwise.
noprocs Number of involved processes
ivarid Variable key id (used for log info only, zero for undefined)
comm MPI communicator. If not present, its value is comm work.
commtype Communication type for the collect operation (between 1
and 5). If not present, its value is set to iopt MPI comm all
if iopt MPI comm coll=0 or to 5 otherwise.
1: blocking, standard send
2: blocking, synchronous send
3: non-blocking, standard send
4: non-blocking, synchronous send
5: collective communication
Non-generic versions
collect vars int 0d Integer scalar
collect vars int 1d Integer vector
collect vars int 2d Integer 2-D array
collect vars int 3d Integer 3-D array
collect vars int 4d Integer 4-D array
collect vars log 0d Logical scalar
collect vars log 1d Logical vector
collect vars log 2d Logical 2-D array
collect vars real 0d Real scalar
collect vars real 1d Real vector
1032 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
combine mod
SUBROUTINE combine mod(glbvals,locvals,lbounds,ivarid,&
& fill,idroot,comm,commtype,commall)
LOGICAL, INTENT(IN), OPTIONAL :: commall
INTEGER, LOGICAL or REAL, INTENT(IN) :: fill
INTEGER, INTENT(IN) :: ivarid
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
INTEGER, INTENT(IN), DIMENSION(:) :: lbounds
INTEGER, LOGICAL or REAL, INTENT(OUT), &
& DIMENSION(lbounds(1):,lbounds(2)&
& [,lbounds(3):[,lbounds(4):]]) :: glbvals
INTEGER, LOGICAL or REAL, INTENT(IN), &
& DIMENSION(lbounds(1):,lbounds(2)&
& [,lbounds(3):[,lbounds(4):]]) :: locvals
File
paral comms.f90
Type
Generic module subroutine
Purpose
Performs a combine or combine-all operation on local model grid arrays.
Reference
Section 9.4.2
Arguments
glbvals Global array. Can be of type INTEGER, LOGICAL, REAL.
Rank is 2 for LOGICAL arrays and between 2 and 4 other-
wise.
locvals Local array. Type and rank is the same as glbvals.
lbounds Lower bounds of the local and global arrays. Size must be
equal to the rank of glbvals and locvals.
ivarid Variable key id (used for log info only, zero for undefined)
23.17. PARALLEL COMMUNICATIONS 1033
fill Fill value for elements in the global array outside all lo-
cal domain grids. Type must be the same as glbvals and
locvals.
idroot Root process where the global array is defined in case of
a combine operation. If not present, the root equals the
master process.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type for the combine operation (between 1
and 4). If not present, its value is set to iopt MPI comm all
for combine-all operations or iopt MPI comm gath other-
wise.
1: blocking, standard send
2: blocking, synchronous send
3: non-blocking, standard send
4: non-blocking, synchronous send
commall A combine-all operation is performed only if present and
set to .TRUE.
Non-generic versions
combine mod int 2d Integer 2-D array
combine mod int 3d Integer 3-D array
combine mod int 4d Integer 4-D array
combine mod log 2d Logical 2-D array
combine mod real 2d Real 2-D array
combine mod real 3d Real 3-D array
combine mod real 4d Real 4-D array
combine obc
SUBROUTINE combine obc(glbvals,cnode,ivarid,idroot,&
& comm,commtype,commall)
LOGICAL, INTENT(IN), OPTIONAL :: commall
CHARACTER (LEN=lennode), INTENT(IN) :: cnode
INTEGER, INTENT(IN) :: ivarid
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
INTEGER, LOGICAL or REAL, INTENT(INOUT),&
& DIMENSION(:[,:[,:]]) :: glbvals
1034 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
paral comms.f90
Type
Generic module subroutine
Purpose
Combines the values of local index elements into a global open boun-
dary array. The result may or may not be available on all processes.
Arguments
glbvals Global array. Can be of type INTEGER, LOGICAL, REAL.
Rank is 1 for LOGICAL arrays and between 1 and 3 other-
wise.
cnode Nodal type of the open boundary array (‘U’, ‘V’, ‘X’, ‘Y’)
ivarid Variable key id (used for log info only, zero for undefined)
idroot Root process where the global array is defined in case of
a combine operation. If not present, the root equals the
master process.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type for the combine operation (between 1
and 4). If not present, its value is set to iopt MPI comm all
for combine-all operations or iopt MPI comm gath other-
wise.
1: blocking, standard send
2: blocking, synchronous send
3: non-blocking, standard send
4: non-blocking, synchronous send
commall A combine-all operation is performed only if present and
set to .TRUE.
Non-generic versions
combine obc int 1d Integer vector
combine obc int 2d Integer 2-D array
combine obc int 3d Integer 3-D array
combine obc log 1d Logical vector
combine obc real 1d Real vector
23.17. PARALLEL COMMUNICATIONS 1035
combine stats
SUBROUTINE combine stats(realglb,realloc,maxstats,nostatprocs,&
& lstatprocs,ivarid,idroot,comm,commtype)
INTEGER, INTENT(IN) :: ivarid, maxstats
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
INTEGER, INTENT(IN), DIMENSION(nprocs) :: nostatprocs
INTEGER, INTENT(IN), DIMENSION(nprocs,maxstats) :: lstatprocs
REAL, INTENT(OUT), DIMENSION(:[,:[,:]]) :: realglb
REAL, INTENT(IN), DIMENSION(:[,:[,:]]) :: realloc
File
paral comms.f90
Type
Generic module subroutine
Purpose
Combine local station data into a global array on the root process.
Reference
Section 9.5
Arguments
realglb Global array. Rank is between 1 and 3.
realloc Local array. Rank is the same as realglb.
maxstats Second dimension of array lstatprocs
nostatprocs Number of local data stations
lstatprocs Index mapping array
ivarid Variable key id (used for log info only, zero for undefined)
idroot Root process where the global array is defined. If not
present, the root equals the master process.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type for the combine operation (between 1
and 4). If not present, its value is set to iopt MPI comm gath.
1: blocking, standard send
1036 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Non-generic versions
combine stats real 1d Real vector
combine stats real 2d Real 2-D array
combine stats real 3d Real 3-D array
combine submod
SUBROUTINE combine submod(realglb,realloc,limprocs,ivarid,rfill,&
& idroot,comm,commtype)
INTEGER, INTENT(IN) :: ivarid
INTEGER, INTENT(IN), DIMENSION(2,2,nprocs) :: limprocs
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
REAL, INTENT(IN) :: rfill
REAL, INTENT(OUT), DIMENSION(:,:[,:[,:]]) :: realglb
REAL, INTENT(IN), DIMENSION(:,:[,:[,:]]) :: realloc
File
paral comms.f90
Type
Generic module subroutine
Purpose
Combine local sub-grid model arrays into a global array on the root
process.
Reference
Section 9.4.2
Arguments
realglb Global array. Rank is between 2 and 4.
realloc Local array. Rank is the same as realglb.
limprocs Start/end indices in the X- and Y-direction of the local
array section within the global array
ivarid Variable key id (used for log info only, zero for undefined)
23.17. PARALLEL COMMUNICATIONS 1037
rfill Fill values for elements in the global array with no corres-
ponding element in a local array
idroot Root process where the global array is defined in case of
a combine operation. If not present, the root equals the
master process.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type for the combine operation (between 1
and 4). If not present, its value is set to iopt MPI comm gath.
1: blocking, standard send
2: blocking, synchronous send
3: non-blocking, standard send
4: non-blocking, synchronous send
Non-generic versions
combine submod real 2d Real 2-D array
combine submod real 3d Real 3-D array
combine submod real 4d Real 4-D array
copy chars
SUBROUTINE copy chars(chardat,lenstr,ivarid,idroot,comm,commtype)
INTEGER, INTENT(IN) :: ivarid, lenstr
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
CHARACTER (LEN=lenstr), INTENT(INOUT) &
& [, DIMENSION(:[,:[,:[,:]]])] :: chardat
File
paral comms.f90
Type
Generic module subroutine
Purpose
Copies a scalar string or an array of strings from the root to all other
processes.
Reference
Section 9.4.2
Arguments
1038 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Non-generic versions
copy chars 0d Character string
copy chars 1d Character string vector
copy chars 2d Character string 2-D array
copy chars 3d Character string 3-D array
copy chars 4d Character string 4-D array
copy vars
SUBROUTINE copy vars(values,ivarid,idroot,comm,commtype)
INTEGER, INTENT(IN) :: ivarid
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
INTEGER, LOGICAL or REAL, INTENT(INOUT) &
& [, DIMENSION(:[,:[,:[,:]]])] :: values
File
paral comms.f90
Type
Generic module subroutine
23.17. PARALLEL COMMUNICATIONS 1039
Purpose
Copies an integer, logical or real scalar or array data from the root to
all other processes.
Reference
Section 9.4.2
Arguments
values Scalar or array data to be copied. Rank is between 0 and
4.
ivarid Variable key id (used for log info only, zero for undefined)
idroot Root process where the global array is defined. If not
present, the root equals the master process.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type for the copy operation (between 1
and 5). If not present, its value is set to iopt MPI comm scat
if iopt MPI comm coll=0 or to 5 otherwise.
1: blocking, standard send
2: blocking, synchronous send
3: non-blocking, standard send
4: non-blocking, synchronous send
5: collective communication
Non-generic versions
copy vars int 0d Integer scalar
copy vars int 1d Integer vector
copy vars int 2d Integer 2-D array
copy vars int 3d Integer 3-D array
copy vars int 4d Integer 4-D array
copy vars log 0d Integer scalar
copy vars log 1d Logical vector
copy vars log 2d Logical 2-D array
copy vars log 3d Logical 3-D array
copy vars log 4d Logical 4-D array
copy vars real 0d Real scalar
copy vars real 1d Real vector
1040 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
distribute mod
SUBROUTINE distribute mod(glbvals,locvals,lbounds,nhdist,&
& ivarid,fill,shared,idroot,comm,commtype)
LOGICAL, INTENT(IN), OPTIONAL :: shared
INTEGER, LOGICAL or REAL, INTENT(IN) :: fill
INTEGER, INTENT(IN) :: ivarid
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
INTEGER, INTENT(IN), DIMENSION(:) :: lbounds
INTEGER, INTENT(IN), DIMENSION(4) :: nhdist
INTEGER, LOGICAL or REAL, INTENT(IN), DIMENSION(lbounds(1):,lbounds(2):&
& [,lbounds(3):[,lbounds(4):]]) :: glbvals
INTEGER, LOGICAL or REAL, INTENT(IN), DIMENSION(lbounds(1):,lbounds(2):&
& [,lbounds(3):[,lbounds(4):]]) :: locvals
File
paral comms.f90
Type
Generic module subroutine
Purpose
Distributes an integer, logical or real model grid array from the root to
all other processes.
Reference
Section 9.4.2
Arguments
glbvals Global integer, logical or real model grid array to be dis-
tributed. Rank is 2 for logical arrays and between 2 and
4 otherwise.
locvals Returned distributed array. Type and rank is the same as
glbvals.
lbounds Lower bounds of the local and global arrays. Size must be
equal to the rank of glbvals and locvals.
23.17. PARALLEL COMMUNICATIONS 1041
Non-generic versions
distribute mod int 2d Integer 2-D array
distribute mod int 3d Integer 3-D array
distribute mod int 4d Integer 4-D array
distribute mod log 2d Logical 2-D array
distribute mod real 2d Real 2-D array
distribute mod real 3d Real 3-D array
distribute mod real 4d Real 4-D array
File
paral comms.f90
Type
Module subroutine
Purpose
Distributes a “global” derived type 2-D model grid array of type
HRelativeCoords from the root to all other processes.
Reference
Section 9.4.2
Arguments
surfglb Global derived type array to be distributed
surfloc Local distributed derived type array
lbounds Lower bounds of the local and global arrays.
nhdist Halo sizes used in the distribution operation (WESN di-
rections)
ivarid Variable key id (used for log info only, zero for undefined)
ifill Fill value for integer components
rfill Fill value for real components
shared The global array is defined on all processes if .TRUE. (in
which case no communication is performed), on the root
process only if .FALSE.
idroot Root process where the global array is defined if shared is
.FALSE. If not present, the root equals the master process.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type for the distribute operation (between
1 and 4). If not present, its value is set to iopt MPI comm scat.
1: blocking, standard send
2: blocking, synchronous send
23.17. PARALLEL COMMUNICATIONS 1043
exchange mod
SUBROUTINE exchange mod(values,lbounds,nhexch,ivarid,comm,corners,commtype)
LOGICAL, INTENT(IN), OPTIONAL :: corners
INTEGER, INTENT(IN) :: ivarid
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype
INTEGER, INTENT(IN), DIMENSION(:) :: lbounds
INTEGER, INTENT(IN), DIMENSION(4) :: nhexch
INTEGER, LOGICAL or REAL, INTENT(INOUT), &
& DIMENSION(lbounds(1):,lbounds(2):&
& [,lbounds(3):[,lbounds(4):]]) :: values
File
paral comms.f90
Type
Generic module subroutine
Purpose
Perform exchange communications between a local process and its
neighbours.
Reference
Section 9.4.3
Arguments
values Local integer, logical or real model grid array. Rank is 2
for logical arrays and between 2 and 4 otherwise.
lbounds Lower bounds of the local array. Size must be equal to the
rank of values.
nhexch Halo sizes used in the exchange operations (WESN direc-
tions). A zero value means that no exchange is made in
the corresponding direction.
ivarid Variable key id (used for log info only, zero for undefined)
comm MPI communicator. If not present, its value is comm work.
corners Corner communications are disabled if present and set to
.FALSE.
1044 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
max vars
SUBROUTINE max vars(values,maxval,ivarid,idroot,comm,commtype,&
& commall,mask)
LOGICAL, INTENT(IN), OPTIONAL :: commall
INTEGER, INTENT(IN) :: ivarid
INTEGER or REAL, INTENT(OUT) :: maxval
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
LOGICAL, INTENT(IN), OPTIONAL, DIMENSION(:,:) :: mask
INTEGER or REAL, INTENT(IN) [, DIMENSION(:,:[,:])] :: values
File
paral utilities.f90
Type
Generic module subroutine
Purpose
Compute the global maximum of a scalar or array integer or real vari-
able.
Arguments
values Local integer or real scalar, 2-D or 3-D model grid array
maxval Returned global maximum. Type must be the same as
values.
ivarid Variable key id (used for log info only, zero for undefined)
idroot Root process which returns the result in case of a all-to-
one communication. If not present, the root equals the
master process.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type (between 1 and 5). If not present, its
value is set to iopt MPI comm gath or iopt MPI comm all
if iopt MPI comm coll=0 or to 5 (collective call) other-
wise.
1: blocking, standard send
2: blocking, synchronous send
1046 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Non-generic versions
max vars int 0d Integer scalar
max vars int 2d Integer 2-D array
max vars int 3d Integer 3-D array
max vars real 0d Real scalar
max vars real 2d Real 2-D array
max vars real 3d Real 3-D array
maxloc vars
SUBROUTINE maxloc vars(values,maxval,maxpos,ivarid,&
& idroot,comm,commtype,commall,mask)
LOGICAL, INTENT(IN), OPTIONAL :: commall
INTEGER, INTENT(IN) :: ivarid
INTEGER or REAL, INTENT(OUT) :: maxval
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
INTEGER, INTENT(OUT), DIMENSION(:) :: maxpos
LOGICAL, INTENT(IN), OPTIONAL, DIMENSION(:,:) :: mask
INTEGER or REAL, INTENT(IN), DIMENSION(:,:[,:])] :: values
File
paral utilities.f90
Type
Generic module subroutine
Purpose
Compute the value and index location of a global maximum of an
integer or real 2-D or 3-D model grid array.
Arguments
23.18. UTILITY ROUTINES FOR PARALLEL APPLICATION 1047
Non-generic versions
maxloc vars int 2d Integer 2-D array
maxloc vars int 3d Integer 3-D array
maxloc vars real 2d Real 2-D array
maxloc vars real 3d Real 3-D array
min vars
SUBROUTINE min vars(values,minval,ivarid,idroot,comm,commtype,&
& commall,mask)
LOGICAL, INTENT(IN), OPTIONAL :: commall
INTEGER, INTENT(IN) :: ivarid
INTEGER or REAL, INTENT(OUT) :: minval
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
LOGICAL, INTENT(IN), OPTIONAL, DIMENSION(:,:) :: mask
INTEGER or REAL, INTENT(IN) [, DIMENSION(:,:[,:])] :: values
1048 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
paral utilities.f90
Type
Generic module subroutine
Purpose
Compute the global minimum of a scalar or array integer or real vari-
able.
Arguments
values Local integer or real scalar, 2-D or 3-D model grid array
minval Returned global minimum. Type must be the same as
values.
ivarid Variable key id (used for log info only, zero for undefined)
idroot Root process which returns the result in case of a all-to-
one communication. If not present, the root equals the
master process.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type (between 1 and 5). If not present, its
value is set to iopt MPI comm gath or iopt MPI comm all
if iopt MPI comm coll=0 or to 5 (collective call) other-
wise.
1: blocking, standard send
2: blocking, synchronous send
3: non-blocking, standard send
4: non-blocking, synchronous send
5: collective communication
commall Result is returned by all processes if present and .TRUE.
mask If present, points where mask is .FALSE. are excluded.
Otherwise all points are included. The argument is not
allowed for scalar input data.
Non-generic versions
min vars int 0d Integer scalar
min vars int 2d Integer 2-D array
min vars int 3d Integer 3-D array
23.18. UTILITY ROUTINES FOR PARALLEL APPLICATION 1049
minloc vars
SUBROUTINE minloc vars(values,minval,minpos,ivarid,&
& idroot,comm,commtype,commall,mask)
LOGICAL, INTENT(IN), OPTIONAL :: commall
INTEGER, INTENT(IN) :: ivarid
INTEGER or REAL, INTENT(OUT) :: minval
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
INTEGER, INTENT(OUT), DIMENSION(:) :: minpos
LOGICAL, INTENT(IN), OPTIONAL, DIMENSION(:,:) :: mask
INTEGER or REAL, INTENT(IN), DIMENSION(:,:[,:])] :: values
File
paral utilities.f90
Type
Generic module subroutine
Purpose
Compute the value and index location of a global minimum of an integer
or real 2-D or 3-D model grid array.
Arguments
values Local integer or real 2-D or 3-D model grid array
minval Returned global minimum. Type must be the same as
values.
minpos Global indices of the location of the minimum. Size equals
the rank of values.
ivarid Variable key id (used for log info only, zero for undefined)
idroot Root process which returns the result in case of a all-to-
one communication. If not present, the root equals the
master process.
comm MPI communicator. If not present, its value is comm work.
commtype Communication type (between 1 and 4). If not present, its
value is set to iopt MPI comm gath or iopt MPI comm all.
1050 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Non-generic versions
minloc vars int 2d Integer 2-D array
minloc vars int 3d Integer 3-D array
minloc vars real 2d Real 2-D array
minloc vars real 3d Real 3-D array
sum vars
SUBROUTINE sum vars(values,sumval,ivarid,idroot,comm,commtype,&
& commall,mask)
LOGICAL, INTENT(IN), OPTIONAL :: commall
INTEGER, INTENT(IN) :: ivarid
INTEGER or REAL, INTENT(OUT) :: sumval
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
LOGICAL, INTENT(IN), OPTIONAL, DIMENSION(:,:) :: mask
INTEGER or REAL, INTENT(IN) [, DIMENSION(:,:[,:])] :: values
File
paral utilities.f90
Type
Generic module subroutine
Purpose
Compute the global sum of a scalar or array integer or real variable.
The result depends on the number of processes, but it more efficient
than sum2 vars (see below).
Arguments
values Local integer or real scalar, 2-D or 3-D model grid array
23.18. UTILITY ROUTINES FOR PARALLEL APPLICATION 1051
Non-generic versions
sum vars int 0d Integer scalar
sum vars int 2d Integer 2-D array
sum vars int 3d Integer 3-D array
sum vars real 0d Real scalar
sum vars real 2d Real 2-D array
sum vars real 3d Real 3-D array
sum2 vars
SUBROUTINE sum2 vars(realdat,realsum,nhdims,cnode,ivarid,idroot,&
& comm,commtype,commall,mask)
LOGICAL, INTENT(IN), OPTIONAL :: commall
CHARACTER (LEN=lennode), INTENT(IN) :: cnode
INTEGER, INTENT(IN) :: ivarid
INTEGER, INTENT(IN), OPTIONAL :: comm, commtype, idroot
1052 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Non-generic versions
sum2 vars real 2d Real 2-D array
sum2 vars real 3d Real 3-D array
sum2 vars real 4d Real 4-D array
File
reset model.F90
Type
Module subroutine
Purpose
Reset initial conditions.
File
reset model.F90
Type
Module subroutine
Purpose
Reset model parameters, defined either by default or by the user. A
warning message is written in most cases.
1054 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
File
reset model.F90
Type
Module subroutine
Purpose
Define the attributes of variables in model forcing files.
Arguments
varatts Returned variable attributes
File
reset model.F90
Type
Generic module subroutine
Purpose
Reset the status and iunit attributes of user output files.
Arguments
filepars Attributes of the user output files
status Values of the new status attributes
Non-generic versions
reset out files 1d Vector array of files
reset out files 2d 2-D array of files
23.19. RESET OF SETUP PARAMETERS 1055
File
reset model.F90
Type
Module subroutine
Purpose
Reset the attributes of a user defined output grid.
Arguments
outgpars Attributes of the user output grid
arrname Name of the attributes array
tseries .TRUE. for time series output, .FALSE. otherwise
end reset If .TRUE., resets the last output time (defined by the
tlims(2) attribute) to the latest possible value before the
end of the simulation.
File
reset model.F90
Type
Module subroutine
Purpose
Reset the attributes of user defined output station attributes.
Arguments
statlocs Attributes of the user defined output stations
1056 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
5. A random generator is closed by calling rng close. After this call the
generator number id can no longer be used.
6. All generators are closed and parameters are reset to their initial de-
fault conditions by a call in the program of rng finalize at the end of a
simulation.
rng close
SUBROUTINE rng close(numgen)
INTEGER, INTENT(IN), OPTIONAL :: numgen
File
rng library.f90
Type
Module subroutine
Purpose
Disable (“close”) a random generator.
Arguments
numgen Generator id
rng finalize
SUBROUTINE rng finalize
File
rng library.f90
Type
Module subroutine
Purpose
Close all generators and reset parameters to the their default values.
The routine is called by the program at the end of a simulation.
1058 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
rng init
SUBROUTINE rng init
File
rng library.f90
Type
Module subroutine
Purpose
Set the random seed for all generators and initialise other parameters.
File
rng library.f90
Type
Module function
Purpose
Returns (as)mod(m). The function is used internally in the library.
Reference
L’Ecuyer & Côté (1991)
File
rng library.f90
Type
Module subroutine
23.20. RANDOM GENERATORS 1059
Purpose
Generate a vector of random numbers with mean xmean and standard
deviation xstd.
Arguments
xrand Returned random numbers
ncount Size of the returned vector
numgen Generator id
xmean Mean value
xstd Standard deviation
File
rng library.f90
Type
Module subroutine
Purpose
Generate a random number with mean xmean and standard deviation
xstd.
Arguments
xrand Returned random number
numgen Generator id
xmean Mean value
xstd Standard deviation
rng open
SUBROUTINE rng open(numgen)
INTEGER, INTENT(OUT) :: numgen
File
rng library.f90
1060 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module subroutine
Purpose
Enable (“open”) a random generator.
Arguments
numgen Returned generator id
rng opened
SUBROUTINE rng opened(numgen,flag)
LOGICAL, INTENT(OUT) :: flag
INTEGER, INTENT(IN) :: numgen
File
rng library.f90
Type
Module subroutine
Purpose
Returns flag as .TRUE. if the generator with id numgen has been opened.
Arguments
numgen Generator id
flag Returned flag
rng reset
SUBROUTINE rng reset(numgen,seedtype)
CHARACTER (LEN=1), INTENT(IN) :: seedtype
INTEGER, INTENT(IN) :: numgen
File
rng library.f90
Type
Module subroutine
Purpose
Reset an open generator according to the value of seedtype. The rou-
tine is called in parallel mode to enable independent series of random
numbers on different sub-domains with the same random generator.
23.20. RANDOM GENERATORS 1061
Reference
L’Ecuyer & Côté (1991)
Arguments
numgen Generator id
seedtype Type of reset
‘I’ reset to the initial state
‘L’ no reset
‘N’ a new set a random numbers will be generated which
are different from the initial state
File
rng library.f90
Type
Module subroutine
Purpose
Generate a random number with zero mean and unit variance.
Reference
Routine gasdev from Press et al. (1992)
Arguments
xran Returned random number
numgen Generator id
File
rng library.f90
1062 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module subroutine
Purpose
Generate a random number between 0 and 1.
Reference
L’Ecuyer & Côté (1991)
Arguments
xran Returned random number
numgen Generator id
File
rng library.f90
Type
Module subroutine
Purpose
Generate a random number between xlo and xhi.
Arguments
xrand Returned vector of random numbers
numgen Generator id
xlo Lower limit
xhi Upper limit
File
time routines.f90
Type
Generic module subroutine
Purpose
Add a number of number of time steps to a given date.
Arguments
datetime1 Initial date and time
datetime2 Returned new date and time. Must have the same type as
datetime1.
numsteps Number of time steps
1064 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Non-generic versions
add secs to date char date and time in string format
add secs to date int date and time in integer vector format
File
time routines.f90
Type
Module subroutine
Purpose
Update an harmonic phase after a number of time steps. The result is
returned modulo 2π.
Arguments
phasein Initial phase [rad]
phaseout Returned updated phase [rad]
numsteps Number of time steps
dsecs Number of seconds in one time step [s]
freq Harmonic frequency [rad/s]
check date
SUBROUTINE check date(datetime,varname)
CHARACTER (LEN=lentime) or INTEGER, DIMENSION(7),&
& INTENT(IN) :: datetime
CHARACTER (LEN=*), INTENT(IN) :: arrname
File
time routines.f90
23.21. TIME AND CALENDAR DATE ROUTINES 1065
Type
Generic module subroutine
Purpose
Check a calendar time and time in string or integer format.
Arguments
datetime Calendar date and time
varname Name of the date/time variable
Non-generic versions
check date char calendar date and time in string format
check date int calendar date and time in integer vector format
File
time routines.f90
Type
Module subroutine
Purpose
Returns the calendar date and time from the machine’s internal real-
time clock.
Arguments
charclock Returned internal calendar date and time in COHERENS
string format
convert date
FUNCTION convert date(datetime1) RESULT(datetime2)
CHARACTER (LEN=lentime) or INTEGER, DIMENSION(7),&
& INTENT(IN) :: datetime1
INTEGER, DIMENSION(7) or CHARACTER (LEN=lentime) : datetime2
File
time routines.f90
1066 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Generic module subroutine
Purpose
Convert a calendar date and time from string to integer format or vice
versa.
Arguments
datetime1 Calendar date and time on input
datetime2 Returned calendar date and time in the opposite format
of datetime1
Non-generic versions
check date to char convert to integer format
check date to int convert to string format
date to year
SUBROUTINE date to year(datetime,yearnum)
CHARACTER (LEN=lentime) or INTEGER, DIMENSION(7),&
& INTENT(IN) :: datetime
REAL, INTENT(OUT) :: yearnum
File
time routines.f90
Type
Generic module subroutine
Purpose
Convert a calendar date and time in string or integer format to a year
number with a decimal part.
Arguments
datetime Calendar date and time
yearnum Returned year number
Non-generic versions
date to year char calendar date and time is in string format
date to year int calendar date and time is in integer format
23.21. TIME AND CALENDAR DATE ROUTINES 1067
date number
SUBROUTINE date to year(datetime,daynum)
CHARACTER (LEN=lentime) or INTEGER, DIMENSION(7),&
& INTENT(IN) :: datetime
REAL, INTENT(OUT) :: daynum
File
time routines.f90
Type
Generic module subroutine
Purpose
Returns the day number of the year. Result is between 0 and 365 (or
366 for a leap year).
Arguments
datetime Calendar date and time
daynum Returned day number
Non-generic versions
day number char calendar date and time is in string format
day number int calendar date and time is in integer format
diff clock
FUNCTION diff clock(npccold)
INTEGER, INTENT(IN) :: npccold
INTEGER :: diff clock
File
time routines.f90
Type
Module function
Purpose
Returns the number of clock counts since a previous call to read clock.
Arguments
npccold Number of previous clock counts
1068 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
diff dates
SUBROUTINE diff dates(datetime1,datetime2,tunit,nosecs,&
& millisecs,rtime)
CHARACTER (LEN=lentime) or INTEGER, DIMENSION(7),&
& INTENT(IN) :: datetime1, datetime2
INTEGER, INTENT(IN) :: tunit
INTEGER, INTENT(OUT), OPTIONAL :: millisecs
INTEGER (KIND=kndilong), INTENT(OUT), OPTIONAL :: nosecs
REAL, INTENT(OUT), OPTIONAL :: rtime
File
time routines.f90
Type
Generic module subroutine
Purpose
Returns the time between two given calendar dates. Result is negative
if the second date is earlier than the first one.
Arguments
datetime1 First calendar date and time
datetime2 Second calendar date and time in the same format as date-
time1
tunit Time unit for the result
0: seconds and (optionally) milliseconds
1: seconds
2: minutes
3: hours
4: days
5: months
6: years
nosecs If present and tunit=0, the result is in integer seconds.
millisecs If present and tunit=0, the residual number of milliseconds
(between 0 and 999).
rtime If present and tunit>0, the result is in real format (with
milliseconds set to zero).
23.21. TIME AND CALENDAR DATE ROUTINES 1069
Non-generic versions
diff dates char calendar dates are in string format
diff dates int calendar dates are in integer format
.earlier.
Usage: datetime1.earlier.datetime2
CHARACTER (LEN=lentime) or INTEGER(7),&
& INTENT(IN) :: datetime1, datetime2
LOGICAL operator :: earlier
File
time routines.f90
Type
Generic operator
Purpose
Returns .TRUE. is datetime1 is earlier than datetime2.
Arguments
datetime1 First calendar date and time
datetime2 Second calendar date and time in the same format as date-
time1
Non-generic versions
earlier char compares calendar dates in string format
earlier int compares calendar dates in integer format
File
time routines.f90
Type
Module subroutine
1070 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Checks whether cdate is not earlier than datemin if matchmin is .TRUE.
or is later than cdatemin if matchmin is .FALSE.
Arguments
cdate Calendar date and time to be checked
varname Name of the calendar date variable
cdatemin Earliest allowed calendar date
machtmin If .FALSE. (.TRUE.), cdate must be later (not earlier) than
cdatemin.
File
time routines.f90
Type
Module subroutine
Purpose
Checks whether cdate is not later than cdatemax if matchmax is .TRUE.
or is earlier than cdatemax if matchmax is .FALSE.
Arguments
cdate Calendar date and time to be checked
varname Name of the calendar date variable
cdatemax Latest allowed calendar date
matchmin If .FALSE. (.TRUE.), cdate must be earlier (not later) than
cdatemax.
initialise time
SUBROUTINE initialise time
File
time routines.f90
23.21. TIME AND CALENDAR DATE ROUTINES 1071
Type
Module subroutine
Purpose
Routine called by the program at the initial time to initialise a series
of parameters related to date and time.
.later.
Usage: datetime1.later.datetime2
CHARACTER (LEN=lentime) or INTEGER(7),&
& INTENT(IN) :: datetime1, datetime2
LOGICAL operator :: .later.
File
time routines.f90
Type
Generic operator
Purpose
Returns .TRUE. is datetime1 is later than datetime2.
Arguments
datetime1 First calendar date and time
datetime2 Second calendar date and time in the same format as date-
time1
Non-generic versions
later char compares calendar dates in string format
later int compares calendar dates in integer format
leap year
FUNCTION leap year(iyear)
INTEGER, INTENT(IN) :: iyear
INTEGER :: leap year
File
time routines.f90
1072 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module function
Purpose
Returns the number of leap days (0 or 1) in a given year.
Arguments
iyear Given year
log timer in
SUBROUTINE log timer in(npcc,ivarid,logname,info)
LOGICAL, INTENT(IN), OPTIONAL :: info
CHARACTER (LEN=*), INTENT(IN), OPTIONAL :: logname
INTEGER, INTENT(IN), OPTIONAL :: ivarid
INTEGER, INTENT(OUT), OPTIONAL :: npcc
File
time routines.f90
Type
Module subroutine
Purpose
Writes the tracing info to a log file when a routine is called and reads
(optionally) the current machine’s clock count.
Arguments
npcc If present, the returned clock count.
ivarid If present, the key id of variable whose name is added in
the log message
logname If not present, the log message writes the name of the
calling routine (i.e. the one at the highest program level).
Otherwise, this name is replaced by the string logname.
info No log message will be written if this argument is present
and .FALSE.
File
time routines.f90
Type
Module subroutine
Purpose
Writes the tracing info to a log file before a routine is exited and update
the number of clock counts for a given timer.
Arguments
npcc If present, the clock count from a previous call to log timer in.
itm type If present, the key id of the timer which needs to be up-
dated.
info No log message will be written if this argument is present
and .FALSE.
.noearlier.
Usage: datetime1.noearlier.datetime2
CHARACTER (LEN=lentime) or INTEGER(7),&
& INTENT(IN) :: datetime1, datetime2
LOGICAL operator :: noearlier
File
time routines.f90
Type
Generic operator
Purpose
Returns .TRUE. is datetime1 is not earlier than datetime2.
Arguments
datetime1 First calendar date and time
datetime2 Second calendar date and time in the same format as date-
time1
Non-generic versions
noearlier char compares calendar dates in string format
noearlier int compares calendar dates in integer format
1074 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
.nolater.
Usage: datetime1.nolater.datetime2
CHARACTER (LEN=lentime) or INTEGER(7),&
& INTENT(IN) :: datetime1, datetime2
LOGICAL operator :: .nolater.
File
time routines.f90
Type
Generic operator
Purpose
Returns .TRUE. is datetime1 is not later than datetime2.
Arguments
datetime1 First calendar date and time
datetime2 Second calendar date and time in the same format as date-
time1
Non-generic versions
nolater char compares calendar dates in string format
nolater int compares calendar dates in integer format
Arguments
datetime1 First calendar date and time
datetime2 Second calendar date and time in the same format as date-
time1
descs Number of seconds in one time step [s]
numsteps Returned number of time steps
Non-generic versions
num time steps char calendar dates are given in string format
num time steps int calendar dates are given in integer format
read clock
FUNCTION read clock()
File
time routines.f90
Type
Module function
Purpose
Returns the machine’s internal clock count.
suspend proc
SUBROUTINE suspend proc(nosecswait)
INTEGER, INTENT(IN) :: nosecswait
File
time routines.f90
Type
Module function
Purpose
Suspends program execution of the calling process for the given number
of seconds.
Arguments
nosecswait Wait time [s]
1076 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
update time
SUBROUTINE update time
File
time routines.f90
Type
Module subroutine
Purpose
Updates the calendar date/time and a series of parameters related to
date and time (e.g. the number of seconds since the start of the simu-
lation) at the start of a new iteration in the time loop.
year to date
SUBROUTINE year to date(yearnum,datetime)
CHARACTER (LEN=lentime) or INTEGER, DIMENSION(7),&
& INTENT(OUT) :: datetime
REAL, INTENT(IN) :: yearnum
File
time routines.f90
Type
Generic module subroutine
Purpose
Convert an absolute year number to a calendar date and time in a
string or integer vector format.
Arguments
yearnum Absolute date in years
datetime Returned calendar date
Non-generic versions
year to date char result is returned in string format
year to date int result is returned in integer format
23.22. ROUTINES USED BY THE TURBULENCE MODEL 1077
buoyancy frequency
SUBROUTINE buoyancy frequency
File
turbulence routines.F90
Type
Module subroutine
Purpose
Calculate the squared buoancy frequency N 2 on the model grid using
the algorithm given in Section 5.3.11.2.
Reference
Section 5.3.11.2
File
turbulence routines.F90
Type
Module subroutine
Purpose
Apply the limiting condition for the dissipation rate ε given by equa-
tion (4.213).
Reference
Section 4.4.3.6
dissip to zlmix
SUBROUTINE dissip to zlmix
File
turbulence routines.F90
1078 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module subroutine
Purpose
Calculate the mixing length l from the dissipation rate ε using equa-
tion (4.191).
mom strat MA
FUNCTION mom strat MA(ricnum,mask)
LOGICAL, INTENT(IN), DIMENSION(ncloc,nrloc) :: mask
REAL, INTENT(IN), DIMENSION(ncloc,nrloc) :: ricnum
REAL, DIMENSION(ncloc,nrloc) :: mom strat MA
File
turbulence routines.F90
Type
Module function
Purpose
Returns the Munk-Anderson stratification function for momentum fm (Ri)
using (4.127). Result is returned at wet points only.
Arguments
ricnum Richardson number
mask Mask to exclude land areas
richardson number
FUNCTION richardson number(k,mask)
INTEGER, INTENT(IN) :: k
LOGICAL, INTENT(IN), DIMENSION(:,:) :: mask
REAL, DIMENSION(LBOUND(mask,1):UBOUND(mask,1),&
& LBOUND(mask,2):UBOUND(mask,2)) :: richardson number
File
turbulence routines.F90
Type
Module function
23.22. ROUTINES USED BY THE TURBULENCE MODEL 1079
Purpose
Returns the Richardson number Ri defined by (4.118) at the vertical
level k. Result is returned at wet points only.
Arguments
k Index of vertical level
mask Mask to exclude land areas
richardson number 0d
FUNCTION richardson number 0d(i,j,k)
INTEGER, INTENT(IN) :: i, j, k
REAL :: richardson number 0d
File
turbulence routines.F90
Type
Module function
Purpose
Returns the Richardson number Ri defined by (4.118) at a location on
the model grid.
Arguments
i X-location on the model grid
j Y-location on the model grid
k Vertical location on the model grid
scal strat MA
FUNCTION scal strat MA(ricnum,mask)
LOGICAL, INTENT(IN), DIMENSION(ncloc,nrloc) :: mask
REAL, INTENT(IN), DIMENSION(ncloc,nrloc) :: ricnum
REAL, DIMENSION(ncloc,nrloc) :: scal strat MA
File
turbulence routines.F90
Type
Module function
1080 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Returns the Munk-Anderson stratification function for scalars gm (Ri)
using (4.128). Result is returned at wet points only.
Arguments
ricnum Richardson number
mask Mask to exclude land areas
shear frequency
SUBROUTINE shear frequency
File
turbulence routines.F90
Type
Module subroutine
Purpose
Calculate the squared shear frequency M 2 on the model grid using the
algorithm given in Section 5.3.11.2.
Reference
Section 5.3.11.2
File
turbulence routines.F90
Type
Module subroutine
Purpose
Apply the limiting condition for the mixing length l given by equa-
tion (4.213).
Reference
Section 4.4.3.6
23.23. MISCELLANEOUS UTILITY ROUTINES 1081
zlmix to dissip
SUBROUTINE zlmlix to dissip
File
turbulence routines.F90
Type
Module subroutine
Purpose
Calculate the dissipation rate ε from the mixing length l using equa-
tion (4.191).
File
utility routines.f90
Type
Module function
Purpose
Evaluate the Orlanski function OR (r1 , r2 , r3 ) defined by equation (5.256).
diff vals
FUNCTION diff vals(ilist)
INTEGER, INTENT(IN), DIMENSION(:) :: ilist
LOGICAL :: diff vals
File
utility routines.f90
Type
Module function
1082 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Purpose
Returns .TRUE. if the elements of the vector array ilist are all different.
Arguments
File
utility routines.f90
Type
Module function
Purpose
Returns the number of significant (decimal) digits needed to represent
the integer number ival.
File
utility routines.f90
Type
Module function
Purpose
Returns the number of significant (decimal) digits needed to represent
the long integer number ival.
23.23. MISCELLANEOUS UTILITY ROUTINES 1083
index position
FUNCTION index position(ival,ilist)
INTEGER, INTENT(IN) :: ival
INTEGER, INTENT(IN), DIMENSION(:) :: ilist
INTEGER :: index position
File
utility routines.f90
Type
Module function
Purpose
Returns the index of the first occurrence of ival in the vector list ilist
or zero if ival is not included.
File
utility routines.f90
Type
Module subroutine
Purpose
Perform a least squares on the input data (a,b).
Arguments
x Data values on the X-axis
y Data values on the Y-axis
nodat Number of data values
afit Returned slope parameter of the interpolated straight line
bfit Returned X-value at the intersection of the straight line
with the X-axis
corrcoef Returned correlation coefficient r2
1084 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
lim dims
FUNCTION lim dims(lims)
INTEGER, INTENT(IN), DIMENSION(3) :: lims
INTEGER :: lim dims
File
utility routines.f90
Type
Module function
Purpose
Returns the number of iterations within the loop whose first, end and
step values are given by respectively the first, second and third element
of lims.
loop index
FUNCTION loop index(lims,iloop)
INTEGER, INTENT(IN) :: iloop
INTEGER, INTENT(IN), DIMENSION(3) :: lims
LOGICAL :: loop index
File
utility routines.f90
Type
Module function
Purpose
Returns .TRUE. if iloop is within the loop whose first, end and step
values are given by respectively the first, second and third element of
lims.
mult index
FUNCTION mult index(ix,iy)
INTEGER, INTENT(IN) :: ix, iy
LOGICAL :: mult index
File
utility routines.f90
23.23. MISCELLANEOUS UTILITY ROUTINES 1085
Type
Module function
Purpose
Returns .TRUE. if iy is non-zero and ix an integer multiple of iy.
num halo
FUNCTION num halo(iopt adv)
INTEGER, INTENT(IN) :: iopt adv
INTEGER :: num halo
File
utility routines.f90
Type
Module function
Purpose
Returns the halo size needed for advection.
Arguments
iopt adv Type of advection scheme
0: no advection
1: upwind
2: central or Lax-Wendroff
3: TVD
outer product
FUNCTION outer product(a,b)
REAL, DIMENSION(:), INTENT(IN) :: a, b
REAL, DIMENSION(SIZE(a), SIZE(b)) :: outer product
File
utility routines.f90
Type
Module function
Purpose
Returns the outer product of the vectors a, b. The elements of the
resulting matrix A are Aij = ai bj .
1086 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
prime factoring
SUBROUTINE prime factoring(nx,nfacs,ifacs,maxfacs,maxprime)
INTEGER, INTENT(IN) :: maxfacs, maxprime, nx
INTEGER, INTENT(OUT) :: nfacs
INTEGER, INTENT(OUT), DIMENSION(maxfacs) :: ifacs
File
utility routines.f90
Type
Module subroutine
Purpose
Returns the prime number factors of an integer number.
Arguments
nx Integer number
nfacs Returned number of prime factors (lower or equal than
maxfacs)
ifacs Returned vector of prime numbers in descending order
(lower or equal than maxprime)
maxfacs Maximum number of prime numbers
maxprime Largest allowed prime factor
qsort index
SUBROUTINE qsort_index(arr,indx,iorder)
INTEGER, INTENT(IN) :: iorder
REAL, INTENT(IN), DIMENSION(:) :: arr
INTEGER, INTENT(OUT), DIMENSION(SIZE(arr)) :: indx
File
utility routines.f90
Type
Module subroutine
Purpose
Uses the “quick-sort” algorithm to create the index array indx such that
the values of arr(indx(j)) are sorted in ascending (descending) order if
iorder = 1 (-1)
23.23. MISCELLANEOUS UTILITY ROUTINES 1087
Reference
Routine indexx from Press et al. (1992)
relax factor
FUNCTION relax factor(idist,ityp,width)
INTEGER, INTENT(IN) :: idist, ityp
REAL, INTENT(IN) :: width
REAL :: relax factor
File
utility routines.f90
Type
Module function
Purpose
Returns the weighting factor for the relaxation scheme.
Arguments
idist Distance of the grid point from the open boundary in grid
indices
ityp Type of weight function
1: linear form (4.375)
2: quadratic form (4.376)
3: hyperbolic form (4.377)
width Width of the relaxation zone in grid indices
string replace
SUBROUTINE string replace(string,cin,cout)
CHARACTER (LEN=*), INTENT(INOUT) :: string
CHARACTER (LEN=1), INTENT(IN) :: cin, cout
File
utility routines.f90
Type
Module subroutine
Purpose
Replaces each occurence of character cin by the character cout in string.
If the string contains blanks only, the string is replaced by cout.
1088 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
swap data
SUBROUTINE swap data(var1,var2)
INTEGER, REAL or COMPLEX &
& [, DIMENSION(:[,:])], INTENT(INOUT) :: var1, var2
File
utility routines.f90
Type
Generic module subroutine
Purpose
Exchange (“swap”) the two integer, real or complex arguments. In case
of integers, only scalars allowed. In case of real or complex data the
arguments are either scalars, vectors or 2-D arrays.
Non-generic versions
swap data var int integer scalars
swap data var real real scalars
swap data var cmplx complex scalars
swap data 1d real real vectors
swap data 1d cmplx complex vectors
swap data 2d real real 2-D arrays
swap data 2d cmplx complex 2-D array
tvd limiter
FUNCTION tvd limiter(x,mask)
REAL, INTENT(IN), DIMENSION(:,:) :: x
LOGICAL, INTENT(IN), OPTIONAL,&
& DIMENSION(LBOUND(x,1):UBOUND(x,1),&
& LBOUND(x,2):UBOUND(x,2)[,&
& LBOUND(x,3):UBOUND(x,3)]) :: mask
REAL[, DIMENSION(LBOUND(x,1):UBOUND(x,1),&
& LBOUND(x,2):UBOUND(x,2)[,&
& LBOUND(x,3):UBOUND(x,3)])] :: tvd limiter
File
utility routines.f90
23.23. MISCELLANEOUS UTILITY ROUTINES 1089
Type
Generic module function
Purpose
Evaluate the TVD limiting function Ω(r) on the model grid using ei-
ther the superbee (5.39) or the monotonic (5.40) limiter. No result is
returned on land areas.
Arguments
x Argument r of the limiting function
mask Mask to exclude land areas. Shape must be the same as
the result.
Non-generic versions
tvd limiter 0d Scalar result
tvd limiter 2d 2-D result
tvd limiter 3d 3-D result
two power
FUNCTION two power(n)
INTEGER, INTENT(IN) :: n
INTEGER :: two power
File
utility routines.f90
Type
Module function
Purpose
Returns the smallest number p for which 2p ≥ n.
upper case
SUBROUTINE upper case(string)
CHARACTER (LEN=*), INTENT(INOUT) :: string
File
utility routines.f90
1090 APPENDIX 23. DESCRIPTION OF MODULES ROUTINES
Type
Module routine
Purpose
Converts a string to upper case
Appendix 24
A series of usrdef routines have been created where the user can define all
parameters and arrays needed for the setup of an application. The contents of
these routines are discussed in Part IV. A summary is given in this chapter.
File
Usrdef Harmonic Analysis.f90
Type
Subroutine
Purpose
Define frequencies and related parameters for performing harmonic
analysis.
Reference
Section 16.3.1
1091
1092 APPENDIX 24. DESCRIPTION OF USER DEFINED ROUTINES
File
Usrdef Harmonic Analysis.f90
Type
Subroutine
Purpose
Define specifiers for harmonic output.
Reference
Section 16.3.2
File
Usrdef Harmonic Analysis.f90
Type
Subroutine
Purpose
Define the 0-D variables for harmonic analysis.
Reference
Section 16.3.3.1
Arguments
out0ddat 0-D data. The variables are given in the same order as
they are defined in analvars.
n0vars The number of 0-D harmonic variables
File
Usrdef Harmonic Analysis.f90
24.1. HARMONIC ANALYSIS AND OUTPUT 1093
Type
Subroutine
Purpose
Define the 2-D variables for harmonic analysis.
Reference
Section 16.3.3.2
Arguments
out2ddat 2-D output data. The variables are given in the same order
as they are defined in the array analvars.
i X-index of the data location on the local model grid
j Y-index of the data location on the local model grid
n2vars The number of 2-D harmonic variables
File
Usrdef Harmonic Analysis.f90
Type
Subroutine
Purpose
Define the 3-D variables for harmonic analysis.
Reference
Section 16.3.3.3
Arguments
out3ddat 3-D output data. The variables are given in the same order
as they are defined in the array analvars.
i X-index of the data location on the local model grid
j Y-index of the data location on the local model grid
k Vertical index of the data location on the model grid
n3vars The number of 3-D harmonic variables
1094 APPENDIX 24. DESCRIPTION OF USER DEFINED ROUTINES
usrdef grid
SUBROUTINE usrdef grid
File
Usrdef Model.f90
Type
Subroutine
Purpose
Define model grid, bathymetry and locations of open boundaries.
Reference
Section 13.1
usrdef partition
SUBROUTINE usrdef partition
File
Usrdef Model.f90
Type
Subroutine
Purpose
Define domain decomposition for parallel applications.
Reference
Section 12.9
usrdef phsics
SUBROUTINE usrdef phsics
File
Usrdef Model.f90
Type
Subroutine
Purpose
Define physical initial conditions.
Reference
Section 13.2
1096 APPENDIX 24. DESCRIPTION OF USER DEFINED ROUTINES
File
Usrdef Model.f90
Type
Subroutine
Purpose
Define the surface forcing specifiers in case of a water column (1-D)
application.
Reference
Section 15.1.1
File
Usrdef Model.f90
Type
Subroutine
Purpose
Define open boundary conditions for the 2-D mode.
Reference
Section 14.1.1
File
Usrdef Model.f90
Type
Subroutine
Purpose
Define open boundary conditions for baroclinic currents and 3-D scalars.
Reference
Section 14.2.1
Arguments
iddesc The file descriptor key id of the 3-D quantity which may
take the following values
io 3uvobc baroclinic currents
io salobc salinity
io tmpobc temperature
io bioobc biological variables (currently not implemented)
itypobu Type of the open boundary condition at the U-nodes (see
Section 14.2.1.1)
itypobv Type of the open boundary condition at the V-nodes (see
Section 14.2.1.1)
iprofobu Profile number used at the U-open boundaries for each
data variable (0 is none)
iprofobv Profile number used at the V-open boundaries for each
data variable (0 is none)
iprofrlx Disables/enables the application of the open boundary re-
laxation scheme within the zones defined in usrdef rlxobc spec
(0/1).
noprofsd Number of profiles per data file
indexprof Mapping array of the profile numbers in the data files to
the profile numbers assigned to the open boundaries. The
physical size of the first dimension equals the number of
profiles in a data file.
1098 APPENDIX 24. DESCRIPTION OF USER DEFINED ROUTINES
File
Usrdef Model.f90
Type
Subroutine
Purpose
Define the surface forcing data in case of a water column (1-D) appli-
cation.
Reference
Section 15.1.2
Arguments
ciodatetime Returned date and time in string format
data1d Returned forcing data. The array elements are:
1: X-component of the pressure gradient if isur1dtype=1
or 3, surface elevation if isur1dtype=2
2: Y-component of the pressure gradient if isur1dtype=1
or 3
3: surface elevation if isur1dtype=1
novars The number of data variables depending on the value of
isur1dtype
1: three data values (X- and Y-component of the pressure
gradient and elevation)
24.2. MODEL SETUP 1099
File
Usrdef Model.f90
Type
Subroutine
Purpose
Define the open boundary data for 3-D quantities.
Reference
Section 14.2.2
Arguments
iddesc The file descriptor key id of the 3-D quantity which may
take the following values:
io 3uvobc baroclinic currents
io salobc salinity
io tmpobc temperature
io bioobc biological variables (currently not implemented)
ifil File number index of the data file (>1)
ciodatetime Returned date and time in string format
psiprofdat Returned values of the open boundary profile data
numprofs The number of profiles in the data file
File
Usrdef Model.f90
Type
Subroutine
Purpose
Define specifier arrays for the use of relaxation conditions near open
boundaries.
Reference
Section 14.3
24.3. SETUP OF NESTED SUB-GRIDS 1101
File
Usrdef Nested Grids.f90
Type
Subroutine
Purpose
Define the number of nested open boundary locations and type of coor-
dinates.
Reference
Section 15.3.1
File
Usrdef Nested Grids.f90
Type
Subroutine
Purpose
Define the absolute geographical positions of the open boundaries for
the sub-grid with index iset.
Reference
Section 15.3.2
Arguments
iset The index number of the sub-grid
1102 APPENDIX 24. DESCRIPTION OF USER DEFINED ROUTINES
File
Usrdef Nested Grids.f90
Type
Subroutine
Purpose
Define the geographical positions of the open boundaries in relative
coordinates for the sub-grid with index iset.
Reference
Section 15.3.3
Arguments
iset The index number of the sub-grid
nhdat Number of sub-grid points in the horizontal, equal to the
value of either nohnstglbc(iset), nohnstglbu(iset) or nohnst-
glbv(iset) depending on the value of cnode
24.4. USER-FORMATTED OUTPUT 1103
File
Usrdef Output.f90
Type
Subroutine
Purpose
User-formatted output
Reference
Section 16.4
File
Usrdef Surface Data.f90
1104 APPENDIX 24. DESCRIPTION OF USER DEFINED ROUTINES
Type
Subroutine
Purpose
Define a surface grid in (absolute) geographical coordinates.
Reference
Section 15.2.1
Arguments
iddesc The file descriptor of the corresponding data file. The
key id in parentheses below is the associated grid key id
(idgrd).
io metgrd surface meteo grid (igrd meteo)
io sstgrd surface grid for sea surface temperature (igrd sst)
ifil File index. In the current implementation its value is 1.
n1dat X-dimension of the data grid equal to surfacegrids(idgrd,ifil)%n1dat
n2dat Y-dimension of the data grid equal to surfacegrids(idgrd,ifil)%n2dat
xcoord X-coordinates of the data grid
[m or degrees longitude]
ycoord Y-coordinates of the data grid
[m or degrees latitude]
File
Usrdef Surface Data.f90
Type
Subroutine
Purpose
Define the relative coordinate arrays of a surface grid with respect to
model grid.
Reference
Section 15.2.2
24.5. SURFACE GRIDS AND DATA 1105
Arguments
iddesc The file descriptor of the corresponding data file. The
key id in parentheses below is the associated grid key id
(idgrd).
io metgrd surface meteo grid (igrd meteo)
io sstgrd surface grid for sea surface temperature (igrd sst)
ifil File index. In the current implementation its value is 1.
surfgridglb Returned relative coordinates of the model C-node grid
with respect to a data grid represented by iddesc
nx Currenly equal to the global X-dimension nc of the model
grid.
ny Currenly equal to the global Y-dimension nr of the model
grid.
nonodes Number of nodes. In the current implementation its value
equals 1.
File
Usrdef Surface Data.f90
Type
Subroutine
Purpose
Define the input surface forcing data.
Reference
Section 15.2.3
Arguments
iddesc The file descriptor of the corresponding data file
io metsur surface meteo data
1106 APPENDIX 24. DESCRIPTION OF USER DEFINED ROUTINES
File
Usrdef Time Averages.f90
Type
Subroutine
Purpose
Define specifiers for time averaged output.
Reference
Section 16.2.1
File
Usrdef Time Averages.f90
Type
Subroutine
24.6. TIME AVERAGED OUTPUT 1107
Purpose
Define the 0-D variables for time averaged output.
Reference
Section 16.2.2.1
Arguments
out0ddat 0-D data. The variables are given in the same order as
they are defined in avrvars.
n0vars The number of 0-D output variables
File
Usrdef Time Averages.f90
Type
Subroutine
Purpose
Define the 2-D variables for time averaged output.
Reference
Section 16.2.2.2
Arguments
out2ddat 2-D output data. The variables are given in the same order
as they are defined in the array avrvars.
i X-index of the data location on the local model grid
j Y-index of the data location on the local model grid
n2vars The number of 2-D output variables
File
Usrdef Time Averages.f90
Type
Subroutine
Purpose
Define the 3-D variables for time averaged output.
Reference
Section 16.2.2.3
Arguments
out3ddat 3-D output data. The variables are given in the same order
as they are defined in the array avrvars.
i X-index of the data location on the local model grid
j Y-index of the data location on the local model grid
k Vertical index of the data location on the model grid
n3vars The number of 3-D output variables
File
Usrdef Time Series.f90
Type
Subroutine
Purpose
Define specifiers for time series output.
Reference
Section 16.1.1
24.7. TIME SERIES OUTPUT 1109
File
Usrdef Time Series.f90
Type
Subroutine
Purpose
Define the 0-D variables for time series output.
Reference
Section 16.1.2.1
Arguments
out0ddat 0-D data. The variables are given in the same order as
they are defined in tsrvars.
n0vars The number of 0-D output variables
File
Usrdef Time Series.f90
Type
Subroutine
Purpose
Define the 2-D variables for time series output.
Reference
Section 16.1.2.2
Arguments
out2ddat 2-D output data. The variables are given in the same order
as they are defined in the array tsrvars.
1110 APPENDIX 24. DESCRIPTION OF USER DEFINED ROUTINES
File
Usrdef Time Series.f90
Type
Subroutine
Purpose
Define the 3-D variables for time series output.
Reference
Section 16.1.2.3
Arguments
out3ddat 3-D output data. The variables are given in the same order
as they are defined in the array tsrvars.
i X-index of the data location on the local model grid
j Y-index of the data location on the local model grid
k Vertical index of the data location on the model grid
n3vars The number of 3-D output variables
Appendix 25
Description of program
variables
25.1 Currents
MODULE currents
REAL, DIMENSION(1-nhalo:ncloc+nhalo,1-nhalo:nrloc+nhalo) :: udvel, uvdvel old,&
& vdvel, vdvel old
REAL, DIMENSION(1-nhalo:ncloc+nhalo,0:nrloc+1) :: umvel
REAL, DIMENSION(0:ncloc+1,1-nhalo:nrloc+nhalo) :: vmvel
REAL, DIMENSION(0:ncloc+1,nrloc) :: umpred
REAL, DIMENSION(ncloc,0:nrloc+1) :: vmpred
REAL, DIMENSION(ncloc+1,nrloc) :: udfvel
REAL, DIMENSION(ncloc,nrloc+1) :: vdfvel
REAL, DIMENSION(ncloc,nrloc) :: p2dbcgradatu, p2dbcgradatv, udevint, vdevint
REAL, DIMENSION(1-nhalo:ncloc+nhalo,1-nhalo:nrloc+nhalo,nz) :: uvel, uvel old,&
& vvel, vvel old
REAL, DIMENSION(2-nhalo:ncloc+nhalo,nrloc,nz) :: ufvel
REAL, DIMENSION(ncloc,2-nhalo:nrloc+nhalo,nz) :: vfvel
REAL, DIMENSION(0:ncloc,0:nrloc,nz+1) :: wvel
REAL, DIMENSION(ncloc,nrloc,nz) :: p3dbcgradatu, p3dbcgradatv, wphys
File
currents.f90
Type
Module
Purpose
Velocity arrays
1111
1112 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
Description
p2dbcgradatu X-component of the depth-integrated baroclinic pressure
gradient F1b [m2 /s2 ]
p2dbcgradatv Y-component of the depth-integrated baroclinic pressure
gradient F2b [m2 /s2 ]
p3dbcgradatu X-component of the baroclinic pressure gradient F1b [m/s2 ]
p3dbcgradatv Y-component of the baroclinic pressure gradient F2b [m/s2 ]
udevint Depth-integrated baroclinic terms δDh1 − δAh1 in the U -
equation [m2 /s2 ]
udfvel X-component of the filtered depth-integrated current Uf
[m2 /s]
udvel X-component of the depth-integrated current U [m2 /s]
udvel old X-component of the depth-integrated current U at the
previous 2-D time step [m2 /s]
ufvel X-component of the filtered 3-D current uf [m/s]
p
umpred X-component of the depth-mean current u at the pre-
dictor step [m/s]
umvel X-component of the depth-mean current u [m/s]
uvel X-component of the 3-D current u [m/s]
uvel old X-component of the 3-D current u at the previous cor-
rector (baroclinic) time step [m/s]
vdevint Depth-integrated baroclinic terms δDh2 − δAh2 in the V -
equation [m2 /s2 ]
vdfvel Y-component of the filtered depth-integrated current Vf
[m2 /s]
vdvel Y-component of the depth-integrated current V [m2 /s]
vdvel old Y-component of the depth-integrated current V at the
previous 2-D time step [m2 /s]
vfvel Y-component of the filtered 3-D current vf [m/s]
vmpred Y-component of the depth-mean current v p at the pre-
dictor step [m/s]
vmvel Y-component of the depth-mean current v [m/s]
vvel Y-component of the 3-D current v [m/s]
vvel old Y-component of the 3-D current v at the previous cor-
rector (baroclinic) time step [m/s]
25.2. DERIVED TYPE DEFINITIONS 1113
ExchComms
TYPE :: ExchComms
LOGICAL :: sfirst
INTEGER :: iddest, idsrce, tag
INTEGER, DIMENSION(2) :: i1rcv, i2rcv, j1rcv, j2rcv
INTEGER, DIMENSION(2) :: i1snd, i2snd, j1snd, j2snd
END TYPE ExchComms
File
datatypes.f90
Type
Derived type definition
Purpose
Parameters for exchange (send and receive) communications in parallel
mode
Description
iddest Destination process in case of a send operation
idsrce Source process in case of a receive operation
i1rcv Start (local) grid index in the X-direction for the receive opera-
tion
i1snd Start (local) grid index in the X-direction for the send operation
i2rcv End (local) grid index in the X-direction for the receive operation
i2snd End (local) grid index in the X-direction for the send operation
j1rcv Start (local) grid index in the Y-direction for the receive opera-
tion
j1snd Start (local) grid index in the Y-direction for the send operation
j2rcv End (local) grid index in the Y-direction for the receive operation
1114 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
j2snd End (local) grid index in the Y-direction for the send operation
sfirst Switch which determines for a local domain whether a send oper-
ation is performed before a receive operation (see Section 9.4.3.2)
tag Communication tag
FileParams
(MODULE datatypes)
TYPE :: FileParams
LOGICAL :: defined, info, opened, time regular
CHARACTER (LEN=1) :: form, status
CHARACTER (LEN=10) :: coherens version
CHARACTER (LEN=leniofile) :: filename, pathname
CHARACTER (LEN=lendesc) :: filedesc
CHARACTER (LEN=lentime-4) :: creation date
INTEGER :: endfile, header_type, iostat, iunit, lenrec, maxrecs, &
& nocoords, nodim, novars, timeid, timerec, tskips, &
& varid, zetaid
INTEGER, DIMENSION(3) :: tlims
END TYPE FileParams
File
datatypes.f90
Type
Derived type definition
Purpose
Global file attributes
Description
coherens version Current COHERENS version
creation date Date and time of creation
defined .TRUE. if the file is activated (status is different from
‘0’)
endfile Switch to select which action needs to be taken in case
an end of file condition occurs during input
0: The program aborts with an error message.
1: The program continues. No further read attempt
is made.
25.2. DERIVED TYPE DEFINITIONS 1115
GridParams
(MODULE datatypes)
TYPE :: GridParams
INTEGER :: nhtype, n1dat, n2dat
REAL :: delxdat, delydat, x0dat, y0dat
END TYPE GridParams
25.2. DERIVED TYPE DEFINITIONS 1117
File
datatypes.f90
Type
Derived type definition
Purpose
Attributes of surface grids
Description
delxdat Spacing in the X-direction in case of a regular grid
[meters or longitude]
delydat Spacing in the Y-direction in case of a regular grid
[meters or latitude]
nhtype Type of data grid
0: single point data grid or data grid not defined
1: rectangular grid with uniform grid spacings in Cartesian or
spherical coordinates (data grid is constructed from x0dat,
y0dat, delxdat, delydat)
2: rectangular grid with non-uniform spacings
3: non-rectangular (curvilinear or non-structured) grid
4: data grid coincides with the model grid
n1dat Number of grid points in the X-direction or, in case of a non-
rectangular grid, the total number of grid points
n2dat Number of grid points in the Y-direction or equal to one in case
of a non-rectangular grid
x0dat X-coordinate of the lower left (Southwest) corner in case of a
regular grid [meters or longitude]
y0dat Y-coordinate of the lower left (Southwest) corner in case of a
regular grid [meters or latitude]
HRelativeCoords
(MODULE datatypes)
TYPE :: HRelativeCoords
INTEGER :: icoord, jcoord
REAL :: xcoord, ycoord
END TYPE HRelativeCoords
1118 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
File
datatypes.f90
Type
Derived type definition
Purpose
Horizontal relative coordinates
Reference
Section 8.4.1
Description
icoord Integer part of the ξ1 curvilinear coordinate with respect to the
reference coordinate system
jcoord Integer part of the ξ2 curvilinear coordinate with respect to the
reference coordinate system
xcoord Fractional part of the ξ1 curvilinear coordinate with respect to
the reference coordinate system
ycoord Fractional part of the ξ2 curvilinear coordinate with respect to
the reference coordinate system
OutGridParams
(MODULE datatypes)
TYPE :: OutGridParams
LOGICAL :: gridded, grid file, land mask, time grid
CHARACTER (LEN=1) :: status
CHARACTER (LEN=lentime) :: enddate, refdate, startdate
INTEGER :: ncout, nodim, nostats, nowetout, nrout, nstepout, nzout, &
& time format
INTEGER, DIMENSION(3) :: tlims, xlims, ylims, zlims
REAL :: deltout
END TYPE OutGridParams
File
datatypes.f90
Type
Derived type definition
25.2. DERIVED TYPE DEFINITIONS 1119
Purpose
Parameters for user-defined output and attributes of output data grids
Description
deltout Output time step. Unit is seconds in case of an absolute
time. Otherwise, the unit is determined by the value of
time format.
enddate Date and time of the last output
gridded .TRUE. (.FALSE.) for gridded (non-gridded) output
grid file The coordinates of the output grid are written to a sepa-
rate external file if .TRUE.
land mask The data are written with a land mask (i.e. without land
points) if .TRUE.
ncout X-dimension of the output grid in case of gridded data
nodim Spatial dimension of the output grid (0,2,3)
nostats Number of output stations in case of non-gridded data
nowetout Number of wet output data in case a land mask is applied
nrout Y-dimension of the output grid in case of gridded data
nstepout Number of output time steps
nzout Vertical dimension of the output grid
refdate Reference date/time used when the time coordinate is writ-
ten in a numerical format in which case it is defined as the
time elapsed since this reference date.
startdate Date and time of the first output
status Status of the corresponding output files
‘W’ data are written to a newly created file
‘P’ data are appended to an existing file. This option is
currently not yet available.
time format Format of the time coordinate. The first and last case are
absolute times, the other ones relative times with respect
to the refdate
0: date/time in string format
1: seconds
2: minutes
3: hours
1120 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
4: days
5: months (one month is taken as 30.4375 days)
6: years (one year is taken as 365.25 days)
7: date in years
time grid Create a time-dependent grid if .TRUE. and nodim = 3.
tlims Start/end/step output time index. The step value deter-
mines the period in case of time-averaged or harmonic out-
put.
xlims Start/end/step output space index in the X-direction in
case of gridded data
ylims Start/end/step output space index in the Y-direction in
case of gridded data
zlims Start/end/step output space index in the vertical direction
StationLocs
(MODULE datatypes)
TYPE :: StationLocs
INTEGER :: ipos, jpos
CHARACTER (LEN=lenname) :: name
END TYPE StationLocs
File
datatypes.f90
Type
Derived type definition
Purpose
Attributes of the output station locations in case of non-gridded output.
The stations are assumed to be located at C-nodes.
Description
ipos C-node X-index of the stations
jpos C-node Y-index of the stations
name Name of the station
25.2. DERIVED TYPE DEFINITIONS 1121
VariableAtts
(MODULE datatypes)
TYPE :: VariableAtts
CHARACTER (LEN=lenname) :: f90 name
CHARACTER (LEN=lendesc) :: long name, vector name
CHARACTER (LEN=lenunit) :: units
CHARACTER (LEN=lennode) :: node
INTEGER :: data type, ivarid, klev, nrank, oopt
INTEGER, DIMENSION(4) :: shape
END TYPE VariableAtts
File
datatypes.f90
Type
Derived type definition
Purpose
Variable attributes
Description
f90 name FORTRAN 90 name
long name Long descriptive name
vector name Associated vector name in case the variable denotes a vec-
tor component
units Variable unit
node Nodal location of the variable on the model grid. In case
of user output, the nodal location on the output grid (‘C’
or ‘W’)
data type Data type of the variable (see Table 6.1)
ivarid Variable key id (a zero means undefined)
klev Vertical level used when oopt equals oopt klev
nrank Variable rank (0 for a scalar)
oopt Selects the operator to be applied in case the variable is
selected for user output
oopt null No operator applied
oopt min Minimum value
oopt max Maximum value
1122 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
VRelativeCoords
(MODULE datatypes)
TYPE :: VRelativeCoords
INTEGER :: kcoord
REAL :: zcoord
END TYPE VRelativeCoords
File
datatypes.f90
Type
Derived type definition
Purpose
Vertical relative coordinates
Description
kcoord Vertical level of the grid point along the reference grid just
below the data point
zcoord Normalised vertical distance from the vertical level kcoord to
the location of the data point (between 0 and 1)
25.3 Density
MODULE density
REAL, DIMENSION(0:ncloc+1,0:nrloc+1,nz) :: beta sal, beta temp, dens
REAL, DIMENSION(1-nhalo:ncloc+nhalo,1-nhalo:nrloc+nhalo,nz) :: sal, temp
File
density.f90
Type
Module
25.4. WATER DEPTHS 1123
Purpose
Density arrays
Description
beta sal Salinity expansion coefficient βS [PSU−1 ]
beta temp Temperature expansion coefficient βT [0 C−1 ]
dens Mass density ρ [kg/m3 ]
sal Salinity S [PSU]
temp Temperature T [0 C]
File
depths.f90
Type
Module
Purpose
Water depths and sea surface elevations
Description
depmeanatc Mean water depth at the C-nodes [m]
depmeanatu Mean water depths at the U-nodes [m]
depmeanatuv Mean water depth at the UV-nodes [m]
depmeanatv Mean water depth at the V-nodes [m]
depmeanglb Mean water depth (global) at C- (or -UV-nodes) [m]
deptotatc Total water depth at the C-nodes [m]
1124 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
25.5 Diffusion
MODULE diffusion
REAL, DIMENSION(0:ncloc,0:nrloc) :: hdifcoef2datc
REAL, DIMENSION(ncloc+1,nrloc+1) :: hdifcoef2datuv
REAL, DIMENSION(0:ncloc,0:nrloc,nz) :: hdifcoef3datc
REAL, DIMENSION(ncloc+1,nrloc,nz) :: hdifcoef3datu
REAL, DIMENSION(ncloc,nrloc+1,nz) :: hdifcoef3datv
REAL, DIMENSION(ncloc+1,nrloc+1,nz) :: hdifcoef3datuv
REAL, DIMENSION(0:ncloc,0:nrloc,nz+1) :: vdifcoefmom
REAL, DIMENSION(ncloc,nrloc,nz+1) :: vdifcoefscal, vdifcoeftke
File
diffusion.f90
Type
Module
Purpose
Horizontal and vertical diffusion coefficients
Description
hdifcoef2datc Vertically integrated horizontal diffusion coefficient νH
at the C-nodes [m3 /s]
hdifcoef2datuv Vertically integrated horizontal diffusion coefficient νH
at the UV-nodes [m3 /s]
25.6. FLUXES 1125
25.6 Fluxes
MODULE fluxes
REAL, DIMENSION(ncloc,nrloc) :: bfricatu, bfricatv, bstresatc, ces, &
& chs, qlatent, qlwave, qnonsol, qsensible, &
& ssalflux, sstresatc, ubstresatu, &
& usstresatu, vbstresatv, vsstresatv, zeros2d
REAL, DIMENSION(0:ncloc,0:nrloc) :: bdragcoefatc, cds, zroughatc
REAL, DIMENSION(0:ncloc,nrloc) :: usstresatc
REAL, DIMENSION(ncloc,0:nrloc) :: vsstresatc
REAL, DIMENSION(0:nwind,-ntemp:ntemp,nrelhum) :: cdstab, cestab, chstab
File
fluxes.f90
Type
Module
Purpose
Bottom and surface flux arrays
Description
bdragcoefatc Bottom drag coefficient Cdb at the C-nodes
bfricatu Bottom friction velocity u⋆b at the U-nodes [m/s]
1126 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
File
grid.f90
Type
Module
Purpose
Arrays for the model grid
Description
alphatc fld α-factor used in the drying/wetting algorithm at the C-
nodes
alphatu fld α-factor used in the drying/wetting algorithm at the U-
nodes
alphatv fld α-factor used in the drying/wetting algorithm at the V-
nodes
coriolatu Coriolis frequency at the U-nodes [rad/s]
coriolatv Coriolis frequency at the V-nodes [rad/s]
delxatc Grid spacing in the X-direction at the C-nodes [m]
delxatu Grid spacing in the X-direction at the U-nodes [m]
delxatuv Grid spacing in the X-direction at the UV-nodes [m]
delxatv Grid spacing in the X-direction at the V-nodes [m]
delyatc Grid spacing in the Y-direction at the C-nodes [m]
delyatu Grid spacing in the Y-direction at the U-nodes [m]
delyatuv Grid spacing in the Y-direction at the UV-nodes [m]
25.7. MODEL GRID ARRAYS 1129
File
gridpars.f90
Type
Module
Purpose
Model grid parameters
Description
delgrid Domain-averaged grid spacing for both X- and Y-direction
[m]
distrlx obc Maximum distance dmax (from the open boundaries) used
in the relaxation factor (5.279) for momentum advection
dXregX .TRUE. if the grid spacing in the X-direction is uniform
in the X-direction
dXregY .TRUE. if the grid spacing in the X-direction is uniform
in the Y-direction
dXYreg .TRUE. if all grid spacings are uniform in both X- and
Y-directions
dYregX .TRUE. if the grid spacing in the Y-direction is uniform
in the X-direction
25.8. MODEL GRID PARAMETERS 1135
General parameters
LOGICAL :: cold start = .FALSE., next simul = .FALSE.
INTEGER :: isimul = 0, nopenf = 0, nrecunit = 4
CHARACTER (LEN=lentitle) :: intitle, outtitle, runtitle
CHARACTER (LEN=lenname), DIMENSION(MaxProgLevels) :: procname
LOGICAL :: log fill = log undef
INTEGER :: int fill = int undef
REAL :: real fill = real undef, real min = real flag
File
iopars.f90
Type
Module
Purpose
General parameters mainly related to all kinds of input and output
Description
cold start If .TRUE., the program only executes the initialisation and
finalisation phases, but does not enter the time loop.
intitle Title for model forcing files
int fill Data flag for invalid integer data
isimul Number of the simulation (as given by the corresponding
line number in the defruns excluding comment lines)
log fill Data flag for invalid logical data
next simul When a new data line is read from the defruns file, its value
is set to .TRUE. to start a new simulation or to .FALSE. to
exit the program.
nopenf Number of current connected files
nrecunit Unit record size in bytes for direct access I/O (not used in
the present implementation)
outtitle Title for user output files
procname Name of the subprogram at the current program level
runtitle Simulation title
real fill Data flag for invalid real data
real min Real data are considered as valid or invalid if they are greater
than or lower than (or equal to) this critical threshold
1138 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
File
iopars.f90
Type
Module
Purpose
Parameters for model forcing
Description
ciflinenum Number of the last input line read from a CIF
ciffiles Attributes of CIFs
icif * Key ids of CIFs
icif defruns defruns file
icif model CIF with model setup parameters
25.9. GENERAL AND I/O PARAMETERS 1139
!---elliptic parameters
INTEGER, DIMENSION(nosetsanal,14) :: ivarsell
INTEGER, DIMENSION(nosetsanal,2) :: ivecell2d, ivecell3d
TYPE (VariableAtts), DIMENSION(14) :: ellvars
!---output operators
INTEGER, PARAMETER :: oopt null = 0, oopt dep = 1, oopt klev = 2, &
& oopt min = 3, oopt max = 4, oopt mean = 5
File
iopars.f90
Type
Module
Purpose
Parameters for user-defined output
Description
analgpars Attributes of the output grids for harmonic output
analgrd Attributes of the grid file for harmonic output con-
taining coordinate data only
analstatlocs Attributes of all output stations for harmonic output
(locations, names)
analvars Attributes of all variables for harmonic output
amp0d Attributes of the 0-D files for the harmonic output of
amplitudes
amp2d Attributes of the 2-D files for the harmonic output of
amplitudes
amp3d Attributes of the 3-D files for the harmonic output of
amplitudes
avrgpars Attributes of the output grids for time averaged out-
put
avrgrd Attributes of the grid file for time averaged output
containing coordinate data only
avrstatlocs Attributes of all output stations for time averaged
output (locations, names)
avrvars Attributes of all variables for time averaged output
avr0d Attributes of the 0-D files for time averaged output
25.9. GENERAL AND I/O PARAMETERS 1143
File
iopars.f90
Type
Module
Purpose
Parameters for monitoring
Description
desctimer Strings written to the timer report for each (active)
timer
25.9. GENERAL AND I/O PARAMETERS 1147
netCDF parameters
(MODULE iopars)
INTEGER :: char NF90 = 0, clobber NF90 = 0, fill NF90 = 0, global NF90 = 0,&
& int NF90 = 0, noerr NF90 = 0, nofill NF90 = 0, nowrite NF90 = 0,&
25.10. METEOROLOGICAL ARRAYS 1151
File
iopars.f90
Type
Module
Purpose
Aliases for parameters of the netCDF library
Description
char NF90 Alias for NF90 char
clobber NF90 Alias for NF90 clobber
fill NF90 Alias for NF90 fill
global NF90 Alias for NF90 global
int NF90 Alias for NF90 int
noerr NF90 Alias for NF90 noerr
nofill NF90 Alias for NF90 nofill
nowrite NF90 Alias for NF90 nowrite
offset 64bit NF90 Alias for NF90 offset 64bit
real NF90 Alias for NF90 real
share NF90 Alias for NF90 share
sizehint default NF90 Alias for NF90 sizehint default
unlimited NF90 Alias for NF90 unlimited
write NF90 Alias for NF90 write
File
meteo.f90
1152 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
Type
Module
Purpose
Meteorological data variables
Description
airtemp Air temperature interpolated in time and in space at
the C-nodes [0 C]
atmpres Atmospheric pressure interpolated in time and in space
at the C-nodes [Pa]
cloud cover Cloud cover interpolated in time and in space at the
C-nodes (between 0 and 1)
evapminprec Evaporation minus precipitation rate interpolated in
time and in space at the C-nodes [kg/m2 /s]
evaporation Evaporation rate interpolated in time and in space at
the C-nodes [kg/m2 /s]
precipitation Precipitation rate interpolated in time and in space at
the C-nodes [kg/m2 /s]
relhum Relative humidity interpolated in time and in space at
the C-nodes (between 0 and 1)
sst Sea surface temperature [0 C]
uwindatc X-component of the wind at 10m height interpolated
in time and in space at C-nodes [m/s]
vwindatc Y-component of the wind at 10m height interpolated
in time and in space at C-nodes [m/s]
File
modids.f90
25.12. NESTED SUB-GRIDS 1153
Type
Module
Purpose
Definitions of key ids for model variables. The key id name has the
form iarr ⋆ where ⋆ is the FORTRAN name of the variable.
File
nestgrids.f90
Type
Module
Purpose
Arrays for the setup of sub-grid nesting
Description
hnstctoc Relative horizontal coordinates of the C-node sub-grid
points with respect to the local C-node main grid
1154 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
2: relative coordinates
nohnstatc Local number of C-node (horizontal) sub-grid open boun-
dary points
nohnstatu Local number of U-node (horizontal) sub-grid open boun-
dary points
nohnstatv Local number of V-node (horizontal) sub-grid open boun-
dary points
nohnstcprocs Number of C-node sub-grid points for each sub-domain
and each sub-grid
nohnstglbc Global number of C-node (horizontal) sub-grid open boun-
dary points
nohnstglbu Global number of U-node (horizontal) sub-grid open boun-
dary points
nohnstglbv Global number of V-node (horizontal) sub-grid open boun-
dary points
nohnstuvprocs Number of U- and V-node sub-grid points for each sub-
domain and each sub-grid
nonestsets Number of sub-grid nests
novnst Number of vertical levels on the sub-grid
vnstctoc Relative vertical coordinates of the C-node sub-grid points
with respect to the local main C-node grid taken at the
four points surrounding each sub-grid point.
vnstctou Relative vertical coordinates of the C-node sub-grid points
with respect to the local main U-node grid taken at the
four points surrounding each sub-grid point.
vnstctov Relative vertical coordinates of the C-node sub-grid points
with respect to the local main V-node grid taken at the
four points surrounding each sub-grid point.
File
obconds.f90
Type
Module
Purpose
Parameters and arrays used to define open boundary conditions for the
2-D and 3-D mode or surface boundary conditions (surface slope and
elevations) for 1-D applications
Description
gxslope X-component of the (barotropic) pressure gradient in case
of a 1-D application [m/s2 ]
gxslope amp Amplitudes of the X-component of the (barotropic) pres-
sure gradient in case of a 1-D application [m/s2 ]
gxslope pha Phases of the X-component of the (barotropic) pressure
gradient in case of a 1-D application [rad]
gyslope Y-component of the (barotropic) pressure gradient in case
of a 1-D application [m/s2 ]
25.13. OPEN BOUNDARY CONDITIONS 1157
File
optics.f90
Type
Module
Purpose
Optical arrays
Description
optattcoef2 Inverse optical attenuation depth for the short-wave spec-
trum [m−1 ]
qrad Solar downard irradiance within the water column [W/m2 ]
radiance Solar irradiance incident on the surface [W/m2 ]
File
paralpars.f90
Type
Module
Purpose
Parameters for parallel applications
Description
bsend overhead MPI Alias for MPI bsend overhead
comm null MPI Alias for MPI comm null
comm work MPI communicator containing all worker (non-idle)
processes
comm world MPI Alias for MPI comm world
comprocs Array defining the rank order for all-to-all com-
munications (see Section 9.4.3.1)
halocomms Parameters for exchange (send/receive) communi-
cations
icoordloc Domain index in the X-direction of the local pro-
cess on the parallel grid
icoordprocs Array with the values of icoordloc for each process
iddomain Process ranks as defined on the parallel domain
grid
idloc Rank of the local process
idmaster Rank of the master process
idprocs Array of process ranks (global)
indexobuprocs Index mapping array at the U-open boundaries.
The element indexobuprocs(llloc,iproc) maps the lo-
cal open boundary index lloc on the local process
iproc to the corresponding global open boundary
index.
1162 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
!---inundation schemes
INTEGER, PARAMETER :: nofldmasks = 11
REAL :: dcrit fld = 0.1, dmin fld = 0.02, dthd fld = 0.1
INTEGER, DIMENSION(nofldmasks) :: fld mask
!---bottom/surface fluxes
REAL :: bdragcoef cst = 0.0, bdraglin = 0.0, ccharno = 0.014, &
& cds cst = 0.0013, ces cst = 0.00113, chs cst = 0.00113, ckar = 0.4, &
& zref atm = 10.0, zrough cst = 0.0
!---open boundary conditions
REAL :: cgravratio = 0.03
!---optical parameters
REAL :: optattcoef1 cst = 10.0, optattcoef2 cst = 0.067, opt frac = 0.54
!---parameters for exchange coefficients in tabular form
INTEGER :: nrelhum, ntemp, nwind
REAL :: drelhum = 0.05, dtempdif = 1.0, dtempmax = 5.0, dtempmin = -5.0, &
& dwind = 0.25, relhummax = 1.0, relhummin = 0.5, uwindmax = 50.0, &
& uwindmin = 3.0
!---numerical
REAL :: theta cor = 0.5, theta vadv = 0.501, theta vdif = 1.0
REAL, PARAMETER :: eps adv = 1.0E-12
File
physpars.f90
Type
Module
Purpose
Physical and numerical model parameters
Description
atmpres ref Reference atmospheric pressure Pref [Pa]
bdragcoef cst Constant bottom drag coefficient Cdb when
iopt bstres drag=1
bdraglin Bottom friction velocity klin used in the linear bottom
friction law if iopt bstres form=1 [m/s]
beta sal ref Reference value for the salinity contraction coefficient
βS [PSU−1 ]
beta temp ref Reference value for the temperature expansion coeffi-
cient βT [0 C−1 ]
25.16. PHYSICAL AND NUMERICAL MODEL PARAMETERS 1165
theta cor Implicity factor θc for the Coriolis term (between 0.0
and 1.0)
theta vadv Implicity factor θa for vertical advection (between 0.0
and 1.0)
theta vdif Implicity factor θd for vertical diffusion (between 0.0
and 1.0)
uwindmax Maximum wind speed taken to calculate the surface
exchange coefficients using the Monin-Obukhov theory
in tabular form [m/s]
uwindmin Minimum wind speed taken to calculate the surface
exchange coefficients using the Monin-Obukhov theory
in tabular form [m/s]
vdifmom cst Constant coefficient for vertical diffusion of momen-
tum used if iopt vdif coef=1 or as background value if
iopt turb iwlim=0 [m2 /s]
vdifscal cst Constant coefficient for vertical diffusion of scalars used
if iopt vdif coef=1 or as background value if
iopt turb iwlim=0 [m2 /s]
zref atm Reference height za for meteorological variables (taken
by default at 10 m height) [m]
zrough cst Constant bottom roughness length z0 taken when
iopt bstres drag=3 [m]
File
relaxation.f90
Type
Module
25.17. RELAXATION ZONES 1169
Purpose
Definitions for application of relaxation conditions near open bounda-
ries
Description
idirrlx Defines the orientation of each zone
1: western boundary
2: eastern boundary
3: southern boundary
4: northern boundary
indexrlxatc Each C-node grid point within a zone must have an as-
sociated boundary location. The array stores both the
corresponding zonal index and the (global) index of the
corresponding open boundary index. If the grid point is
outside all zones, its value is 0. The last array index refers
to either U-node (1) or V-node (2) boundaries.
indexrlxatuv Each velocity node grid point within a zone must have an
associated boundary location. The array stores both the
corresponding zonal index and the (global) index of the
corresponding open boundary index. If the grid point is
outside all zones, its value is 0. The last array index refers
to either U-node (1) or V-node (2) boundaries.
inodesrlx The first element disables (0) or enables (1) the application
of relaxation condition for C-node (scalar quantities), the
second element for quantities at velocity (U- or V-) nodes.
iposrlx (Global) X-index of the southwest corner of each relaxation
zone
ityprlx Type of interpolation (weighting) scheme within the relax-
ation zones
1: linear
2: quadratic
3: hyperbolic
jposrlx (Global) Y-index of the southwest corner of each relaxation
zone
ncrlx Sizes of the zones (number of C- or velocity-node grid
points) in the X-direction
norlxzones Number of relaxation zones
1170 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
File
switches.f90
Type
Module
Purpose
1172 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
Model switches
Reference
Section 12.4
Description
iopt adv scal Type of scheme for the advection of scalar quan-
tities
0: advection disabled
1: upwind scheme
2: Lax-Wendroff (explicit) in the horizontal, cen-
tral (semi-implicit) in the vertical
3: TVD scheme
iopt adv turb Type of scheme for the advection of turbulence
quantities.
0: advection disabled
1: upwind scheme
2: Lax-Wendroff (explicit) in the horizontal, cen-
tral (semi-implicit) in the vertical
3: TVD scheme
iopt adv tvd Type of limiting function for the TVD scheme.
1: superbee limiter
2: monotone limiter
iopt adv 2D Type of scheme for the advection of 2-D trans-
ports.
0: advection disabled
1: upwind scheme
2: Lax-Wendroff (explicit) in the horizontal, cen-
tral (semi-implicit) in the vertical
3: TVD scheme
iopt adv 3D Type of scheme for the advection of 3-D cur-
rents.
0: advection disabled
1: upwind scheme
25.18. MODEL SWITCHES 1173
iopt turb stab lev Selects the level for stability functions if iopt turb stab form=
3.
1: quasi-equilibrium method (Section 4.4.3.3)
2: non-equilibrium method (Section 4.4.3.3)
iopt turb stab mod Selects the type of closure (RANS) model.
1: MY82-model (Mellor & Yamada, 1982)
2: KC94-model (Kantha & Clayson, 1994)
3: BB95-model (Burchard & Baumert, 1995)
4: HR82-model (Hossain & Rodi, 1982)
5: CA01-model (Canuto et al., 2001)
6: CA02-model (Canuto et al., 2001)
iopt turb stab tke Formulation for the turbulent diffusion coefficient
νk (or stability coefficient Sk ) of turbulent en-
ergy.
1: constant value for Sk as given by equation (4.188)
2: Sk is taken as proportional to the momentum
stability function Su as given by (4.189)
3: using the formulation of Daly & Harlow (1970)
as given by (4.173) or (4.179)
iopt turb tke bcc Type of the bottom boundary condition for tur-
bulence energy.
1: Neumann condition (4.338)
2: Dirichlet condition (4.337)
iopt turb tke sbc Type of the surface boundary condition for tur-
bulence energy.
1: Neumann condition (4.271)
2: Dirichlet condition (4.269)
iopt vadv impl Time-integration for vertical advection
0: explicit
1: semi-implicit
2: implicit
iopt vdif coef Selects the (general) type of the vertical diffusion
scheme.
1184 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
!---cif file
CHARACTER (LEN=1), PARAMETER :: cifcom = ’!’, cifend =’#’, cifsep =’,’
!---user output
LOGICAL, PARAMETER :: DegreesOut = .TRUE.
CHARACTER (LEN=lenversion), PARAMETER :: model version = ’V2.1.2’
!---output formats
CHARACTER (LEN=lenformat), PARAMETER :: IntegerFormat=’(50I11)’,&
& RealFormat=’(50G16.7)’
!---undefined and zero values
LOGICAL, PARAMETER :: log undef = .FALSE.
INTEGER, PARAMETER :: int undef = -2147483647, izero = 0
INTEGER (KIND=kndilong), PARAMETER :: izero d = 0 kndilong, &
& longint undef = -2147483647 kndilong
REAL, PARAMETER :: real undef = -9.9692099683868690E+36, &
& real flag = -9.9692099683868690E+35, rzero = 0.0
REAL (KIND=kndlong), PARAMETER :: rzero d = 0.0 kndlong
CHARACTER (LEN=lentime), PARAMETER :: cdatetime undef = &
& ’xxxx/xx/xx;00:00:00,000’
1186 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
File
syspars.f90
Type
Module
Purpose
Constants and other system parameters. The Max* parameters are
mostly intended for the dimensioning of arrays which cannot be de-
clared as allocatable.
Description
DegreesOut Determines the unit of phases and angles in user-
defined output files
.TRUE. degrees
.FALSE. radians
IntegerFormat Format string used for reading/writing integer data
from/to a ASCII (‘A’) file in standard COHERENS
format
MaxAstroTides Maximum allowed number of constituents for the as-
tronomical forcing
MaxBioArids Maximum available number of key ids for biological
array variables. Currently not implemented.
MaxCIFTypes Maximum number of CIF files
MaxCIFVars Maximum number of data variables on a CIF line
MaxConstituents Maximum allowed number of tidal constituents at open
boundaries
MaxErrCodes Maximum number of key ids for error messages
MaxErrMesgs Default maximum number of error messages
MaxGenerators Maximum available number of random generators which
can be simultaneously used in the program
MaxGridFiles Maximum number of surface grid files for each grid
type. Current value is 1.
MaxGridTypes Maximum number of surface grid types
MaxHaloComms Maximum available number of exchange communica-
tions (send or receive)
MaxIOFiles Maximum number of forcing files for a given file de-
scriptor key id.
25.19. CONSTANTS AND SYSTEM PARAMETERS 1187
File
tide.f90
Type
Module
Purpose
Parameters and arrays for tidal forcing
Description
astro ampl Amplitudes of the astronomical equilibrium tide [m]
astro earth Elasticity factor αqn representing the effect of the Earth
tides on the tidal force
fnode astro Nodal factors of the constituents used for the astro-
nomical tidal force
fnode obc Nodal factors of the tidal constituents used at open
boundaries
fxastro X-component of the astronomical tidal force [m2 /s]
fyastro Y-component of the astronomical tidal force [m2 /s]
icon ⋆ Key ids of all tidal constituents
index astro Key ids of the constituents used in the calulcation of
the astronomical force
index obc Key ids of the constituents used at the open bounda-
ries
ispec tides Tidal species indices q for each frequency
nconastro Number of tidal constituents used in the calculation
of the astronomical force
nconobc Number of tidal constituents used at open boundaries
phase astro Astronomical phases of the constituents used for the
astronomical tidal force, at Greenwhich. Nodal cor-
rections are included if iopt astro pars=2. [rad]
phase obc Astronomical phases of the constituents used at open
boundaries with respect to the reference longitude
dlon ref obc. Nodal corrections are included if iopt -
astro pars=2. [rad]
25.21. TIME PARAMETERS 1191
File
timepars.f90
Type
Module
Purpose
Time parameters
Description
CDateTime Current date and time in string format
CEndDateTime End date and time in string format
CStartDateTime Start date and time in string format
ClockTime Date and time from the machine’s internal real-time
clock at the start of the simulation
IDateTime Current date and time in integer vector format
IEndDateTime End date and time in integer vector format
IStartDateTime Start date and time in integer vector format
1192 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
File
turbpars.f90
Type
Module
1194 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
Purpose
Parameters for turbulence schemes
Description
alpha Black constant α1 in the Blackadar (1962) mixing length for-
mulation (4.205)
alphaM max maximum value for the stability parameter αM in case
of stable stratification when the the non-equilibrium
method is applied
alphaN max maximum value for the stability parameter αN in case
of stable stratification
alphaN min minimum value for the stability parameter αN in case
of unstable stratification
alphaN sl slope of the limiting curve for αN in the case of a stable
stratification
alpha ma parameter αm in the Munk & Anderson (1948) scheme
(4.125)–(4.128)
alpha pp parameter αp in the Pacanowski & Philander (1981)
scheme (4.121)–(4.123)
beta ma parameter βm in the Munk & Anderson (1948) scheme
(4.125)–(4.128)
beta Xing attenuation factor β1 in the Xing & Davies (1996) mix-
ing length formulation (4.203)
cfequil coefficients Cd used in the equilibrium formulation (4.182–
4.183) for the stability functions
cfstabtke coefficients used in the non-equilibrium (4.173) or the
quasi-equilibrium (4.179) method for the stability func-
tion Sk
cfstab1 coefficients Cb or Cc used in the quasi-equilibrium for-
mulation (4.175) or (4.178) for the stability functions
cfstab2 coefficients Ca used in the non-equilibrium formulation
(4.170) for the stability functions
cnu ad parameter Cν in equation (4.140)
c1 eps constant c1ε in the shear production term of the ε-
equation (4.193)
c2 eps constant c2ε in the dissipation term of the ε-equation
(4.193)
25.22. TURBULENCE MODEL PARAMETERS 1195
c31 eps constant c3ε in the buoyance sink term of the ε-equation
(4.193) in case of stable stratification (N 2 > 0)
c32 eps constant c3ε in the buoyancy source term of the ε-
equation (4.193) in case of unstable stratification (N 2 <
0)
c sk Daly-Harlow parameter csk in (4.165)
delta1 ad parameter δ1 in equation (4.132)
delta2 ad parameter δ2 in equation (4.132)
dissipmin numerical lower limit εmin for ε [W/kg]
eps0 parameter ǫ0 as defined by (4.270)
expmom ma parameter n1 in the Munk & Anderson (1948) scheme
(4.125)–(4.128)
expmom pp parameter np in the Pacanowski & Philander (1981)
scheme (4.121)–(4.123)
expscal ma parameter n2 in the Munk & Anderson (1948) scheme
(4.125)–(4.128)
e1 my constant E1 in the shear production term of the kl-
equation (4.197)
e2 my constant E2 in the wall proximity term (4.198) of the
kl-equation (4.197)
e3 my constant E3 in the buocancy source/sink term of the
kl-equation (4.197)
f0stabmom neutral stability coefficient Su0 for momentum (quasi-
equilibrium or equilibrium method)
f0stabscal neutral stability coefficient Sb0 for scalars (quasi-equilibrium
or equilibrium method)
f0stabtke constant stability coefficient Sk0 for turbulent kinetic
energy
ib22 Equals 1 when the parameter c22β 6= 0, 0 otherwise
k1 ad parameter K1 in equations (4.137) and (4.139)
k2 ad parameter K2 in equation (4.138)
lambda ad parameter λ⋆ in equation (4.135) [m]
omega1 ad parameter ω1 in equation (4.140) [s−1 ]
riccrit iw critical Richardson number Ri0 in the Large et al.
(1994) background mixing scheme (4.215)
1196 APPENDIX 25. DESCRIPTION OF PROGRAM VARIABLES
File
turbulence.f90
Type
Module
Purpose
Turbulence arrays
Description
buofreq2 Squared buoyancy frequency N 2 [1/s2 ]
dissip Dissipation of turbulent kinetic energy [W/kg]
tke Turbulent kinetic energy [J/kg]
tke old Turbulent kinetic energy at the old 3-D time step [J/kg]
2
shearfreq2 Squared shear frequency M [1/s2 ]
zlmix Turbulent mixing length [m]