Commit cbbd383b authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

NetCDF: added support for dimension name of x and y axis

parent 52f9ef37
2016-06-?? Uwe Schulzweida
* Version 1.7.2 released
2016-03-01 Uwe Schulzweida
* NetCDF: added support for dimension name of x and y axis
2016-02-19 Uwe Schulzweida
* Version 1.7.1 released
......
......@@ -759,6 +759,9 @@ int gridInqYvals(int gridID, double yvals[]);
/* gridDefXdimname: Define the dimension name of a X-axis */
void gridDefXdimname(int gridID, const char *xdimname);
/* gridInqXdimname: Get the dimension name of a X-axis */
void gridInqXdimname(int gridID, char *xdimname);
/* gridDefXname: Define the name of a X-axis */
void gridDefXname(int gridID, const char *xname);
......@@ -780,6 +783,9 @@ void gridInqXunits(int gridID, char *xunits);
/* gridDefYdimname: Define the dimension name of a Y-axis */
void gridDefYdimname(int gridID, const char *ydimname);
/* gridInqYdimname: Get the dimension name of a Y-axis */
void gridInqYdimname(int gridID, char *ydimname);
/* gridDefYname: Define the name of a Y-axis */
void gridDefYname(int gridID, const char *yname);
......
......@@ -777,6 +777,32 @@ void gridDefYunits(int gridID, const char *yunits)
}
}
/*
@Function gridInqXdimname
@Title Get the dimension name of a X-axis
@Prototype void gridInqXdimname(int gridID, char *dimname)
@Parameter
@Item gridID Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
@Item dimname Dimension name of the X-axis. The caller must allocate space for the
returned string. The maximum possible length, in characters, of
the string is given by the predefined constant @func{CDI_MAX_NAME}.
@Description
The function @func{gridInqXdimname} returns the dimension name of a X-axis.
@Result
@func{gridInqXname} returns the dimension name of the X-axis to the parameter dimname.
@EndFunction
*/
void gridInqXdimname(int gridID, char *xdimname)
{
grid_t *gridptr = gridID2Ptr(gridID);
strcpy(xdimname, gridptr->xdimname);
}
/*
@Function gridInqXname
@Title Get the name of a X-axis
......@@ -865,6 +891,32 @@ void gridInqXstdname(int gridID, char *xstdname)
xstdname[0] = 0;
}
/*
@Function gridInqYdimname
@Title Get the dimension name of a Y-axis
@Prototype void gridInqYdimname(int gridID, char *dimname)
@Parameter
@Item gridID Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
@Item dimname Dimension name of the Y-axis. The caller must allocate space for the
returned string. The maximum possible length, in characters, of
the string is given by the predefined constant @func{CDI_MAX_NAME}.
@Description
The function @func{gridInqYdimname} returns the dimension name of a Y-axis.
@Result
@func{gridInqYname} returns the dimension name of the Y-axis to the parameter dimname.
@EndFunction
*/
void gridInqYdimname(int gridID, char *ydimname)
{
grid_t *gridptr = gridID2Ptr(gridID);
strcpy(ydimname, gridptr->ydimname);
}
/*
@Function gridInqYname
@Title Get the name of a Y-axis
......
......@@ -445,6 +445,7 @@ module mo_cdi
public :: gridDefYvals
public :: gridInqYvals
public :: gridDefXdimname
public :: gridInqXdimname
public :: gridDefXname
public :: gridInqXname
public :: gridDefXlongname
......@@ -452,6 +453,7 @@ module mo_cdi
public :: gridDefXunits
public :: gridInqXunits
public :: gridDefYdimname
public :: gridInqYdimname
public :: gridDefYname
public :: gridInqYname
public :: gridDefYlongname
......@@ -4923,6 +4925,37 @@ contains
call lib_gridDefXdimname(gridID_dummy, xdimname_temp)
end subroutine gridDefXdimname
subroutine gridInqXdimname(gridID_dummy, xdimname_dummy)
integer(c_int), value :: gridID_dummy
character(kind = c_char, len = *), intent(inout) :: xdimname_dummy
character(kind = c_char) :: xdimname_temp(len(xdimname_dummy) + 1)
integer :: xdimname_i
interface
subroutine lib_gridInqXdimname(gridID_dummy, xdimname_dummy) bind(c, name&
& = 'gridInqXdimname')
import c_char, c_int
integer(c_int), value :: gridID_dummy
character(kind = c_char) :: xdimname_dummy(*)
end subroutine lib_gridInqXdimname
end interface
xdimname_temp(len(xdimname_dummy) + 1) = c_null_char
do xdimname_i = len(xdimname_dummy), 1, -1
if(xdimname_dummy(xdimname_i:xdimname_i) /= ' ') exit
xdimname_temp(xdimname_i) = c_null_char
end do
do xdimname_i = xdimname_i, 1, -1
xdimname_temp(xdimname_i) = xdimname_dummy(xdimname_i:xdimname_i)
end do
call lib_gridInqXdimname(gridID_dummy, xdimname_temp)
do xdimname_i = 1, len(xdimname_dummy)
if(xdimname_temp(xdimname_i) == c_null_char) exit
xdimname_dummy(xdimname_i:xdimname_i) = xdimname_temp(xdimname_i)
end do
do xdimname_i = xdimname_i, len(xdimname_dummy)
xdimname_dummy(xdimname_i:xdimname_i) = ' '
end do
end subroutine gridInqXdimname
subroutine gridDefXname(gridID_dummy, xname_dummy)
integer(c_int), value :: gridID_dummy
character(kind = c_char, len = *), intent(in) :: xname_dummy
......@@ -5096,6 +5129,37 @@ contains
call lib_gridDefYdimname(gridID_dummy, ydimname_temp)
end subroutine gridDefYdimname
subroutine gridInqYdimname(gridID_dummy, ydimname_dummy)
integer(c_int), value :: gridID_dummy
character(kind = c_char, len = *), intent(inout) :: ydimname_dummy
character(kind = c_char) :: ydimname_temp(len(ydimname_dummy) + 1)
integer :: ydimname_i
interface
subroutine lib_gridInqYdimname(gridID_dummy, ydimname_dummy) bind(c, name&
& = 'gridInqYdimname')
import c_char, c_int
integer(c_int), value :: gridID_dummy
character(kind = c_char) :: ydimname_dummy(*)
end subroutine lib_gridInqYdimname
end interface
ydimname_temp(len(ydimname_dummy) + 1) = c_null_char
do ydimname_i = len(ydimname_dummy), 1, -1
if(ydimname_dummy(ydimname_i:ydimname_i) /= ' ') exit
ydimname_temp(ydimname_i) = c_null_char
end do
do ydimname_i = ydimname_i, 1, -1
ydimname_temp(ydimname_i) = ydimname_dummy(ydimname_i:ydimname_i)
end do
call lib_gridInqYdimname(gridID_dummy, ydimname_temp)
do ydimname_i = 1, len(ydimname_dummy)
if(ydimname_temp(ydimname_i) == c_null_char) exit
ydimname_dummy(ydimname_i:ydimname_i) = ydimname_temp(ydimname_i)
end do
do ydimname_i = ydimname_i, len(ydimname_dummy)
ydimname_dummy(ydimname_i:ydimname_i) = ' '
end do
end subroutine gridInqYdimname
subroutine gridDefYname(gridID_dummy, yname_dummy)
integer(c_int), value :: gridID_dummy
character(kind = c_char, len = *), intent(in) :: yname_dummy
......
......@@ -1485,8 +1485,8 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID)
char ystdname[CDI_MAX_NAME];
char xaxisname[CDI_MAX_NAME];
char yaxisname[CDI_MAX_NAME];
char xdimname[4] = "x";
char ydimname[4] = "y";
char xdimname[CDI_MAX_NAME+3];
char ydimname[CDI_MAX_NAME+3];
int index;
int xdimID = UNDEFID;
int ydimID = UNDEFID;
......@@ -1508,15 +1508,20 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID)
size_t ydimlen = (size_t)gridInqYsize(gridID);
int gridindex = vlistGridIndex(vlistID, gridID);
gridInqXdimname(gridID, xdimname);
gridInqXname(gridID, xaxisname);
gridInqXlongname(gridID, xlongname);
gridInqXstdname(gridID, xstdname);
gridInqXunits(gridID, xunits);
gridInqYdimname(gridID, ydimname);
gridInqYname(gridID, yaxisname);
gridInqYlongname(gridID, ylongname);
gridInqYstdname(gridID, ystdname);
gridInqYunits(gridID, yunits);
if ( xdimname[0] == 0 ) xdimname[0] = 'x';
if ( ydimname[0] == 0 ) ydimname[0] = 'y';
for ( index = 0; index < ngrids; index++ )
{
if ( streamptr->xdimID[index] != UNDEFID )
......@@ -1871,6 +1876,7 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
char ystdname[CDI_MAX_NAME];
char xaxisname[CDI_MAX_NAME];
char yaxisname[CDI_MAX_NAME];
char xdimname[CDI_MAX_NAME+3];
int index;
int dimID = UNDEFID;
size_t len;
......@@ -1889,6 +1895,7 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
size_t dimlen = (size_t)gridInqSize(gridID);
int gridindex = vlistGridIndex(vlistID, gridID);
gridInqXdimname(gridID, xdimname);
gridInqXname(gridID, xaxisname);
gridInqXlongname(gridID, xlongname);
gridInqXstdname(gridID, xstdname);
......@@ -1898,6 +1905,8 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
gridInqYstdname(gridID, ystdname);
gridInqYunits(gridID, yunits);
if ( xdimname[0] == 0 ) strcpy(xdimname, "ncells");
for ( index = 0; index < ngrids; index++ )
{
if ( streamptr->xdimID[index] != UNDEFID )
......@@ -1924,19 +1933,17 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
if ( dimID == UNDEFID )
{
char axisname[CDI_MAX_NAME];
char vertname[CDI_MAX_NAME];
strcpy(axisname, "ncells");
strcpy(vertname, "vertices");
checkGridName('V', xaxisname, fileID, vlistID, gridID, ngrids, 'X');
checkGridName('V', yaxisname, fileID, vlistID, gridID, ngrids, 'Y');
checkGridName('D', axisname, fileID, vlistID, gridID, ngrids, 'X');
checkGridName('D', xdimname, fileID, vlistID, gridID, ngrids, 'X');
checkGridName('D', vertname, fileID, vlistID, gridID, ngrids, 'X');
if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
cdf_def_dim(fileID, axisname, dimlen, &dimID);
cdf_def_dim(fileID, xdimname, dimlen, &dimID);
size_t nvertex = (size_t)gridInqNvertex(gridID);
if ( nvertex > 0 ) cdf_def_dim(fileID, vertname, nvertex, &nvdimID);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment