Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
libcdi
Commits
a53191d7
Commit
a53191d7
authored
13 years ago
by
Deike Kleberg
Browse files
Options
Downloads
Patches
Plain Diff
Bug fixed in varscan.c, catch empty arrays.
parent
d999798b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/cdi_read.c
+5
-1
5 additions, 1 deletion
examples/cdi_read.c
src/varscan.c
+31
-25
31 additions, 25 deletions
src/varscan.c
with
36 additions
and
26 deletions
examples/cdi_read.c
+
5
−
1
View file @
a53191d7
#include
<stdio.h>
#include
"cdi.h"
extern
void
reshArrayPrint
(
char
*
filename
);
int
nlon
=
12
;
// Number of longitudes
int
nlat
=
6
;
// Number of latitudes
int
nlev
=
5
;
// Number of levels
...
...
@@ -15,7 +17,7 @@ int main(void)
// Open the dataset
streamID
=
streamOpenRead
(
"example.
nc
"
);
streamID
=
streamOpenRead
(
"example.
grb
"
);
if
(
streamID
<
0
)
{
fprintf
(
stderr
,
"%s
\n
"
,
cdiStringError
(
streamID
));
...
...
@@ -47,6 +49,8 @@ int main(void)
streamReadVar
(
streamID
,
varID2
,
var2
,
&
nmiss
);
}
reshArrayPrint
(
"reshArrayRead"
);
// Close the input stream
streamClose
(
streamID
);
...
...
This diff is collapsed.
Click to expand it.
src/varscan.c
+
31
−
25
View file @
a53191d7
...
...
@@ -658,19 +658,22 @@ int varDefGrid(int vlistID, grid_t grid, int mode)
if
(
!
griddefined
)
{
ngrids
=
gridSize
();
gridIndexArray
=
malloc
(
ngrids
*
sizeof
(
int
));
gridGetIndexArray
(
ngrids
,
gridIndexArray
);
for
(
i
=
0
;
i
<
ngrids
;
i
++
)
{
gridID
=
gridIndexArray
[
i
];
if
(
gridCompare
(
gridID
,
grid
)
==
0
)
{
gridglobdefined
=
TRUE
;
break
;
}
}
if
(
gridIndexArray
)
free
(
gridIndexArray
);
if
(
ngrids
>
0
)
{
gridIndexArray
=
malloc
(
ngrids
*
sizeof
(
int
));
gridGetIndexArray
(
ngrids
,
gridIndexArray
);
for
(
i
=
0
;
i
<
ngrids
;
i
++
)
{
gridID
=
gridIndexArray
[
i
];
if
(
gridCompare
(
gridID
,
grid
)
==
0
)
{
gridglobdefined
=
TRUE
;
break
;
}
}
if
(
gridIndexArray
)
free
(
gridIndexArray
);
}
ngrids
=
vlistptr
->
ngrids
;
if
(
mode
==
1
)
for
(
index
=
0
;
index
<
ngrids
;
index
++
)
...
...
@@ -776,18 +779,21 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
if
(
!
zaxisdefined
)
{
nzaxis
=
zaxisSize
();
zaxisIndexArray
=
malloc
(
nzaxis
*
sizeof
(
int
));
zaxisGetIndexArray
(
nzaxis
,
zaxisIndexArray
);
for
(
i
=
0
;
i
<
nzaxis
;
i
++
)
{
zaxisID
=
zaxisIndexArray
[
i
];
if
(
zaxisCompare
(
zaxisID
,
zaxistype
,
nlevels
,
lbounds
,
levels
,
longname
,
units
,
ltype
)
==
0
)
{
zaxisglobdefined
=
1
;
break
;
}
}
if
(
zaxisIndexArray
)
free
(
zaxisIndexArray
);
if
(
nzaxis
>
0
)
{
zaxisIndexArray
=
malloc
(
nzaxis
*
sizeof
(
int
));
zaxisGetIndexArray
(
nzaxis
,
zaxisIndexArray
);
for
(
i
=
0
;
i
<
nzaxis
;
i
++
)
{
zaxisID
=
zaxisIndexArray
[
i
];
if
(
zaxisCompare
(
zaxisID
,
zaxistype
,
nlevels
,
lbounds
,
levels
,
longname
,
units
,
ltype
)
==
0
)
{
zaxisglobdefined
=
1
;
break
;
}
}
if
(
zaxisIndexArray
)
free
(
zaxisIndexArray
);
}
nzaxis
=
vlistptr
->
nzaxis
;
if
(
mode
==
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment