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
3cfe894f
Commit
3cfe894f
authored
Mar 25, 2015
by
Thomas Jahns
🤸
Browse files
Replace array of resource handles with apply call.
parent
1d9efebb
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/varscan.c
View file @
3cfe894f
...
...
@@ -866,6 +866,33 @@ int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const dou
return
(
differ
);
}
struct
varDefZAxisSearchState
{
int
resIDValue
;
int
zaxistype
;
int
nlevels
;
double
*
levels
;
int
lbounds
;
char
*
longname
,
*
units
;
int
ltype
;
};
static
enum
cdiApplyRet
varDefZAxisSearch
(
int
id
,
void
*
res
,
void
*
data
)
{
struct
varDefZAxisSearchState
*
state
=
data
;
(
void
)
res
;
if
(
zaxisCompare
(
id
,
state
->
zaxistype
,
state
->
nlevels
,
state
->
lbounds
,
state
->
levels
,
state
->
longname
,
state
->
units
,
state
->
ltype
)
==
0
)
{
state
->
resIDValue
=
id
;
return
CDI_APPLY_STOP
;
}
else
return
CDI_APPLY_GO_ON
;
}
int
varDefZaxis
(
int
vlistID
,
int
zaxistype
,
int
nlevels
,
double
*
levels
,
int
lbounds
,
double
*
levels1
,
double
*
levels2
,
int
vctsize
,
double
*
vct
,
char
*
name
,
...
...
@@ -900,29 +927,22 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
if
(
!
zaxisdefined
)
{
reshLock
();
unsigned
nzaxis
=
cdiZaxisCount
();
if
(
nzaxis
>
0
)
{
int
*
zaxisIndexList
;
zaxisIndexList
=
(
int
*
)
xmalloc
((
size_t
)
nzaxis
*
sizeof
(
int
));
cdiZaxisGetIndexList
(
nzaxis
,
zaxisIndexList
);
for
(
unsigned
i
=
0
;
i
<
nzaxis
;
i
++
)
{
zaxisID
=
zaxisIndexList
[
i
];
if
(
zaxisCompare
(
zaxisID
,
zaxistype
,
nlevels
,
lbounds
,
levels
,
longname
,
units
,
ltype1
)
==
0
)
{
zaxisglobdefined
=
1
;
break
;
}
}
free
(
zaxisIndexList
);
}
reshUnlock
();
struct
varDefZAxisSearchState
query
=
{
.
zaxistype
=
zaxistype
,
.
nlevels
=
nlevels
,
.
levels
=
levels
,
.
lbounds
=
lbounds
,
.
longname
=
longname
,
.
units
=
units
,
.
ltype
=
ltype1
,
};
if
((
zaxisglobdefined
=
(
cdiResHFilterApply
(
&
zaxisOps
,
varDefZAxisSearch
,
&
query
)
==
CDI_APPLY_STOP
)))
zaxisID
=
query
.
resIDValue
;
nzaxis
=
(
unsigned
)
vlistptr
->
nzaxis
;
if
(
mode
==
1
)
for
(
unsigned
index
=
0
;
index
<
nzaxis
;
index
++
)
if
(
mode
==
1
&&
zaxisglobdefined
)
for
(
int
index
=
0
;
index
<
nzaxis
;
index
++
)
if
(
vlistptr
->
zaxisIDs
[
index
]
==
zaxisID
)
{
zaxisglobdefined
=
FALSE
;
...
...
src/zaxis.c
View file @
3cfe894f
...
...
@@ -94,7 +94,7 @@ static int zaxisGetPackSize ( void * zaxisptr, void *context);
static
void
zaxisPack
(
void
*
zaxisptr
,
void
*
buffer
,
int
size
,
int
*
pos
,
void
*
context
);
static
int
zaxisTxCode
(
void
);
static
const
resOps
zaxisOps
=
{
const
resOps
zaxisOps
=
{
(
int
(
*
)(
void
*
,
void
*
))
zaxisCompareP
,
zaxisDestroyP
,
zaxisPrintP
,
...
...
src/zaxis.h
View file @
3cfe894f
#ifndef _ZAXIS_H
#define _ZAXIS_H
#ifndef RESOURCE_HANDLE_H
#include
"resource_handle.h"
#endif
unsigned
cdiZaxisCount
(
void
);
void
cdiZaxisGetIndexList
(
unsigned
numIDs
,
int
IDs
[
numIDs
]);
...
...
@@ -12,4 +16,6 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
void
zaxisDefLtype2
(
int
zaxisID
,
int
ltype2
);
extern
const
resOps
zaxisOps
;
#endif
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