PSMILe interface proposal

3 - Routines for grid declaration

(12/09/2002)

link to 26/07/2002 version


-in green: IPSL last comments (02/07/02)
-in red: WP3A new comments or WP3a old comments that still need to be discussed (16/07/02 or 26/07/02)
-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
- in purple: comments from Stephanie Legutke


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.
>SL: I agree , I do not see how  'reproduced' horizontal grid layers can be brought together: not only land/sea etc. masks are different for different layers in ocean models but also the vertical scale factors (in each cell!). And for the latter a simple rule as for the masks (no. of valid values from the surface downward) does not exist.

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 ???
>SL: I did not really understand the concept of axes:
What are the axes of a grid built from several rotated sperical grids? And of a stretched grid? I do not see that axes is a useful concept if it can not be defined for all grid ...
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.
> SL:To be exact, extendible, and flexible, one would have to define a land mask, a sea mask, an ice sheet mask, an SST mask, etc. A mask must not necessarily have only values 1 or 0. Any value between 0 and 1 could be allowed if the mask is a 'present/non-present' flag. This is an extension to the normal mask definition. To call it land/sea mask, the sum of the mask-value of both must be 1.
>WP3a: Yes; our proposition below follows this principle. Each variable can have a different grid.

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_040702.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 > Sophie 12/09: Do we need a "name" (and a "long name") argument in order to identify the grid in the SMIOC in order to get additional information (e.g. number of overlapping grid points for lat-lon grids)?


Grid center localisation:

>SL: if I am well informed (I put this into question here ) SCRIP needs (as long as interpolation is on a sphere) just the lat/lon of all corners of a cell. And the maximum number of corners a cell can have. Why do we need to give more than that? Do we need to allow the value to lie elsewhere than in the geometrical center (relevant for interpolation only not for averaging)? If  this  is not needed it can be calculated. To avoid the overhead of calculating it repeatedly one could think of a method similar to the one used in OASIS, i.e. let PSMILe calculate it if the information is needed but not available, otherwise take it from a file. This can be made more transparent to the user than is done presently in OASIS.

>Sophie 12/09: Do we need the "units" as argument, or will they be imposed?
>SL: the model can define its grid's lat/lon in radian, in east or west or whatever. But there is no need to provide for all that in the PSMILe parameter variables, since the grid for exchange-fields can be 'transformed' to be in degrees N/E. The question remains whether this grid transformation - if required - is to be done in the model or PSMILe. In any case, the units with which the interpolation is to be done, has to be specified. Since we are talking of earth climate models, I  vote for the unit which is most frequently used, i.e. degree E/N.
It should not be forgetten that the coupler is doing interpolation only, it will not solve the prognostics/diagnostic equations.

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)

** Refer to the above discussion for the vertical coordinates evolving during the run (hybrid, sigma, ...)**
 

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.

> Due to the strong stratification I see the need here, in contrast to the horizontal case, to also specify the vertical coordinate in addition to the upper and lower  boundaries.
 


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] Real: value between 0 and 1. The rank of mask_array can be 1, 2, or 3 (defined by grid_type associated with the grid_id)

> SL: There are several mask concepts: e.g. the sea mask can take on one of a number of specified integers to indicate to which basin the cell belongs (same for catchment definitions).
For a mask one has to define therefore, what it will be used for.  For interpolation purposes it would be sufficient to indicate whether an interpolation onto a cell of the target grid is needed, and which cells of the source grid to use (i.e. a 1/0 mask will do). Conservative averaging methods depend on the areas of the source and target grids, and therefore for these cases the mask (e.g. for atm<->oce heat flux calculation) should allow for values between 0 and 1. I would not recommend to rely on derived masks (e.g. sea  masks = 1-land mask) since this is not flexible if the cell is partitioned into more surface types later.
Normally the land and sea masks  do not change. And with them e.g. the SST mask does not change either.  However, this is only owned to the fact that small scale tidal drying is not simulated nor longterm  continental drift. Taking this into account, there is no conceptual difference between a land masks and the (gridded) variable describing the sea ice coverage or tracer concentration or the partial coverage of a grid cell by a vegetation type.
It does not make much sense, however, to call the sea-ice concentration a mask, since it is prognosed in the same way as e.g. sea-ice thickness (see the mail). And the same would be true for vegetation-type cell coverage.
Is it a practical way to define a mask to be a function on the grid that takes over values between 0 and 1 but does not change, and call everything else which has a prognostic equation a variable? E.g. the vegetation-type cell coverage is a mask as long as it does not change with time, while in models it is prognosed it is treated as a variable? There are potential conflicts with standard interfaces.
The decision (mask or variable) could also be made dependend on whether the variable is a potential exchange field (which implies that it changes or can change with time). This will go better with the concept of a standard interface.
> We should allow for more than one mask for the same grid: land/sea/lake/ice sheet(if not variable)/vegetation type coverage(if not variable). The latter is not really consistent with a standard interface where a variable should not be treated differently depending on whether it changes or not in a particular model. When the PRISM model is designed to be extendible to new components (ice sheets) then this holds for all masks. And we end up with considering a mask to be a variable with, if the case, exchange frequency 0.

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.

> SL: again I do not see the need to do this by the user. If the interpolation needs it, it can be calculated from the 'corners' . I think the user should be asked to give as little information as possible.


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)

>Sophie 12/09: Additional information will probably needed when we will address unstructured grid (e.g. connectivity) and/or 3D coupling in more details. This additional information could be given by an additional routine such as a PRISM_def_connectivity.