2.5. Build initial and boundary conditions#
Initial and boundary conditions, here after “ibc” (surface elevation, 3D currents, barotropic currents, temperature and salinity, eventually other tracers) for realistic simulations are extracted from an ocean (re-)analysis (generally at lower resolution, and encompassing a larger area), named in the following OGCM.
Initial conditions are interpolated over the whole 3D CROCO grid at the initialization date, while boundary conditions are interpolated for the whole simulation timeseries but only at the 4 lateral grid boundaries. A sponge layer in CROCO ensures a smooth transition between the boundary and the interior values.
These 2 processing steps are performed with make_ini.py and make_bry.py scripts.
The different steps to build ibc are:
Extrapolate values on mask
At each Z-level of the OGCM grid, interpolate each field on the CROCO horizontal grid
Then, interpolate on the vertical sigma-coordinates
For velocities (u,v vectors), project them on the grid angle, and shift them to the u,v grid
2.5.1. User-defined parameters#
All the requested user-defined parameters to build the IBC conditions are
gathered in a configuration file, here named ibc.ini.
This file contains:
The [Croco_Files] section defines the path and prefix for CROCO files:
|
Path of the CROCO files directory |
|
Prefix for the CROCO grid file |
|
Prefix used for the CROCO initial file, usually = croco_ini |
|
Prefix used for CROCO boundary files, usually = croco_bry |
|
How boundary files are splitted (options: MONTHLY,YEARLY,FULL) |
The [Zoom_Options] section defines if you are using the main grid
(parent grid) or a nested grid (zoom or child grid). If using agrif,
it will uses agrif_level as extension of created files.
|
True/False flag to define if the grid is a zoom or the main grid |
|
True/False flag to define if the grid is an agrif nested grid |
|
integer level of the agrif grid to consider (0 is parent, 1 is first child) |
The [Times] section defines dates of the simulation:
|
year, month, day, hour of the chosen start date to prepare initial and boundary conditions |
|
year, month, day, hour of the chosen end date to prepare boundary conditions |
|
year, month, day, hour of the time origin date |
The origin date defines the time at which the OGCM input data will be referenced in CROCO ibc files (e.g. days since XXXX:XX:XX). Note that it can be different from the reference of the source data input files (this reference is properly read in python tools), but it must be consistent between boundary and surface forcing conditions :
Note
Origin time and initial time can be different. Origin time should be consistent between boundary and forcing conditions.
The [Sigma_Params] section defines the stretching parameters for the sigma coordinate:
|
Vertical sigma-coordinate surface stretching parameter |
|
Vertical sigma-coordinate bottom stretching parameter |
|
Number of vertical sigma levels |
|
Vertical sigma-coordinate critical depth parameter, giving approximately the transition depth between the horizontal surface levels and the bottom terrain following levels. |
CROCO uses sigma coordinate, which is a generalized vertical terrain-following vertical coordinate system:
with:
\(\sigma\) a fractional vertical stretching coordinate, \(-1 \le \sigma \le 0\)
\(\zeta (x,y,\sigma)\) the free-surface
\(h(x,y)\) the ocean bottom
\(z_0 (x,y,\sigma)\) a nonlinear vertical transformation defined as:
with:
\(h_c\) a positive thickness controlling the stretching
\(Cs(\sigma)\) a nondimensional, monotonic, vertical stretching, \(-1 \le (C\sigma) \le 0\), defined as:
with:
and:
Warning
Note that sigma levels prescribed here during pre-processing MUST be
consistent with sigma parameters prescribed
for the run in croco.in (stretching parameters) and param.h
(number of vertical levels, N).
The [IBC_Options] section defines several parameters regarding the initial input data:
|
define boundary status: opened or closed (1=open , [S W E N]) |
|
used if you want to create a cycle in number of days on bry conditions:
typically, to have a repetition
of a year of boundary forcing |
|
list of tracers to consider. Names defined here must also be defined in your reader |
|
0/1 flag to correct the 3D velocities according to the barotropic OGCM transport,
i.e. for each water column remove the integrated tranport on the sigma
grid and add instead the OGCM transport:
|
|
minimum number of valid data in a given z-level layer to consider this z-level as valid. If at a certain depth this threshold is not reached, the level will be considered as not intersecting the ocean. |
Note
Initialization time for the simulation is set by Ystart, Mstart, Dstart, Hstart. Time in the input file is not considered for creating the initial file, only the time index, tndx, to select data in the input file is considered.
The [IBC_Input_Files] section defines directories and path of inputs and outputs files:
|
keyword of the reader to use as defined in |
|
path of OGCM input data |
|
prefix of OGCM input data filenames (expected filename form is
|
|
extension (e.g. .nc or .cdf) of OGCM input data filenames
(expected filename form is |
|
indicate the frequency of inputs to be read to build boundary conditions. Accepted format: 1M, 1D, 3h, 15m, 30s. This is used only in case of missing data at the begining or at the end of the wanted simulation period to duplicate the first or the last time step to be able to perform time interpolation. |
|
True/False flag to indicate if the different variables are in separated files or in the same input file |
|
if |
|
date in the filename of the initial file to read |
|
time index to read in the input file used for initial conditions |
In the provided example of ibc.ini, we use as initial and boundary
conditions the
Mercator product GLORYS12,
but already processed in a CROCO-like format by tools available for
downloading Mercator data in croco_tools.
An extraction from January 2013 to March 2013 is available in the tutorial
section of CROCO website: https://www.croco-ocean.org/trainings/, in the
section ‘Regional configuration (#define REGIONAL in cppdefs.h)’
under ‘Global datasets needed for preprocessing’. Here is the link to
download them: https://data-croco.ifremer.fr/CONFIGS_EXAMPLES/DATASETS_GLOB_INTER/CROCO/MERCATOR_GLOB_201301.tar.gz
The following 3 files are provided:
mercator_Y2013M1.cdfmercator_Y2013M2.cdfmercator_Y2013M3.cdf
These files are not “original” mercator files, and we will use the
mercator_croco keyword in readers.jsonc to differentiate their formatting.
2.5.2. Check or add reader for input data#
Check/edit the reader configuration, readers.jsonc, for these data.
In this example, we use the mercator_croco style of formatting:
"mercator_croco": {
"depth": "depth",
"lonr": "lonT",
"lonu": "lonU",
"lonv": "lonV",
"latr": "latT",
"latu": "latU",
"latv": "latV",
"ssh": "ssh",
"temp": "temp",
"salt": "salt",
"u": "u",
"v": "v",
"time": "time",
"time_dim": "time"
}
You can check the variables name from the input data by doing:
ncdump -h mercator_Y2013M1.cdf
If you have downloaded mercator data on your own (for example using the provided
script download_mercator.py)
, with a more “mercator-native”
format, you may rather use the mercator dictionnary:
"mercator": {
"depth": "depth",
"lonr": "longitude",
"lonu": "longitude",
"lonv": "longitude",
"latr": "latitude",
"latu": "latitude",
"latv": "latitude",
"ssh": "zos",
"temp": "thetao",
"salt": "so",
"u": "uo",
"v": "vo",
"time": "time",
"time_dim": "time"
},
If you have another type of input data, not already existing in reader
configuration (readers.jsonc), you can add it.
2.5.3. Build the initial conditions with make_ini.py#
Edit the
ibc.iniconfiguration file.Eventually edit the
readers.jsoncreader dictionnaryLaunch the script:
./make_ini.py ibc.ini
Check the generated file, which path and prefix is defined in
ibc.ini. In this example it will be:
croco_ini_mercator_croco_Y2013M01.nc
2.5.4. Build the boundary conditions with make_bry.py#
If not alreay done, edit the relevant sections in ibc.ini, and then launch:
./make_bry.py ibc.ini
Check the generated files in the directory defined in croco_dir.
In this example they will be:
croco_bry_mercator_croco_Y2013M01.nccroco_bry_mercator_croco_Y2013M02.nccroco_bry_mercator_croco_Y2013M03.nc
Note that make_bry is quite similar to make_ini, but you will have several time
frames in the output bry file, and only the four boundaries are computed
instead of the full 3D grid.