The grid data files grids.nc, masks.nc and areas.nc can be created by the user before the run or can be written directly at run time by the master process of each component model (except when OASIS3 is used in ``IPSL'' parallel mode, see section 8.2.1).
If written by the component models, the writing of those grid files is driven by OASIS3 main process. It first checks whether the binary file grids or the netCDF file grids.nc exists (if it is the case, it assumes that areas or areas.nc and masks or masks.nc files exist too), or if writing is needed. If grids or grids.nc exists, it must contain all grid information from all models; the file will not be completed or overwritten even if the following routines are explicitely called. If grids or grids.nc does not exist, each model must write its grid, mask and area definition in the grid data files with the following routines.
The coupler sends the information on whether or not writing is needed
to the models following an OASIS3 internal order (below
prism_start_grids_writing called by the component master process).
If the grid data files already exist in the working directory, nothing
happens when the component model calls the prism_write_grid,
prism_write_corner, prism_write_ang,
prism_write_mask,
prism_write_area routines;
the grid information is NOT overwritten in the grid files. If
writing is needed, the first model creates the files, writes the data
arrays when calling the appropriate routines,
and then sends a termination flag to the coupler (below
prism_terminate_grids_writing call). The coupler will then send the
starting flag to the next model; this ensures that only one model
accesses the files at a time.
This section describes the PSMILe routines to be called by the master process of each component model to write, at run time, the whole grid information to the grid data files. These routines have to be called just after prism_init_comp_proto.
As an example, see the TOYOASIS3 coupled model components that use these routines to write the grid data files (effective if gridswr=1 in the running script run_toyoasis3, see section 8.3).
Module to be used by the component model to call grid writing routines.
Writing of the model grid longitudes and latitudes. Longitudes must be given in degrees East in the interval -360.0 to 720.0. Latitudes must be given in degrees North in the interval -90.0 to 90.0. Note that if some grid points overlap, it is recommended to define those points with the same number (e.g. 90.0 for both, not 450.0 for one and 90.0 for the other) to ensure automatic detection of overlap by OASIS (which is essential to have a correct conservative remapping SCRIPR/CONSERV, see section 6.4).
Writing of the grid cell corner longitudes and latitudes (counterclockwise sense). Longitudes must be given in degrees East in the interval -360.0 to 720.0. Latitudes must be given in degrees North in the interval -90.0 to 90.0. Note also that cells larger than 180.0 degrees in longitude are not supported. Writing of corners is optional as corner information is needed only for some transformations (see section 7.2). If called, prism_write_corners needs to be called after prism_write_grids.
Writing of the grid angles; needed only if coupling fields are vector fields defined on a grid which has a local coordinate system not oriented in the zonal and meridional directions. The angle is defined as the angle between the vector first component and the zonal direction. See SCRIPR/CONSERV in section 6.3.
If called, prism_write_angle needs to be called after prism_write_grids.
Termination of grids writing. A flag stating that all needed grid information was written will be sent to OASIS3 main process.