PSMILe interface proposal

3 - Routines for grid declaration

>WP3a:commented (14/06/2002)

>IPSL : comments (02/07/02)

>WP3a:comments (16/07/02 or 26/07/02)


-in green: IPSL last comments
-in red: WP3A new comments or WP3a old comments that still need to be discussed,
-in orange: modifications that wp3a/wp4a agreed on.
-in black and small characters: WP3a old comments on issues that are solved
-in magenta and small character: text that wp3a/wp4a agreed that should be removed


Content:
> IPSL or
> WP3A

>WP3a: Our comments on this section on the grid declaration will be pretty basic and we will make no proposition, as we feel we still need more (joint wp3a-wp4a) thinking on this delicate aspect of the PSMILe.
>IPSL : Yes we too. Alexandre needs to think it through as well for the PMIOD content.
>WP3A: We now make a more detailed proposition below.

The function for the definition of the grids are based on the assumption that all grids in geophysical models are decomposed in horizontal, vertical and time coordinates. This should be pretty general as in all cases we deal with stratified fluids and there is little reason to work with grids which are fully 3D.
>WP3a: We should allow,  in the description of a 3D grid, for the case in which the grid can be simply expressed as a 2D grid reproduced over a vertical axis. But even in this case, we think that only one grid Id should be given to identify this 3D grid.

Horizontal grids :
Name :
PSMILe_def_horigrid() interface for :
Description :
These function allow to define and describe a grid. These grids will then be used latter as a basis for the definition of variables.
This system clearly favors rectangular grids on the global. A stereographic grid, or other projects which do not fit into a rectangular presentation will need to switch to the general interface.
>WP3a: OK
The names of the coordinates are describe the entire grid and not the axes. This information will be derived from the other information in the argument list.
>WP3a: meaning ???
A question remains opens here, is the mask a property of the grid and/or the variable. In fact the grid here is a geophysical entity which exists whether the model simulates something over it or not and thus no masking is justified. The consequence here is that it obliges all variables which will come will need to be masked if they do not cover the entire domain. If on the contrary if the mask is a property of the grid then it will not be able to evolve with time.

>WP3a: we favour use of separate function to define the mask.

>IPSL : In general we believe it would be a good substitute to have 'Optional subroutine' instead of 'optional arguments' but this requires a clear definition of dependences. i.e. A mask can not be defined if the grid does not yet exist and so on.


>WP3a: Yes; our proposition below follows this principle.

A flow diagram for the PSMILe_def_horigrid function

Arguments:

name: Name of the horizontal grid.


>WP3a: We do not understand this argument. What is its use?
>IPSL : Well this is the argument which allows us to link the information from the model to the one in the SMIOC. As a matter of principle we believe that the model should provide two pieces of information which should also be in the SMIOC. The first one would be to identify the variables (or element) and the other to verify that there is no mistake. More redundancy would be better but it would obviously make the interface more complex.
>WP3A: ??? (Sophie: I personally still do not understand this argumentation)

