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
3afe099c
Commit
3afe099c
authored
May 27, 2011
by
Deike Kleberg
Browse files
Testcase compare resource arrays.
parent
31f5dd5c
Changes
15
Hide whitespace changes
Inline
Side-by-side
pioExamples/compareResourcesArray.c
View file @
3afe099c
...
...
@@ -13,9 +13,11 @@
#include
"pio_c_temp.h"
#include
"pio_util.h"
extern
void
reshPackBufferCreate
(
char
**
,
int
*
,
MPI_Comm
);
extern
int
reshArrayCompare
(
int
,
int
);
extern
void
reshArrayPrint
(
char
*
);
extern
void
reshPackBufferCreate
(
char
**
,
int
*
,
MPI_Comm
);
extern
void
reshPackBufferDestroy
(
char
**
);
extern
void
rpcUnpackResources
(
char
*
,
int
,
MPI_Comm
);
extern
void
rpcUnpackResources
(
char
*
,
int
,
MPI_Comm
);
#define nlon 12 // Number of longitudes
#define nlat 6 // Number of latitudes
...
...
@@ -75,6 +77,8 @@ void modelRun ()
int
bufferSize
;
MPI_Status
status
;
int
differ
;
namespaceInit
(
2
,
hlf
);
namespaceSetActive
(
0
);
...
...
@@ -140,12 +144,17 @@ void modelRun ()
namespaceSetActive
(
0
);
free
(
recvBuffer
);
reshPackBufferDestroy
(
&
sendBuffer
);
xdebug
();
differ
=
reshArrayCompare
(
0
,
1
);
printf
(
"###### The resource arrays %s.
\n
"
,
differ
?
"differ"
:
"are equal"
);
xdebug
();
reshArrayPrint
(
"reshArrayModel"
);
// Close the output stream
streamClose
(
streamID
);
// Destroy the objects
vlistDestroy
(
vlistID
);
taxisDestroy
(
taxisID
);
zaxisDestroy
(
zaxisID1
);
...
...
pioExamples/myModel.c
View file @
3afe099c
...
...
@@ -14,6 +14,9 @@
#include
"pio_util.h"
extern
void
reshArrayPrint
(
char
*
);
#define nlon 12 // Number of longitudes
#define nlat 6 // Number of latitudes
#define nlev 5 // Number of levels
...
...
src/cdi.h
View file @
3afe099c
...
...
@@ -209,8 +209,6 @@ void pioMetadata ( void );
void
namespaceInit
(
int
,
int
*
);
void
namespaceSetActive
(
int
);
void
reshArrayPrint
(
char
*
);
void
gridGetIndexArray
(
int
,
int
*
);
void
zaxisGetIndexArray
(
int
,
int
*
);
...
...
src/grid.c
View file @
3afe099c
...
...
@@ -53,7 +53,7 @@ static void gridPrintP ( void * gridptr, FILE * fp );
static
int
gridGetSizeP
(
void
*
gridptr
,
MPI_Comm
comm
);
static
void
gridPackP
(
void
*
gridptr
,
void
*
buff
,
int
size
,
int
*
position
,
MPI_Comm
comm
);
static
int
gridTxCode
(
void
*
gridptr
);
static
int
gridTxCode
(
void
);
#endif
resOps
gridOps
=
{
gridCompareP
,
gridDestroyP
,
gridPrintP
...
...
@@ -3873,7 +3873,7 @@ void gridGetIndexArray ( int ngrids, int * gridIndexArray )
#ifdef USE_MPI
static
int
gridTxCode
(
void
*
gridptr
)
gridTxCode
(
)
{
return
GRID
;
}
...
...
src/institution.c
View file @
3afe099c
...
...
@@ -37,7 +37,7 @@ static void institutePrintP ( void * instituteptr, FILE * fp );
static
int
instituteGetSizeP
(
void
*
instituteptr
,
MPI_Comm
comm
);
static
void
institutePackP
(
void
*
instituteptr
,
void
*
buf
,
int
size
,
int
*
position
,
MPI_Comm
comm
);
static
int
instituteTxCode
(
void
*
instituteptr
);
static
int
instituteTxCode
(
void
);
#endif
resOps
instituteOps
=
{
instituteCompareP
,
instituteDestroyP
,
institutePrintP
...
...
@@ -368,7 +368,7 @@ void institutePrintP ( void * instituteptr, FILE * fp )
#ifdef USE_MPI
static
int
instituteTxCode
(
void
*
vlistptr
)
instituteTxCode
(
void
)
{
return
INSTITUTE
;
}
...
...
src/model.c
View file @
3afe099c
...
...
@@ -41,7 +41,7 @@ static void modelPrintP ( void * modelptr, FILE * fp );
static
int
modelGetSizeP
(
void
*
modelptr
,
MPI_Comm
comm
);
static
void
modelPackP
(
void
*
modelptr
,
void
*
buff
,
int
size
,
int
*
position
,
MPI_Comm
comm
);
static
int
modelTxCode
(
void
*
modelptr
);
static
int
modelTxCode
(
void
);
#endif
resOps
modelOps
=
{
modelCompareP
,
modelDestroyP
,
modelPrintP
...
...
@@ -289,7 +289,7 @@ void modelPrintP ( void * modelptr, FILE * fp )
#ifdef USE_MPI
static
int
modelTxCode
(
void
*
modelptr
)
modelTxCode
(
void
)
{
return
MODEL
;
}
...
...
src/pio_util.c
View file @
3afe099c
...
...
@@ -186,4 +186,22 @@ void pcdiDebugMsg2 ( const char *filename, const char *functionname, int line,
#endif
/****************************************************/
int
xmaxInt
(
int
a
,
int
b
)
{
return
a
>=
b
?
a
:
b
;
}
/****************************************************/
int
xminInt
(
int
a
,
int
b
)
{
return
a
<=
b
?
a
:
b
;
}
/****************************************************/
src/pio_util.h
View file @
3afe099c
...
...
@@ -130,4 +130,6 @@ void pcdiDebugMsg2 ( const char *filename, const char *functionname, int line, \
int
tag
,
int
source
,
char
*
text
);
#define xdebugMsg2(tag,source,text) pcdiDebugMsg ( __FILE__, __func__, \
__LINE__, tag, source, text )
int
xmaxInt
(
int
,
int
);
int
xminInt
(
int
,
int
);
#endif
src/resource_handle.c
View file @
3afe099c
...
...
@@ -407,7 +407,7 @@ void reshPackBufferCreate ( char ** packBuffer, int * packBufferSize, MPI_Comm c
curr
=
arrayResources
[
nsp
]
+
i
;
assert
(
curr
->
ops
);
type
=
curr
->
ops
->
valTxCode
(
curr
->
ptr
);
type
=
curr
->
ops
->
valTxCode
();
if
(
!
type
)
continue
;
...
...
@@ -524,6 +524,70 @@ void reshUnlock ()
/**************************************************************/
int
reshArrayCompare
(
int
nsp0
,
int
nsp1
)
{
const
int
equal
=
0
;
const
int
differ
=
-
1
;
int
i
;
node
*
node0
,
*
node1
;
assert
(
arrayInit
&&
namespaceGetNumber
()
>
xmaxInt
(
nsp0
,
nsp1
)
&&
xminInt
(
nsp0
,
nsp1
)
>=
0
);
for
(
i
=
0
;
i
<
arraySizeAllocated
[
nsp0
];
i
++
)
{
node0
=
arrayResources
[
nsp0
]
+
i
;
if
(
node0
->
ptr
)
{
if
(
i
>=
arraySizeAllocated
[
nsp1
]
)
{
xdebug
();
return
differ
;
}
node1
=
arrayResources
[
nsp1
]
+
i
;
if
(
!
node1
->
ptr
)
{
xdebug
();
return
differ
;
}
assert
(
node0
->
ops
&&
node1
->
ops
);
if
(
node0
->
ops
!=
node1
->
ops
)
{
xdebug
();
return
differ
;
}
if
(
node0
->
ops
->
valCompare
((
void
*
)
node0
->
ptr
,
(
void
*
)
node1
->
ptr
)
!=
equal
)
{
printf
(
"type %d, values idx0=%d and idx1=%d differ
\n
"
,
node0
->
ops
->
valTxCode
(),
node0
->
idx
,
node1
->
idx
);
return
differ
;
}
else
{
printf
(
"type %d, values idx0=%d and idx1=%d are equal
\n
"
,
node0
->
ops
->
valTxCode
(),
node0
->
idx
,
node1
->
idx
);
}
}
else
if
(
arrayResources
[
nsp1
][
i
].
ptr
)
return
differ
;
}
for
(
;
i
<
arraySizeAllocated
[
nsp1
];
i
++
)
if
(
arrayResources
[
nsp1
][
i
].
ptr
)
{
xdebug
();
return
differ
;
}
return
equal
;
}
/**************************************************************/
void
reshArrayPrint
(
char
*
filename
)
{
int
i
,
j
,
temp
;
...
...
src/resource_handle.h
View file @
3afe099c
...
...
@@ -30,7 +30,7 @@ typedef void ( * valPrintFunc )( void *, FILE * );
typedef
int
(
*
valGetPackSizeFunc
)(
void
*
,
MPI_Comm
comm
);
typedef
void
(
*
valPackFunc
)(
void
*
,
void
*
buf
,
int
size
,
int
*
pos
,
MPI_Comm
comm
);
typedef
int
(
*
valTxCodeFunc
)(
void
*
);
typedef
int
(
*
valTxCodeFunc
)(
void
);
#endif
typedef
struct
{
...
...
@@ -66,4 +66,7 @@ int reshGetStatus ( cdiResH, resOps * );
void
reshLock
(
void
);
void
reshUnlock
(
void
);
int
reshArrayCompare
(
int
,
int
);
void
reshArrayPrint
(
char
*
);
#endif
src/stream_int.c
View file @
3afe099c
...
...
@@ -73,7 +73,7 @@ static void streamPrintP ( void * streamptr, FILE * fp );
static
int
streamGetSizeP
(
void
*
streamptr
,
MPI_Comm
comm
);
static
void
streamPackP
(
void
*
streamptr
,
void
*
buff
,
int
size
,
int
*
position
,
MPI_Comm
comm
);
static
int
streamTxCode
(
void
*
streamptr
);
static
int
streamTxCode
(
void
);
#endif
resOps
streamOps
=
{
streamCompareP
,
streamDestroyP
,
streamPrintP
,
...
...
@@ -576,7 +576,7 @@ void streamPrintP ( void * streamptr, FILE * fp )
#ifdef USE_MPI
static
int
streamTxCode
(
void
*
streamptr
)
streamTxCode
(
void
)
{
return
STREAM
;
}
...
...
src/taxis.c
View file @
3afe099c
...
...
@@ -46,7 +46,7 @@ static void taxisPrintP ( void * taxisptr, FILE * fp );
static
int
taxisGetSizeP
(
void
*
taxisptr
,
MPI_Comm
comm
);
static
void
taxisPackP
(
void
*
taxisptr
,
void
*
buf
,
int
size
,
int
*
position
,
MPI_Comm
comm
);
static
int
taxisTxCode
(
void
*
taxisptr
);
static
int
taxisTxCode
(
void
);
#endif
resOps
taxisOps
=
{
taxisCompareP
,
taxisDestroyP
,
taxisPrintP
...
...
@@ -1331,7 +1331,7 @@ int taxisCompareP ( void * taxisptr1, void * taxisptr2 )
#ifdef USE_MPI
static
int
taxisTxCode
(
void
*
taxisptr
)
taxisTxCode
(
void
)
{
return
TAXIS
;
}
...
...
src/varscan.c
View file @
3afe099c
...
...
@@ -10,6 +10,8 @@
#include
"dmemory.h"
#include
"varscan.h"
#include
"vlist.h"
#include
"pio_util.h"
#undef UNDEFID
#define UNDEFID -1
...
...
@@ -695,16 +697,26 @@ int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, double *l
int
zlbounds
=
0
;
int
ltype_is_equal
=
FALSE
;
xdebug
();
if
(
ltype
==
zaxisInqLtype
(
zaxisID
)
)
ltype_is_equal
=
TRUE
;
xdebug
();
if
(
ltype_is_equal
&&
(
zaxistype
==
zaxisInqType
(
zaxisID
)
||
zaxistype
==
ZAXIS_GENERIC
)
)
{
xdebug
();
if
(
zaxisInqLbounds
(
zaxisID
,
NULL
)
>
0
)
zlbounds
=
1
;
xdebug
();
if
(
nlevels
==
zaxisInqSize
(
zaxisID
)
&&
zlbounds
==
lbounds
)
{
const
double
*
dlevels
;
char
zlongname
[
256
];
char
zunits
[
256
];
xdebug
();
dlevels
=
zaxisInqLevelsPtr
(
zaxisID
);
for
(
levelID
=
0
;
levelID
<
nlevels
;
levelID
++
)
...
...
@@ -713,21 +725,31 @@ int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, double *l
break
;
}
xdebug
();
if
(
levelID
==
nlevels
)
differ
=
0
;
if
(
!
differ
)
{
xdebug
();
zaxisInqLongname
(
zaxisID
,
zlongname
);
zaxisInqUnits
(
zaxisID
,
zunits
);
if
(
longname
&&
zlongname
[
0
]
)
{
xdebug
();
if
(
strcmp
(
longname
,
zlongname
)
!=
0
)
differ
=
1
;
}
if
(
units
&&
zunits
[
0
]
)
{
xdebug
();
if
(
strcmp
(
units
,
zunits
)
!=
0
)
differ
=
1
;
}
}
xdebug
();
}
}
...
...
src/vlist.c
View file @
3afe099c
...
...
@@ -53,7 +53,7 @@ vlistPrintKernel(vlist_t *vlistptr, FILE * fp );
static
int
vlistGetSizeP
(
void
*
vlistptr
,
MPI_Comm
comm
);
static
void
vlistPackP
(
void
*
vlistptr
,
void
*
buff
,
int
size
,
int
*
position
,
MPI_Comm
comm
);
static
int
vlistTxCode
(
void
*
vlistptr
);
static
int
vlistTxCode
(
void
);
#endif
resOps
vlist_ops
=
{
...
...
@@ -1567,7 +1567,7 @@ enum {
};
static
int
vlistTxCode
(
void
*
vlistptr
)
vlistTxCode
(
void
)
{
return
VLIST
;
}
...
...
src/zaxis.c
View file @
3afe099c
...
...
@@ -69,7 +69,7 @@ static void zaxisPrintP ( void * zaxisptr, FILE * fp );
static
int
zaxisGetSizeP
(
void
*
zaxisptr
,
MPI_Comm
comm
);
static
void
zaxisPackP
(
void
*
zaxisptr
,
void
*
buffer
,
int
size
,
int
*
pos
,
MPI_Comm
comm
);
static
int
zaxisTxCode
(
void
*
zaxisptr
);
static
int
zaxisTxCode
(
void
);
#endif
resOps
zaxisOps
=
{
zaxisCompareP
,
zaxisDestroyP
,
zaxisPrintP
...
...
@@ -1252,19 +1252,40 @@ int zaxisCompareP ( void * zaxisptr1, void * zaxisptr2 )
{
zaxis_t
*
z1
=
(
zaxis_t
*
)
zaxisptr1
;
zaxis_t
*
z2
=
(
zaxis_t
*
)
zaxisptr2
;
static
int
differ
=
-
1
;
static
int
equal
=
0
;
assert
(
z1
);
assert
(
z2
);
return
zaxisCompare
(
z1
->
self
,
z2
->
type
,
z2
->
size
,
z2
->
size
>
0
?
1
:
0
,
z2
->
vals
,
z2
->
longname
,
z2
->
units
,
z2
->
ltype
);
//zaxisptr->self = CDI_UNDEFID;
//zaxisptr->name[0] = 0;
//zaxisptr->longname[0] = 0;
//zaxisptr->units[0] = 0;
//zaxisptr->vals = NULL;
//zaxisptr->ubounds = NULL;
//zaxisptr->lbounds = NULL;
//zaxisptr->weights = NULL;
if
(
z1
->
type
!=
z2
->
type
)
return
differ
;
if
(
z1
->
ltype
!=
z2
->
ltype
)
return
differ
;
if
(
z1
->
direction
!=
z2
->
direction
)
return
differ
;
if
(
z1
->
prec
!=
z2
->
prec
)
return
differ
;
if
(
z1
->
size
!=
z2
->
size
)
return
differ
;
if
(
z1
->
vctsize
!=
z2
->
vctsize
)
return
differ
;
//zaxisptr->vct = NULL;
/*
return zaxisCompare ( z1->self,
z2->type, z2->size, z2->size > 0 ? 1 : 0,
z2->vals, z2->longname, z2->units, z2->ltype );
*/
return
equal
;
}
#ifdef USE_MPI
static
int
zaxisTxCode
(
void
*
zaxisptr
)
zaxisTxCode
(
void
)
{
return
ZAXIS
;
}
...
...
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