NWPconf  Version1.0
Functions
swan_model.sh File Reference

Module with functions specific to the SWAN model. More...

Functions

 swan_model_init ()
 Setup the environment for SWAN model. More...
 
 inputmodel_name ($1)
 
 swan_compute_scanning_mode ($1)
 Output the number to be used in the SWAN command file according to the scanning mode of the input grib file. More...
 
 swan_create_wind_input ($1, $2)
 Generate an input file with wind field suitable for the SWAN model from an input file in grib format. More...
 
 swan_create_bathymetry ($1, $2)
 Generate an input file with bathymetry suitable for the SWAN model from an input file in grib format. More...
 
 swan_make_grib ($1-$n-1, $n)
 Convert the SWAN gridded output into a file in grib format. More...
 

Detailed Description

Module with functions specific to the SWAN model.

This module provides functions specific to the sea wave model SWAN. Grid-related functions for SWAN support only regular latlon grids.

The following environmental variables should be set by the user when using the functions from present module:

Function Documentation

swan_model_init ( )

Setup the environment for SWAN model.

This functions is implicitly called when the module is sourced, it sets up the environment for SWAN model with reasonable defaults.

swan_compute_scanning_mode (   $1)

Output the number to be used in the SWAN command file according to the scanning mode of the input grib file.

This function scans the input grib file provided, reads the scanning mode of the first message and prints on stdout a number (either 2, 4 or 6) describing the grib scanning mode in the convention required by the SWAN command file as described in http://swanmodel.sourceforge.net/online_doc/swanuse/node26.html parameter idla of command READINP, e.g. for wind and bathymetry input. If the scanning mode is not handled by SWAN, 0 is printed.

Parameters
$1name of the grib file in input
swan_create_wind_input (   $1,
  $2 
)

Generate an input file with wind field suitable for the SWAN model from an input file in grib format.

This function interpolates all the 10m wind fields encountered in the input grib file on the grid defined for SWAN and outputs them in a text format suitable to be read by the SWAN model. The fields are interpolated on the configured latlon regular grid (other types of SWAN grids are not supported) according to $SWAN_NX, $SWAN_XMIN etc. environmental variables. The input projections supported are those supported by libsim package; input wind components with different values of component flag (wind rotation) are supported. The input scanning mode (i.e. order of points in the grib fields) is assumed to be the same for all wind fields and an equivalent value in the SWAN convention is computed and assigned to the variable $SWAN_WIND_SCMODE to be used in the SWAN command file, see swan_compute_scanning_mode() function.

The output text file should be read by SWAN using, in the command file, the key EXC -99999. in INPGRID command and the key FORMAT "(19X,F17.0)" in READINP command.

No check is made on the quantity and reference/forecast time of wind fields in input file, it is up to the user to make sure that they correspond to what SWAN expects.

Parameters
$1input file name in grib format
$2output file name in text format
swan_create_bathymetry (   $1,
  $2 
)

Generate an input file with bathymetry suitable for the SWAN model from an input file in grib format.

This function interpolates the field in the input grib file on the grid defined for SWAN and outputs it in a text format suitable to be read by the SWAN model. The field is interpolated on the configured latlon regular grid (other types of SWAN grids are not supported) according to $SWAN_NX, $SWAN_XMIN etc. environmental variables. The input projections supported are those supported by libsim package. The input scanning mode (i.e. order of points in the grib field) is read from the input file and an equivalent value in the SWAN convention is computed and assigned to the variable $SWAN_BATHY_SCMODE to be used in the SWAN command file, see swan_compute_scanning_mode() function.

The output text file should be read by SWAN using, in the command file, the key EXC -99999. in INPGRID command and the key FORMAT "(19X,F17.0)" in READINP command.

The input grib file should contain only a single grib field with the height of earth surface/sea bottom above sea level in m, no check is made on the correctness of the parameter. Points having a missing value or a value greater than -0.1 m in the input file are set to a missing value (EXC key) in the output.

Notice that, if the field is coded as a topography height (i.e. with negative values in sea points), a value of -1 for the fac key of the READINP command should be used in order to change the sign of the bathymetry values as expected by SWAN.

Parameters
$1name of input file in grib format
$2name of output file in text format
swan_make_grib (   $1-$n-,
  $n 
)

Convert the SWAN gridded output into a file in grib format.

This function converts a set of plain text files, generated by the SWAN model on the computational regular latlon grid with a command like TABLE 'COMPGRID'..., into a grib file using the ECMWF local table 140. The file name is assumed to be in the form <dirname>/<prefix>_<param>_<suffix> where <prefix> must not contain underscore characters and the value of <param> is used as the grib indicator of parameter for the variable in the file. It is assumed that each input text file contains data from start to end of run ($DATES$TIMES $DATEE$TIMEE) strictly at hourly intervals and the grib timerange is coded in forecast or analysis mode depending on the type of the run.

Parameters
$1-$n-1name of input plain text files
$nname of output grib file