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
ebd63c51
Commit
ebd63c51
authored
Jun 13, 2013
by
Thomas Jahns
🤸
Browse files
Move PIO functionality from cdf_int.c to separate source.
parent
4573f9ce
Changes
10
Hide whitespace changes
Inline
Side-by-side
.gitattributes
View file @
ebd63c51
...
...
@@ -228,6 +228,8 @@ src/namespace.c -text
src/namespace.h -text
src/pio.c -text
src/pio.h -text
src/pio_cdf_int.c -text
src/pio_cdf_int.h -text
src/pio_comm.c -text
src/pio_comm.h -text
src/pio_dbuffer.c -text
...
...
src/Makefile.am
View file @
ebd63c51
...
...
@@ -80,6 +80,8 @@ libcdi_la_SOURCES = \
pio_util.h
\
pio_serialize.h
\
pio_serialize.c
\
pio_cdf_int.c
\
pio_cdf_int.h
\
resource_handle.c
\
resource_handle.h
\
service.h
\
...
...
src/Makefile.in
View file @
ebd63c51
...
...
@@ -118,7 +118,7 @@ am_libcdi_la_OBJECTS = basetime.lo binary.lo calendar.lo cdf.lo \
pio_record_send.lo pio_posixasynch.lo
\
pio_posixfpguardsendrecv.lo pio_posixnonb.lo pio_list_set.lo
\
resource_unpack.lo pio_server.lo pio_util.lo pio_serialize.lo
\
resource_handle.lo servicelib.lo stream_cdf.lo
\
pio_cdf_int.lo
resource_handle.lo servicelib.lo stream_cdf.lo
\
stream_cgribex.lo stream_ext.lo stream_grb.lo
\
stream_gribapi.lo stream_history.lo stream_ieg.lo cdi_int.lo
\
stream_record.lo stream_srv.lo stream_var.lo table.lo taxis.lo
\
...
...
@@ -413,6 +413,8 @@ libcdi_la_SOURCES = \
pio_util.h
\
pio_serialize.h
\
pio_serialize.c
\
pio_cdf_int.c
\
pio_cdf_int.h
\
resource_handle.c
\
resource_handle.h
\
service.h
\
...
...
@@ -588,6 +590,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/model.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/namespace.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/pio.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/pio_cdf_int.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/pio_comm.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/pio_dbuffer.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/pio_interface.Plo@am__quote@
...
...
src/cdf_int.c
View file @
ebd63c51
...
...
@@ -10,16 +10,7 @@
#include
"cdi.h"
#include
"cdi_int.h"
#include
"cdf_int.h"
#ifdef USE_MPI
#include
"namespace.h"
#include
"pio.h"
#include
"pio_comm.h"
#include
"pio_util.h"
#ifdef HAVE_NETCDF_PAR_H
#include
<netcdf_par.h>
#endif
#endif
extern
int
CDF_Fatal
;
extern
int
CDF_Verbose
;
...
...
@@ -67,32 +58,9 @@ void cdf_create(const char *path, int cmode, int *ncidp)
if
(
cdiNcChunksizehint
!=
CDI_UNDEFID
)
chunksizehint
=
cdiNcChunksizehint
;
#if USE_MPI
#if defined (HAVE_NETCDF4) && defined (HAVE_PARALLEL_NC4)
if
(
cmode
&
NC_NETCDF4
&&
namespaceHasLocalFile
(
namespaceGetActive
())
&&
commInqIOMode
()
!=
PIO_NONE
)
{
cmode
|=
NC_MPIPOSIX
;
status
=
nc_create_par
(
path
,
cmode
,
commInqCommColl
(),
MPI_INFO_NULL
,
ncidp
);
}
else
if
(
cmode
&
(
NC_64BIT_OFFSET
|
NC_CLASSIC_MODEL
)
&&
namespaceHasLocalFile
(
namespaceGetActive
())
&&
commInqIOMode
()
!=
PIO_NONE
)
{
/* FIXME: improve handling of pnetcdf here */
abort
();
}
else
status
=
nc__create
(
path
,
cmode
,
initialsz
,
&
chunksizehint
,
ncidp
);
#else
/* FIXME: Only open netcdf file on one task */
status
=
nc__create
(
path
,
cmode
,
initialsz
,
&
chunksizehint
,
ncidp
);
#endif
#else
status
=
nc__create
(
path
,
cmode
,
initialsz
,
&
chunksizehint
,
ncidp
);
#endif
cdi_nc__create_funcp
my_nc__create
=
namespaceSwitchGet
(
NSSWITCH_NC__CREATE
);
status
=
my_nc__create
(
path
,
cmode
,
initialsz
,
&
chunksizehint
,
ncidp
);
if
(
CDF_Debug
||
status
!=
NC_NOERR
)
Message
(
"ncid = %d mode = %d file = %s"
,
*
ncidp
,
cmode
,
path
);
...
...
@@ -270,11 +238,18 @@ void cdf_inq_dimlen(int ncid, int dimid, size_t * lengthp)
void
cdf_def_var
(
int
ncid
,
const
char
*
name
,
nc_type
xtype
,
int
ndims
,
const
int
dimids
[],
int
*
varidp
)
const
int
dimids
[],
int
*
varidp
)
{
int
status
;
cdi_cdf_def_var_funcp
my_cdf_def_var
=
namespaceSwitchGet
(
NSSWITCH_CDF_DEF_VAR
);
my_cdf_def_var
(
ncid
,
name
,
xtype
,
ndims
,
dimids
,
varidp
);
}
status
=
nc_def_var
(
ncid
,
name
,
xtype
,
ndims
,
dimids
,
varidp
);
void
cdf_def_var_serial
(
int
ncid
,
const
char
*
name
,
nc_type
xtype
,
int
ndims
,
const
int
dimids
[],
int
*
varidp
)
{
int
status
=
nc_def_var
(
ncid
,
name
,
xtype
,
ndims
,
dimids
,
varidp
);
if
(
CDF_Debug
||
status
!=
NC_NOERR
)
Message
(
"ncid = %d name = %s xtype = %d ndims = %d varid = %d"
,
...
...
@@ -282,23 +257,10 @@ void cdf_def_var(int ncid, const char *name, nc_type xtype, int ndims,
if
(
status
!=
NC_NOERR
)
Error
(
"%s"
,
nc_strerror
(
status
));
#if USE_MPI
#if defined (HAVE_NETCDF4) && defined (HAVE_PARALLEL_NC4)
if
(
namespaceHasLocalFile
(
namespaceGetActive
())
&&
commInqIOMode
()
!=
PIO_NONE
)
{
xdebug
(
"%s"
,
"calling nc_var_par_access"
);
status
=
nc_var_par_access
(
ncid
,
*
varidp
,
NC_COLLECTIVE
);
if
(
status
!=
NC_NOERR
)
Error
(
"%s"
,
nc_strerror
(
status
));
}
#endif
#endif
}
void
cdf_inq_varid
(
int
ncid
,
const
char
*
name
,
int
*
varidp
)
{
int
status
;
...
...
src/cdf_int.h
View file @
ebd63c51
...
...
@@ -3,10 +3,7 @@
#if defined (HAVE_LIBNETCDF)
#ifdef USE_MPI
#include
<mpi.h>
#endif
#include
<stdlib.h>
#include
"netcdf.h"
void
cdf_create
(
const
char
*
path
,
int
cmode
,
int
*
idp
);
...
...
@@ -26,6 +23,8 @@ void cdf_inq_dimname (int ncid, int dimid, char *name);
void
cdf_inq_dimlen
(
int
ncid
,
int
dimid
,
size_t
*
lengthp
);
void
cdf_def_var
(
int
ncid
,
const
char
*
name
,
nc_type
xtype
,
int
ndims
,
const
int
dimids
[],
int
*
varidp
);
void
cdf_def_var_serial
(
int
ncid
,
const
char
*
name
,
nc_type
xtype
,
int
ndims
,
const
int
dimids
[],
int
*
varidp
);
void
cdf_inq_varid
(
int
ncid
,
const
char
*
name
,
int
*
varidp
);
void
cdf_inq_nvars
(
int
ncid
,
int
*
nvarsp
);
void
cdf_inq_var
(
int
ncid
,
int
varid
,
char
*
name
,
nc_type
*
xtypep
,
...
...
@@ -91,6 +90,14 @@ void cdf_inq_attlen (int ncid, int varid, const char *name, size_t *lenp);
void
cdf_inq_attname
(
int
ncid
,
int
varid
,
int
attnum
,
char
*
name
);
void
cdf_inq_attid
(
int
ncid
,
int
varid
,
const
char
*
name
,
int
*
attnump
);
typedef
int
(
*
cdi_nc__create_funcp
)(
const
char
*
path
,
int
cmode
,
size_t
initialsz
,
size_t
*
chunksizehintp
,
int
*
ncidp
);
typedef
void
(
*
cdi_cdf_def_var_funcp
)(
int
ncid
,
const
char
*
name
,
nc_type
xtype
,
int
ndims
,
const
int
dimids
[],
int
*
varidp
);
#endif
#endif
/* _CDF_INT_H */
...
...
src/namespace.c
View file @
ebd63c51
...
...
@@ -7,15 +7,23 @@
#include
"pio_util.h"
#include
"serialize.h"
#include
"error.h"
#include
"cdf_int.h"
static
int
nNamespaces
=
1
;
static
int
activeNamespace
=
0
;
#ifdef HAVE_LIBNETCDF
#define CDI_NETCDF_SWITCHES nc__create,cdf_def_var_serial,
#else
#define CDI_NETCDF_SWITCHES
#endif
#define defaultSwitches { \
cdiAbortC_serial, \
serializeGetSizeInCore, \
serializePackInCore, \
serializeUnpackInCore, \
CDI_NETCDF_SWITCHES \
}
struct
namespace
...
...
src/namespace.h
View file @
ebd63c51
#ifndef NAMESPACE_H
#define NAMESPACE_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
typedef
enum
{
STAGE_DEFINITION
=
0
,
STAGE_TIMELOOP
=
1
,
...
...
@@ -20,6 +25,10 @@ enum namespaceSwitch
NSSWITCH_SERIALIZE_GET_SIZE
,
NSSWITCH_SERIALIZE_PACK
,
NSSWITCH_SERIALIZE_UNPACK
,
#ifdef HAVE_LIBNETCDF
NSSWITCH_NC__CREATE
,
NSSWITCH_CDF_DEF_VAR
,
#endif
NUM_NAMESPACE_SWITCH
,
};
...
...
src/pio_cdf_int.c
0 → 100644
View file @
ebd63c51
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if defined USE_MPI && defined (HAVE_NETCDF4) && defined (HAVE_PARALLEL_NC4)
#include
<netcdf.h>
#ifdef HAVE_NETCDF_PAR_H
#include
<netcdf_par.h>
#endif
#include
"namespace.h"
#include
"pio.h"
#include
"pio_comm.h"
#include
"pio_cdf_int.h"
#include
"pio_util.h"
#include
"pio_cdf_int.h"
int
cdiPio_nc__create
(
const
char
*
path
,
int
cmode
,
size_t
initialsz
,
size_t
*
chunksizehintp
,
int
*
ncidp
)
{
int
status
;
if
(
cmode
&
NC_NETCDF4
&&
namespaceHasLocalFile
(
namespaceGetActive
())
&&
commInqIOMode
()
!=
PIO_NONE
)
{
cmode
|=
NC_MPIPOSIX
;
status
=
nc_create_par
(
path
,
cmode
,
commInqCommColl
(),
MPI_INFO_NULL
,
ncidp
);
}
else
if
(
cmode
&
(
NC_64BIT_OFFSET
|
NC_CLASSIC_MODEL
)
&&
namespaceHasLocalFile
(
namespaceGetActive
())
&&
commInqIOMode
()
!=
PIO_NONE
)
{
/* FIXME: improve handling of pnetcdf here */
abort
();
}
else
status
=
nc__create
(
path
,
cmode
,
initialsz
,
chunksizehintp
,
ncidp
);
return
status
;
}
#if 0
/* original code: */
#if USE_MPI
#if defined (HAVE_NETCDF4) && defined (HAVE_PARALLEL_NC4)
if (cmode & NC_NETCDF4
&& namespaceHasLocalFile(namespaceGetActive())
&& commInqIOMode() != PIO_NONE)
{
cmode |= NC_MPIPOSIX;
status = nc_create_par(path, cmode, commInqCommColl(),
MPI_INFO_NULL, ncidp);
}
else if (cmode & (NC_64BIT_OFFSET | NC_CLASSIC_MODEL)
&& namespaceHasLocalFile(namespaceGetActive())
&& commInqIOMode() != PIO_NONE)
{
/* FIXME: improve handling of pnetcdf here */
abort();
}
else
status = nc__create(path, cmode, initialsz, &chunksizehint, ncidp);
#else
/* FIXME: Only open netcdf file on one task */
status = nc__create(path, cmode, initialsz, &chunksizehint, ncidp);
#endif
#else
status
=
nc__create
(
path
,
cmode
,
initialsz
,
&
chunksizehint
,
ncidp
);
#endif
#endif
void
cdiPioCdfDefVar
(
int
ncid
,
const
char
*
name
,
nc_type
xtype
,
int
ndims
,
const
int
dimids
[],
int
*
varidp
)
{
cdf_def_var_serial
(
ncid
,
name
,
xtype
,
ndims
,
dimids
,
varidp
);
if
(
commInqIOMode
()
!=
PIO_NONE
)
{
xdebug
(
"%s"
,
"calling nc_var_par_access"
);
int
status
=
nc_var_par_access
(
ncid
,
*
varidp
,
NC_COLLECTIVE
);
if
(
status
!=
NC_NOERR
)
Error
(
"%s"
,
nc_strerror
(
status
));
}
}
void
cdiPioEnableNetCDFParAccess
()
{
namespaceSwitchSet
(
NSSWITCH_NC__CREATE
,
cdiPio_nc__create
);
namespaceSwitchSet
(
NSSWITCH_CDF_DEF_VAR
,
cdiPioCdfDefVar
);
}
#endif
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
src/pio_cdf_int.h
0 → 100644
View file @
ebd63c51
#ifndef PIO_CDF_INT_H
#define PIO_CDF_INT_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_LIBNETCDF
#include
"cdf_int.h"
int
cdiPio_nc__create
(
const
char
*
path
,
int
cmode
,
size_t
initialsz
,
size_t
*
chunksizehintp
,
int
*
ncidp
);
void
cdiPioCdfDefVar
(
int
ncid
,
const
char
*
name
,
nc_type
xtype
,
int
ndims
,
const
int
dimids
[],
int
*
varidp
);
void
cdiPioEnableNetCDFParAccess
();
#endif
#endif
src/pio_server.c
View file @
ebd63c51
...
...
@@ -28,6 +28,7 @@
#include
"pio_rpc.h"
#include
"pio_util.h"
#include
"cdi_int.h"
#include
"pio_cdf_int.h"
#include
"resource_handle.h"
#include
"resource_unpack.h"
#include
"vlist_var.h"
...
...
@@ -866,6 +867,7 @@ void IOServer ()
backendFinalize
();
commCalc
=
commInqCommCalc
();
#ifdef HAVE_PARALLEL_NC4
cdiPioEnableNetCDFParAccess
();
numPioPrimes
=
PPM_prime_factorization_32
((
uint32_t
)
commInqSizeColl
(),
&
pioPrimes
);
#elif defined (HAVE_LIBNETCDF)
...
...
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