Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
fb8f77bc
Commit
fb8f77bc
authored
Nov 04, 2014
by
Thomas Jahns
🤸
Browse files
Consistently use unsigned char arrays for UUID.
parent
2fdda575
Changes
16
Hide whitespace changes
Inline
Side-by-side
app/printinfo.h
View file @
fb8f77bc
#define DATE_FORMAT "%5.4d-%2.2d-%2.2d"
#define TIME_FORMAT "%2.2d:%2.2d:%2.2d"
void
uuid2str
(
const
char
*
uuid
,
char
*
uuidstr
);
void
uuid2str
(
const
unsigned
char
uuid
[
CDI_UUID_SIZE
]
,
char
*
uuidstr
);
void
date2str
(
int
date
,
char
*
datestr
,
int
maxlen
)
{
...
...
@@ -135,7 +135,7 @@ void printGridInfo(int vlistID)
int
ngrids
,
index
;
int
gridID
,
gridtype
,
trunc
,
gridsize
,
xsize
,
ysize
,
xysize
;
char
xname
[
CDI_MAX_NAME
],
yname
[
CDI_MAX_NAME
],
xunits
[
CDI_MAX_NAME
],
yunits
[
CDI_MAX_NAME
];
char
uuidOfHGrid
[
17
];
unsigned
char
uuidOfHGrid
[
CDI_UUID_SIZE
];
ngrids
=
vlistNgrids
(
vlistID
);
for
(
index
=
0
;
index
<
ngrids
;
index
++
)
...
...
@@ -473,7 +473,7 @@ void printZaxisInfo(int vlistID)
fprintf
(
stdout
,
"number = %d
\n
"
,
number
);
}
char
uuidOfVGrid
[
17
];
unsigned
char
uuidOfVGrid
[
CDI_UUID_SIZE
];
zaxisInqUUID
(
zaxisID
,
uuidOfVGrid
);
if
(
uuidOfVGrid
[
0
]
!=
0
)
{
...
...
doc/tex/c_quick_ref.tex
View file @
fb8f77bc
...
...
@@ -88,7 +88,7 @@ Define the reference URI for an unstructured grid.
\section*
{
\tt
\htmlref
{
gridDefUUID
}{
gridDefUUID
}}
\begin{verbatim}
void gridDefUUID (int gridID, const char
*
uuid
_
cbuf
);
void gridDefUUID (int gridID, const
unsigned
char uuid
[CDI
_
UUID
_
SIZE]
);
\end{verbatim}
Define the UUID of an unstructured grid.
...
...
@@ -295,7 +295,7 @@ Get the type of a Grid.
\section*
{
\tt
\htmlref
{
gridInqUUID
}{
gridInqUUID
}}
\begin{verbatim}
void gridInqUUID (int gridID, char
*
uuid
_
cbuf
);
void gridInqUUID (int gridID,
unsigned
char uuid
[CDI
_
UUID
_
SIZE]
);
\end{verbatim}
Get the UUID of an unstructured grid.
...
...
@@ -1240,7 +1240,7 @@ Define the reference number for a generalized Z-axis.
\section*
{
\tt
\htmlref
{
zaxisDefUUID
}{
zaxisDefUUID
}}
\begin{verbatim}
void zaxisDefUUID (int zaxisID, const char
*
uuid
_
cbuf
);
void zaxisDefUUID (int zaxisID, const
unsigned
char uuid
[CDI
_
UUID
_
SIZE]
);
\end{verbatim}
Define the UUID of a generalized Z-axis.
...
...
@@ -1357,7 +1357,7 @@ Get the type of a Z-axis.
\section*
{
\tt
\htmlref
{
zaxisInqUUID
}{
zaxisInqUUID
}}
\begin{verbatim}
void zaxisInqUUID (int zaxisID, char
*
uuid
_
cbuf
);
void zaxisInqUUID (int zaxisID,
unsigned
char uuid
[CDI
_
UUID
_
SIZE]
);
\end{verbatim}
Get the UUID of a generalized Z-axis.
...
...
doc/tex/f_quick_ref.tex
View file @
fb8f77bc
...
...
@@ -88,7 +88,7 @@ Define the reference URI for an unstructured grid.
\section*
{
\tt
\htmlref
{
gridDefUUID
}{
gridDefUUID
}}
\begin{verbatim}
SUBROUTINE gridDefUUID (INTEGER gridID,
CHARACTER*(*
) uuid
_
cbuf
)
SUBROUTINE gridDefUUID (INTEGER gridID,
INTEGER*1(16
) uuid)
\end{verbatim}
Define the UUID of an unstructured grid.
...
...
@@ -295,7 +295,7 @@ Get the type of a Grid.
\section*
{
\tt
\htmlref
{
gridInqUUID
}{
gridInqUUID
}}
\begin{verbatim}
SUBROUTINE gridInqUUID (INTEGER gridID,
CHARACTER*(*
) uuid
_
cbuf
)
SUBROUTINE gridInqUUID (INTEGER gridID,
INTEGER*1(16
) uuid)
\end{verbatim}
Get the UUID of an unstructured grid.
...
...
@@ -1260,7 +1260,7 @@ Define the reference number for a generalized Z-axis.
\section*
{
\tt
\htmlref
{
zaxisDefUUID
}{
zaxisDefUUID
}}
\begin{verbatim}
SUBROUTINE zaxisDefUUID (INTEGER zaxisID,
CHARACTER*(*
) uuid
_
cbuf
)
SUBROUTINE zaxisDefUUID (INTEGER zaxisID,
INTEGER*1(16
) uuid)
\end{verbatim}
Define the UUID of a generalized Z-axis.
...
...
@@ -1377,7 +1377,7 @@ Get the type of a Z-axis.
\section*
{
\tt
\htmlref
{
zaxisInqUUID
}{
zaxisInqUUID
}}
\begin{verbatim}
SUBROUTINE zaxisInqUUID (INTEGER zaxisID,
CHARACTER*(*
) uuid
_
cbuf
)
SUBROUTINE zaxisInqUUID (INTEGER zaxisID,
INTEGER*1(16
) uuid)
\end{verbatim}
Get the UUID of a generalized Z-axis.
...
...
src/cdi.h
View file @
fb8f77bc
...
...
@@ -744,10 +744,10 @@ void gridDefReference(int gridID, const char *reference);
int
gridInqReference
(
int
gridID
,
char
*
reference
);
/* gridDefUUID: Define the UUID of an unstructured grid */
void
gridDefUUID
(
int
gridID
,
const
char
*
uuid
_cbuf
);
void
gridDefUUID
(
int
gridID
,
const
unsigned
char
uuid
[
CDI_UUID_SIZE
]
);
/* gridInqUUID: Get the UUID of an unstructured grid */
void
gridInqUUID
(
int
gridID
,
char
*
uuid
_cbuf
);
void
gridInqUUID
(
int
gridID
,
unsigned
char
uuid
[
CDI_UUID_SIZE
]
);
/* Lambert Conformal Conic grid (GRIB version) */
...
...
@@ -840,10 +840,10 @@ void zaxisDefNumber(int gridID, int number);
int
zaxisInqNumber
(
int
gridID
);
/* zaxisDefUUID: Define the UUID of a generalized Z-axis */
void
zaxisDefUUID
(
int
zaxisID
,
const
char
*
uuid
_cbuf
);
void
zaxisDefUUID
(
int
zaxisID
,
const
unsigned
char
uuid
[
CDI_UUID_SIZE
]
);
/* zaxisInqUUID: Get the UUID of a generalized Z-axis */
void
zaxisInqUUID
(
int
zaxisID
,
char
*
uuid
_cbuf
);
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
);
...
...
src/cdi.inc
View file @
fb8f77bc
...
...
@@ -1661,12 +1661,12 @@
!
gridDefUUID
!
(
INTEGER
gridID
,
!
CHARACTER
*
(
*
)
uuid
_cbuf
)
!
INTEGER
*
1
(
16
)
uuid
)
EXTERNAL
gridDefUUID
!
gridInqUUID
!
(
INTEGER
gridID
,
!
CHARACTER
*
(
*
)
uuid
_cbuf
)
!
INTEGER
*
1
(
16
)
uuid
)
EXTERNAL
gridInqUUID
!
...
...
@@ -1883,12 +1883,12 @@
!
zaxisDefUUID
!
(
INTEGER
zaxisID
,
!
CHARACTER
*
(
*
)
uuid
_cbuf
)
!
INTEGER
*
1
(
16
)
uuid
)
EXTERNAL
zaxisDefUUID
!
zaxisInqUUID
!
(
INTEGER
zaxisID
,
!
CHARACTER
*
(
*
)
uuid
_cbuf
)
!
INTEGER
*
1
(
16
)
uuid
)
EXTERNAL
zaxisInqUUID
!
zaxisDefName
...
...
src/cdiFortran.c
View file @
fb8f77bc
...
...
@@ -347,8 +347,8 @@ FCALLSCSUB2 (gridDefPosition, GRIDDEFPOSITION, griddefposition, INT, INT)
FCALLSCFUN1
(
INT
,
gridInqPosition
,
GRIDINQPOSITION
,
gridinqposition
,
INT
)
FCALLSCSUB2
(
gridDefReference
,
GRIDDEFREFERENCE
,
griddefreference
,
INT
,
STRING
)
FCALLSCFUN2
(
INT
,
gridInqReference
,
GRIDINQREFERENCE
,
gridinqreference
,
INT
,
PSTRING
)
FCALLSCSUB2
(
gridDefUUID
,
GRIDDEFUUID
,
griddefuuid
,
INT
,
P
PSTRING
)
FCALLSCSUB2
(
gridInqUUID
,
GRIDINQUUID
,
gridinquuid
,
INT
,
P
PSTRING
)
FCALLSCSUB2
(
gridDefUUID
,
GRIDDEFUUID
,
griddefuuid
,
INT
,
P
VOID
)
FCALLSCSUB2
(
gridInqUUID
,
GRIDINQUUID
,
gridinquuid
,
INT
,
P
VOID
)
/* Lambert Conformal Conic grid (GRIB version) */
...
...
@@ -397,8 +397,8 @@ FCALLSCSUB2 (zaxisDefNlevRef, ZAXISDEFNLEVREF, zaxisdefnlevref, INT, INT)
FCALLSCFUN1
(
INT
,
zaxisInqNlevRef
,
ZAXISINQNLEVREF
,
zaxisinqnlevref
,
INT
)
FCALLSCSUB2
(
zaxisDefNumber
,
ZAXISDEFNUMBER
,
zaxisdefnumber
,
INT
,
INT
)
FCALLSCFUN1
(
INT
,
zaxisInqNumber
,
ZAXISINQNUMBER
,
zaxisinqnumber
,
INT
)
FCALLSCSUB2
(
zaxisDefUUID
,
ZAXISDEFUUID
,
zaxisdefuuid
,
INT
,
P
PSTRING
)
FCALLSCSUB2
(
zaxisInqUUID
,
ZAXISINQUUID
,
zaxisinquuid
,
INT
,
P
PSTRING
)
FCALLSCSUB2
(
zaxisDefUUID
,
ZAXISDEFUUID
,
zaxisdefuuid
,
INT
,
P
VOID
)
FCALLSCSUB2
(
zaxisInqUUID
,
ZAXISINQUUID
,
zaxisinquuid
,
INT
,
P
VOID
)
FCALLSCSUB2
(
zaxisDefName
,
ZAXISDEFNAME
,
zaxisdefname
,
INT
,
STRING
)
FCALLSCSUB2
(
zaxisInqName
,
ZAXISINQNAME
,
zaxisinqname
,
INT
,
PSTRING
)
FCALLSCSUB2
(
zaxisDefLongname
,
ZAXISDEFLONGNAME
,
zaxisdeflongname
,
INT
,
STRING
)
...
...
src/cdi_int.h
View file @
fb8f77bc
...
...
@@ -340,8 +340,8 @@ void streamGetIndexList ( int, int * );
void
cdiInitialize
(
void
);
void
uuid2str
(
const
char
*
uuid
,
char
*
uuidstr
);
void
str2uuid
(
const
char
*
uuidstr
,
char
*
uuid
);
void
uuid2str
(
const
unsigned
char
*
uuid
,
char
*
uuidstr
);
int
str2uuid
(
const
char
*
uuidstr
,
unsigned
char
*
uuid
);
#define CDI_UNIT_PA 1
#define CDI_UNIT_HPA 2
...
...
src/grid.c
View file @
fb8f77bc
...
...
@@ -2300,20 +2300,11 @@ int gridCompare(int gridID, grid_t grid)
}
else
if
(
grid
.
type
==
GRID_UNSTRUCTURED
)
{
char
uuidOfHGrid
[
17
];
unsigned
char
uuidOfHGrid
[
CDI_UUID_SIZE
];
gridInqUUID
(
gridID
,
uuidOfHGrid
);
/*
printf("compare unstructured grids\n");
printf("gridID %d\n", gridID);
printf("gridsize %d\n", grid.size);
if ( uuidOfHGrid[0] != 0 && grid.uuid[0] != 0 && memcmp(grid.uuid, uuidOfHGrid, 16) )
printf("uuidOfHGrid differ\n");
printf("nvertex %d %d\n", grid.nvertex, gridInqNvertex(gridID));
printf("number %d %d\n", grid.number, gridInqNumber(gridID));
printf("position %d %d\n", grid.position, gridInqPosition(gridID));
*/
if
(
uuidOfHGrid
[
0
]
!=
0
&&
grid
.
uuid
[
0
]
!=
0
)
if
(
!
differ
&&
memcmp
(
uuidOfHGrid
,
grid
.
uuid
,
16
)
!=
0
)
differ
=
1
;
if
(
!
differ
&&
memcmp
(
uuidOfHGrid
,
grid
.
uuid
,
CDI_UUID_SIZE
)
!=
0
)
differ
=
1
;
if
(
!
differ
&&
grid
.
nvertex
!=
gridInqNvertex
(
gridID
)
)
differ
=
1
;
if
(
!
differ
&&
grid
.
number
!=
gridInqNumber
(
gridID
)
)
differ
=
1
;
if
(
!
differ
&&
grid
.
number
>
0
&&
grid
.
position
!=
gridInqPosition
(
gridID
)
)
differ
=
1
;
...
...
@@ -3186,7 +3177,7 @@ void gridPrintKernel(grid_t * gridptr, int opt, FILE *fp)
int
nbyte0
,
nbyte
;
int
i
;
int
nvertex
,
iv
;
char
uuidOfHGrid
[
17
];
unsigned
char
uuidOfHGrid
[
CDI_UUID_SIZE
];
int
gridID
=
gridptr
->
self
;
const
double
*
area
=
gridInqAreaPtr
(
gridID
);
const
double
*
xvals
=
gridInqXvalsPtr
(
gridID
);
...
...
@@ -4030,13 +4021,13 @@ The function @func{gridDefUUID} defines the UUID for an unstructured grid.
@EndFunction
*/
void
gridDefUUID
(
int
gridID
,
const
char
*
uuid
)
void
gridDefUUID
(
int
gridID
,
const
unsigned
char
uuid
[
CDI_UUID_SIZE
]
)
{
grid_t
*
gridptr
=
(
grid_t
*
)
reshGetVal
(
gridID
,
&
gridOps
);
grid_check_ptr
(
gridID
,
gridptr
);
memcpy
(
gridptr
->
uuid
,
uuid
,
16
);
memcpy
(
gridptr
->
uuid
,
uuid
,
CDI_UUID_SIZE
);
reshSetStatus
(
gridID
,
&
gridOps
,
RESH_DESYNC_IN_USE
);
}
...
...
@@ -4055,13 +4046,13 @@ The function @func{gridInqUUID} returns the UUID to an unstructured grid.
@func{gridInqUUID} returns the UUID to an unstructured grid to the parameter uuid.
@EndFunction
*/
void
gridInqUUID
(
int
gridID
,
char
*
uuid
)
void
gridInqUUID
(
int
gridID
,
unsigned
char
uuid
[
CDI_UUID_SIZE
]
)
{
grid_t
*
gridptr
=
(
grid_t
*
)
reshGetVal
(
gridID
,
&
gridOps
);
grid_check_ptr
(
gridID
,
gridptr
);
memcpy
(
uuid
,
gridptr
->
uuid
,
16
);
memcpy
(
uuid
,
gridptr
->
uuid
,
CDI_UUID_SIZE
);
}
...
...
src/grid.h
View file @
fb8f77bc
#ifndef _GRID_H
#define _GRID_H
#include
"cdi.h"
typedef
unsigned
char
mask_t
;
typedef
struct
{
...
...
@@ -46,7 +48,7 @@ typedef struct {
int
nd
,
ni
,
ni2
,
ni3
;
/* parameter for GRID_GME */
int
number
,
position
;
/* parameter for GRID_REFERENCE */
char
*
reference
;
char
uuid
[
17
];
/* uuid for grid reference */
unsigned
char
uuid
[
CDI_UUID_SIZE
];
/* uuid for grid reference */
int
trunc
;
/* parameter for GRID_SPECTEAL */
int
nvertex
;
int
*
rowlon
;
...
...
src/make_fint.c
View file @
fb8f77bc
...
...
@@ -88,7 +88,8 @@ static void doctotxt(FILE *fp, Docu *doc, size_t ndoc)
enum
cftype
{
ISVOID
,
ISCONSTSTRING
,
ISINT
,
ISREAL
,
ISDOUBLE
,
ISMPI_COMM
,
ISXT_IDXLIST
,
ISCHOICE
,
ISINTP
,
ISINTV
,
ISINTVV
,
ISREALP
,
ISDOUBLEP
,
ISCBUF
,
ISSTRING
,
ISSTRINGP
,
VOIDFUNCVOID
,
ISDOUBLEP
,
ISCBUF
,
ISUUID
,
ISUCHAR
,
ISSTRING
,
ISSTRINGP
,
VOIDFUNCVOID
,
NUM_KNOWN_ARG_TYPES
};
enum
conversionType
{
CONV_ARG
,
CONV_RET
};
...
...
@@ -157,6 +158,10 @@ static struct symbol funArgSym[]
{
"CHARACTER*(*)"
,
"PPSTRING"
,
"char *%.*s"
,
"^"
WS
"*(const"
WS
"+)?char"
WS
"+
\\
*""([A-Za-z_][A-Za-z_0-9]*_cbuf)"
WS
"*[,
\\
)]"
,
2
,
0
,
0
},
{
"INTEGER*1(16)"
,
"PVOID"
,
"unsigned char %.*s[16]"
,
"^"
WS
"*(const"
WS
"+)?unsigned"
WS
"+char"
WS
"+"
SYMRE
"?
\\
[(16|CDI_UUID_SIZE)
\\
]"
WS
"*[,
\\
)]"
,
2
,
0
,
0
},
{
"INTEGER*1(*)"
,
"PVOID"
,
"unsigned char *%.*s"
,
"^"
WS
"*(const"
WS
"+)?unsigned"
WS
"+char"
WS
"+
\\
*"
SYMRE
"?"
WS
"*[,
\\
)]"
,
2
,
0
,
0
},
{
"CHARACTER*(*)"
,
"STRING"
,
"char *%.*s"
,
"^"
WS
"*const"
WS
"+char"
WS
"+
\\
*"
WS
"*"
SYMRE
"?"
WS
"*[,
\\
)]"
,
1
,
0
,
0
},
{
"CHARACTER*(*)"
,
"PSTRING"
,
"char *%.*s"
,
...
...
@@ -164,7 +169,7 @@ static struct symbol funArgSym[]
{
"PROCEDURE"
,
"ROUTINE"
,
"void (*%.*s)(void)"
,
"^"
WS
"*void"
WS
"*
\\
("
WS
"*
\\
*"
WS
"*"
SYMRE
"?"
WS
"*
\\
)"
WS
"*
\\
("
WS
"*void"
WS
"*
\\
)"
WS
"*[,
\\
)]"
,
1
,
0
,
1
,
NULL
,
NULL
,
cfVoidFuncPrologue
}
NULL
,
NULL
,
cfVoidFuncPrologue
}
,
};
static
struct
symbol
funRet
[]
=
{
...
...
src/stream_cdf.c
View file @
fb8f77bc
...
...
@@ -2079,7 +2079,7 @@ void cdfDefGridReference(stream_t *streamptr, int gridID)
static
void
cdfDefGridUUID
(
stream_t
*
streamptr
,
int
gridID
)
{
char
uuidOfHGrid
[
17
];
unsigned
char
uuidOfHGrid
[
CDI_UUID_SIZE
];
gridInqUUID
(
gridID
,
uuidOfHGrid
);
if
(
uuidOfHGrid
[
0
]
!=
0
)
...
...
@@ -2099,7 +2099,7 @@ void cdfDefGridUUID(stream_t *streamptr, int gridID)
static
void
cdfDefZaxisUUID
(
stream_t
*
streamptr
,
int
zaxisID
)
{
char
uuidOfVGrid
[
17
];
unsigned
char
uuidOfVGrid
[
CDI_UUID_SIZE
];
zaxisInqUUID
(
zaxisID
,
uuidOfVGrid
);
if
(
uuidOfVGrid
[
0
]
!=
0
)
...
...
@@ -6017,7 +6017,7 @@ void copy_numeric_projatts(int gridID, int ncvarID, int ncfileID)
/* define all input grids */
static
void
define_all_grids
(
stream_t
*
streamptr
,
int
vlistID
,
ncdim_t
*
ncdims
,
int
nvars
,
ncvar_t
*
ncvars
,
int
timedimid
,
char
*
uuidOfHGrid
,
char
*
gridfile
,
int
number_of_grid_used
)
void
define_all_grids
(
stream_t
*
streamptr
,
int
vlistID
,
ncdim_t
*
ncdims
,
int
nvars
,
ncvar_t
*
ncvars
,
int
timedimid
,
unsigned
char
*
uuidOfHGrid
,
char
*
gridfile
,
int
number_of_grid_used
)
{
int
ncvarid
,
ncvarid2
;
int
ndims
;
...
...
@@ -6747,7 +6747,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
/* define all input zaxes */
static
void
define_all_zaxes
(
stream_t
*
streamptr
,
int
vlistID
,
ncdim_t
*
ncdims
,
int
nvars
,
ncvar_t
*
ncvars
,
size_t
vctsize
,
double
*
vct
,
char
*
uuidOfVGrid
)
size_t
vctsize
,
double
*
vct
,
unsigned
char
*
uuidOfVGrid
)
{
int
ncvarid
,
ncvarid2
;
int
i
,
ilev
,
ndims
;
...
...
@@ -7212,9 +7212,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
}
static
void
scan_global_attributes
(
int
fileID
,
int
vlistID
,
stream_t
*
streamptr
,
int
ngatts
,
int
*
instID
,
int
*
modelID
,
int
*
ucla_les
,
char
*
uuidOfHGrid
,
char
*
uuidOfVGrid
,
char
*
gridfile
,
int
*
number_of_grid_used
,
char
*
fcreftime
)
void
scan_global_attributes
(
int
fileID
,
int
vlistID
,
stream_t
*
streamptr
,
int
ngatts
,
int
*
instID
,
int
*
modelID
,
int
*
ucla_les
,
unsigned
char
*
uuidOfHGrid
,
unsigned
char
*
uuidOfVGrid
,
char
*
gridfile
,
int
*
number_of_grid_used
,
char
*
fcreftime
)
{
nc_type
xtype
;
size_t
attlen
;
...
...
@@ -7493,8 +7491,8 @@ int cdfInqContents(stream_t *streamptr)
int
vlistID
;
int
format
=
0
;
int
ucla_les
=
FALSE
;
char
uuidOfHGrid
[
17
];
char
uuidOfVGrid
[
17
];
unsigned
char
uuidOfHGrid
[
CDI_UUID_SIZE
];
unsigned
char
uuidOfVGrid
[
CDI_UUID_SIZE
];
char
gridfile
[
8912
];
char
fcreftime
[
CDI_MAX_NAME
];
int
number_of_grid_used
=
UNDEFID
;
...
...
src/stream_gribapi.c
View file @
fb8f77bc
...
...
@@ -926,7 +926,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
case
ZAXIS_REFERENCE
:
{
size_t
len
;
char
uuid
[
CDI_UUID_SIZE
];
unsigned
char
uuid
[
CDI_UUID_SIZE
];
long
ltmp
;
long
nhlev
,
nvgrid
;
...
...
@@ -3020,7 +3020,6 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
case
ZAXIS_REFERENCE
:
{
unsigned
char
uuid
[
CDI_UUID_SIZE
];
int
number
;
if
(
!
gcinit
)
{
...
...
@@ -3033,7 +3032,7 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
;
// not available
else
{
number
=
zaxisInqNumber
(
zaxisID
);
int
number
=
zaxisInqNumber
(
zaxisID
);
gribapiDefLevelType
(
gh
,
gcinit
,
"typeOfFirstFixedSurface"
,
GRIB2_LTYPE_REFERENCE
);
gribapiDefLevelType
(
gh
,
gcinit
,
"typeOfSecondFixedSurface"
,
GRIB2_LTYPE_REFERENCE
);
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"NV"
,
6
),
0
);
...
...
@@ -3053,7 +3052,7 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
;
// not available
else
{
number
=
zaxisInqNumber
(
zaxisID
);
int
number
=
zaxisInqNumber
(
zaxisID
);
gribapiDefLevelType
(
gh
,
gcinit
,
"typeOfFirstFixedSurface"
,
GRIB2_LTYPE_REFERENCE
);
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"NV"
,
6
),
0
);
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"nlev"
,
zaxisInqNlevRef
(
zaxisID
)),
0
);
...
...
src/util.c
View file @
fb8f77bc
...
...
@@ -7,6 +7,7 @@
#include
<float.h>
#include
<sys/types.h>
#include
"cdi.h"
#include
"cdi_int.h"
#include
"dmemory.h"
#include
"binary.h"
...
...
@@ -53,48 +54,34 @@ void cdiPrintDatatypes(void)
fprintf
(
stderr
,
"
\n
byte ordering is LITTLEENDIAN
\n\n
"
);
}
static
char
uuidFmt
[]
=
"%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
;
void
uuid2str
(
const
char
*
uuid
,
char
*
uuidstr
)
void
uuid2str
(
const
unsigned
char
*
uuid
,
char
*
uuidstr
)
{
int
iret
;
unsigned
int
ui
[
16
];
if
(
uuid
==
NULL
)
return
;
if
(
uuidstr
==
NULL
)
return
;
if
(
uuid
==
NULL
||
uuidstr
==
NULL
)
return
;
uuidstr
[
0
]
=
0
;
for
(
int
i
=
0
;
i
<
16
;
++
i
)
ui
[
i
]
=
(
unsigned
char
)
uuid
[
i
];
iret
=
sprintf
(
uuidstr
,
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
,
ui
[
0
],
ui
[
1
],
ui
[
2
],
ui
[
3
],
ui
[
4
],
ui
[
5
],
ui
[
6
],
ui
[
7
],
ui
[
8
],
ui
[
9
],
ui
[
10
],
ui
[
11
],
ui
[
12
],
ui
[
13
],
ui
[
14
],
ui
[
15
]);
int
iret
=
sprintf
(
uuidstr
,
uuidFmt
,
uuid
[
0
],
uuid
[
1
],
uuid
[
2
],
uuid
[
3
],
uuid
[
4
],
uuid
[
5
],
uuid
[
6
],
uuid
[
7
],
uuid
[
8
],
uuid
[
9
],
uuid
[
10
],
uuid
[
11
],
uuid
[
12
],
uuid
[
13
],
uuid
[
14
],
uuid
[
15
]);
if
(
iret
!=
36
)
uuidstr
[
0
]
=
0
;
}
void
str2uuid
(
const
char
*
uuidstr
,
char
*
uuid
)
int
str2uuid
(
const
char
*
uuidstr
,
unsigned
char
*
uuid
)
{
int
iret
;
unsigned
int
ui
[
16
];
if
(
uuid
==
NULL
)
return
;
if
(
uuidstr
==
NULL
)
return
;
uuid
[
0
]
=
0
;
if
(
strlen
(
uuidstr
)
!=
36
)
return
;
iret
=
sscanf
(
uuidstr
,
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
,
&
ui
[
0
],
&
ui
[
1
],
&
ui
[
2
],
&
ui
[
3
],
&
ui
[
4
],
&
ui
[
5
],
&
ui
[
6
],
&
ui
[
7
],
&
ui
[
8
],
&
ui
[
9
],
&
ui
[
10
],
&
ui
[
11
],
&
ui
[
12
],
&
ui
[
13
],
&
ui
[
14
],
&
ui
[
15
]);
if
(
iret
!=
16
)
return
;
for
(
int
i
=
0
;
i
<
16
;
++
i
)
uuid
[
i
]
=
ui
[
i
];
uuid
[
16
]
=
0
;
if
(
uuid
==
NULL
||
uuidstr
==
NULL
||
strlen
(
uuidstr
)
!=
36
)
return
-
1
;
int
iret
=
sscanf
(
uuidstr
,
uuidFmt
,
&
uuid
[
0
],
&
uuid
[
1
],
&
uuid
[
2
],
&
uuid
[
3
],
&
uuid
[
4
],
&
uuid
[
5
],
&
uuid
[
6
],
&
uuid
[
7
],
&
uuid
[
8
],
&
uuid
[
9
],
&
uuid
[
10
],
&
uuid
[
11
],
&
uuid
[
12
],
&
uuid
[
13
],
&
uuid
[
14
],
&
uuid
[
15
]);
if
(
iret
!=
CDI_UUID_SIZE
)
return
-
1
;
return
iret
;
}
/*
...
...
src/varscan.c
View file @
fb8f77bc
...
...
@@ -26,7 +26,7 @@ static double *Vct = NULL;
static
int
numberOfVerticalLevels
=
0
;
static
int
numberOfVerticalGrid
=
0
;
static
char
uuidVGrid
[
17
];
static
unsigned
char
uuidVGrid
[
CDI_UUID_SIZE
];
typedef
struct
{
...
...
@@ -738,11 +738,11 @@ void varDefVCT(size_t vctsize, double *vctptr)
}
void
varDefZAxisReference
(
int
nhlev
,
int
nvgrid
,
char
*
uuid
)
void
varDefZAxisReference
(
int
nhlev
,
int
nvgrid
,
unsigned
char
uuid
[
CDI_UUID_SIZE
]
)
{
numberOfVerticalLevels
=
nhlev
;
numberOfVerticalGrid
=
nvgrid
;
memcpy
(
uuidVGrid
,
uuid
,
16
);
memcpy
(
uuidVGrid
,
uuid
,
CDI_UUID_SIZE
);
}
...
...
src/varscan.h
View file @
fb8f77bc
...
...
@@ -5,6 +5,7 @@
# include "grid.h"
#endif
#include
"cdi.h"
void
varAddRecord
(
int
recID
,
int
param
,
int
gridID
,
int
zaxistype
,
int
lbounds
,
int
level1
,
int
level2
,
int
level_sf
,
int
level_unit
,
int
prec
,
...
...
@@ -12,7 +13,7 @@ void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
const
char
*
name
,
const
char
*
stdname
,
const
char
*
longname
,
const
char
*
units
);
void
varDefVCT
(
size_t
vctsize
,
double
*
vctptr
);
void
varDefZAxisReference
(
int
nlev
,
int
nvgrid
,
char
*
uuid
);
void
varDefZAxisReference
(
int
nlev
,
int
nvgrid
,
unsigned
char
uuid
[
CDI_UUID_SIZE
]
);
int
varDefGrid
(
int
vlistID
,
grid_t
grid
,
int
mode
);
int
varDefZaxis
(
int
vlistID
,
int
zaxistype
,
int
nlevels
,
double
*
levels
,
int
lbounds
,
...
...
src/zaxis.c
View file @
fb8f77bc
...
...
@@ -83,7 +83,7 @@ typedef struct {
double
*
vct
;
int
number
;
/* Reference number to a generalized Z-axis */
int
nhlev
;
char
uuid
[
17
];
unsigned
char
uuid
[
CDI_UUID_SIZE
];
}
zaxis_t
;
...
...
@@ -748,13 +748,13 @@ The function @func{zaxisDefUUID} defines the UUID for a generalized Z-axis.
@EndFunction
*/
void
zaxisDefUUID
(
int
zaxisID
,
const
char
*
uuid
)
void
zaxisDefUUID
(
int
zaxisID
,
const
unsigned
char
uuid
[
CDI_UUID_SIZE
]
)
{
zaxis_t
*
zaxisptr
=
reshGetVal
(
zaxisID
,
&
zaxisOps
);
zaxis_check_ptr
(
zaxisID
,
zaxisptr
);
memcpy
(
zaxisptr
->
uuid
,
uuid
,
16
);
memcpy
(
zaxisptr
->
uuid
,
uuid
,
CDI_UUID_SIZE
);
reshSetStatus
(
zaxisID
,
&
zaxisOps
,
RESH_DESYNC_IN_USE
);
}
...
...
@@ -773,13 +773,13 @@ The function @func{zaxisInqUUID} returns the UUID to a generalized Z-axis.
@func{zaxisInqUUID} returns the UUID to a generalized Z-axis to the parameter uuid.
@EndFunction
*/
void
zaxisInqUUID
(
int
zaxisID
,
char
*
uuid
)
void
zaxisInqUUID
(
int
zaxisID
,
unsigned
char
uuid
[
CDI_UUID_SIZE
]
)
{
zaxis_t
*
zaxisptr
=
reshGetVal
(
zaxisID
,
&
zaxisOps
);
zaxis_check_ptr
(
zaxisID
,
zaxisptr
);
memcpy
(
uuid
,
zaxisptr
->
uuid
,
16
);
memcpy
(
uuid
,
zaxisptr
->
uuid
,
CDI_UUID_SIZE
);
}
/*
...
...
@@ -1253,7 +1253,7 @@ void zaxisPrintKernel ( zaxis_t * zaxisptr, FILE * fp )
{
int
zaxisID
;
int
type
;
char
uuid
[
17
];
unsigned
char
uuid
[
CDI_UUID_SIZE
];
int
nlevels
,
levelID
;
int
nbyte0
,
nbyte
;
double
level
;
...
...
@@ -1354,7 +1354,7 @@ void zaxisPrintKernel ( zaxis_t * zaxisptr, FILE * fp )
{
const
unsigned
char
*
d
;
zaxisInqUUID
(
zaxisID
,
uuid
);
d
=
(
unsigned
char
*
)
&
uuid
;
d
=
uuid
;
fprintf
(
fp
,
"uuid = %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x
\n
"
,
d
[
0
],
d
[
1
],
d
[
2
],
d
[
3
],
d
[
4
],
d
[
5
],
d
[
6
],
d
[
7
],
d
[
8
],
d
[
9
],
d
[
10
],
d
[
11
],
d
[
12
],
d
[
13
],
d
[
14
],
d
[
15
]);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment