Commit 590d54a5 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

replace gridDefXdimname/gridDefYdimname by cdiGridDefString

parent c5255e07
......@@ -772,9 +772,6 @@ int cdiGridDefString(int gridID, int key, int size, const char *mesg);
// cdiGridInqString: Get a CDI grid string value from a key
int cdiGridInqString(int gridID, int key, int size, char *mesg);
/* 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);
......@@ -796,9 +793,6 @@ void gridDefXunits(int gridID, const char *xunits);
/* gridInqXunits: Get the units of a X-axis */
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);
......
......@@ -601,6 +601,20 @@ void gridName(int gridtype, char *gridname)
strcpy(gridname, gridNamePtr(gridtype));
}
static
char *grid_key_to_string(grid_t *gridptr, int key)
{
char *gridstring = NULL;
switch (key)
{
case CDI_GRID_XDIMNAME: gridstring = gridptr->xdimname; break;
case CDI_GRID_YDIMNAME: gridstring = gridptr->ydimname; break;
}
return gridstring;
}
/*
@Function cdiGridDefString
@Title Define a CDI grid string value from a key
......@@ -625,12 +639,10 @@ int cdiGridDefString(int gridID, int key, int size, const char *mesg)
if ( size == 0 || mesg == NULL || *mesg == 0 ) return -1;
grid_t *gridptr = gridID2Ptr(gridID);
char *gridstring = NULL;
switch (key)
char *gridstring = grid_key_to_string(gridptr, key);
if ( gridstring == NULL)
{
case CDI_GRID_XDIMNAME: gridstring = gridptr->xdimname; break;
default:
Warning("CDI grid string key %d not supported!", key);
return -1;
}
......@@ -668,12 +680,9 @@ int cdiGridInqString(int gridID, int key, int size, char *mesg)
if ( size == 0 || mesg == NULL || *mesg == 0 ) return -1;
grid_t *gridptr = gridID2Ptr(gridID);
const char *gridstring = NULL;
switch (key)
const char *gridstring = grid_key_to_string(gridptr, key);
if ( gridstring == NULL)
{
case CDI_GRID_XDIMNAME: gridstring = gridptr->xdimname; break;
default:
Warning("CDI grid string key %d not supported!", key);
return -1;
}
......@@ -683,30 +692,6 @@ int cdiGridInqString(int gridID, int key, int size, char *mesg)
return 0;
}
/*
@Function gridDefXdimname
@Title Define the dimension name of a X-axis
@Prototype void gridDefXdimname(int gridID, const char *dimname)
@Parameter
@Item gridID Grid ID, from a previous call to @fref{gridCreate}.
@Item dimname Dimension name of the X-axis.
@Description
The function @func{gridDefXdimname} defines the dimension name of a X-axis.
@EndFunction
*/
void gridDefXdimname(int gridID, const char *xdimname)
{
if ( xdimname && *xdimname )
{
grid_t *gridptr = gridID2Ptr(gridID);
gridSetName(gridptr->xdimname, xdimname);
gridMark4Update(gridID);
}
}
/*
@Function gridDefXname
@Title Define the name of a X-axis
......@@ -779,30 +764,6 @@ void gridDefXunits(int gridID, const char *xunits)
}
}
/*
@Function gridDefYdimname
@Title Define the dimension name of a Y-axis
@Prototype void gridDefYdimname(int gridID, const char *dimname)
@Parameter
@Item gridID Grid ID, from a previous call to @fref{gridCreate}.
@Item dimname Dimension name of the Y-axis.
@Description
The function @func{gridDefYdimname} defines the dimension name of a Y-axis.
@EndFunction
*/
void gridDefYdimname(int gridID, const char *ydimname)
{
if ( ydimname && *ydimname )
{
grid_t *gridptr = gridID2Ptr(gridID);
gridSetName(gridptr->ydimname, ydimname);
gridMark4Update(gridID);
}
}
/*
@Function gridDefYname
@Title Define the name of a Y-axis
......
......@@ -454,7 +454,6 @@ module mo_cdi
integer(c_int), public, parameter :: CDI_GRID_YUNITS = 908
public :: cdiGridDefString
public :: cdiGridInqString
public :: gridDefXdimname
public :: gridInqXdimname
public :: gridDefXname
public :: gridInqXname
......@@ -462,7 +461,6 @@ module mo_cdi
public :: gridInqXlongname
public :: gridDefXunits
public :: gridInqXunits
public :: gridDefYdimname
public :: gridInqYdimname
public :: gridDefYname
public :: gridInqYname
......@@ -4982,26 +4980,6 @@ contains
end do
end function cdiGridInqString
subroutine gridDefXdimname(gridID_dummy, xdimname_dummy)
integer(c_int), value :: gridID_dummy
character(kind = c_char, len = *), intent(in) :: xdimname_dummy
character(kind = c_char) :: xdimname_temp(len(xdimname_dummy) + 1)
integer :: xdimname_i
interface
subroutine lib_gridDefXdimname(gridID_dummy, xdimname_dummy) bind(c, name&
& = 'gridDefXdimname')
import c_char, c_int
integer(c_int), value :: gridID_dummy
character(kind = c_char) :: xdimname_dummy(*)
end subroutine lib_gridDefXdimname
end interface
do xdimname_i = 1, len(xdimname_dummy)
xdimname_temp(xdimname_i) = xdimname_dummy(xdimname_i:xdimname_i)
end do
xdimname_temp(len(xdimname_dummy) + 1) = c_null_char
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
......@@ -5186,26 +5164,6 @@ contains
end do
end subroutine gridInqXunits
subroutine gridDefYdimname(gridID_dummy, ydimname_dummy)
integer(c_int), value :: gridID_dummy
character(kind = c_char, len = *), intent(in) :: ydimname_dummy
character(kind = c_char) :: ydimname_temp(len(ydimname_dummy) + 1)
integer :: ydimname_i
interface
subroutine lib_gridDefYdimname(gridID_dummy, ydimname_dummy) bind(c, name&
& = 'gridDefYdimname')
import c_char, c_int
integer(c_int), value :: gridID_dummy
character(kind = c_char) :: ydimname_dummy(*)
end subroutine lib_gridDefYdimname
end interface
do ydimname_i = 1, len(ydimname_dummy)
ydimname_temp(ydimname_i) = ydimname_dummy(ydimname_i:ydimname_i)
end do
ydimname_temp(len(ydimname_dummy) + 1) = c_null_char
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
......
......@@ -5736,8 +5736,10 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
if ( xdimid == -1 && ydimid == -1 && grid->size == 1 )
gridDefHasDims(ncvars[ncvarid].gridID, FALSE);
if ( xdimid != -1 ) gridDefXdimname(ncvars[ncvarid].gridID, ncdims[xdimid].name);
if ( ydimid != -1 ) gridDefYdimname(ncvars[ncvarid].gridID, ncdims[ydimid].name);
if ( xdimid != -1 )
cdiGridDefString(ncvars[ncvarid].gridID, CDI_GRID_XDIMNAME, strlen(ncdims[xdimid].name)+1, ncdims[xdimid].name);
if ( ydimid != -1 )
cdiGridDefString(ncvars[ncvarid].gridID, CDI_GRID_YDIMNAME, strlen(ncdims[ydimid].name)+1, ncdims[ydimid].name);
if ( CDI_Debug )
Message("gridID %d %d %s", ncvars[ncvarid].gridID, ncvarid, ncvars[ncvarid].name);
......
Supports Markdown
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