>WP3a: An argument that may be missing above is an array of integer describing the local partition with respect to the global grid (let's call it center_shape). For ortho and rect grid, a many-block partition should be supported. For unstructured grid (gen), a many-segment partition should be supported. ... We are still discussing this aspect, more on this later...
>IPSL : we do not understand this ! Is this for the description of the domain decomposition ?
>WP3a: size_inx (and) size_iny are not sufficient. We need to describe the "valid" range and the "actual" range of the array (see our proposition below).
>Vertical grids :
For vertical grids we have the extra difficulty that we need to allow for coordinate systems which depend on a prognostic grid of the model. This requires that a function be provided and that the correct variable is also available at the right time during execution so that the vertical grid can be evaluated. The case in point here are the sigma abd hybrid levels used by AGCMs. If this is not done properly the PSMILe will not be able to forward the right information to any vertical interpolation process.
One could also think about putting a mask on this coordinate as well, but in the vertical axis it becomes clear that it should be time varying (think about mountains cutting in a pressure level system) and thus a property of the variable.
A flow diagram for the PSMILe_def_vertgrid function


------------------------------

>WP3A: Our new proposition for the definition of the grid and related variables is the following. More information on the wp3a discussions that led to this proposition can be found in http://www.cerfacs.fr/PRISM/MTCI/grid_def.html.

Note: We have to make the distinction here between the rank of a variable (i.e. the number of informatic dimensions) and the number of physical dimensions covered by the variable. Hereafter, I will respectively use the words "rank" and "physical dimensions". Each physical dimension will be described by one coordinate array.

For example, an unstructured grid covering a 2D physical space will be a grid of physical dimension 2 but the localisation of the grid points will be expressed with arrays of rank 1, e.g. longitude(nbr_pts), latitude(nbr_pts).

Note: We suppose below that each 3D grid is identified by one grid_id.
Sophie: Even if we finally decide to work with 3D grids decomposed in a 2D horizontal grid and a 1D vertical axis, (personally I tend to prefer that option as I think it is more intuitive for our type of geophysical codes) the 1D and 2D routines below would still be relevant. In that case, the 3D mask could be given by a  a 2D array given the number of unmasked level for each horizontal grid point.

Grid definition:

Name:
PRISM_def_grid (grid_id, comp_id, grid_valid_shape, grid_nodims, grid_type, ierror )
Responsible: NEC-CCRLE/CERFACS

Description :
     This routine announces a grid and describes its structure. The localisation of the grid points and other characteristics will be described by other routines. The link will be made through the grid identifier.

Arguments:
 
grid_id [OUT]  unique identifier of the grid 
comp_id [IN] component Id as given by PRISM_init_comp
grid_valid_shape [IN] ilow,ihigh,[jlow,jhigh],[klow,khigh] of valid range, without halo regions
grid_nodims  [IN] indicates the rank of the arrays describing the grid (e.g. grid_valid_shape)
grid_type [IN} PRISM integer named parameter describing the structure of the grid

Note 1: We need to describe the minimum and maximum index values of each dimension for the "valid" part of the array that is effectively treated by the process, without the halo region (for example, if the extent of the first dimension is 100, it may be that the "valid" part of the array goes from 2 to 98); that information is in our xxx_valid_shape arguments above.
Furthermore, we will need also to describe the minimum and maximum index values of each dimension of the "actual" data array including the halo region (for example, if the extent of the first dimension is 100, it may be that the index goes from 0 to 99, or from 1 to 100); that information is in our xxx_actual_shape arguments below.

Note 2: Some examples of grid_type and the related way of describing the grid point localisation could be:
-"1D_lon" for a 1D grid expressed as a vector of longitudes, center_1stcoord_array(i) -see below.
-"2D_reglonlat" for a  2D grid expressed as vectors of longitudes and latitudes, center_1stcoord_array(i) and center_2ndcoord_array(j).
-"2D_irrlonlat" for a  2D grid expressed as arrays of longitudes and latitudes, center_1stcoord_array(i,j) and center_2ndcoord_array(i,j).
-"2D_reglondep" for a  2D grid expressed as vectors of longitudes and depths, center_1stcoord_array(i) and center_2ndcoord_array(k).
-"2D_unstruclonlat" for a  2D grid expressed as vectors of longitudes and latitudes, center_1stcoord_array(nbr_pts), and center_2ndcoord_array(nbr_pts).
-"3D_reglonlatdep" for a  3D grid expressed as vectors of longitudes, latitudes and depths, center_1stcoord_array(i) and center_2ndcoord_array(j), and center_2ndcoord_array(k).

>Sophie 26/07/02:
Note 3: A more complete list of grid_type supported by the PSMILe could be.

1-dimensional grids 2-dimensional grids 3-dimensional grids


Grid center localisation:
 

Name:
PRISM_set_center_1D (grid_id, center_actual_shape, center_1stcoord_array, ierror )
Responsible: NEC-CCRLE/CERFACS

Description:
This routine defines the localisation of the center coordinate array of a grid covering a 1D physical space.

Arguments:
 
grid_id [IN] value received from PRISM_def_grid
center_actual_shape [IN] array containing minimum and maximum index values for the informatic dimension (1). This must cover at least the grid_valid_shape region but can also include halo regions.
center_1stcoord_array [IN] Describe the coordinate of the grid centers (the shape this array depends on  grid_type)

Name:
PRISM_set_center_2D (grid_id, center_actual_shape, center_1stcoord_array, center_2ndcoord_array,  ierror )
Responsible: NEC-CCRLE/CERFACS

Description:
This routine defines the localisation of the center 2 coordinate arrays of a grid covering a 2D physical space.

Arguments:
 
grid_id [IN] value received from PRISM_def_grid
center_actual_shape [IN] array containing minimum and maximum index values for each informatic dimension (1, 2). This must cover at least the grid_valid_shape region but can also include halo regions.
center_1stcoord_array [IN] Describe the longitude of the grid centers (the shape this array depends on  grid_type)
center_2ndcoord_array [IN] Describe the latitude of the grid centers (the shape this array depends on grid_type)

Name:
PRISM_set_center_3D (grid_id, center_actual_shape, center_1stcoord_array, center_2ndcoord_array, center_3rdcoord_array, ierror )
Responsible: NEC-CCRLE/CERFACS

Description:
This routine defines the localisation of the center 3 coordinate arrays of a grid covering a 3D physical space.

Arguments:
 
grid_id [IN] value received from PRISM_def_grid
center_actual_shape [IN] array containing minimum and maximum index values for each informatic dimension (1, 2 or 3). This must cover at least the grid_valid_shape region but can also include halo regions.
center_1stcoord_array [IN] Describe the longitude of the grid centers (the shape this array depends on  grid_type)
center_2ndcoord_array [IN] Describe the latitude of the grid centers (the shape this array depends on grid_type)
center_3rdcoord_array [IN] Describe the depth of the grid centers (the shape this array depends on grid_type)


Grid corner localisation:
 

We propose to have one call to define the 2 "corners" of a 1D grid, one call to define the 4 "corners" of a 2D grid, and one call to define the 8 "corners" of a 3D grid.  In this case, each dimension of corner_1stcoord_array, corner_2ndcoord_array and corner_3rdcoord_array has one more element as compared to the dimensions of center_1stcoord_array and center_2ndcoord_array of the PRISM_set_location_xx, except for unstructured grid for which other specific routines should be defined.

We would define other routines if we ever need to specify more than 4 corners for 2D grids, or more than 8 corners for 3D grids.

Name:
PRISM_set_2corners_1D  (grid_id, corner_valid_shape, corner_actual_shape, corner_1stcoord_array, ierror)
Responsible: NEC-CCRLE/CERFACS

Description:
This routine defines the localisation of the corner coordinate array of a grid covering a 1D physical space.
Note: The "valid_shape" needs to be redefined as it may be different for the grid_valid_shape (the arrays do not have the same shape)

Name:
PRISM_set_4corners_2D  (grid_id, corner_valid_shape, corner_actual_shape, corner_1stcoord_array, corner_2ndcoord_array, ierror)
Responsible: NEC-CCRLE/CERFACS

Description:
This routine defines the localisation of the corner coordinate arrays of a grid covering a 2D physical space.

Name:
PRISM_set_8corners_3D  (grid_id, corner_valid_shape, corner_actual_shape, corner_1stcoord_array, corner_2ndcoord_array, corner_3rdcoord_array, ierror)
Responsible: NEC-CCRLE/CERFACS

Description:
This routine defines the localisation of the corner coordinate arrays of a grid covering a 3D physical space.


Mask definition
 

Name:
PRISM_set_mask (grid_id, mask_id, mask_actual_shape, mask_array, ierror)
Responsible: NEC-CCRLE/CERFACS

Description:
This routine defines the mask related to the grid with id grid_id. The mask will be attached to a variable in the PRISM_def_var call.
 
grid_id  [IN] value received from PRISM_def_grid
mask_id [OUT] handle to the defined mask
mask_actual_shape [IN] actual range of coordinates, must cover at least grid_valid_shape but can also include halo regions
mask_array [IN] The rank of mask_array can be 1, 2, or 3 (defined by grid_type associated with the grid_id)

Scale factor definition
 
Name:
PRISM_set_scalefactor(grid_id, scalefactor_actual_shape, scalefactor_array, ierror)
Responsible: NEC-CCRLE/CERFACS

Description:
This routine defines the scale factors describing the area of the meshes of the grid with id grid_id.
 
grid_id  [IN] value received from PRISM_def_grid
scalefactor_actual_shape [IN] Array containing the minimum and maximum index values for each informatic dimension (1, 2 or 3). This must cover at least the grid_valid_shape region but can also include halo regions.
scalefactor_array [IN] This array will have one extra dimension (as compared to the shape of center_array), this extra dimension being of extent 2 for 2D grids -2 scale factors are needed) or of extent 3 for 3D grids -3 scale factors are needed.


Local rotation angle definition
 

Name:
PRISM_set_angle (grid_id, angle_actual_shape, angle_array, ierror)
Responsible: NEC-CCRLE/CERFACS

Description:
This routine defines the local rotation angle at the center of the grid with id grid_id.
Arguments:
grid_id  [IN] value received from PRISM_DefineBlock
angle_actual_shape [IN] Array containing the minimum and maximum index values for each informatic dimension (1, 2 or 3). This must cover at least the grid_valid_shape region but can also include halo regions.
angle_array [IN] The rank of angle_array can be 1, 2, or 3 (defined by grid_type associated with the grid_id)