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
12420eeb
Commit
12420eeb
authored
Jan 07, 2016
by
Thomas Jahns
🤸
Browse files
Narrow variable scope in cdfTimeDimID and fold array storage.
parent
bb905f59
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf.c
View file @
12420eeb
...
...
@@ -2928,54 +2928,38 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
static
int
cdfTimeDimID
(
int
fileID
,
int
ndims
,
int
nvars
)
{
int
dimid
=
UNDEFID
;
int
timedimid
=
UNDEFID
;
char
dimname
[
80
];
char
timeunits
[
CDI_MAX_NAME
];
char
attname
[
CDI_MAX_NAME
];
char
name
[
CDI_MAX_NAME
];
nc_type
xtype
;
int
nvdims
,
nvatts
;
int
dimids
[
9
];
int
varid
,
iatt
;
for
(
dimid
=
0
;
dimid
<
ndims
;
dimid
++
)
for
(
int
dimid
=
0
;
dimid
<
ndims
;
dimid
++
)
{
char
dimname
[
80
];
cdf_inq_dimname
(
fileID
,
dimid
,
dimname
);
if
(
memcmp
(
dimname
,
"time"
,
4
)
==
0
)
{
timedimid
=
dimid
;
break
;
}
return
dimid
;
}
if
(
timedimid
==
UNDEFID
)
for
(
int
varid
=
0
;
varid
<
nvars
;
varid
++
)
{
for
(
varid
=
0
;
varid
<
nvars
;
varid
++
)
int
nvdims
,
nvatts
,
dimids
[
9
];
cdf_inq_var
(
fileID
,
varid
,
NULL
,
NULL
,
&
nvdims
,
dimids
,
&
nvatts
);
if
(
nvdims
==
1
)
{
cdf_inq_var
(
fileID
,
varid
,
name
,
&
xtype
,
&
nvdims
,
dimids
,
&
nvatts
);
if
(
nvdims
==
1
)
for
(
int
iatt
=
0
;
iatt
<
nvatts
;
iatt
++
)
{
for
(
iatt
=
0
;
iatt
<
nvatts
;
iatt
++
)
char
sbuf
[
CDI_MAX_NAME
];
cdf_inq_attname
(
fileID
,
varid
,
iatt
,
sbuf
);
if
(
strncmp
(
sbuf
,
"units"
,
5
)
==
0
)
{
cdf_inq_attname
(
fileID
,
varid
,
iatt
,
attname
);
if
(
strncmp
(
attname
,
"units"
,
5
)
==
0
)
{
cdfGetAttText
(
fileID
,
varid
,
"units"
,
sizeof
(
timeunits
),
timeunits
);
strtolower
(
timeunits
);
cdfGetAttText
(
fileID
,
varid
,
"units"
,
sizeof
(
sbuf
),
sbuf
);
strtolower
(
sbuf
);
if
(
isTimeUnits
(
timeunits
)
)
{
timedimid
=
dimids
[
0
];
break
;
}
}
if
(
isTimeUnits
(
sbuf
)
)
return
dimids
[
0
];
}
}
}
}
return
(
timedimid
)
;
return
UNDEFID
;
}
static
...
...
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