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
49b7fd3a
Commit
49b7fd3a
authored
Jul 13, 2016
by
Uwe Schulzweida
Browse files
cdf_time_dimid(): check dimension name Time.
parent
8463e7da
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf_i.c
View file @
49b7fd3a
...
...
@@ -614,6 +614,7 @@ int cdf_time_dimid(int fileID, int ndims, int nvars)
cdf_inq_dimname
(
fileID
,
dimid
,
dimname
);
size_t
len
=
strlen
(
dimname
);
if
(
len
>=
4
&&
memcmp
(
dimname
,
"time"
,
4
)
==
0
)
return
dimid
;
if
(
len
>=
4
&&
memcmp
(
dimname
,
"Time"
,
4
)
==
0
)
return
dimid
;
}
for
(
int
varid
=
0
;
varid
<
nvars
;
++
varid
)
...
...
@@ -3648,7 +3649,6 @@ int cdfInqContents(stream_t *streamptr)
int
ndims
,
nvars
,
ngatts
,
unlimdimid
;
int
ncvarid
;
int
ncdimid
;
size_t
ntsteps
;
int
timedimid
=
-
1
;
int
*
varids
;
int
nvarids
;
...
...
@@ -3661,16 +3661,14 @@ int cdfInqContents(stream_t *streamptr)
int
modelID
=
UNDEFID
;
int
taxisID
;
int
calendar
=
UNDEFID
;
ncdim_t
*
ncdims
;
ncvar_t
*
ncvars
=
NULL
;
int
format
=
0
;
bool
ucla_les
=
false
;
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
;
unsigned
char
uuidOfHGrid
[
CDI_UUID_SIZE
];
unsigned
char
uuidOfVGrid
[
CDI_UUID_SIZE
];
memset
(
uuidOfHGrid
,
0
,
CDI_UUID_SIZE
);
memset
(
uuidOfVGrid
,
0
,
CDI_UUID_SIZE
);
gridfile
[
0
]
=
0
;
...
...
@@ -3697,19 +3695,9 @@ int cdfInqContents(stream_t *streamptr)
}
/* alloc ncdims */
ncdims
=
(
ncdim_t
*
)
Malloc
((
size_t
)
ndims
*
sizeof
(
ncdim_t
));
ncdim_t
*
ncdims
=
(
ncdim_t
*
)
Malloc
((
size_t
)
ndims
*
sizeof
(
ncdim_t
));
init_ncdims
(
ndims
,
ncdims
);
if
(
nvars
>
0
)
{
/* alloc ncvars */
ncvars
=
(
ncvar_t
*
)
Malloc
((
size_t
)
nvars
*
sizeof
(
ncvar_t
));
init_ncvars
(
nvars
,
ncvars
);
for
(
ncvarid
=
0
;
ncvarid
<
nvars
;
++
ncvarid
)
ncvars
[
ncvarid
].
ncid
=
fileID
;
}
#if defined (TEST_GROUPS)
#if defined (HAVE_NETCDF4)
if
(
format
==
NC_FORMAT_NETCDF4
)
...
...
@@ -3743,6 +3731,13 @@ int cdfInqContents(stream_t *streamptr)
return
CDI_EUFSTRUCT
;
}
/* alloc ncvars */
ncvar_t
*
ncvars
=
(
ncvar_t
*
)
Malloc
((
size_t
)
nvars
*
sizeof
(
ncvar_t
));
init_ncvars
(
nvars
,
ncvars
);
for
(
ncvarid
=
0
;
ncvarid
<
nvars
;
++
ncvarid
)
ncvars
[
ncvarid
].
ncid
=
fileID
;
/* scan global attributes */
cdf_scan_global_attr
(
fileID
,
vlistID
,
streamptr
,
ngatts
,
&
instID
,
&
modelID
,
&
ucla_les
,
uuidOfHGrid
,
uuidOfVGrid
,
gridfile
,
&
number_of_grid_used
);
...
...
@@ -3755,10 +3750,8 @@ int cdfInqContents(stream_t *streamptr)
streamptr
->
basetime
.
ncdimid
=
timedimid
;
if
(
timedimid
!=
UNDEFID
)
cdf_inq_dimlen
(
fileID
,
timedimid
,
&
ntsteps
);
else
ntsteps
=
0
;
size_t
ntsteps
=
0
;
if
(
timedimid
!=
UNDEFID
)
cdf_inq_dimlen
(
fileID
,
timedimid
,
&
ntsteps
);
if
(
CDI_Debug
)
Message
(
"Number of timesteps = %d"
,
ntsteps
);
if
(
CDI_Debug
)
Message
(
"Time dimid = %d"
,
streamptr
->
basetime
.
ncdimid
);
...
...
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