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
4370c5a2
Commit
4370c5a2
authored
Mar 05, 2013
by
Uwe Schulzweida
Browse files
netCDF: scan uuid of horizontal grid
parent
63593b22
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/printinfo.h
View file @
4370c5a2
#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
date2str
(
int
date
,
char
*
datestr
,
int
maxlen
)
{
int
year
,
month
,
day
;
...
...
@@ -66,6 +68,7 @@ void printFiletype(int streamID, int vlistID)
break
;
default:
printf
(
" File format: unsupported filetype %d"
,
filetype
);
break
;
}
if
(
filetype
==
FILETYPE_SRV
||
filetype
==
FILETYPE_EXT
||
filetype
==
FILETYPE_IEG
)
...
...
@@ -133,6 +136,7 @@ void printGridInfo(int vlistID)
int
gridID
,
gridtype
,
trunc
,
gridsize
,
xsize
,
ysize
;
int
nbyte0
;
char
xname
[
CDI_MAX_NAME
],
yname
[
CDI_MAX_NAME
],
xunits
[
CDI_MAX_NAME
],
yunits
[
CDI_MAX_NAME
];
char
uuidOfHGrid
[
17
];
ngrids
=
vlistNgrids
(
vlistID
);
for
(
index
=
0
;
index
<
ngrids
;
index
++
)
...
...
@@ -356,9 +360,7 @@ void printGridInfo(int vlistID)
if
(
ysize
==
0
)
fprintf
(
stdout
,
"size : dim = %d
\n
"
,
gridsize
);
else
{
fprintf
(
stdout
,
"size : dim = %d nx = %d ny = %d
\n
"
,
gridsize
,
xsize
,
ysize
);
}
fprintf
(
stdout
,
"size : dim = %d nx = %d ny = %d
\n
"
,
gridsize
,
xsize
,
ysize
);
}
if
(
gridtype
==
GRID_CURVILINEAR
||
gridtype
==
GRID_UNSTRUCTURED
||
gridtype
==
GRID_LCC
)
...
...
@@ -377,6 +379,18 @@ void printGridInfo(int vlistID)
fprintf
(
stdout
,
"
\n
"
);
}
}
gridInqUUID
(
gridID
,
uuidOfHGrid
);
if
(
uuidOfHGrid
[
0
]
!=
0
)
{
char
uuidOfHGridStr
[
37
];
uuid2str
(
uuidOfHGrid
,
uuidOfHGridStr
);
if
(
uuidOfHGridStr
[
0
]
!=
0
&&
strlen
(
uuidOfHGridStr
)
==
36
)
{
fprintf
(
stdout
,
"%*s"
,
nbyte0
,
""
);
fprintf
(
stdout
,
"uuid : %s
\n
"
,
uuidOfHGridStr
);
}
}
}
}
/*
...
...
src/stream_cdf.c
View file @
4370c5a2
...
...
@@ -1831,7 +1831,7 @@ void cdfDefGdim(stream_t *streamptr, int gridID)
break
;
}
else
iz
++
;
iz
++
;
}
}
}
...
...
@@ -1852,7 +1852,7 @@ void cdfDefGdim(stream_t *streamptr, int gridID)
break
;
}
else
iz
++
;
iz
++
;
}
}
}
...
...
@@ -1864,6 +1864,7 @@ void cdfDefGdim(stream_t *streamptr, int gridID)
if
(
streamptr
->
ncmode
==
2
)
cdf_redef
(
fileID
);
//printf("axisname, dimlen %s %d\n", axisname, dimlen);
cdf_def_dim
(
fileID
,
axisname
,
dimlen
,
&
dimID
);
cdf_enddef
(
fileID
);
...
...
@@ -2510,6 +2511,23 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
#endif
#if defined (HAVE_LIBNETCDF)
static
void
cdfDefGridUUID
(
stream_t
*
streamptr
,
int
gridID
)
{
char
uuidOfHGrid
[
17
];
gridInqUUID
(
gridID
,
uuidOfHGrid
);
if
(
uuidOfHGrid
[
0
]
!=
0
)
{
char
uuidOfHGridStr
[
37
];
uuid2str
(
uuidOfHGrid
,
uuidOfHGridStr
);
if
(
uuidOfHGridStr
[
0
]
!=
0
&&
strlen
(
uuidOfHGridStr
)
==
36
)
{
// cdf_put_att_text(fileID, ncvarid, "uuid", 36, uuidOfHGridStr);
}
}
}
static
void
cdfDefGrid
(
stream_t
*
streamptr
,
int
gridID
)
{
...
...
@@ -2607,6 +2625,8 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
{
Error
(
"Unsupported grid type: %s"
,
gridNamePtr
(
gridtype
));
}
cdfDefGridUUID
(
streamptr
,
gridID
);
}
#endif
...
...
@@ -5157,7 +5177,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
)
void
define_all_grids
(
stream_t
*
streamptr
,
int
vlistID
,
ncdim_t
*
ncdims
,
int
nvars
,
ncvar_t
*
ncvars
,
int
timedimid
,
char
*
uuidOfHGrid
)
{
int
ncvarid
,
ncvarid2
;
int
ndims
;
...
...
@@ -5704,6 +5724,9 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
#endif
ncvars
[
ncvarid
].
gridID
=
varDefGrid
(
vlistID
,
grid
,
1
);
if
(
uuidOfHGrid
[
0
]
!=
0
&&
grid
.
type
==
GRID_UNSTRUCTURED
)
gridDefUUID
(
ncvars
[
ncvarid
].
gridID
,
uuidOfHGrid
);
if
(
ncvars
[
ncvarid
].
chunked
)
{
ndims
=
ncvars
[
ncvarid
].
ndims
;
...
...
@@ -5719,7 +5742,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
{
if
(
grid
.
xsize
>
1
&&
grid
.
ysize
>
1
&&
ndims
>
1
&&
grid
.
xsize
==
ncvars
[
ncvarid
].
chunks
[
ndims
-
1
]
&&
grid
.
ysize
==
ncvars
[
ncvarid
].
chunks
[
ndims
-
2
]
)
grid
.
ysize
==
ncvars
[
ncvarid
].
chunks
[
ndims
-
2
]
)
ncvars
[
ncvarid
].
chunktype
=
CHUNK_GRID
;
else
if
(
grid
.
xsize
>
1
&&
grid
.
xsize
==
ncvars
[
ncvarid
].
chunks
[
ndims
-
1
]
)
ncvars
[
ncvarid
].
chunktype
=
CHUNK_LINES
;
...
...
@@ -6218,8 +6241,8 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
}
static
void
read
_global_attributtes
(
int
fileID
,
int
vlistID
,
stream_t
*
streamptr
,
int
ngatts
,
int
*
instID
,
int
*
modelID
,
int
*
ucla_les
)
void
scan
_global_attributtes
(
int
fileID
,
int
vlistID
,
stream_t
*
streamptr
,
int
ngatts
,
int
*
instID
,
int
*
modelID
,
int
*
ucla_les
,
char
*
uuidOfHGrid
)
{
nc_type
xtype
;
size_t
attlen
;
...
...
@@ -6271,6 +6294,12 @@ void read_global_attributtes(int fileID, int vlistID, stream_t *streamptr, int n
else
if
(
strcmp
(
attname
,
"CDO"
)
==
0
)
{
}
else
if
(
strcmp
(
attname
,
"uuid"
)
==
0
&&
attlen
==
36
)
{
attstring
[
36
]
=
0
;
str2uuid
(
attstring
,
uuidOfHGrid
);
// printf("uuid: %d %s\n", attlen, attstring);
}
else
{
vlistDefAttTxt
(
vlistID
,
CDI_GLOBAL
,
attname
,
(
int
)
attlen
,
attstring
);
...
...
@@ -6333,6 +6362,9 @@ int cdfInqContents(stream_t *streamptr)
int
vlistID
;
int
format
=
0
;
int
ucla_les
=
FALSE
;
char
uuidOfHGrid
[
17
];
uuidOfHGrid
[
0
]
=
0
;
vlistID
=
streamptr
->
vlistID
;
fileID
=
streamptr
->
fileID
;
...
...
@@ -6401,8 +6433,8 @@ int cdfInqContents(stream_t *streamptr)
return
(
CDI_EUFSTRUCT
);
}
/*
read
global attributtes */
read
_global_attributtes
(
fileID
,
vlistID
,
streamptr
,
ngatts
,
&
instID
,
&
modelID
,
&
ucla_les
);
/*
scan
global attributtes */
scan
_global_attributtes
(
fileID
,
vlistID
,
streamptr
,
ngatts
,
&
instID
,
&
modelID
,
&
ucla_les
,
uuidOfHGrid
);
/* find time dim */
if
(
unlimdimid
>=
0
)
...
...
@@ -6695,7 +6727,7 @@ int cdfInqContents(stream_t *streamptr)
/* define all grids */
define_all_grids
(
streamptr
,
vlistID
,
ncdims
,
nvars
,
ncvars
,
timedimid
);
define_all_grids
(
streamptr
,
vlistID
,
ncdims
,
nvars
,
ncvars
,
timedimid
,
uuidOfHGrid
);
/* read VCT */
...
...
src/util.c
View file @
4370c5a2
...
...
@@ -93,6 +93,8 @@ void str2uuid(const char *uuidstr, char *uuid)
if
(
iret
!=
16
)
return
;
for
(
int
i
=
0
;
i
<
16
;
++
i
)
uuid
[
i
]
=
ui
[
i
];
uuid
[
16
]
=
0
;
}
/*
...
...
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