Commit 2ca9847d authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Minor cleanup of zaxis resource handling.

parent ce07094b
......@@ -1312,7 +1312,7 @@ Define the levels of a Z-axis.
\section*{\tt \htmlref{zaxisDefLongname}{zaxisDefLongname}}
\begin{verbatim}
void zaxisDefLongname (int zaxisID, const char *longname);
void zaxisDefLongname (int zaxisID, const char *longname_optional);
\end{verbatim}
Define the longname of a Z-axis.
......@@ -1321,7 +1321,7 @@ Define the longname of a Z-axis.
\section*{\tt \htmlref{zaxisDefName}{zaxisDefName}}
\begin{verbatim}
void zaxisDefName (int zaxisID, const char *name);
void zaxisDefName (int zaxisID, const char *name_optional);
\end{verbatim}
Define the name of a Z-axis.
......@@ -1357,7 +1357,7 @@ Define the UUID of a generalized Z-axis.
\section*{\tt \htmlref{zaxisDefUnits}{zaxisDefUnits}}
\begin{verbatim}
void zaxisDefUnits (int zaxisID, const char *units);
void zaxisDefUnits (int zaxisID, const char *units_optional);
\end{verbatim}
Define the units of a Z-axis.
......
......@@ -1334,7 +1334,7 @@ Define the levels of a Z-axis.
\section*{\tt \htmlref{zaxisDefLongname}{zaxisDefLongname}}
\begin{verbatim}
SUBROUTINE zaxisDefLongname (INTEGER zaxisID, CHARACTER*(*) longname)
SUBROUTINE zaxisDefLongname (INTEGER zaxisID, CHARACTER*(*) longname_optional)
\end{verbatim}
Define the longname of a Z-axis.
......@@ -1343,7 +1343,7 @@ Define the longname of a Z-axis.
\section*{\tt \htmlref{zaxisDefName}{zaxisDefName}}
\begin{verbatim}
SUBROUTINE zaxisDefName (INTEGER zaxisID, CHARACTER*(*) name)
SUBROUTINE zaxisDefName (INTEGER zaxisID, CHARACTER*(*) name_optional)
\end{verbatim}
Define the name of a Z-axis.
......@@ -1379,7 +1379,7 @@ Define the UUID of a generalized Z-axis.
\section*{\tt \htmlref{zaxisDefUnits}{zaxisDefUnits}}
\begin{verbatim}
SUBROUTINE zaxisDefUnits (INTEGER zaxisID, CHARACTER*(*) units)
SUBROUTINE zaxisDefUnits (INTEGER zaxisID, CHARACTER*(*) units_optional)
\end{verbatim}
Define the units of a Z-axis.
......
......@@ -951,19 +951,19 @@ void zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE]);
void zaxisInqUUID(int zaxisID, unsigned char uuid[CDI_UUID_SIZE]);
/* zaxisDefName: Define the name of a Z-axis */
void zaxisDefName(int zaxisID, const char *name);
void zaxisDefName(int zaxisID, const char *name_optional);
/* zaxisInqName: Get the name of a Z-axis */
void zaxisInqName(int zaxisID, char *name);
/* zaxisDefLongname: Define the longname of a Z-axis */
void zaxisDefLongname(int zaxisID, const char *longname);
void zaxisDefLongname(int zaxisID, const char *longname_optional);
/* zaxisInqLongname: Get the longname of a Z-axis */
void zaxisInqLongname(int zaxisID, char *longname);
/* zaxisDefUnits: Define the units of a Z-axis */
void zaxisDefUnits(int zaxisID, const char *units);
void zaxisDefUnits(int zaxisID, const char *units_optional);
/* zaxisInqUnits: Get the units of a Z-axis */
void zaxisInqUnits(int zaxisID, char *units);
......@@ -986,13 +986,13 @@ void zaxisInqVct(int zaxisID, double vct[]);
int zaxisInqVctSize(int zaxisID);
const double *zaxisInqVctPtr(int zaxisID);
void zaxisDefLbounds(int zaxisID, const double lbounds[]);
int zaxisInqLbounds(int zaxisID, double lbounds[]);
int zaxisInqLbounds(int zaxisID, double lbounds_optional[]);
double zaxisInqLbound(int zaxisID, int index);
void zaxisDefUbounds(int zaxisID, const double ubounds[]);
int zaxisInqUbounds(int zaxisID, double ubounds[]);
int zaxisInqUbounds(int zaxisID, double ubounds_optional[]);
double zaxisInqUbound(int zaxisID, int index);
void zaxisDefWeights(int zaxisID, const double weights[]);
int zaxisInqWeights(int zaxisID, double weights[]);
int zaxisInqWeights(int zaxisID, double weights_optional[]);
void zaxisChangeType(int zaxisID, int zaxistype);
/* TAXIS routines */
......
......@@ -1947,7 +1947,7 @@
! zaxisDefName
! (INTEGER zaxisID,
! CHARACTER*(*) name)
! CHARACTER*(*) name_optional)
EXTERNAL zaxisDefName
! zaxisInqName
......@@ -1957,7 +1957,7 @@
! zaxisDefLongname
! (INTEGER zaxisID,
! CHARACTER*(*) longname)
! CHARACTER*(*) longname_optional)
EXTERNAL zaxisDefLongname
! zaxisInqLongname
......@@ -1967,7 +1967,7 @@
! zaxisDefUnits
! (INTEGER zaxisID,
! CHARACTER*(*) units)
! CHARACTER*(*) units_optional)
EXTERNAL zaxisDefUnits
! zaxisInqUnits
......@@ -2029,7 +2029,7 @@
INTEGER zaxisInqLbounds
! (INTEGER zaxisID,
! DOUBLEPRECISION lbounds(*))
! DOUBLEPRECISION lbounds_optional(*))
EXTERNAL zaxisInqLbounds
DOUBLEPRECISION zaxisInqLbound
......@@ -2044,7 +2044,7 @@
INTEGER zaxisInqUbounds
! (INTEGER zaxisID,
! DOUBLEPRECISION ubounds(*))
! DOUBLEPRECISION ubounds_optional(*))
EXTERNAL zaxisInqUbounds
DOUBLEPRECISION zaxisInqUbound
......@@ -2059,7 +2059,7 @@
INTEGER zaxisInqWeights
! (INTEGER zaxisID,
! DOUBLEPRECISION weights(*))
! DOUBLEPRECISION weights_optional(*))
EXTERNAL zaxisInqWeights
! zaxisChangeType
......
......@@ -2443,14 +2443,6 @@ module mo_cdi
real(c_double), intent(in) :: lbounds_dummy(*)
end subroutine zaxisDefLbounds
function zaxisInqLbounds(zaxisID_dummy, lbounds_dummy) bind(c, name =&
& 'zaxisInqLbounds') result(f_result)
import c_double, c_int
integer(c_int), value :: zaxisID_dummy
real(c_double), intent(inout) :: lbounds_dummy(*)
integer(c_int) :: f_result
end function zaxisInqLbounds
function zaxisInqLbound(zaxisID_dummy, index_dummy) bind(c, name =&
& 'zaxisInqLbound') result(f_result)
import c_double, c_int
......@@ -2466,14 +2458,6 @@ module mo_cdi
real(c_double), intent(in) :: ubounds_dummy(*)
end subroutine zaxisDefUbounds
function zaxisInqUbounds(zaxisID_dummy, ubounds_dummy) bind(c, name =&
& 'zaxisInqUbounds') result(f_result)
import c_double, c_int
integer(c_int), value :: zaxisID_dummy
real(c_double), intent(inout) :: ubounds_dummy(*)
integer(c_int) :: f_result
end function zaxisInqUbounds
function zaxisInqUbound(zaxisID_dummy, index_dummy) bind(c, name =&
& 'zaxisInqUbound') result(f_result)
import c_double, c_int
......@@ -2489,14 +2473,6 @@ module mo_cdi
real(c_double), intent(in) :: weights_dummy(*)
end subroutine zaxisDefWeights
function zaxisInqWeights(zaxisID_dummy, weights_dummy) bind(c, name =&
& 'zaxisInqWeights') result(f_result)
import c_double, c_int
integer(c_int), value :: zaxisID_dummy
real(c_double), intent(inout) :: weights_dummy(*)
integer(c_int) :: f_result
end function zaxisInqWeights
subroutine zaxisChangeType(zaxisID_dummy, zaxistype_dummy) bind(c, name =&
& 'zaxisChangeType')
import c_int
......@@ -5186,24 +5162,35 @@ contains
end do
end subroutine zaxisName
subroutine zaxisDefName(zaxisID_dummy, name_dummy)
subroutine zaxisDefName(zaxisID_dummy, name)
integer(c_int), value :: zaxisID_dummy
character(kind = c_char, len = *), intent(in) :: name_dummy
character(kind = c_char) :: name_temp(len(name_dummy) + 1)
character(kind = c_char, len = *), optional, intent(in) :: name
character(kind = c_char), allocatable, target :: name_temp(:)
integer :: name_i
type(c_ptr) :: name_cptr
interface
subroutine lib_zaxisDefName(zaxisID_dummy, name_dummy) bind(c, name =&
subroutine lib_zaxisDefName(zaxisID_dummy, name) bind(c, name =&
& 'zaxisDefName')
import c_char, c_int
import c_int, c_ptr
integer(c_int), value :: zaxisID_dummy
character(kind = c_char) :: name_dummy(*)
type(c_ptr), value :: name
end subroutine lib_zaxisDefName
end interface
do name_i = 1, len(name_dummy)
name_temp(name_i) = name_dummy(name_i:name_i)
end do
name_temp(len(name_dummy) + 1) = c_null_char
call lib_zaxisDefName(zaxisID_dummy, name_temp)
if (present(name)) then
allocate(name_temp(len(name) + 1))
name_temp(len(name) + 1) = c_null_char
do name_i = len(name), 1, -1
if(name(name_i:name_i) /= ' ') exit
name_temp(name_i) = c_null_char
end do
do name_i = name_i, 1, -1
name_temp(name_i) = name(name_i:name_i)
end do
name_cptr = c_loc(name_temp)
else
name_cptr = c_null_ptr
end if
call lib_zaxisDefName(zaxisID_dummy, name_cptr)
end subroutine zaxisDefName
subroutine zaxisInqName(zaxisID_dummy, name_dummy)
......@@ -5237,24 +5224,35 @@ contains
end do
end subroutine zaxisInqName
subroutine zaxisDefLongname(zaxisID_dummy, longname_dummy)
subroutine zaxisDefLongname(zaxisID_dummy, longname)
integer(c_int), value :: zaxisID_dummy
character(kind = c_char, len = *), intent(in) :: longname_dummy
character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
character(kind = c_char, len = *), optional, intent(in) :: longname
character(kind = c_char), allocatable, target :: longname_temp(:)
integer :: longname_i
type(c_ptr) :: longname_cptr
interface
subroutine lib_zaxisDefLongname(zaxisID_dummy, longname_dummy) bind(c,&
& name = 'zaxisDefLongname')
import c_char, c_int
subroutine lib_zaxisDefLongname(zaxisID_dummy, longname) bind(c, name =&
& 'zaxisDefLongname')
import c_int, c_ptr
integer(c_int), value :: zaxisID_dummy
character(kind = c_char) :: longname_dummy(*)
type(c_ptr), value :: longname
end subroutine lib_zaxisDefLongname
end interface
do longname_i = 1, len(longname_dummy)
longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
end do
longname_temp(len(longname_dummy) + 1) = c_null_char
call lib_zaxisDefLongname(zaxisID_dummy, longname_temp)
if (present(longname)) then
allocate(longname_temp(len(longname) + 1))
longname_temp(len(longname) + 1) = c_null_char
do longname_i = len(longname), 1, -1
if(longname(longname_i:longname_i) /= ' ') exit
longname_temp(longname_i) = c_null_char
end do
do longname_i = longname_i, 1, -1
longname_temp(longname_i) = longname(longname_i:longname_i)
end do
longname_cptr = c_loc(longname_temp)
else
longname_cptr = c_null_ptr
end if
call lib_zaxisDefLongname(zaxisID_dummy, longname_cptr)
end subroutine zaxisDefLongname
subroutine zaxisInqLongname(zaxisID_dummy, longname_dummy)
......@@ -5288,24 +5286,35 @@ contains
end do
end subroutine zaxisInqLongname
subroutine zaxisDefUnits(zaxisID_dummy, units_dummy)
subroutine zaxisDefUnits(zaxisID_dummy, units)
integer(c_int), value :: zaxisID_dummy
character(kind = c_char, len = *), intent(in) :: units_dummy
character(kind = c_char) :: units_temp(len(units_dummy) + 1)
character(kind = c_char, len = *), optional, intent(in) :: units
character(kind = c_char), allocatable, target :: units_temp(:)
integer :: units_i
type(c_ptr) :: units_cptr
interface
subroutine lib_zaxisDefUnits(zaxisID_dummy, units_dummy) bind(c, name =&
subroutine lib_zaxisDefUnits(zaxisID_dummy, units) bind(c, name =&
& 'zaxisDefUnits')
import c_char, c_int
import c_int, c_ptr
integer(c_int), value :: zaxisID_dummy
character(kind = c_char) :: units_dummy(*)
type(c_ptr), value :: units
end subroutine lib_zaxisDefUnits
end interface
do units_i = 1, len(units_dummy)
units_temp(units_i) = units_dummy(units_i:units_i)
end do
units_temp(len(units_dummy) + 1) = c_null_char
call lib_zaxisDefUnits(zaxisID_dummy, units_temp)
if (present(units)) then
allocate(units_temp(len(units) + 1))
units_temp(len(units) + 1) = c_null_char
do units_i = len(units), 1, -1
if(units(units_i:units_i) /= ' ') exit
units_temp(units_i) = c_null_char
end do
do units_i = units_i, 1, -1
units_temp(units_i) = units(units_i:units_i)
end do
units_cptr = c_loc(units_temp)
else
units_cptr = c_null_ptr
end if
call lib_zaxisDefUnits(zaxisID_dummy, units_cptr)
end subroutine zaxisDefUnits
subroutine zaxisInqUnits(zaxisID_dummy, units_dummy)
......@@ -5370,6 +5379,63 @@ contains
end do
end subroutine zaxisInqStdname
function zaxisInqLbounds(zaxisID_dummy, lbounds) result(f_result)
integer(c_int) :: f_result
integer(c_int), value :: zaxisID_dummy
real(c_double), target, optional, intent(inout) :: lbounds(*)
type(c_ptr) :: lbounds_cptr
interface
function lib_zaxisInqLbounds(zaxisID_dummy, lbounds) bind(c, name =&
& 'zaxisInqLbounds') result(c_result)
import c_int, c_ptr
integer(c_int) :: c_result
integer(c_int), value :: zaxisID_dummy
type(c_ptr), value :: lbounds
end function lib_zaxisInqLbounds
end interface
lbounds_cptr = c_null_ptr
if(present(lbounds)) lbounds_cptr = c_loc(lbounds)
f_result = lib_zaxisInqLbounds(zaxisID_dummy, lbounds_cptr)
end function zaxisInqLbounds
function zaxisInqUbounds(zaxisID_dummy, ubounds) result(f_result)
integer(c_int) :: f_result
integer(c_int), value :: zaxisID_dummy
real(c_double), target, optional, intent(inout) :: ubounds(*)
type(c_ptr) :: ubounds_cptr
interface
function lib_zaxisInqUbounds(zaxisID_dummy, ubounds) bind(c, name =&
& 'zaxisInqUbounds') result(c_result)
import c_int, c_ptr
integer(c_int) :: c_result
integer(c_int), value :: zaxisID_dummy
type(c_ptr), value :: ubounds
end function lib_zaxisInqUbounds
end interface
ubounds_cptr = c_null_ptr
if(present(ubounds)) ubounds_cptr = c_loc(ubounds)
f_result = lib_zaxisInqUbounds(zaxisID_dummy, ubounds_cptr)
end function zaxisInqUbounds
function zaxisInqWeights(zaxisID_dummy, weights) result(f_result)
integer(c_int) :: f_result
integer(c_int), value :: zaxisID_dummy
real(c_double), target, optional, intent(inout) :: weights(*)
type(c_ptr) :: weights_cptr
interface
function lib_zaxisInqWeights(zaxisID_dummy, weights) bind(c, name =&
& 'zaxisInqWeights') result(c_result)
import c_int, c_ptr
integer(c_int) :: c_result
integer(c_int), value :: zaxisID_dummy
type(c_ptr), value :: weights
end function lib_zaxisInqWeights
end interface
weights_cptr = c_null_ptr
if(present(weights)) weights_cptr = c_loc(weights)
f_result = lib_zaxisInqWeights(zaxisID_dummy, weights_cptr)
end function zaxisInqWeights
function tunitNamePtr(tunitID_dummy) result(f_result)
character(kind = c_char), dimension(:), pointer :: f_result
integer(c_int), value :: tunitID_dummy
......
......@@ -526,7 +526,6 @@ void zaxisDefPrec(int zaxisID, int prec)
int zaxisInqPrec(int zaxisID)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
return (zaxisptr->prec);
}
......@@ -546,8 +545,7 @@ void zaxisDefPositive(int zaxisID, int positive)
int zaxisInqPositive(int zaxisID)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
return (zaxisptr->positive);
return zaxisptr->positive;
}
......@@ -566,8 +564,7 @@ void zaxisDefLtype(int zaxisID, int ltype)
int zaxisInqLtype(int zaxisID)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
return (zaxisptr->ltype);
return zaxisptr->ltype;
}
......@@ -586,8 +583,7 @@ void zaxisDefLtype2(int zaxisID, int ltype2)
int zaxisInqLtype2(int zaxisID)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
return (zaxisptr->ltype2);
return zaxisptr->ltype2;
}
/*
......@@ -635,7 +631,6 @@ The function @func{zaxisDefLevel} defines one level of a Z-axis.
void zaxisDefLevel(int zaxisID, int levelID, double level)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
if ( levelID >= 0 && levelID < zaxisptr->size )
zaxisptr->vals[levelID] = level;
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
......@@ -645,7 +640,6 @@ void zaxisDefLevel(int zaxisID, int levelID, double level)
void zaxisDefNlevRef(int zaxisID, const int nhlev)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
if (zaxisptr->nhlev != nhlev)
{
zaxisptr->nhlev = nhlev;
......@@ -657,8 +651,7 @@ void zaxisDefNlevRef(int zaxisID, const int nhlev)
int zaxisInqNlevRef(int zaxisID)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
return (zaxisptr->nhlev);
return zaxisptr->nhlev;
}
/*
......@@ -678,7 +671,6 @@ The function @func{zaxisDefNumber} defines the reference number for a generalize
void zaxisDefNumber(int zaxisID, const int number)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
if (zaxisptr->number != number)
{
zaxisptr->number = number;
......@@ -704,8 +696,7 @@ The function @func{zaxisInqNumber} returns the reference number to a generalized
int zaxisInqNumber(int zaxisID)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
return (zaxisptr->number);
return zaxisptr->number;
}
/*
......@@ -725,7 +716,6 @@ The function @func{zaxisDefUUID} defines the UUID for a generalized Z-axis.
void zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE])
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
memcpy(zaxisptr->uuid, uuid, CDI_UUID_SIZE);
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
}
......@@ -776,7 +766,7 @@ double zaxisInqLevel(int zaxisID, int levelID)
if ( levelID >= 0 && levelID < zaxisptr->size )
level = zaxisptr->vals[levelID];
return (level);
return level;
}
double zaxisInqLbound(int zaxisID, int index)
......@@ -784,11 +774,10 @@ double zaxisInqLbound(int zaxisID, int index)
double level = 0;
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
if ( zaxisptr->lbounds )
if ( index >= 0 && index < zaxisptr->size )
if ( zaxisptr->lbounds && ( index >= 0 && index < zaxisptr->size ) )
level = zaxisptr->lbounds[index];
return (level);
return level;
}
......@@ -797,18 +786,16 @@ double zaxisInqUbound(int zaxisID, int index)
double level = 0;
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
if ( zaxisptr->ubounds )
if ( index >= 0 && index < zaxisptr->size )
level = zaxisptr->ubounds[index];
return (level);
if ( zaxisptr->ubounds && ( index >= 0 && index < zaxisptr->size ) )
level = zaxisptr->ubounds[index];
return level;
}
const double *zaxisInqLevelsPtr(int zaxisID)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
return ( zaxisptr->vals );
return zaxisptr->vals;
}
/*
......@@ -904,7 +891,7 @@ int zaxisInqLevelID(int zaxisID, double level)
break;
}
return (levelID);
return levelID;
}
/*
......
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