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
c7c1dc96
Commit
c7c1dc96
authored
Feb 03, 2012
by
Deike Kleberg
Browse files
Bugfix, dereferencing of pointer
parent
0962958d
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
config/default
View file @
c7c1dc96
...
...
@@ -11,6 +11,16 @@ fi
set
-x
#
case
"
${
HOSTNAME
}
"
in
tornado
*
)
./configure
--prefix
=
/scratch/work/mh0033/m300050/cdi-pio
\
--disable-shared
\
--enable-maintainer-mode
\
--with-netcdf
=
/sw/sles10-x64/netcdf-4.1.3-static-nag52
\
--with-hdf5
=
/sw/sles10-x64/hdf5-1.8.7-static
\
--with-zlib
=
/sw/sles10-x64/zlib-1.2.3
\
--with-szlib
=
/sw/sles10-x64/szip-2.1-static
\
CC
=
gcc
CFLAGS
=
"-g -pipe -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O2 -DNAGf90Fortran"
;;
# i386-apple-darwin10
bailung
*
)
./configure
--prefix
=
$HOME
/local
\
...
...
pioExamples/collectData.c
View file @
c7c1dc96
...
...
@@ -5,7 +5,7 @@
#ifdef USE_MPI
#include
<mpi.h>
#include
"pio_c_temp.h"
#endif
#endif
#include
"cdi.h"
#include
"pio_util.h"
...
...
@@ -21,7 +21,7 @@ void modelRun ()
nlon
=
12
,
nlat
=
6
,
maxlev
=
5
};
static
int
nlev
[
nVars
]
=
{
1
,
1
,
5
,
5
,
2
};
static
char
*
name
=
"example"
;
...
...
@@ -43,18 +43,18 @@ void modelRun ()
gridDefYvals
(
gridID
,
lats
);
for
(
i
=
0
;
i
<
nVars
;
i
++
)
{
{
zaxisID
[
i
]
=
zaxisCreate
(
ZAXIS_PRESSURE
,
nlev
[
i
]
);
zaxisDefLevels
(
zaxisID
[
i
],
levs
);
}
vlistID
=
vlistCreate
();
for
(
i
=
0
;
i
<
nVars
;
i
++
)
vlistID
=
vlistCreate
();
for
(
i
=
0
;
i
<
nVars
;
i
++
)
varID
[
i
]
=
vlistDefVar
(
vlistID
,
gridID
,
zaxisID
[
i
],
TIME_VARIABLE
);
taxisID
=
taxisCreate
(
TAXIS_ABSOLUTE
);
vlistDefTaxis
(
vlistID
,
taxisID
);
sprintf
(
&
filename
[
0
],
"%s_%d.grb"
,
name
,
tfID
);
streamID
=
streamOpenWrite
(
filename
,
filetype
);
xassert
(
streamID
>=
0
);
...
...
@@ -82,7 +82,7 @@ void modelRun ()
start
=
pioInqVarDecoOff
(
vlistID
,
varID
[
i
]
);
chunk
=
pioInqVarDecoChunk
(
vlistID
,
varID
[
i
]
);
stop
=
start
+
chunk
;
for
(
j
=
start
;
j
<
stop
;
j
++
)
var
[
j
]
=
2
.
2
;
for
(
j
=
start
;
j
<
stop
;
j
++
)
var
[
j
]
=
2
.
2
;
streamWriteVar
(
streamID
,
varID
[
i
],
&
var
[
start
],
nmiss
);
start
=
CDI_UNDEFID
;
chunk
=
CDI_UNDEFID
;
...
...
@@ -90,38 +90,38 @@ void modelRun ()
pioWriteTimestep
(
tsID
,
vdate
,
vtime
);
}
}
streamClose
(
streamID
);
vlistDestroy
(
vlistID
);
taxisDestroy
(
taxisID
);
for
(
i
=
0
;
i
<
nVars
;
i
++
)
zaxisDestroy
(
zaxisID
[
i
]
);
gridDestroy
(
gridID
);
gridDestroy
(
gridID
);
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
enum
{
nProcsIO
=
3
,
//
IOMode = PIO_NONE,
//IOMode = PIO_MPI,
IOMode
=
PIO_FPGUARD
,
enum
{
nProcsIO
=
1
,
IOMode
=
PIO_NONE
,
//IOMode = PIO_MPI,
//
IOMode = PIO_FPGUARD,
//IOMode = PIO_ASYNCH,
//IOMode = PIO_WRITER,
nNamespaces
=
1
};
static
int
hasLocalFile
[
nNamespaces
]
=
{
0
};
#ifdef USE_MPI
MPI_Comm
commGlob
,
commModel
;
MPI_Comm
commGlob
,
commModel
;
int
sizeGlob
;
int
rankGlob
;
xmpi
(
MPI_Init
(
&
argc
,
&
argv
));
xmpi
(
MPI_Init
(
&
argc
,
&
argv
));
xmpi
(
MPI_Comm_dup
(
MPI_COMM_WORLD
,
&
commGlob
));
xmpi
(
MPI_Comm_set_errhandler
(
commGlob
,
MPI_ERRORS_RETURN
));
xmpi
(
MPI_Comm_size
(
commGlob
,
&
sizeGlob
));
xmpi
(
MPI_Comm_size
(
commGlob
,
&
sizeGlob
));
xmpi
(
MPI_Comm_rank
(
commGlob
,
&
rankGlob
));
commModel
=
pioInit_c
(
commGlob
,
nProcsIO
,
IOMode
,
nNamespaces
,
hasLocalFile
);
...
...
@@ -131,7 +131,7 @@ int main (int argc, char *argv[])
#ifdef USE_MPI
pioFinalize
();
MPI_Finalize
();
MPI_Finalize
();
#endif
return
0
;
}
src/pio_dbuffer.c
View file @
c7c1dc96
...
...
@@ -15,7 +15,7 @@
#include
"pio_impl.h"
#include
"pio_util.h"
bool
l
d
ebug
=
false
;
bool
l
ocalD
ebug
=
false
;
int
dbuffer_init
(
struct
dBuffer
**
dbuffer
,
size_t
size
)
...
...
@@ -28,7 +28,7 @@ int dbuffer_init ( struct dBuffer **dbuffer, size_t size )
#ifndef _SX
pagesize
=
(
size_t
)
sysconf
(
_SC_PAGESIZE
);
if
(
l
d
ebug
)
if
(
l
ocalD
ebug
)
fprintf
(
stdout
,
"dbuffer_init(): pagesize = %zu bytes, size = %zu
\n
"
,
pagesize
,
size
);
if
(
dbuffer
==
NULL
||
size
<
pagesize
)
...
...
@@ -49,7 +49,7 @@ int dbuffer_init ( struct dBuffer **dbuffer, size_t size )
while
(
db
->
size
<
size
)
{
db
->
size
<<=
1
;
if
(
l
d
ebug
)
if
(
l
ocalD
ebug
)
fprintf
(
stdout
,
"size correction: %zu
\n
"
,
db
->
size
);
}
...
...
src/pio_interface.c
View file @
c7c1dc96
This diff is collapsed.
Click to expand it.
src/pio_rpc.c
View file @
c7c1dc96
...
...
@@ -70,6 +70,8 @@ void rpcUnpackResources ( char * unpackBuffer, int unpackBufferSize,
int
token1
,
token2
,
nspTarget
;
int
unpackBufferPos
=
0
;
char
text
[
4096
];
xdebug
();
while
(
unpackBufferPos
<
unpackBufferSize
)
{
...
...
@@ -120,6 +122,7 @@ void rpcUnpackResources ( char * unpackBuffer, int unpackBufferSize,
&
token2
,
1
,
MPI_INT
,
comm
));
xassert
(
token2
==
SEPARATOR
);
}
xdebug
();
}
#endif
...
...
src/pio_rpc.h
View file @
c7c1dc96
...
...
@@ -37,7 +37,7 @@ enum
winBufferOverhead
=
1
,
winBufferOverheadChunk
=
5
,
winBufferOverheadFuncCall
=
3
,
MAXWINBUFFERSIZE
=
128
*
1024
,
MAXWINBUFFERSIZE
=
128
*
1024
*
1024
,
timestepSize
=
3
};
...
...
src/pio_server.c
View file @
c7c1dc96
...
...
@@ -465,6 +465,7 @@ void IOServer ()
tag
,
commCalc
,
&
status
));
xdebug
(
"RECEIVED MESSAGE WITH TAG
\"
RESOURCES
\"
"
);
rpcUnpackResources
(
buffer
,
size
,
commCalc
);
xdebug
();
free
(
buffer
);
if
(
ddebug
>
0
&&
commInqRankGlob
()
==
nProcsModel
)
reshArrayPrint
(
"reshArrayIOServer"
);
...
...
src/pio_util.c
View file @
c7c1dc96
...
...
@@ -23,12 +23,12 @@ void pcdiAssert ( bool assumption, const char * filename,
int
rank
;
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
fprintf
(
stderr
,
"ERROR, ASSUMPTION
FALSE
: PE%d in %s, %s, line %d
\n
"
,
fprintf
(
stderr
,
"ERROR,
FALSE
ASSUMPTION: PE%d in %s, %s, line %d
\n
"
,
rank
,
functionname
,
filename
,
line
);
fflush
(
stderr
);
MPI_Abort
(
MPI_COMM_WORLD
,
1
);
#else
fprintf
(
stderr
,
"ERROR ASSUMPTION
FALSE
, %s, %s, line %d
\n
"
,
fprintf
(
stderr
,
"ERROR
, FALSE
ASSUMPTION, %s, %s, line %d
\n
"
,
functionname
,
filename
,
line
);
fflush
(
stderr
);
abort
();
...
...
src/pio_util.h
View file @
c7c1dc96
...
...
@@ -36,11 +36,10 @@
#define MINFILETYPE 1
#define MAXFILETYPE 9
#define ddebug
0
#define ddebug
1
static
char
*
debugString
=
"#####"
;
void
pcdiAssert
(
bool
,
const
char
*
,
const
char
*
,
int
);
#define xassert(arg) pcdiAssert ( arg, __FILE__, __func__, __LINE__ );
...
...
@@ -57,8 +56,8 @@ void pcdiAssert ( bool, const char *, const char *, int );
#else
#define xdebug(fmt, ...) \
if ( ddebug ){ \
fprintf ( stderr, "%s, %s, line %d: " fmt "\n", \
__func__, __FILE__, __LINE__,
\
fprintf ( stderr, "%s
%s
, %s, line %d: " fmt "\n", \
debugString,
__func__, __FILE__, __LINE__, \
## __VA_ARGS__ ); \
}
#endif
...
...
src/stream.c
View file @
c7c1dc96
...
...
@@ -41,10 +41,10 @@ int pclose(FILE *stream);
void
cdiPrintDefaults
(
void
)
{
fprintf
(
stderr
,
"default instID : %d
\n
"
,
cdiDefaultInstID
);
fprintf
(
stderr
,
"default modelID : %d
\n
"
,
cdiDefaultModelID
);
fprintf
(
stderr
,
"default tableID : %d
\n
"
,
cdiDefaultTableID
);
fprintf
(
stderr
,
"default missval : %g
\n
"
,
cdiDefaultMissval
);
fprintf
(
stderr
,
"default instID : %d
\n
"
,
cdiDefaultInstID
);
fprintf
(
stderr
,
"default modelID : %d
\n
"
,
cdiDefaultModelID
);
fprintf
(
stderr
,
"default tableID : %d
\n
"
,
cdiDefaultTableID
);
fprintf
(
stderr
,
"default missval : %g
\n
"
,
cdiDefaultMissval
);
}
...
...
@@ -244,7 +244,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
{
pch
=
&
argument
[
i
+
1
];
len
-=
(
i
+
1
);
if
(
len
&&
(
memcmp
(
argument
,
"filelist:"
,
i
)
==
0
||
if
(
len
&&
(
memcmp
(
argument
,
"filelist:"
,
i
)
==
0
||
memcmp
(
argument
,
"flist:"
,
i
)
==
0
)
)
{
for
(
i
=
0
;
i
<
len
;
++
i
)
if
(
pch
[
i
]
==
','
)
nfiles
++
;
...
...
@@ -265,7 +265,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
{
if
(
line
[
0
]
==
'#'
||
line
[
0
]
==
'\0'
||
line
[
0
]
==
' '
)
continue
;
if
(
nfiles
>=
max_fnames
)
{
Warning
(
"Too many input files (limit: %d)"
,
max_fnames
);
...
...
@@ -274,7 +274,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
fnames
[
nfiles
]
=
strdupx
(
line
);
nfiles
++
;
}
fclose
(
fp
);
if
(
nfiles
==
0
)
Error
(
"No input file found in %s"
,
pch
);
...
...
@@ -282,10 +282,10 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
else
{
char
xline
[
65536
];
strcpy
(
xline
,
pch
);
for
(
i
=
0
;
i
<
len
;
i
++
)
if
(
xline
[
i
]
==
','
)
xline
[
i
]
=
0
;
nfiles
++
;
if
(
nfiles
>=
max_fnames
)
{
...
...
@@ -305,14 +305,14 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
{
char
command
[
4096
];
FILE
*
pfp
;
strcpy
(
command
,
"ls "
);
strcat
(
command
,
pch
);
pfp
=
popen
(
command
,
"r"
);
if
(
pfp
==
NULL
)
SysError
(
"popen %s failed"
,
command
);
nfiles
=
0
;
while
(
_readline_
(
pfp
,
line
,
MAX_LINE
)
)
{
...
...
@@ -333,7 +333,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
}
num_fnames
=
nfiles
;
return
(
num_fnames
);
}
...
...
@@ -618,8 +618,8 @@ int streamOpen(const char *filename, const char *filemode, int filetype)
if
(
!
filename
||
!
filemode
||
filetype
<
0
)
return
(
CDI_EINVAL
);
xdebug
(
"filename = %s, filemode = %s, filetype = %d, "
"namespaceHasLocalFile(%d)=%s"
,
filename
,
filemode
,
filetype
,
namespaceGetActive
(),
"namespaceHasLocalFile(%d)=%s"
,
filename
,
filemode
,
filetype
,
namespaceGetActive
(),
namespaceHasLocalFile
(
namespaceGetActive
())
?
"true"
:
"false"
);
if
(
hasLocalFile
)
...
...
@@ -710,7 +710,7 @@ int streamOpen(const char *filename, const char *filemode, int filetype)
}
}
#endif
if
(
fileID
<
0
&&
hasLocalFile
)
{
...
...
@@ -744,7 +744,7 @@ int streamOpen(const char *filename, const char *filemode, int filetype)
vlistptr
->
ntsteps
=
streamNtsteps
(
streamID
);
}
}
return
(
streamID
);
}
...
...
@@ -853,7 +853,7 @@ int streamOpenA(const char *filename, const char *filemode, int filetype)
vlistptr
=
vlist_to_pointer
(
streamptr
->
vlistID
);
vlistptr
->
ntsteps
=
cdiInqTimeSize
(
streamID
);
}
switch
(
filetype
)
{
#if defined (HAVE_LIBGRIB)
...
...
@@ -1022,7 +1022,7 @@ int streamOpenRead(const char *filenames)
filename
=
filenames
;
else
{
int
i
;
int
i
;
for
(
i
=
0
;
i
<
num_fnames
;
++
i
)
printf
(
"fnames: %d %s
\n
"
,
i
,
fnames
[
i
]);
filename
=
fnames
[
0
];
}
...
...
@@ -1100,7 +1100,7 @@ open stream. Otherwise, a negative number with the error status is returned.
@EndList
@Example
Here is an example using @func{streamOpenWrite} to create a new netCDF file
Here is an example using @func{streamOpenWrite} to create a new netCDF file
named @func{foo.nc} for writing:
@Source
...
...
@@ -1148,10 +1148,10 @@ void streamClose(int streamID)
fileID
=
streamptr
->
fileID
;
filetype
=
streamptr
->
filetype
;
vlistID
=
streamptr
->
vlistID
;
vlistID
=
streamptr
->
vlistID
;
if
(
namespaceHasLocalFile
(
namespaceGetActive
()))
{
{
if
(
fileID
==
CDI_UNDEFID
)
Warning
(
"File %s not open!"
,
streamptr
->
filename
);
else
...
...
@@ -1225,14 +1225,14 @@ void streamClose(int streamID)
}
}
#endif
if
(
streamptr
->
record
)
{
if
(
streamptr
->
record
->
buffer
)
free
(
streamptr
->
record
->
buffer
);
free
(
streamptr
->
record
);
}
}
streamptr
->
filetype
=
0
;
if
(
streamptr
->
filename
)
free
(
streamptr
->
filename
);
...
...
@@ -1253,7 +1253,7 @@ void streamClose(int streamID)
if
(
streamptr
->
tsteps
[
index
].
recIDs
)
free
(
streamptr
->
tsteps
[
index
].
recIDs
);
}
if
(
streamptr
->
tsteps
)
free
(
streamptr
->
tsteps
);
if
(
streamptr
->
nfiles
>
0
)
...
...
@@ -1611,7 +1611,7 @@ void streamReadVar(int streamID, int varID, double *data, int *nmiss)
@Item nmiss Number of missing values.
@Description
The function streamWriteVar writes the values of one time step of a variable
The function streamWriteVar writes the values of one time step of a variable
to an open dataset.
@EndFunction
*/
...
...
@@ -1804,7 +1804,7 @@ void streamReadVarSlice(int streamID, int varID, int levelID, double *data, int
@Item nmiss Number of missing values.
@Description
The function streamWriteVarSlice writes the values of a horizontal slice of a
The function streamWriteVarSlice writes the values of a horizontal slice of a
variable to an open dataset.
@EndFunction
*/
...
...
@@ -1941,7 +1941,7 @@ void streamWriteContents(int streamID, char *cname)
fprintf
(
cnp
,
"#
\n
"
);
fprintf
(
cnp
,
"tsID:nrecs:date:time
\n
"
);
tsID
=
0
;
while
(
1
)
{
...
...
@@ -2153,7 +2153,7 @@ int streamInqVlist(int streamID)
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
stream_check_ptr
(
__func__
,
streamptr
);
return
(
streamptr
->
vlistID
);
...
...
@@ -2165,7 +2165,7 @@ int streamInqVlistIDorig(int streamID)
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
stream_check_ptr
(
__func__
,
streamptr
);
return
(
streamptr
->
vlistIDorig
);
...
...
src/vlist_var.c
View file @
c7c1dc96
...
...
@@ -761,15 +761,10 @@ int vlistInqVarSize(int vlistID, int varID)
vlist_t
*
vlistptr
;
vlistptr
=
vlist_to_pointer
(
vlistID
);
vlistCheckVarID
(
__func__
,
vlistID
,
varID
);
vlistInqVar
(
vlistID
,
varID
,
&
gridID
,
&
zaxisID
,
&
timeID
);
nlevs
=
zaxisInqSize
(
zaxisID
);
gridsize
=
gridInqSize
(
gridID
);
size
=
gridsize
*
nlevs
;
return
(
size
);
...
...
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