diff --git a/Legacy/check_install.in b/Legacy/check_install.in deleted file mode 100644 index 70b76e6b3..000000000 --- a/Legacy/check_install.in +++ /dev/null @@ -1,91 +0,0 @@ -#! /bin/sh -# -# Copyright (C) 2016, Northwestern University and Argonne National Laboratory -# See COPYRIGHT notice in top-level directory. -# -# $Id$ -# -# @configure_input@ - -prefix="@prefix@" - -if test $# -eq 1 ; then - prefix=$1 -elif test $# -eq 0 ; then - if test "x$prefix" = "x" ; then - echo "This utility checks the PnetCDF install files" >& 2 - echo "Usage: $0 install_path" >&2 - exit 1 - fi -fi - -installdir=$prefix -nerrs=0 - -headerfiles="pnetcdf pnetcdf.h pnetcdf.inc pnetcdf.mod" -for f in $headerfiles -do - installfile=$installdir/include/$f - if ! test -e $installfile ; then - echo "Error: file NOT found: $installfile" >& 2 - nerrs=`expr $nerrs + 1` - fi -done - -libfiles="libpnetcdf.a" -for f in $libfiles -do - installfile=$installdir/lib/$f - if ! test -e $installfile ; then - echo "Error: file NOT found: $installfile" >& 2 - nerrs=`expr $nerrs + 1` - fi -done - -pkgfiles="pnetcdf.pc" -for f in $pkgfiles -do - installfile=$installdir/lib/pkgconfig/$f - if ! test -e $installfile ; then - echo "Error: file NOT found: $installfile" >& 2 - nerrs=`expr $nerrs + 1` - fi -done - -binfiles="ncmpidiff ncmpidump ncmpigen ncmpivalid ncoffsets pnetcdf-config pnetcdf_version" -for f in $binfiles -do - installfile=$installdir/bin/$f - if ! test -e $installfile ; then - echo "Error: file NOT found: $installfile" >& 2 - nerrs=`expr $nerrs + 1` - fi -done - -man1files="ncmpidiff.1 ncmpigen.1 ncoffsets.1 ncmpidump.1 ncmpivalid.1 pnetcdf_version.1" -for f in $man1files -do - installfile=$installdir/share/man/man1/$f - if ! test -e $installfile ; then - echo "Error: file NOT found: $installfile" >& 2 - nerrs=`expr $nerrs + 1` - fi -done - -man3files="pnetcdf.3 pnetcdf_f77.3 pnetcdf_f90.3" -for f in $man3files -do - installfile=$installdir/share/man/man3/$f - if ! test -e $installfile ; then - echo "Error: file NOT found: $installfile" >& 2 - nerrs=`expr $nerrs + 1` - fi -done - -if test $nerrs = 0 ; then - echo "PASS -- all PnetCDF files appear in $installdir" -else - echo "FAIL -- $nerrs error(s) found" >& 2 - exit 1 -fi - diff --git a/Legacy/macros.make.in b/Legacy/macros.make.in deleted file mode 100644 index e07f39175..000000000 --- a/Legacy/macros.make.in +++ /dev/null @@ -1,159 +0,0 @@ -# -# Copyright (C) 2003, Northwestern University and Argonne National Laboratory -# See COPYRIGHT notice in top-level directory. -# -# $Id$ -# -# @configure_input@ -# -# The purpose of this file is to contain common make(1) macros. -# It should be processed by every execution of that utility. -# - -@SET_MAKE@ - -# POSIX shell. Shouldn't be necessary -- but is under IRIX 5.3. -SHELL = /bin/sh -RM = @RM@ -LN_S = @LN_S@ - -# Installation Directories: -# SRCDIR = @SRCDIR@ -prefix = @prefix@ -BUILDDIR = @BUILDDIR@ -LIBRARY = @BUILDDIR@/src/lib/libpnetcdf.a - -ifdef DESTDIR -INCDIR = $(DESTDIR)/$(prefix)/include -LIBDIR = $(DESTDIR)/$(prefix)/lib -BINDIR = $(DESTDIR)/$(prefix)/bin -MANDIR = $(DESTDIR)/$(prefix)/share/man -else -INCDIR = $(prefix)/include -LIBDIR = $(prefix)/lib -BINDIR = $(prefix)/bin -MANDIR = $(prefix)/share/man -endif - -# Useful tools -M4 = @M4@ -M4FLAGS = @M4FLAGS@ -I@abs_top_srcdir@/scripts -DPNETCDF -M4FFLAGS = @M4FFLAGS@ -I@abs_top_srcdir@/scripts -DPNETCDF -EGREP = @EGREP@ - -# AC_PROG_SED and AC_PROG_GREP are only available on autoconf 2.60 and later -# SED = @SED@ -# GREP = @GREP@ -SED = sed -GREP = grep - -# Preprocessing: -DEFS = @DEFS@ -FC_DEFINE = @FC_DEFINE@ -CPP = @CPP@ -FPP = @FPP@ - -ifeq (@PNETCDF_DEBUG@, 1) -CPPFLAGS = $(INCLUDES) $(DEFS) @CPPFLAGS@ -DPNETCDF_DEBUG -CXXCPPFLAGS = $(INCLUDES) $(DEFS) @CXXCPPFLAGS@ -DPNETCDF_DEBUG -FPPFLAGS = $(INCLUDES) @FPPFLAGS@ @NAGf90FPPFLAGS@ @FC_DEFINE@PNETCDF_DEBUG -else -CPPFLAGS = $(INCLUDES) $(DEFS) @CPPFLAGS@ -CXXCPPFLAGS = $(INCLUDES) $(DEFS) @CXXCPPFLAGS@ -FPPFLAGS = $(INCLUDES) @FPPFLAGS@ @NAGf90FPPFLAGS@ -endif - -# Compilation: -MPICC = @MPICC@ -MPICXX = @MPICXX@ -MPIF77 = @MPIF77@ -MPIF90 = @MPIF90@ - -SEQ_CC = @SEQ_CC@ - -# debugging and optimization options for compiling and linking -CFLAGS = @CFLAGS@ -CXXFLAGS = @CXXFLAGS@ -F77FLAGS = @F77FLAGS@ @NAG_FCFLAGS@ -F90FLAGS = @F90FLAGS@ @NAG_FCFLAGS@ - -# compiler options for different file extensions: .f .F .f90 .F90 -F77FLAGS_f = @F77FLAGS_f@ -F77FLAGS_F = @F77FLAGS_F@ -F90FLAGS_f90 = @F90FLAGS_f90@ -F90FLAGS_F90 = @F90FLAGS_F90@ - -# preprocessor options for different file extensions: .f .F .f90 .F90 -F77PPFLAGS_f = @F77PPFLAGS_f@ -F77PPFLAGS_F = @F77PPFLAGS_F@ -F90PPFLAGS_f90 = @F90PPFLAGS_f90@ -F90PPFLAGS_F90 = @F90PPFLAGS_F90@ - -# NETCDF.MOD = @NETCDF_MOD@ -CC_MAKEDEPEND = @CC_MAKEDEPEND@ - -COMPILE.c = $(MPICC) $(CFLAGS) $(CPPFLAGS) -c -COMPILE.cxx = $(MPICXX) $(CXXFLAGS) $(CXXCPPFLAGS) -c -COMPILE.f = $(MPIF77) $(F77FLAGS_f) $(FPPFLAGS) $(F77FLAGS) -c -COMPILE.f90 = $(MPIF90) $(F90FLAGS_f90) $(FPPFLAGS) $(F90FLAGS) -c -COMPILE.F = $(MPIF77) $(F77FLAGS_F) $(FPPFLAGS) $(F77FLAGS) $(F77PPFLAGS_F) -c -COMPILE.F90 = $(MPIF90) $(F90FLAGS_F90) $(FPPFLAGS) $(F90FLAGS) $(F90PPFLAGS_F90) -c -# In PnetCDF, we follow the file extension convention that .F and .F90 files -# require preprocessing, while .f and .f90 do not. - - -# Linking: -FLIBS = @FLIBS@ -FCLIBS = @FCLIBS@ -F90LIBS = @F90LIBS@ -FLDFLAGS = @FLDFLAGS@ -F90LDFLAGS = @F90LDFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ - -LINK.c = $(MPICC) $(CFLAGS) -o $@ -LINK.cxx = $(MPICXX) $(CXXFLAGS) -o $@ -LINK.F77 = $(MPIF77) $(F77FLAGS) -o $@ -LINK.F90 = $(MPIF90) $(F90FLAGS) -o $@ - -TEST_MPIRUN = @TEST_MPIRUN@ -TEST_OUTDIR = @TEST_OUTDIR@ -TEST_SEQRUN = @TEST_SEQRUN@ - -# Manual pages: -WHATIS = @WHATIS@ -# The following macro should be empty on systems that don't -# allow users to create their own manual-page indexes. -MAKEWHATIS_CMD = @MAKEWHATIS_CMD@ - - -# Misc. Utilities: -AR = @AR@ -ARFLAGS = @ARFLAGS@ -AWK = @AWK@ -RANLIB = @RANLIB@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -TARFLAGS = -chf - - -# Dummy macros: used only as placeholders to silence GNU make. They are -# redefined, as necessary, in subdirectory makefiles. -HEADER = dummy_header -HEADER1 = dummy_header1 -HEADER2 = dummy_header2 -HEADER3 = dummy_header3 -MANUAL = dummy_manual -PROGRAM = dummy_program - - -# Distribution macros: -FTPDIR = /home/ftp/pub/$(PACKAGE) -FTPBINDIR = @FTPBINDIR@ - -PNETCDF_VERSION_MAJOR = @PNETCDF_VERSION_MAJOR@ -PNETCDF_VERSION_MINOR = @PNETCDF_VERSION_MINOR@ -PNETCDF_VERSION_SUB = @PNETCDF_VERSION_SUB@ -PNETCDF_VERSION_PRE = @PNETCDF_VERSION_PRE@ -PNETCDF_VERSION = @PNETCDF_VERSION@ - diff --git a/Legacy/rules.make b/Legacy/rules.make deleted file mode 100644 index 8ac06cdbe..000000000 --- a/Legacy/rules.make +++ /dev/null @@ -1,264 +0,0 @@ -# $Id$ - -# The purpose of this file is to contain common make(1) rules. -# It should be processed by every execution of the that utility. - -.SUFFIXES: -.SUFFIXES: .a .o .i .f .c .cpp .F .y .l .m4 .f90 .F90 - - -################################################################################ -# Compilation (including preprocessing): - -.c.o: - $(COMPILE.c) $< - -.c.i: - $(CPP) $(CPPFLAGS) $< >$@ - -.cpp.o: - $(COMPILE.cxx) $< - -.f.o: - $(COMPILE.f) $< - -.f90.o: - $(COMPILE.f90) $< - -.F90.o: - $(COMPILE.F90) $< - -.F.o: - $(COMPILE.F) $< - -# Not all FORTRAN compilers support C-preprocessing of *.F files; ergo, a -# relatively complicated rule ensues. -# .F.o: -# @case "$(COMPILE.F)" in \ -# '') \ -# set -x; \ -# $(FPP) $(FPPFLAGS) -C $*.F | grep -v '^#' >$*-tmp.f || \ -# ($(RM) -f $*-tmp.f ; exit 1); \ -# $(COMPILE.f) -o $@ $*-tmp.f || ($(RM) -f $*-tmp.f; exit 1); \ -# $(RM) -f $*-tmp.f; \ -# ;; \ -# *) \ -# $(COMPILE.F) $<; \ -# ;; \ -# esac - -#.F.f: -# $(FPP) $(FPPFLAGS) $*.F | grep -v '^#' >$*.f || ($(RM) -f $*.f; exit 1) - -.m4.h: - $(M4) $(M4FLAGS) $< >$@ - -.m4.c: - $(M4) $(M4FLAGS) $< >$@ - -.m4.F: - $(M4) $(M4FFLAGS) $< >$@ - -.m4.f90: - $(M4) $(M4FFLAGS) $< >$@ - -.m4.F90: - $(M4) $(M4FFLAGS) $< >$@ - - -################################################################################ -# Libraries: - -# lib: $(LIBRARY) - -#------------------------------------------------------------------------------- -# Shared Libraries: -# -# Here only as a place holder and notebook. Don't try to use this stuff -# unless you really, really know what you're doing! (And even then we -# guarantee nothing!) -# -shared_library: - @case `uname -sr` in \ - HP-UX*) \ - $(MAKE) $(MFLAGS) hpux_shared_library;; \ - IRIX*) \ - $(MAKE) $(MFLAGS) irix_shared_library;; \ - Linux*) \ - $(MAKE) $(MFLAGS) linux_shared_library;; \ - OSF1*) \ - $(MAKE) $(MFLAGS) osf1_shared_library;; \ - 'SunOS 4'*) \ - $(MAKE) $(MFLAGS) sunos4_shared_library;; \ - 'SunOS 5'*) \ - $(MAKE) $(MFLAGS) sunos5_shared_library;; \ - *) \ - echo 1>&2 "Don't know how to make a shared library" \ - "on this system"; \ - exit 1;; \ - esac - -hpux_shared_library: - nm libpnetcdf.a | grep extern | grep entry | \ - awk '-F|' '{print $$1}' | sed 's/^/-u /' >symbols.log - ld -o $(LIBRARY:.a=.sl) -b -c symbols.log $(LIBRARY) - $(RM) -f symbols.log -irix_shared_library: - ld -o $(LIBRARY:.a=.so) -shared -no_archive \ - -all $(LIBRARY) -none -lc -lC $(LIBS) -linux_shared_library: - ld -o $(LIBRARY:.a=.so) -shared --whole-archive $(LIBRARY) -osf1_shared_library: - ld -o $(LIBRARY:.a=.so) -shared -all $(LIBRARY) -sunos4_shared_library: - undefopts=`/bin/nm $(LIBRARY) | awk '$$2~/^T$$/{print $$3}' | \ - sed 's/^/-u /'` && \ - ld -o $(LIBRARY:.a=.so) $$undefopts $(LIBRARY) -sunos5_shared_library: - undefopts=`/usr/ccs/bin/nm $(LIBRARY) | grep GLOB | grep FUNC | \ - awk '-F|' '{print $$8}' | sed 's/^/-u /'` && \ - ld -o $(LIBRARY:.a=.so) -G $$undefopts $(LIBRARY) - - -################################################################################ -# Linking: - - -################################################################################ -# $(INSTALL)ation: - -$(INCDIR)/$(HEADER): $(INCDIR) $(HEADER) - $(INSTALL) $(srcdir)/$(HEADER) $@ -$(INCDIR)/$(HEADER1): $(INCDIR) $(HEADER1) - $(INSTALL) $(srcdir)/$(HEADER1) $@ -$(INCDIR)/$(HEADER2): $(INCDIR) $(HEADER2) - $(INSTALL) $(srcdir)/$(HEADER2) $@ -$(INCDIR)/$(HEADER3): $(INCDIR) $(HEADER3) - $(INSTALL) $(srcdir)/$(HEADER3) $@ - -$(LIBDIR)/$(LIBRARY): $(LIBDIR) $(LIBRARY) - $(INSTALL) -d -m 755 $(LIBDIR) - $(INSTALL) -m 644 $(LIBRARY) $@ - -$(BINDIR)/$(PROGRAM): $(BINDIR) $(PROGRAM) - $(INSTALL) -d -m 755 $(BINDIR) - $(INSTALL) -m 755 $(PROGRAM) $@ - -#$(BINDIR) \ -#$(INCDIR) \ -#$(LIBDIR) \ -#$(MANDIR) : -# -test -d $@ || mkdir $@ - -#$(MANDIR)/man1 \ -#$(MANDIR)/man3 \ -#$(MANDIR)/man3f \ -#$(MANDIR)/man3f90 : $(MANDIR) -# -test -d $@ || mkdir $@ - -# $(MANDIR)/man1/$(MANUAL): $(MANDIR)/man1 $(MANUAL) -# $(INSTALL) $(srcdir)/$(MANUAL) $@ -# $(MANDIR)/man3/$(MANUAL): $(MANDIR)/man3 $(MANUAL) -# $(INSTALL) $(srcdir)/$(MANUAL) $@ -# $(MANDIR)/man3f/$(MANUAL): $(MANDIR)/man3 $(MANDIR)/man3/$(MANUAL) \ -# $(MANDIR)/man3f -# $(RM) -f $@ -# $(LN_S) $(MANDIR)/man3/$(MANUAL) $@ -# $(MANDIR)/man3f90/$(MANUAL): $(MANDIR)/man3 $(MANDIR)/man3/$(MANUAL) \ -# $(MANDIR)/man3f90 -# $(RM) -f $@ -# $(LN_S) $(MANDIR)/man3/$(MANUAL) $@ - -################################################################################ -# Cleanup: - -clean: FORCE - @if [ -n "$(SUBDIRS)" ]; then \ - subdirs="$(SUBDIRS)"; \ - for subdir in $$subdirs; do \ - (cd $$subdir && $(MAKE) $(MFLAGS) clean) ; \ - done; \ - fi - @$(RM) -f *.o *.a *.so *.sl *.i *.Z core core.* vgcore.* $(GARBAGE) \ - *.gcda *.gcno *.gcov gmon.out - -distclean: FORCE - @if [ -n "$(PACKING_SUBDIRS)" ]; then \ - subdirs="$(PACKING_SUBDIRS)"; \ - for subdir in $$subdirs; do \ - (cd $$subdir && $(MAKE) $(MFLAGS) distclean) ; \ - done; \ - fi - @if [ -n "$(PACKING_SUBDIRS)" ]; then \ - subdirs="$(PACKING_SUBDIRS)"; \ - for subdir in $$subdirs; do \ - if ! [ $(srcdir) -ef `pwd` ] ; then rmdir $$subdir ; fi \ - done; \ - fi - @$(RM) -rf SunWS_cache - @$(RM) -f *.o *.a *.so *.sl *.i *.Z core core.* vgcore.* $(GARBAGE) \ - *.gcda *.gcno *.gcov gmon.out \ - MANIFEST *.log $(DIST_GARBAGE) cscope.out cscope.files - @$(RM) -f Makefile - -################################################################################ -# Dependencies: - -# This target should only need to be made at the UPC. -# NOTES: -# * The target file might be a symbolic link. -# * The name of the target doesn't match the name of the created file to -# prevent constant updating of the included file `depend' by make(1). -# -deps: FORCE - $(CC_MAKEDEPEND) $(CPPFLAGS) *.c | grep -v '/usr/include' >>depend - sort -u -o depend depend - - -################################################################################ -# Distribution: - -# The following rule echoes the contents of $(PACKING_LIST) in the -# current directory and in all subdirectories. All pathnames are made -# relative to the current directory. -# -MANIFEST.echo: FORCE - echo $(PACKING_LIST) | fmt -1 - if [ -n "$(PACKING_SUBDIRS)" ]; then \ - subdirs="$(PACKING_SUBDIRS)"; \ - for subdir in $$subdirs; do \ - (cd $$subdir && \ - echo 1>&2 Creating $@ in `pwd` && \ - $(MAKE) $(MFLAGS) MANIFEST.echo | sed "s|^|$$subdir/|") || exit 1; \ - done; \ - else \ - :; \ - fi - -# The following rule ensures that all files in $(PACKING_LIST) exist in -# the current directory and in all subdirectories. -# -ensure_manifest: $(PACKING_LIST) FORCE - if [ -n "$(SUBDIRS)" ]; then \ - subdirs="$(SUBDIRS)"; \ - for subdir in $$subdirs; do \ - (cd $$subdir && \ - echo 1>&2 Creating $@ in `pwd` && \ - $(MAKE) $(MFLAGS) ensure_manifest) || exit 1; \ - done; \ - else \ - :; \ - fi - - -################################################################################ -# Misc: - -FORCE: - -.PHONY: FORCE all library clean distclean TAGS clean_macros rmdir_src_test b-test c-test f-test -.PHONY: subdirs $(SUBDIRS) install $(INSTALLDIRS) uninstall $(UNINSTALLDIRS) -.PHONY: tests check testing $(CHECK_DIRS) $(PTEST_DIRS) verbose_check verbose_testing $(VCHECK_DIRS) -.PHONY: ptest ptests ptest2 ptest4 ptest6 ptest8 ptest10 -.PHONY: install_PKGCONFIG uninstall_PKGCONFIG install_CONFIG uninstall_CONFIG - diff --git a/src/binding/f77/Legacy/nfconfig_inc.in b/src/binding/f77/Legacy/nfconfig_inc.in deleted file mode 100644 index 1b0cff3ed..000000000 --- a/src/binding/f77/Legacy/nfconfig_inc.in +++ /dev/null @@ -1,91 +0,0 @@ -#if 0 - Copyright (C) 2003, Northwestern University and Argonne National Laboratory - See COPYRIGHT notice in top-level directory. - - $Id$ -#endif - - -#ifndef UD_NETCDF_CPP_INC -#define UD_NETCDF_CPP_INC - - -#if 0 - Do not have C-style comments in here because this file is processed - by both the FORTRAN compiler (for the nf_test/ stuff) and the C - compiler (for the FORTRAN-callable interface routines) and some - FORTRAN preprocessors do not understand the /*...*/ syntax. -#endif - - -#if 0 - The following macros define the supplementary FORTRAN arithmetic - datatypes beyond the standard INTEGER, REAL, and DOUBLEPRECISION -- - ostensibly corresponding to 8-bit and 16-bit integers, respectively. - For example: - - #define NF_INT1_T integer*1 - #define NF_INT2_T integer*2 - #define NF_INT8_T integer*8 - - These are the types of the relevant arguments in the NF_*_INT1() and - NF_*_INT2() netCDF FORTRAN function calls. The word "ostensibly" - is used advisedly: on some systems an "integer*2" datatype, - nevertheless, occupies 64 bits (we are not making this up). - - If your FORTRAN system does not have the respective supplementary - datatype, then do not define the corresponding macro. -#endif -#undef NF_INT1_T -#undef NF_INT2_T -#undef NF_INT8_T - - -#if 0 - Define the following NF_*_IS_C_* macros appropriatly for your system. - The "INT1", "INT2", "INT", and "INT8" after the "NF_" refer to the - NF_INT1_T FORTRAN datatype, the NF_INT2_T FORTRAN datatype, the INTEGER - FORTRAN datatype, and the NF_INT8_T FORTRAN datatype, respectively. - If the respective FORTRAN datatype - does not exist, then do not define the corresponding macro. -#endif -#undef NF_INT1_IS_C_SIGNED_CHAR -#undef NF_INT1_IS_C_SHORT -#undef NF_INT1_IS_C_INT -#undef NF_INT1_IS_C_LONG -#undef NF_INT2_IS_C_SHORT -#undef NF_INT2_IS_C_INT -#undef NF_INT2_IS_C_LONG -#undef NF_INT_IS_C_INT -#undef NF_INT_IS_C_LONG -#undef NF_INT8_IS_C_LONG -#undef NF_INT8_IS_C_LONG_LONG -#undef NF_REAL_IS_C_FLOAT -#undef NF_REAL_IS_C_DOUBLE -#undef NF_DOUBLEPRECISION_IS_C_DOUBLE -#undef NF_DOUBLEPRECISION_IS_C_FLOAT - - -#if 0 - Whether the system uses something besides the IEEE floating-point - format to represent floating-point values. -#endif -#undef NO_IEEE_FLOAT - - -#if 0 - END OF CUSTOMIZATION -#endif - - -#if 0 - FORTRAN data types corresponding to netCDF version 2 "byte" and "short" - data types (e.g. INTEGER*1, INTEGER*2). See file "ftest.F" for usage. -#endif -#if !defined(NO_NETCDF_2) -# undef NCBYTE_T -# undef NCSHORT_T -#endif - - -#endif diff --git a/src/binding/f77/Legacy/varn_external.m4 b/src/binding/f77/Legacy/varn_external.m4 deleted file mode 100644 index 5b5b8e5a1..000000000 --- a/src/binding/f77/Legacy/varn_external.m4 +++ /dev/null @@ -1,73 +0,0 @@ -! -! Begin of varn subroutines -! - -define(`VARNX',dnl -`dnl - integer nfmpi_$1_varn$3 -! INTEGER FUNCTION nfmpi_$1_varn$3(ncid, varid, num, starts, counts, buf, bufcount, buftype) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) -! , INTENT($2) :: buf(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount -! INTEGER, INTENT(IN) :: buftype -! END FUNCTION nfmpi_$1_varn$3 - external nfmpi_$1_varn$3 -')dnl -! -! flexible APIs -! -VARNX(get, OUT) -VARNX(get, OUT, _all) -VARNX(put, IN) -VARNX(put, IN, _all) - -define(`VARN',dnl -`dnl - integer nfmpi_$1_varn_$3$4 -! INTEGER FUNCTION nfmpi_$1_varn_$3$4(ncid, varid, num, starts, counts, $5) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) -! $6, INTENT($2) :: $7 -! END FUNCTION nfmpi_$1_varn_$3$4 - external nfmpi_$1_varn_$3$4 -')dnl -VARN(get, OUT, text, , text, CHARACTER(len=*), text) -VARN(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARN(get, OUT, real, , rvals, REAL, rvals(*)) -VARN(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN(get, OUT, text, _all, text, CHARACTER(len=*), text) -VARN(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARN(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARN(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARN(put, IN, text, , text, CHARACTER(len=*), text) -VARN(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN(put, IN, int, , ivals, INTEGER, ivals(*)) -VARN(put, IN, real, , rvals, REAL, rvals(*)) -VARN(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN(put, IN, text, _all, text, CHARACTER(len=*), text) -VARN(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARN(put, IN, real, _all, rvals, REAL, rvals(*)) -VARN(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) -! -! End of varn subroutines -! - diff --git a/src/binding/f77/Legacy/varnx_external.m4 b/src/binding/f77/Legacy/varnx_external.m4 deleted file mode 100644 index 9c206d4ca..000000000 --- a/src/binding/f77/Legacy/varnx_external.m4 +++ /dev/null @@ -1,337 +0,0 @@ -! -! Begin of varn subroutines -! - -define(`VARNX',dnl -`dnl - integer nfmpi_$1_varn$3 -! INTEGER FUNCTION nfmpi_$1_varn$3(ncid, varid, num, buf, bufcount, buftype) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! , INTENT($2) :: buf(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount -! INTEGER, INTENT(IN) :: buftype -! END FUNCTION nfmpi_$1_varn$3 - external nfmpi_$1_varn$3 -')dnl -! -! flexible APIs -! -VARNX(get, OUT) -VARNX(get, OUT, _all) -VARNX(put, IN) -VARNX(put, IN, _all) - -define(`VARN',dnl -`dnl - integer nfmpi_$1_varn_$3$4 -! INTEGER FUNCTION nfmpi_$1_varn_$3$4(ncid, varid, num, $5) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! $6, INTENT($2) :: $7 -! END FUNCTION nfmpi_$1_varn_$3$4 - external nfmpi_$1_varn_$3$4 -')dnl -VARN(get, OUT, text, , text, CHARACTER(len=*), text) -VARN(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARN(get, OUT, real, , rvals, REAL, rvals(*)) -VARN(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN(get, OUT, text, _all, text, CHARACTER(len=*), text) -VARN(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARN(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARN(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARN(put, IN, text, , text, CHARACTER(len=*), text) -VARN(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN(put, IN, int, , ivals, INTEGER, ivals(*)) -VARN(put, IN, real, , rvals, REAL, rvals(*)) -VARN(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN(put, IN, text, _all, text, CHARACTER(len=*), text) -VARN(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARN(put, IN, real, _all, rvals, REAL, rvals(*)) -VARN(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -define(`VARN1X',dnl -`dnl - integer nfmpi_$1_varn1$3 -! INTEGER FUNCTION nfmpi_$1_varn1$3(ncid, varid, num, starts, buf, bufcount, buftype) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) -! , INTENT($2) :: buf(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount -! INTEGER, INTENT(IN) :: buftype -! END FUNCTION nfmpi_$1_varn1$3 - external nfmpi_$1_varn1$3 -')dnl -! -! flexible APIs -! -VARN1X(get, OUT) -VARN1X(get, OUT, _all) -VARN1X(put, IN) -VARN1X(put, IN, _all) - -define(`VARN1',dnl -`dnl - integer nfmpi_$1_varn1_$3$4 -! INTEGER FUNCTION nfmpi_$1_varn1_$3$4(ncid, varid, num, starts, $5) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) -! $6, INTENT($2) :: $7 -! END FUNCTION nfmpi_$1_varn1_$3$4 - external nfmpi_$1_varn1_$3$4 -')dnl -VARN1(get, OUT, text, , text, CHARACTER, text) -VARN1(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN1(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN1(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARN1(get, OUT, real, , rvals, REAL, rvals(*)) -VARN1(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN1(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN1(get, OUT, text, _all, text, CHARACTER, text) -VARN1(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN1(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN1(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARN1(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARN1(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN1(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARN1(put, IN, text, , text, CHARACTER, text) -VARN1(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN1(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN1(put, IN, int, , ivals, INTEGER, ivals(*)) -VARN1(put, IN, real, , rvals, REAL, rvals(*)) -VARN1(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN1(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN1(put, IN, text, _all, text, CHARACTER, text) -VARN1(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN1(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN1(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARN1(put, IN, real, _all, rvals, REAL, rvals(*)) -VARN1(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN1(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -define(`VARNAX',dnl -`dnl - integer nfmpi_$1_varna$3 -! INTEGER FUNCTION nfmpi_$1_varna$3(ncid, varid, num, starts, counts, buf, bufcount, buftype) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) -! , INTENT($2) :: buf(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount -! INTEGER, INTENT(IN) :: buftype -! END FUNCTION nfmpi_$1_varna$3 - external nfmpi_$1_varna$3 -')dnl -! -! flexible APIs -! -VARNAX(get, OUT) -VARNAX(get, OUT, _all) -VARNAX(put, IN) -VARNAX(put, IN, _all) - -define(`VARNA',dnl -`dnl - integer nfmpi_$1_varna_$3$4 -! INTEGER FUNCTION nfmpi_$1_varna_$3$4(ncid, varid, num, starts, counts, $5) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) -! $6, INTENT($2) :: $7 -! END FUNCTION nfmpi_$1_varna_$3$4 - external nfmpi_$1_varna_$3$4 -')dnl -VARNA(get, OUT, text, , text, CHARACTER(len=*), text) -VARNA(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNA(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNA(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARNA(get, OUT, real, , rvals, REAL, rvals(*)) -VARNA(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNA(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNA(get, OUT, text, _all, text, CHARACTER(len=*), text) -VARNA(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNA(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNA(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARNA(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARNA(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNA(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARNA(put, IN, text, , text, CHARACTER(len=*), text) -VARNA(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNA(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNA(put, IN, int, , ivals, INTEGER, ivals(*)) -VARNA(put, IN, real, , rvals, REAL, rvals(*)) -VARNA(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNA(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNA(put, IN, text, _all, text, CHARACTER(len=*), text) -VARNA(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNA(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNA(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARNA(put, IN, real, _all, rvals, REAL, rvals(*)) -VARNA(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNA(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -define(`VARNSX',dnl -`dnl - integer nfmpi_$1_varns$3 -! INTEGER FUNCTION nfmpi_$1_varns$3(ncid, varid, num, starts, counts, strides, buf, bufcount, buftype) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: strides(*) -! , INTENT($2) :: buf(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount -! INTEGER, INTENT(IN) :: buftype -! END FUNCTION nfmpi_$1_varns$3 - external nfmpi_$1_varns$3 -')dnl -! -! flexible APIs -! -VARNSX(get, OUT) -VARNSX(get, OUT, _all) -VARNSX(put, IN) -VARNSX(put, IN, _all) - -define(`VARNS',dnl -`dnl - integer nfmpi_$1_varns_$3$4 -! INTEGER FUNCTION nfmpi_$1_varns_$3$4(ncid, varid, num, starts, counts, strides, $5) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: strides(*) -! $6, INTENT($2) :: $7 -! END FUNCTION nfmpi_$1_varns_$3$4 - external nfmpi_$1_varns_$3$4 -')dnl -VARNS(get, OUT, text, , text, CHARACTER(len=*), text) -VARNS(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNS(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNS(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARNS(get, OUT, real, , rvals, REAL, rvals(*)) -VARNS(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNS(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNS(get, OUT, text, _all, text, CHARACTER(len=*), text) -VARNS(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNS(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNS(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARNS(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARNS(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNS(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARNS(put, IN, text, , text, CHARACTER(len=*), text) -VARNS(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNS(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNS(put, IN, int, , ivals, INTEGER, ivals(*)) -VARNS(put, IN, real, , rvals, REAL, rvals(*)) -VARNS(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNS(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNS(put, IN, text, _all, text, CHARACTER(len=*), text) -VARNS(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNS(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNS(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARNS(put, IN, real, _all, rvals, REAL, rvals(*)) -VARNS(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNS(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -define(`VARNMX',dnl -`dnl - integer nfmpi_$1_varnm$3 -! INTEGER FUNCTION nfmpi_$1_varnm$3(ncid, varid, num, starts, counts, strides, imaps, buf, bufcount, buftype) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: strides(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: imaps(*) -! , INTENT($2) :: buf(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount -! INTEGER, INTENT(IN) :: buftype -! END FUNCTION nfmpi_$1_varnm$3 - external nfmpi_$1_varnm$3 -')dnl -! -! flexible APIs -! -VARNMX(get, OUT) -VARNMX(get, OUT, _all) -VARNMX(put, IN) -VARNMX(put, IN, _all) - -define(`VARNM',dnl -`dnl - integer nfmpi_$1_varnm_$3$4 -! INTEGER FUNCTION nfmpi_$1_varnm_$3$4(ncid, varid, num, starts, counts, strides, imaps, $5) -! INTEGER, INTENT(IN) :: ncid -! INTEGER, INTENT(IN) :: varid -! INTEGER, INTENT(IN) :: num -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: strides(*) -! INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: imaps(*) -! $6, INTENT($2) :: $7 -! END FUNCTION nfmpi_$1_varnm_$3$4 - external nfmpi_$1_varnm_$3$4 -')dnl -VARNM(get, OUT, text, , text, CHARACTER(len=*), text) -VARNM(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNM(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNM(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARNM(get, OUT, real, , rvals, REAL, rvals(*)) -VARNM(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNM(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNM(get, OUT, text, _all, text, CHARACTER(len=*), text) -VARNM(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNM(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNM(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARNM(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARNM(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNM(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARNM(put, IN, text, , text, CHARACTER(len=*), text) -VARNM(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNM(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNM(put, IN, int, , ivals, INTEGER, ivals(*)) -VARNM(put, IN, real, , rvals, REAL, rvals(*)) -VARNM(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNM(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNM(put, IN, text, _all, text, CHARACTER(len=*), text) -VARNM(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNM(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNM(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARNM(put, IN, real, _all, rvals, REAL, rvals(*)) -VARNM(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNM(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) -! -! End of varn subroutines -! - diff --git a/src/binding/f90/Legacy/varn_interface.m4 b/src/binding/f90/Legacy/varn_interface.m4 deleted file mode 100644 index 2f86edcd0..000000000 --- a/src/binding/f90/Legacy/varn_interface.m4 +++ /dev/null @@ -1,77 +0,0 @@ -! -! Begin of varn subroutines: -! -! Note that we use starts(*) and counts(*) instead of starts(:,:) and -! counts(:,:), because we will rearrange the Fortran order for the -! dimensions to C order and would like the arrays in a contiguous space -! -! $Id$ -! - -define(`VARN_FLEXIBLE',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varn$3(ncid, varid, num, starts, counts, buf, bufcount, buftype) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) - , INTENT($2) :: buf(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount - INTEGER, INTENT(IN) :: buftype - END FUNCTION nfmpi_$1_varn$3 -')dnl -#if 0 -! -! flexible APIs, not ready yet for Fortran90 -! -VARN_FLEXIBLE(get, OUT) -VARN_FLEXIBLE(get, OUT, _all) -VARN_FLEXIBLE(put, IN) -VARN_FLEXIBLE(put, IN, _all) -#endif - -define(`VARN',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varn_$3$4(ncid, varid, num, starts, counts, $5) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) - $6, INTENT($2) :: $7 - END FUNCTION nfmpi_$1_varn_$3$4 -')dnl -VARN(get, OUT, text, , text, CHARACTER(len=*), text) -VARN(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARN(get, OUT, real, , rvals, REAL, rvals(*)) -VARN(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN(get, OUT, text, _all, text, CHARACTER(len=*), text) -VARN(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARN(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARN(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARN(put, IN, text, , text, CHARACTER(len=*), text) -VARN(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN(put, IN, int, , ivals, INTEGER, ivals(*)) -VARN(put, IN, real, , rvals, REAL, rvals(*)) -VARN(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN(put, IN, text, _all, text, CHARACTER(len=*), text) -VARN(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARN(put, IN, real, _all, rvals, REAL, rvals(*)) -VARN(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) -! -! End of varn subroutines: -! - diff --git a/src/binding/f90/Legacy/varnx_interface.m4 b/src/binding/f90/Legacy/varnx_interface.m4 deleted file mode 100644 index f1484717e..000000000 --- a/src/binding/f90/Legacy/varnx_interface.m4 +++ /dev/null @@ -1,329 +0,0 @@ -! -! Begin of varn subroutines: -! -! $Id$ -! - -define(`VARNX',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varn$3(ncid, varid, num, buf, bufcount, buftype) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - , INTENT($2) :: buf(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount - INTEGER, INTENT(IN) :: buftype - END FUNCTION nfmpi_$1_varn$3 -')dnl -#if 0 -! -! flexible APIs, not ready yet for Fortran90 -! -VARNX(get, OUT) -VARNX(get, OUT, _all) -VARNX(put, IN) -VARNX(put, IN, _all) -#endif - -define(`VARN',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varn_$3$4(ncid, varid, num, $5) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - $6, INTENT($2) :: $7 - END FUNCTION nfmpi_$1_varn_$3$4 -')dnl -VARN(get, OUT, text, , text, CHARACTER(len=*), text) -VARN(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARN(get, OUT, real, , rvals, REAL, rvals(*)) -VARN(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN(get, OUT, text, _all, text, CHARACTER(len=*), text) -VARN(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARN(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARN(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARN(put, IN, text, , text, CHARACTER(len=*), text) -VARN(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN(put, IN, int, , ivals, INTEGER, ivals(*)) -VARN(put, IN, real, , rvals, REAL, rvals(*)) -VARN(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN(put, IN, text, _all, text, CHARACTER(len=*), text) -VARN(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARN(put, IN, real, _all, rvals, REAL, rvals(*)) -VARN(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -define(`VARN1X',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varn1$3(ncid, varid, num, starts, buf, bufcount, buftype) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) - , INTENT($2) :: buf(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount - INTEGER, INTENT(IN) :: buftype - END FUNCTION nfmpi_$1_varn1$3 -')dnl -#if 0 -! -! flexible APIs, not ready yet for Fortran90 -! -VARN1X(get, OUT) -VARN1X(get, OUT, _all) -VARN1X(put, IN) -VARN1X(put, IN, _all) -#endif - -define(`VARN1',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varn1_$3$4(ncid, varid, num, starts, $5) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) - $6, INTENT($2) :: $7 - END FUNCTION nfmpi_$1_varn1_$3$4 -')dnl -VARN1(get, OUT, text, , text, CHARACTER, text) -VARN1(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN1(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN1(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARN1(get, OUT, real, , rvals, REAL, rvals(*)) -VARN1(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN1(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN1(get, OUT, text, _all, text, CHARACTER, text) -VARN1(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN1(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN1(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARN1(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARN1(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN1(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARN1(put, IN, text, , text, CHARACTER, text) -VARN1(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARN1(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARN1(put, IN, int, , ivals, INTEGER, ivals(*)) -VARN1(put, IN, real, , rvals, REAL, rvals(*)) -VARN1(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARN1(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARN1(put, IN, text, _all, text, CHARACTER, text) -VARN1(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARN1(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARN1(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARN1(put, IN, real, _all, rvals, REAL, rvals(*)) -VARN1(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARN1(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -define(`VARNAX',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varna$3(ncid, varid, num, starts, counts, buf, bufcount, buftype) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) - , INTENT($2) :: buf(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount - INTEGER, INTENT(IN) :: buftype - END FUNCTION nfmpi_$1_varna$3 -')dnl -#if 0 -! -! flexible APIs, not ready yet for Fortran90 -! -VARNAX(get, OUT) -VARNAX(get, OUT, _all) -VARNAX(put, IN) -VARNAX(put, IN, _all) -#endif - -define(`VARNA',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varna_$3$4(ncid, varid, num, starts, counts, $5) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) - $6, INTENT($2) :: $7 - END FUNCTION nfmpi_$1_varna_$3$4 -')dnl -VARNA(get, OUT, text, , text, CHARACTER(len=*), text) -VARNA(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNA(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNA(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARNA(get, OUT, real, , rvals, REAL, rvals(*)) -VARNA(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNA(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNA(get, OUT, text, _all, text, CHARACTER(len=*), text) -VARNA(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNA(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNA(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARNA(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARNA(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNA(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARNA(put, IN, text, , text, CHARACTER(len=*), text) -VARNA(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNA(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNA(put, IN, int, , ivals, INTEGER, ivals(*)) -VARNA(put, IN, real, , rvals, REAL, rvals(*)) -VARNA(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNA(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNA(put, IN, text, _all, text, CHARACTER(len=*), text) -VARNA(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNA(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNA(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARNA(put, IN, real, _all, rvals, REAL, rvals(*)) -VARNA(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNA(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -define(`VARNSX',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varns$3(ncid, varid, num, starts, counts, strides, buf, bufcount, buftype) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: strides(*) - , INTENT($2) :: buf(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount - INTEGER, INTENT(IN) :: buftype - END FUNCTION nfmpi_$1_varns$3 -')dnl -#if 0 -! -! flexible APIs, not ready yet for Fortran90 -! -VARNSX(get, OUT) -VARNSX(get, OUT, _all) -VARNSX(put, IN) -VARNSX(put, IN, _all) -#endif - -define(`VARNS',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varns_$3$4(ncid, varid, num, starts, counts, strides, $5) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: strides(*) - $6, INTENT($2) :: $7 - END FUNCTION nfmpi_$1_varns_$3$4 -')dnl -VARNS(get, OUT, text, , text, CHARACTER(len=*), text) -VARNS(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNS(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNS(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARNS(get, OUT, real, , rvals, REAL, rvals(*)) -VARNS(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNS(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNS(get, OUT, text, _all, text, CHARACTER(len=*), text) -VARNS(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNS(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNS(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARNS(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARNS(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNS(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARNS(put, IN, text, , text, CHARACTER(len=*), text) -VARNS(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNS(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNS(put, IN, int, , ivals, INTEGER, ivals(*)) -VARNS(put, IN, real, , rvals, REAL, rvals(*)) -VARNS(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNS(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNS(put, IN, text, _all, text, CHARACTER(len=*), text) -VARNS(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNS(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNS(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARNS(put, IN, real, _all, rvals, REAL, rvals(*)) -VARNS(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNS(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -define(`VARNMX',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varnm$3(ncid, varid, num, starts, counts, strides, imaps, buf, bufcount, buftype) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: strides(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: imaps(*) - , INTENT($2) :: buf(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: bufcount - INTEGER, INTENT(IN) :: buftype - END FUNCTION nfmpi_$1_varnm$3 -')dnl -#if 0 -! -! flexible APIs, not ready yet for Fortran90 -! -VARNMX(get, OUT) -VARNMX(get, OUT, _all) -VARNMX(put, IN) -VARNMX(put, IN, _all) -#endif - -define(`VARNM',dnl -`dnl - INTEGER FUNCTION nfmpi_$1_varnm_$3$4(ncid, varid, num, starts, counts, strides, imaps, $5) - INTEGER, INTENT(IN) :: ncid - INTEGER, INTENT(IN) :: varid - INTEGER, INTENT(IN) :: num - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: starts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: counts(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: strides(*) - INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: imaps(*) - $6, INTENT($2) :: $7 - END FUNCTION nfmpi_$1_varnm_$3$4 -')dnl -VARNM(get, OUT, text, , text, CHARACTER(len=*), text) -VARNM(get, OUT, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNM(get, OUT, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNM(get, OUT, int, , ivals, INTEGER, ivals(*)) -VARNM(get, OUT, real, , rvals, REAL, rvals(*)) -VARNM(get, OUT, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNM(get, OUT, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNM(get, OUT, text, _all, text, CHARACTER(len=*), text) -VARNM(get, OUT, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNM(get, OUT, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNM(get, OUT, int, _all, ivals, INTEGER, ivals(*)) -VARNM(get, OUT, real, _all, rvals, REAL, rvals(*)) -VARNM(get, OUT, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNM(get, OUT, int8, _all, i8vals, INTEGER*8, i8vals(*)) - -VARNM(put, IN, text, , text, CHARACTER(len=*), text) -VARNM(put, IN, int1, , i1vals, INTEGER*1, i1vals(*)) -VARNM(put, IN, int2, , i2vals, INTEGER*2, i2vals(*)) -VARNM(put, IN, int, , ivals, INTEGER, ivals(*)) -VARNM(put, IN, real, , rvals, REAL, rvals(*)) -VARNM(put, IN, double, , dvals, DOUBLE PRECISION, dvals(*)) -VARNM(put, IN, int8, , i8vals, INTEGER*8, i8vals(*)) -VARNM(put, IN, text, _all, text, CHARACTER(len=*), text) -VARNM(put, IN, int1, _all, i1vals, INTEGER*1, i1vals(*)) -VARNM(put, IN, int2, _all, i2vals, INTEGER*2, i2vals(*)) -VARNM(put, IN, int, _all, ivals, INTEGER, ivals(*)) -VARNM(put, IN, real, _all, rvals, REAL, rvals(*)) -VARNM(put, IN, double, _all, dvals, DOUBLE PRECISION, dvals(*)) -VARNM(put, IN, int8, _all, i8vals, INTEGER*8, i8vals(*)) -! -! End of varn subroutines: -! - diff --git a/src/drivers/ncmpio/Legacy/check_start_count_stride.c b/src/drivers/ncmpio/Legacy/check_start_count_stride.c deleted file mode 100644 index 6ce0bd0e5..000000000 --- a/src/drivers/ncmpio/Legacy/check_start_count_stride.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) 2015, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#ifdef HAVE_STDLIB_H -#include -#endif - -#include - -#include -#include -#include -#include - -/*----< ncmpii_start_count_stride_check() >----------------------------------*/ -/* - * Check whether start, count, stride values are valid for the variable. - * Report error codes: NC_EINVALCOORDS, NC_EEDGE, or NC_ESTRIDE. - * Note that even if the request size is zero, this check is enforced in both - * netCDF and PnetCDF. Otherwise, many test cases under test directory can - * fail. Arguments count and stride can be NULL. - */ -int -ncmpii_start_count_stride_check(int format, - int api, - int ndims, - int numrecs, - const MPI_Offset *shape, - const MPI_Offset *start, - const MPI_Offset *count, - const MPI_Offset *stride, - const int reqMode) /* read or write */ -{ - int i=0, firstDim; - - if (ndims == 0) return NC_NOERR; /* 'scalar' variable */ - - if (api <= API_VAR) /* var/varn/vard APIs, start/count/stride are NULL */ - return NC_NOERR; - - /* Now only need to check var1, vara, vars, and varm APIs */ - - /* Check NC_EINVALCOORDS error for argument start[] - * for API var1/vara/vars/varm, start cannot be NULL, except for scalars - * and negative start[] is illegal */ - if (start == NULL || start[0] < 0) DEBUG_RETURN_ERROR(NC_EINVALCOORDS) - - firstDim = 0; - /* check NC_EINVALCOORDS for record dimension */ - if (shape[0] == NC_UNLIMITED) { - if (format < 5 && start[0] > NC_MAX_UINT) /* CDF-1 and 2 */ - DEBUG_RETURN_ERROR(NC_EINVALCOORDS) - - /* for record variable, [0] is the NC_UNLIMITED dimension */ - if (fIsSet(reqMode, NC_REQ_RD)) { - /* read cannot go beyond current numrecs */ -#ifdef RELAX_COORD_BOUND - if (start[0] > numrecs) DEBUG_RETURN_ERROR(NC_EINVALCOORDS) - - if (start[0] == numrecs) { - if (api == API_VAR1) { - /* for var1 APIs, count[0] is considered of 1 */ - DEBUG_RETURN_ERROR(NC_EINVALCOORDS) - } - else if (count != NULL && count[0] > 0) { - DEBUG_RETURN_ERROR(NC_EINVALCOORDS) - } - } -#else - if (start[0] >= numrecs) DEBUG_RETURN_ERROR(NC_EINVALCOORDS) -#endif - } - firstDim = 1; /* done for checking the record dimension */ - } - - /* continue to check NC_EINVALCOORDS for the rest dimensions */ - for (i=firstDim; i shape[i]) - DEBUG_RETURN_ERROR(NC_EINVALCOORDS) - - if (start[i] == shape[i]) { - if (api == API_VAR1) { - /* for var1 APIs, count[0] is considered of 1 */ - DEBUG_RETURN_ERROR(NC_EINVALCOORDS) - } - else if (count != NULL && count[i] > 0) { - DEBUG_RETURN_ERROR(NC_EINVALCOORDS) - } - } -#else - if (start[i] < 0 || start[i] >= shape[i]) - DEBUG_RETURN_ERROR(NC_EINVALCOORDS) -#endif - } - - /* Now check NC_EEDGE error for argument count[] */ - if (api <= API_VAR1) /* var1/var APIs have no count argument */ - return NC_NOERR; - - /* for API vara/vars/varm, count cannot be NULL, except for scalars */ - if (count == NULL) DEBUG_RETURN_ERROR(NC_EEDGE) - - firstDim = 0; - /* check NC_EINVALCOORDS for record dimension */ - if (shape[0] == NC_UNLIMITED) { - if (count[0] < 0) /* no negative count[] */ - DEBUG_RETURN_ERROR(NC_ENEGATIVECNT) - - /* for record variable, [0] is the NC_UNLIMITED dimension */ - if (fIsSet(reqMode, NC_REQ_RD)) { - /* read cannot go beyond current numrecs */ - if (stride == NULL) { /* for vara APIs */ - if (start[0] + count[0] > numrecs) - DEBUG_RETURN_ERROR(NC_EEDGE) - } - else { /* for vars/varm APIs */ - if (count[0] > 0 && - start[0] + (count[0]-1) * stride[0] >= numrecs) - DEBUG_RETURN_ERROR(NC_EEDGE) - } - } - firstDim = 1; /* skip checking the record dimension */ - } - - /* continue to check NC_EEDGE for the rest dimensions */ - for (i=firstDim; i shape[i] || start[i] + count[i] > shape[i]) - DEBUG_RETURN_ERROR(NC_EEDGE) - } - else { /* for vars APIs */ - if (count[i] > 0 && start[i] + (count[i]-1) * stride[i] >= shape[i]) - DEBUG_RETURN_ERROR(NC_EEDGE) - } - } - - /* Now check NC_ESTRIDE error for argument stride[] */ - if (api <= API_VARA || stride == NULL) - /* vara APIs have no stride argument */ - return NC_NOERR; - - /* Check NC_ESTRIDE for non-positive values. We did not check - * stride[i] >= shape[i], as it is caught as NC_EEDGE error above */ - for (i=0; i -#endif - -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#include - -#include - -#include -#include -#include "nc.h" -#include "ncx.h" - -/*----< ncmpio_calc_datatype_elems() >---------------------------------------*/ -/* Obtain the following metadata about buftype: - * etype: element data type (MPI primitive type) in buftype - * bufcount: If it is -1, then this is called from a high-level API and in - * this case buftype will be an MPI primitive data type and bufcount - * is assigned to a number match with count[]. If bufcount is not -1, - * then this is called from a flexible API. - * nelems: number of etypes in user buffer - * xnbytes: number of bytes (in external data representation) to read/write - * from/to the file - * esize: byte size of etype - * isContig: whether buftype is contiguous - */ -int -ncmpio_calc_datatype_elems(const NC_var *varp, - const MPI_Offset *count, - MPI_Datatype buftype, - MPI_Datatype *etype, /* out */ - MPI_Offset *bufcount, /* in/out */ - MPI_Offset *nelems, /* out */ - MPI_Offset *xnbytes, /* out */ - int *esize, /* out */ - int *isContig) /* out */ -{ - int i; - MPI_Offset fnelems; - - /* fnelems is the total number of nc_type elements calculated from - * count[]. count[] is the access count to the variable defined in - * the netCDF file. - */ - fnelems = 1; - for (i=0; indims; i++) - fnelems *= count[i]; - - if (*bufcount == -1) { /* the subroutine is called from a high-level API */ - *bufcount = fnelems; - *nelems = fnelems; - *etype = buftype; /* buftype is an MPI primitive data type */ - *isContig = 1; - *xnbytes = *nelems * varp->xsz; - MPI_Type_size(buftype, esize); - } - else if (buftype == MPI_DATATYPE_NULL) { - /* This is called from a flexible API and buftype is set by user to - * MPI_DATATYPE_NULL. In this case, bufcount is ignored and set by - * this subroutine to a number match count[], and etype to match the - * variable's external NC data type. - */ - *bufcount = fnelems; - *nelems = fnelems; - *etype = ncmpii_nc2mpitype(varp->xtype); - *esize = varp->xsz; - *xnbytes = *nelems * varp->xsz; - *isContig = 1; - } - else { /* This is called from a flexible API */ - int err, isderived; - /* check some metadata of the MPI derived datatype */ - err = ncmpii_dtype_decode(buftype, etype, esize, nelems, &isderived, - isContig); - if (err != NC_NOERR) return err; - - /* make nelems the number of etype in the whole user buf */ - *nelems *= *bufcount; - *xnbytes = *nelems * varp->xsz; - - /* check mismatch between nelems and fnelems */ - if (fnelems != *nelems) DEBUG_RETURN_ERROR(NC_EIOMISMATCH) - } - return NC_NOERR; -} - diff --git a/src/drivers/ncmpio/Legacy/header.c b/src/drivers/ncmpio/Legacy/header.c deleted file mode 100644 index 2ae080cf9..000000000 --- a/src/drivers/ncmpio/Legacy/header.c +++ /dev/null @@ -1,1907 +0,0 @@ -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include /* memcpy(), memcmp() */ -#ifdef HAVE_STDLIB_H -#include -#endif -#include - -#include - -#include -#include -#include "nc.h" -#include "ncx.h" - -typedef enum { - NC_UNSPECIFIED = 0, -/* NC_BITFIELD = 7, */ -/* NC_STRING = 8, */ - NC_DIMENSION = 10, /* \x00 \x00 \x00 \x0A */ - NC_VARIABLE = 11, /* \x00 \x00 \x00 \x0B */ - NC_ATTRIBUTE = 12 /* \x00 \x00 \x00 \x0C */ -} NC_tag; - -/* - * "magic number" at beginning of file: 0x43444601 (big endian) - */ -static const char ncmagic1[] = {'C', 'D', 'F', 0x01}; -static const char ncmagic2[] = {'C', 'D', 'F', 0x02}; -static const char ncmagic5[] = {'C', 'D', 'F', 0x05}; - - -/*----< compute_var_shape() >------------------------------------------------*/ -/* Recompute the shapes of all variables - * Sets ncp->begin_var to start of first variable. - * Sets ncp->begin_rec to start of first record variable. - * Returns -1 on error. The only possible error is an reference to a non - * existent dimension, which would occur for a corrupt netcdf file. - */ -static int -compute_var_shape(NC *ncp) -{ - int i, err; - NC_var *first_var = NULL; /* first "non-record" var */ - NC_var *first_rec = NULL; /* first "record" var */ - - if (ncp->vars.ndefined == 0) return NC_NOERR; - - ncp->begin_var = ncp->xsz; - ncp->begin_rec = ncp->xsz; - ncp->recsize = 0; - - for (i=0; ivars.ndefined; i++) { - /* ncp->vars.value[i]->len will be recomputed from dimensions in - * ncmpio_NC_var_shape64() */ - err = ncmpio_NC_var_shape64(ncp->vars.value[i], &ncp->dims); - if (err != NC_NOERR) return err; - - if (IS_RECVAR(ncp->vars.value[i])) { - if (first_rec == NULL) first_rec = ncp->vars.value[i]; - ncp->recsize += ncp->vars.value[i]->len; - } - else { /* fixed-size variable */ - if (first_var == NULL) first_var = ncp->vars.value[i]; - /* - * Overwritten each time thru. - * Usually overwritten in first_rec != NULL clause. - */ - ncp->begin_rec = ncp->vars.value[i]->begin - + ncp->vars.value[i]->len; - } - } - - if (first_rec != NULL) { - if (ncp->begin_rec > first_rec->begin) - DEBUG_RETURN_ERROR(NC_ENOTNC) /* not a netCDF file or corrupted */ - - ncp->begin_rec = first_rec->begin; - /* - * for special case of exactly one record variable, pack value - */ - if (ncp->recsize == first_rec->len) - ncp->recsize = *first_rec->dsizes * first_rec->xsz; - } - - if (first_var != NULL) - ncp->begin_var = first_var->begin; - else - ncp->begin_var = ncp->begin_rec; - - if (ncp->begin_var <= 0 || ncp->xsz > ncp->begin_var || - ncp->begin_rec <= 0 || ncp->begin_var > ncp->begin_rec) - DEBUG_RETURN_ERROR(NC_ENOTNC) /* not a netCDF file or corrupted */ - - return NC_NOERR; -} - -#define X_SIZEOF_NC_TYPE X_SIZEOF_INT -#define X_SIZEOF_NC_TAG X_SIZEOF_INT - -/*----< hdr_len_NC_name() >--------------------------------------------------*/ -inline static MPI_Offset -hdr_len_NC_name(const NC_string *ncstrp, - int sizeof_NON_NEG) /* NON_NEG */ -{ - /* netCDF file format: - * name = nelems namestring - * nelems = NON_NEG - * namestring = ID1 [IDN ...] padding - * ID1 = alphanumeric | '_' - * IDN = alphanumeric | special1 | special2 - * padding = <0, 1, 2, or 3 bytes to next 4-byte boundary> - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - MPI_Offset sz = sizeof_NON_NEG; /* nelems */ - - assert(ncstrp != NULL); - - if (ncstrp->nchars != 0) /* namestring */ - sz += _RNDUP(ncstrp->nchars, X_ALIGN); - - return sz; -} - -/*----< hdr_len_NC_dim() >---------------------------------------------------*/ -inline static MPI_Offset -hdr_len_NC_dim(const NC_dim *dimp, - int sizeof_NON_NEG) /* NON_NEG */ -{ - /* netCDF file format: - * ... - * dim = name dim_length - * dim_length = NON_NEG - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - MPI_Offset sz; - - assert(dimp != NULL); - - sz = hdr_len_NC_name(dimp->name, sizeof_NON_NEG); /* name */ - sz += sizeof_NON_NEG; /* dim_length */ - - return sz; -} - -/*----< hdr_len_NC_dimarray() >----------------------------------------------*/ -inline static MPI_Offset -hdr_len_NC_dimarray(const NC_dimarray *ncap, - int sizeof_NON_NEG) /* NON_NEG */ -{ - /* netCDF file format: - * ... - * dim_list = ABSENT | NC_DIMENSION nelems [dim ...] - * ABSENT = ZERO ZERO | // list is not present for CDF-1 and 2 - * ZERO ZERO64 // for CDF-5 - * ZERO = \x00 \x00 \x00 \x00 // 32-bit zero - * ZERO64 = \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 // 64-bit zero - * NC_DIMENSION = \x00 \x00 \x00 \x0A // tag for list of dimensions - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int i; - MPI_Offset xlen; - - xlen = X_SIZEOF_NC_TAG; /* NC_DIMENSION */ - xlen += sizeof_NON_NEG; /* nelems */ - - if (ncap == NULL) /* ABSENT: no dimension is defined */ - return xlen; - - /* [dim ...] */ - for (i=0; indefined; i++) - xlen += hdr_len_NC_dim(ncap->value[i], sizeof_NON_NEG); - - return xlen; -} - -/*----< hdr_len_NC_attr() >--------------------------------------------------*/ -inline static MPI_Offset -hdr_len_NC_attr(const NC_attr *attrp, - int sizeof_NON_NEG) /* NON_NEG */ -{ - /* netCDF file format: - * ... - * attr = name nc_type nelems [values ...] - * nc_type = NC_BYTE | NC_CHAR | NC_SHORT | ... - * nelems = NON_NEG // number of elements in following sequence - * values = bytes | chars | shorts | ints | floats | doubles - * bytes = [BYTE ...] padding - * chars = [CHAR ...] padding - * shorts = [SHORT ...] padding - * ints = [INT ...] - * floats = [FLOAT ...] - * doubles = [DOUBLE ...] - * padding = <0, 1, 2, or 3 bytes to next 4-byte boundary> - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - MPI_Offset sz; - - assert(attrp != NULL); - - sz = hdr_len_NC_name(attrp->name, sizeof_NON_NEG); /* name */ - sz += X_SIZEOF_NC_TYPE; /* nc_type */ - sz += sizeof_NON_NEG; /* nelems */ - sz += attrp->xsz; /* [values ...] */ - - return sz; -} - -/*----< hdr_len_NC_attrarray() >---------------------------------------------*/ -inline static MPI_Offset -hdr_len_NC_attrarray(const NC_attrarray *ncap, - int sizeof_NON_NEG) /* NON_NEG */ -{ - /* netCDF file format: - * ... - * att_list = ABSENT | NC_ATTRIBUTE nelems [attr ...] - * ABSENT = ZERO ZERO | // list is not present for CDF-1 and 2 - * ZERO ZERO64 // for CDF-5 - * ZERO = \x00 \x00 \x00 \x00 // 32-bit zero - * ZERO64 = \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 // 64-bit zero - * NC_ATTRIBUTE = \x00 \x00 \x00 \x0C // tag for list of attributes - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int i; - MPI_Offset xlen; - - xlen = X_SIZEOF_NC_TAG; /* NC_ATTRIBUTE */ - xlen += sizeof_NON_NEG; /* nelems */ - - if (ncap == NULL) /* ABSENT: no attribute is defined */ - return xlen; - - for (i=0; indefined; i++) /* [attr ...] */ - xlen += hdr_len_NC_attr(ncap->value[i], sizeof_NON_NEG); - - return xlen; -} - -/*----< hdr_len_NC_var() >---------------------------------------------------*/ -inline static MPI_Offset -hdr_len_NC_var(const NC_var *varp, - int sizeof_off_t, /* OFFSET */ - int sizeof_NON_NEG) /* NON_NEG */ -{ - /* netCDF file format: - * netcdf_file = header data - * header = magic numrecs dim_list gatt_list var_list - * ... - * var = name nelems [dimid ...] vatt_list nc_type vsize begin - * nelems = NON_NEG - * dimid = NON_NEG - * vatt_list = att_list - * nc_type = NC_BYTE | NC_CHAR | NC_SHORT | ... - * vsize = NON_NEG - * begin = OFFSET // Variable start location. - * OFFSET = | // CDF-1 - * // CDF-2 and CDF-5 - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - MPI_Offset sz; - - assert(varp != NULL); - - /* for CDF-1, sizeof_off_t == 4 && sizeof_NON_NEG == 4 - * for CDF-2, sizeof_off_t == 8 && sizeof_NON_NEG == 4 - * for CDF-5, sizeof_off_t == 8 && sizeof_NON_NEG == 8 - */ - sz = hdr_len_NC_name(varp->name, sizeof_NON_NEG); /* name */ - sz += sizeof_NON_NEG; /* nelems */ - sz += sizeof_NON_NEG * varp->ndims; /* [dimid ...] */ - sz += hdr_len_NC_attrarray(&varp->attrs, sizeof_NON_NEG); /* vatt_list */ - sz += X_SIZEOF_NC_TYPE; /* nc_type */ - sz += sizeof_NON_NEG; /* vsize */ - sz += sizeof_off_t; /* begin */ - - return sz; -} - -/*----< hdr_len_NC_vararray() >----------------------------------------------*/ -inline static MPI_Offset -hdr_len_NC_vararray(const NC_vararray *ncap, - int sizeof_NON_NEG, /* NON_NEG */ - int sizeof_off_t) /* OFFSET */ -{ - /* netCDF file format: - * netcdf_file = header data - * header = magic numrecs dim_list gatt_list var_list - * ... - * var_list = ABSENT | NC_VARIABLE nelems [var ...] - * ABSENT = ZERO ZERO | // list is not present for CDF-1 and 2 - * ZERO ZERO64 // for CDF-5 - * ZERO = \x00 \x00 \x00 \x00 // 32-bit zero - * ZERO64 = \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 // 64-bit zero - * NC_VARIABLE = \x00 \x00 \x00 \x0B // tag for list of variables - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int i; - MPI_Offset xlen; - - xlen = X_SIZEOF_NC_TAG; /* NC_VARIABLE */ - xlen += sizeof_NON_NEG; /* nelems */ - - if (ncap == NULL) /* ABSENT: no variable is defined */ - return xlen; - - /* for CDF-1, sizeof_off_t == 4 && sizeof_NON_NEG == 4 - * for CDF-2, sizeof_off_t == 8 && sizeof_NON_NEG == 4 - * for CDF-5, sizeof_off_t == 8 && sizeof_NON_NEG == 8 - */ - for (i=0; indefined; i++) /* [var ...] */ - xlen += hdr_len_NC_var(ncap->value[i], sizeof_off_t, sizeof_NON_NEG); - - return xlen; -} - -/*----< hdr_put_NC_name() >--------------------------------------------------*/ -inline static int -hdr_put_NC_name(bufferinfo *pbp, - const NC_string *ncstrp) -{ - /* netCDF file format: - * ... - * name = nelems namestring - * nelems = NON_NEG - * namestring = ID1 [IDN ...] padding - * ID1 = alphanumeric | '_' - * IDN = alphanumeric | special1 | special2 - * padding = <0, 1, 2, or 3 bytes to next 4-byte boundary> - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int err; - - /* copy nelems */ - if (pbp->version < 5) { - if (ncstrp->nchars != (uint)ncstrp->nchars) - DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - err = ncmpix_put_uint32((void**)(&pbp->pos), (uint)ncstrp->nchars); - } - else - err = ncmpix_put_uint64((void**)(&pbp->pos), (uint64)ncstrp->nchars); - if (err != NC_NOERR) return err; - - /* copy namestring */ - err = ncmpix_pad_putn_text(&pbp->pos, ncstrp->nchars, ncstrp->cp); - - return err; -} - -/*----< hdr_put_NC_dim() >---------------------------------------------------*/ -inline static int -hdr_put_NC_dim(bufferinfo *pbp, - const NC_dim *dimp) -{ - /* netCDF file format: - * ... - * dim = name dim_length - * dim_length = NON_NEG - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int err; - - /* copy name */ - err = hdr_put_NC_name(pbp, dimp->name); - if (err != NC_NOERR) return err; - - /* copy dim_length */ - if (pbp->version < 5) { - /* TODO: Isn't checking dimension size already done in def_dim()? */ - if (dimp->size != (uint)dimp->size) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - err = ncmpix_put_uint32((void**)(&pbp->pos), (uint)dimp->size); - } - else - err = ncmpix_put_uint64((void**)(&pbp->pos), (uint64)dimp->size); - - return err; -} - -/*----< hdr_put_NC_dimarray() >----------------------------------------------*/ -inline static int -hdr_put_NC_dimarray(bufferinfo *pbp, - const NC_dimarray *ncap) -{ - /* netCDF file format: - * ... - * dim_list = ABSENT | NC_DIMENSION nelems [dim ...] - * ABSENT = ZERO ZERO | // list is not present for CDF-1 and 2 - * ZERO ZERO64 // for CDF-5 - * ZERO = \x00 \x00 \x00 \x00 // 32-bit zero - * ZERO64 = \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 // 64-bit zero - * NC_DIMENSION = \x00 \x00 \x00 \x0A // tag for list of dimensions - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int i, status; - - assert(pbp != NULL); - - if (ncap == NULL || ncap->ndefined == 0) { /* ABSENT */ - status = ncmpix_put_uint32((void**)(&pbp->pos), NC_UNSPECIFIED); - if (status != NC_NOERR) return status; - - /* put a ZERO or ZERO64 depending on which CDF format */ - if (pbp->version < 5) - status = ncmpix_put_uint32((void**)(&pbp->pos), 0); - else - status = ncmpix_put_uint64((void**)(&pbp->pos), 0); - if (status != NC_NOERR) return status; - } - else { - /* copy NC_DIMENSION */ - status = ncmpix_put_uint32((void**)(&pbp->pos), NC_DIMENSION); - if (status != NC_NOERR) return status; - - /* copy nelems */ - if (pbp->version < 5) - status = ncmpix_put_uint32((void**)(&pbp->pos), (uint)ncap->ndefined); - else - status = ncmpix_put_uint64((void**)(&pbp->pos), (uint64)ncap->ndefined); - if (status != NC_NOERR) return status; - - /* copy [dim ...] */ - for (i=0; indefined; i++) { - status = hdr_put_NC_dim(pbp, ncap->value[i]); - if (status != NC_NOERR) return status; - } - } - - return NC_NOERR; -} - -/*----< hdr_put_NC_attrV() >-------------------------------------------------*/ -/* - * Put the values of an attribute - */ -inline static int -hdr_put_NC_attrV(bufferinfo *pbp, - const NC_attr *attrp) -{ - /* netCDF file format: - * ... - * attr = name nc_type nelems [values ...] - * ... - * values = bytes | chars | shorts | ints | floats | doubles - * bytes = [BYTE ...] padding - * chars = [CHAR ...] padding - * shorts = [SHORT ...] padding - * ints = [INT ...] - * floats = [FLOAT ...] - * doubles = [DOUBLE ...] - * padding = <0, 1, 2, or 3 bytes to next 4-byte boundary> - */ - MPI_Offset padding, sz; - - /* ncmpio_xlen_nc_type() returns the element size (unaligned) of attrp->type - attrp->xsz is the aligned total size of attribute values - */ - sz = ncmpio_xlen_nc_type(attrp->type); - sz *= attrp->nelems; - padding = attrp->xsz - sz; - - if (sz != (size_t) sz) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - memcpy(pbp->pos, attrp->xvalue, (size_t)sz); - pbp->pos = (void *)((char *)pbp->pos + sz); - - if (padding > 0) { - /* zero-padding is per buffer, not per element */ - memset(pbp->pos, 0, (size_t)padding); - pbp->pos = (void *)((char *)pbp->pos + padding); - } - - return NC_NOERR; -} - -/*----< hdr_put_NC_attr() >--------------------------------------------------*/ -inline static int -hdr_put_NC_attr(bufferinfo *pbp, - const NC_attr *attrp) -{ - /* netCDF file format: - * ... - * attr = name nc_type nelems [values ...] - * nc_type = NC_BYTE | NC_CHAR | NC_SHORT | ... - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int status; - - /* copy name */ - status = hdr_put_NC_name(pbp, attrp->name); - if (status != NC_NOERR) return status; - - /* copy nc_type */ - status = ncmpix_put_uint32((void**)(&pbp->pos), (uint)attrp->type); - if (status != NC_NOERR) return status; - - /* copy nelems */ - if (pbp->version < 5) { - if (attrp->nelems != (uint)attrp->nelems) - DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - status = ncmpix_put_uint32((void**)(&pbp->pos), (uint)attrp->nelems); - } - else - status = ncmpix_put_uint64((void**)(&pbp->pos), (uint64)attrp->nelems); - if (status != NC_NOERR) return status; - - /* copy [values ...] */ - status = hdr_put_NC_attrV(pbp, attrp); - if (status != NC_NOERR) return status; - - return NC_NOERR; -} - -/*----< hdr_put_NC_attrarray() >---------------------------------------------*/ -inline static int -hdr_put_NC_attrarray(bufferinfo *pbp, - const NC_attrarray *ncap) -{ - /* netCDF file format: - * ... - * att_list = ABSENT | NC_ATTRIBUTE nelems [attr ...] - * ABSENT = ZERO ZERO | // list is not present for CDF-1 and 2 - * ZERO ZERO64 // for CDF-5 - * ZERO = \x00 \x00 \x00 \x00 // 32-bit zero - * ZERO64 = \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 // 64-bit zero - * NC_ATTRIBUTE = \x00 \x00 \x00 \x0C // tag for list of attributes - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int i, status; - - assert(pbp != NULL); - - if (ncap == NULL || ncap->ndefined == 0) { /* ABSENT */ - status = ncmpix_put_uint32((void**)(&pbp->pos), NC_UNSPECIFIED); - if (status != NC_NOERR) return status; - - /* put a ZERO or ZERO64 depending on which CDF format */ - if (pbp->version < 5) - status = ncmpix_put_uint32((void**)(&pbp->pos), 0); - else - status = ncmpix_put_uint64((void**)(&pbp->pos), 0); - if (status != NC_NOERR) return status; - } - else { - /* copy NC_ATTRIBUTE */ - status = ncmpix_put_uint32((void**)(&pbp->pos), NC_ATTRIBUTE); - if (status != NC_NOERR) return status; - - /* copy nelems */ - if (pbp->version < 5) - status = ncmpix_put_uint32((void**)(&pbp->pos), (uint)ncap->ndefined); - else - status = ncmpix_put_uint64((void**)(&pbp->pos), (uint64)ncap->ndefined); - if (status != NC_NOERR) return status; - - /* copy [attr ...] */ - for (i=0; indefined; i++) { - status = hdr_put_NC_attr(pbp, ncap->value[i]); - if (status != NC_NOERR) return status; - } - } - - return NC_NOERR; -} - -/*----< hdr_put_NC_var() >---------------------------------------------------*/ -static int -hdr_put_NC_var(bufferinfo *pbp, - const NC_var *varp) -{ - /* netCDF file format: - * netcdf_file = header data - * header = magic numrecs dim_list gatt_list var_list - * ... - * var = name nelems [dimid ...] vatt_list nc_type vsize begin - * nelems = NON_NEG - * dimid = NON_NEG - * vatt_list = att_list - * nc_type = NC_BYTE | NC_CHAR | NC_SHORT | ... - * vsize = NON_NEG - * begin = OFFSET // Variable start location. - * OFFSET = | // CDF-1 - * // CDF-2 and CDF-5 - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int i, status; - - /* copy name */ - status = hdr_put_NC_name(pbp, varp->name); - if (status != NC_NOERR) return status; - - /* copy nelems */ - if (pbp->version < 5) - status = ncmpix_put_uint32((void**)(&pbp->pos), (uint)varp->ndims); - else - status = ncmpix_put_uint64((void**)(&pbp->pos), (uint64)varp->ndims); - if (status != NC_NOERR) return status; - - /* copy [dimid ...] */ - for (i=0; indims; i++) { - if (pbp->version < 5) - status = ncmpix_put_uint32((void**)(&pbp->pos), (uint)varp->dimids[i]); - else - status = ncmpix_put_uint64((void**)(&pbp->pos), (uint64)varp->dimids[i]); - if (status != NC_NOERR) return status; - } - - /* copy vatt_list */ - status = hdr_put_NC_attrarray(pbp, &varp->attrs); - if (status != NC_NOERR) return status; - - /* copy nc_type */ - status = ncmpix_put_uint32((void**)(&pbp->pos), (uint)varp->type); - if (status != NC_NOERR) return status; - - /* copy vsize */ - /* in CDF-1 and CDF-2, a variable's size in the header is a 32-bit integer - * in CDF-5, it is a 64-bit integer - */ - if (pbp->version < 5) { - /* Special case, when there is no record variable, the last fixed-size - * variable can be larger than 2 GiB if its file starting offset is - * less than 2 GiB. This checking has already been done in the call - * to ncmpio_NC_check_vlens() in ncmpio_NC_enddef(). - * - * if (varp->len != (int)varp->len) DEBUG_RETURN_ERROR(NC_EVARSIZE) - */ - uint vsize = (uint)varp->len; - if (varp->len > 4294967292LL) { /* 2^32 - 4 bytes */ - /* CDF-2 specification: use 2^32-1 for vsize when the variable - * size is larger than 2^32-4 bytes - */ - vsize = 4294967295U; - } - status = ncmpix_put_uint32((void**)(&pbp->pos), vsize); - } - else { - status = ncmpix_put_uint64((void**)(&pbp->pos), (uint64)varp->len); - } - if (status != NC_NOERR) return status; - - /* copy begin */ - /* in CDF-1 header, a variable's starting file offset is a 32-bit integer - * in CDF-2 and CDF-5, it is a 64-bit integer - */ - if (pbp->version == 1) { - if (varp->begin != (uint)varp->begin) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - status = ncmpix_put_uint32((void**)(&pbp->pos), (uint)varp->begin); - } - else - status = ncmpix_put_uint64((void**)(&pbp->pos), (uint64)varp->begin); - if (status != NC_NOERR) return status; - - return NC_NOERR; -} - -/*----< hdr_put_NC_vararray() >----------------------------------------------*/ -static int -hdr_put_NC_vararray(bufferinfo *pbp, - const NC_vararray *ncap) -{ - /* netCDF file format: - * netcdf_file = header data - * header = magic numrecs dim_list gatt_list var_list - * ... - * var_list = ABSENT | NC_VARIABLE nelems [var ...] - * ABSENT = ZERO ZERO | // list is not present for CDF-1 and 2 - * ZERO ZERO64 // for CDF-5 - * ZERO = \x00 \x00 \x00 \x00 // 32-bit zero - * ZERO64 = \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 // 64-bit zero - * NC_VARIABLE = \x00 \x00 \x00 \x0B // tag for list of variables - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int i, status; - - assert(pbp != NULL); - - if (ncap == NULL || ncap->ndefined == 0) { /* ABSENT */ - status = ncmpix_put_uint32((void**)(&pbp->pos), NC_UNSPECIFIED); - if (status != NC_NOERR) return status; - - /* put a ZERO or ZERO64 depending on which CDF format */ - if (pbp->version < 5) - status = ncmpix_put_uint32((void**)(&pbp->pos), 0); - else - status = ncmpix_put_uint64((void**)(&pbp->pos), 0); - if (status != NC_NOERR) return status; - } - else { - /* copy NC_VARIABLE */ - status = ncmpix_put_uint32((void**)(&pbp->pos), NC_VARIABLE); - if (status != NC_NOERR) return status; - - /* copy nelems */ - if (pbp->version < 5) - status = ncmpix_put_uint32((void**)(&pbp->pos), (uint)ncap->ndefined); - else - status = ncmpix_put_uint64((void**)(&pbp->pos), (uint64)ncap->ndefined); - if (status != NC_NOERR) return status; - - /* copy [var ...] */ - for (i=0; indefined; i++) { - status = hdr_put_NC_var(pbp, ncap->value[i]); - if (status != NC_NOERR) return status; - } - } - - return NC_NOERR; -} - -/*----< ncmpio_hdr_put_NC() >------------------------------------------------*/ -/* fill the file header into the I/O buffer, buf - * this function is collective */ -int -ncmpio_hdr_put_NC(NC *ncp, void *buf) -{ - int status; - bufferinfo putbuf; - MPI_Offset nrecs=0; - - putbuf.comm = ncp->comm; - putbuf.collective_fh = ncp->collective_fh; - putbuf.offset = 0; - putbuf.pos = buf; - putbuf.base = buf; - putbuf.size = ncp->xsz; - putbuf.safe_mode = ncp->safe_mode; - - /* netCDF file format: - * netcdf_file = header data - * header = magic numrecs dim_list gatt_list var_list - */ - - /* copy "magic", 4 characters */ - if (ncp->format == 5) { - putbuf.version = 5; - status = ncmpix_putn_text(&putbuf.pos, sizeof(ncmagic5), ncmagic5); - } - else if (ncp->format == 2) { - putbuf.version = 2; - status = ncmpix_putn_text(&putbuf.pos, sizeof(ncmagic2), ncmagic2); - } - else { - putbuf.version = 1; - status = ncmpix_putn_text(&putbuf.pos, sizeof(ncmagic1), ncmagic1); - } - if (status != NC_NOERR) return status; - - /* copy numrecs, number of records */ - nrecs = ncp->numrecs; - if (ncp->format < 5) { - if (nrecs != (uint)nrecs) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - status = ncmpix_put_uint32((void**)(&putbuf.pos), (uint)nrecs); - } - else { - status = ncmpix_put_uint64((void**)(&putbuf.pos), (uint64)nrecs); - } - if (status != NC_NOERR) return status; - - /* copy dim_list */ - status = hdr_put_NC_dimarray(&putbuf, &ncp->dims); - if (status != NC_NOERR) return status; - - /* copy gatt_list */ - status = hdr_put_NC_attrarray(&putbuf, &ncp->attrs); - if (status != NC_NOERR) return status; - - /* copy var_list */ - status = hdr_put_NC_vararray(&putbuf, &ncp->vars); - if (status != NC_NOERR) return status; - - return NC_NOERR; -} - -/*----< hdr_fetch() >--------------------------------------------------------*/ -/* Fetch the next header chunk. the chunk is 'gbp->size' bytes big - * Takes care to not overwrite leftover (unused) data in the buffer before - * fetching a new chunk: the current approach is to re-read the extra data. - * - * NOTE: An alternate approach (which we do not do) would be to save the old - * data, read the next chunk and then copy the old data into the new - * chunk. This alternate approach might help if it is important for - * reads to be aligned. - */ -static int -hdr_fetch(bufferinfo *gbp) { - int rank, err=NC_NOERR, mpireturn; - MPI_Offset slack; /* any leftover data in the buffer */ - MPI_Aint pos_addr, base_addr; - - assert(gbp->base != NULL); - -#ifdef HAVE_MPI_GET_ADDRESS - MPI_Get_address(gbp->pos, &pos_addr); - MPI_Get_address(gbp->base, &base_addr); -#else - MPI_Address(gbp->pos, &pos_addr); - MPI_Address(gbp->base, &base_addr); -#endif - slack = gbp->size - (pos_addr - base_addr); - /* . if gbp->pos and gbp->base are the same, there is no leftover buffer - * data to worry about. - * In the other extreme, where gbp->size == (gbp->pos - gbp->base), then - * all data in the buffer has been consumed */ - if (slack == gbp->size) slack = 0; - - if (gbp->size != (int)gbp->size) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - - memset(gbp->base, 0, (size_t)gbp->size); - gbp->pos = gbp->base; - - MPI_Comm_rank(gbp->comm, &rank); - if (rank == 0) { - MPI_Status mpistatus; - /* fileview is already entire file visible and MPI_File_read_at does - not change the file pointer */ - TRACE_IO(MPI_File_read_at)(gbp->collective_fh, - (gbp->offset)-slack, gbp->base, - (int)gbp->size, MPI_BYTE, &mpistatus); - if (mpireturn != MPI_SUCCESS) { - err = ncmpio_handle_error(mpireturn, "MPI_File_read_at"); - if (err == NC_EFILE) DEBUG_ASSIGN_ERROR(err, NC_EREAD) - } - else { - int get_size; /* actual read amount can be smaller */ - MPI_Get_count(&mpistatus, MPI_BYTE, &get_size); - gbp->get_size += get_size; - } - } - /* we might have to backtrack */ - gbp->offset += (gbp->size - slack); - - if (gbp->safe_mode == 1) { - TRACE_COMM(MPI_Bcast)(&err, 1, MPI_INT, 0, gbp->comm); - if (err != NC_NOERR) return err; - } - - /* broadcast root's read (full or partial header) to other processes */ - TRACE_COMM(MPI_Bcast)(gbp->base, (int)gbp->size, MPI_BYTE, 0, gbp->comm); - - return err; -} - -/*----< hdr_check_buffer() >--------------------------------------------------*/ -/* Ensure that 'nextread' bytes are available. */ -inline static int -hdr_check_buffer(bufferinfo *gbp, - MPI_Offset nextread) -{ - MPI_Aint pos_addr, base_addr; - -#ifdef HAVE_MPI_GET_ADDRESS - MPI_Get_address(gbp->pos, &pos_addr); - MPI_Get_address(gbp->base, &base_addr); -#else - MPI_Address(gbp->pos, &pos_addr); - MPI_Address(gbp->base, &base_addr); -#endif - if (pos_addr + nextread <= base_addr + gbp->size) - return NC_NOERR; - - return hdr_fetch(gbp); -} - -/*----< hdr_get_uint32() >---------------------------------------------------*/ -inline static int -hdr_get_uint32(bufferinfo *gbp, - uint *xp) -{ - /* in CDF-1 format, all integers are 32-bit - * in CDF-2 format, only variable begin (starting file offset) is 64-bit - * in CDF-5 format, both variable's begin and size are 64-bit - */ - int status = hdr_check_buffer(gbp, 4); /* size of int32 == 4 */ - if (status != NC_NOERR) return status; - - status = ncmpix_get_uint32((const void **)(&gbp->pos), xp); - return status; -} - -/*----< hdr_get_uint64() >---------------------------------------------------*/ -inline static int -hdr_get_uint64(bufferinfo *gbp, - uint64 *xp) -{ - /* in CDF-1 format, all integers are 32-bit - * in CDF-2 format, only variable begin (starting file offset) is 64-bit - * in CDF-5 format, both variable's begin and size are 64-bit - */ - int status = hdr_check_buffer(gbp, 8); /* size of int64 == 8 */ - if (status != NC_NOERR) return status; - - status = ncmpix_get_uint64((const void **)(&gbp->pos), xp); - return status; -} - -/*----< hdr_get_NC_tag() >----------------------------------------------------*/ -inline static int -hdr_get_NC_tag(bufferinfo *gbp, - NC_tag *tagp) -{ - /* NC_tag is 4-byte integer: NC_DIMENSION, NC_VARIABLE, NC_ATTRIBUTE */ - uint type = 0; - int status = hdr_check_buffer(gbp, 4); - if (status != NC_NOERR) return status; - - /* get an external unsigned 4-byte integer from the file */ - status = ncmpix_get_uint32((const void**)(&gbp->pos), &type); - if (status != NC_NOERR) return status; - - *tagp = (NC_tag) type; - return NC_NOERR; -} - -/*----< hdr_get_nc_type() >---------------------------------------------------*/ -inline static int -hdr_get_nc_type(bufferinfo *gbp, - nc_type *typep) -{ - /* nc_type is 4-byte integer, X_SIZEOF_INT */ - int status; - uint type; - - status = hdr_check_buffer(gbp, X_SIZEOF_INT); - if (status != NC_NOERR) return status; - - status = ncmpix_get_uint32((const void**)(&gbp->pos), &type); - if (status != NC_NOERR) return status; - - if (type != NC_CHAR && - type != NC_BYTE && - type != NC_UBYTE && - type != NC_SHORT && - type != NC_USHORT && - type != NC_INT && - type != NC_UINT && - type != NC_FLOAT && - type != NC_DOUBLE && - type != NC_INT64 && - type != NC_UINT64 - ) - DEBUG_RETURN_ERROR(NC_EBADTYPE) - - *typep = (nc_type) type; - return NC_NOERR; -} - -/*----< hdr_get_NC_name() >---------------------------------------------------*/ -static int -hdr_get_NC_name(bufferinfo *gbp, - NC_string **ncstrpp) -{ - /* netCDF file format: - * ... - * name = nelems namestring - * nelems = NON_NEG - * namestring = ID1 [IDN ...] padding - * ID1 = alphanumeric | '_' - * IDN = alphanumeric | special1 | special2 - * padding = <0, 1, 2, or 3 bytes to next 4-byte boundary> - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int err; - char *cpos; - NC_string *ncstrp; - MPI_Aint pos_addr, base_addr; - MPI_Offset nchars, nbytes, padding, bufremain, strcount; - - /* get nelems */ - if (gbp->version < 5) { - uint tmp; - err = hdr_get_uint32(gbp, &tmp); - nchars = (MPI_Offset)tmp; - } - else { - uint64 tmp; - err = hdr_get_uint64(gbp, &tmp); - nchars = (MPI_Offset)tmp; - } - if (err != NC_NOERR) return err; - - /* Allocate a NC_string structure large enough to hold nchars characters */ - ncstrp = ncmpio_new_NC_string((size_t)nchars, NULL); - if (ncstrp == NULL) DEBUG_RETURN_ERROR(NC_ENOMEM) - - nbytes = nchars * X_SIZEOF_CHAR; - padding = _RNDUP(X_SIZEOF_CHAR * ncstrp->nchars, X_ALIGN) - - X_SIZEOF_CHAR * ncstrp->nchars; -#ifdef HAVE_MPI_GET_ADDRESS - MPI_Get_address(gbp->pos, &pos_addr); - MPI_Get_address(gbp->base, &base_addr); -#else - MPI_Address(gbp->pos, &pos_addr); - MPI_Address(gbp->base, &base_addr); -#endif - bufremain = gbp->size - (pos_addr - base_addr); - cpos = ncstrp->cp; - - /* get namestring with padding */ - while (nbytes > 0) { - if (bufremain > 0) { - strcount = MIN(bufremain, nbytes); - if (strcount != (size_t)strcount) - DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - memcpy(cpos, gbp->pos, (size_t)strcount); - nbytes -= strcount; - gbp->pos = (void *)((char *)gbp->pos + strcount); - cpos += strcount; - bufremain -= strcount; - } else { - err = hdr_fetch(gbp); - if (err != NC_NOERR) { - ncmpio_free_NC_string(ncstrp); - return err; - } - bufremain = gbp->size; - } - } - - /* handle the padding */ - if (padding > 0) { - /* CDF specification: Header padding uses null (\x00) bytes. */ - char pad[X_ALIGN-1]; - memset(pad, 0, X_ALIGN-1); - if (memcmp(gbp->pos, pad, (size_t)padding) != 0) { -#ifdef PNETCDF_DEBUG - fprintf(stderr,"Error in file %s func %s line %d: NetCDF header non-zero padding found\n",__FILE__,__func__,__LINE__); -#endif - ncmpio_free_NC_string(ncstrp); - DEBUG_RETURN_ERROR(NC_EINVAL) - } - gbp->pos = (void *)((char *)gbp->pos + padding); - } - - *ncstrpp = ncstrp; - - return NC_NOERR; -} - -/*----< hdr_get_NC_dim() >----------------------------------------------------*/ -inline static int -hdr_get_NC_dim(bufferinfo *gbp, - NC_dim **dimpp) -{ - /* netCDF file format: - * ... - * dim = name dim_length - * dim_length = NON_NEG - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int status; - NC_string *ncstrp; - NC_dim *dimp; - - /* get name */ - status = hdr_get_NC_name(gbp, &ncstrp); - if (status != NC_NOERR) return status; - - dimp = ncmpio_new_x_NC_dim(ncstrp); - if (dimp == NULL) DEBUG_RETURN_ERROR(NC_ENOMEM) - - /* get dim_length */ - if (gbp->version < 5) { - uint tmp; - status = hdr_get_uint32(gbp, &tmp); - dimp->size = (MPI_Offset)tmp; - } - else { - uint64 tmp; - status = hdr_get_uint64(gbp, &tmp); - dimp->size = (MPI_Offset)tmp; - } - if (status != NC_NOERR) { - ncmpio_free_NC_dim(dimp); /* frees dim */ - return status; - } - - *dimpp = dimp; - return NC_NOERR; -} - -/*----< hdr_get_NC_dimarray() >-----------------------------------------------*/ -static int -hdr_get_NC_dimarray(bufferinfo *gbp, - NC_dimarray *ncap) -{ - /* netCDF file format: - * ... - * dim_list = ABSENT | NC_DIMENSION nelems [dim ...] - * ABSENT = ZERO ZERO | // list is not present for CDF-1 and 2 - * ZERO ZERO64 // for CDF-5 - * ZERO = \x00 \x00 \x00 \x00 // 32-bit zero - * ZERO64 = \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 // 64-bit zero - * NC_DIMENSION = \x00 \x00 \x00 \x0A // tag for list of dimensions - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int i, status; - NC_tag tag = NC_UNSPECIFIED; - MPI_Offset ndefined; - - assert(gbp != NULL && gbp->pos != NULL); - assert(ncap != NULL); - assert(ncap->value == NULL); - - /* get NC_tag (NC_DIMENSION) */ - status = hdr_get_NC_tag(gbp, &tag); - if (status != NC_NOERR) return status; - - /* get nelems */ - if (gbp->version < 5) { - uint tmp; - status = hdr_get_uint32(gbp, &tmp); - ndefined = (MPI_Offset)tmp; - } - else { - uint64 tmp; - status = hdr_get_uint64(gbp, &tmp); - ndefined = (MPI_Offset)tmp; - } - if (status != NC_NOERR) return status; - if (ndefined != (int)ndefined) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - ncap->ndefined = (int)ndefined; - /* TODO: we should allow ndefined > 2^32, considering change the data type - * of ndefined from int to MPI_Offset */ - - ncap->unlimited_id = -1; - - if (ndefined == 0) { - if (tag != NC_DIMENSION && tag != NC_UNSPECIFIED) { -#ifdef PNETCDF_DEBUG - fprintf(stderr,"Error in file %s func %s line %d: NetCDF header format for NC_DIMENSION\n",__FILE__,__func__,__LINE__); -#endif - DEBUG_RETURN_ERROR(NC_EINVAL) - } - } else { - if (tag != NC_DIMENSION) { -#ifdef PNETCDF_DEBUG - fprintf(stderr,"Error in file %s func %s line %d: NetCDF header format for NC_DIMENSION\n",__FILE__,__func__,__LINE__); -#endif - DEBUG_RETURN_ERROR(NC_EINVAL) - } - - ncap->value = (NC_dim**) NCI_Malloc((size_t)ndefined * sizeof(NC_dim*)); - if (ncap->value == NULL) DEBUG_RETURN_ERROR(NC_ENOMEM) - ncap->nalloc = (int)ndefined; - /* TODO: we should allow nalloc > 2^32, considering change the data - * type of nalloc from int to MPI_Offset */ - - for (i=0; ivalue + i); - if (status != NC_NOERR) { /* error: fail to get the next dim */ - ncap->ndefined = i; - ncmpio_free_NC_dimarray(ncap); - return status; - } - if (ncap->value[i]->size == NC_UNLIMITED) - ncap->unlimited_id = i; /* ID of unlimited dimension */ - } - } - return NC_NOERR; -} - -/*----< hdr_get_NC_attrV() >--------------------------------------------------*/ -static int -hdr_get_NC_attrV(bufferinfo *gbp, - NC_attr *attrp) -{ - /* netCDF file format: - * ... - * attr = name nc_type nelems [values ...] - * ... - * values = bytes | chars | shorts | ints | floats | doubles - * bytes = [BYTE ...] padding - * chars = [CHAR ...] padding - * shorts = [SHORT ...] padding - * ints = [INT ...] - * floats = [FLOAT ...] - * doubles = [DOUBLE ...] - * padding = <0, 1, 2, or 3 bytes to next 4-byte boundary> - */ - void *value = attrp->xvalue; - MPI_Offset nbytes, padding, bufremain, attcount; - MPI_Aint pos_addr, base_addr; - - nbytes = attrp->nelems * ncmpio_xlen_nc_type(attrp->type); - padding = attrp->xsz - nbytes; -#ifdef HAVE_MPI_GET_ADDRESS - MPI_Get_address(gbp->pos, &pos_addr); - MPI_Get_address(gbp->base, &base_addr); -#else - MPI_Address(gbp->pos, &pos_addr); - MPI_Address(gbp->base, &base_addr); -#endif - bufremain = gbp->size - (pos_addr - base_addr); - - /* get values */ - while (nbytes > 0) { - if (bufremain > 0) { - attcount = MIN(bufremain, nbytes); - if (attcount != (size_t)attcount) - DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - memcpy(value, gbp->pos, (size_t)attcount); - nbytes -= attcount; - gbp->pos = (void *)((char *)gbp->pos + attcount); - value = (void *)((char *)value + attcount); - bufremain -= attcount; - } else { - int err; - err = hdr_fetch(gbp); - if (err != NC_NOERR) return err; - bufremain = gbp->size; - } - } - - /* handle the padding */ - if (padding > 0) { - /* CDF specification: Header padding uses null (\x00) bytes. */ - char pad[X_ALIGN-1]; - memset(pad, 0, X_ALIGN-1); - if (memcmp(gbp->pos, pad, (size_t)padding) != 0) { -#ifdef PNETCDF_DEBUG - fprintf(stderr,"Error in file %s func %s line %d: NetCDF header non-zero padding found\n",__FILE__,__func__,__LINE__); -#endif - DEBUG_RETURN_ERROR(NC_EINVAL) - } - gbp->pos = (void *)((char *)gbp->pos + padding); - } - return NC_NOERR; -} - -/*----< hdr_get_NC_attr() >---------------------------------------------------*/ -static int -hdr_get_NC_attr(bufferinfo *gbp, - NC_attr **attrpp) -{ - /* netCDF file format: - * ... - * attr = name nc_type nelems [values ...] - * nc_type = NC_BYTE | NC_CHAR | NC_SHORT | ... - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int status; - NC_string *strp; - nc_type type; - MPI_Offset nelems; - NC_attr *attrp; - - /* get name */ - status = hdr_get_NC_name(gbp, &strp); - if (status != NC_NOERR) return status; - - /* get nc_type */ - status = hdr_get_nc_type(gbp, &type); - if (status != NC_NOERR) { - ncmpio_free_NC_string(strp); - return status; - } - - /* get nelems */ - if (gbp->version < 5) { - uint tmp; - status = hdr_get_uint32(gbp, &tmp); - nelems = (MPI_Offset)tmp; - } - else { - uint64 tmp; - status = hdr_get_uint64(gbp, &tmp); - nelems = (MPI_Offset)tmp; - } - if (status != NC_NOERR) { - ncmpio_free_NC_string(strp); - return status; - } - - /* allocate space for attribute object */ - attrp = ncmpio_new_x_NC_attr(strp, type, nelems); - if (attrp == NULL) { - ncmpio_free_NC_string(strp); - return status; - } - - /* get [values ...] */ - status = hdr_get_NC_attrV(gbp, attrp); - if (status != NC_NOERR) { - ncmpio_free_NC_attr(attrp); - return status; - } - - *attrpp = attrp; - return NC_NOERR; -} - -/*----< hdr_get_NC_attrarray() >----------------------------------------------*/ -static int -hdr_get_NC_attrarray(bufferinfo *gbp, - NC_attrarray *ncap) -{ - /* netCDF file format: - * ... - * att_list = ABSENT | NC_ATTRIBUTE nelems [attr ...] - * ABSENT = ZERO ZERO | // list is not present for CDF-1 and 2 - * ZERO ZERO64 // for CDF-5 - * ZERO = \x00 \x00 \x00 \x00 // 32-bit zero - * ZERO64 = \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 // 64-bit zero - * NC_ATTRIBUTE = \x00 \x00 \x00 \x0C // tag for list of attributes - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int i, status; - NC_tag tag = NC_UNSPECIFIED; - MPI_Offset ndefined; - - assert(gbp != NULL && gbp->pos != NULL); - assert(ncap != NULL); - assert(ncap->value == NULL); - - /* get NC_tag (NC_ATTRIBUTE) */ - status = hdr_get_NC_tag(gbp, &tag); - if (status != NC_NOERR) return status; - - /* get nelems */ - if (gbp->version < 5) { - uint tmp; - status = hdr_get_uint32(gbp, &tmp); - ndefined = (MPI_Offset)tmp; - } - else { - uint64 tmp; - status = hdr_get_uint64(gbp, &tmp); - ndefined = (MPI_Offset)tmp; - } - if (status != NC_NOERR) return status; - if (ndefined != (int)ndefined) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - ncap->ndefined = (int)ndefined; - - if (ndefined == 0) { - if (tag != NC_ATTRIBUTE && tag != NC_UNSPECIFIED) { -#ifdef PNETCDF_DEBUG - fprintf(stderr,"Error in file %s func %s line %d: NetCDF header format for NC_ATTRIBUTE\n",__FILE__,__func__,__LINE__); -#endif - DEBUG_RETURN_ERROR(NC_EINVAL) - } - } else { - if (tag != NC_ATTRIBUTE) { -#ifdef PNETCDF_DEBUG - fprintf(stderr,"Error in file %s func %s line %d: NetCDF header format for NC_ATTRIBUTE\n",__FILE__,__func__,__LINE__); -#endif - DEBUG_RETURN_ERROR(NC_EINVAL) - } - - ncap->value = (NC_attr**)NCI_Malloc((size_t)ndefined *sizeof(NC_attr*)); - if (ncap->value == NULL) DEBUG_RETURN_ERROR(NC_ENOMEM) - ncap->nalloc = (int)ndefined; - - /* get [attr ...] */ - for (i=0; ivalue + i); - if (status != NC_NOERR) { /* Error: fail to get the next att */ - ncap->ndefined = i; - ncmpio_free_NC_attrarray(ncap); - return status; - } - } - } - return NC_NOERR; -} - -/*----< hdr_get_NC_var() >---------------------------------------------------*/ -static int -hdr_get_NC_var(bufferinfo *gbp, - NC_var **varpp) -{ - /* netCDF file format: - * netcdf_file = header data - * header = magic numrecs dim_list gatt_list var_list - * ... - * var = name nelems [dimid ...] vatt_list nc_type vsize begin - * nelems = NON_NEG - * dimid = NON_NEG - * vatt_list = att_list - * nc_type = NC_BYTE | NC_CHAR | NC_SHORT | ... - * vsize = NON_NEG - * begin = OFFSET // Variable start location. - * OFFSET = | // CDF-1 - * // CDF-2 and CDF-5 - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int status; - NC_string *strp; - MPI_Offset ndims=0, dim; - MPI_Offset tmp_dimids=0; - NC_var *varp; - - /* get name */ - status = hdr_get_NC_name(gbp, &strp); - if (status != NC_NOERR) return status; - - /* nelems */ - if (gbp->version < 5) { - uint tmp; - status = hdr_get_uint32(gbp, &tmp); - ndims = (MPI_Offset)tmp; - } - else { - uint64 tmp; - status = hdr_get_uint64(gbp, &tmp); - ndims = (MPI_Offset)tmp; - } - if (status != NC_NOERR) { - ncmpio_free_NC_string(strp); - return status; - } - if (ndims != (int)ndims) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - - /* allocate space for var object */ - varp = ncmpio_new_x_NC_var(strp, (int)ndims); - if (varp == NULL) { - ncmpio_free_NC_string(strp); - DEBUG_RETURN_ERROR(NC_ENOMEM) - } - - /* get [dimid ...] */ - for (dim=0; dimversion < 5 ? 4 : 8)); - if (status != NC_NOERR) { - ncmpio_free_NC_var(varp); - return status; - } - if (gbp->version < 5) { - uint tmp; - status = hdr_get_uint32(gbp, &tmp); - tmp_dimids = (MPI_Offset)tmp; - } - else { - uint64 tmp; - status = hdr_get_uint64(gbp, &tmp); - tmp_dimids = (MPI_Offset)tmp; - } - /* TODO: consider change the data type of dimids from int to - * MPI_Offset */ - varp->dimids[dim] = (int)tmp_dimids; - if (status != NC_NOERR) { - return status; - } - } - - /* get vatt_list */ - status = hdr_get_NC_attrarray(gbp, &varp->attrs); - if (status != NC_NOERR) { - ncmpio_free_NC_var(varp); - return status; - } - - /* get nc_type */ - status = hdr_get_nc_type(gbp, &varp->type); - if (status != NC_NOERR) { - ncmpio_free_NC_var(varp); - return status; - } - - /* get vsize */ - if (gbp->version < 5) { - uint tmp; - status = hdr_get_uint32(gbp, &tmp); - varp->len = (MPI_Offset)tmp; - } - else { - uint64 tmp; - status = hdr_get_uint64(gbp, &tmp); - varp->len = (MPI_Offset)tmp; - } - if (status != NC_NOERR) { - ncmpio_free_NC_var(varp); - return status; - } - /* As described in CDF-2 format specification, vsize is redundant. - Its value may be computed from the product of dimension lengths. - In CDF-2, vsize is a 4-byte integer. So, if we define a variable of - less than 2^32 elements but size > 2^32-4 bytes, then vsize in CDF-2 - will overflow. Recompute varp->len can ignore an overflowed value in - vsize stored in the file and hence bypass the limitation of CDF-2 on - variable size of 2^32-4 bytes. - - Later on, back to ncmpio_hdr_get_NC(), compute_var_shape() is - called which recomputes varp->len using the dimension values and hence - overwrites the value read from file above. - - In summary, PnetCDF now ignores the value of vsize stored in the file - header. - */ - - /* next element is 'begin' */ - status = hdr_check_buffer(gbp, (gbp->version == 1 ? 4 : 8)); - if (status != NC_NOERR) { - ncmpio_free_NC_var(varp); - return status; - } - - /* get begin */ - if (gbp->version == 1) { - uint tmp=0; - status = ncmpix_get_uint32((const void **)(&gbp->pos), &tmp); - varp->begin = (MPI_Offset)tmp; - } - else { - uint64 tmp=0; - status = ncmpix_get_uint64((const void **)(&gbp->pos), &tmp); - varp->begin = (MPI_Offset)tmp; - } - if (status != NC_NOERR) { - ncmpio_free_NC_var(varp); - return status; - } - - *varpp = varp; - return NC_NOERR; -} - -/*----< hdr_get_NC_vararray() >----------------------------------------------*/ -static int -hdr_get_NC_vararray(bufferinfo *gbp, - NC_vararray *ncap) -{ - /* netCDF file format: - * netcdf_file = header data - * header = magic numrecs dim_list gatt_list var_list - * ... - * var_list = ABSENT | NC_VARIABLE nelems [var ...] - * ABSENT = ZERO ZERO | // list is not present for CDF-1 and 2 - * ZERO ZERO64 // for CDF-5 - * ZERO = \x00 \x00 \x00 \x00 // 32-bit zero - * ZERO64 = \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 // 64-bit zero - * NC_VARIABLE = \x00 \x00 \x00 \x0B // tag for list of variables - * nelems = NON_NEG // number of elements in following sequence - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - int i, status; - NC_tag tag = NC_UNSPECIFIED; - MPI_Offset ndefined; - - assert(gbp != NULL && gbp->pos != NULL); - assert(ncap != NULL); - assert(ncap->value == NULL); - - /* get NC_tag (NC_VARIABLE) from gbp buffer */ - status = hdr_get_NC_tag(gbp, &tag); - if (status != NC_NOERR) return status; - - /* get nelems (number of variables) from gbp buffer */ - if (gbp->version < 5) { - uint tmp; - status = hdr_get_uint32(gbp, &tmp); - ndefined = (MPI_Offset)tmp; - } - else { - uint64 tmp; - status = hdr_get_uint64(gbp, &tmp); - ndefined = (MPI_Offset)tmp; - } - if (status != NC_NOERR) return status; - if (ndefined != (int)ndefined) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - ncap->ndefined = (int)ndefined; - /* TODO: we should allow ndefined > 2^32, considering change the data type - * of ndefined from int to MPI_Offset */ - - if (ndefined == 0) { /* no variable defined */ - if (tag != NC_VARIABLE && tag != NC_UNSPECIFIED) { -#ifdef PNETCDF_DEBUG - fprintf(stderr,"Error in file %s func %s line %d: NetCDF header format for NC_VARIABLE\n",__FILE__,__func__,__LINE__); -#endif - DEBUG_RETURN_ERROR(NC_EINVAL) - } - } else { - if (tag != NC_VARIABLE) { -#ifdef PNETCDF_DEBUG - fprintf(stderr,"Error in file %s func %s line %d: NetCDF header format for NC_VARIABLE\n",__FILE__,__func__,__LINE__); -#endif - DEBUG_RETURN_ERROR(NC_EINVAL) - } - - ncap->value = (NC_var**) NCI_Malloc((size_t)ndefined * sizeof(NC_var*)); - if (ncap->value == NULL) DEBUG_RETURN_ERROR(NC_ENOMEM) - ncap->nalloc = (int)ndefined; - - /* get [var ...] */ - for (i=0; ivalue + i); - ncap->value[i]->varid = i; - if (status != NC_NOERR) { /* Error: fail to get the next var */ - ncap->ndefined = i; - ncmpio_free_NC_vararray(ncap); - return status; - } - } - } - - return NC_NOERR; -} - -/*----< ncmpio_hdr_len_NC() >------------------------------------------------*/ -MPI_Offset -ncmpio_hdr_len_NC(const NC *ncp) -{ - /* netCDF file format: - * netcdf_file = header data - * header = magic numrecs dim_list gatt_list var_list - * ... - * numrecs = NON_NEG | STREAMING // length of record dimension - * NON_NEG = | // CDF-1 and CDF-2 - * // CDF-5 - */ - - int sizeof_NON_NEG, sizeof_off_t; - MPI_Offset xlen; - - assert(ncp != NULL); - - if (ncp->format == 5) { /* CDF-5 */ - sizeof_NON_NEG = X_SIZEOF_INT64; /* 8-byte integer for all integers */ - sizeof_off_t = X_SIZEOF_INT64; /* 8-byte integer for var begin */ - } - else if (ncp->format == 2) { /* CDF-2 */ - sizeof_NON_NEG = X_SIZEOF_INT; /* 4-byte integer in CDF-1 */ - sizeof_off_t = X_SIZEOF_INT64; /* 8-byte integer for var begin */ - } - else { /* CDF-1 */ - sizeof_NON_NEG = X_SIZEOF_INT; /* 4-byte integer in CDF-1 */ - sizeof_off_t = X_SIZEOF_INT; /* 4-byte integer in CDF-1 */ - } - - xlen = sizeof(ncmagic1); /* magic */ - xlen += sizeof_NON_NEG; /* numrecs */ - xlen += hdr_len_NC_dimarray(&ncp->dims, sizeof_NON_NEG); /* dim_list */ - xlen += hdr_len_NC_attrarray(&ncp->attrs, sizeof_NON_NEG); /* gatt_list */ - xlen += hdr_len_NC_vararray(&ncp->vars, sizeof_NON_NEG, sizeof_off_t); /* var_list */ - - return xlen; /* return the header size (not yet aligned) */ -} - -/*----< ncmpio_hdr_get_NC() >------------------------------------------------*/ -/* CDF format specification - * netcdf_file = header data - * header = magic numrecs dim_list gatt_list var_list - * magic = 'C' 'D' 'F' VERSION - * VERSION = \x01 | // classic format - * \x02 | // 64-bit offset format - * \x05 // 64-bit data format - * numrecs = NON_NEG | STREAMING // length of record dimension - * dim_list = ABSENT | NC_DIMENSION nelems [dim ...] - * gatt_list = att_list // global attributes - * att_list = ABSENT | NC_ATTRIBUTE nelems [attr ...] - * var_list = ABSENT | NC_VARIABLE nelems [var ...] - */ -int -ncmpio_hdr_get_NC(NC *ncp) -{ - int status; - bufferinfo getbuf; - char magic[sizeof(ncmagic1)]; - MPI_Offset nrecs = 0; - MPI_Aint pos_addr, base_addr; - - assert(ncp != NULL); - - /* Initialize the get buffer that stores the header read from the file */ - getbuf.comm = ncp->comm; - getbuf.collective_fh = ncp->collective_fh; - getbuf.get_size = 0; - getbuf.offset = 0; /* read from start of the file */ - getbuf.safe_mode = ncp->safe_mode; - - /* CDF-5's minimum header size is 4 bytes more than CDF-1 and CDF-2's */ - getbuf.size = _RNDUP( MAX(MIN_NC_XSZ+4, ncp->chunk), X_ALIGN ); - - if (getbuf.size != (size_t)getbuf.size) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - getbuf.pos = getbuf.base = (void *)NCI_Malloc((size_t)getbuf.size); - - /* Fetch the next header chunk. The chunk is 'gbp->size' bytes big */ - status = hdr_fetch(&getbuf); - if (status != NC_NOERR) return status; - - /* processing the header from getbuf, the get buffer */ - - /* First get the file format information, magic */ - memset(magic, 0, sizeof(magic)); - status = ncmpix_getn_text((const void **)(&getbuf.pos), sizeof(magic), - magic); - if (status != NC_NOERR) return status; - - /* check if the first three bytes are 'C','D','F' */ - if (memcmp(magic, ncmagic1, sizeof(ncmagic1)-1) != 0) { - /* check if is HDF5 file */ - char signature[8], *hdf5_signature="\211HDF\r\n\032\n"; - memcpy(signature, magic, 4); - ncmpix_getn_text((const void **)(&getbuf.pos), 4, signature+4); - if (memcmp(signature, hdf5_signature, 8) == 0) { - DEBUG_ASSIGN_ERROR(status, NC_ENOTNC3) - if (ncp->safe_mode) - fprintf(stderr,"Error: file %s is HDF5 format\n",ncp->path); - } - else - DEBUG_ASSIGN_ERROR(status, NC_ENOTNC) - goto fn_exit; - } - - /* check version number in last byte of magic */ - if (magic[sizeof(ncmagic1)-1] == 0x1) { - getbuf.version = ncp->format = 1; - } else if (magic[sizeof(ncmagic1)-1] == 0x2) { - getbuf.version = ncp->format = 2; -#if SIZEOF_MPI_OFFSET < 8 - /* take the easy way out: if we can't support all CDF-2 - * files, return immediately */ - NCI_Free(getbuf.base); - DEBUG_RETURN_ERROR(NC_ESMALL) -#endif - } else if (magic[sizeof(ncmagic1)-1] == 0x5) { - getbuf.version = ncp->format = 5; -#if SIZEOF_MPI_OFFSET < 8 - NCI_Free(getbuf.base); - DEBUG_RETURN_ERROR(NC_ESMALL) -#endif - } else { - NCI_Free(getbuf.base); - DEBUG_RETURN_ERROR(NC_ENOTNC) /* not a netCDF file */ - } - - /** Ensure that 'nextread' bytes (numrecs) are available. */ - status = hdr_check_buffer(&getbuf, (getbuf.version < 5) ? 4 : 8); - if (status != NC_NOERR) goto fn_exit; - - /* get numrecs from getbuf into ncp */ - if (getbuf.version < 5) { - uint tmp=0; - status = ncmpix_get_uint32((const void **)(&getbuf.pos), &tmp); - nrecs = (MPI_Offset)tmp; - } - else { - uint64 tmp=0; - status = ncmpix_get_uint64((const void **)(&getbuf.pos), &tmp); - nrecs = (MPI_Offset)tmp; - } - if (status != NC_NOERR) goto fn_exit; - - ncp->numrecs = nrecs; - -#ifdef HAVE_MPI_GET_ADDRESS - MPI_Get_address(getbuf.pos, &pos_addr); - MPI_Get_address(getbuf.base, &base_addr); -#else - MPI_Address(getbuf.pos, &pos_addr); - MPI_Address(getbuf.base, &base_addr); -#endif - assert(pos_addr < base_addr + getbuf.size); - - /* get dim_list from getbuf into ncp */ - status = hdr_get_NC_dimarray(&getbuf, &ncp->dims); - if (status != NC_NOERR) goto fn_exit; - - /* get gatt_list from getbuf into ncp */ - status = hdr_get_NC_attrarray(&getbuf, &ncp->attrs); - if (status != NC_NOERR) goto fn_exit; - - /* get var_list from getbuf into ncp */ - status = hdr_get_NC_vararray(&getbuf, &ncp->vars); - if (status != NC_NOERR) goto fn_exit; - - /* get the un-aligned size occupied by the file header */ - ncp->xsz = ncmpio_hdr_len_NC(ncp); - - /* Recompute the shapes of all variables - * Sets ncp->begin_var to start of first variable. - * Sets ncp->begin_rec to start of first record variable. - */ - status = compute_var_shape(ncp); - if (status != NC_NOERR) goto fn_exit; - - status = ncmpio_NC_check_vlens(ncp); - if (status != NC_NOERR) goto fn_exit; - -fn_exit: - ncp->get_size += getbuf.get_size; - NCI_Free(getbuf.base); - - return status; -} - -/*----< ncmpio_write_header() >---------------------------------------------*/ -/* This function is collective (even in independent data mode). - * It is called only in data mode (collective or independent) and by - * 1. ncmpi_rename_att() - * 2. ncmpi_copy_att() - * 3. ncmpi_put_att() - * 4. ncmpi_rename_dim() - * 5. ncmpi_rename_var() - */ -int ncmpio_write_header(NC *ncp) -{ - int rank, status=NC_NOERR, mpireturn, err; - MPI_File fh; - - /* Write the entire header to the file. This function may be called from - * a rename API. In that case, we cannot just change the variable name in - * the file header, because if the file space occupied by the name shrinks, - * all metadata following the new name must be moved ahead. - */ - - fh = ncp->collective_fh; - if (NC_indep(ncp)) - fh = ncp->independent_fh; - - /* update file header size, as this subroutine may be called from a rename - * API (var or attribute) and the new name is smaller/bigger which changes - * the header size. We recalculate ncp->xsz by getting the un-aligned size - * occupied by the file header */ - ncp->xsz = ncmpio_hdr_len_NC(ncp); - - MPI_Comm_rank(ncp->comm, &rank); - if (rank == 0) { /* only root writes to file header */ - MPI_Status mpistatus; - void *buf = NCI_Malloc((size_t)ncp->xsz); /* header's write buffer */ - - /* copy header object to write buffer */ - status = ncmpio_hdr_put_NC(ncp, buf); - - if (ncp->xsz != (int)ncp->xsz) { - NCI_Free(buf); - DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - } - TRACE_IO(MPI_File_write_at)(fh, 0, buf, (int)ncp->xsz, MPI_BYTE, &mpistatus); - if (mpireturn != MPI_SUCCESS) { - err = ncmpio_handle_error(mpireturn, "MPI_File_write_at"); - if (status == NC_NOERR) { - err = (err == NC_EFILE) ? NC_EWRITE : err; - DEBUG_ASSIGN_ERROR(status, err) - } - } - else { - ncp->put_size += ncp->xsz; - } - NCI_Free(buf); - } - - if (ncp->safe_mode == 1) { - /* broadcast root's status, because only root writes to the file */ - int root_status = status; - TRACE_COMM(MPI_Bcast)(&root_status, 1, MPI_INT, 0, ncp->comm); - /* root's write has failed, which is serious */ - if (root_status == NC_EWRITE) DEBUG_ASSIGN_ERROR(status, NC_EWRITE) - if (mpireturn != MPI_SUCCESS) { - ncmpio_handle_error(mpireturn,"MPI_Bcast"); - DEBUG_RETURN_ERROR(NC_EMPI) - } - } - - if (NC_doFsync(ncp)) { /* NC_SHARE is set */ - TRACE_IO(MPI_File_sync)(fh); - if (mpireturn != MPI_SUCCESS) { - ncmpio_handle_error(mpireturn,"MPI_File_sync"); - DEBUG_RETURN_ERROR(NC_EMPI) - } - TRACE_COMM(MPI_Barrier)(ncp->comm); - if (mpireturn != MPI_SUCCESS) { - ncmpio_handle_error(mpireturn,"MPI_Barrier"); - DEBUG_RETURN_ERROR(NC_EMPI) - } - } - - return status; -} - diff --git a/src/drivers/ncmpio/Legacy/m_getput_varx.m4 b/src/drivers/ncmpio/Legacy/m_getput_varx.m4 deleted file mode 100644 index 900418ec7..000000000 --- a/src/drivers/ncmpio/Legacy/m_getput_varx.m4 +++ /dev/null @@ -1,1093 +0,0 @@ -dnl Process this m4 file to produce 'C' language file. -dnl -dnl If you see this line, you can ignore the next one. -/* Do not edit this file. It is produced from the corresponding .m4 source */ -dnl -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#include - -#include - -#include -#include -#include "ncx.h" -#include "ncmpidtype.h" - - -/* buffer layers: - - User Level buf (user defined buffer of MPI_Datatype) - MPI Datatype Level cbuf (contiguous buffer of ptype) - NetCDF XDR Level xbuf (XDR I/O buffer) -*/ - -static int -ncmpio_mgetput_varm(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[], /* [num] */ - int rw_flag, /* WRITE_REQ or READ_REQ */ - int io_method); /* COLL_IO or INDEP_IO */ - -/*----< ncmpi_mput_var() >---------------------------------------------------*/ -int -ncmpi_mput_var(int ncid, - int num, - int varids[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, NULL, NULL, NULL, - NULL, bufs, bufcounts, datatypes, - WRITE_REQ, INDEP_IO); -} - -/*----< ncmpi_mput_var_all() >-----------------------------------------------*/ -int -ncmpi_mput_var_all(int ncid, - int num, - int varids[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, NULL, NULL, NULL, - NULL, bufs, bufcounts, datatypes, - WRITE_REQ, COLL_IO); -} - -dnl -dnl MPUT_VAR(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`MPUT_VAR',dnl -`dnl -/*----< ncmpi_mput_var_$1$5() >-----------------------------------------------*/ -int -ncmpi_mput_var_$1$5(int ncid, - int num, - int varids[], - $2 *bufs[]) -{ - int i, err; - MPI_Datatype *datatypes; - - datatypes = (MPI_Datatype*) NCI_Malloc((size_t)num * sizeof(MPI_Datatype)); - for (i=0; i--------------------------------------------------*/ -int -ncmpi_mput_var1(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, NULL, NULL, - NULL, bufs, bufcounts, datatypes, - WRITE_REQ, INDEP_IO); -} - -/*----< ncmpi_mput_var1_all() >----------------------------------------------*/ -int -ncmpi_mput_var1_all(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, NULL, NULL, - NULL, bufs, bufcounts, datatypes, - WRITE_REQ, COLL_IO); -} - -dnl -dnl MPUT_VAR1(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`MPUT_VAR1',dnl -`dnl -/*----< ncmpi_mput_var1_$1$5() >----------------------------------------------*/ -int -ncmpi_mput_var1_$1$5(int ncid, - int num, - int varids[], - MPI_Offset* const starts[], /* [num] */ - $2 *bufs[]) -{ - int i, err; - MPI_Datatype *datatypes; - - datatypes = (MPI_Datatype*) NCI_Malloc((size_t)num * sizeof(MPI_Datatype)); - for (i=0; i--------------------------------------------------*/ -int -ncmpi_mput_vara(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, NULL, - NULL, bufs, bufcounts, datatypes, - WRITE_REQ, INDEP_IO); -} - -/*----< ncmpi_mput_vara_all() >----------------------------------------------*/ -int -ncmpi_mput_vara_all(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, NULL, - NULL, bufs, bufcounts, datatypes, - WRITE_REQ, COLL_IO); -} - -dnl -dnl MPUT_VARA(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`MPUT_VARA',dnl -`dnl -/*----< ncmpi_mput_vara_$1$5() >----------------------------------------------*/ -int -ncmpi_mput_vara_$1$5(int ncid, - int num, - int varids[], - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - $2 *bufs[]) -{ - int i, err; - MPI_Datatype *datatypes; - - datatypes = (MPI_Datatype*) NCI_Malloc((size_t)num * sizeof(MPI_Datatype)); - for (i=0; i--------------------------------------------------*/ -int -ncmpi_mput_vars(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, strides, - NULL, bufs, bufcounts, datatypes, - WRITE_REQ, INDEP_IO); -} - -/*----< ncmpi_mput_vars_all() >----------------------------------------------*/ -int -ncmpi_mput_vars_all(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, strides, - NULL, bufs, bufcounts, datatypes, - WRITE_REQ, COLL_IO); -} - -dnl -dnl MPUT_VARS(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`MPUT_VARS',dnl -`dnl -/*----< ncmpi_mput_vars_$1$5() >----------------------------------------------*/ -int -ncmpi_mput_vars_$1$5(int ncid, - int num, - int varids[], - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - $2 *bufs[]) -{ - int i, err; - MPI_Datatype *datatypes; - - datatypes = (MPI_Datatype*) NCI_Malloc((size_t)num * sizeof(MPI_Datatype)); - for (i=0; i--------------------------------------------------*/ -int -ncmpi_mput_varm(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, strides, - imaps, bufs, bufcounts, datatypes, - WRITE_REQ, INDEP_IO); -} - -/*----< ncmpi_mput_varm_all() >----------------------------------------------*/ -int -ncmpi_mput_varm_all(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, strides, - imaps, bufs, bufcounts, datatypes, - WRITE_REQ, COLL_IO); -} - -dnl -dnl MPUT_VARM(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`MPUT_VARM',dnl -`dnl -/*----< ncmpi_mput_varm_$1$5() >----------------------------------------------*/ -int -ncmpi_mput_varm_$1$5(int ncid, - int num, - int varids[], - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - $2 *bufs[]) -{ - int i, err; - MPI_Datatype *datatypes; - - datatypes = (MPI_Datatype*) NCI_Malloc((size_t)num * sizeof(MPI_Datatype)); - for (i=0; i---------------------------------------------------*/ -int -ncmpi_mget_var(int ncid, - int num, - int varids[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, NULL, NULL, NULL, - NULL, bufs, bufcounts, datatypes, - READ_REQ, INDEP_IO); -} - -/*----< ncmpi_mget_var_all() >-----------------------------------------------*/ -int -ncmpi_mget_var_all(int ncid, - int num, - int varids[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, NULL, NULL, NULL, - NULL, bufs, bufcounts, datatypes, - READ_REQ, COLL_IO); -} - -dnl -dnl MGET_VAR(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`MGET_VAR',dnl -`dnl -/*----< ncmpi_mget_var_$1$5() >-----------------------------------------------*/ -int -ncmpi_mget_var_$1$5(int ncid, - int num, - int varids[], - $2 *bufs[]) -{ - int i, err; - MPI_Datatype *datatypes; - - datatypes = (MPI_Datatype*) NCI_Malloc((size_t)num * sizeof(MPI_Datatype)); - for (i=0; i--------------------------------------------------*/ -int -ncmpi_mget_var1(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, NULL, NULL, - NULL, bufs, bufcounts, datatypes, - READ_REQ, INDEP_IO); -} - -/*----< ncmpi_mget_var1_all() >----------------------------------------------*/ -int -ncmpi_mget_var1_all(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, NULL, NULL, - NULL, bufs, bufcounts, datatypes, - READ_REQ, COLL_IO); -} - -dnl -dnl MGET_VAR1(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`MGET_VAR1',dnl -`dnl -/*----< ncmpi_mget_var1_$1$5() >----------------------------------------------*/ -int -ncmpi_mget_var1_$1$5(int ncid, - int num, - int varids[], - MPI_Offset* const starts[], /* [num] */ - $2 *bufs[]) -{ - int i, err; - MPI_Datatype *datatypes; - - datatypes = (MPI_Datatype*) NCI_Malloc((size_t)num * sizeof(MPI_Datatype)); - for (i=0; i--------------------------------------------------*/ -int -ncmpi_mget_vara(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, NULL, - NULL, bufs, bufcounts, datatypes, - READ_REQ, INDEP_IO); -} - -/*----< ncmpi_mget_vara_all() >----------------------------------------------*/ -int -ncmpi_mget_vara_all(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, NULL, - NULL, bufs, bufcounts, datatypes, - READ_REQ, COLL_IO); -} - -dnl -dnl MGET_VARA(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`MGET_VARA',dnl -`dnl -/*----< ncmpi_mget_vara_$1$5() >----------------------------------------------*/ -int -ncmpi_mget_vara_$1$5(int ncid, - int num, - int varids[], - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - $2 *bufs[]) -{ - int i, err; - MPI_Datatype *datatypes; - - datatypes = (MPI_Datatype*) NCI_Malloc((size_t)num * sizeof(MPI_Datatype)); - for (i=0; i--------------------------------------------------*/ -int -ncmpi_mget_vars(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, strides, - NULL, bufs, bufcounts, datatypes, - READ_REQ, INDEP_IO); -} - -/*----< ncmpi_mget_vars_all() >----------------------------------------------*/ -int -ncmpi_mget_vars_all(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, strides, - NULL, bufs, bufcounts, datatypes, - READ_REQ, COLL_IO); -} - -dnl -dnl MGET_VARS(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`MGET_VARS',dnl -`dnl -/*----< ncmpi_mget_vars_$1$5() >----------------------------------------------*/ -int -ncmpi_mget_vars_$1$5(int ncid, - int num, - int varids[], - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - $2 *bufs[]) -{ - int i, err; - MPI_Datatype *datatypes; - - datatypes = (MPI_Datatype*) NCI_Malloc((size_t)num * sizeof(MPI_Datatype)); - for (i=0; i--------------------------------------------------*/ -int -ncmpi_mget_varm(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, strides, - imaps, bufs, bufcounts, datatypes, - READ_REQ, INDEP_IO); -} - -/*----< ncmpi_mget_varm_all() >----------------------------------------------*/ -int -ncmpi_mget_varm_all(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[]) /* [num] */ -{ - return ncmpio_mgetput_varm(ncid, num, varids, starts, counts, strides, - imaps, bufs, bufcounts, datatypes, - READ_REQ, COLL_IO); -} - -dnl -dnl MGET_VARM(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`MGET_VARM',dnl -`dnl -/*----< ncmpi_mget_varm_$1$5() >----------------------------------------------*/ -int -ncmpi_mget_varm_$1$5(int ncid, - int num, - int varids[], - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - $2 *bufs[]) -{ - int i, err; - MPI_Datatype *datatypes; - - datatypes = (MPI_Datatype*) NCI_Malloc((size_t)num * sizeof(MPI_Datatype)); - for (i=0; i-----------------------------------------------*/ -int -ncmpio_mgetput_varm(int ncid, - int num, - int varids[], /* [num] */ - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - void *bufs[], /* [num] */ - MPI_Offset bufcounts[], /* [num] */ - MPI_Datatype datatypes[], /* [num] */ - int rw_flag, /* WRITE_REQ or READ_REQ */ - int io_method) /* COLL_IO or INDEP_IO */ -{ - int i, j, err, status=NC_NOERR, *req_ids=NULL, *statuses=NULL; - NC *ncp=NULL; - PNC *pncp; - - /* check if ncid is valid */ - status = PNC_check_id(ncid, &pncp); - if (status != NC_NOERR) DEBUG_RETURN_ERROR(status) - ncp = (NC*)pncp->ncp; - - /* if ncid is invalid, we must return the error now. However, the program - * might hang when only a subset or processes have this error. - */ - - /* check if it is in define mode. This must be called in data mode */ - if (NC_indef(ncp)) { - DEBUG_ASSIGN_ERROR(status, NC_EINDEFINE) - goto err_check; - } - - /* check file write permission if this is write request */ - if (rw_flag == WRITE_REQ && NC_readonly(ncp)) { - DEBUG_ASSIGN_ERROR(status, NC_EPERM) - goto err_check; - } - -err_check: - /* at this point, if status is not NC_NOERR, it is a fatal error */ - if (ncp->safe_mode == 1 && io_method == COLL_IO) { - int mpireturn, min_st; - TRACE_COMM(MPI_Allreduce)(&status, &min_st, 1, MPI_INT, MPI_MIN, - ncp->nciop->comm); - if (mpireturn != MPI_SUCCESS) - return ncmpio_handle_error(mpireturn, "MPI_Allreduce"); - if (min_st != NC_NOERR) return status; - } - - if (io_method == INDEP_IO && status != NC_NOERR) - return status; - - if (status != NC_NOERR) - /* this can only be reached for COLL_IO and safe_mode == 0, set num=0 - * just so this process can participate the collective calls in - * wait_all */ - num = 0; - - if (num > 0) { - req_ids = (int*) NCI_Malloc((size_t)(2 * num * SIZEOF_INT)); - statuses = req_ids + num; - } - - /* for each request call ncmpi_igetput_varm() */ - for (i=0; indims; j++) - buflen *= count[j]; - } - err = ncmpio_igetput_varm(ncp, varp, start, count, NULL, NULL, - bufs[i], buflen, datatypes[i], - &req_ids[i], rw_flag, 0, 0); - if (status == NC_NOERR) status = err; - NCI_Free(start); - } else if (counts == NULL) { /* var1 */ - /* check whether starts[i] is valid */ - err = NC_start_count_stride_ck(ncp, varp, starts[i], NULL, NULL, rw_flag); - if (status == NC_NOERR) status = err; - if (err != NC_NOERR) continue; /* skip this request */ - GET_ONE_COUNT(count) - /* when bufcounts == NULL, it means the same as counts[] */ - if (bufcounts == NULL) buflen = 1; - - err = ncmpio_igetput_varm(ncp, varp, starts[i], count, NULL, NULL, - bufs[i], buflen, datatypes[i], - &req_ids[i], rw_flag, 0, 0); - if (status == NC_NOERR) status = err; - NCI_Free(count); - } else if (strides == NULL) { /* vara */ - /* check whether starts[i] and counts[i] are valid */ - err = NC_start_count_stride_ck(ncp, varp, starts[i], counts[i], NULL, rw_flag); - if (status == NC_NOERR) status = err; - if (err != NC_NOERR) continue; /* skip this request */ - /* when bufcounts == NULL, it means the same as counts[] */ - if (bufcounts == NULL) { - for (buflen=1, j=0; jndims; j++) - buflen *= counts[i][j]; - } - err = ncmpio_igetput_varm(ncp, varp, starts[i], counts[i], NULL, - NULL, bufs[i], buflen, datatypes[i], - &req_ids[i], rw_flag, 0, 0); - if (status == NC_NOERR) status = err; - } else if (imaps == NULL) { /* vars */ - /* check whether starts[i], counts[i], and strides[i] are valid */ - err = NC_start_count_stride_ck(ncp, varp, starts[i], counts[i], strides[i], rw_flag); - if (status == NC_NOERR) status = err; - if (err != NC_NOERR) continue; /* skip this request */ - /* when bufcounts == NULL, it means the same as counts[] */ - if (bufcounts == NULL) { - for (buflen=1, j=0; jndims; j++) - buflen *= counts[i][j]; - } - err = ncmpio_igetput_varm(ncp, varp, starts[i], counts[i], - strides[i], NULL, bufs[i], buflen, - datatypes[i], &req_ids[i], - rw_flag, 0, 0); - if (status == NC_NOERR) status = err; - } else { /* varm */ - /* check whether starts[i], counts[i], and strides[i] are valid */ - err = NC_start_count_stride_ck(ncp, varp, starts[i], counts[i], strides[i], rw_flag); - if (status == NC_NOERR) status = err; - if (err != NC_NOERR) continue; /* skip this request */ - /* when bufcounts == NULL, it means the same as counts[] */ - if (bufcounts == NULL) { - for (buflen=1, j=0; jndims; j++) - buflen *= counts[i][j]; - } - err = ncmpio_igetput_varm(ncp, varp, starts[i], counts[i], - strides[i], imaps[i], bufs[i], - buflen, datatypes[i], - &req_ids[i], rw_flag, 0, 0); - if (status == NC_NOERR) status = err; - } - } - - if (io_method == COLL_IO) - err = ncmpi_wait_all(ncid, num, req_ids, statuses); - else - err = ncmpi_wait(ncid, num, req_ids, statuses); - - /* return the first error if there is one */ - if (status == NC_NOERR) status = err; - if (status == NC_NOERR) { - for (i=0; i 0) NCI_Free(req_ids); - - return status; -} diff --git a/src/drivers/ncmpio/Legacy/macro.h b/src/drivers/ncmpio/Legacy/macro.h deleted file mode 100644 index d57b7e605..000000000 --- a/src/drivers/ncmpio/Legacy/macro.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifndef _MACRO_H -#define _MACRO_H - -#define GET_ONE_COUNT(count) { \ - int _i; \ - count = (MPI_Offset*) NCI_Malloc((size_t)varp->ndims * SIZEOF_MPI_OFFSET);\ - for (_i=0; _indims; _i++) \ - count[_i] = 1; \ -} - -#ifdef ENABLE_SUBFILING -#define GET_FULL_DIMENSIONS(start, count) { \ - int _i; \ - int _ndims = (varp->num_subfiles>1?varp->ndims_org:varp->ndims); \ - start = (MPI_Offset*) NCI_Malloc((size_t)_ndims*2*SIZEOF_MPI_OFFSET); \ - count = start + _ndims; \ - \ - for (_i=0; _i<_ndims; _i++) { \ - NC_dim *dimp; \ - int _dimid; \ - _dimid = (varp->num_subfiles>1)?varp->dimids_org[_i]:varp->dimids[_i];\ - dimp = ncp->dims.value[_dimid]; \ - if (dimp->size == NC_UNLIMITED) \ - count[_i] = ncp->numrecs; \ - else \ - count[_i] = dimp->size; \ - start[_i] = 0; \ - } \ -} -#else /* without subfiling */ -#define GET_FULL_DIMENSIONS(start, count) { \ - int _i=0; \ - start = (MPI_Offset*) NCI_Malloc((size_t)varp->ndims*2*SIZEOF_MPI_OFFSET);\ - count = start + varp->ndims; \ - \ - if (IS_RECVAR(varp)) { /* find current numrec if varp is record var */ \ - count[0] = ncp->numrecs; \ - start[0] = 0; \ - _i = 1; \ - } \ - for (; _indims; _i++) { \ - count[_i] = varp->shape[_i]; \ - start[_i] = 0; \ - } \ -} -#endif - -#define DATATYPE_GET_CONVERT(cdf_ver,xtype,xbuf,ibuf,bnelems,itype,err) { \ - /* xtype is the NC variable's external data type stored in the nc file \ - * itype (internal type) is the user I/O buffer data type (MPI_Datatype) \ - * xbuf is the buffer containing the data read from the nc file in the \ - * external representation, to be converted to internal representation r \ - * into user buffer, ibuf */ \ - switch(xtype) { \ - case NC_BYTE: \ - err = ncmpii_getn_NC_BYTE(cdf_ver,xbuf,ibuf,bnelems,itype); \ - break; \ - case NC_UBYTE: \ - err = ncmpii_getn_NC_UBYTE(xbuf,ibuf,bnelems,itype); \ - break; \ - case NC_SHORT: \ - err = ncmpii_getn_NC_SHORT(xbuf,ibuf,bnelems,itype); \ - break; \ - case NC_USHORT: \ - err = ncmpii_getn_NC_USHORT(xbuf,ibuf,bnelems,itype); \ - break; \ - case NC_INT: \ - err = ncmpii_getn_NC_INT(xbuf,ibuf,bnelems,itype); \ - break; \ - case NC_UINT: \ - err = ncmpii_getn_NC_UINT(xbuf,ibuf,bnelems,itype); \ - break; \ - case NC_FLOAT: \ - err = ncmpii_getn_NC_FLOAT(xbuf,ibuf,bnelems,itype); \ - break; \ - case NC_DOUBLE: \ - err = ncmpii_getn_NC_DOUBLE(xbuf,ibuf,bnelems,itype); \ - break; \ - case NC_INT64: \ - err = ncmpii_getn_NC_INT64(xbuf,ibuf,bnelems,itype); \ - break; \ - case NC_UINT64: \ - err = ncmpii_getn_NC_UINT64(xbuf,ibuf,bnelems,itype); \ - break; \ - default: \ - err = NC_EBADTYPE; \ - break; \ - } \ -} - -#define DATATYPE_PUT_CONVERT(cdf_ver,xtype,xbuf,ibuf,cnelems,itype,fillp,err) {\ - /* xtype is the NC variable's external data type stored in the nc file \ - * itype (internal type)is the user I/O buffer data type (MPI_Datatype) \ - * ibuf is user buffer containing the data in internal format of itype, \ - * they meed to be converted to external format to external buffer, xbuf, \ - * so xbuf can be used to write to the nc file through the call to \ - * MPI_FIle_write call */ \ - switch(xtype) { \ - case NC_BYTE: \ - err = ncmpii_putn_NC_BYTE(cdf_ver,xbuf,ibuf,cnelems,itype,fillp);\ - break; \ - case NC_UBYTE: \ - err = ncmpii_putn_NC_UBYTE(xbuf,ibuf,cnelems,itype,fillp); \ - break; \ - case NC_SHORT: \ - err = ncmpii_putn_NC_SHORT(xbuf,ibuf,cnelems,itype,fillp); \ - break; \ - case NC_USHORT: \ - err = ncmpii_putn_NC_USHORT(xbuf,ibuf,cnelems,itype,fillp); \ - break; \ - case NC_INT: \ - err = ncmpii_putn_NC_INT(xbuf,ibuf,cnelems,itype,fillp); \ - break; \ - case NC_UINT: \ - err = ncmpii_putn_NC_UINT(xbuf,ibuf,cnelems,itype,fillp); \ - break; \ - case NC_FLOAT: \ - err = ncmpii_putn_NC_FLOAT(xbuf,ibuf,cnelems,itype,fillp); \ - break; \ - case NC_DOUBLE: \ - err = ncmpii_putn_NC_DOUBLE(xbuf,ibuf,cnelems,itype,fillp); \ - break; \ - case NC_INT64: \ - err = ncmpii_putn_NC_INT64(xbuf,ibuf,cnelems,itype,fillp); \ - break; \ - case NC_UINT64: \ - err = ncmpii_putn_NC_UINT64(xbuf,ibuf,cnelems,itype,fillp); \ - break; \ - default: \ - err = NC_EBADTYPE; \ - break; \ - } \ -} - -#endif diff --git a/src/drivers/ncmpio/Legacy/misc.c b/src/drivers/ncmpio/Legacy/misc.c deleted file mode 100644 index aee0a6a57..000000000 --- a/src/drivers/ncmpio/Legacy/misc.c +++ /dev/null @@ -1,1064 +0,0 @@ -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -/* Starting from version 1.8.0, PnetCDF checks file metadata consistency only - * when safe mode is enabled and the checking is no longer done at enddef(). - * The check has been moved to where the new metadata is added, e.g. - * ncmpi_def_dim, ncmpi_def_var, ncmpi_put_att, etc. Thus, below legacy codes - * are for checking the entire metadata all at once. - */ -#ifdef _CHECK_HEADER_CONSISTENCY - -#ifdef SIZEOF_INT -# if SIZEOF_INT == 4 -# define lld(x) (x) -# elif SIZEOF_INT == 8 -# define lld(x) (long long)(x) -# endif -#endif - -#define WARN_STR "Warning (inconsistent metadata):" - -/*----< compare_dims() >-----------------------------------------------------*/ -/* compare the local copy of dim_list against root's - * If inconsistency is detected, overwrite local's with root's - * this function is collective. - */ -static int -compare_dims(int safe_mode, - NC_dimarray *root_dim, - NC_dimarray *local_dim) -{ - int i, err, status=NC_NOERR; - - if (root_dim->ndefined != local_dim->ndefined) { - if (safe_mode) - printf("%s number of dimensions (local=%d, root=%d)\n", - WARN_STR, local_dim->ndefined, root_dim->ndefined); - DEBUG_ASSIGN_ERROR(status, NC_EMULTIDEFINE_DIM_NUM) - } - - for (i=0; indefined; i++) { - - if (i >= local_dim->ndefined) { /* if local list is shorter */ - /* copy root's dim to local */ - NC_dim *new_dim = ncmpio_dup_NC_dim(root_dim->value[i]); - err = ncmpio_incr_NC_dimarray(local_dim, new_dim); - if (err != NC_NOERR) return err; /* this is a fatal error */ - continue; - } - - /* check dimension name */ - NC_string *root_name, *local_name; - root_name = root_dim->value[i]->name; - local_name = local_dim->value[i]->name; - - err = NC_NOERR; - if (root_name->nchars != local_name->nchars) { - if (safe_mode) - printf("%s dimension name length (local=%lld, root=%lld)\n", - WARN_STR, local_name->nchars, root_name->nchars); - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_DIM_NAME) - } - else if (memcmp(root_name->cp, local_name->cp, (size_t)root_name->nchars) != 0) { - if (safe_mode) - printf("%s dimension name (local=%s, root=%s)\n", - WARN_STR, local_name->cp, root_name->cp); - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_DIM_NAME) - } - else if (root_dim->value[i]->size != local_dim->value[i]->size) { - /* check dimension size */ - if (safe_mode) - printf("%s dimension %s's size (local=%lld, root=%lld)\n", - WARN_STR, root_dim->value[i]->name->cp, - root_dim->value[i]->size, local_dim->value[i]->size); - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_DIM_SIZE) - } - if (status == NC_NOERR) status = err; - - /* overwrite local's dim with root's */ - if (err != NC_NOERR) { - ncmpio_free_NC_dim(local_dim->value[i]); - local_dim->value[i] = ncmpio_dup_NC_dim(root_dim->value[i]); - } - } - - /* delete extra dimensions defined only in local copy */ - for (; indefined; i++) - ncmpio_free_NC_dim(local_dim->value[i]); - - local_dim->ndefined = root_dim->ndefined; - -#ifndef SEARCH_NAME_LINEARLY - if (status != NC_NOERR) { - /* dims are not consistent, must rebuild dim name lookup table */ - for (i=0; inameT[i].num > 0) - NCI_Free(local_dim->nameT[i].list); - local_dim->nameT[i].num = 0; - local_dim->nameT[i].list = NULL; - } - - /* populate dim name lookup table */ - for (i=0; indefined; i++) { - /* hash the dim name into a key for name lookup */ - int key = HASH_FUNC(local_dim->value[i]->name->cp); - NC_nametable *nameT = &local_dim->nameT[key]; - if (nameT->num % NC_NAME_TABLE_CHUNK == 0) - nameT->list = (int*) NCI_Realloc(nameT->list, - (size_t)(nameT->num+NC_NAME_TABLE_CHUNK) * SIZEOF_INT); - nameT->list[nameT->num] = i; - nameT->num++; - } - } -#endif - - return status; -} - -/*----< compare_attrs() >-----------------------------------------------------*/ -/* compare the local copy of attr_list against root's - * If inconsistency is detected, overwrite local's with root's - */ -static int -compare_attrs(int safe_mode, - NC_attrarray *root_attr, - NC_attrarray *local_attr) -{ - int i, j, err, status=NC_NOERR; - char *msg; - - /* check if the numbers of attributes are the same */ - if (root_attr->ndefined != local_attr->ndefined) { - if (safe_mode) - printf("%s number of attributes (root=%d, local=%d)\n", - WARN_STR, root_attr->ndefined, local_attr->ndefined); - DEBUG_ASSIGN_ERROR(status, NC_EMULTIDEFINE_ATTR_NUM) - } - - for (i=0; indefined; i++) { - - if (i >= local_attr->ndefined) { /* if local list is shorter */ - /* copy root's attr to local */ - NC_attr *new_attr = ncmpio_dup_NC_attr(root_attr->value[i]); - err = ncmpio_incr_NC_attrarray(local_attr, new_attr); - if (err != NC_NOERR) return err; /* a fatal error */ - continue; - } - - NC_attr *v1 = root_attr->value[i]; - NC_attr *v2 = local_attr->value[i]; - char *name = v1->name->cp; - -#define ATTR_WARN(msg, attr, root, local) \ - if (safe_mode) printf(msg, WARN_STR, attr, root, local); - -#define ATTR_WARN_J(msg, attr, j, root, local) \ - if (safe_mode) printf(msg, WARN_STR, attr, j, root, local); - - err = NC_NOERR; - if (v1->name->nchars != v2->name->nchars || - memcmp(name, v2->name->cp, (size_t)v1->name->nchars) != 0) { - msg ="%s attribute %s (root=%s, local=%s)\n"; - ATTR_WARN(msg, "name", name, v2->name->cp) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_NAME) - } - else if (v1->type != v2->type) { - msg = "%s attribute \"%s\" type (root=%d, local=%d)\n"; - ATTR_WARN(msg, name, v1->type, v2->type) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_TYPE) - } - else if (v1->nelems != v2->nelems) { - msg = "%s attribute \"%s\" length (root=%lld, local=%lld)\n"; - ATTR_WARN(msg, name, lld(v1->nelems), lld(v2->nelems)) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_LEN) - } - else if (v1->xsz != v2->xsz) { /* internal check */ - msg = "%s attribute \"%s\" size (root=%lld, local=%lld)\n"; - ATTR_WARN(msg, name, lld(v1->xsz), lld(v2->xsz)) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_SIZE) - } - /* hereinafter, we have v1->nelems == v2->nelems */ - else if (v1->type == NC_CHAR) { - if (memcmp(v1->xvalue, v2->xvalue, (size_t)v1->nelems)) { - msg = "%s attribute \"%s\" CHAR (root=%s, local=%s)\n"; - ATTR_WARN(msg, name, (char*)v1->xvalue, (char*)v2->xvalue); - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - } - } - else if (v1->type == NC_BYTE) { - schar *sba = (schar*) v1->xvalue; - schar *sbb = (schar*) v2->xvalue; - for (j=0; jnelems; j++) { - if (sba[j] != sbb[j]) { - msg = "%s attribute \"%s\"[%d] BYTE (root=%hhdb, local=%hhdb)\n"; - ATTR_WARN_J(msg, name, j, sba[j], sbb[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - break; - } - } - } - else if (v1->type == NC_UBYTE) { - uchar *uba = (uchar*) v1->xvalue; - uchar *ubb = (uchar*) v2->xvalue; - for (j=0; jnelems; j++) { - if (uba[j] != ubb[j]) { - msg = "%s attribute \"%s\"[%d] UBYTE (root=%hhuub, local=%hhuub)\n"; - ATTR_WARN_J(msg, name, j, uba[j], ubb[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - break; - } - } - } - else if (v1->type == NC_SHORT) { - short *ssa = (short*) v1->xvalue; - short *ssb = (short*) v2->xvalue; - for (j=0; jnelems; j++) { - if (ssa[j] != ssb[j]) { - msg = "%s attribute \"%s\"[%d] SHORT (root=%hds, local=%hds)\n"; - ATTR_WARN_J(msg, name, j, ssa[j], ssb[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - break; - } - } - } - else if (v1->type == NC_USHORT) { - ushort *usa = (ushort*) v1->xvalue; - ushort *usb = (ushort*) v2->xvalue; - for (j=0; jnelems; j++) { - if (usa[j] != usb[j]) { - msg = "%s attribute \"%s\"[%d] USHORT (root=%huus, local=%huus)\n"; - ATTR_WARN_J(msg, name, j, usa[j], usb[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - break; - } - } - } - else if (v1->type == NC_INT) { - int *sia = (int*) v1->xvalue; - int *sib = (int*) v2->xvalue; - for (j=0; jnelems; j++) { - if (sia[j] != sib[j]) { - msg = "%s attribute \"%s\"[%d] INT (root=%d, local=%d)\n"; - ATTR_WARN_J(msg, name, j, sia[j], sib[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - break; - } - } - } - else if (v1->type == NC_UINT) { - uint *uia = (uint*) v1->xvalue; - uint *uib = (uint*) v2->xvalue; - for (j=0; jnelems; j++) { - if (uia[j] != uib[j]) { - msg = "%s attribute \"%s\"[%d] UINT (root=%uu, local=%uu)\n"; - ATTR_WARN_J(msg, name, j, uia[j], uib[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - break; - } - } - } - else if (v1->type == NC_FLOAT) { - float *fa = (float*) v1->xvalue; - float *fb = (float*) v2->xvalue; - for (j=0; jnelems; j++) { - /* floating-point inequality here but we genuinely do - * expect all processors to set bit-for-bit identical - * headers - if (fa[j] != fb[j]) { - */ - if (memcmp(fa+j, fb+j, SIZEOF_FLOAT)) { - msg = "%s attribute \"%s\"[%d] FLOAT (root=%f, local=%f)\n"; - ATTR_WARN_J(msg, name, j, fa[j], fb[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - break; - } - } - } - else if (v1->type == NC_DOUBLE) { - double *da = (double*) v1->xvalue; - double *db = (double*) v2->xvalue; - for (j=0; jnelems; j++) { - /* floating-point inequality here but we genuinely do - * expect all processors to set bit-for-bit identical - * headers - if (da[j] != db[j]) { - */ - if (memcmp(da+j, db+j, SIZEOF_DOUBLE)) { - msg = "%s attribute \"%s\"[%d] DOUBLE (root=%f, local=%f)\n"; - ATTR_WARN_J(msg, name, j, da[j], db[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - break; - } - } - } - else if (v1->type == NC_INT64) { - long long *slla = (long long*) v1->xvalue; - long long *sllb = (long long*) v2->xvalue; - for (j=0; jnelems; j++) { - if (slla[j] != sllb[j]) { - msg = "%s attribute \"%s\"[%d] INT64 (root=%lldll, local=%lldll)\n"; - ATTR_WARN_J(msg, name, j, slla[j], sllb[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - break; - } - } - } - else if (v1->type == NC_UINT64) { - unsigned long long *ulla = (unsigned long long*) v1->xvalue; - unsigned long long *ullb = (unsigned long long*) v2->xvalue; - for (j=0; jnelems; j++) { - if (ulla[j] != ullb[j]) { - msg = "%s attribute \"%s\"[%d] UINT64 (root=%llull, local=%llull)\n"; - ATTR_WARN_J(msg, name, j, ulla[j], ullb[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_ATTR_VAL) - break; - } - } - } - if (status == NC_NOERR) status = err; - - /* overwrite local's attr with root's */ - if (ErrIsHeaderDiff(err)) { - ncmpio_free_NC_attr(local_attr->value[i]); - local_attr->value[i] = ncmpio_dup_NC_attr(root_attr->value[i]); - } - } - - /* delete extra attributes defined only in local copy */ - for (; indefined; i++) - ncmpio_free_NC_attr(local_attr->value[i]); - - local_attr->ndefined = root_attr->ndefined; - - return status; -} - -/*----< compare_vars() >------------------------------------------------------*/ -/* compare the local copy of var_list against root's - * If inconsistency is detected, overwrite local's with root's - */ -static int -compare_vars(int safe_mode, - NC_vararray *root_var, - NC_vararray *local_var) -{ - int i, j, err, status=NC_NOERR; - char *msg; - - /* check if the numbers of variables are the same */ - if (root_var->ndefined != local_var->ndefined) { - if (safe_mode) - printf("%s number of variables (root=%d, local=%d)\n", - WARN_STR, root_var->ndefined, local_var->ndefined); - DEBUG_ASSIGN_ERROR(status, NC_EMULTIDEFINE_VAR_NUM) - } - - for (i=0; indefined; i++) { - - if (i >= local_var->ndefined) { /* if local list is shorter */ - /* copy root's variable to local */ - NC_var *new_var = ncmpio_dup_NC_var(root_var->value[i]); - err = ncmpio_incr_NC_vararray(local_var, new_var); - if (err != NC_NOERR) return err; /* a fatal error */ - /* local_var->ndefined is increased by 1 in ncmpio_incr_NC_vararray() */ - continue; - } - - NC_var *v1 = root_var->value[i]; - NC_var *v2 = local_var->value[i]; - char *name = v1->name->cp; - -#define VAR_WARN(msg, var, root, local) \ - if (safe_mode) printf(msg, WARN_STR, var, root, local); - -#define VAR_WARN_J(msg, var, j, root, local) \ - if (safe_mode) printf(msg, WARN_STR, var, j, root, local); - - err = NC_NOERR; - if (v1->name->nchars != v2->name->nchars || - strncmp(v1->name->cp, v2->name->cp, (size_t)v1->name->nchars) != 0) { - msg = "%s variable %s (root=%s, local=%s)\n"; - VAR_WARN(msg, "name", name, v2->name->cp) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_VAR_NAME) - } - else if (v1->ndims != v2->ndims) { - msg = "%s variable %s's ndims (root=%d, local=%d)\n"; - VAR_WARN(msg, name, v1->ndims, v2->ndims) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_VAR_NDIMS) - } - else if (v1->type != v2->type) { - msg = "%s variable %s's type (root=%d, local=%d)\n"; - VAR_WARN(msg, name, v1->type, v2->type) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_VAR_TYPE) - } - else if (v1->len != v2->len) { - msg = "%s variable %s's len (root=%lld, local=%lld)\n"; - VAR_WARN(msg, name, v1->len, v2->len) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_VAR_LEN) - } - else if (v1->begin != v2->begin) { - msg = "%s variable %s's begin (root=%lld, local=%lld)\n"; - VAR_WARN(msg, name, v1->begin, v2->begin) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_VAR_BEGIN) - } - else { - for (j=0; jndims; j++) { - if (v1->dimids[j] != v2->dimids[j]) { - msg = "%s variable %s's %dth dim ID (root=%d, local=%ld)\n"; - VAR_WARN_J(msg, name, j, v1->dimids[j], v2->dimids[j]) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_VAR_DIMIDS) - break; - } - } - } - /* compare variable's attributes if by far no inconsistency is found */ - if (err == NC_NOERR) { - err = compare_attrs(safe_mode, &(v1->attrs), &(v2->attrs)); - if (err != NC_NOERR && !ErrIsHeaderDiff(err)) - return err; /* a fatal error */ - } - - if (status == NC_NOERR) status = err; - - /* if there is any inconsistency, overwrite local's var with root's */ - if (ErrIsHeaderDiff(err)) { - ncmpio_free_NC_var(local_var->value[i]); - local_var->value[i] = ncmpio_dup_NC_var(root_var->value[i]); - /* note once a new var is created, one must call - * compute_var_shape() to recalculate the shape */ - } - } - - /* delete extra variables defined only in local copy */ - for (; indefined; i++) - ncmpio_free_NC_var(local_var->value[i]); - - local_var->ndefined = root_var->ndefined; - -#ifndef SEARCH_NAME_LINEARLY - if (status != NC_NOERR) { - /* vars are not consistent, must rebuild var name lookup table */ - for (i=0; inameT[i].num > 0) - NCI_Free(local_var->nameT[i].list); - local_var->nameT[i].num = 0; - local_var->nameT[i].list = NULL; - } - - /* populate var name lookup table */ - for (i=0; indefined; i++) { - /* hash the var name into a key for name lookup */ - int key = HASH_FUNC(local_var->value[i]->name->cp); - NC_nametable *nameT = &local_var->nameT[key]; - if (nameT->num % NC_NAME_TABLE_CHUNK == 0) - nameT->list = (int*) NCI_Realloc(nameT->list, - (size_t)(nameT->num+NC_NAME_TABLE_CHUNK) * SIZEOF_INT); - nameT->list[nameT->num] = i; - nameT->num++; - } - } -#endif - - return status; -} - -/*----< compare_NC() >--------------------------------------------------------*/ -/* This function is only called by NC_check_header() - * It checks the header of local copy against root's and overwrites local's - * header object, ncp, with root's header if any inconsistency is detected. - * This function is called independently and should not contain any MPI - * communication calls. - * - * Possible error codes returned: - * NC_ENOTNC3, NC_ENOTNC, NC_ESMALL, and all inconsistency errors - * NC_EMULTIDEFINE_XXX - */ -static int -compare_NC(bufferinfo *getbuf, /* header from root */ - NC *ncp) -{ - int err, status=NC_NOERR; - char magic[sizeof(ncmagic1)]; /* root's file format signature */ - MPI_Offset nrecs=0; - MPI_Aint pos_addr, base_addr; - NC *root_ncp; - - assert(ncp != NULL); - assert(getbuf != NULL); - - /* check the file format signature in root's header */ - memset(magic, 0, sizeof(magic)); - err = ncmpix_getn_text((const void **)(&getbuf->pos), sizeof(magic), magic); - if (err != NC_NOERR) { - /* Fatal error, as root's header is significant */ - if (ncp->safe_mode) fprintf(stderr,"Error: CDF magic number from root's header\n"); - return err; - } - - /* check if the first 3 letters are "CDF" */ - if (memcmp(magic, ncmagic1, sizeof(ncmagic1)-1) != 0) { - /* Fatal error, as root's header is significant */ - /* check if is HDF5 file */ - char signature[8], *hdf5_signature="\211HDF\r\n\032\n"; - memcpy(signature, magic, 4); - ncmpix_getn_text((const void **)(&getbuf->pos), 4, signature+4); - if (memcmp(signature, hdf5_signature, 8) == 0) { - DEBUG_ASSIGN_ERROR(status, NC_ENOTNC3) - if (ncp->safe_mode) - fprintf(stderr,"Error: root's header indicates an HDF5 file\n"); - } - else { - DEBUG_ASSIGN_ERROR(status, NC_ENOTNC) - if (ncp->safe_mode) - fprintf(stderr,"Error: root's header indicates not a CDF file\n"); - } - return status; /* should not continue */ - } - - /* allocate a header object and fill it with root's header */ - root_ncp = (NC*) NCI_Calloc(1, sizeof(NC)); - if (root_ncp == NULL) DEBUG_RETURN_ERROR(NC_ENOMEM) - root_ncp->comm = MPI_COMM_NULL; - root_ncp->mpiinfo = MPI_INFO_NULL; - - /* in safe_mode, consistency of magic numbers have already been checked in - * ncmpi_create() - */ - if (magic[sizeof(ncmagic1)-1] == 0x5) { - root_ncp->format = 5; - getbuf->version = 5; - } - else if (magic[sizeof(ncmagic1)-1] == 0x2) { - root_ncp->format = 2; - getbuf->version = 2; - } - else if (magic[sizeof(ncmagic1)-1] != 0x1) { - getbuf->version = 1; - root_ncp->format = 1; - /* Fatal error, as root's header is significant */ - if (ncp->safe_mode) - fprintf(stderr,"Error: root's header indicates not CDF 1/2/5 format\n"); - DEBUG_RETURN_ERROR(NC_ENOTNC) /* should not continue */ - } - - if (! ncp->safe_mode) { - /* check local's version number in last byte of magic against root's */ - int root_ver = magic[sizeof(ncmagic1)-1]; - - if (ncp->format != root_ver) { -#ifdef PNETCDF_DEBUG - printf("%s CDF file format (local=CDF-%d, root=CDF-%d)\n", - WARN_STR, ncp->format, root_ver); -#endif - /* overwrite the local header object with root's */ - ncp->format = root_ver; - - /* this inconsistency is not fatal */ - DEBUG_ASSIGN_ERROR(status, NC_EMULTIDEFINE_CMODE) - } - getbuf->version = root_ver; - ncp->format = root_ver; - } - -#if SIZEOF_MPI_OFFSET < 8 - if (getbuf->version > 1) { - /* for NC_64BIT_DATA or NC_64BIT_OFFSET, MPI_Offset must be 8 bytes */ - if (ncp->safe_mode) - fprintf(stderr,"Error: cannot support CDF-2 and CDF-5 on this machine\n"); - DEBUG_RETURN_ERROR(NC_ESMALL) /* should not continue */ - } -#endif - - /* since getbuf contains the entire root's header, we do not need to check - * for any next element in the buffer. Similarly, for all possible calls - * to hdr_check_buffer() from this subroutine, hdr_fetch() will never be - * called. - * (move on to the next element in header: number of records) - err = hdr_check_buffer(getbuf, (getbuf->version < 5) ? 4 : 8); - if (err != NC_NOERR) { - if (ncp->safe_mode) - fprintf(stderr,"Error: root's header is too short\n"); - return err; - } - */ - - if (getbuf->version < 5) { - uint tmp=0; - err = ncmpix_get_uint32((const void **)(&getbuf->pos), &tmp); - nrecs = (MPI_Offset)tmp; - } - else { - uint64 tmp=0; - err = ncmpix_get_uint64((const void **)(&getbuf->pos), &tmp); - nrecs = (MPI_Offset)tmp; - } - if (err != NC_NOERR) { - if (ncp->safe_mode) - fprintf(stderr,"Error: failed to read numrecs from root's header\n"); - return err; /* should not continue */ - } - - root_ncp->numrecs = nrecs; - if (root_ncp->numrecs != ncp->numrecs) { - if (ncp->safe_mode) - printf("%s number of records (local=%lld, root=%lld)\n", - WARN_STR, ncp->numrecs, root_ncp->numrecs); - /* overwrite the local header's numrecs */ - ncp->numrecs = root_ncp->numrecs; - if (status == NC_NOERR) DEBUG_ASSIGN_ERROR(status, NC_EMULTIDEFINE_NUMRECS) - } - -#ifdef HAVE_MPI_GET_ADDRESS - MPI_Get_address(getbuf->pos, &pos_addr); - MPI_Get_address(getbuf->base, &base_addr); -#else - MPI_Address(getbuf->pos, &pos_addr); - MPI_Address(getbuf->base, &base_addr); -#endif - assert(pos_addr < base_addr + getbuf->size); - - /* get the next header element dim_list from getbuf to root_ncp */ - err = hdr_get_NC_dimarray(getbuf, &root_ncp->dims); - if (err != NC_NOERR) return err; /* fatal error */ - - /* compare local's and root's dim_list */ - err = compare_dims(ncp->safe_mode, &root_ncp->dims, &ncp->dims); - if (err != NC_NOERR && !ErrIsHeaderDiff(err)) - return err; /* a fatal error */ - if (status == NC_NOERR) status = err; - - /* get the next header element gatt_list from getbuf to root_ncp */ - err = hdr_get_NC_attrarray(getbuf, &root_ncp->attrs); - if (err != NC_NOERR) return err; /* fatal error */ - - /* get the next header element att_list from getbuf to root_ncp */ - err = compare_attrs(ncp->safe_mode, &root_ncp->attrs, &ncp->attrs); - if (err != NC_NOERR && !ErrIsHeaderDiff(err)) - return err; /* a fatal error */ - if (status == NC_NOERR) status = err; - - /* get the next header element var_list from getbuf to root_ncp */ - err = hdr_get_NC_vararray(getbuf, &root_ncp->vars); - if (err != NC_NOERR) return err; /* fatal error */ - - /* compare local's and root's var_list */ - err = compare_vars(ncp->safe_mode, &root_ncp->vars, &ncp->vars); - if (err != NC_NOERR && !ErrIsHeaderDiff(err)) - return err; /* a fatal error */ - if (status == NC_NOERR) status = err; - - if (err != NC_NOERR) { /* header has been sync-ed with root */ - /* recompute shape is required for every new variable created */ - err = compute_var_shape(ncp); - if (err != NC_NOERR) return err; /* a fatal error */ - } - /* now, the local header object has been sync-ed with root */ - - if (ncp->safe_mode && ErrIsHeaderDiff(status)) { - /* recompute header size */ - MPI_Offset root_xsz, local_xsz; - root_xsz = ncmpio_hdr_len_NC(root_ncp); - local_xsz = ncmpio_hdr_len_NC(ncp); - /* root's header size is getbuf->size */ - assert( ncp->xsz == getbuf->size && - root_xsz == local_xsz && - local_xsz == getbuf->size); - } - ncmpio_free_NC(root_ncp); - return status; -} - -/*----< NC_check_header() >--------------------------------------------------*/ -/* - * Check the consistency of defined header metadata across all processes and - * overwrite the local header objects with root's if inconsistency is found. - * This function is collective. - */ -static int -NC_check_header(NC *ncp, - void *buf, - MPI_Offset local_xsz) /* size of buf */ -{ - int h_size, rank, g_status, status=NC_NOERR, mpireturn; - - /* root's header size has been broadcasted in NC_begin() and saved in - * ncp->xsz. - */ - - /* TODO: When root process 0 broadcasts its header, - * currently the header size cannot be larger than 2^31 bytes, - * due to the 2nd argument, count, of MPI_Bcast being of type int. - * Possible solution is to broadcast in chunks of 2^31 bytes. - */ - h_size = (int)ncp->xsz; - if (ncp->xsz != h_size) - DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - - MPI_Comm_rank(ncp->nciop->comm, &rank); - - if (rank == 0) { - TRACE_COMM(MPI_Bcast)(buf, h_size, MPI_BYTE, 0, ncp->nciop->comm); - } - else { - bufferinfo gbp; - void *cmpbuf = (void*) NCI_Malloc((size_t)h_size); - - TRACE_COMM(MPI_Bcast)(cmpbuf, h_size, MPI_BYTE, 0, ncp->nciop->comm); - - if (h_size != local_xsz || memcmp(buf, cmpbuf, h_size)) { - /* now part of this process's header is not consistent with root's - * check and report the inconsistent part - */ - - /* Note that gbp.nciop and gbp.offset below will not be used in - * compare_NC() */ - gbp.nciop = ncp->nciop; - gbp.offset = 0; - gbp.size = h_size; /* entire header is in the buffer, cmpbuf */ - gbp.index = 0; - gbp.pos = gbp.base = cmpbuf; - - /* find the inconsistent part of the header, report the difference, - * and overwrite the local header object with root's. - * compare_NC() should not have any MPI communication calls. - */ - status = compare_NC(&gbp, ncp); - - /* header consistency is only checked on non-root processes. The - * returned status can be a fatal error or header inconsistency - * error, (fatal errors are due to object allocation), but never - * NC_NOERR. - */ - } - NCI_Free(cmpbuf); - } - - if (ncp->safe_mode) { - TRACE_COMM(MPI_Allreduce)(&status, &g_status, 1, MPI_INT, MPI_MIN, - ncp->nciop->comm); - if (mpireturn != MPI_SUCCESS) { - return ncmpio_handle_error(mpireturn, "MPI_Allreduce"); - } - if (g_status != NC_NOERR) { /* some headers are inconsistent */ - if (status == NC_NOERR) DEBUG_ASSIGN_ERROR(status, NC_EMULTIDEFINE) - } - } - - return status; -} -#endif - -/*----< ncmpio_read_NC() >---------------------------------------------------*/ -/* Re-read in the header. - * On PnetCDF, this is of no use, as header metadata is always sync-ed among - * all processes, except for numrecs, which can be sync-ed by calling - * ncmpio_sync_numrecs() - */ -int -ncmpio_read_NC(NC *ncp) { - int status = NC_NOERR; - - ncmpio_free_NC_dimarray(&ncp->dims); - ncmpio_free_NC_attrarray(&ncp->attrs); - ncmpio_free_NC_vararray(&ncp->vars); - - status = ncmpio_hdr_get_NC(ncp); - - if (status == NC_NOERR) - fClr(ncp->flags, NC_NDIRTY); - - return status; -} - -/*----< ncmpio_find_NC_Udim() >----------------------------------------------*/ -/* - * Step thru NC_DIMENSION array, seeking the UNLIMITED dimension. - * Return dimid or -1 on not found. - * *dimpp is set to the appropriate NC_dim. - */ -int -ncmpio_find_NC_Udim(const NC_dimarray *ncap, - NC_dim **dimpp) -{ - int dimid; - - assert(ncap != NULL); - - if (ncap->ndefined == 0) return -1; - - /* note that the number of dimensions allowed is < 2^32 */ - for (dimid=0; dimidndefined; dimid++) - if (ncap->value[dimid]->size == NC_UNLIMITED) { - /* found the matched name */ - if (dimpp != NULL) - *dimpp = ncap->value[dimid]; - return dimid; - } - - /* not found */ - return -1; -} - -/*----< ncmpio_swapn() >-----------------------------------------------------*/ -/* out-place byte swap, i.e. dest_p != src_p */ -void -ncmpio_swapn(void *dest_p, /* destination array */ - const void *src_p, /* source array */ - MPI_Offset nelems, /* number of elements in buf[] */ - int esize) /* byte size of each element */ -{ - int i; - - if (esize <= 1 || nelems <= 0) return; /* no need */ - - if (esize == 4) { /* this is the most common case */ - uint32_t *dest = (uint32_t*) dest_p; - const uint32_t *src = (const uint32_t*) src_p; - for (i=0; i> 8) - | (((dest[i]) >> 24)); - } - } - else if (esize == 8) { - uint64_t *dest = (uint64_t*) dest_p; - const uint64_t *src = (const uint64_t*) src_p; - for (i=0; i> 8) | - ((dest[i] & 0x0000FF0000000000ULL) >> 24) | - ((dest[i] & 0x00FF000000000000ULL) >> 40) | - ((dest[i] & 0xFF00000000000000ULL) >> 56); - } - } - else if (esize == 2) { - uint16_t *dest = (uint16_t*) dest_p; - const uint16_t *src = (const uint16_t*) src_p; - for (i=0; i> 8) & 0xff)); - } - } - else { - uchar *op = (uchar*) dest_p; - const uchar *ip = (uchar*) src_p; - /* for esize is not 1, 2, or 4 */ - while (nelems-- > 0) { - for (i=0; i---------------------------------------*/ -/* This is an independent subroutine */ -int -ncmpi_print_all_var_offsets(int ncid) { - int i, err; - NC_var **vpp=NULL; - NC *ncp=NULL; - PNC *pncp; - - err = PNC_check_id(ncid, &pncp); - if (err != NC_NOERR) DEBUG_RETURN_ERROR(err) - ncp = (NC*)pncp->ncp; - - if (ncp->begin_var%1048576) - printf("%s header size (ncp->begin_var)=%lld MB + %lld\n", - ncp->path, ncp->begin_var/1048575, ncp->begin_var%1048576); - else - printf("%s header size (ncp->begin_var)=%lld MB\n", - ncp->path, ncp->begin_var/1048575); - - vpp = ncp->vars.value; - for (i=0; ivars.ndefined; i++, vpp++) { - char str[1024]; - MPI_Offset off = (*vpp)->begin; - MPI_Offset rem = off % 1048576;; - - if (IS_RECVAR(*vpp)) - sprintf(str," Record variable \"%20s\": ",(*vpp)->name->cp); - else - sprintf(str,"non-record variable \"%20s\": ",(*vpp)->name->cp); - - if (rem) - printf("%s offset=%12lld MB + %7lld len=%lld\n", str, off/1048576, rem,(*vpp)->len); - else - printf("%s offset=%12lld MB len=%lld\n", str, off/1048576,(*vpp)->len); - } - return NC_NOERR; -} - -/*----< ncmpio_free_NC_string() >--------------------------------------------*/ -/* - * Free string, and, if needed, its values. - * Formerly -NC_free_string() - */ -inline void -ncmpio_free_NC_string(NC_string *ncstrp) -{ - if (ncstrp == NULL) return; - /* ncstrp->cp is allocated as part of ncstrp object */ - NCI_Free(ncstrp); -} - -/*----< ncmpio_new_NC_string() >---------------------------------------------*/ -/* - * Allocate a NC_string structure large enough - * to hold slen characters. - */ -NC_string * -ncmpio_new_NC_string(size_t slen, - const char *str) /* must be already normalized */ -{ - /* str may not be NULL terminated */ - NC_string *ncstrp; - size_t sizeof_NC_string = M_RNDUP(sizeof(NC_string)); - size_t sz = slen + sizeof_NC_string + 1; - /* one char more space for NULL terminate char */ - - ncstrp = (NC_string *) NCI_Calloc(sz, sizeof(char)); - if (ncstrp == NULL) return NULL; - - /* make space occupied by ncstrp->cp part of ncstrp */ - ncstrp->nchars = (MPI_Offset)slen; - ncstrp->cp = (char *)ncstrp + sizeof_NC_string; - - /* in PnetCDF, we want to make name->cp always NULL character terminated */ - if (str != NULL && *str != '\0') { - strncpy(ncstrp->cp, str, slen); - ncstrp->cp[slen] = '\0'; /* NULL terminated */ - } - - return(ncstrp); -} - - -/*----< ncmpio_set_NC_string() >---------------------------------------------*/ -/* - * If possible, change the value of an NC_string to 'str'. - */ -int -ncmpio_set_NC_string(NC_string *ncstrp, - const char *str) -{ - size_t slen; - - assert(str != NULL && *str != '\0'); - - slen = strlen(str); - - if (ncstrp->nchars < (MPI_Offset)slen) DEBUG_RETURN_ERROR(NC_ENOTINDEFINE) - - memcpy(ncstrp->cp, str, slen); - - /* in PnetCDF, we want to make name->cp always NULL character terminated */ - if (ncstrp->nchars > (MPI_Offset)slen) - memset(ncstrp->cp + slen, 0, (size_t)ncstrp->nchars - slen); - - ncstrp->nchars = (MPI_Offset)slen; - - return NC_NOERR; -} - -/*@ - ncmpio_data_repack - copy data between two buffers with different datatypes. - - Input: -. inbuf - input buffer where data is copied from -. incount - number of input elements -. intype - datatype of each element in input buffer -. outbuf - output buffer where data is copied to -. outcount - number of output elements -. outtype - datatype of each element in output buffer -@*/ - -int ncmpio_data_repack(void *inbuf, - MPI_Offset incount, - MPI_Datatype intype, - void *outbuf, - MPI_Offset outcount, - MPI_Datatype outtype) -{ - int intypesz, outtypesz; - int packsz; - void *packbuf; - int packpos; - - MPI_Type_size(intype, &intypesz); - MPI_Type_size(outtype, &outtypesz); - - if (incount*intypesz != outcount*outtypesz) { - /* input data amount does not match output data amount */ - /* NOTE: we ignore it for user responsibility or add error handling ? */ - - /* for rescue, guarantee output data amount <= input data amount */ - if (incount*intypesz < outcount*outtypesz) - outcount = incount*intypesz/outtypesz; - } - - if (incount == 0) - return NC_NOERR; - - /* local pack-n-unpack, using MPI_COMM_SELF */ - if (incount != (int)incount) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - if (outcount != (int)outcount) DEBUG_RETURN_ERROR(NC_EINTOVERFLOW) - - MPI_Pack_size((int)incount, intype, MPI_COMM_SELF, &packsz); - packbuf = (void *)NCI_Malloc((size_t)packsz); - packpos = 0; - MPI_Pack(inbuf, (int)incount, intype, packbuf, packsz, &packpos, MPI_COMM_SELF); - packpos = 0; - MPI_Unpack(packbuf, packsz, &packpos, outbuf, (int)outcount, outtype, MPI_COMM_SELF); - NCI_Free(packbuf); - - return NC_NOERR; -} - -/*----< ncmpio_cktype() >----------------------------------------------------*/ -/* Verify that this is a user nc_type */ -int -ncmpio_cktype(int cdf_ver, nc_type type) -{ - /* the max data type supported by CDF-5 is NC_UINT64 */ - if (type <= 0 || type > NC_UINT64) - DEBUG_RETURN_ERROR(NC_EBADTYPE) - - /* For CDF-1 and CDF-2 files, only classic types are allowed. */ - if (cdf_ver < 5 && type > NC_DOUBLE) - DEBUG_RETURN_ERROR(NC_ESTRICTCDF2) - - return NC_NOERR; -} - diff --git a/src/drivers/ncmpio/Legacy/mpincio.c b/src/drivers/ncmpio/Legacy/mpincio.c deleted file mode 100644 index f2070e262..000000000 --- a/src/drivers/ncmpio/Legacy/mpincio.c +++ /dev/null @@ -1,627 +0,0 @@ -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifdef HAVE_ACCESS -#include /* access() */ -#endif -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#include -#include -#include /* strchr() */ -#ifdef _MSC_VER /* Microsoft Compilers */ -#include -#else -#include -#endif - -/* #define INSTRUMENT 1 */ -#ifdef INSTRUMENT /* debugging */ -#undef NDEBUG -#include -#include "instr.h" -#endif - -#include - -#include -#include -#include "nc.h" -#include "ncio.h" -#include "fbits.h" -#include "rnd.h" - -#if !defined(NDEBUG) && !defined(X_INT_MAX) -#define X_INT_MAX INT_MAX -#endif - -#if 0 /* !defined(NDEBUG) && !defined(X_ALIGN) */ -#define X_ALIGN 4 -#else -#undef X_ALIGN -#endif - -inline void -ncmpiio_free(ncio *nciop) { - if (nciop != NULL) { -#ifdef HAVE_MPI_INFO_FREE - if (nciop->mpiinfo != MPI_INFO_NULL) - MPI_Info_free(&(nciop->mpiinfo)); -#endif - if (nciop->comm != MPI_COMM_NULL) - MPI_Comm_free(&(nciop->comm)); - - NCI_Free(nciop); - } -} - -inline ncio * -ncmpiio_new(const char *path, int ioflags) -{ - size_t sz_ncio = M_RNDUP(sizeof(ncio)); - size_t sz_path = M_RNDUP(strlen(path) +1); - ncio *nciop; - - nciop = (ncio *) NCI_Malloc(sz_ncio + sz_path); - if (nciop == NULL) return NULL; - - nciop->ioflags = ioflags; - nciop->comm = MPI_COMM_NULL; - nciop->mpiinfo = MPI_INFO_NULL; - nciop->put_size = 0; - nciop->get_size = 0; - - nciop->path = (char *) ((char *)nciop + sz_ncio); - (void) strcpy((char *)nciop->path, path); - - return nciop; -} - -/*----< ncmpiio_extract_hints() >--------------------------------------------*/ -/* this is where the I/O hints designated to pnetcdf are extracted */ -static -void ncmpiio_extract_hints(ncio *nciop, - MPI_Info info) -{ - char value[MPI_MAX_INFO_VAL]; - int flag; - - /* value 0 indicates the hint is not set */ - nciop->hints.h_align = 0; - nciop->hints.v_align = 0; - nciop->hints.r_align = 0; - nciop->hints.header_read_chunk_size = 0; -#ifdef ENABLE_SUBFILING - nciop->hints.subfile_mode = 1; - nciop->hints.num_subfiles = 0; -#endif - - /* extract NC hints */ - if (info == MPI_INFO_NULL) return; - - MPI_Info_get(info, "nc_header_align_size", MPI_MAX_INFO_VAL-1, value, - &flag); - if (flag) { - errno = 0; - nciop->hints.h_align = strtoll(value,NULL,10); - if (errno != 0) nciop->hints.h_align = 0; - } - - MPI_Info_get(info, "nc_var_align_size", MPI_MAX_INFO_VAL-1, value, - &flag); - if (flag) { - errno = 0; - nciop->hints.v_align = strtoll(value,NULL,10); - if (errno != 0) nciop->hints.v_align = 0; - } - - MPI_Info_get(info, "nc_record_align_size", MPI_MAX_INFO_VAL-1, - value, &flag); - if (flag) { - errno = 0; - nciop->hints.r_align = strtoll(value,NULL,10); - if (errno != 0) nciop->hints.r_align = 0; - } - - MPI_Info_get(info, "nc_header_read_chunk_size", MPI_MAX_INFO_VAL-1, - value, &flag); - if (flag) { - errno = 0; - nciop->hints.header_read_chunk_size = strtoll(value,NULL,10); - if (errno != 0) nciop->hints.header_read_chunk_size = 0; - } - -#ifdef ENABLE_SUBFILING - MPI_Info_get(info, "pnetcdf_subfiling", MPI_MAX_INFO_VAL-1, - value, &flag); - if (flag && strcasecmp(value, "disable") == 0) - nciop->hints.subfile_mode = 0; - - MPI_Info_get(info, "nc_num_subfiles", MPI_MAX_INFO_VAL-1, - value, &flag); - if (flag) { - errno = 0; - nciop->hints.num_subfiles = strtoll(value,NULL,10); - if (errno != 0) nciop->hints.num_subfiles = 0; - } -#endif - - /* nc_header_align_size, nc_var_align_size, and nciop->hints.r_align - * take effect when a file is created or opened and later adding more - * header or variable data */ - - if (nciop->hints.h_align < 0) - nciop->hints.h_align = 0; - if (nciop->hints.v_align < 0) - nciop->hints.v_align = 0; - if (nciop->hints.r_align < 0) - nciop->hints.r_align = 0; - if (nciop->hints.header_read_chunk_size < 0) - nciop->hints.header_read_chunk_size = 0; -#ifdef ENABLE_SUBFILING - if (nciop->hints.num_subfiles < 0) - nciop->hints.num_subfiles = 0; - /* override subfile hints if env var is set */ - char *num_sf_env; - num_sf_env = getenv("NC_NUM_SUBFILES"); - if (num_sf_env != NULL) { - errno = 0; - nciop->hints.num_subfiles = (int)strtol(num_sf_env,NULL,10); - if (errno != 0) nciop->hints.num_subfiles = 0; - } - if (nciop->hints.subfile_mode == 0) - nciop->hints.num_subfiles = 0; -#endif -} - -/*----< ncmpiio_create() >---------------------------------------------------*/ -int -ncmpiio_create(MPI_Comm comm, - const char *path, - int ioflags, - MPI_Info info, - NC *ncp) -{ - ncio *nciop; - int rank, mpireturn, err; - int mpiomode = MPI_MODE_RDWR | MPI_MODE_CREATE; - - /* checking path consistency is expected to be done in MPI-IO */ - - MPI_Comm_rank(comm, &rank); - - /* NC_CLOBBER is the default mode, even if it is not used in cmode. - * Note ioflags has been checked for consistency before entering this API. - */ - if (fIsSet(ioflags, NC_NOCLOBBER)) { - /* check if file exists: NetCDF requires NC_EEXIST returned if the file - * already exists and NC_NOCLOBBER mode is used in create - */ -#ifdef HAVE_ACCESS - int file_exist; - /* if access() is available, use it to check whether file already exists - * rank 0 calls access() and broadcasts file_exist */ - if (rank == 0) { - /* remove the file system type prefix name if there is any. - * For example, path=="lustre:/home/foo/testfile.nc", - * use "/home/foo/testfile.nc" when calling access() - */ - char *filename = strchr(path, ':'); - if (filename == NULL) /* no prefix */ - filename = (char*)path; - else - filename++; - - if (access(filename, F_OK) == 0) file_exist = 1; - else file_exist = 0; - } - TRACE_COMM(MPI_Bcast)(&file_exist, 1, MPI_INT, 0, comm); - if (file_exist) DEBUG_RETURN_ERROR(NC_EEXIST) -#else - /* use MPI_MODE_EXCL mode in MPI_File_open and check returned error */ - fSet(mpiomode, MPI_MODE_EXCL); -#endif - } - else { /* NC_CLOBBER is the default mode in create */ - /* rank 0 deletes the file and ignores error code for file not exist - * Note calling MPI_File_set_size is expensive as it calls truncate() - */ - if (rank == 0) { -#ifdef HAVE_UNLINK - err = unlink(path); - if (err < 0 && errno != ENOENT) /* ignore ENOENT: file not exist */ - DEBUG_ASSIGN_ERROR(err, NC_EFILE) /* other error */ - else - err = NC_NOERR; -#else - err = NC_NOERR; - TRACE_IO(MPI_File_delete)((char*)path, MPI_INFO_NULL); - if (mpireturn != MPI_SUCCESS) { - int errorclass; - MPI_Error_class(mpireturn, &errorclass); - if (errorclass != MPI_ERR_NO_SUCH_FILE) /* ignore this error */ - err = ncmpii_handle_error(mpireturn, "MPI_File_delete"); - } -#endif - } - /* all processes must wait here until file deletion is completed */ - TRACE_COMM(MPI_Bcast)(&err, 1, MPI_INT, 0, comm); - if (err != NC_NOERR) return err; - } - - /* ignore if NC_NOWRITE set by user */ - fSet(ioflags, NC_WRITE); - - /* allocate ncio object */ - nciop = ncmpiio_new(path, ioflags); - if (nciop == NULL) DEBUG_RETURN_ERROR(NC_ENOMEM) - - nciop->mpiomode = MPI_MODE_RDWR; - nciop->mpioflags = 0; - - /* intialize hints and extract PnetCDF-level hints */ - ncmpiio_extract_hints(nciop, info); - - /* open file in parallel */ - TRACE_IO(MPI_File_open)(comm, (char *)path, mpiomode, info, - &nciop->collective_fh); - if (mpireturn != MPI_SUCCESS) { - ncmpiio_free(nciop); -#ifndef HAVE_ACCESS - if (fIsSet(ioflags, NC_NOCLOBBER)) { - /* This is the case when NC_NOCLOBBER is used in file creation and - * function access() is not available. MPI_MODE_EXCL is set in open - * mode. When MPI_MODE_EXCL is used and the file already exists, - * MPI-IO should return error class MPI_ERR_FILE_EXISTS. But, some - * MPI-IO implementations (older ROMIO) do not correctly return - * this error class. In this case, we can do the followings: check - * errno to see if it set to EEXIST. Note usually rank 0 makes the - * file open call and can be the only one having errno set. - */ - TRACE_COMM(MPI_Bcast)(&errno, 1, MPI_INT, 0, comm); - if (errno == EEXIST) DEBUG_RETURN_ERROR(NC_EEXIST) - } -#endif - return ncmpii_handle_error(mpireturn, "MPI_File_open"); - /* for NC_NOCLOBBER, MPI_MODE_EXCL was added to mpiomode. If the file - * already exists, MPI-IO should return error class MPI_ERR_FILE_EXISTS - * which PnetCDF will return error code NC_EEXIST. This is checked - * inside of ncmpii_handle_error() - */ - } - - /* collective I/O mode is the default mode */ - set_NC_collectiveFh(nciop); - - /* duplicate communicator as user may free it later */ - mpireturn = MPI_Comm_dup(comm, &(nciop->comm)); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_Comm_dup"); - - /* get the file info actually used by MPI-IO (maybe alter user's info) */ - mpireturn = MPI_File_get_info(nciop->collective_fh, &nciop->mpiinfo); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_File_get_info"); - - ncp->nciop = nciop; - return NC_NOERR; -} - -/*----< ncmpiio_open() >-----------------------------------------------------*/ -int -ncmpiio_open(MPI_Comm comm, - const char *path, - int ioflags, - MPI_Info info, - NC *ncp) -{ - ncio *nciop; - int mpireturn; - int mpiomode = fIsSet(ioflags, NC_WRITE) ? MPI_MODE_RDWR : MPI_MODE_RDONLY; - - /* Note ioflags has been checked for consistency before entering this API. - */ - - assert(ncp != NULL); - - /* checking path consistency is expected done in MPI-IO */ - - /* When open an non-existing file for read, we can either call access() to - * check and return error code NC_ENOENT, or call MPI_File_open and expect - * error class MPI_ERR_NO_SUCH_FILE. For now, we let MPI-IO to check. - */ -#if 0 && defined(HAVE_ACCESS) - if (mpiomode == MPI_MODE_RDONLY) { /* file should already exit */ - int rank, file_exist; - MPI_Comm_rank(comm, &rank); - if (rank == 0) { - if (access(path, F_OK) == 0) file_exist = 1; - else file_exist = 0; - } - TRACE_COMM(MPI_Bcast)(&file_exist, 1, MPI_INT, 0, comm); - if (!file_exist) DEBUG_RETURN_ERROR(NC_ENOENT) - } -#endif - - /* allocate ncio object */ - nciop = ncmpiio_new(path, ioflags); - if (nciop == NULL) DEBUG_RETURN_ERROR(NC_ENOMEM) - - nciop->mpiomode = mpiomode; - nciop->mpioflags = 0; - - /* intialize hints and extract PnetCDF-level hints */ - ncmpiio_extract_hints(nciop, info); - - /* open file in parallel */ - TRACE_IO(MPI_File_open)(comm, (char *)path, mpiomode, info, - &nciop->collective_fh); - if (mpireturn != MPI_SUCCESS) { - ncmpiio_free(nciop); - return ncmpii_handle_error(mpireturn, "MPI_File_open"); - } - - /* default mode is collective */ - set_NC_collectiveFh(nciop); - - /* duplicate MPI communicator as user may free it later */ - mpireturn = MPI_Comm_dup(comm, &(nciop->comm)); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_Comm_dup"); - - /* get the file info used by MPI-IO */ - mpireturn = MPI_File_get_info(nciop->collective_fh, &nciop->mpiinfo); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_File_get_info"); - - ncp->nciop = nciop; - return NC_NOERR; -} - -/*----< ncmpiio_sync() >-----------------------------------------------------*/ -/* This function must be called collectively, no matter if it is in collective - * or independent data mode. - */ -inline int -ncmpiio_sync(ncio *nciop) { -#ifndef DISABLE_FILE_SYNC - int mpireturn; - - if (NC_independentFhOpened(nciop)) { - TRACE_IO(MPI_File_sync)(nciop->independent_fh); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_File_sync"); - } - if (NC_collectiveFhOpened(nciop)) { - TRACE_IO(MPI_File_sync)(nciop->collective_fh); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_File_sync"); - } - TRACE_COMM(MPI_Barrier)(nciop->comm); -#endif - return NC_NOERR; -} - -/*----< ncmpiio_close() >----------------------------------------------------*/ -int -ncmpiio_close(ncio *nciop, int doUnlink) { - int mpireturn; - - if (nciop == NULL) /* this should never occur */ - DEBUG_RETURN_ERROR(NC_EINVAL) - - if (NC_independentFhOpened(nciop)) { - TRACE_IO(MPI_File_close)(&(nciop->independent_fh)); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_File_close"); - } - - if (NC_collectiveFhOpened(nciop)) { - TRACE_IO(MPI_File_close)(&(nciop->collective_fh)); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_File_close"); - } - - if (doUnlink) { - TRACE_IO(MPI_File_delete)((char *)nciop->path, nciop->mpiinfo); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_File_delete"); - } - ncmpiio_free(nciop); - - return NC_NOERR; -} - -/*----< ncmpiio_move() >-----------------------------------------------------*/ -int -ncmpiio_move(ncio *const nciop, - MPI_Offset to, - MPI_Offset from, - MPI_Offset nbytes) -{ - int rank, nprocs, bufcount, mpireturn, err, status=NC_NOERR, min_st; - void *buf; - int chunk_size=1048576; /* move 1 MB per process at a time */ - MPI_Status mpistatus; - - MPI_Comm_size(nciop->comm, &nprocs); - MPI_Comm_rank(nciop->comm, &rank); - - /* if the file striping unit size is known (obtained from MPI-IO), then - * we use that instead of 1 MB */ - if (nciop->striping_unit > 0) chunk_size = nciop->striping_unit; - - /* buf will be used as a temporal buffer to move data in chunks, i.e. - * read a chunk and later write to the new location */ - buf = NCI_Malloc((size_t)chunk_size); - if (buf == NULL) DEBUG_RETURN_ERROR(NC_ENOMEM) - - /* make fileview entire file visible */ - TRACE_IO(MPI_File_set_view)(nciop->collective_fh, 0, MPI_BYTE, MPI_BYTE, - "native", MPI_INFO_NULL); - - /* move the variable starting from its tail toward its beginning */ - while (nbytes > 0) { - int get_size=0; - - /* calculate how much to move at each time */ - bufcount = chunk_size; - if (nbytes < (MPI_Offset)nprocs * chunk_size) { - /* handle the last group of chunks */ - MPI_Offset rem_chunks = nbytes / chunk_size; - if (rank > rem_chunks) /* these processes do not read/write */ - bufcount = 0; - else if (rank == rem_chunks) /* this process reads/writes less */ - bufcount = (int)(nbytes % chunk_size); - nbytes = 0; - } - else { - nbytes -= chunk_size*nprocs; - } - - /* explicitly initialize mpistatus object to 0, see comments below */ - memset(&mpistatus, 0, sizeof(MPI_Status)); - - /* read the original data @ from+nbytes+rank*chunk_size */ - TRACE_IO(MPI_File_read_at_all)(nciop->collective_fh, - from+nbytes+rank*chunk_size, - buf, bufcount, MPI_BYTE, &mpistatus); - if (mpireturn != MPI_SUCCESS) { - err = ncmpii_handle_error(mpireturn, "MPI_File_read_at_all"); - if (err == NC_EFILE) DEBUG_ASSIGN_ERROR(status, NC_EREAD) - } - else { - /* for zero-length read, MPI_Get_count may report incorrect result - * for some MPICH version, due to the uninitialized MPI_Status - * object passed to MPI-IO calls. Thus we initialize it above to - * work around. Otherwise we can just use: - nciop->get_size += bufcount; - */ - MPI_Get_count(&mpistatus, MPI_BYTE, &get_size); - nciop->get_size += get_size; - } - - /* MPI_Barrier(nciop->comm); */ - /* important, in case new region overlaps old region */ - TRACE_COMM(MPI_Allreduce)(&status, &min_st, 1, MPI_INT, MPI_MIN, nciop->comm); - status = min_st; - if (status != NC_NOERR) break; - - /* write to new location @ to+nbytes+rank*chunk_size - * - * Ideally, we should write the amount of get_size returned from a call - * to MPI_Get_count in the below MPI write. This is in case some - * variables are defined but never been written. The value returned by - * MPI_Get_count is supposed to be the actual amount read by the MPI - * read call. If partial data (or none) is available for read, then we - * should just write that amount. Note this MPI write is collective, - * and thus all processes must participate the call even if get_size - * is 0. However, in some MPICH versions MPI_Get_count fails to report - * the correct value due to an internal error that fails to initialize - * the MPI_Status object. Therefore, the solution can be either to - * explicitly initialize the status object to zeros, or to just use - * bufcount for write. Note that the latter will write the variables - * that have not been written before. Below uses the former option. - */ - TRACE_IO(MPI_File_write_at_all)(nciop->collective_fh, - to+nbytes+rank*chunk_size, - buf, get_size /* bufcount */, - MPI_BYTE, &mpistatus); - if (mpireturn != MPI_SUCCESS) { - err = ncmpii_handle_error(mpireturn, "MPI_File_write_at_all"); - if (err == NC_EFILE) DEBUG_ASSIGN_ERROR(status, NC_EWRITE) - } - else { - /* for zero-length read, MPI_Get_count may report incorrect result - * for some MPICH version, due to the uninitialized MPI_Status - * object passed to MPI-IO calls. Thus we initialize it above to - * work around. Otherwise we can just use: - nciop->put_size += bufcount; - */ - int put_size; - MPI_Get_count(&mpistatus, MPI_BYTE, &put_size); - nciop->put_size += put_size; - } - TRACE_COMM(MPI_Allreduce)(&status, &min_st, 1, MPI_INT, MPI_MIN, nciop->comm); - status = min_st; - if (status != NC_NOERR) break; - } - NCI_Free(buf); - return status; -} - -/*----< ncmpiio_move_fixed_vars() >-------------------------------------------*/ -/* move one fixed variable at a time, only when the new begin > old begin */ -int -ncmpiio_move_fixed_vars(NC *ncp, - NC *old) -{ - int i, err, status=NC_NOERR; - - /* move starting from the last fixed variable */ - for (i=old->vars.ndefined-1; i>=0; i--) { - if (IS_RECVAR(old->vars.value[i])) continue; - - MPI_Offset from = old->vars.value[i]->begin; - MPI_Offset to = ncp->vars.value[i]->begin; - if (to > from) { - err = ncmpiio_move(ncp->nciop, to, from, ncp->vars.value[i]->len); - if (status == NC_NOERR) status = err; - } - } - return status; -} - -int ncmpiio_get_hint(NC *ncp, char *key, char *value, int *flag) -{ - MPI_Info info; - - /* info hints can come from the file system but can also come from - * user-specified hints. the MPI implementation probably should - * merge the two, but some implementations not only ignore hints - * they don't understand, but also fail to incorporate those hints - * into the info struct (this is unfortunate for us, but entirely - * standards compliant). - * - * Our policy will be to use the implementation's info first - * (perhaps the implementation knows something about the underlying - * file system), and then consult user-supplied hints should we not - * find the hint in the info associated with the MPI file descriptor - */ - - /* first check the hint from the MPI library ... */ - MPI_File_get_info(ncp->nciop->collective_fh, &info); - if (info != MPI_INFO_NULL) - MPI_Info_get(info, key, MPI_MAX_INFO_VAL-1, value, flag); - if (*flag == 0) { - /* ... then check the hint passed in through ncmpi_create */ - if (ncp->nciop->mpiinfo != MPI_INFO_NULL) { - MPI_Info_get(ncp->nciop->mpiinfo, key, - MPI_MAX_INFO_VAL-1, value, flag); - } - } -#ifdef HAVE_MPI_INFO_FREE - if (info != MPI_INFO_NULL) - MPI_Info_free(&info); -#endif - - return 0; -} - -/* - * Local variables: - * c-indent-level: 4 - * c-basic-offset: 4 - * End: - * - * vim: ts=8 sts=4 sw=4 expandtab - */ diff --git a/src/drivers/ncmpio/Legacy/mpinetcdf.c b/src/drivers/ncmpio/Legacy/mpinetcdf.c deleted file mode 100644 index a48ccb320..000000000 --- a/src/drivers/ncmpio/Legacy/mpinetcdf.c +++ /dev/null @@ -1,1121 +0,0 @@ -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#include -#include /* strtok(), strcpy(), strchr() */ -#include /* strcasecmp() */ - -#include - -#include -#include -#include "nc.h" -#include "ncx.h" -#ifdef ENABLE_SUBFILING -#include "subfile.h" -#endif - -/* Begin Of Dataset Functions */ - -/*----< ncmpii_create() >----------------------------------------------------*/ -/** \ingroup datasets -Create a new netCDF file. - -This function creates a new netCDF dataset, returning a netCDF ID that can -subsequently be used to refer to the netCDF dataset in other PnetCDF function -calls. The new netCDF dataset opened for write access and placed in define -mode, ready for you to add dimensions, variables, and attributes. - -\param comm The MPI communicator. This API is a collective routine: all -processes must provide the same value for cmode, and all processes must provide -filenames that reference the same file. (Values for info may vary.) comm must -be an MPI intracommunicator. - -\param path The file name of the new netCDF dataset. - -\param cmode The creation mode flag. The following flags are available: -NC_NOCLOBBER, NC_SHARE, NC_64BIT_OFFSET, and NC_64BIT_DATA. - -\param info MPI info object. It is used to provide file access hints,including -existing MPI hints as well as PnetCDF hints. For MPI hints, users are referred -to MPI user guide for further information. For PnetCDF hints see below. - -\param ncidp Pointer to location where returned netCDF ID is to be stored. - -

The cmode Flag

- -The cmode flag is used to control the type of file created, and some aspects of -how it may be used. - -Setting NC_NOCLOBBER means you do not want to clobber (overwrite) an existing -dataset; an error (NC_EEXIST) is returned if the specified dataset already -exists. - -The NC_SHARE flag in PnetCDF does not mean sharing the file with the processes -in this MPI program. Instead, it means the file will be concurrently shared -by a different MPI program. Hence, PnetCDF calls MPI_File_sync() right after -every time an MPI_File_write() call is made. This includes writing to metadata -(file header) as well as array data. - -Setting NC_64BIT_OFFSET causes PnetCDF to create a 64-bit offset format file -(CDF-2), instead of a netCDF classic format file. The 64-bit offset format -imposes far fewer restrictions on large (i.e. over 2 GB) data files. See Large -File Support (The PnetCDF Users Guide). - -Setting NC_64BIT_DATA causes PnetCDF to create a 64-bit data format file -(CDF-5). The 64-bit data format allows define variables with more than 4 -billion array elements. See Large File Support (The PnetCDF Users Guide). - -A zero value (defined for convenience as NC_CLOBBER) specifies the default -behavior: overwrite any existing dataset with the same file name. - -

The info object Flag

- -Starting from version 1.3.1, the following PnetCDF hints are available: - -- nc_header_align_size: This hint allows some extra space between the end of -the header describing the entire file and the first variable. If you have an -application that periodically wishes to add more variables to an already -existing file, expanding the file header size may result in an expensive move -of the entire data file to make room for the definition of the new variables. -Hence, setting this hint to a value that is big enough to accommodate any -additional variables means you may leave your application code as-is and yet -still see tremendous performance improvements. - -- nc_var_align_size: If you are writing to a block-based parallel file system, -such as IBM's GPFS or Lustre, then an application write becomes a block write -at the file system layer. If a write straddles two blocks, then locks must be -acquired for both blocks. Aligning the start of a variable to a block boundary, -combined with collective I/O optimization in the MPI-IO library can often -eliminate all unaligned file system accesses. - -- nc_record_align_size: This hint aligns the starting file offset of the -record variable section. - -- nc_header_read_chunk_size: PnetCDF reads the file headers in chunks. This -hint indicates the chunk size (in bytes). The default is 256 KB. - -\returns ::NC_NOERR No error. -\returns ::NC_ENOMEM System out of memory. -\returns ::NC_EEXIST Specified file name exists when using NC_NOCLOBBER. -Can be use to check if the file exists. -\returns ::NC_EMULTIDEFINE_OMODE Bad file create/open mode or modes are -inconsistent across processes -\returns ::NC_EFILE: Unknown error in file operation - -

Examples

- -In this example we create a netCDF dataset named foo.nc; we want the dataset to -be created in the current directory only if a dataset with that name does not -already exist: - -@code - #include - #include - ... - int status; - int ncid; - MPI_Info info; - ... - MPI_Info_create (&info); - MPI_Info_set (info, "romio_no_indep_rw", "true"); - MPI_Info_set (info, "nc_header_align_size", "4194304"); - MPI_Info_set (info, "nc_var_align_size", "1048576"); - MPI_Info_set (info, "nc_record_align_size", "1048576"); - - status = ncmpi_create(MPI_COMM_WORLD, "foo.nc", NC_NOCLOBBER, info, &ncid); - if (status != NC_NOERR) handle_error(status); - MPI_Info_free(&info); -@endcode - -In this example we create a netCDF dataset named foo.nc. It will -be in the CDF-5 format. - -@code - #include - #include - ... - int status; - int ncid; - int cmode = NC_NOCLOBBER | NC_64BIT_DATA; - MPI_Info info = MPI_INFO_NULL; - ... - status = ncmpi_create(MPI_COMM_WORLD, "foo.nc", cmode, info, &ncid); - if (status != NC_NOERR) handle_error(status); -@endcode -*/ -int -ncmpii_create(MPI_Comm comm, - const char *path, - int cmode, - int ncid, - MPI_Info info, - void **ncpp) -{ - int i, err, safe_mode=0, mpireturn, default_format; - char *env_str; - MPI_Info env_info=MPI_INFO_NULL; - MPI_Offset chunksize=NC_DEFAULT_CHUNKSIZE; - NC *ncp=NULL; - -#ifdef PNETCDF_DEBUG - safe_mode = 1; - /* this configure time setting will be overwritten by the run-time - * environment variable PNETCDF_SAFE_MODE */ -#endif - /* get environment variable PNETCDF_SAFE_MODE - * if it is set to 1, then we perform a strict parameter consistent test - */ - if ((env_str = getenv("PNETCDF_SAFE_MODE")) != NULL) { - if (*env_str == '0') safe_mode = 0; - else safe_mode = 1; - /* if PNETCDF_SAFE_MODE is set but without a value, *env_str can - * be '\0' (null character). In this case, safe_mode is enabled */ - } - - /* path's validity and cmode consistency have been checked in ncmpi_create() - * in src/dispatchers/file.c */ - - /* check default format */ - ncmpi_inq_default_format(&default_format); - -#if SIZEOF_MPI_OFFSET < 8 - /* check cmode */ - if (fIsSet(cmode, NC_64BIT_DATA) || - fIsSet(cmode, NC_64BIT_OFFSET) || - default_format == NC_FORMAT_CDF5 || - default_format == NC_FORMAT_CDF2) { - /* unlike serial netcdf, we will not bother to support - * NC_64BIT_OFFSET on systems with off_t smaller than 8 bytes. - * serial netcdf has proven it's possible if datasets are small, but - * that's a hassle we don't want to worry about */ - DEBUG_RETURN_ERROR(NC_ESMALL) - } -#endif - - /* NC_DISKLESS is not supported yet */ - if (cmode & NC_DISKLESS) DEBUG_RETURN_ERROR(NC_EINVAL_CMODE) - - /* NC_MMAP is not supported yet */ - if (cmode & NC_MMAP) DEBUG_RETURN_ERROR(NC_EINVAL_CMODE) - - /* It is illegal to have both NC_64BIT_OFFSET & NC_64BIT_DATA */ - if ((cmode & (NC_64BIT_OFFSET|NC_64BIT_DATA)) == - (NC_64BIT_OFFSET|NC_64BIT_DATA)) { - DEBUG_RETURN_ERROR(NC_EINVAL_CMODE) - } - - /* take hints from the environment variable PNETCDF_HINTS - * a string of hints separated by ";" and each hint is in the - * form of hint=value. E.g. cb_nodes=16;cb_config_list=*:6 - * If this environment variable is set, it overrides any values that - * were set by using calls to MPI_Info_set in the application code. - */ - if (info != MPI_INFO_NULL) { -#ifdef HAVE_MPI_INFO_DUP - mpireturn = MPI_Info_dup(info, &env_info); - if (mpireturn != MPI_SUCCESS) - DEBUG_RETURN_ERROR(ncmpii_handle_error(mpireturn, "MPI_Info_dup")) -#else - printf("Warning: MPI info is ignored as MPI_Info_dup() is missing\n"); -#endif - } - if ((env_str = getenv("PNETCDF_HINTS")) != NULL) { - if (env_info == MPI_INFO_NULL) - MPI_Info_create(&env_info); /* ignore error */ - - char *env_str_cpy, *key; - env_str_cpy = (char*) NCI_Malloc(strlen(env_str)+1); - strcpy(env_str_cpy, env_str); - key = strtok(env_str_cpy, ";"); - while (key != NULL) { - char *val; - val = strchr(key, '='); - if (val == NULL) continue; /* ill-formed hint */ - *val = '\0'; - val++; - /* printf("env hint: key=%s val=%s\n",key,val); */ - MPI_Info_set(env_info, key, val); /* override or add */ - key = strtok(NULL, ";"); - } - NCI_Free(env_str_cpy); - } - - /* get header chunk size from user info */ - if (env_info != MPI_INFO_NULL) { - int flag; - char value[MPI_MAX_INFO_VAL]; - MPI_Info_get(env_info, "nc_header_read_chunk_size", MPI_MAX_INFO_VAL-1, - value, &flag); - if (flag) { - errno = 0; - chunksize = strtoll(value,NULL,10); - if (errno != 0) chunksize = NC_DEFAULT_CHUNKSIZE; - } - } - - /* allocate buffer for header object NC */ - ncp = ncmpii_new_NC(&chunksize); - if (ncp == NULL) { - if (env_info != MPI_INFO_NULL) MPI_Info_free(&env_info); - DEBUG_RETURN_ERROR(NC_ENOMEM) - } - - ncp->safe_mode = safe_mode; - ncp->abuf = NULL; - ncp->old = NULL; -#ifdef ENABLE_SUBFILING - ncp->subfile_mode = 1; - if (env_info != MPI_INFO_NULL) { - int flag; - char value[MPI_MAX_INFO_VAL]; - MPI_Info_get(env_info, "pnetcdf_subfiling", MPI_MAX_INFO_VAL-1, - value, &flag); - if (flag && strcasecmp(value, "disable") == 0) - ncp->subfile_mode = 0; - } - ncp->ncid_sf = -1; /* subfile ncid; init to -1 */ - ncp->nc_num_subfiles = 0; /* num_subfiles; init to 0 */ -#endif - - /* set the file format version based on the create mode, cmode */ - if (fIsSet(cmode, NC_64BIT_DATA)) { - fSet(ncp->flags, NC_64BIT_DATA); - ncp->format = 5; - } else if (fIsSet(cmode, NC_64BIT_OFFSET)) { - fSet(ncp->flags, NC_64BIT_OFFSET); - ncp->format = 2; - } else { - if (default_format == NC_FORMAT_CDF5) { - fSet(ncp->flags, NC_64BIT_DATA); - ncp->format = 5; - } - else if (default_format == NC_FORMAT_CDF2) { - fSet(ncp->flags, NC_64BIT_OFFSET); - ncp->format = 2; - } - else { - fSet(ncp->flags, NC_32BIT); - ncp->format = 1; - } - } - - /* find the true header size (not-yet aligned) */ - ncp->xsz = ncmpii_hdr_len_NC(ncp); - - /* PnetCDF default fill mode is no fill */ - fSet(ncp->flags, NC_NOFILL); - - /* open file collectively */ - err = ncmpiio_create(comm, path, cmode, env_info, ncp); - if (env_info != MPI_INFO_NULL) MPI_Info_free(&env_info); - if (err != NC_NOERR) { /* fatal error */ - if (err == NC_EMULTIDEFINE_OMODE) err = NC_EMULTIDEFINE_CMODE; - ncmpii_free_NC(ncp); - DEBUG_RETURN_ERROR(err) - } - - fSet(ncp->flags, NC_CREAT); - - /* initialize arrays storing pending non-blocking requests */ - ncp->numGetReqs = 0; - ncp->numPutReqs = 0; - ncp->get_list = NULL; - ncp->put_list = NULL; - - /* initialize unlimited_id as no unlimited dimension yet defined */ - ncp->dims.unlimited_id = -1; - -#ifndef SEARCH_NAME_LINEARLY - for (i=0; idims.nameT[i].num = 0; - ncp->dims.nameT[i].list = NULL; - /* initialize var name lookup table */ - ncp->vars.nameT[i].num = 0; - ncp->vars.nameT[i].list = NULL; - } -#endif - - ncp->ncid = ncid; - - *ncpp = (void*)ncp; - - return NC_NOERR; -} - -/*----< ncmpii_open() >------------------------------------------------------*/ -int -ncmpii_open(MPI_Comm comm, - const char *path, - int omode, - int ncid, - MPI_Info info, - void **ncpp) -{ - int i, err, status=NC_NOERR, safe_mode=0, mpireturn; - char *env_str; - MPI_Info env_info=MPI_INFO_NULL; - MPI_Offset chunksize=NC_DEFAULT_CHUNKSIZE; - NC *ncp=NULL; -#ifndef SEARCH_NAME_LINEARLY - NC_nametable *nameT; -#endif - -#ifdef PNETCDF_DEBUG - safe_mode = 1; - /* this configure time setting will be overwritten by the run-time - * environment variable PNETCDF_SAFE_MODE */ -#endif - /* get environment variable PNETCDF_SAFE_MODE - * if it is set to 1, then we perform a strict parameter consistent test - */ - if ((env_str = getenv("PNETCDF_SAFE_MODE")) != NULL) { - if (*env_str == '0') safe_mode = 0; - else safe_mode = 1; - /* if PNETCDF_SAFE_MODE is set but without a value, *env_str can - * be '\0' (null character). In this case, safe_mode is enabled */ - } - - /* path's validity and omode consistency have been checked in ncmpi_open() - * in src/dispatchers/file.c */ - - /* NC_DISKLESS is not supported yet */ - if (omode & NC_DISKLESS) DEBUG_RETURN_ERROR(NC_EINVAL_OMODE) - - /* NC_MMAP is not supported yet */ - if (omode & NC_MMAP) DEBUG_RETURN_ERROR(NC_EINVAL_OMODE) - - /* take hints from the environment variable PNETCDF_HINTS - * a string of hints separated by ";" and each hint is in the - * form of hint=value. E.g. cb_nodes=16;cb_config_list=*:6 - * If this environment variable is set, it overrides any values that - * were set by using calls to MPI_Info_set in the application code. - */ - if (info != MPI_INFO_NULL) { -#ifdef HAVE_MPI_INFO_DUP - mpireturn = MPI_Info_dup(info, &env_info); - if (mpireturn != MPI_SUCCESS) - DEBUG_RETURN_ERROR(ncmpii_handle_error(mpireturn, "MPI_Info_dup")) -#else - printf("Warning: MPI info is ignored as MPI_Info_dup() is missing\n"); -#endif - } - if ((env_str = getenv("PNETCDF_HINTS")) != NULL) { - if (env_info == MPI_INFO_NULL) - MPI_Info_create(&env_info); /* ignore error */ - - char *env_str_cpy, *key; - env_str_cpy = (char*) NCI_Malloc(strlen(env_str)+1); - strcpy(env_str_cpy, env_str); - key = strtok(env_str_cpy, ";"); - while (key != NULL) { - char *val; - val = strchr(key, '='); - if (val == NULL) continue; /* ill-formed hint */ - *val = '\0'; - val++; - /* printf("env hint: key=%s val=%s\n",key,val); */ - MPI_Info_set(env_info, key, val); /* override or add */ - key = strtok(NULL, ";"); - } - NCI_Free(env_str_cpy); - } - - /* get header chunk size from user info, if provided */ - if (env_info != MPI_INFO_NULL) { - int flag; - char value[MPI_MAX_INFO_VAL]; - MPI_Info_get(env_info, "nc_header_read_chunk_size", MPI_MAX_INFO_VAL-1, - value, &flag); - if (flag) { - errno = 0; - chunksize = strtoll(value,NULL,10); - if (errno != 0) chunksize = NC_DEFAULT_CHUNKSIZE; - } - } - - /* allocate NC file object */ - ncp = ncmpii_new_NC(&chunksize); - if (ncp == NULL) { - if (env_info != MPI_INFO_NULL) MPI_Info_free(&env_info); - DEBUG_RETURN_ERROR(NC_ENOMEM) - } - - ncp->safe_mode = safe_mode; - ncp->old = NULL; -#ifdef ENABLE_SUBFILING - ncp->subfile_mode = 1; - if (env_info != MPI_INFO_NULL) { - int flag; - char value[MPI_MAX_INFO_VAL]; - MPI_Info_get(env_info, "pnetcdf_subfiling", MPI_MAX_INFO_VAL-1, - value, &flag); - if (flag && strcasecmp(value, "disable") == 0) - ncp->subfile_mode = 0; - } - ncp->ncid_sf = -1; - ncp->nc_num_subfiles = 0; -#endif - - /* open the file in parallel */ - err = ncmpiio_open(comm, path, omode, env_info, ncp); - if (err != NC_NOERR) { /* fatal error */ - if (env_info != MPI_INFO_NULL) MPI_Info_free(&env_info); - ncmpii_free_NC(ncp); - if (status == NC_NOERR) status = err; - DEBUG_RETURN_ERROR(status) /* return the 1st error encountered */ - } - - /* PnetCDF's default mode is no fill */ - fSet(ncp->flags, NC_NOFILL); - - /* read header from file into an NC object pointed by ncp */ - err = ncmpii_hdr_get_NC(ncp); - if (err != NC_NOERR) { /* fatal error */ - ncmpiio_close(ncp->nciop, 0); - if (env_info != MPI_INFO_NULL) MPI_Info_free(&env_info); - ncmpii_free_NC(ncp); - if (status == NC_NOERR) status = err; - DEBUG_RETURN_ERROR(status) /* return the 1st error encountered */ - } - - /* initialize arrays storing pending non-blocking requests */ - ncp->numGetReqs = 0; - ncp->numPutReqs = 0; - ncp->get_list = NULL; - ncp->put_list = NULL; - -#ifdef ENABLE_SUBFILING - if (ncp->subfile_mode) { - /* check attr for subfiles */ - err = ncmpii_get_att(ncp, NC_GLOBAL, "num_subfiles", - &ncp->nc_num_subfiles, NC_INT); - if (err == NC_NOERR && ncp->nc_num_subfiles > 1) { - /* ignore error NC_ENOTATT if this attribute is not defined */ - int nvars; - - err = ncmpii_inq(ncp, NULL, &nvars, NULL, NULL); - - if (status == NC_NOERR) status = err; - - for (i=0; ivars.value[i]->num_subfiles, NC_INT); - if (err == NC_ENOTATT) continue; - if (err != NC_NOERR && status == NC_NOERR) { /* other error */ - status = err; - continue; - } - - if (ncp->vars.value[i]->num_subfiles > 1) { - err = ncmpii_get_att(ncp, i, "ndims_org", - &ncp->vars.value[i]->ndims_org, NC_INT); - if (status == NC_NOERR) status = err; - } - } - - if (ncp->nc_num_subfiles > 1) { - err = ncmpii_subfile_open(ncp, &ncp->ncid_sf); - if (status == NC_NOERR) status = err; - } - } - } - else - ncp->nc_num_subfiles = 0; -#endif - - if (env_info != info) MPI_Info_free(&env_info); - - /* update the total number of record variables */ - ncp->vars.num_rec_vars = 0; - for (i=0; ivars.ndefined; i++) - ncp->vars.num_rec_vars += IS_RECVAR(ncp->vars.value[i]); - -#ifndef SEARCH_NAME_LINEARLY - /* initialize dim name lookup table */ - nameT = ncp->dims.nameT; - memset(nameT, 0, sizeof(NC_nametable) * HASH_TABLE_SIZE); - - /* populate dim name lookup table */ - for (i=0; idims.ndefined; i++) { - /* hash the dim name into a key for name lookup */ - int key = HASH_FUNC(ncp->dims.value[i]->name->cp); - nameT = &ncp->dims.nameT[key]; - if (nameT->num % NC_NAME_TABLE_CHUNK == 0) - nameT->list = (int*) NCI_Realloc(nameT->list, - (size_t)(nameT->num+NC_NAME_TABLE_CHUNK) * SIZEOF_INT); - nameT->list[nameT->num] = i; - nameT->num++; - } - - /* initialize var name lookup table */ - nameT = ncp->vars.nameT; - memset(nameT, 0, sizeof(NC_nametable) * HASH_TABLE_SIZE); - - /* populate var name lookup table */ - for (i=0; ivars.ndefined; i++) { - /* hash the var name into a key for name lookup */ - int key = HASH_FUNC(ncp->vars.value[i]->name->cp); - nameT = &ncp->vars.nameT[key]; - if (nameT->num % NC_NAME_TABLE_CHUNK == 0) - nameT->list = (int*) NCI_Realloc(nameT->list, - (size_t)(nameT->num+NC_NAME_TABLE_CHUNK) * SIZEOF_INT); - nameT->list[nameT->num] = i; - nameT->num++; - } -#endif - - ncp->ncid = ncid; - - *ncpp = (void*)ncp; - - return status; -} - -/*----< ncmpii_redef() >-----------------------------------------------------*/ -/* This is a collective subroutine. */ -int -ncmpii_redef(void *ncdp) -{ - int err=NC_NOERR; - NC *ncp = (NC*)ncdp; - - if (NC_readonly(ncp)) DEBUG_RETURN_ERROR(NC_EPERM) /* read-only */ - /* if open mode is inconsistent, then this return might cause parallel - * program to hang */ - - /* cannot be in define mode, must enter from data mode */ - if (NC_indef(ncp)) DEBUG_RETURN_ERROR(NC_EINDEFINE) - - /* sync all metadata, including numrecs, if changed in independent mode. - * also ensure exiting define mode always entering collective data mode - */ - if (NC_indep(ncp)) - ncmpiio_end_indep_data(ncp); - - if (NC_doFsync(ncp)) { /* re-read the header from file */ - err = ncmpii_read_NC(ncp); - if (err != NC_NOERR) return err; - } - - /* duplicate a header to be used in enddef() for checking if header grows */ - ncp->old = ncmpii_dup_NC(ncp); - if (ncp->old == NULL) DEBUG_RETURN_ERROR(NC_ENOMEM) - - /* we are now entering define mode */ - fSet(ncp->flags, NC_INDEF); - - return NC_NOERR; -} - -/*----< ncmpii_begin_indep_data() >------------------------------------------*/ -/* This is a collective subroutine. */ -int -ncmpii_begin_indep_data(void *ncdp) -{ - int err=NC_NOERR; - NC *ncp = (NC*)ncdp; - - if (NC_indef(ncp)) /* must not be in define mode */ - DEBUG_RETURN_ERROR(NC_EINDEFINE) - - if (NC_indep(ncp)) /* already in indep data mode */ - return NC_NOERR; - - /* we need no MPI_File_sync() here. If users want a stronger data - * consistency, they can call ncmpi_sync() - */ -#if 0 && !defined(DISABLE_FILE_SYNC) - if (!NC_readonly(ncp) && NC_collectiveFhOpened(ncp->nciop)) { - /* calling file sync for those already open the file */ - int err, mpireturn; - /* MPI_File_sync() is collective */ - TRACE_IO(MPI_File_sync)(ncp->nciop->collective_fh); - if (mpireturn != MPI_SUCCESS) { - err = ncmpii_handle_error(mpireturn, "MPI_File_sync"); - if (err == NC_NOERR) return err; - } - TRACE_COMM(MPI_Barrier)(ncp->nciop->comm); - } -#endif - - fSet(ncp->flags, NC_INDEP); - - err = ncmpii_check_mpifh(ncp, 0); - - return err; -} - -/*----< ncmpii_end_indep_data() >--------------------------------------------*/ -/* This is a collective subroutine. */ -int -ncmpii_end_indep_data(void *ncdp) -{ - NC *ncp = (NC*)ncdp; - - if (!NC_indep(ncp)) /* must be in independent data mode */ - DEBUG_RETURN_ERROR(NC_ENOTINDEP) - - return ncmpiio_end_indep_data(ncp); -} - -/*----< ncmpiio_end_indep_data() >-------------------------------------------*/ -/* this function is called when: - * 1. ncmpi_end_indep_data() - * 2. ncmpi_redef() from independent data mode entering to define more - * 3. ncmpii_close() when closing the file - * This function is collective. - */ -int -ncmpiio_end_indep_data(NC *ncp) -{ - int status=NC_NOERR; - - if (!NC_readonly(ncp)) { - if (ncp->vars.num_rec_vars > 0) { - /* numrecs dirty bit may not be the same across all processes. - * force sync in memory no matter if dirty or not. - */ - set_NC_ndirty(ncp); - status = ncmpiio_sync_numrecs(ncp, ncp->numrecs); - /* the only possible dirty part of the header is numrecs */ - } - -#ifndef DISABLE_FILE_SYNC - /* calling file sync for those already open the file */ - if (NC_doFsync(ncp) && NC_independentFhOpened(ncp->nciop)) { - int mpireturn; - /* MPI_File_sync() is collective */ - TRACE_IO(MPI_File_sync)(ncp->nciop->independent_fh); - if (mpireturn != MPI_SUCCESS) { - int err = ncmpii_handle_error(mpireturn, "MPI_File_sync"); - if (status == NC_NOERR) status = err; - } - TRACE_COMM(MPI_Barrier)(ncp->nciop->comm); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_Barrier"); - } -#endif - } - - fClr(ncp->flags, NC_INDEP); - - return status; -} - -/*----< ncmpii_enddef() >----------------------------------------------------*/ -/* This is a collective subroutine. */ -int -ncmpii_enddef(void *ncdp) -{ - NC *ncp = (NC*)ncdp; - - if (!NC_indef(ncp)) /* must currently in define mode */ - DEBUG_RETURN_ERROR(NC_ENOTINDEFINE) - - return ncmpiio_enddef(ncp); -} - -/*----< ncmpii__enddef() >---------------------------------------------------*/ -/* This is a collective subroutine. */ -int -ncmpii__enddef(void *ncdp, - MPI_Offset h_minfree, - MPI_Offset v_align, - MPI_Offset v_minfree, - MPI_Offset r_align) -{ - int err=NC_NOERR; - NC *ncp = (NC*)ncdp; - - if (!NC_indef(ncp)) /* must currently in define mode */ - DEBUG_RETURN_ERROR(NC_ENOTINDEFINE) - - if (ncp->safe_mode) { - int status, mpireturn; - MPI_Offset root_args[4]; - - /* check if h_minfree, v_align, v_minfree, and r_align are consistent - * among all processes */ - root_args[0] = h_minfree; - root_args[1] = v_align; - root_args[2] = v_minfree; - root_args[3] = r_align; - TRACE_COMM(MPI_Bcast)(&root_args, 4, MPI_OFFSET, 0, ncp->nciop->comm); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_Bcast"); - - if (root_args[0] != h_minfree || - root_args[1] != v_align || - root_args[2] != v_minfree || - root_args[3] != r_align) - DEBUG_ASSIGN_ERROR(err, NC_EMULTIDEFINE_FNC_ARGS) - - /* find min error code across processes */ - TRACE_COMM(MPI_Allreduce)(&err, &status, 1, MPI_INT, MPI_MIN, ncp->nciop->comm); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_Allreduce"); - - if (status != NC_NOERR) return status; - } - - return ncmpiio__enddef(ncp, h_minfree, v_align, v_minfree, r_align); -} - -/*----< ncmpii_sync_numrecs() >-----------------------------------------------*/ -/* this API is collective, but can be called in independent data mode. - * Note numrecs is always sync-ed in memory and update in file in collective - * data mode. - */ -int -ncmpii_sync_numrecs(void *ncdp) -{ - int err=NC_NOERR; - NC *ncp=(NC*)ncdp; - - /* cannot be in define mode */ - if (NC_indef(ncp)) DEBUG_RETURN_ERROR(NC_EINDEFINE) - - /* check if we have defined record variables */ - if (ncp->vars.num_rec_vars == 0) return NC_NOERR; - - if (!NC_indep(ncp)) /* in collective data mode, numrecs is always sync-ed */ - return NC_NOERR; - else /* if called in independent mode, we force sync in memory */ - set_NC_ndirty(ncp); - - /* sync numrecs in memory and file */ - err = ncmpiio_sync_numrecs(ncp, ncp->numrecs); - -#ifndef DISABLE_FILE_SYNC - if (NC_doFsync(ncp)) { /* NC_SHARE is set */ - int mpierr, mpireturn; - if (NC_indep(ncp)) { - TRACE_IO(MPI_File_sync)(ncp->nciop->independent_fh); - } - else { - TRACE_IO(MPI_File_sync)(ncp->nciop->collective_fh); - } - if (mpireturn != MPI_SUCCESS) { - mpierr = ncmpii_handle_error(mpireturn, "MPI_File_sync"); - if (err == NC_NOERR) err = mpierr; - } - TRACE_COMM(MPI_Barrier)(ncp->nciop->comm); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_Barrier"); - } -#endif - return err; -} - -/*----< ncmpii_sync() >------------------------------------------------------*/ -/* This API is a collective subroutine, and must be called in data mode, no - * matter if it is in collective or independent data mode. - */ -int -ncmpii_sync(void *ncdp) -{ - int err; - NC *ncp = (NC*)ncdp; - - /* cannot be in define mode */ - if (NC_indef(ncp)) DEBUG_RETURN_ERROR(NC_EINDEFINE) - - if (NC_readonly(ncp)) - /* calling sync for file opened for read only means re-read header */ - return ncmpii_read_NC(ncp); - - /* the only part of header that can be dirty is numrecs (caused only by - * independent APIs) */ - if (ncp->vars.num_rec_vars > 0 && NC_indep(ncp)) { - /* sync numrecs in memory among processes and in file */ - set_NC_ndirty(ncp); - err = ncmpiio_sync_numrecs(ncp, ncp->numrecs); - if (err != NC_NOERR) return err; - } - - /* calling MPI_File_sync() on both collective and independent handlers */ - return ncmpiio_sync(ncp->nciop); -} - -/*----< ncmpii_abort() >-----------------------------------------------------*/ -/* This API is a collective subroutine */ -int -ncmpii_abort(void *ncdp) -{ - /* - * In data mode, same as ncmpiio_close. - * In define mode, descard new definition. - * If file is just created, remove the file. - */ - int status=NC_NOERR, err, doUnlink = 0; - NC *ncp = (NC*)ncdp; - - /* delete the file if it is newly created by ncmpi_create() */ - doUnlink = NC_IsNew(ncp); - - if (ncp->old != NULL) { - /* a plain redef, not a create */ - assert(!NC_IsNew(ncp)); - assert(fIsSet(ncp->flags, NC_INDEF)); - ncmpii_free_NC(ncp->old); - ncp->old = NULL; - fClr(ncp->flags, NC_INDEF); - } - - if (!doUnlink) { - if (!NC_readonly(ncp) && /* file is open for write */ - NC_indep(ncp)) { /* in independent data mode */ - status = ncmpiio_end_indep_data(ncp); /* sync header */ - } - - if (NC_doFsync(ncp)) { - err = ncmpiio_sync(ncp->nciop); /* calling MPI_File_sync() */ - if (status == NC_NOERR ) status = err; - } - } - - /* close the file */ - err = ncmpiio_close(ncp->nciop, doUnlink); - if (status == NC_NOERR ) status = err; - - ncp->nciop = NULL; - - /* free up space occupied by the header metadata */ - ncmpii_free_NC(ncp); - - return status; -} - -/*----< ncmpi_delete() >-----------------------------------------------------*/ -/* doesn't do anything to release resources, so call ncmpi_close before calling - * this function. - * - * filename: the name of the file we will remove. - * info: MPI info object, in case underlying file system needs hints. - */ -int -ncmpi_delete(const char *filename, - MPI_Info info) -{ - int err=NC_NOERR, mpireturn; - - TRACE_IO(MPI_File_delete)((char*)filename, info); - if (mpireturn != MPI_SUCCESS) - err = ncmpii_handle_error(mpireturn, "MPI_File_delete"); - return err; -} - -/* End Of Dataset Functions */ - -/*----< ncmpii_check_mpifh() >-----------------------------------------------*/ -int -ncmpii_check_mpifh(NC *ncp, - int collective) -{ - int mpireturn; - - if (collective && NC_indep(ncp)) /* collective handle but in indep mode */ - DEBUG_RETURN_ERROR(NC_EINDEP) - - if (!collective && !NC_indep(ncp)) /* indep handle but in collective mode */ - DEBUG_RETURN_ERROR(NC_ENOTINDEP) - - if (collective && !NC_collectiveFhOpened(ncp->nciop)) { - TRACE_IO(MPI_File_open)(ncp->nciop->comm, (char*)ncp->nciop->path, - ncp->nciop->mpiomode, ncp->nciop->mpiinfo, - &ncp->nciop->collective_fh); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_File_open"); - - set_NC_collectiveFh(ncp->nciop); - } - else if (!collective && !NC_independentFhOpened(ncp->nciop)) { - TRACE_IO(MPI_File_open)(MPI_COMM_SELF, (char*)ncp->nciop->path, - ncp->nciop->mpiomode, ncp->nciop->mpiinfo, - &ncp->nciop->independent_fh); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_File_open"); - - set_NC_independentFh(ncp->nciop); - } - - return NC_NOERR; -} - -/*----< ncmpii_inq_misc() >--------------------------------------------------*/ -/* This is an independent subroutine. */ -int -ncmpii_inq_misc(void *ncdp, - int *pathlen, - char *path, - int *num_fix_varsp, - int *num_rec_varsp, - int *striping_size, - int *striping_count, - MPI_Offset *header_size, - MPI_Offset *header_extent, - MPI_Offset *recsize, - MPI_Offset *put_size, - MPI_Offset *get_size, - MPI_Info *info_used, - int *nreqs, - MPI_Offset *usage, - MPI_Offset *buf_size) -{ - int i, flag, mpireturn; - char value[MPI_MAX_INFO_VAL]; - NC *ncp=(NC*)ncdp; - - /* Get the file pathname which was used to open/create the ncid's file. - * path must already be allocated. Ignored if NULL */ - if (ncp->nciop->path == NULL) { - if (pathlen != NULL) *pathlen = 0; - if (path != NULL) *path = '\0'; - } else { - if (pathlen != NULL) *pathlen = (int)strlen(ncp->nciop->path); - if (path != NULL) strcpy(path, ncp->nciop->path); - } - - /* obtain the number of fixed-size variables */ - if (num_fix_varsp != NULL) { - if (NC_indef(ncp)) { - /* if in define mode, recalculate the number of record variables */ - *num_fix_varsp = 0; - for (i=0; ivars.ndefined; i++) - *num_fix_varsp += IS_RECVAR(ncp->vars.value[i]); - } - else - *num_fix_varsp = ncp->vars.num_rec_vars; - - /* no. fixed-size == ndefined - no. record variables */ - *num_fix_varsp = ncp->vars.ndefined - *num_fix_varsp; - } - - /* obtain the number of record variables */ - if (num_rec_varsp != NULL) { - if (NC_indef(ncp)) { - /* if in define mode, recalculate the number of record variables */ - *num_rec_varsp = 0; - for (i=0; ivars.ndefined; i++) - *num_rec_varsp += IS_RECVAR(ncp->vars.value[i]); - } - else - *num_rec_varsp = ncp->vars.num_rec_vars; - } - - /* obtain file (system) striping settings, striping size and count, if they - * are available from MPI-IO hint. Otherwise, 0s are returned. - */ - if (striping_size != NULL) { - MPI_Info_get(ncp->nciop->mpiinfo, "striping_unit", MPI_MAX_INFO_VAL-1, - value, &flag); - *striping_size = 0; - if (flag) { - errno = 0; - *striping_size = (int)strtol(value,NULL,10); - if (errno != 0) *striping_size = 0; - } - } - - if (striping_count != NULL) { - MPI_Info_get(ncp->nciop->mpiinfo, "striping_factor", MPI_MAX_INFO_VAL-1, - value, &flag); - *striping_count = 0; - if (flag) { - errno = 0; - *striping_count = (int)strtol(value,NULL,10); - if (errno != 0) *striping_count = 0; - } - } - - /* the amount of writes, in bytes, committed to file system so far */ - if (put_size != NULL) *put_size = ncp->nciop->put_size; - - /* the amount of reads, in bytes, obtained from file system so far */ - if (get_size != NULL) *get_size = ncp->nciop->get_size; - - if (recsize != NULL) *recsize = ncp->recsize; - - if (header_size != NULL) *header_size = ncp->xsz; - - if (header_extent != NULL) *header_extent = ncp->begin_var; - - if (info_used != NULL) { -#ifdef HAVE_MPI_INFO_DUP - mpireturn = MPI_Info_dup(ncp->nciop->mpiinfo, info_used); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_Info_dup"); -#else - mpireturn = MPI_File_get_info(ncp->nciop->collective_fh, info_used); - if (mpireturn != MPI_SUCCESS) - return ncmpii_handle_error(mpireturn, "MPI_File_get_info"); -#endif - - sprintf(value, "%lld", ncp->nciop->hints.h_align); - MPI_Info_set(*info_used, "nc_header_align_size", value); - - sprintf(value, "%lld", ncp->nciop->hints.v_align); - MPI_Info_set(*info_used, "nc_var_align_size", value); - - sprintf(value, "%lld", ncp->nciop->hints.r_align); - MPI_Info_set(*info_used, "nc_record_align_size", value); - - sprintf(value, "%lld", ncp->nciop->hints.header_read_chunk_size); - MPI_Info_set(*info_used, "nc_header_read_chunk_size", value); - -#ifdef ENABLE_SUBFILING - sprintf(value, "%d", ncp->nciop->hints.subfile_mode); - MPI_Info_set(*info_used, "pnetcdf_subfiling", value); - sprintf(value, "%d", ncp->nciop->hints.num_subfiles); - MPI_Info_set(*info_used, "nc_num_subfiles", value); -#endif - } - - if (nreqs != NULL) { - /* cannot just use *nreqs = ncp->numGetReqs + ncp->numPutReqs; - * because some request IDs are repeated, such as record variables and - * varn requests - */ - *nreqs = 0; - for (i=0; inumGetReqs; i++) { - if (i > 0 && ncp->get_list[i].id == ncp->get_list[i-1].id) - continue; - (*nreqs)++; - } - for (i=0; inumPutReqs; i++) { - if (i > 0 && ncp->put_list[i].id == ncp->put_list[i-1].id) - continue; - (*nreqs)++; - } - } - - if (usage != NULL) { - /* check if the buffer has been previously attached */ - if (ncp->abuf == NULL) DEBUG_RETURN_ERROR(NC_ENULLABUF) - /* return the current usage in bytes */ - *usage = ncp->abuf->size_used; - } - - if (buf_size != NULL) { - /* check if the buffer has been previously attached */ - if (ncp->abuf == NULL) DEBUG_RETURN_ERROR(NC_ENULLABUF) - /* return the current usage in bytes */ - *buf_size = ncp->abuf->size_allocated; - } - - return NC_NOERR; -} - diff --git a/src/drivers/ncmpio/Legacy/ncio.h b/src/drivers/ncmpio/Legacy/ncio.h deleted file mode 100644 index d99a2a7f3..000000000 --- a/src/drivers/ncmpio/Legacy/ncio.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifndef _NCIO_H -#define _NCIO_H - -#include /* size_t */ -#include /* off_t */ -#include -#include "pnetcdf.h" - -#define MPI_COLLECTIVE_FH 2 -#define MPI_INDEPENDENT_FH 8 - -#define NC_collectiveFhOpened(nciop) \ - (fIsSet(nciop->mpioflags, MPI_COLLECTIVE_FH)) - -#define NC_independentFhOpened(nciop) \ - (fIsSet(nciop->mpioflags, MPI_INDEPENDENT_FH)) - -#define set_NC_collectiveFh(nciop) \ - fSet((nciop)->mpioflags, MPI_COLLECTIVE_FH) - -#define set_NC_independentFh(nciop) \ - fSet((nciop)->mpioflags, MPI_INDEPENDENT_FH) - - -/* - * netcdf i/o abstraction - */ -typedef struct { - /* - * A copy of the ioflags argument passed in to ncmpiio_open() - * or ncmpiio_create(). - */ - int ioflags; - int mpioflags; /* MPI_COLLECTIVE_FH or MPI_INDEPENDENT_FH */ - - int mpiomode; /* mode used in MPI_File_open, passed from collective open - to independent open */ - - /* - * The MPI File handle and the communicator - */ - MPI_File collective_fh; - MPI_File independent_fh; - MPI_Comm comm; - MPI_Info mpiinfo; - - int striping_unit; /* file stripe size of the file */ - - MPI_Offset put_size; /* amount of writes committed so far in bytes */ - MPI_Offset get_size; /* amount of reads committed so far in bytes */ - - /* - * A copy of the 'path' argument passed in to ncmpiio_open() - * or ncmpiio_create(). Used by ncabort() to remove (unlink) - * the file and by error messages. - */ - char *path; -} ncio; - - -#endif /* _NCIO_H */ diff --git a/src/drivers/ncmpio/Legacy/ncmpidtype.h b/src/drivers/ncmpio/Legacy/ncmpidtype.h deleted file mode 100644 index 68d31e764..000000000 --- a/src/drivers/ncmpio/Legacy/ncmpidtype.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifndef _NCMPIDTYPE_H -#define _NCMPIDTYPE_H - -int ncmpio_dtype_decode(MPI_Datatype dtype, - MPI_Datatype *ptype, - int *el_size, - MPI_Offset *nelems, - int *isderived, - int *iscontig_of_ptypes); - -int ncmpio_data_repack(void *inbuf, - MPI_Offset incount, - MPI_Datatype intype, - void *outbuf, - MPI_Offset outcount, - MPI_Datatype outtype); - -#endif diff --git a/src/drivers/ncmpio/Legacy/rnd.h b/src/drivers/ncmpio/Legacy/rnd.h deleted file mode 100644 index 3b9e31221..000000000 --- a/src/drivers/ncmpio/Legacy/rnd.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ -#ifndef _RND_H -#define _RND_H - -/* useful for aligning memory */ -#define _RNDUP(x, unit) ((((x) + (unit) - 1) / (unit)) * (unit)) -#define _RNDDOWN(x, unit) ((x) - ((x)%(unit))) - -/* #define M_RND_UNIT (sizeof(double)) - * SIZEOF_DOUBLE is defined in config.h - */ -#define M_RND_UNIT SIZEOF_DOUBLE -#define M_RNDUP(x) _RNDUP(x, M_RND_UNIT) -#define M_RNDDOWN(x) __RNDDOWN(x, M_RND_UNIT) - -#define D_RNDUP(x, align) _RNDUP(x, (off_t)(align)) - -#endif diff --git a/src/drivers/ncmpio/Legacy/string.c b/src/drivers/ncmpio/Legacy/string.c deleted file mode 100644 index 29d91d012..000000000 --- a/src/drivers/ncmpio/Legacy/string.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#include -#include -#include - -#include - -#include -#include -#include "nc.h" -#include "rnd.h" - -#if 0 -/*----< ncmpio_free_NC_string() >--------------------------------------------*/ -/* - * Free string, and, if needed, its values. - * Formerly -NC_free_string() - */ -inline void -ncmpio_free_NC_string(NC_string *ncstrp) -{ - if (ncstrp == NULL) return; - /* ncstrp->cp is allocated as part of ncstrp object */ - NCI_Free(ncstrp); -} - -/*----< ncmpio_new_NC_string() >---------------------------------------------*/ -/* - * Allocate a NC_string structure large enough - * to hold slen characters. - */ -NC_string * -ncmpio_new_NC_string(size_t slen, - const char *str) /* must be already normalized */ -{ - /* str may not be NULL terminated */ - NC_string *ncstrp; - size_t sizeof_NC_string = M_RNDUP(sizeof(NC_string)); - size_t sz = slen + sizeof_NC_string + 1; - /* one char more space for NULL terminate char */ - - ncstrp = (NC_string *) NCI_Calloc(sz, sizeof(char)); - if (ncstrp == NULL) return NULL; - - /* make space occupied by ncstrp->cp part of ncstrp */ - ncstrp->nchars = (MPI_Offset)slen; - ncstrp->cp = (char *)ncstrp + sizeof_NC_string; - - /* in PnetCDF, we want to make name->cp always NULL character terminated */ - if (str != NULL && *str != '\0') { - strncpy(ncstrp->cp, str, slen); - ncstrp->cp[slen] = '\0'; /* NULL terminated */ - } - - return(ncstrp); -} - - -/*----< ncmpio_set_NC_string() >---------------------------------------------*/ -/* - * If possible, change the value of an NC_string to 'str'. - */ -int -ncmpio_set_NC_string(NC_string *ncstrp, - const char *str) -{ - size_t slen; - - assert(str != NULL && *str != '\0'); - - slen = strlen(str); - - if (ncstrp->nchars < (MPI_Offset)slen) DEBUG_RETURN_ERROR(NC_ENOTINDEFINE) - - memcpy(ncstrp->cp, str, slen); - - /* in PnetCDF, we want to make name->cp always NULL character terminated */ - if (ncstrp->nchars > (MPI_Offset)slen) - memset(ncstrp->cp + slen, 0, (size_t)ncstrp->nchars - slen); - - ncstrp->nchars = (MPI_Offset)slen; - - return NC_NOERR; -} -#endif - -#include "utf8proc.h" - -/* There are 3 levels of UTF8 checking: 1=> (exact)validating 2=>relaxed - and 3=>very relaxed -*/ -/* Use semi-relaxed check */ -#define UTF8_CHECK 2 - -static int -nextUTF8(const char* cp) -{ - /* The goal here is to recognize the length of each - multibyte utf8 character sequence and skip it. - Again, we assume that every non-ascii character is legal. - We can define three possible tests of decreasing correctness - (in the sense that the least correct will allow some sequences that - are technically illegal UTF8). - As Regular expressions they are as follows: - 1. most correct: - UTF8 ([\xC2-\xDF][\x80-\xBF]) \ - | (\xE0[\xA0-\xBF][\x80-\xBF]) \ - | ([\xE1-\xEC][\x80-\xBF][\x80-\xBF]) \ - | (\xED[\x80-\x9F][\x80-\xBF]) \ - | ([\xEE-\xEF][\x80-\xBF][\x80-\xBF]) \ - | (\xF0[\x90-\xBF][\x80-\xBF][\x80-\xBF]) \ - | ([\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]) \ - | (\xF4[\x80-\x8F][\x80-\xBF][\x80-\xBF]) \ - - 2. partially relaxed: - UTF8 ([\xC0-\xDF][\x80-\xBF]) - |([\xE0-\xEF][\x80-\xBF][\x80-\xBF]) - |([\xF0-\xF7][\x80-\xBF][\x80-\xBF][\x80-\xBF]) - - 3. The most relaxed version of UTF8: - UTF8 ([\xC0-\xD6].)|([\xE0-\xEF]..)|([\xF0-\xF7]...) - - We use #2 here. - - The tests are derived from the table at - http://www.w3.org/2005/03/23-lex-U - */ - -/* Define a test macro to test against a range */ -#define RANGE(c,lo,hi) (((uchar)c) >= lo && ((uchar)c) <= hi) -/* Define a common RANGE */ -#define RANGE0(c) RANGE(c,0x80,0xBF) - - int ch0; - - int skip = -1; /* assume failed */ - - ch0 = (uchar)*cp; - if(ch0 <= 0x7f) skip = 1; /* remove ascii case */ - else - -#if UTF8_CHECK == 2 - /* Do relaxed validation check */ - if(RANGE(ch0,0xC0,0XDF)) {/* 2-bytes, but check */ - if(cp[1] != 0 && RANGE0(cp[1])) - skip = 2; /* two bytes */ - } else if(RANGE(ch0,0xE0,0XEF)) {/* 3-bytes, but check */ - if(cp[1] != 0 && RANGE0(cp[1]) && cp[2] != 0 && RANGE0(cp[1])) - skip = 3; /* three bytes */ - } else if(RANGE(ch0,0xF0,0XF7)) {/* 3-bytes, but check */ - if(cp[1] != 0 && RANGE0(cp[1]) && cp[2] != 0 - && RANGE0(cp[1]) && cp[3] != 0 && RANGE0(cp[1])) - skip = 4; /* four bytes*/ - } -#elif UTF8_CHECK == 1 - /* Do exact validation check */ - if(RANGE(ch0,0xC2,0xDF)) {/* non-overlong 2-bytes */ - int ch1 = (uchar)cp[1]; - if(ch1 != 0 && RANGE0(ch1)) skip = 2; - } else if((ch0 == 0xE0)) {/* 3-bytes, not overlong */ - int ch1 = (uchar)cp[1]; - if(ch1 != 0 && RANGE(ch1,0xA0,0xBF)) { - int ch2 = (uchar)cp[2]; - if(ch2 != 0 && RANGE0(ch2)) skip = 3; - } - } else if((ch0 == 0xED)) {/* 3-bytes minus surrogates */ - int ch1 = (uchar)cp[1]; - if(ch1 != 0 && RANGE(ch1,0x80,0x9f)) { - int ch2 = (uchar)cp[2]; - if(ch2 != 0 && RANGE0(ch2)) skip = 3; - } - } else if(RANGE(ch0,0xE1,0xEC) || ch0 == 0xEE || ch0 == 0xEF) { - int ch1 = (uchar)cp[1]; - if(ch1 != 0 && RANGE0(ch1)) { - int ch2 = (uchar)cp[2]; - if(ch2 != 0 && RANGE0(ch2)) skip = 3; - } - } else if((ch0 == 0xF0)) {/* planes 1-3 */ - int ch1 = (uchar)cp[1]; - if(ch1 != 0 && RANGE(ch1,0x90,0xBF)) { - int ch2 = (uchar)cp[2]; - if(ch2 != 0 && RANGE0(ch2)) { - int ch3 = (uchar)cp[3]; - if(ch3 != 0 && RANGE0(ch3)) skip = 4; - } - } - } else if((ch0 == 0xF4)) {/* plane 16 */ - int ch1 = (uchar)cp[1]; - if(ch1 != 0 && RANGE0(ch1)) { - int ch2 = (uchar)cp[2]; - if(ch2 != 0 && RANGE0(ch2)) { - int ch3 = (uchar)cp[3]; - if(ch3 != 0 && RANGE0(ch3)) skip = 4; - } - } - } else if(RANGE(ch0,0xF1,0xF3)) { /* planes 4-15 */ - int ch1 = (uchar)cp[1]; - if(ch1 != 0 && RANGE0(ch1)) { - int ch2 = (uchar)cp[2]; - if(ch2 != 0 && RANGE0(ch2)) { - int ch3 = (uchar)cp[3]; - if(ch3 != 0 && RANGE0(ch3)) skip = 4; - } - } - } -#else -#error "Must Define UTF8_CHECK as 1 or 2" -#endif - return skip; -} - - -#ifdef _CONFORM_NETCDF_3_5_1 -/* - * For CDF-1, Verify that a name string is valid - * CDL syntax, eg, all the characters are - * alphanumeric, '-', '_', or '.'. - * Also permit ':', '@', '(', or ')' in names for chemists currently making - * use of these characters, but don't document until ncgen and ncdump can - * also handle these characters in names. - */ -static int -check_name_CDF1(const char *name) -{ - const char *cp = name; - assert(name != NULL); - - if (*name == 0) - DEBUG_RETURN_ERROR(NC_EBADNAME) /* empty names disallowed */ - - for (; *cp != 0; cp++) { - int ch = *cp; - if (!isalnum(ch)) { - if (ch != '_' && ch != '-' && ch != '+' && ch != '.' && - ch != ':' && ch != '@' && ch != '(' && ch != ')') - DEBUG_RETURN_ERROR(NC_EBADNAME) - } - } - if (cp - name > NC_MAX_NAME) - DEBUG_RETURN_ERROR(NC_EMAXNAME) - - return NC_NOERR; -} -#endif - -/* - * Verify that a name string is valid syntax. The allowed name - * syntax (in RE form) is: - * - * ([a-zA-Z_]|{UTF8})([^\x00-\x1F\x7F/]|{UTF8})* - * - * where UTF8 represents a multibyte UTF-8 encoding. Also, no - * trailing spaces are permitted in names. This definition - * must be consistent with the one in ncgen.l. We do not allow '/' - * because HDF5 does not permit slashes in names as slash is used as a - * group separator. If UTF-8 is supported, then a multi-byte UTF-8 - * character can occur anywhere within an identifier. We later - * normalize UTF-8 strings to NFC to facilitate matching and queries. - */ -static int -check_name_CDF2(const char *name) -{ - int skip; - int ch; - const char *cp = name; - ssize_t utf8_stat; - - assert(name != NULL); - - if(*name == 0 /* empty names disallowed */ - || strchr(cp, '/')) /* '/' can't be in a name */ - DEBUG_RETURN_ERROR(NC_EBADNAME) - - /* check validity of any UTF-8 */ - utf8_stat = ncmpii_utf8proc_check((const unsigned char *)name); - if (utf8_stat < 0) - DEBUG_RETURN_ERROR(NC_EBADNAME) - - /* First char must be [a-z][A-Z][0-9]_ | UTF8 */ - ch = (uchar)*cp; - if(ch <= 0x7f) { - if(!('A' <= ch && ch <= 'Z') - && !('a' <= ch && ch <= 'z') - && !('0' <= ch && ch <= '9') - && ch != '_' ) - DEBUG_RETURN_ERROR(NC_EBADNAME) - cp++; - } else { - if((skip = nextUTF8(cp)) < 0) - DEBUG_RETURN_ERROR(NC_EBADNAME) - cp += skip; - } - - while(*cp != 0) { - ch = (uchar)*cp; - /* handle simple 0x00-0x7f characters here */ - if(ch <= 0x7f) { - if( ch < ' ' || ch > 0x7E) /* control char or DEL */ - DEBUG_RETURN_ERROR(NC_EBADNAME) - cp++; - } else { - if((skip = nextUTF8(cp)) < 0) DEBUG_RETURN_ERROR(NC_EBADNAME) - cp += skip; - } - if(cp - name > NC_MAX_NAME) - DEBUG_RETURN_ERROR(NC_EMAXNAME) - } - if(ch <= 0x7f && isspace(ch)) /* trailing spaces disallowed */ - DEBUG_RETURN_ERROR(NC_EBADNAME) - return NC_NOERR; -} - -/*----< ncmpio_NC_check_name() >---------------------------------------------*/ -int -ncmpio_NC_check_name(const char *name, - int file_ver) /* CDF version: 1, 2, or 5 */ -{ - /* NetCDF4 has made CDF-1 no different from CDF-2 except the size of - * OFFSET (i.e. 32-bit vs. 64-bit integer. Both formats support extended - * names now. - */ -#ifdef _CONFORM_NETCDF_3_5_1 - if (file_ver == 1) - return check_name_CDF1(name); -#endif - - return check_name_CDF2(name); -} - diff --git a/src/drivers/ncmpio/Legacy/swap.c b/src/drivers/ncmpio/Legacy/swap.c deleted file mode 100644 index 64f8ac5c3..000000000 --- a/src/drivers/ncmpio/Legacy/swap.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include "nc.h" -#include "ncx.h" - -#ifndef WORDS_BIGENDIAN -/* LITTLE_ENDIAN: DEC and intel */ -/* - * Routines to convert to BIG ENDIAN. - * Optimize the swapn?b() and swap?b() routines aggressively. - */ - -/* netcdf-3.6.2beta5 added loop unrolling to many of these routines. Could - * confer a 22% performance increase on little endian platforms if compiler - * does not already aggressively unroll loops */ - -void -ncmpii_swapn2b(void *dst, const void *src, MPI_Offset nn) -{ - char *op = (char*) dst; - const char *ip = (char*) src; - - while(nn > 3) - { - *op++ = *(++ip); - *op++ = *(ip++ -1); - *op++ = *(++ip); - *op++ = *(ip++ -1); - *op++ = *(++ip); - *op++ = *(ip++ -1); - *op++ = *(++ip); - *op++ = *(ip++ -1); - nn -= 4; - } - while(nn-- != 0) - { - *op++ = *(++ip); - *op++ = *(ip++ -1); - } -} - -# ifndef vax -void -ncmpii_swap4b(void *dst, const void *src) -{ - char *op = (char*) dst; - const char *ip = (char*) src; - op[0] = ip[3]; - op[1] = ip[2]; - op[2] = ip[1]; - op[3] = ip[0]; -} -# endif /* !vax */ - -void -ncmpii_swapn4b(void *dst, const void *src, MPI_Offset nn) -{ - char *op = (char*) dst; - const char *ip = (char*) src; - - while(nn > 3) - { - op[0] = ip[3]; - op[1] = ip[2]; - op[2] = ip[1]; - op[3] = ip[0]; - op[4] = ip[7]; - op[5] = ip[6]; - op[6] = ip[5]; - op[7] = ip[4]; - op[8] = ip[11]; - op[9] = ip[10]; - op[10] = ip[9]; - op[11] = ip[8]; - op[12] = ip[15]; - op[13] = ip[14]; - op[14] = ip[13]; - op[15] = ip[12]; - op += 16; - ip += 16; - nn -= 4; - } - while(nn-- != 0) - { - op[0] = ip[3]; - op[1] = ip[2]; - op[2] = ip[1]; - op[3] = ip[0]; - op += 4; - ip += 4; - } -} - -# ifndef vax -void -ncmpii_swap8b(void *dst, const void *src) -{ - char *op = (char*) dst; - const char *ip = (char*) src; - op[0] = ip[7]; - op[1] = ip[6]; - op[2] = ip[5]; - op[3] = ip[4]; - op[4] = ip[3]; - op[5] = ip[2]; - op[6] = ip[1]; - op[7] = ip[0]; -} -# endif /* !vax */ - -# ifndef vax -void -ncmpii_swapn8b(void *dst, const void *src, MPI_Offset nn) -{ - char *op = (char*) dst; - const char *ip = (char*) src; - - while(nn > 1) - { - op[0] = ip[7]; - op[1] = ip[6]; - op[2] = ip[5]; - op[3] = ip[4]; - op[4] = ip[3]; - op[5] = ip[2]; - op[6] = ip[1]; - op[7] = ip[0]; - op[8] = ip[15]; - op[9] = ip[14]; - op[10] = ip[13]; - op[11] = ip[12]; - op[12] = ip[11]; - op[13] = ip[10]; - op[14] = ip[9]; - op[15] = ip[8]; - op += 16; - ip += 16; - nn -= 2; - } - while(nn-- != 0) - { - op[0] = ip[7]; - op[1] = ip[6]; - op[2] = ip[5]; - op[3] = ip[4]; - op[4] = ip[3]; - op[5] = ip[2]; - op[6] = ip[1]; - op[7] = ip[0]; - op += 8; - ip += 8; - } -} -# endif /* !vax */ - -#endif /* LITTLE_ENDIAN */ - diff --git a/src/drivers/ncmpio/Legacy/util.c b/src/drivers/ncmpio/Legacy/util.c deleted file mode 100644 index e8db1fceb..000000000 --- a/src/drivers/ncmpio/Legacy/util.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2015, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#include -#include /* strcasecmp() */ -#include -#include - -#include -#include -#include "nc.h" -#include "ncx.h" - -/*----< ncmpio_sanity_check() >----------------------------------------------*/ -/* check the following errors and in that precedence. - * NC_EBADID, NC_EPERM, NC_EINDEFINE, NC_EINDEP/NC_ENOTINDEP, NC_ENOTVAR, - * NC_ECHAR, NC_EINVALCOORDS, NC_EEDGE, NC_ESTRIDE, NC_EINVAL. - */ -int ncmpio_sanity_check(NC *ncp, - int varid, - const MPI_Offset bufcount, - MPI_Datatype buftype, /* internal datatype */ - int reqMode, - NC_var **varp) /* OUT */ -{ - /* all errors detected here are fatal, must return immediately */ - int err=NC_NOERR; - - /* check file write permission if this is write request */ - if (fIsSet(reqMode, NC_REQ_WR) && NC_readonly(ncp)) - DEBUG_RETURN_ERROR(NC_EPERM) - - if (fIsSet(reqMode, NC_REQ_BLK)) { - /* blocking APIs must be called in data mode */ - if (NC_indef(ncp)) - DEBUG_RETURN_ERROR(NC_EINDEFINE) - - /* for blocking APIs, check if in the right collective or independent - * mode, nonblocking APIs can be called in either mode */ - if (fIsSet(reqMode, NC_REQ_INDEP) && !NC_indep(ncp)) - DEBUG_RETURN_ERROR(NC_ENOTINDEP) - else if (fIsSet(reqMode, NC_REQ_COLL) && NC_indep(ncp)) - DEBUG_RETURN_ERROR(NC_EINDEP) - } - - if (fIsSet(reqMode, NC_REQ_ZERO)) return NC_NOERR; - - /* check if varid is valid (check NC_ENOTVAR) */ - err = ncmpio_NC_lookupvar(ncp, varid, varp); - if (err != NC_NOERR) return err; - - /* check NC_ECHAR */ - if (fIsSet(reqMode, NC_REQ_FLEX)) { - /* when buftype == MPI_DATATYPE_NULL, bufcount is ignored and this API - * assumes argument buf's data type matches the data type of variable - * defined in the file - no data conversion will be done. - */ - if (buftype != MPI_DATATYPE_NULL) { - int isderived, el_size, buftype_is_contig; - MPI_Datatype ptype; - MPI_Offset bnelems=0; - - err = ncmpii_dtype_decode(buftype, &ptype, &el_size, &bnelems, - &isderived, &buftype_is_contig); - if (err != NC_NOERR) return err; - - err = NCMPII_ECHAR((*varp)->type, ptype); - if (err != NC_NOERR) return err; - } - /* else case: itype matches xtype */ - - /* for flexible APIs, bufcount cannot be negative */ - if (bufcount < 0) DEBUG_RETURN_ERROR(NC_EINVAL) - } - else { /* called from a high-level API */ - err = NCMPII_ECHAR((*varp)->type, buftype); - if (err != NC_NOERR) return err; - } - return NC_NOERR; -} diff --git a/src/drivers/ncmpio/Legacy/varn_api_header.m4 b/src/drivers/ncmpio/Legacy/varn_api_header.m4 deleted file mode 100644 index a93776d57..000000000 --- a/src/drivers/ncmpio/Legacy/varn_api_header.m4 +++ /dev/null @@ -1,96 +0,0 @@ -/* Begin of {put,get}_varn{kind} */ - -define(`VARN_FLEXIBLE',dnl -`dnl -int ncmpi_$1_varn$4(int ncid, int varid, int num, MPI_Offset* const starts[], - MPI_Offset* const counts[], $2 void *buf, MPI_Offset bufcount, - MPI_Datatype buftype); -')dnl - -dnl PnetCDF flexible APIs -VARN_FLEXIBLE(put, const, WRITE_REQ, , INDEP_IO) -VARN_FLEXIBLE(put, const, WRITE_REQ, _all, COLL_IO) -VARN_FLEXIBLE(get, , READ_REQ, , INDEP_IO) -VARN_FLEXIBLE(get, , READ_REQ, _all, COLL_IO) - -define(`VARN',dnl -`dnl -int ncmpi_$1_varn_$6$4(int ncid, int varid, int num, - MPI_Offset* const starts[], MPI_Offset* const counts[], - $2 $7 *buf); -')dnl - -VARN(put, const, WRITE_REQ, , INDEP_IO, text, char, MPI_CHAR) -VARN(put, const, WRITE_REQ, , INDEP_IO, schar, signed char, MPI_SIGNED_CHAR) -VARN(put, const, WRITE_REQ, , INDEP_IO, short, short, MPI_SHORT) -VARN(put, const, WRITE_REQ, , INDEP_IO, int, int, MPI_INT) -VARN(put, const, WRITE_REQ, , INDEP_IO, float, float, MPI_FLOAT) -VARN(put, const, WRITE_REQ, , INDEP_IO, double, double, MPI_DOUBLE) -VARN(put, const, WRITE_REQ, , INDEP_IO, longlong, long long, MPI_LONG_LONG_INT) - -/* Begin Skip Prototypes for Fortran binding */ -/* skip types: uchar, ubyte, ushort, uint, long, ulonglong string */ - -VARN(put, const, WRITE_REQ, , INDEP_IO, uchar, unsigned char, MPI_UNSIGNED_CHAR) -VARN(put, const, WRITE_REQ, , INDEP_IO, ushort, unsigned short, MPI_UNSIGNED_SHORT) -VARN(put, const, WRITE_REQ, , INDEP_IO, uint, unsigned int, MPI_UNSIGNED) -VARN(put, const, WRITE_REQ, , INDEP_IO, long, long, MPI_LONG) -VARN(put, const, WRITE_REQ, , INDEP_IO, ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG) -/* End Skip Prototypes for Fortran binding */ - -VARN(put, const, WRITE_REQ, _all, COLL_IO, text, char, MPI_CHAR) -VARN(put, const, WRITE_REQ, _all, COLL_IO, schar, signed char, MPI_SIGNED_CHAR) -VARN(put, const, WRITE_REQ, _all, COLL_IO, short, short, MPI_SHORT) -VARN(put, const, WRITE_REQ, _all, COLL_IO, int, int, MPI_INT) -VARN(put, const, WRITE_REQ, _all, COLL_IO, float, float, MPI_FLOAT) -VARN(put, const, WRITE_REQ, _all, COLL_IO, double, double, MPI_DOUBLE) -VARN(put, const, WRITE_REQ, _all, COLL_IO, longlong, long long, MPI_LONG_LONG_INT) - -/* Begin Skip Prototypes for Fortran binding */ -/* skip types: uchar, ubyte, ushort, uint, long, ulonglong string */ - -VARN(put, const, WRITE_REQ, _all, COLL_IO, uchar, unsigned char, MPI_UNSIGNED_CHAR) -VARN(put, const, WRITE_REQ, _all, COLL_IO, ushort, unsigned short, MPI_UNSIGNED_SHORT) -VARN(put, const, WRITE_REQ, _all, COLL_IO, uint, unsigned int, MPI_UNSIGNED) -VARN(put, const, WRITE_REQ, _all, COLL_IO, long, long, MPI_LONG) -VARN(put, const, WRITE_REQ, _all, COLL_IO, ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG) -/* End Skip Prototypes for Fortran binding */ - -VARN(get, , READ_REQ, , INDEP_IO, text, char, MPI_CHAR) -VARN(get, , READ_REQ, , INDEP_IO, schar, signed char, MPI_SIGNED_CHAR) -VARN(get, , READ_REQ, , INDEP_IO, short, short, MPI_SHORT) -VARN(get, , READ_REQ, , INDEP_IO, int, int, MPI_INT) -VARN(get, , READ_REQ, , INDEP_IO, float, float, MPI_FLOAT) -VARN(get, , READ_REQ, , INDEP_IO, double, double, MPI_DOUBLE) -VARN(get, , READ_REQ, , INDEP_IO, longlong, long long, MPI_LONG_LONG_INT) - -/* Begin Skip Prototypes for Fortran binding */ -/* skip types: uchar, ubyte, ushort, uint, long, ulonglong string */ - -VARN(get, , READ_REQ, , INDEP_IO, uchar, unsigned char, MPI_UNSIGNED_CHAR) -VARN(get, , READ_REQ, , INDEP_IO, ushort, unsigned short, MPI_UNSIGNED_SHORT) -VARN(get, , READ_REQ, , INDEP_IO, uint, unsigned int, MPI_UNSIGNED) -VARN(get, , READ_REQ, , INDEP_IO, long, long, MPI_LONG) -VARN(get, , READ_REQ, , INDEP_IO, ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG) -/* End Skip Prototypes for Fortran binding */ - -VARN(get, , READ_REQ, _all, COLL_IO, text, char, MPI_CHAR) -VARN(get, , READ_REQ, _all, COLL_IO, schar, signed char, MPI_SIGNED_CHAR) -VARN(get, , READ_REQ, _all, COLL_IO, short, short, MPI_SHORT) -VARN(get, , READ_REQ, _all, COLL_IO, int, int, MPI_INT) -VARN(get, , READ_REQ, _all, COLL_IO, float, float, MPI_FLOAT) -VARN(get, , READ_REQ, _all, COLL_IO, double, double, MPI_DOUBLE) -VARN(get, , READ_REQ, _all, COLL_IO, longlong, long long, MPI_LONG_LONG_INT) - -/* Begin Skip Prototypes for Fortran binding */ -/* skip types: uchar, ubyte, ushort, uint, long, ulonglong string */ - -VARN(get, , READ_REQ, _all, COLL_IO, uchar, unsigned char, MPI_UNSIGNED_CHAR) -VARN(get, , READ_REQ, _all, COLL_IO, ushort, unsigned short, MPI_UNSIGNED_SHORT) -VARN(get, , READ_REQ, _all, COLL_IO, uint, unsigned int, MPI_UNSIGNED) -VARN(get, , READ_REQ, _all, COLL_IO, long, long, MPI_LONG) -VARN(get, , READ_REQ, _all, COLL_IO, ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG) -/* End Skip Prototypes for Fortran binding */ - -/* End of {put,get}_varn{kind} */ - diff --git a/src/drivers/ncmpio/Legacy/varnx.m4 b/src/drivers/ncmpio/Legacy/varnx.m4 deleted file mode 100644 index 679b881a7..000000000 --- a/src/drivers/ncmpio/Legacy/varnx.m4 +++ /dev/null @@ -1,988 +0,0 @@ -dnl Process this m4 file to produce 'C' language file. -dnl -dnl If you see this line, you can ignore the next one. -/* Do not edit this file. It is produced from the corresponding .m4 source */ -dnl -/* - * Copyright (C) 2003, Northwestern University and Argonne National Laboratory - * See COPYRIGHT notice in top-level directory. - */ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#include - -#include - -#include -#include -#include "nc.h" -#include "ncx.h" -#include "ncmpidtype.h" - - -/* buffer layers: - - User Level buf (user defined buffer of MPI_Datatype) - MPI Datatype Level cbuf (contiguous buffer of ptype) - NetCDF XDR Level xbuf (XDR I/O buffer) -*/ - -static int -ncmpio_getput_varnm(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype, - int rw_flag, /* WRITE_REQ or READ_REQ */ - int io_method); /* COLL_IO or INDEP_IO */ - -/*----< ncmpi_put_varn() >---------------------------------------------------*/ -int -ncmpi_put_varn(int ncid, - int varid, - int num, - const void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, NULL, NULL, NULL, - NULL, (void*)buf, bufcount, buftype, - WRITE_REQ, INDEP_IO); -} - -/*----< ncmpi_put_varn_all() >-----------------------------------------------*/ -int -ncmpi_put_varn_all(int ncid, - int varid, - int num, - const void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, NULL, NULL, NULL, - NULL, (void*)buf, bufcount, buftype, - WRITE_REQ, COLL_IO); -} - -dnl -dnl PUT_VARN(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`PUT_VARN',dnl -`dnl -/*----< ncmpi_put_varn_$1$5() >-----------------------------------------------*/ -int -ncmpi_put_varn_$1$5(int ncid, - int varid, - int num, - const $2 *buf) -{ - return ncmpio_getput_varnm(ncid, varid, num, NULL, NULL, NULL, - NULL, (void*)buf, -1, $3, WRITE_REQ, $4); -} -')dnl - -PUT_VARN(text, char, MPI_CHAR, INDEP_IO) -PUT_VARN(schar, signed char, MPI_SIGNED_CHAR, INDEP_IO) -PUT_VARN(uchar, unsigned char, MPI_UNSIGNED_CHAR, INDEP_IO) -PUT_VARN(short, short, MPI_SHORT, INDEP_IO) -PUT_VARN(ushort, unsigned short, MPI_UNSIGNED_SHORT, INDEP_IO) -PUT_VARN(int, int, MPI_INT, INDEP_IO) -PUT_VARN(uint, unsigned int, MPI_UNSIGNED, INDEP_IO) -PUT_VARN(long, long, MPI_LONG, INDEP_IO) -PUT_VARN(float, float, MPI_FLOAT, INDEP_IO) -PUT_VARN(double, double, MPI_DOUBLE, INDEP_IO) -PUT_VARN(longlong, long long, MPI_LONG_LONG_INT, INDEP_IO) -PUT_VARN(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, INDEP_IO) - -PUT_VARN(text, char, MPI_CHAR, COLL_IO, _all) -PUT_VARN(schar, signed char, MPI_SIGNED_CHAR, COLL_IO, _all) -PUT_VARN(uchar, unsigned char, MPI_UNSIGNED_CHAR, COLL_IO, _all) -PUT_VARN(short, short, MPI_SHORT, COLL_IO, _all) -PUT_VARN(ushort, unsigned short, MPI_UNSIGNED_SHORT, COLL_IO, _all) -PUT_VARN(int, int, MPI_INT, COLL_IO, _all) -PUT_VARN(uint, unsigned int, MPI_UNSIGNED, COLL_IO, _all) -PUT_VARN(long, long, MPI_LONG, COLL_IO, _all) -PUT_VARN(float, float, MPI_FLOAT, COLL_IO, _all) -PUT_VARN(double, double, MPI_DOUBLE, COLL_IO, _all) -PUT_VARN(longlong, long long, MPI_LONG_LONG_INT, COLL_IO, _all) -PUT_VARN(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, COLL_IO, _all) - -/*----< ncmpi_put_varn1() >--------------------------------------------------*/ -int -ncmpi_put_varn1(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - const void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, NULL, NULL, - NULL, (void*)buf, bufcount, buftype, - WRITE_REQ, INDEP_IO); -} - -/*----< ncmpi_put_varn1_all() >----------------------------------------------*/ -int -ncmpi_put_varn1_all(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - const void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, NULL, NULL, - NULL, (void*)buf, bufcount, buftype, - WRITE_REQ, COLL_IO); -} - -dnl -dnl PUT_VARN1(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`PUT_VARN1',dnl -`dnl -/*----< ncmpi_put_varn1_$1$5() >----------------------------------------------*/ -int -ncmpi_put_varn1_$1$5(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - const $2 *buf) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, NULL, NULL, - NULL, (void*)buf, -1, $3, WRITE_REQ, $4); -} -')dnl - -PUT_VARN1(text, char, MPI_CHAR, INDEP_IO) -PUT_VARN1(schar, signed char, MPI_SIGNED_CHAR, INDEP_IO) -PUT_VARN1(uchar, unsigned char, MPI_UNSIGNED_CHAR, INDEP_IO) -PUT_VARN1(short, short, MPI_SHORT, INDEP_IO) -PUT_VARN1(ushort, unsigned short, MPI_UNSIGNED_SHORT, INDEP_IO) -PUT_VARN1(int, int, MPI_INT, INDEP_IO) -PUT_VARN1(uint, unsigned int, MPI_UNSIGNED, INDEP_IO) -PUT_VARN1(long, long, MPI_LONG, INDEP_IO) -PUT_VARN1(float, float, MPI_FLOAT, INDEP_IO) -PUT_VARN1(double, double, MPI_DOUBLE, INDEP_IO) -PUT_VARN1(longlong, long long, MPI_LONG_LONG_INT, INDEP_IO) -PUT_VARN1(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, INDEP_IO) - -PUT_VARN1(text, char, MPI_CHAR, COLL_IO, _all) -PUT_VARN1(schar, signed char, MPI_SIGNED_CHAR, COLL_IO, _all) -PUT_VARN1(uchar, unsigned char, MPI_UNSIGNED_CHAR, COLL_IO, _all) -PUT_VARN1(short, short, MPI_SHORT, COLL_IO, _all) -PUT_VARN1(ushort, unsigned short, MPI_UNSIGNED_SHORT, COLL_IO, _all) -PUT_VARN1(int, int, MPI_INT, COLL_IO, _all) -PUT_VARN1(uint, unsigned int, MPI_UNSIGNED, COLL_IO, _all) -PUT_VARN1(long, long, MPI_LONG, COLL_IO, _all) -PUT_VARN1(float, float, MPI_FLOAT, COLL_IO, _all) -PUT_VARN1(double, double, MPI_DOUBLE, COLL_IO, _all) -PUT_VARN1(longlong, long long, MPI_LONG_LONG_INT, COLL_IO, _all) -PUT_VARN1(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, COLL_IO, _all) - -/*----< ncmpi_put_varna() >--------------------------------------------------*/ -int -ncmpi_put_varna(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - const void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, NULL, - NULL, (void*)buf, bufcount, buftype, - WRITE_REQ, INDEP_IO); -} - -/*----< ncmpi_put_varna_all() >----------------------------------------------*/ -int -ncmpi_put_varna_all(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - const void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, NULL, - NULL, (void*)buf, bufcount, buftype, - WRITE_REQ, COLL_IO); -} - -dnl -dnl PUT_VARNA(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`PUT_VARNA',dnl -`dnl -/*----< ncmpi_put_varna_$1$5() >----------------------------------------------*/ -int -ncmpi_put_varna_$1$5(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - const $2 *buf) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, NULL, - NULL, (void*)buf, -1, $3, WRITE_REQ, $4); -} -')dnl - -PUT_VARNA(text, char, MPI_CHAR, INDEP_IO) -PUT_VARNA(schar, signed char, MPI_SIGNED_CHAR, INDEP_IO) -PUT_VARNA(uchar, unsigned char, MPI_UNSIGNED_CHAR, INDEP_IO) -PUT_VARNA(short, short, MPI_SHORT, INDEP_IO) -PUT_VARNA(ushort, unsigned short, MPI_UNSIGNED_SHORT, INDEP_IO) -PUT_VARNA(int, int, MPI_INT, INDEP_IO) -PUT_VARNA(uint, unsigned int, MPI_UNSIGNED, INDEP_IO) -PUT_VARNA(long, long, MPI_LONG, INDEP_IO) -PUT_VARNA(float, float, MPI_FLOAT, INDEP_IO) -PUT_VARNA(double, double, MPI_DOUBLE, INDEP_IO) -PUT_VARNA(longlong, long long, MPI_LONG_LONG_INT, INDEP_IO) -PUT_VARNA(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, INDEP_IO) - -PUT_VARNA(text, char, MPI_CHAR, COLL_IO, _all) -PUT_VARNA(schar, signed char, MPI_SIGNED_CHAR, COLL_IO, _all) -PUT_VARNA(uchar, unsigned char, MPI_UNSIGNED_CHAR, COLL_IO, _all) -PUT_VARNA(short, short, MPI_SHORT, COLL_IO, _all) -PUT_VARNA(ushort, unsigned short, MPI_UNSIGNED_SHORT, COLL_IO, _all) -PUT_VARNA(int, int, MPI_INT, COLL_IO, _all) -PUT_VARNA(uint, unsigned int, MPI_UNSIGNED, COLL_IO, _all) -PUT_VARNA(long, long, MPI_LONG, COLL_IO, _all) -PUT_VARNA(float, float, MPI_FLOAT, COLL_IO, _all) -PUT_VARNA(double, double, MPI_DOUBLE, COLL_IO, _all) -PUT_VARNA(longlong, long long, MPI_LONG_LONG_INT, COLL_IO, _all) -PUT_VARNA(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, COLL_IO, _all) - -/*----< ncmpi_put_varns() >--------------------------------------------------*/ -int -ncmpi_put_varns(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - const void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - NULL, (void*)buf, bufcount, buftype, - WRITE_REQ, INDEP_IO); -} - -/*----< ncmpi_put_varns_all() >----------------------------------------------*/ -int -ncmpi_put_varns_all(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - const void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - NULL, (void*)buf, bufcount, buftype, - WRITE_REQ, COLL_IO); -} - -dnl -dnl PUT_VARNS(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`PUT_VARNS',dnl -`dnl -/*----< ncmpi_put_varns_$1$5() >----------------------------------------------*/ -int -ncmpi_put_varns_$1$5(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - const $2 *buf) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - NULL, (void*)buf, -1, $3, WRITE_REQ, $4); -} -')dnl - -PUT_VARNS(text, char, MPI_CHAR, INDEP_IO) -PUT_VARNS(schar, signed char, MPI_SIGNED_CHAR, INDEP_IO) -PUT_VARNS(uchar, unsigned char, MPI_UNSIGNED_CHAR, INDEP_IO) -PUT_VARNS(short, short, MPI_SHORT, INDEP_IO) -PUT_VARNS(ushort, unsigned short, MPI_UNSIGNED_SHORT, INDEP_IO) -PUT_VARNS(int, int, MPI_INT, INDEP_IO) -PUT_VARNS(uint, unsigned int, MPI_UNSIGNED, INDEP_IO) -PUT_VARNS(long, long, MPI_LONG, INDEP_IO) -PUT_VARNS(float, float, MPI_FLOAT, INDEP_IO) -PUT_VARNS(double, double, MPI_DOUBLE, INDEP_IO) -PUT_VARNS(longlong, long long, MPI_LONG_LONG_INT, INDEP_IO) -PUT_VARNS(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, INDEP_IO) - -PUT_VARNS(text, char, MPI_CHAR, COLL_IO, _all) -PUT_VARNS(schar, signed char, MPI_SIGNED_CHAR, COLL_IO, _all) -PUT_VARNS(uchar, unsigned char, MPI_UNSIGNED_CHAR, COLL_IO, _all) -PUT_VARNS(short, short, MPI_SHORT, COLL_IO, _all) -PUT_VARNS(ushort, unsigned short, MPI_UNSIGNED_SHORT, COLL_IO, _all) -PUT_VARNS(int, int, MPI_INT, COLL_IO, _all) -PUT_VARNS(uint, unsigned int, MPI_UNSIGNED, COLL_IO, _all) -PUT_VARNS(long, long, MPI_LONG, COLL_IO, _all) -PUT_VARNS(float, float, MPI_FLOAT, COLL_IO, _all) -PUT_VARNS(double, double, MPI_DOUBLE, COLL_IO, _all) -PUT_VARNS(longlong, long long, MPI_LONG_LONG_INT, COLL_IO, _all) -PUT_VARNS(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, COLL_IO, _all) - -/*----< ncmpi_put_varnm() >--------------------------------------------------*/ -int -ncmpi_put_varnm(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - const void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - imaps, (void*)buf, bufcount, buftype, - WRITE_REQ, INDEP_IO); -} - -/*----< ncmpi_put_varnm_all() >----------------------------------------------*/ -int -ncmpi_put_varnm_all(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - const void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - imaps, (void*)buf, bufcount, buftype, - WRITE_REQ, COLL_IO); -} - -dnl -dnl PUT_VARNM(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`PUT_VARNM',dnl -`dnl -/*----< ncmpi_put_varnm_$1$5() >----------------------------------------------*/ -int -ncmpi_put_varnm_$1$5(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - const $2 *buf) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - imaps, (void*)buf, -1, $3, WRITE_REQ, $4); -} -')dnl - -PUT_VARNM(text, char, MPI_CHAR, INDEP_IO) -PUT_VARNM(schar, signed char, MPI_SIGNED_CHAR, INDEP_IO) -PUT_VARNM(uchar, unsigned char, MPI_UNSIGNED_CHAR, INDEP_IO) -PUT_VARNM(short, short, MPI_SHORT, INDEP_IO) -PUT_VARNM(ushort, unsigned short, MPI_UNSIGNED_SHORT, INDEP_IO) -PUT_VARNM(int, int, MPI_INT, INDEP_IO) -PUT_VARNM(uint, unsigned int, MPI_UNSIGNED, INDEP_IO) -PUT_VARNM(long, long, MPI_LONG, INDEP_IO) -PUT_VARNM(float, float, MPI_FLOAT, INDEP_IO) -PUT_VARNM(double, double, MPI_DOUBLE, INDEP_IO) -PUT_VARNM(longlong, long long, MPI_LONG_LONG_INT, INDEP_IO) -PUT_VARNM(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, INDEP_IO) - -PUT_VARNM(text, char, MPI_CHAR, COLL_IO, _all) -PUT_VARNM(schar, signed char, MPI_SIGNED_CHAR, COLL_IO, _all) -PUT_VARNM(uchar, unsigned char, MPI_UNSIGNED_CHAR, COLL_IO, _all) -PUT_VARNM(short, short, MPI_SHORT, COLL_IO, _all) -PUT_VARNM(ushort, unsigned short, MPI_UNSIGNED_SHORT, COLL_IO, _all) -PUT_VARNM(int, int, MPI_INT, COLL_IO, _all) -PUT_VARNM(uint, unsigned int, MPI_UNSIGNED, COLL_IO, _all) -PUT_VARNM(long, long, MPI_LONG, COLL_IO, _all) -PUT_VARNM(float, float, MPI_FLOAT, COLL_IO, _all) -PUT_VARNM(double, double, MPI_DOUBLE, COLL_IO, _all) -PUT_VARNM(longlong, long long, MPI_LONG_LONG_INT, COLL_IO, _all) -PUT_VARNM(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, COLL_IO, _all) - -/*----< ncmpi_get_varn() >---------------------------------------------------*/ -int -ncmpi_get_varn(int ncid, - int varid, - int num, - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, NULL, NULL, NULL, - NULL, buf, bufcount, buftype, - READ_REQ, INDEP_IO); -} - -/*----< ncmpi_get_varn_all() >-----------------------------------------------*/ -int -ncmpi_get_varn_all(int ncid, - int varid, - int num, - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, NULL, NULL, NULL, - NULL, buf, bufcount, buftype, - READ_REQ, COLL_IO); -} - -dnl -dnl GET_VARN(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`GET_VARN',dnl -`dnl -/*----< ncmpi_get_varn_$1$5() >-----------------------------------------------*/ -int -ncmpi_get_varn_$1$5(int ncid, - int varid, - int num, - $2 *buf) -{ - return ncmpio_getput_varnm(ncid, varid, num, NULL, NULL, NULL, - NULL, buf, -1, $3, READ_REQ, $4); -} -')dnl - -GET_VARN(text, char, MPI_CHAR, INDEP_IO) -GET_VARN(schar, signed char, MPI_SIGNED_CHAR, INDEP_IO) -GET_VARN(uchar, unsigned char, MPI_UNSIGNED_CHAR, INDEP_IO) -GET_VARN(short, short, MPI_SHORT, INDEP_IO) -GET_VARN(ushort, unsigned short, MPI_UNSIGNED_SHORT, INDEP_IO) -GET_VARN(int, int, MPI_INT, INDEP_IO) -GET_VARN(uint, unsigned int, MPI_UNSIGNED, INDEP_IO) -GET_VARN(long, long, MPI_LONG, INDEP_IO) -GET_VARN(float, float, MPI_FLOAT, INDEP_IO) -GET_VARN(double, double, MPI_DOUBLE, INDEP_IO) -GET_VARN(longlong, long long, MPI_LONG_LONG_INT, INDEP_IO) -GET_VARN(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, INDEP_IO) - -GET_VARN(text, char, MPI_CHAR, COLL_IO, _all) -GET_VARN(schar, signed char, MPI_SIGNED_CHAR, COLL_IO, _all) -GET_VARN(uchar, unsigned char, MPI_UNSIGNED_CHAR, COLL_IO, _all) -GET_VARN(short, short, MPI_SHORT, COLL_IO, _all) -GET_VARN(ushort, unsigned short, MPI_UNSIGNED_SHORT, COLL_IO, _all) -GET_VARN(int, int, MPI_INT, COLL_IO, _all) -GET_VARN(uint, unsigned int, MPI_UNSIGNED, COLL_IO, _all) -GET_VARN(long, long, MPI_LONG, COLL_IO, _all) -GET_VARN(float, float, MPI_FLOAT, COLL_IO, _all) -GET_VARN(double, double, MPI_DOUBLE, COLL_IO, _all) -GET_VARN(longlong, long long, MPI_LONG_LONG_INT, COLL_IO, _all) -GET_VARN(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, COLL_IO, _all) - -/*----< ncmpi_get_varn1() >--------------------------------------------------*/ -int -ncmpi_get_varn1(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, NULL, NULL, - NULL, buf, bufcount, buftype, - READ_REQ, INDEP_IO); -} - -/*----< ncmpi_get_varn1_all() >----------------------------------------------*/ -int -ncmpi_get_varn1_all(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, NULL, NULL, - NULL, buf, bufcount, buftype, - READ_REQ, COLL_IO); -} - -dnl -dnl GET_VARN1(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`GET_VARN1',dnl -`dnl -/*----< ncmpi_get_varn1_$1$5() >----------------------------------------------*/ -int -ncmpi_get_varn1_$1$5(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - $2 *buf) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, NULL, NULL, - NULL, buf, -1, $3, READ_REQ, $4); -} -')dnl - -GET_VARN1(text, char, MPI_CHAR, INDEP_IO) -GET_VARN1(schar, signed char, MPI_SIGNED_CHAR, INDEP_IO) -GET_VARN1(uchar, unsigned char, MPI_UNSIGNED_CHAR, INDEP_IO) -GET_VARN1(short, short, MPI_SHORT, INDEP_IO) -GET_VARN1(ushort, unsigned short, MPI_UNSIGNED_SHORT, INDEP_IO) -GET_VARN1(int, int, MPI_INT, INDEP_IO) -GET_VARN1(uint, unsigned int, MPI_UNSIGNED, INDEP_IO) -GET_VARN1(long, long, MPI_LONG, INDEP_IO) -GET_VARN1(float, float, MPI_FLOAT, INDEP_IO) -GET_VARN1(double, double, MPI_DOUBLE, INDEP_IO) -GET_VARN1(longlong, long long, MPI_LONG_LONG_INT, INDEP_IO) -GET_VARN1(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, INDEP_IO) - -GET_VARN1(text, char, MPI_CHAR, COLL_IO, _all) -GET_VARN1(schar, signed char, MPI_SIGNED_CHAR, COLL_IO, _all) -GET_VARN1(uchar, unsigned char, MPI_UNSIGNED_CHAR, COLL_IO, _all) -GET_VARN1(short, short, MPI_SHORT, COLL_IO, _all) -GET_VARN1(ushort, unsigned short, MPI_UNSIGNED_SHORT, COLL_IO, _all) -GET_VARN1(int, int, MPI_INT, COLL_IO, _all) -GET_VARN1(uint, unsigned int, MPI_UNSIGNED, COLL_IO, _all) -GET_VARN1(long, long, MPI_LONG, COLL_IO, _all) -GET_VARN1(float, float, MPI_FLOAT, COLL_IO, _all) -GET_VARN1(double, double, MPI_DOUBLE, COLL_IO, _all) -GET_VARN1(longlong, long long, MPI_LONG_LONG_INT, COLL_IO, _all) -GET_VARN1(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, COLL_IO, _all) - -/*----< ncmpi_get_varna() >--------------------------------------------------*/ -int -ncmpi_get_varna(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, NULL, - NULL, buf, bufcount, buftype, - READ_REQ, INDEP_IO); -} - -/*----< ncmpi_get_varna_all() >----------------------------------------------*/ -int -ncmpi_get_varna_all(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, NULL, - NULL, buf, bufcount, buftype, - READ_REQ, COLL_IO); -} - -dnl -dnl GET_VARNA(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`GET_VARNA',dnl -`dnl -/*----< ncmpi_get_varna_$1$5() >----------------------------------------------*/ -int -ncmpi_get_varna_$1$5(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - $2 *buf) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, NULL, - NULL, buf, -1, $3, READ_REQ, $4); -} -')dnl - -GET_VARNA(text, char, MPI_CHAR, INDEP_IO) -GET_VARNA(schar, signed char, MPI_SIGNED_CHAR, INDEP_IO) -GET_VARNA(uchar, unsigned char, MPI_UNSIGNED_CHAR, INDEP_IO) -GET_VARNA(short, short, MPI_SHORT, INDEP_IO) -GET_VARNA(ushort, unsigned short, MPI_UNSIGNED_SHORT, INDEP_IO) -GET_VARNA(int, int, MPI_INT, INDEP_IO) -GET_VARNA(uint, unsigned int, MPI_UNSIGNED, INDEP_IO) -GET_VARNA(long, long, MPI_LONG, INDEP_IO) -GET_VARNA(float, float, MPI_FLOAT, INDEP_IO) -GET_VARNA(double, double, MPI_DOUBLE, INDEP_IO) -GET_VARNA(longlong, long long, MPI_LONG_LONG_INT, INDEP_IO) -GET_VARNA(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, INDEP_IO) - -GET_VARNA(text, char, MPI_CHAR, COLL_IO, _all) -GET_VARNA(schar, signed char, MPI_SIGNED_CHAR, COLL_IO, _all) -GET_VARNA(uchar, unsigned char, MPI_UNSIGNED_CHAR, COLL_IO, _all) -GET_VARNA(short, short, MPI_SHORT, COLL_IO, _all) -GET_VARNA(ushort, unsigned short, MPI_UNSIGNED_SHORT, COLL_IO, _all) -GET_VARNA(int, int, MPI_INT, COLL_IO, _all) -GET_VARNA(uint, unsigned int, MPI_UNSIGNED, COLL_IO, _all) -GET_VARNA(long, long, MPI_LONG, COLL_IO, _all) -GET_VARNA(float, float, MPI_FLOAT, COLL_IO, _all) -GET_VARNA(double, double, MPI_DOUBLE, COLL_IO, _all) -GET_VARNA(longlong, long long, MPI_LONG_LONG_INT, COLL_IO, _all) -GET_VARNA(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, COLL_IO, _all) - -/*----< ncmpi_get_varns() >--------------------------------------------------*/ -int -ncmpi_get_varns(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - NULL, buf, bufcount, buftype, - READ_REQ, INDEP_IO); -} - -/*----< ncmpi_get_varns_all() >----------------------------------------------*/ -int -ncmpi_get_varns_all(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - NULL, buf, bufcount, buftype, - READ_REQ, COLL_IO); -} - -dnl -dnl GET_VARNS(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`GET_VARNS',dnl -`dnl -/*----< ncmpi_get_varns_$1$5() >----------------------------------------------*/ -int -ncmpi_get_varns_$1$5(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - $2 *buf) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - NULL, buf, -1, $3, READ_REQ, $4); -} -')dnl - -GET_VARNS(text, char, MPI_CHAR, INDEP_IO) -GET_VARNS(schar, signed char, MPI_SIGNED_CHAR, INDEP_IO) -GET_VARNS(uchar, unsigned char, MPI_UNSIGNED_CHAR, INDEP_IO) -GET_VARNS(short, short, MPI_SHORT, INDEP_IO) -GET_VARNS(ushort, unsigned short, MPI_UNSIGNED_SHORT, INDEP_IO) -GET_VARNS(int, int, MPI_INT, INDEP_IO) -GET_VARNS(uint, unsigned int, MPI_UNSIGNED, INDEP_IO) -GET_VARNS(long, long, MPI_LONG, INDEP_IO) -GET_VARNS(float, float, MPI_FLOAT, INDEP_IO) -GET_VARNS(double, double, MPI_DOUBLE, INDEP_IO) -GET_VARNS(longlong, long long, MPI_LONG_LONG_INT, INDEP_IO) -GET_VARNS(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, INDEP_IO) - -GET_VARNS(text, char, MPI_CHAR, COLL_IO, _all) -GET_VARNS(schar, signed char, MPI_SIGNED_CHAR, COLL_IO, _all) -GET_VARNS(uchar, unsigned char, MPI_UNSIGNED_CHAR, COLL_IO, _all) -GET_VARNS(short, short, MPI_SHORT, COLL_IO, _all) -GET_VARNS(ushort, unsigned short, MPI_UNSIGNED_SHORT, COLL_IO, _all) -GET_VARNS(int, int, MPI_INT, COLL_IO, _all) -GET_VARNS(uint, unsigned int, MPI_UNSIGNED, COLL_IO, _all) -GET_VARNS(long, long, MPI_LONG, COLL_IO, _all) -GET_VARNS(float, float, MPI_FLOAT, COLL_IO, _all) -GET_VARNS(double, double, MPI_DOUBLE, COLL_IO, _all) -GET_VARNS(longlong, long long, MPI_LONG_LONG_INT, COLL_IO, _all) -GET_VARNS(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, COLL_IO, _all) - -/*----< ncmpi_get_varnm() >--------------------------------------------------*/ -int -ncmpi_get_varnm(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - imaps, buf, bufcount, buftype, - READ_REQ, INDEP_IO); -} - -/*----< ncmpi_get_varnm_all() >----------------------------------------------*/ -int -ncmpi_get_varnm_all(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - imaps, buf, bufcount, buftype, - READ_REQ, COLL_IO); -} - -dnl -dnl GET_VARNM(btype_name, btype, mpi_type, mode, mode_name) -dnl -define(`GET_VARNM',dnl -`dnl -/*----< ncmpi_get_varnm_$1$5() >----------------------------------------------*/ -int -ncmpi_get_varnm_$1$5(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - $2 *buf) -{ - return ncmpio_getput_varnm(ncid, varid, num, starts, counts, strides, - imaps, buf, -1, $3, READ_REQ, $4); -} -')dnl - -GET_VARNM(text, char, MPI_CHAR, INDEP_IO) -GET_VARNM(schar, signed char, MPI_SIGNED_CHAR, INDEP_IO) -GET_VARNM(uchar, unsigned char, MPI_UNSIGNED_CHAR, INDEP_IO) -GET_VARNM(short, short, MPI_SHORT, INDEP_IO) -GET_VARNM(ushort, unsigned short, MPI_UNSIGNED_SHORT, INDEP_IO) -GET_VARNM(int, int, MPI_INT, INDEP_IO) -GET_VARNM(uint, unsigned int, MPI_UNSIGNED, INDEP_IO) -GET_VARNM(long, long, MPI_LONG, INDEP_IO) -GET_VARNM(float, float, MPI_FLOAT, INDEP_IO) -GET_VARNM(double, double, MPI_DOUBLE, INDEP_IO) -GET_VARNM(longlong, long long, MPI_LONG_LONG_INT, INDEP_IO) -GET_VARNM(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, INDEP_IO) - -GET_VARNM(text, char, MPI_CHAR, COLL_IO, _all) -GET_VARNM(schar, signed char, MPI_SIGNED_CHAR, COLL_IO, _all) -GET_VARNM(uchar, unsigned char, MPI_UNSIGNED_CHAR, COLL_IO, _all) -GET_VARNM(short, short, MPI_SHORT, COLL_IO, _all) -GET_VARNM(ushort, unsigned short, MPI_UNSIGNED_SHORT, COLL_IO, _all) -GET_VARNM(int, int, MPI_INT, COLL_IO, _all) -GET_VARNM(uint, unsigned int, MPI_UNSIGNED, COLL_IO, _all) -GET_VARNM(long, long, MPI_LONG, COLL_IO, _all) -GET_VARNM(float, float, MPI_FLOAT, COLL_IO, _all) -GET_VARNM(double, double, MPI_DOUBLE, COLL_IO, _all) -GET_VARNM(longlong, long long, MPI_LONG_LONG_INT, COLL_IO, _all) -GET_VARNM(ulonglong, unsigned long long, MPI_UNSIGNED_LONG_LONG, COLL_IO, _all) - -/*----< ncmpio_getput_varnm() >-----------------------------------------------*/ -static int -ncmpio_getput_varnm(int ncid, - int varid, - int num, - MPI_Offset* const starts[], /* [num] */ - MPI_Offset* const counts[], /* [num] */ - MPI_Offset* const strides[], /* [num] */ - MPI_Offset* const imaps[], /* [num] */ - void *buf, - MPI_Offset bufcount, - MPI_Datatype buftype, - int rw_flag, /* WRITE_REQ or READ_REQ */ - int io_method) /* COLL_IO or INDEP_IO */ -{ - int i, j, status=NC_NOERR, *req_ids=NULL, *statuses=NULL, min_st; - int el_size, iscontig_of_ptypes, isderived; - void *lbuf; - MPI_Offset bnelems; - MPI_Datatype ptype; - NC *ncp=NULL; - NC_var *varp; - PNC *pncp; - - /* check if ncid is valid */ - status = PNC_check_id(ncid, &pncp); - if (status != NC_NOERR) - /* must return the error now, parallel program might hang */ - return status; - - ncp = (NC*)pncp->ncp; - - /* check if it is in define mode */ - if (NC_indef(ncp)) status = NC_EINDEFINE; - - /* check file write permission if this is write request */ - if (status == NC_NOERR) { - if (rw_flag == WRITE_REQ && NC_readonly(ncp)) status = NC_EPERM; - } - /* check whether collective or independent mode */ - if (status == NC_NOERR) { - if (io_method == INDEP_IO) - status = ncmpio_check_mpifh(ncp, 0); - else if (io_method == COLL_IO) - status = ncmpio_check_mpifh(ncp, 1); - /* else if (io_method == INDEP_COLL_IO) */ - } - - /* check if varid is valid */ - if (status == NC_NOERR) - status = ncmpio_NC_lookupvar(ncp, varid, &varp); - - /* decode buftype */ - if (status == NC_NOERR) { - if (bufcount >= 0) /* flexible API is used */ - /* ptype (primitive MPI data type) from buftype - * el_size is the element size of ptype - * bnelems is the total number of ptype elements in buftype - */ - status = ncmpii_dtype_decode(buftype, &ptype, &el_size, &bnelems, - &isderived, &iscontig_of_ptypes); - else if (bufcount == 0) - num = 0; - else { - ptype = buftype; - el_size = ncmpio_xlen_nc_type(varp->type); - } - } - - if (ncp->safe_mode == 1 && io_method == COLL_IO) - MPI_Allreduce(&status, &min_st, 1, MPI_INT, MPI_MIN, ncp->nciop->comm); - else - min_st = status; - - if (min_st != NC_NOERR) - return status; - - if (num > 0) { - req_ids = (int*) NCI_Malloc(2 * num * SIZEOF_INT); - statuses = req_ids + num; - - lbuf = buf; - if (bufcount > 0) { /* flexible API is used */ - /* check if buftype is contiguous, if not, pack to one, lbuf */ - if (! iscontig_of_ptypes && bnelems > 0) { - /* pack buf into lbuf, a contiguous buffer, based on buftype */ - int position=0, outsize=bnelems*el_size; - lbuf = NCI_Malloc(outsize); - MPI_Pack(buf, bufcount, buftype, lbuf, outsize, &position, - MPI_COMM_SELF); - } - } - } - - /* break buf into num pieces */ - char *bufp = (char*)lbuf; - MPI_Offset *start, *count, buflen; - - if (starts == NULL) { /* var */ - if (num > 0) { - /* if num > 1, skip the 2nd and rest of requests */ - GET_FULL_DIMENSIONS(start, count) - for (buflen=1, j=0; jndims; j++) buflen *= count[j]; - status = ncmpio_igetput_varm(ncp, varp, start, count, NULL, - NULL, bufp, buflen, - ptype, &req_ids[0], rw_flag, 0); - if (varp->ndims > 0) NCI_Free(start); - } - } else if (counts == NULL) { /* var1 */ - count = (MPI_Offset*) NCI_Malloc(varp->ndims * SIZEOF_MPI_OFFSET); - for (j=0; jndims; j++) count[j] = 1; - for (i=0; indims > 0) NCI_Free(count); - } else if (strides == NULL) { /* vara */ - for (i=0; indims; j++) buflen *= counts[i][j]; - status = ncmpio_igetput_varm(ncp, varp, starts[i], counts[i], NULL, - NULL, bufp, buflen, - ptype, &req_ids[i], rw_flag, 0); - bufp += buflen * el_size; - } - } else if (imaps == NULL) { /* vars */ - for (i=0; indims; j++) buflen *= counts[i][j]; - status = ncmpio_igetput_varm(ncp, varp, starts[i], counts[i], - strides[i], NULL, bufp, buflen, - ptype, &req_ids[i], rw_flag, 0); - bufp += buflen * el_size; - } - } else { /* varm */ - for (i=0; indims; j++) buflen *= counts[i][j]; - status = ncmpio_igetput_varm(ncp, varp, starts[i], counts[i], - strides[i], imaps[i], bufp, buflen, - ptype, &req_ids[i], rw_flag, 0); - bufp += buflen * el_size; - } - } - - if (status != NC_NOERR) - return status; - - if (starts == NULL && num > 0) num = 1; /* var */ - - if (io_method == COLL_IO) - status = ncmpi_wait_all(ncid, num, req_ids, statuses); - else - status = ncmpi_wait(ncid, num, req_ids, statuses); - - if (status != NC_NOERR) - return status; - - for (i=0; i 0) - NCI_Free(req_ids); - - return NC_NOERR; -} diff --git a/src/drivers/ncmpio/Legacy/varnx_api_header.m4 b/src/drivers/ncmpio/Legacy/varnx_api_header.m4 deleted file mode 100644 index 38e3661bd..000000000 --- a/src/drivers/ncmpio/Legacy/varnx_api_header.m4 +++ /dev/null @@ -1,360 +0,0 @@ -/* Begin of {put,get}_varn{kind} */ - -define(`VARNX',dnl -`dnl -int ncmpi_$1_varn$2(int ncid, int varid, int num, $3 void *buf, - MPI_Offset bufcount, MPI_Datatype buftype); -')dnl -VARNX(get) -VARNX(get, _all) -VARNX(put, , const) -VARNX(put, _all, const) - -define(`VARN',dnl -`dnl -int ncmpi_$1_varn_$2$3(int ncid, int varid, int num, $4 *buf); -')dnl -VARN(get, text, , char) -VARN(get, schar, , signed char) -VARN(get, short, , short) -VARN(get, int, , int) -VARN(get, float, , float) -VARN(get, double, , double) -VARN(get, longlong, , long long) -VARN(get, text, _all, char) -VARN(get, schar, _all, signed char) -VARN(get, short, _all, short) -VARN(get, int, _all, int) -VARN(get, float, _all, float) -VARN(get, double, _all, double) -VARN(get, longlong, _all, long long) -VARN(put, text, , const char) -VARN(put, schar, , const signed char) -VARN(put, short, , const short) -VARN(put, int, , const int) -VARN(put, float, , const float) -VARN(put, double, , const double) -VARN(put, longlong, , const long long) -VARN(put, text, _all, const char) -VARN(put, schar, _all, const signed char) -VARN(put, short, _all, const short) -VARN(put, int, _all, const int) -VARN(put, float, _all, const float) -VARN(put, double, _all, const double) -VARN(put, longlong, _all, const long long) - -/* Begin Skip Prototypes for Fortran binding */ -/* skip types: uchar, ubyte, ushort, uint, long, ulonglong string */ - -VARN(get, uchar, , unsigned char) -VARN(get, ushort, , unsigned short) -VARN(get, uint, , unsigned int) -VARN(get, long, , long) -VARN(get, ulonglong, , unsigned long long) -VARN(get, uchar, _all, unsigned char) -VARN(get, ushort, _all, unsigned short) -VARN(get, uint, _all, unsigned int) -VARN(get, long, _all, long) -VARN(get, ulonglong, _all, unsigned long long) -VARN(put, uchar, , const unsigned char) -VARN(put, ushort, , const unsigned short) -VARN(put, uint, , const unsigned int) -VARN(put, long, , const long) -VARN(put, ulonglong, , const unsigned long long) -VARN(put, uchar, _all, const unsigned char) -VARN(put, ushort, _all, const unsigned short) -VARN(put, uint, _all, const unsigned int) -VARN(put, long, _all, const long) -VARN(put, ulonglong, _all, const unsigned long long) -/* End Skip Prototypes for Fortran binding */ - -define(`VARN1X',dnl -`dnl -int ncmpi_$1_varn1$2(int ncid, int varid, int num, - MPI_Offset* const starts[], $3 void *buf, - MPI_Offset bufcount, MPI_Datatype buftype); -')dnl -VARN1X(get) -VARN1X(get, _all) -VARN1X(put, , const) -VARN1X(put, _all, const) - -define(`VARN1',dnl -`dnl -int ncmpi_$1_varn1_$2$3(int ncid, int varid, int num, - MPI_Offset* const starts[], $4 *buf); -')dnl -VARN1(get, text, , char) -VARN1(get, schar, , signed char) -VARN1(get, short, , short) -VARN1(get, int, , int) -VARN1(get, float, , float) -VARN1(get, double, , double) -VARN1(get, longlong, , long long) -VARN1(get, text, _all, char) -VARN1(get, schar, _all, signed char) -VARN1(get, short, _all, short) -VARN1(get, int, _all, int) -VARN1(get, float, _all, float) -VARN1(get, double, _all, double) -VARN1(get, longlong, _all, long long) -VARN1(put, text, , const char) -VARN1(put, schar, , const signed char) -VARN1(put, short, , const short) -VARN1(put, int, , const int) -VARN1(put, float, , const float) -VARN1(put, double, , const double) -VARN1(put, longlong, , const long long) -VARN1(put, text, _all, const char) -VARN1(put, schar, _all, const signed char) -VARN1(put, short, _all, const short) -VARN1(put, int, _all, const int) -VARN1(put, float, _all, const float) -VARN1(put, double, _all, const double) -VARN1(put, longlong, _all, const long long) - -/* Begin Skip Prototypes for Fortran binding */ -/* skip types: uchar, ubyte, ushort, uint, long, ulonglong string */ - -VARN1(get, uchar, , unsigned char) -VARN1(get, ushort, , unsigned short) -VARN1(get, uint, , unsigned int) -VARN1(get, long, , long) -VARN1(get, ulonglong, , unsigned long long) -VARN1(get, uchar, _all, unsigned char) -VARN1(get, ushort, _all, unsigned short) -VARN1(get, uint, _all, unsigned int) -VARN1(get, long, _all, long) -VARN1(get, ulonglong, _all, unsigned long long) -VARN1(put, uchar, , const unsigned char) -VARN1(put, ushort, , const unsigned short) -VARN1(put, uint, , const unsigned int) -VARN1(put, long, , const long) -VARN1(put, ulonglong, , const unsigned long long) -VARN1(put, uchar, _all, const unsigned char) -VARN1(put, ushort, _all, const unsigned short) -VARN1(put, uint, _all, const unsigned int) -VARN1(put, long, _all, const long) -VARN1(put, ulonglong, _all, const unsigned long long) -/* End Skip Prototypes for Fortran binding */ - -define(`VARNAX',dnl -`dnl -int ncmpi_$1_varna$2(int ncid, int varid, int num, - MPI_Offset* const starts[], MPI_Offset* const counts[], - $3 void *buf, - MPI_Offset bufcount, MPI_Datatype buftype); -')dnl -VARNAX(get) -VARNAX(get, _all) -VARNAX(put, , const) -VARNAX(put, _all, const) - -define(`VARNA',dnl -`dnl -int ncmpi_$1_varna_$2$3(int ncid, int varid, int num, - MPI_Offset* const starts[], MPI_Offset* const counts[], - $4 *buf); -')dnl -VARNA(get, text, , char) -VARNA(get, schar, , signed char) -VARNA(get, short, , short) -VARNA(get, int, , int) -VARNA(get, float, , float) -VARNA(get, double, , double) -VARNA(get, longlong, , long long) -VARNA(get, text, _all, char) -VARNA(get, schar, _all, signed char) -VARNA(get, short, _all, short) -VARNA(get, int, _all, int) -VARNA(get, float, _all, float) -VARNA(get, double, _all, double) -VARNA(get, longlong, _all, long long) -VARNA(put, text, , const char) -VARNA(put, schar, , const signed char) -VARNA(put, short, , const short) -VARNA(put, int, , const int) -VARNA(put, float, , const float) -VARNA(put, double, , const double) -VARNA(put, longlong, , const long long) -VARNA(put, text, _all, const char) -VARNA(put, schar, _all, const signed char) -VARNA(put, short, _all, const short) -VARNA(put, int, _all, const int) -VARNA(put, float, _all, const float) -VARNA(put, double, _all, const double) -VARNA(put, longlong, _all, const long long) - -/* Begin Skip Prototypes for Fortran binding */ -/* skip types: uchar, ubyte, ushort, uint, long, ulonglong string */ - -VARNA(get, uchar, , unsigned char) -VARNA(get, ushort, , unsigned short) -VARNA(get, uint, , unsigned int) -VARNA(get, long, , long) -VARNA(get, ulonglong, , unsigned long long) -VARNA(get, uchar, _all, unsigned char) -VARNA(get, ushort, _all, unsigned short) -VARNA(get, uint, _all, unsigned int) -VARNA(get, long, _all, long) -VARNA(get, ulonglong, _all, unsigned long long) -VARNA(put, uchar, , const unsigned char) -VARNA(put, ushort, , const unsigned short) -VARNA(put, uint, , const unsigned int) -VARNA(put, long, , const long) -VARNA(put, ulonglong, , const unsigned long long) -VARNA(put, uchar, _all, const unsigned char) -VARNA(put, ushort, _all, const unsigned short) -VARNA(put, uint, _all, const unsigned int) -VARNA(put, long, _all, const long) -VARNA(put, ulonglong, _all, const unsigned long long) -/* End Skip Prototypes for Fortran binding */ - -define(`VARNSX',dnl -`dnl -int ncmpi_$1_varns$2(int ncid, int varid, int num, - MPI_Offset* const starts[], MPI_Offset* const counts[], - MPI_Offset* const strides[], $3 void *buf, - MPI_Offset bufcount, MPI_Datatype buftype); -')dnl -VARNSX(get) -VARNSX(get, _all) -VARNSX(put, , const) -VARNSX(put, _all, const) - -define(`VARNS',dnl -`dnl -int ncmpi_$1_varns_$2$3(int ncid, int varid, int num, - MPI_Offset* const starts[], MPI_Offset* const counts[], - MPI_Offset* const strides[], $4 *buf); -')dnl -VARNS(get, text, , char) -VARNS(get, schar, , signed char) -VARNS(get, short, , short) -VARNS(get, int, , int) -VARNS(get, float, , float) -VARNS(get, double, , double) -VARNS(get, longlong, , long long) -VARNS(get, text, _all, char) -VARNS(get, schar, _all, signed char) -VARNS(get, short, _all, short) -VARNS(get, int, _all, int) -VARNS(get, float, _all, float) -VARNS(get, double, _all, double) -VARNS(get, longlong, _all, long long) -VARNS(put, text, , const char) -VARNS(put, schar, , const signed char) -VARNS(put, short, , const short) -VARNS(put, int, , const int) -VARNS(put, float, , const float) -VARNS(put, double, , const double) -VARNS(put, longlong, , const long long) -VARNS(put, text, _all, const char) -VARNS(put, schar, _all, const signed char) -VARNS(put, short, _all, const short) -VARNS(put, int, _all, const int) -VARNS(put, float, _all, const float) -VARNS(put, double, _all, const double) -VARNS(put, longlong, _all, const long long) - -/* Begin Skip Prototypes for Fortran binding */ -/* skip types: uchar, ubyte, ushort, uint, long, ulonglong string */ - -VARNS(get, uchar, , unsigned char) -VARNS(get, ushort, , unsigned short) -VARNS(get, uint, , unsigned int) -VARNS(get, long, , long) -VARNS(get, ulonglong, , unsigned long long) -VARNS(get, uchar, _all, unsigned char) -VARNS(get, ushort, _all, unsigned short) -VARNS(get, uint, _all, unsigned int) -VARNS(get, long, _all, long) -VARNS(get, ulonglong, _all, unsigned long long) -VARNS(put, uchar, , const unsigned char) -VARNS(put, ushort, , const unsigned short) -VARNS(put, uint, , const unsigned int) -VARNS(put, long, , const long) -VARNS(put, ulonglong, , const unsigned long long) -VARNS(put, uchar, _all, const unsigned char) -VARNS(put, ushort, _all, const unsigned short) -VARNS(put, uint, _all, const unsigned int) -VARNS(put, long, _all, const long) -VARNS(put, ulonglong, _all, const unsigned long long) -/* End Skip Prototypes for Fortran binding */ - -define(`VARNMX',dnl -`dnl -int ncmpi_$1_varnm$2(int ncid, int varid, int num, - MPI_Offset* const starts[], MPI_Offset* const counts[], - MPI_Offset* const strides[], MPI_Offset* const imaps[], - $3 void *buf, - MPI_Offset bufcount, MPI_Datatype buftype); -')dnl -VARNMX(get) -VARNMX(get, _all) -VARNMX(put, , const) -VARNMX(put, _all, const) - -define(`VARNM',dnl -`dnl -int ncmpi_$1_varnm_$2$3(int ncid, int varid, int num, - MPI_Offset* const starts[], MPI_Offset* const counts[], - MPI_Offset* const strides[], MPI_Offset* const imaps[], - $4 *buf); -')dnl -VARNM(get, text, , char) -VARNM(get, schar, , signed char) -VARNM(get, short, , short) -VARNM(get, int, , int) -VARNM(get, float, , float) -VARNM(get, double, , double) -VARNM(get, longlong, , long long) -VARNM(get, text, _all, char) -VARNM(get, schar, _all, signed char) -VARNM(get, short, _all, short) -VARNM(get, int, _all, int) -VARNM(get, float, _all, float) -VARNM(get, double, _all, double) -VARNM(get, longlong, _all, long long) -VARNM(put, text, , const char) -VARNM(put, schar, , const signed char) -VARNM(put, short, , const short) -VARNM(put, int, , const int) -VARNM(put, float, , const float) -VARNM(put, double, , const double) -VARNM(put, longlong, , const long long) -VARNM(put, text, _all, const char) -VARNM(put, schar, _all, const signed char) -VARNM(put, short, _all, const short) -VARNM(put, int, _all, const int) -VARNM(put, float, _all, const float) -VARNM(put, double, _all, const double) -VARNM(put, longlong, _all, const long long) - -/* Begin Skip Prototypes for Fortran binding */ -/* skip types: uchar, ubyte, ushort, uint, long, ulonglong string */ - -VARNM(get, uchar, , unsigned char) -VARNM(get, ushort, , unsigned short) -VARNM(get, uint, , unsigned int) -VARNM(get, long, , long) -VARNM(get, ulonglong, , unsigned long long) -VARNM(get, uchar, _all, unsigned char) -VARNM(get, ushort, _all, unsigned short) -VARNM(get, uint, _all, unsigned int) -VARNM(get, long, _all, long) -VARNM(get, ulonglong, _all, unsigned long long) -VARNM(put, uchar, , const unsigned char) -VARNM(put, ushort, , const unsigned short) -VARNM(put, uint, , const unsigned int) -VARNM(put, long, , const long) -VARNM(put, ulonglong, , const unsigned long long) -VARNM(put, uchar, _all, const unsigned char) -VARNM(put, ushort, _all, const unsigned short) -VARNM(put, uint, _all, const unsigned int) -VARNM(put, long, _all, const long) -VARNM(put, ulonglong, _all, const unsigned long long) -/* End Skip Prototypes for Fortran binding */ - -/* Begin of {put,get}_varn{kind} */ - diff --git a/test/C/Legacy/sfc_pres_temp_rd.c b/test/C/Legacy/sfc_pres_temp_rd.c deleted file mode 100644 index 7d240255b..000000000 --- a/test/C/Legacy/sfc_pres_temp_rd.c +++ /dev/null @@ -1,170 +0,0 @@ -/* This is part of the netCDF package. - Copyright 2006 University Corporation for Atmospheric Research/Unidata. - See COPYRIGHT file for conditions of use. - - This is an example which reads some surface pressure and - temperatures. The data file read by this program is produced by the - companion program sfc_pres_temp_wr.c. It is intended to illustrate - the use of the netCDF C API. - - This program is part of the netCDF tutorial: - http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial - - Full documentation of the netCDF C API can be found at: - http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c - - $Id$ -*/ - -#include -#include -#include - -/* This is the name of the data file we will read. */ -#define FILE_NAME "sfc_pres_temp.nc" - -/* We are reading 2D data, a 6 x 12 lat-lon grid. */ -#define NDIMS 2 -#define NLAT 6 -#define NLON 12 - -#define LAT_NAME "latitude" -#define LON_NAME "longitude" -#define PRES_NAME "pressure" -#define TEMP_NAME "temperature" - -/* These are used to calculate the values we expect to find. */ -#define SAMPLE_PRESSURE 900 -#define SAMPLE_TEMP 9.0 -#define START_LAT 25.0 -#define START_LON -125.0 - -/* For the units attributes. */ -#define UNITS "units" -#define PRES_UNITS "hPa" -#define TEMP_UNITS "celsius" -#define LAT_UNITS "degrees_north" -#define LON_UNITS "degrees_east" -#define MAX_ATT_LEN 80 - -/* Handle errors by printing an error message and exiting with a - * non-zero status. */ -#define ERR(e) {printf("Error: %s\n", nc_strerror(e)); return 2;} - -int -main() -{ - int ncid, pres_varid, temp_varid; - int lat_varid, lon_varid; - - /* We will read surface temperature and pressure fields. */ - float pres_in[NLAT][NLON]; - float temp_in[NLAT][NLON]; - - /* For the lat lon coordinate variables. */ - float lats_in[NLAT], lons_in[NLON]; - - /* To check the units attributes. */ - char pres_units_in[MAX_ATT_LEN], temp_units_in[MAX_ATT_LEN]; - char lat_units_in[MAX_ATT_LEN], lon_units_in[MAX_ATT_LEN]; - - /* We will learn about the data file and store results in these - program variables. */ - int ndims_in, nvars_in, ngatts_in, unlimdimid_in; - - /* Loop indexes. */ - int lat, lon; - - /* Error handling. */ - int retval; - - /* Open the file. */ - if ((retval = nc_open(FILE_NAME, NC_NOWRITE, &ncid))) - ERR(retval); - - /* There are a number of inquiry functions in netCDF which can be - used to learn about an unknown netCDF file. NC_INQ tells how - many netCDF variables, dimensions, and global attributes are in - the file; also the dimension id of the unlimited dimension, if - there is one. */ - if ((retval = nc_inq(ncid, &ndims_in, &nvars_in, &ngatts_in, - &unlimdimid_in))) - ERR(retval); - - /* In this case we know that there are 2 netCDF dimensions, 4 - netCDF variables, no global attributes, and no unlimited - dimension. */ - if (ndims_in != 2 || nvars_in != 4 || ngatts_in != 0 || - unlimdimid_in != -1) return 2; - - /* Get the varids of the latitude and longitude coordinate - * variables. */ - if ((retval = nc_inq_varid(ncid, LAT_NAME, &lat_varid))) - ERR(retval); - if ((retval = nc_inq_varid(ncid, LON_NAME, &lon_varid))) - ERR(retval); - - /* Read the coordinate variable data. */ - if ((retval = nc_get_var_float(ncid, lat_varid, &lats_in[0]))) - ERR(retval); - if ((retval = nc_get_var_float(ncid, lon_varid, &lons_in[0]))) - ERR(retval); - - /* Check the coordinate variable data. */ - for (lat = 0; lat < NLAT; lat++) - if (lats_in[lat] != START_LAT + 5.*lat) - return 2; - for (lon = 0; lon < NLON; lon++) - if (lons_in[lon] != START_LON + 5.*lon) - return 2; - - /* Get the varids of the pressure and temperature netCDF - * variables. */ - if ((retval = nc_inq_varid(ncid, PRES_NAME, &pres_varid))) - ERR(retval); - if ((retval = nc_inq_varid(ncid, TEMP_NAME, &temp_varid))) - ERR(retval); - - /* Read the data. Since we know the contents of the file we know - * that the data arrays in this program are the correct size to - * hold all the data. */ - if ((retval = nc_get_var_float(ncid, pres_varid, &pres_in[0][0]))) - ERR(retval); - if ((retval = nc_get_var_float(ncid, temp_varid, &temp_in[0][0]))) - ERR(retval); - - /* Check the data. */ - for (lat = 0; lat < NLAT; lat++) - for (lon = 0; lon < NLON; lon++) - if (pres_in[lat][lon] != SAMPLE_PRESSURE + (lon * NLAT + lat) || - temp_in[lat][lon] != SAMPLE_TEMP + .25 * (lon * NLAT + lat)) - return 2; - - /* Each of the netCDF variables has a "units" attribute. Let's read - them and check them. */ - if ((retval = nc_get_att_text(ncid, lat_varid, UNITS, lat_units_in))) - ERR(retval); - if (strncmp(lat_units_in, LAT_UNITS, strlen(LAT_UNITS))) - return 2; - - if ((retval = nc_get_att_text(ncid, lon_varid, UNITS, lon_units_in))) - ERR(retval); - if (strncmp(lon_units_in, LON_UNITS, strlen(LON_UNITS))) - return 2; - - if ((retval = nc_get_att_text(ncid, pres_varid, UNITS, pres_units_in))) - ERR(retval); - if (strncmp(pres_units_in, PRES_UNITS, strlen(PRES_UNITS))) - return 2; - - if ((retval = nc_get_att_text(ncid, temp_varid, UNITS, temp_units_in))) - ERR(retval); - if (strncmp(temp_units_in, TEMP_UNITS, strlen(TEMP_UNITS))) return 2; - - /* Close the file. */ - if ((retval = nc_close(ncid))) - ERR(retval); - - printf("*** SUCCESS reading example file sfc_pres_temp.nc!\n"); - return 0; -} diff --git a/test/C/Legacy/sfc_pres_temp_wr.c b/test/C/Legacy/sfc_pres_temp_wr.c deleted file mode 100644 index 44543c596..000000000 --- a/test/C/Legacy/sfc_pres_temp_wr.c +++ /dev/null @@ -1,174 +0,0 @@ -/* This is part of the netCDF package. - Copyright 2006 University Corporation for Atmospheric Research/Unidata. - See COPYRIGHT file for conditions of use. - - This example writes some surface pressure and temperatures. It is - intended to illustrate the use of the netCDF C API. The companion - program sfc_pres_temp_rd.c shows how to read the netCDF data file - created by this program. - - This program is part of the netCDF tutorial: - http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial - - Full documentation of the netCDF C API can be found at: - http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c - - $Id$ -*/ - -#include -#include -#include - -/* This is the name of the data file we will create. */ -#define FILE_NAME "sfc_pres_temp.nc" - -/* We are writing 2D data, a 6 x 12 lat-lon grid. We will need two - * netCDF dimensions. */ -#define NDIMS 2 -#define NLAT 6 -#define NLON 12 -#define LAT_NAME "latitude" -#define LON_NAME "longitude" - -/* Names of things. */ -#define PRES_NAME "pressure" -#define TEMP_NAME "temperature" -#define UNITS "units" -#define DEGREES_EAST "degrees_east" -#define DEGREES_NORTH "degrees_north" - -/* These are used to construct some example data. */ -#define SAMPLE_PRESSURE 900 -#define SAMPLE_TEMP 9.0 -#define START_LAT 25.0 -#define START_LON -125.0 - -/* Handle errors by printing an error message and exiting with a - * non-zero status. */ -#define ERR(e) {printf("Error: %s\n", nc_strerror(e)); return 2;} - -int -main() -{ - int ncid, lon_dimid, lat_dimid, pres_varid, temp_varid; - -/* In addition to the latitude and longitude dimensions, we will also - create latitude and longitude netCDF variables which will hold the - actual latitudes and longitudes. Since they hold data about the - coordinate system, the netCDF term for these is: "coordinate - variables." */ - int lat_varid, lon_varid; - - int dimids[NDIMS]; - - /* We will write surface temperature and pressure fields. */ - float pres_out[NLAT][NLON]; - float temp_out[NLAT][NLON]; - float lats[NLAT], lons[NLON]; - - /* It's good practice for each netCDF variable to carry a "units" - * attribute. */ - char pres_units[] = "hPa"; - char temp_units[] = "celsius"; - - /* Loop indexes. */ - int lat, lon; - - /* Error handling. */ - int retval; - - /* Create some pretend data. If this wasn't an example program, we - * would have some real data to write, for example, model - * output. */ - for (lat = 0; lat < NLAT; lat++) - lats[lat] = START_LAT + 5.*lat; - for (lon = 0; lon < NLON; lon++) - lons[lon] = START_LON + 5.*lon; - - for (lat = 0; lat < NLAT; lat++) - for (lon = 0; lon < NLON; lon++) - { - pres_out[lat][lon] = SAMPLE_PRESSURE + (lon * NLAT + lat); - temp_out[lat][lon] = SAMPLE_TEMP + .25 * (lon * NLAT + lat); - } - - /* Create the file. */ - if ((retval = nc_create(FILE_NAME, NC_CLOBBER, &ncid))) - ERR(retval); - - /* Define the dimensions. */ - if ((retval = nc_def_dim(ncid, LAT_NAME, NLAT, &lat_dimid))) - ERR(retval); - if ((retval = nc_def_dim(ncid, LON_NAME, NLON, &lon_dimid))) - ERR(retval); - - /* Define coordinate netCDF variables. They will hold the - coordinate information, that is, the latitudes and longitudes. A - varid is returned for each.*/ - if ((retval = nc_def_var(ncid, LAT_NAME, NC_FLOAT, 1, &lat_dimid, - &lat_varid))) - ERR(retval); - if ((retval = nc_def_var(ncid, LON_NAME, NC_FLOAT, 1, &lon_dimid, - &lon_varid))) - ERR(retval); - - /* Define units attributes for coordinate vars. This attaches a - text attribute to each of the coordinate variables, containing - the units. Note that we are not writing a trailing NULL, just - "units", because the reading program may be fortran which does - not use null-terminated strings. In general it is up to the - reading C program to ensure that it puts null-terminators on - strings where necessary.*/ - if ((retval = nc_put_att_text(ncid, lat_varid, UNITS, - strlen(DEGREES_NORTH), DEGREES_NORTH))) - ERR(retval); - if ((retval = nc_put_att_text(ncid, lon_varid, UNITS, - strlen(DEGREES_EAST), DEGREES_EAST))) - ERR(retval); - - /* Define the netCDF variables. The dimids array is used to pass - the dimids of the dimensions of the variables.*/ - dimids[0] = lat_dimid; - dimids[1] = lon_dimid; - if ((retval = nc_def_var(ncid, PRES_NAME, NC_FLOAT, NDIMS, - dimids, &pres_varid))) - ERR(retval); - if ((retval = nc_def_var(ncid, TEMP_NAME, NC_FLOAT, NDIMS, - dimids, &temp_varid))) - ERR(retval); - - /* Define units attributes for vars. */ - if ((retval = nc_put_att_text(ncid, pres_varid, UNITS, - strlen(pres_units), pres_units))) - ERR(retval); - if ((retval = nc_put_att_text(ncid, temp_varid, UNITS, - strlen(temp_units), temp_units))) - ERR(retval); - - /* End define mode. */ - if ((retval = nc_enddef(ncid))) - ERR(retval); - - /* Write the coordinate variable data. This will put the latitudes - and longitudes of our data grid into the netCDF file. */ - if ((retval = nc_put_var_float(ncid, lat_varid, &lats[0]))) - ERR(retval); - if ((retval = nc_put_var_float(ncid, lon_varid, &lons[0]))) - ERR(retval); - - /* Write the pretend data. This will write our surface pressure and - surface temperature data. The arrays of data are the same size - as the netCDF variables we have defined. */ - if ((retval = nc_put_var_float(ncid, pres_varid, &pres_out[0][0]))) - ERR(retval); - if ((retval = nc_put_var_float(ncid, temp_varid, &temp_out[0][0]))) - ERR(retval); - - /* Close the file. */ - if ((retval = nc_close(ncid))) - ERR(retval); - - printf("*** SUCCESS writing example file sfc_pres_temp.nc!\n"); - return 0; -} diff --git a/test/C/Legacy/simple_xy_rd.c b/test/C/Legacy/simple_xy_rd.c deleted file mode 100644 index 6d841348b..000000000 --- a/test/C/Legacy/simple_xy_rd.c +++ /dev/null @@ -1,69 +0,0 @@ -/* This is part of the netCDF package. - Copyright 2006 University Corporation for Atmospheric Research/Unidata. - See COPYRIGHT file for conditions of use. - - This is a simple example which reads a small dummy array, which was - written by simple_xy_wr.c. This is intended to illustrate the use - of the netCDF C API. - - This program is part of the netCDF tutorial: - http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial - - Full documentation of the netCDF C API can be found at: - http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c - - $Id$ -*/ -#include -#include -#include - -/* This is the name of the data file we will read. */ -#define FILE_NAME "simple_xy.nc" - -/* We are reading 2D data, a 6 x 12 grid. */ -#define NX 6 -#define NY 12 - -/* Handle errors by printing an error message and exiting with a - * non-zero status. */ -#define ERRCODE 2 -#define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} - -int -main() -{ - /* This will be the netCDF ID for the file and data variable. */ - int ncid, varid; - - int data_in[NX][NY]; - - /* Loop indexes, and error handling. */ - int x, y, retval; - - /* Open the file. NC_NOWRITE tells netCDF we want read-only access - * to the file.*/ - if ((retval = nc_open(FILE_NAME, NC_NOWRITE, &ncid))) - ERR(retval); - - /* Get the varid of the data variable, based on its name. */ - if ((retval = nc_inq_varid(ncid, "data", &varid))) - ERR(retval); - - /* Read the data. */ - if ((retval = nc_get_var_int(ncid, varid, &data_in[0][0]))) - ERR(retval); - - /* Check the data. */ - for (x = 0; x < NX; x++) - for (y = 0; y < NY; y++) - if (data_in[x][y] != x * NY + y) - return ERRCODE; - - /* Close the file, freeing all resources. */ - if ((retval = nc_close(ncid))) - ERR(retval); - - printf("*** SUCCESS reading example file %s!\n", FILE_NAME); - return 0; -} diff --git a/test/C/Legacy/simple_xy_wr.c b/test/C/Legacy/simple_xy_wr.c deleted file mode 100644 index ff039c33b..000000000 --- a/test/C/Legacy/simple_xy_wr.c +++ /dev/null @@ -1,102 +0,0 @@ -/* This is part of the netCDF package. - Copyright 2006 University Corporation for Atmospheric Research/Unidata. - See COPYRIGHT file for conditions of use. - - This is a very simple example which writes a 2D array of - sample data. To handle this in netCDF we create two shared - dimensions, "x" and "y", and a netCDF variable, called "data". - - This example demonstrates the netCDF C API. This is part of the - netCDF tutorial, which can be found at: - http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial - - Full documentation of the netCDF C API can be found at: - http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c - - $Id$ -*/ -#include -#include -#include - -/* This is the name of the data file we will create. */ -#define FILE_NAME "simple_xy.nc" - -/* We are writing 2D data, a 6 x 12 grid. */ -#define NDIMS 2 -#define NX 6 -#define NY 12 - -/* Handle errors by printing an error message and exiting with a - * non-zero status. */ -#define ERRCODE 2 -#define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} - -int -main() -{ - /* When we create netCDF variables and dimensions, we get back an - * ID for each one. */ - int ncid, x_dimid, y_dimid, varid; - int dimids[NDIMS]; - - /* This is the data array we will write. It will be filled with a - * progression of numbers for this example. */ - int data_out[NX][NY]; - - /* Loop indexes, and error handling. */ - int x, y, retval; - - /* Create some pretend data. If this wasn't an example program, we - * would have some real data to write, for example, model - * output. */ - for (x = 0; x < NX; x++) - for (y = 0; y < NY; y++) - data_out[x][y] = x * NY + y; - - /* Always check the return code of every netCDF function call. In - * this example program, any retval which is not equal to NC_NOERR - * (0) will cause the program to print an error message and exit - * with a non-zero return code. */ - - /* Create the file. The NC_CLOBBER parameter tells netCDF to - * overwrite this file, if it already exists.*/ - if ((retval = nc_create(FILE_NAME, NC_CLOBBER, &ncid))) - ERR(retval); - - /* Define the dimensions. NetCDF will hand back an ID for each. */ - if ((retval = nc_def_dim(ncid, "x", NX, &x_dimid))) - ERR(retval); - if ((retval = nc_def_dim(ncid, "y", NY, &y_dimid))) - ERR(retval); - - /* The dimids array is used to pass the IDs of the dimensions of - * the variable. */ - dimids[0] = x_dimid; - dimids[1] = y_dimid; - - /* Define the variable. The type of the variable in this case is - * NC_INT (4-byte integer). */ - if ((retval = nc_def_var(ncid, "data", NC_INT, NDIMS, - dimids, &varid))) - ERR(retval); - - /* End define mode. This tells netCDF we are done defining - * metadata. */ - if ((retval = nc_enddef(ncid))) - ERR(retval); - - /* Write the pretend data to the file. Although netCDF supports - * reading and writing subsets of data, in this case we write all - * the data in one operation. */ - if ((retval = nc_put_var_int(ncid, varid, &data_out[0][0]))) - ERR(retval); - - /* Close the file. This frees up any internal netCDF resources - * associated with the file, and flushes any buffers. */ - if ((retval = nc_close(ncid))) - ERR(retval); - - printf("*** SUCCESS writing example file simple_xy.nc!\n"); - return 0; -} diff --git a/test/Legacy/data/Makefile.am b/test/Legacy/data/Makefile.am deleted file mode 100644 index c8ebd5e9c..000000000 --- a/test/Legacy/data/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (C) 2003, Northwestern University and Argonne National Laboratory -# See COPYRIGHT notice in top-level directory. -# -# $Id$ -# -# @configure_input@ - -srcdir = @srcdir@ -VPATH = @srcdir@ - -include ../../macros.make - -NC_ZIP_FILES = test_double.nc.gz \ - test_float.nc.gz \ - test_int_cdf5.nc.gz \ - test_int.nc.gz - -NC_FILES = $(NC_ZIP_FILES:.nc.gz=.nc) - -GARBAGE = $(NC_FILES) - -PACKING_LIST = $(NC_ZIP_FILES) Makefile.in - -all: $(NC_FILES) - -test_double.nc: test_double.nc.gz - gzip -dc $< > $@ - -test_float.nc: test_float.nc.gz - gzip -dc $< > $@ - -test_int_cdf5.nc: test_int_cdf5.nc.gz - gzip -dc $< > $@ - -test_int.nc: test_int.nc.gz - gzip -dc $< > $@ - -unzip: - set -e; for i in $(NC_ZIP_FILES); do ( if [ ! -f $$i ] ; then gzip -dc $(srcdir)/$$i.gz > $$i ; fi ) ; done - -testing check verbose_testing: - -ptest ptests ptest2 ptest4 ptest6 ptest8 ptest10: - - -include $(srcdir)/../../rules.make - diff --git a/test/Legacy/data/test_double.nc.gz b/test/Legacy/data/test_double.nc.gz deleted file mode 100644 index a4a99bf0a..000000000 Binary files a/test/Legacy/data/test_double.nc.gz and /dev/null differ diff --git a/test/Legacy/data/test_float.nc.gz b/test/Legacy/data/test_float.nc.gz deleted file mode 100644 index c82253d7e..000000000 Binary files a/test/Legacy/data/test_float.nc.gz and /dev/null differ diff --git a/test/Legacy/data/test_int.nc.gz b/test/Legacy/data/test_int.nc.gz deleted file mode 100644 index faf6e6fa4..000000000 Binary files a/test/Legacy/data/test_int.nc.gz and /dev/null differ diff --git a/test/Legacy/data/test_int_cdf5.nc.gz b/test/Legacy/data/test_int_cdf5.nc.gz deleted file mode 100644 index 7db7b7a15..000000000 Binary files a/test/Legacy/data/test_int_cdf5.nc.gz and /dev/null differ diff --git a/test/Legacy/test_double/Makefile.am b/test/Legacy/test_double/Makefile.am deleted file mode 100644 index d24e3ae97..000000000 --- a/test/Legacy/test_double/Makefile.am +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright (C) 2003, Northwestern University and Argonne National Laboratory -# See COPYRIGHT notice in top-level directory. -# -# $Id$ -# -# @configure_input@ - -srcdir = @srcdir@ -VPATH = @srcdir@ - -include ../../macros.make - -INCLUDES = -I../../src/lib -I$(srcdir)/../common -LDFLAGS := $(LDFLAGS) -L../common -LIBS := $(LIBRARY) -ltestutils $(LIBS) - -SRCS = test_read.c \ - test_read_indep.c \ - test_write.c \ - test_write_indep.c - -OBJS = $(SRCS:.c=.o) -PROGS = $(SRCS:.c=) - -GARBAGE = $(PROGS) - -PACKING_LIST = $(SRCS) README Makefile.in - -all: $(PROGS) - set -e; cd ../data && $(MAKE) $(MFLAGS) all - -$(OBJS): $(srcdir)/../common/testutils.h - -$(PROGS): ../common/libtestutils.a - -../common/libtestutils.a: - set -e; cd ../common && $(MAKE) $(MFLAGS) all - -test_read: test_read.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -test_read_indep: test_read_indep.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -test_write: test_write.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -test_write_indep: test_write_indep.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -testing check verbose_testing: - -ptest ptests ptest2 ptest4 ptest6 ptest8 ptest10: - -include $(srcdir)/../../rules.make - -$(LIBRARY): ; - diff --git a/test/Legacy/test_double/README b/test/Legacy/test_double/README deleted file mode 100644 index 07ff33bad..000000000 --- a/test/Legacy/test_double/README +++ /dev/null @@ -1,3 +0,0 @@ -These examples test data transfers of: - - "file NC_DOUBLE var" <---> "memory double" diff --git a/test/Legacy/test_double/test_read.c b/test/Legacy/test_double/test_read.c deleted file mode 100644 index acaa4895f..000000000 --- a/test/Legacy/test_double/test_read.c +++ /dev/null @@ -1,430 +0,0 @@ -/*********************************************************** - * - * This test program reads a netCDF file, and then write it - * out to another netCDF file, using the parallel netCDF - * library using MPI-IO. The two files should be identical. - * - * Input File: "../data/test_double.nc" generated from original netcdf-3. - * Output File: "testread.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * double square(x, y); - * squre: description = "2-D integer array"; - * - * double cube(x,y,z); - * - * double time(time); // coordinate & record variable - * - * double xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses collective APIs to read/write variable data and - * only deals with integer variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototypes for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - printf("%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j; - int status; - int ncid1, ncid2; - int ndims, nvars, ngatts, unlimdimid; - char name[NC_MAX_NAME]; - nc_type type, *vartypes; - MPI_Offset attlen, dimlen, varsize; - MPI_Offset *shape, *start, *stride; - void *valuep; - int *dimids, *varids, **vardims, *varndims, *varnatts; - int isRecvar; - params opts; - - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing read ... "); - parse_read_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - - /* Read a netCDF file and write it out to another file */ - - /** - * Open the input dataset - ncid1: - * File name: "../data/test_double.nc" - * Dataset API: Collective - * And create the output dataset - ncid2: - * File name: "testread.nc" - * Dataset API: Collective - */ - - status = ncmpi_open(comm, opts.infname, 0, MPI_INFO_NULL, &ncid1); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid2); - if (status != NC_NOERR) handle_error(status); - - - /** - * Inquire the dataset definitions of input dataset AND - * Add dataset definitions for output dataset. - */ - - status = ncmpi_inq(ncid1, &ndims, &nvars, &ngatts, &unlimdimid); - if (status != NC_NOERR) handle_error(status); - - - /* Inquire global attributes, assume CHAR attributes. */ - - for (i = 0; i < ngatts; i++) { - status = ncmpi_inq_attname(ncid1, NC_GLOBAL, i, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, NC_GLOBAL, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, NC_GLOBAL, name, (char*) valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, NC_GLOBAL, name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, NC_GLOBAL, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, NC_GLOBAL, name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, NC_GLOBAL, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, NC_GLOBAL, name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, NC_GLOBAL, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, NC_GLOBAL, name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, NC_GLOBAL, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, NC_GLOBAL, name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* XXX: handle default case */ - } - } - - /* Inquire dimension */ - dimids = (int*) malloc(ndims * sizeof(int)); - - for (i = 0; i < ndims; i++) { - status = ncmpi_inq_dim(ncid1, i, name, &dimlen); - if (status != NC_NOERR) handle_error(status); - if (i == unlimdimid) - dimlen = NC_UNLIMITED; - status = ncmpi_def_dim(ncid2, name, dimlen, dimids+i); - if (status != NC_NOERR) handle_error(status); - } - free(dimids); - - vartypes = (nc_type*) malloc(nvars * sizeof(nc_type)); - varids = (int*) malloc(nvars * sizeof(int)); - varndims = (int*) malloc(nvars * sizeof(int)); - varnatts = (int*) malloc(nvars * sizeof(int)); - vardims = (int**) malloc(nvars * sizeof(int*)); - - /* Inquire variables */ - - for (i = 0; i < nvars; i++) { - status = ncmpi_inq_varndims(ncid1, i, varndims+i); - if (status != NC_NOERR) handle_error(status); - vardims[i] = (int*) malloc(varndims[i] * sizeof(int)); - - status = ncmpi_inq_var (ncid1, i, name, vartypes+i, varndims+i, vardims[i], varnatts+i); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_def_var(ncid2, name, vartypes[i], varndims[i], vardims[i], varids+i); - if (status != NC_NOERR) handle_error(status); - - /* var attributes, assume CHAR attributes */ - - for (j = 0; j < varnatts[i]; j++) { - status = ncmpi_inq_attname(ncid1, i, j, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, i, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, i, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, varids[i], name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, i, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, varids[i], name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, i, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, varids[i], name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, i, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, varids[i], name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, i, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, varids[i], name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* XXX: handle unexpected types */ - } - } - } - - /** - * End Define Mode (switch to data mode) for output dataset - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Read data of variables from input dataset - * (ONLY DEAL WITH: NC_INT, NC_FLOAT, NC_DOUBLE for now) - * Write the data out to the corresponding variables in the output dataset - * - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, *), 25*100 from 100*100 - * cube: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * xytime: 3-D, (Cyclic, *, *), 25*100*100 from 100*100*100 - * time: 1-D, Cyclic, 25 from 100 - * - * Data Mode API: collective - */ - - for (i = 0; i < nvars; i++) { - shape = (MPI_Offset*) malloc(varndims[i] * 3 * sizeof(MPI_Offset)); - start = shape + varndims[i]; - stride = start + varndims[i]; - - isRecvar = 0; - varsize = 1; - for (j = 0; j < varndims[i]; j++) { - status = ncmpi_inq_dim(ncid1, vardims[i][j], name, shape + j); - if (status != NC_NOERR) handle_error(status); - if (j == 0) { - shape[j] /= nprocs; - if (vardims[i][j] == unlimdimid) { - isRecvar = 1; - start[j] = rank; - stride[j] = nprocs; - } else { - start[j] = shape[j] * rank; - } - } else { - stride[j] = 1; - } - varsize *= shape[j]; - } - - if (isRecvar) switch (vartypes[i]) { - - /* strided access for record variable */ - - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vars_short_all(ncid1, i, start, shape, stride, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vars_short_all(ncid2, varids[i], - start, shape, stride, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vars_int_all(ncid1, i, start, shape, stride, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vars_int_all(ncid2, varids[i], - start, shape, stride, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vars_float_all(ncid1, i, start, shape, stride, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vars_float_all(ncid2, varids[i], - start, shape, stride, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(double)); - status = ncmpi_get_vars_double_all(ncid1, i, start, shape, stride, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vars_double_all(ncid2, varids[i], - start, shape, stride, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* XXX: handle unexpected types */ - } - else switch (vartypes[i]) { - - /* subarray access for non-record variable */ - - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vara_short_all(ncid1, i, start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_short_all(ncid2, varids[i], - start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int_all(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vara_float_all(ncid1, i, start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float_all(ncid2, varids[i], - start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(double)); - status = ncmpi_get_vara_double_all(ncid1, i, start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_double_all(ncid2, varids[i], - start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* Handle unexpected types */ - } - free(shape); - free(vardims[i]); - } - - /** - * Close the datasets - * Dataset API: collective - */ - - status = ncmpi_close(ncid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_close(ncid2); - if (status != NC_NOERR) handle_error(status); - - free(vartypes); - free(varids); - free(varndims); - free(varnatts); - free(vardims); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nInput file %s copied to: %s!\n", opts.infname, opts.outfname); - - MPI_Finalize(); - return 0; -} diff --git a/test/Legacy/test_double/test_read_indep.c b/test/Legacy/test_double/test_read_indep.c deleted file mode 100644 index 53630be29..000000000 --- a/test/Legacy/test_double/test_read_indep.c +++ /dev/null @@ -1,438 +0,0 @@ -/*********************************************************** - * - * This test program reads a netCDF file, and then write it - * out to another netCDF file, using the parallel netCDF - * library using MPI-IO. The two files should be identical. - * - * Input File: "../data/test_double.nc" generated from original netcdf-3. - * Output File: "testread.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * double square(x, y); - * squre: description = "2-D integer array"; - * - * double cube(x,y,z); - * - * double time(time); // coordinate & record variable - * - * double xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses non-collective APIs to read/write variable data and - * only deals with double variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototypes for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - printf("%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j; - int status; - int ncid1, ncid2; - int ndims, nvars, ngatts, unlimdimid; - char name[NC_MAX_NAME]; - nc_type type, *vartypes; - MPI_Offset attlen, dimlen, varsize; - MPI_Offset *shape, *start, *stride; - void *valuep; - int *dimids, *varids, **vardims, *varndims, *varnatts; - int isRecvar; - params opts; - - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing independent read ... "); - parse_read_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - - /* Read a netCDF file and write it out to another file */ - - /** - * Open the input dataset - ncid1: - * File name: "../data/test_double.nc" - * Dataset API: Collective - * And create the output dataset - ncid2: - * File name: "testread.nc" - * Dataset API: Collective - */ - - status = ncmpi_open(comm, opts.infname, 0, MPI_INFO_NULL, &ncid1); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid2); - if (status != NC_NOERR) handle_error(status); - - - /** - * Inquire the dataset definitions of input dataset AND - * Add dataset definitions for output dataset. - */ - - status = ncmpi_inq(ncid1, &ndims, &nvars, &ngatts, &unlimdimid); - if (status != NC_NOERR) handle_error(status); - - - /* Inquire global attributes, assume CHAR attributes. */ - - for (i = 0; i < ngatts; i++) { - status = ncmpi_inq_attname(ncid1, NC_GLOBAL, i, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, NC_GLOBAL, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, NC_GLOBAL, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, NC_GLOBAL, name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, NC_GLOBAL, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, NC_GLOBAL, name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, NC_GLOBAL, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, NC_GLOBAL, name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, NC_GLOBAL, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, NC_GLOBAL, name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, NC_GLOBAL, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, NC_GLOBAL, name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected errors */ - } - } - - /* Inquire dimension */ - dimids = (int*) malloc(ndims * sizeof(int)); - - for (i = 0; i < ndims; i++) { - status = ncmpi_inq_dim(ncid1, i, name, &dimlen); - if (status != NC_NOERR) handle_error(status); - if (i == unlimdimid) - dimlen = NC_UNLIMITED; - status = ncmpi_def_dim(ncid2, name, dimlen, dimids+i); - if (status != NC_NOERR) handle_error(status); - } - free(dimids); - - vartypes = (nc_type*) malloc(nvars * sizeof(nc_type)); - varids = (int*) malloc(nvars * sizeof(int)); - varndims = (int*) malloc(nvars * sizeof(int)); - varnatts = (int*) malloc(nvars * sizeof(int)); - vardims = (int**) malloc(nvars * sizeof(int*)); - - /* Inquire variables */ - - for (i = 0; i < nvars; i++) { - status = ncmpi_inq_varndims(ncid1, i, varndims+i); - if (status != NC_NOERR) handle_error(status); - vardims[i] = (int*) malloc(varndims[i] * sizeof(int)); - - status = ncmpi_inq_var (ncid1, i, name, vartypes+i, varndims+i, vardims[i], varnatts+i); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_def_var(ncid2, name, vartypes[i], varndims[i], vardims[i], varids+i); - if (status != NC_NOERR) handle_error(status); - - /* var attributes, assume CHAR attributes */ - - for (j = 0; j < varnatts[i]; j++) { - status = ncmpi_inq_attname(ncid1, i, j, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, i, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, i, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, varids[i], name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, i, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, varids[i], name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, i, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, varids[i], name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, i, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, varids[i], name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, i, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, varids[i], name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected errors */ - } - } - } - - /** - * End Define Mode (switch to data mode) for output dataset - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Read data of variables from input dataset - * (ONLY DEAL WITH: NC_INT, NC_FLOAT, NC_DOUBLE for now) - * Write the data out to the corresponding variables in the output dataset - * - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, *), 25*100 from 100*100 - * cube: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * xytime: 3-D, (Cyclic, *, *), 25*100*100 from 100*100*100 - * time: 1-D, Cyclic, 25 from 100 - * - * Data Mode API: non-collective - */ - - status = ncmpi_begin_indep_data(ncid1); - if (status != NC_NOERR) handle_error(status); - status =ncmpi_begin_indep_data(ncid2); - if (status != NC_NOERR) handle_error(status); - - for (i = 0; i < nvars; i++) { - shape = (MPI_Offset*) malloc(varndims[i] * 3 * sizeof(MPI_Offset)); - start = shape + varndims[i]; - stride = start + varndims[i]; - isRecvar = 0; - varsize = 1; - for (j = 0; j < varndims[i]; j++) { - status = ncmpi_inq_dim(ncid1, vardims[i][j], name, shape + j); - if (status != NC_NOERR) handle_error(status); - if (j == 0) { - shape[j] /= nprocs; - if (vardims[i][j] == unlimdimid) { - isRecvar = 1; - start[j] = rank; - stride[j] = nprocs; - } else { - start[j] = shape[j] * rank; - } - } else { - stride[j] = 1; - } - varsize *= shape[j]; - } - if (isRecvar) switch (vartypes[i]) { - - /* strided access for record variables */ - - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vars_short(ncid1, i, start, shape, stride, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vars_short(ncid2, varids[i], - start, shape, stride, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vars_int(ncid1, i, start, shape, stride, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vars_int(ncid2, varids[i], - start, shape, stride, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vars_float(ncid1, i, start, shape, stride, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vars_float(ncid2, varids[i], - start, shape, stride, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(double)); - status = ncmpi_get_vars_double(ncid1, i, start, shape, stride, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vars_double(ncid2, varids[i], - start, shape, stride, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected errors */ - } - else switch (vartypes[i]) { - - /* subarray access for non-record variable */ - - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vara_short(ncid1, i, start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_short(ncid2, varids[i], - start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vara_float(ncid1, i, start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float(ncid2, varids[i], - start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(double)); - status = ncmpi_get_vara_double(ncid1, i, start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_double(ncid2, varids[i], - start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected errors */ - } - free(shape); - free(vardims[i]); - } - - status = ncmpi_end_indep_data(ncid1); - if (status != NC_NOERR) handle_error(status); - status =ncmpi_end_indep_data(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Close the datasets - * Dataset API: collective - */ - - status = ncmpi_close(ncid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_close(ncid2); - if (status != NC_NOERR) handle_error(status); - - free(vartypes); - free(varids); - free(varndims); - free(varnatts); - free(vardims); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nInput file %s copied to: %s!\n", opts.infname, opts.outfname); - - MPI_Finalize(); - return 0; -} diff --git a/test/Legacy/test_double/test_write.c b/test/Legacy/test_double/test_write.c deleted file mode 100644 index 800c9e006..000000000 --- a/test/Legacy/test_double/test_write.c +++ /dev/null @@ -1,220 +0,0 @@ -/*********************************************************** - * - * This test program writes a netCDF file using the parallel - * netCDF library using MPI-IO. - * - * The output file is: "testwrite.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * double square(x, y); - * squre: description = "2-D integer array"; - * - * double cube(x,y,z); - * - * double time(time); // coordinate & record variable - * - * double xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses collective APIs to write variable data and only - * deals with double variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - - - -#include -#include -#include -#include -#include "testutils.h" - -#define ERR {if(err!=NC_NOERR){printf("Error at line=%d: %s\n", __LINE__, ncmpi_strerror(err)); nerrs++;}} - -int main(int argc, char **argv) { - - int i, j, k, err, ncid, nerrs=0; - int dimid1, dimid2, dimid3, udimid; - int square_dim[2], cube_dim[3], xytime_dim[3], time_dim[1]; - MPI_Offset square_start[2], cube_start[3] = {0, 0, 0}; - MPI_Offset square_count[2] = {50, 50}, cube_count[3] = {100, 50, 50}; - MPI_Offset square_stride[2] = {2, 2}; - MPI_Offset xytime_start[3] = {0, 0, 0}; - MPI_Offset xytime_count[3] = {100, 50, 50}; - MPI_Offset time_start[1], time_count[1] = {25}; - int square_id, cube_id, xytime_id, time_id; - static char title[] = "example netCDF dataset"; - static char description[] = "2-D integer array"; - double data[100][50][50], buffer[100]; - double stride_2d_data[50][50]; - int rank, nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - params opts; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) fprintf(stderr, "Testing write ... "); - parse_write_args(argc, argv, rank, &opts); - - /** - * Create the dataset - * File name: "testwrite.nc" - * Dataset API: Collective - */ - err = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid); ERR - - - /** - * Create a global attribute: - * :title = "example netCDF dataset"; - */ - err = ncmpi_put_att_text (ncid, NC_GLOBAL, "title", strlen(title), title); ERR - - /** - * Add 4 pre-defined dimensions: - * x = 100, y = 100, z = 100, time = NC_UNLIMITED - */ - err = ncmpi_def_dim(ncid, "x", 100, &dimid1); ERR - err = ncmpi_def_dim(ncid, "y", 100, &dimid2); ERR - err = ncmpi_def_dim(ncid, "z", 100, &dimid3); ERR - err = ncmpi_def_dim(ncid, "time", NC_UNLIMITED, &udimid); ERR - - /** - * Define the dimensionality and then add 4 variables: - * square(x, y), cube(x,y,z), time(time), xytime(time, x, y) - */ - square_dim[0] = cube_dim[0] = xytime_dim[1] = dimid1; - square_dim[1] = cube_dim[1] = xytime_dim[2] = dimid2; - cube_dim[2] = dimid3; - xytime_dim[0] = udimid; - time_dim[0] = udimid; - err = ncmpi_def_var(ncid, "square", NC_DOUBLE, 2, square_dim, &square_id); ERR - err = ncmpi_def_var(ncid, "cube", NC_DOUBLE, 3, cube_dim, &cube_id); ERR - err = ncmpi_def_var(ncid, "time", NC_DOUBLE, 1, time_dim, &time_id); ERR - err = ncmpi_def_var(ncid, "xytime", NC_DOUBLE, 3, xytime_dim, &xytime_id); ERR - - /** - * Add an attribute for variable: - * square: decsription = "2-D integer array" - */ - err = ncmpi_put_att_text(ncid, square_id, "description", strlen(description), description); ERR - - - /** - * End Define Mode (switch to data mode) - * Dataset API: Collective - */ - err = ncmpi_enddef(ncid); ERR - - /** - * Data Partition (Assume 4 processors): - * square: 2-D, (Cyclic, Cyclic), 50*50 from 100*100, strided access - * cube: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * xytime: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - */ - - /* square_start[0] = */ - cube_start[1] = xytime_start[1] = (rank/2) * 50; - /* square_start[1] = */ - cube_start[2] = xytime_start[2] = (rank%2) * 50; - time_start[0] = (rank%4) * 25; - square_start[0] = rank/2; - square_start[1] = rank%2; - - /** - * Packing data in the buffer - */ - - /* Data for variable: time */ - for ( i = time_start[0]; i < time_start[0] + time_count[0]; i++ ) - buffer[i - time_start[0]] = i; - - /* Data for variable: cube and xytime */ - for ( i = 0; i < 100; i++ ) - for ( j = cube_start[1]; j < cube_start[1]+cube_count[1]; j++ ) - for ( k = cube_start[2]; k < cube_start[2]+cube_count[2]; k++ ) - data[i][j-cube_start[1]][k-cube_start[2]] = i*100*100 + j*100 + k; - - /* Data for variable: square */ - for ( i = 0; i < 50; i ++ ) - for ( j = 0; j < 50; j++ ) - stride_2d_data[i][j] = (2*i + rank/2)*100 + (2*j + rank%2); - - /* this program is designed for running less than 4 processes */ - if (rank >= 4) { - square_start[0] = square_start[1] = 0; - square_count[0] = square_count[1] = 0; - square_stride[0] = square_stride[1] = 1; - cube_start[0] = cube_start[1] = cube_start[2] = 0; - cube_count[0] = cube_count[1] = cube_count[2] = 0; - xytime_start[0] = xytime_start[1] = xytime_start[2] = 0; - xytime_count[0] = xytime_count[1] = xytime_count[2] = 0; - time_start[0] = 0; - time_count[0] = 0; - } - /** - * Write data into variables: square, cube, time and xytime - * Access Method: subarray - * Data Mode API: collective - */ - err = ncmpi_put_vars_double_all(ncid, square_id, - square_start, square_count, square_stride, - &stride_2d_data[0][0]); - ERR - err = ncmpi_put_vara_double_all(ncid, cube_id, - cube_start, cube_count, - &data[0][0][0]); - ERR - err = ncmpi_put_vara_double_all(ncid, time_id, - time_start, time_count, - (double *)buffer); - ERR - err = ncmpi_put_vara_double_all(ncid, xytime_id, - xytime_start, xytime_count, - &data[0][0][0]); - ERR - - /** - * Close the dataset - * Dataset API: collective - */ - err = ncmpi_close(ncid); ERR - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nFile written to: %s!\n", opts.outfname); - - MPI_Finalize(); - return 0; -} - diff --git a/test/Legacy/test_double/test_write_indep.c b/test/Legacy/test_double/test_write_indep.c deleted file mode 100644 index 8b5b46ed0..000000000 --- a/test/Legacy/test_double/test_write_indep.c +++ /dev/null @@ -1,304 +0,0 @@ -/*********************************************************** - * - * This test program writes a netCDF file using the parallel - * netCDF library using MPI-IO. - * - * The output file is: "testwrite.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * double square(x, y); - * squre: description = "2-D integer array"; - * - * double cube(x,y,z); - * - * double time(time); // coordinate & record variable - * - * double xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses non-collective APIs to write variable data and only - * deals with double variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - - - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - fprintf(stderr, "%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j, k; - int status; - int ncid; - int dimid1, dimid2, dimid3, udimid; - int square_dim[2], cube_dim[3], xytime_dim[3], time_dim[1]; - MPI_Offset square_start[2], cube_start[3] = {0, 0, 0}; - MPI_Offset square_count[2] = {50, 50}, cube_count[3] = {100, 50, 50}; - MPI_Offset xytime_start[3] = {0, 0, 0}; - MPI_Offset xytime_count[3] = {100, 50, 50}; - MPI_Offset time_start[1], time_count[1] = {25}; - int square_id, cube_id, xytime_id, time_id; - static char title[] = "example netCDF dataset"; - static char description[] = "2-D integer array"; - double data[100][50][50], buffer[100]; - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info; - params opts; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing independent write ... "); - parse_write_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "4"); - MPI_Info_set(info, "striping_unit", "20000"); - MPI_Info_set(info, "start_iodevice", "0"); - - /** - * Create the dataset - * File name: "testwrite.nc" - * Dataset API: Collective - */ - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, info, &ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Create a global attribute: - * :title = "example netCDF dataset"; - */ - - status = ncmpi_put_att_text (ncid, NC_GLOBAL, "title", - strlen(title), title); - if (status != NC_NOERR) handle_error(status); - - /** - * Add 4 pre-defined dimensions: - * x = 100, y = 100, z = 100, time = NC_UNLIMITED - */ - - status = ncmpi_def_dim(ncid, "x", 100L, &dimid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "y", 100L, &dimid2); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "z", 100L, &dimid3); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "time", NC_UNLIMITED, &udimid); - if (status != NC_NOERR) handle_error(status); - - /** - * Define the dimensionality and then add 4 variables: - * square(x, y), cube(x,y,z), time(time), xytime(time, x, y) - */ - - square_dim[0] = cube_dim[0] = xytime_dim[1] = dimid1; - square_dim[1] = cube_dim[1] = xytime_dim[2] = dimid2; - cube_dim[2] = dimid3; - xytime_dim[0] = udimid; - time_dim[0] = udimid; - status = ncmpi_def_var (ncid, "square", NC_DOUBLE, 2, square_dim, &square_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "cube", NC_DOUBLE, 3, cube_dim, &cube_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "time", NC_DOUBLE, 1, time_dim, &time_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "xytime", NC_DOUBLE, 3, xytime_dim, &xytime_id); - if (status != NC_NOERR) handle_error(status); - - /** - * Add an attribute for variable: - * square: decsription = "2-D integer array" - */ - - status = ncmpi_put_att_text (ncid, square_id, "description", - strlen(description), description); - if (status != NC_NOERR) handle_error(status); - - - /** - * End Define Mode (switch to data mode) - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, Block), 50*50 from 100*100 - * cube: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * xytime: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - */ - - square_start[0] = cube_start[1] = xytime_start[1] = (rank/2) * 50; - square_start[1] = cube_start[2] = xytime_start[2] = (rank%2) * 50; - time_start[0] = (rank%4) * 25; - - - /** - * Packing data in the buffer - */ - - /* Data for variable: time */ - for ( i = time_start[0]; i < time_start[0] + time_count[0]; i++ ) - buffer[i - time_start[0]] = i; - - /* Data for variable: square, cube and xytime */ - for ( i = 0; i < 100; i++ ) - for ( j = square_start[0]; j < square_start[0]+square_count[0]; j++ ) - for ( k = square_start[1]; k < square_start[1]+square_count[1]; k++ ) - data[i][j-square_start[0]][k-square_start[1]] = i*100*100 + j*100 + k; - - /** - * Write data into variables: square, cube, time and xytime - * Access Method: subarray - * Data Mode API: non-collective - */ - - status = ncmpi_begin_indep_data(ncid); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_put_vara_double(ncid, square_id, - square_start, square_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_double(ncid, cube_id, - cube_start, cube_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_double(ncid, time_id, - time_start, time_count, - (double *)buffer); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_double(ncid, xytime_id, - xytime_start, xytime_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - -{ - /** - * Change a single element and then change it back - * Access Method: single value - * Data Mode API: non-collective - */ - - double singlevalue = 0; - - ncmpi_sync(ncid); - - status = ncmpi_put_var1_double(ncid, square_id, - square_start, &singlevalue); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_put_var1_double(ncid, time_id, - time_start, &singlevalue); - if (status != NC_NOERR) handle_error(status); - - ncmpi_sync(ncid); - - singlevalue = square_start[0]*100 + square_start[1]; - status = ncmpi_put_var1_double(ncid, square_id, - square_start, &singlevalue); - if (status != NC_NOERR) handle_error(status); - - singlevalue = time_start[0]; - status = ncmpi_put_var1_double(ncid, time_id, - time_start, &singlevalue); - if (status != NC_NOERR) handle_error(status); -} - -{ - /** - * Change the whole array for time[] and then change it back - * Access Method: whole array - * Data Mode API: non-collective - */ - - ncmpi_sync(ncid); - - for (i = 0; i < 100; i++ ) - buffer[i] = 0; - - if (rank == 0) { - status = ncmpi_put_var_double(ncid, time_id, buffer); - if (status != NC_NOERR) handle_error(status); - } - - ncmpi_sync(ncid); - - for (i=0; i<100; i++) - buffer[i] = i; - - if (rank == 1) { - status = ncmpi_put_var_double(ncid, time_id, buffer); - if (status != NC_NOERR) handle_error(status); - } -} - - status = ncmpi_end_indep_data(ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Close the dataset - * Dataset API: collective - */ - - status = ncmpi_close(ncid); - if (status != NC_NOERR) handle_error(status); - - MPI_Info_free(&info); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nFile written to: %s!\n", opts.outfname); - - MPI_Finalize(); - return 0; -} diff --git a/test/Legacy/test_double_int/Makefile.am b/test/Legacy/test_double_int/Makefile.am deleted file mode 100644 index e57ea9745..000000000 --- a/test/Legacy/test_double_int/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -# -# Copyright (C) 2003, Northwestern University and Argonne National Laboratory -# See COPYRIGHT notice in top-level directory. -# -# $Id$ -# -# @configure_input@ - -SUFFIXES = .o .c - -AM_DEFAULT_SOURCE_EXT = .c - -AM_CPPFLAGS = -I$(srcdir)/../common -I$(top_builddir)/src/include -LDADD = $(top_builddir)/src/libs/libpnetcdf.la ../common/libtestutils.la - -if DECL_MPI_OFFSET - AM_CPPFLAGS += -DHAVE_DECL_MPI_OFFSET -endif - -TESTPROGRAMS = test_read \ - test_read_indep \ - test_write \ - test_write_indep - -check_PROGRAMS = $(TESTPROGRAMS) - -# autimake 1.11.3 has not yet implemented AM_TESTS_ENVIRONMENT -# For newer versions, we can use AM_TESTS_ENVIRONMENT instead -# AM_TESTS_ENVIRONMENT = TESTPROGRAMS="$(TESTPROGRAMS)" ; export TESTPROGRAMS; -# AM_TESTS_ENVIRONMENT += TESTSEQRUN="$(TESTSEQRUN)" ; export TESTSEQRUN; -# AM_TESTS_ENVIRONMENT += TESTOUTDIR="$(TESTOUTDIR)" ; export TESTOUTDIR; -TESTS_ENVIRONMENT = TESTPROGRAMS="$(TESTPROGRAMS)" ; export TESTPROGRAMS; -TESTS_ENVIRONMENT += TESTSEQRUN="$(TESTSEQRUN)" ; export TESTSEQRUN; -TESTS_ENVIRONMENT += TESTOUTDIR="$(TESTOUTDIR)" ; export TESTOUTDIR; - -# TESTS = seq_runs.sh -# EXTRA_DIST = seq_runs.sh -EXTRA_DIST = README - -CLEANFILES = *.nc core core.* *.gcda *.gcno *.gcov gmon.out - -../common/libtestutils.la: - set -e; cd ../common && $(MAKE) $(MFLAGS) tests - -TESTMPIRUN4 = `echo $(TESTMPIRUN) | $(SED) -e 's/NP/4/g'` - -ptest ptests ptest4: $(TESTPROGRAMS) - set -e ; for i in $(TESTPROGRAMS); do ( \ - $(TESTMPIRUN4) ./$$i $(TESTOUTDIR)/testfile.nc ; \ - ) ; done - -ptest2 ptest6 ptest8 ptest10: - -# build check targets but not invoke -tests-local: all $(check_PROGRAMS) - -.PHONY: ptest ptests ptest2 ptest4 ptest6 ptest8 ptest10 - diff --git a/test/Legacy/test_double_int/README b/test/Legacy/test_double_int/README deleted file mode 100644 index f2c1638fe..000000000 --- a/test/Legacy/test_double_int/README +++ /dev/null @@ -1,3 +0,0 @@ -These examples test data transfers of: - - "file NC_DOUBLE var" <---> "memory int" diff --git a/test/Legacy/test_double_int/test_read.c b/test/Legacy/test_double_int/test_read.c deleted file mode 100644 index 8f97ecf8c..000000000 --- a/test/Legacy/test_double_int/test_read.c +++ /dev/null @@ -1,368 +0,0 @@ -/*********************************************************** - * - * This test program reads a netCDF file, and then write it - * out to another netCDF file, using the parallel netCDF - * library using MPI-IO. The two files should be identical. - * - * Input File: "../data/test_double.nc" generated from original netcdf-3. - * Output File: "testread.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * double square(x, y); - * squre: description = "2-D integer array"; - * - * double cube(x,y,z); - * - * double time(time); // coordinate & record variable - * - * double xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses collective APIs to read/write variable data and - * only deals with integer variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - printf("%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j; - int status; - int ncid1, ncid2; - int ndims, nvars, ngatts, unlimdimid; - char name[NC_MAX_NAME]; - nc_type type, *vartypes; - MPI_Offset attlen, dimlen, varsize; - MPI_Offset *shape, *start; - void *valuep; - int *dimids, *varids, **vardims, *varndims, *varnatts; - params opts; - - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing read ... "); - parse_read_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - - /* Read a netCDF file and write it out to another file */ - - /** - * Open the input dataset - ncid1: - * File name: "../data/test_double.nc" - * Dataset API: Collective - * And create the output dataset - ncid2: - * File name: "testread.nc" - * Dataset API: Collective - */ - - status = ncmpi_open(comm, opts.infname, 0, MPI_INFO_NULL, &ncid1); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid2); - if (status != NC_NOERR) handle_error(status); - - - /** - * Inquire the dataset definitions of input dataset AND - * Add dataset definitions for output dataset. - */ - - status = ncmpi_inq(ncid1, &ndims, &nvars, &ngatts, &unlimdimid); - if (status != NC_NOERR) handle_error(status); - - - /* Inquire global attributes, assume CHAR attributes. */ - - for (i = 0; i < ngatts; i++) { - status = ncmpi_inq_attname(ncid1, NC_GLOBAL, i, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, NC_GLOBAL, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, NC_GLOBAL, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, NC_GLOBAL, name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, NC_GLOBAL, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, NC_GLOBAL, name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, NC_GLOBAL, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, NC_GLOBAL, name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, NC_GLOBAL, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, NC_GLOBAL, name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, NC_GLOBAL, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, NC_GLOBAL, name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - } - - /* Inquire dimension */ - dimids = (int*) malloc(ndims * sizeof(int)); - - for (i = 0; i < ndims; i++) { - status = ncmpi_inq_dim(ncid1, i, name, &dimlen); - if (status != NC_NOERR) handle_error(status); - if (i == unlimdimid) - dimlen = NC_UNLIMITED; - status = ncmpi_def_dim(ncid2, name, dimlen, dimids+i); - if (status != NC_NOERR) handle_error(status); - } - free(dimids); - - vartypes = (nc_type*) malloc(nvars * sizeof(nc_type)); - varids = (int*) malloc(nvars * sizeof(int)); - varndims = (int*) malloc(nvars * sizeof(int)); - varnatts = (int*) malloc(nvars * sizeof(int)); - vardims = (int**) malloc(nvars * sizeof(int*)); - - /* Inquire variables */ - - for (i = 0; i < nvars; i++) { - status = ncmpi_inq_varndims(ncid1, i, varndims+i); - if (status != NC_NOERR) handle_error(status); - vardims[i] = (int*) malloc(varndims[i] * sizeof(int)); - - status = ncmpi_inq_var (ncid1, i, name, vartypes+i, varndims+i, vardims[i], varnatts+i); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_def_var(ncid2, name, vartypes[i], varndims[i], vardims[i], varids+i); - if (status != NC_NOERR) handle_error(status); - - /* var attributes, assume CHAR attributes */ - - for (j = 0; j < varnatts[i]; j++) { - status = ncmpi_inq_attname(ncid1, i, j, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, i, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, i, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, varids[i], name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, i, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, varids[i], name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, i, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, varids[i], name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, i, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, varids[i], name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, i, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, varids[i], name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - } - } - - /** - * End Define Mode (switch to data mode) for output dataset - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Read data of variables from input dataset - * (ONLY DEAL WITH: NC_INT, NC_FLOAT, NC_DOUBLE for now) - * Write the data out to the corresponding variables in the output dataset - * - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, *), 25*100 from 100*100 - * cube: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * xytime: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - * - * Data Mode API: collective - */ - - for (i = 0; i < nvars; i++) { - shape = (MPI_Offset*) malloc(varndims[i] * 2 * sizeof(MPI_Offset)); - start = shape + varndims[i]; - - varsize = 1; - for (j = 0; j < varndims[i]; j++) { - status = ncmpi_inq_dim(ncid1, vardims[i][j], name, shape + j); - if (status != NC_NOERR) handle_error(status); - if (j == 0) { - shape[j] /= nprocs; - start[j] = shape[j] * rank; - } - varsize *= shape[j]; - } - switch (vartypes[i]) { - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vara_short_all(ncid1, i, start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_short_all(ncid2, varids[i], - start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int_all(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vara_float_all(ncid1, i, start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float_all(ncid2, varids[i], - start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int_all(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - free(shape); - free(vardims[i]); - } - - /** - * Close the datasets - * Dataset API: collective - */ - - status = ncmpi_close(ncid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_close(ncid2); - if (status != NC_NOERR) handle_error(status); - - free(vartypes); - free(varids); - free(varndims); - free(varnatts); - free(vardims); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nInput file %s copied to: %s!\n", opts.infname, opts.outfname); - - MPI_Finalize(); - return 0; -} diff --git a/test/Legacy/test_double_int/test_read_indep.c b/test/Legacy/test_double_int/test_read_indep.c deleted file mode 100644 index 77ade3ffd..000000000 --- a/test/Legacy/test_double_int/test_read_indep.c +++ /dev/null @@ -1,381 +0,0 @@ -/*********************************************************** - * - * This test program reads a netCDF file, and then write it - * out to another netCDF file, using the parallel netCDF - * library using MPI-IO. The two files should be identical. - * - * Input File: "../data/test_double.nc" generated from original netcdf-3. - * Output File: "testread.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * double square(x, y); - * squre: description = "2-D integer array"; - * - * double cube(x,y,z); - * - * double time(time); // coordinate & record variable - * - * double xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses non-collective APIs to read/write variable data and - * only deals with integer variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - printf("%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j; - int status; - int ncid1, ncid2; - int ndims, nvars, ngatts, unlimdimid; - char name[NC_MAX_NAME]; - nc_type type, *vartypes; - MPI_Offset attlen, dimlen, varsize; - MPI_Offset *shape, *start; - void *valuep; - int *dimids, *varids, **vardims, *varndims, *varnatts; - params opts; - - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing read ... "); - parse_read_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - - /* Read a netCDF file and write it out to another file */ - - /** - * Open the input dataset - ncid1: - * File name: "../data/test_double.nc" - * Dataset API: Collective - * And create the output dataset - ncid2: - * File name: "testread.nc" - * Dataset API: Collective - */ - - status = ncmpi_open(comm, opts.infname, 0, MPI_INFO_NULL, &ncid1); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid2); - if (status != NC_NOERR) handle_error(status); - - - /** - * Inquire the dataset definitions of input dataset AND - * Add dataset definitions for output dataset. - */ - - status = ncmpi_inq(ncid1, &ndims, &nvars, &ngatts, &unlimdimid); - if (status != NC_NOERR) handle_error(status); - - - /* Inquire global attributes, assume CHAR attributes. */ - - for (i = 0; i < ngatts; i++) { - status = ncmpi_inq_attname(ncid1, NC_GLOBAL, i, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, NC_GLOBAL, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, NC_GLOBAL, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, NC_GLOBAL, name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, NC_GLOBAL, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, NC_GLOBAL, name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, NC_GLOBAL, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, NC_GLOBAL, name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, NC_GLOBAL, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, NC_GLOBAL, name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, NC_GLOBAL, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, NC_GLOBAL, name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - - } - } - - /* Inquire dimension */ - dimids = (int*) malloc(ndims * sizeof(int)); - - for (i = 0; i < ndims; i++) { - status = ncmpi_inq_dim(ncid1, i, name, &dimlen); - if (status != NC_NOERR) handle_error(status); - if (i == unlimdimid) - dimlen = NC_UNLIMITED; - status = ncmpi_def_dim(ncid2, name, dimlen, dimids+i); - if (status != NC_NOERR) handle_error(status); - } - free(dimids); - - vartypes = (nc_type*) malloc(nvars * sizeof(nc_type)); - varids = (int*) malloc(nvars * sizeof(int)); - varndims = (int*) malloc(nvars * sizeof(int)); - varnatts = (int*) malloc(nvars * sizeof(int)); - vardims = (int**) malloc(nvars * sizeof(int*)); - - /* Inquire variables */ - - for (i = 0; i < nvars; i++) { - status = ncmpi_inq_varndims(ncid1, i, varndims+i); - if (status != NC_NOERR) handle_error(status); - vardims[i] = (int*) malloc(varndims[i] * sizeof(int)); - - status = ncmpi_inq_var (ncid1, i, name, vartypes+i, varndims+i, vardims[i], varnatts+i); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_def_var(ncid2, name, vartypes[i], varndims[i], vardims[i], varids+i); - if (status != NC_NOERR) handle_error(status); - - /* var attributes, assume CHAR attributes */ - - for (j = 0; j < varnatts[i]; j++) { - status = ncmpi_inq_attname(ncid1, i, j, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, i, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, i, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, varids[i], name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, i, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, varids[i], name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, i, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, varids[i], name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, i, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, varids[i], name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, i, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, varids[i], name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - } - } - - /** - * End Define Mode (switch to data mode) for output dataset - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Read data of variables from input dataset - * (ONLY DEAL WITH: NC_INT, NC_FLOAT, NC_DOUBLE for now) - * Write the data out to the corresponding variables in the output dataset - * - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, *), 25*100 from 100*100 - * cube: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * xytime: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - * - * Data Mode API: non-collective - */ - - status = ncmpi_begin_indep_data(ncid1); - if (status != NC_NOERR) handle_error(status); - status =ncmpi_begin_indep_data(ncid2); - if (status != NC_NOERR) handle_error(status); - - for (i = 0; i < nvars; i++) { - shape = (MPI_Offset*) malloc(varndims[i] * 3 * sizeof(MPI_Offset)); - start = shape + varndims[i]; - stride = start + varndims[i]; - - varsize = 1; - for (j = 0; j < varndims[i]; j++) { - status = ncmpi_inq_dim(ncid1, vardims[i][j], name, shape + j); - if (status != NC_NOERR) handle_error(status); - if (j == 0) { - shape[j] /= nprocs; - start[j] = shape[j] * rank; - } - varsize *= shape[j]; - } - switch (vartypes[i]) { - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vara_short(ncid1, i, start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_short(ncid2, varids[i], - start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vara_float(ncid1, i, start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float(ncid2, varids[i], - start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - free(shape); - free(vardims[i]); - } - - status = ncmpi_end_indep_data(ncid1); - if (status != NC_NOERR) handle_error(status); - status =ncmpi_end_indep_data(ncid2); - if (status != NC_NOERR) handle_error(status); - - free(vartypes); - free(varids); - free(varndims); - free(varnatts); - free(vardims); - - /** - * Close the datasets - * Dataset API: collective - */ - - status = ncmpi_close(ncid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_close(ncid2); - if (status != NC_NOERR) handle_error(status); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nInput file %s copied to: %s!\n", opts.infname, opts.outfname); - - MPI_Finalize(); - return 0; -} diff --git a/test/Legacy/test_double_int/test_write.c b/test/Legacy/test_double_int/test_write.c deleted file mode 100644 index ecd45477f..000000000 --- a/test/Legacy/test_double_int/test_write.c +++ /dev/null @@ -1,232 +0,0 @@ -/*********************************************************** - * - * This test program writes a netCDF file using the parallel - * netCDF library using MPI-IO. - * - * The output file is: "testwrite.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * double square(x, y); - * squre: description = "2-D integer array"; - * - * double cube(x,y,z); - * - * double time(time); // coordinate & record variable - * - * double xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses collective APIs to write variable data and only - * deals with double variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - - - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - fprintf(stderr, "%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j, k; - int status; - int ncid; - int dimid1, dimid2, dimid3, udimid; - int square_dim[2], cube_dim[3], xytime_dim[3], time_dim[1]; - MPI_Offset square_start[2], cube_start[3] = {0, 0, 0}; - MPI_Offset square_count[2] = {50, 50}, cube_count[3] = {100, 50, 50}; - MPI_Offset xytime_start[3] = {0, 0, 0}; - MPI_Offset xytime_count[3] = {100, 50, 50}; - MPI_Offset time_start[1], time_count[1] = {25}; - int square_id, cube_id, xytime_id, time_id; - static char title[] = "example netCDF dataset"; - static char description[] = "2-D integer array"; - int data[100][50][50], buffer[100]; - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - params opts; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing write ... "); - parse_write_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - /** - * Create the dataset - * File name: "testwrite.nc" - * Dataset API: Collective - */ - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid); - if (status != NC_NOERR) handle_error(status); - - - /** - * Create a global attribute: - * :title = "example netCDF dataset"; - */ - - status = ncmpi_put_att_text (ncid, NC_GLOBAL, "title", - strlen(title), title); - if (status != NC_NOERR) handle_error(status); - - /** - * Add 4 pre-defined dimensions: - * x = 100, y = 100, z = 100, time = NC_UNLIMITED - */ - - status = ncmpi_def_dim(ncid, "x", 100L, &dimid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "y", 100L, &dimid2); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "z", 100L, &dimid3); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "time", NC_UNLIMITED, &udimid); - if (status != NC_NOERR) handle_error(status); - - /** - * Define the dimensionality and then add 4 variables: - * square(x, y), cube(x,y,z), time(time), xytime(time, x, y) - */ - - square_dim[0] = cube_dim[0] = xytime_dim[1] = dimid1; - square_dim[1] = cube_dim[1] = xytime_dim[2] = dimid2; - cube_dim[2] = dimid3; - xytime_dim[0] = udimid; - time_dim[0] = udimid; - status = ncmpi_def_var (ncid, "square", NC_DOUBLE, 2, square_dim, &square_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "cube", NC_DOUBLE, 3, cube_dim, &cube_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "time", NC_DOUBLE, 1, time_dim, &time_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "xytime", NC_DOUBLE, 3, xytime_dim, &xytime_id); - if (status != NC_NOERR) handle_error(status); - - /** - * Add an attribute for variable: - * square: decsription = "2-D integer array" - */ - - status = ncmpi_put_att_text (ncid, square_id, "description", - strlen(description), description); - if (status != NC_NOERR) handle_error(status); - - - /** - * End Define Mode (switch to data mode) - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, Block), 50*50 from 100*100 - * cube: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * xytime: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - */ - - square_start[0] = cube_start[1] = xytime_start[1] = (rank/2) * 50; - square_start[1] = cube_start[2] = xytime_start[2] = (rank%2) * 50; - time_start[0] = (rank%4) * 25; - - - /** - * Packing data in the buffer - */ - - /* Data for variable: time */ - for ( i = time_start[0]; i < time_start[0] + time_count[0]; i++ ) - buffer[i - time_start[0]] = i; - - /* Data for variable: square, cube and xytime */ - for ( i = 0; i < 100; i++ ) - for ( j = square_start[0]; j < square_start[0]+square_count[0]; j++ ) - for ( k = square_start[1]; k < square_start[1]+square_count[1]; k++ ) - data[i][j-square_start[0]][k-square_start[1]] = i*100*100 + j*100 + k; - - /** - * Write data into variables: square, cube, time and xytime - * Access Method: subarray - * Data Mode API: collective - */ - - status = ncmpi_put_vara_int_all(ncid, square_id, - square_start, square_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid, cube_id, - cube_start, cube_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid, time_id, - time_start, time_count, - buffer); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid, xytime_id, - xytime_start, xytime_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - - /** - * Close the dataset - * Dataset API: collective - */ - - status = ncmpi_close(ncid); - if (status != NC_NOERR) handle_error(status); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nFile written to: %s!\n", opts.outfname); - - MPI_Finalize(); - return 0; -} - diff --git a/test/Legacy/test_double_int/test_write_indep.c b/test/Legacy/test_double_int/test_write_indep.c deleted file mode 100644 index 2147f707e..000000000 --- a/test/Legacy/test_double_int/test_write_indep.c +++ /dev/null @@ -1,238 +0,0 @@ -/*********************************************************** - * - * This test program writes a netCDF file using the parallel - * netCDF library using MPI-IO. - * - * The output file is: "testwrite.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * double square(x, y); - * squre: description = "2-D integer array"; - * - * double cube(x,y,z); - * - * double time(time); // coordinate & record variable - * - * double xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses non-collective APIs to write variable data and only - * deals with double variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - - - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - fprintf(stderr, "%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j, k; - int status; - int ncid; - int dimid1, dimid2, dimid3, udimid; - int square_dim[2], cube_dim[3], xytime_dim[3], time_dim[1]; - MPI_Offset square_start[2], cube_start[3] = {0, 0, 0}; - MPI_Offset square_count[2] = {50, 50}, cube_count[3] = {100, 50, 50}; - MPI_Offset xytime_start[3] = {0, 0, 0}; - MPI_Offset xytime_count[3] = {100, 50, 50}; - MPI_Offset time_start[1], time_count[1] = {25}; - int square_id, cube_id, xytime_id, time_id; - static char title[] = "example netCDF dataset"; - static char description[] = "2-D integer array"; - int data[100][50][50], buffer[100]; - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - params opts; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing write ... "); - parse_write_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - /** - * Create the dataset - * File name: "testwrite.nc" - * Dataset API: Collective - */ - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid); - if (status != NC_NOERR) handle_error(status); - - - /** - * Create a global attribute: - * :title = "example netCDF dataset"; - */ - - status = ncmpi_put_att_text (ncid, NC_GLOBAL, "title", - strlen(title), title); - if (status != NC_NOERR) handle_error(status); - - /** - * Add 4 pre-defined dimensions: - * x = 100, y = 100, z = 100, time = NC_UNLIMITED - */ - - status = ncmpi_def_dim(ncid, "x", 100L, &dimid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "y", 100L, &dimid2); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "z", 100L, &dimid3); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "time", NC_UNLIMITED, &udimid); - if (status != NC_NOERR) handle_error(status); - - /** - * Define the dimensionality and then add 4 variables: - * square(x, y), cube(x,y,z), time(time), xytime(time, x, y) - */ - - square_dim[0] = cube_dim[0] = xytime_dim[1] = dimid1; - square_dim[1] = cube_dim[1] = xytime_dim[2] = dimid2; - cube_dim[2] = dimid3; - xytime_dim[0] = udimid; - time_dim[0] = udimid; - status = ncmpi_def_var (ncid, "square", NC_DOUBLE, 2, square_dim, &square_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "cube", NC_DOUBLE, 3, cube_dim, &cube_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "time", NC_DOUBLE, 1, time_dim, &time_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "xytime", NC_DOUBLE, 3, xytime_dim, &xytime_id); - if (status != NC_NOERR) handle_error(status); - - /** - * Add an attribute for variable: - * square: decsription = "2-D integer array" - */ - - status = ncmpi_put_att_text (ncid, square_id, "description", - strlen(description), description); - if (status != NC_NOERR) handle_error(status); - - - /** - * End Define Mode (switch to data mode) - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, Block), 50*50 from 100*100 - * cube: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * xytime: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - */ - - square_start[0] = cube_start[1] = xytime_start[1] = (rank/2) * 50; - square_start[1] = cube_start[2] = xytime_start[2] = (rank%2) * 50; - time_start[0] = (rank%4) * 25; - - - /** - * Packing data in the buffer - */ - - /* Data for variable: time */ - for ( i = time_start[0]; i < time_start[0] + time_count[0]; i++ ) - buffer[i - time_start[0]] = i; - - /* Data for variable: square, cube and xytime */ - for ( i = 0; i < 100; i++ ) - for ( j = square_start[0]; j < square_start[0]+square_count[0]; j++ ) - for ( k = square_start[1]; k < square_start[1]+square_count[1]; k++ ) - data[i][j-square_start[0]][k-square_start[1]] = i*100*100 + j*100 + k; - - /** - * Write data into variables: square, cube, time and xytime - * Access Method: subarray - * Data Mode API: non-collective - */ - - status = ncmpi_begin_indep_data(ncid); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_put_vara_int(ncid, square_id, - square_start, square_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid, cube_id, - cube_start, cube_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid, time_id, - time_start, time_count, - buffer); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid, xytime_id, - xytime_start, xytime_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_end_indep_data(ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Close the dataset - * Dataset API: collective - */ - - status = ncmpi_close(ncid); - if (status != NC_NOERR) handle_error(status); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nFile written to: %s!\n", opts.outfname); - - MPI_Finalize(); - return 0; -} - diff --git a/test/Legacy/test_dtype/Makefile.am b/test/Legacy/test_dtype/Makefile.am deleted file mode 100644 index dd003d992..000000000 --- a/test/Legacy/test_dtype/Makefile.am +++ /dev/null @@ -1,55 +0,0 @@ -# -# Copyright (C) 2003, Northwestern University and Argonne National Laboratory -# See COPYRIGHT notice in top-level directory. -# -# $Id$ -# -# @configure_input@ - -srcdir = @srcdir@ -VPATH = @srcdir@ - -include ../../macros.make - -INCLUDES = -I../../src/lib -I$(srcdir)/../common -LDFLAGS := $(LDFLAGS) -L../common -LIBS := $(LIBRARY) -ltestutils $(LIBS) - -SRCS = test_subarray.c \ - test_darray.c \ - test_nonblocking.c - -HEADERS = test_dtype.h - -OBJS = $(SRCS:.c=.o) -PROGS = $(SRCS:.c=) - -GARBAGE = $(PROGS) -PACKING_LIST = $(SRCS) $(HEADERS) Makefile.in README - -all: $(PROGS) - -$(OBJS): $(srcdir)/../common/testutils.h - -$(PROGS): ../common/libtestutils.a - -../common/libtestutils.a: - set -e; cd ../common && $(MAKE) $(MFLAGS) all - -test_subarray: test_subarray.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -test_darray: test_darray.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -test_nonblocking: test_nonblocking.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -testing check verbose_testing: - -ptest ptests ptest2 ptest4 ptest6 ptest8 ptest10: - -include $(srcdir)/../../rules.make - -$(LIBRARY): ; - diff --git a/test/Legacy/test_dtype/README b/test/Legacy/test_dtype/README deleted file mode 100644 index 3664b8c21..000000000 --- a/test/Legacy/test_dtype/README +++ /dev/null @@ -1,19 +0,0 @@ -These examples test reading into or writing from noncontiguous memory data -specified by MPI derived datatypes and/or array index mapping. - -test_subarray: - .Test for subarray memory layout - .Test for collective subarray netcdf access - .Test for whole array netcdf access - .Test for mapped subarray netcdf access - -test_darray: - .Test for darray memory layout - .Test for collective strided subarray netcdf access - -TEST CONFIGURATIONS: - .the tests will run with defaults automatically. - .edit "test_dtype.h" as described inside. - .run test with option [-h] or [-help] to get command-line argument help. - .for more test flexibility, please program the src code by - following the testing logic indicated in the src comments. diff --git a/test/Legacy/test_dtype/test_darray.c b/test/Legacy/test_dtype/test_darray.c deleted file mode 100644 index af414ed3a..000000000 --- a/test/Legacy/test_dtype/test_darray.c +++ /dev/null @@ -1,442 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "test_dtype.h" - -/* Configurable test parameters: edit it as you wish */ -#define TEST_DEFAULT_FILE "test_darray.nc" /* file to be written/read */ -#define TEST_DIMS 3 /* number of dimensions */ -#define TEST_N 64 /* size for the shortest dimension of the array */ -#define TEST_M 0.9 /* size of each dimension is increasingly multiplied by M */ -#define TEST_ARRAY_ORDER MPI_ORDER_C - -int ndims = TEST_DIMS; -char *filename = TEST_DEFAULT_FILE; -int test_n = TEST_N; -double test_m = TEST_M; -int order = TEST_ARRAY_ORDER; - -static -void parse_args(int argc, char **argv, int rank) { - extern char * optarg; - int c; - - if (argc == 1) - return; - - while ((c=getopt(argc,argv,"h:f:d:n:m:o:"))!=-1) { - switch(c) { - case 'f': - filename = optarg; - break; - - case 'd': - ndims = (int)strtol(optarg,NULL,10); - break; - - case 'n': - test_n = (int)strtol(optarg,NULL,10); - break; - - case 'm': - test_m = atof(optarg); - break; - - case 'o': - if ( !strncmp(optarg, "MPI_ORDER_C", 11) || !strcmp(optarg, "0") ) - order = MPI_ORDER_C; - else if ( !strncmp(optarg, "MPI_ORDER_FORTRAN", 17) || - !strcmp(optarg, "1") ) - order = MPI_ORDER_FORTRAN; - else { - if (rank == 0) { - fprintf(stderr, - "Invalid order_of_array specified in command line args! \n"); - fprintf(stderr, - "[-o ] 0/1: MPI_ORDER_C/MPI_ORDER_FORTRAN\n"); - } - TEST_EXIT(-1); - } - break; - - case 'h': - default: - if (rank == 0) { - /* print help */ - printf("Usage: %s [options]\n", argv[0]); - printf("or %s [options]\n", argv[0]); - printf(" [-h] [-f ] [-d ]\n"); - printf(" [-n ] [-m ]\n"); - printf(" [-o ]\n\n"); - printf("\t[-h] print this help.\n"); - printf("\t[-f] filename to be used.\n"); - printf("\t NOTE: This test will create/overwrite the file!\n"); - printf("\t[-d] ndims of array to be tested. (int)\n"); - printf("\t[-n] size of the first array dimension. (int)\n"); - printf("\t[-m] multiplier for the size of each later dimension\n"); - printf("\t over the size of previous dimension. (int/float)\n"); - printf("\t[-o] memory layout order of the array\n"); - printf("\t 0/1 for MPI_ORDER_C/MPI_ORDER_FORTRAN.\n\n"); - } - - TEST_EXIT( c != 'h' ); - } - } - - return; -} - -static -void partition_array( /* input parameters : */ - int nprocs, int myrank, int ndims, int *array_of_sizes, - /* output parameters : */ - int *array_of_distribs, int *array_of_dargs, - MPI_Offset *local_starts, - MPI_Offset *local_edges, - MPI_Offset *local_strides, - int *array_of_psizes) -{ - int i; - int pcoord; - - for (i=0; i=0; i--) { - /* compute the netCDF strided-subarray access parameters */ - pcoord = myrank % array_of_psizes[i]; - myrank /= array_of_psizes[i]; - local_starts[i] = (MPI_Offset)( (pcoord>=array_of_sizes[i])?0:pcoord ); - local_edges[i] = (MPI_Offset)( array_of_sizes[i]/array_of_psizes[i] ); - if ( local_edges[i]*array_of_psizes[i]+pcoord < array_of_sizes[i] ) - local_edges[i]++; - local_strides[i] = (MPI_Offset)array_of_psizes[i]; - } - - return; -} - -int main(int argc, char** argv) { - - int i; - double power_M; - int *array_of_sizes; - int *array_of_distribs, *array_of_dargs; - int *array_of_psizes; - int ncid, *dimids, varid_1; - MPI_Offset *local_starts, *local_edges, *local_strides; - char dimname[20]; - nc_type nc_etype; - MPI_Datatype mpi_etype, mpi_darray; - TEST_NATIVE_ETYPE *buf1, *buf2, *tmpbuf; - void *packbuf; - int packsz; - int packpos; - int total_sz, local_sz; - int nprocs, rank; - int status; - int success, successall; - int malloc_failure, malloc_failure_any; - int pass1 = 0, pass2 = 0; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - /* test initializations: nc_file, nc_variables, dimensions, arrays */ - - parse_args(argc, argv, rank); - TEST_SET_NCMPI_ETYPE(nc_etype, mpi_etype); -#ifdef TEST_NCTYPE - nc_etype = TEST_NCTYPE; -#endif - if (rank == 0) { - printf("testing memory darray layout ...\n"); - } - - status = ncmpi_create(MPI_COMM_WORLD, filename, NC_CLOBBER, - MPI_INFO_NULL, &ncid); - TEST_HANDLE_ERR(status); - - array_of_sizes = (int *) - malloc(sizeof(int)*ndims*5 + sizeof(MPI_Offset)*ndims*3); - array_of_distribs = array_of_sizes + ndims; - array_of_dargs = array_of_distribs + ndims; - array_of_psizes = array_of_dargs + ndims; - dimids = array_of_psizes + ndims; - local_starts = (MPI_Offset *)(dimids + ndims); - local_edges = local_starts + ndims; - local_strides = local_edges + ndims; - - total_sz = 1; - power_M = 1; - for (i=0; i (double)TEST_MAX_INT ){ - /* upper bound check */ - if (rank == 0) { - fprintf(stderr, "Total size of array is too big to be represented\n"); - fprintf(stderr, "Current size = %f, Max size = %d\n", - (double)total_sz*array_of_sizes[i], TEST_MAX_INT); - } - TEST_EXIT(-1); - } - total_sz *= array_of_sizes[i]; - sprintf(dimname, "dim_%d", i); - status = ncmpi_def_dim(ncid, dimname, - (MPI_Offset)array_of_sizes[i], dimids+i); - TEST_HANDLE_ERR(status); - } - - if (order == MPI_ORDER_FORTRAN) { - /* reverse the filearray dimension, since NC always use C ORDER */ - TEST_REVERSE(dimids, ndims, int); - } - - status = ncmpi_def_var(ncid, "var_1", nc_etype, ndims, dimids, &varid_1); - TEST_HANDLE_ERR(status); - - status = ncmpi_enddef(ncid); - TEST_HANDLE_ERR(status); - - if (rank == 0) { - printf("\t Filesize = %2.3fMB, MAX_Memory_needed = %2.3fMB\n\n", - 1*total_sz*TEST_NCTYPE_LEN(nc_etype)/1024.0/1024.0, - ( (2*total_sz + 4*total_sz/nprocs)*sizeof(TEST_NATIVE_ETYPE) - + total_sz*TEST_NCTYPE_LEN(nc_etype) )/1024.0/1024.0 ); - } - - buf1 = (TEST_NATIVE_ETYPE *)malloc(total_sz*sizeof(TEST_NATIVE_ETYPE)*2); - malloc_failure = (buf1 == NULL || - (float)total_sz*sizeof(TEST_NATIVE_ETYPE)*2 > TEST_MAX_INT); - MPI_Allreduce(&malloc_failure, &malloc_failure_any, 1, MPI_INT, - MPI_LOR, MPI_COMM_WORLD); - if (malloc_failure_any) { - if (rank == 0) { - fprintf(stderr, "malloc(%2.3fMB) failed!\n", - (float)total_sz*sizeof(TEST_NATIVE_ETYPE)*2/1024/1024); - fprintf(stderr, "The whole array may be too big for malloc to handle!\n"); fprintf(stderr, "Please choose smaller array size.\n"); - } - TEST_EXIT(-1); - } - - buf2 = buf1 + total_sz; - for (i=0; i -#ifdef INT_MAX -#define TEST_MAX_INT INT_MAX -#else -#define TEST_MAX_INT ( ~((int)(1) << (8*sizeof(int)-1)) ) -#endif - -#define TEST_SET_NCMPI_ETYPE(nc_etype, mpi_etype) \ -{ \ - switch( (int)TEST_TYPE_INDEX ) { \ - case 0: \ - nc_etype = NC_BYTE; \ - mpi_etype = MPI_UNSIGNED_CHAR; \ - break; \ - case 1: \ - nc_etype = NC_BYTE; \ - mpi_etype = MPI_SIGNED_CHAR; \ - break; \ - case 2: \ - nc_etype = NC_CHAR; \ - mpi_etype = MPI_CHAR; \ - break; \ - case 3: \ - nc_etype = NC_SHORT; \ - mpi_etype = MPI_SHORT; \ - break; \ - case 4: \ - nc_etype = NC_INT; \ - mpi_etype = MPI_INT; \ - break; \ - case 5: \ - nc_etype = NC_INT; \ - mpi_etype = MPI_LONG; \ - break; \ - case 6: \ - nc_etype = NC_FLOAT; \ - mpi_etype = MPI_FLOAT; \ - break; \ - case 7: \ - nc_etype = NC_DOUBLE; \ - mpi_etype = MPI_DOUBLE; \ - break; \ - } \ -} - -#define TEST_GET_NCTYPE_STR(nc_etype) \ -( \ - (nc_etype == NC_CHAR)?"NC_CHAR":( \ - (nc_etype == NC_BYTE)?"NC_BYTE":( \ - (nc_etype == NC_SHORT)?"NC_SHORT":( \ - (nc_etype == NC_INT)?"NC_INT":( \ - (nc_etype == NC_FLOAT)?"NC_FLOAT":( \ - (nc_etype == NC_DOUBLE)?"NC_DOUBLE":"INVALID_TYPE"))))) \ -) - -#define TEST_NCTYPE_LEN(nc_etype) \ -( \ - (nc_etype == NC_CHAR || nc_etype == NC_BYTE) ? 1 : ( \ - (nc_etype == NC_SHORT) ? 2 : ( \ - (nc_etype == NC_INT || nc_etype == NC_FLOAT) ? 4 : ( \ - (nc_etype == NC_DOUBLE) ? 8 : 0 ))) \ -) - -#define TEST_HANDLE_ERR(status) \ -{ \ - if ((status) != NC_NOERR) \ - printf( "%s\n", ncmpi_strerror((status)) ); \ -} - -#define TEST_REVERSE(array, nelems, type) \ -{ \ - int i; \ - type tmp; \ - for (i=0; i<(nelems)/2; i++) { \ - tmp = (array)[i]; \ - (array)[i] = (array)[(nelems)-1-i]; \ - (array)[(nelems)-1-i] = tmp; \ - } \ -} - -#define TEST_PRINT_LIST(list, start, end, step) \ -{ \ - int i; \ - for ( i=(start); (i-(start))*(i-(end))<=0; i+=(step) ) { \ - if ( i==(start) ) \ - printf("%2d", (int)(list)[i]); \ - else \ - printf(", %2d", (int)(list)[i]); \ - } \ -} - -#define TEST_EXIT(err_code) \ -{ \ - MPI_Finalize(); \ - exit((err_code)); \ -} - -#endif diff --git a/test/Legacy/test_dtype/test_nonblocking.c b/test/Legacy/test_dtype/test_nonblocking.c deleted file mode 100644 index a91f882a7..000000000 --- a/test/Legacy/test_dtype/test_nonblocking.c +++ /dev/null @@ -1,455 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "test_dtype.h" - -/* Configurable test parameters: edit it as you wish */ -#define TEST_DEFAULT_FILE "test_subarray.nc" /* file to be written/read */ -#define TEST_DIMS 3 /* number of dimensions */ -#define TEST_N 17 /* size for the shortest dimension of the array */ -#define TEST_M 3 /* size of each dimension is increasingly multiplied by M */ -#define TEST_ARRAY_ORDER MPI_ORDER_C - -int ndims = TEST_DIMS; -char *filename = TEST_DEFAULT_FILE; -int test_n = TEST_N; -double test_m = TEST_M; -int order = TEST_ARRAY_ORDER; - -static -void parse_args(int argc, char **argv, int rank) { - extern char * optarg; - int c; - - if (argc == 1) - return; - - while ((c=getopt(argc,argv,"h:f:d:n:m:o:"))!=-1) { - switch(c) { - case 'f': - filename = optarg; - break; - - case 'd': - ndims = (int)strtol(optarg,NULL,10); - break; - - case 'n': - test_n = (int)strtol(optarg,NULL,10); - break; - - case 'm': - test_m = atof(optarg); - break; - - case 'o': - if ( !strncmp(optarg, "MPI_ORDER_C", 11) || !strcmp(optarg, "0") ) - order = MPI_ORDER_C; - else if ( !strncmp(optarg, "MPI_ORDER_FORTRAN", 17) || - !strcmp(optarg, "1") ) - order = MPI_ORDER_FORTRAN; - else { - if (rank == 0) { - fprintf(stderr, - "Invalid order_of_array specified in command line args! \n"); - fprintf(stderr, - "[-o ] 0/1: MPI_ORDER_C/MPI_ORDER_FORTRAN\n"); - } - TEST_EXIT(-1); - } - break; - - case 'h': - default: - if (rank == 0) { - /* print help */ - printf("Usage: %s [options]\n", argv[0]); - printf("or %s [options]\n", argv[0]); - printf(" [-h] [-f ] [-d ]\n"); - printf(" [-n ] [-m ]\n"); - printf(" [-o ]\n\n"); - printf("\t[-help] print this help.\n"); - printf("\t[-f] filename to be used.\n"); - printf("\t NOTE: This test will create/overwrite the file!\n"); - printf("\t[-d] ndims of array to be tested. (int)\n"); - printf("\t[-n] size of the first array dimension. (int)\n"); - printf("\t[-m] multiplier for the size of each later dimension\n"); - printf("\t over the size of previous dimension. (int/float)\n"); - printf("\t[-o] memory layout order of the array\n"); - printf("\t 0/1 for MPI_ORDER_C/MPI_ORDER_FORTRAN.\n\n"); - } - - TEST_EXIT( c != 'h' ); - } - } - - return; -} - -static -void partition_array(int ndims, - int *total_sizes, - int *local_subsizes, - int *local_starts, - int nprocs, - int myrank) -{ - int k; - int odd; - - for (k=0; k 1) { - - /* cut this dimension into two halves: - - [0 : ceiling{nprocs/2}) get first half - - [ceiling{nprocs/2} : nprocs) get second half - */ - - odd = local_subsizes[k] % 2; - local_subsizes[k] /= 2; - if (myrank >= (nprocs+1)/2) { - local_starts[k] += local_subsizes[k]; - local_subsizes[k] += odd; - myrank -= (nprocs+1)/2; /* rank_in_myhalfgroup */ - nprocs /= 2; /* nprocs_in_myhalfgroup */ - } else { - nprocs = (nprocs+1)/2; /* nprocs_in_myhalfgroup */ - } - - /* move to the next dimension */ - if (--k < 0) - k = ndims-1; - } - -} - -int main(int argc, char** argv) { - - int i; - double power_M; - int *array_of_sizes, *array_of_subsizes, *array_of_starts; - int ncid, *dimids, varid_1, varid_2; - MPI_Offset *local_starts, *local_edges; - char dimname[20]; - nc_type nc_etype; - MPI_Datatype mpi_etype, mpi_subarray; - TEST_NATIVE_ETYPE *buf1, *buf2, *tmpbuf; - void *packbuf; - int packsz; - int packpos; - int total_sz, local_sz; - int nprocs, rank; - int status; - int success, successall; - int malloc_failure, malloc_failure_any; - int request; - - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - /* test initializations: nc_file, nc_variables, dimensions, arrays */ - - parse_args(argc, argv, rank); - TEST_SET_NCMPI_ETYPE(nc_etype, mpi_etype); -#ifdef TEST_NCTYPE - nc_etype = TEST_NCTYPE; -#endif - if (rank == 0) { - printf("testing memory subarray layout ...\n"); - } - - status = ncmpi_create(MPI_COMM_WORLD, filename, NC_CLOBBER, - MPI_INFO_NULL, &ncid); - TEST_HANDLE_ERR(status); - - array_of_sizes = (int *) - malloc(sizeof(int)*ndims*4 + sizeof(MPI_Offset)*ndims*4); - array_of_subsizes = array_of_sizes + ndims; - array_of_starts = array_of_subsizes + ndims; - dimids = array_of_starts + ndims; - local_starts = (MPI_Offset *)(dimids + ndims); - local_edges = local_starts + ndims; - - total_sz = 1; - power_M = 1; - for (i=0; i (double)TEST_MAX_INT ){ - /* upper bound check */ - if (rank == 0) { - fprintf(stderr, "Total size of array is too big to be represented\n"); - fprintf(stderr, "Current size = %f, Max size = %d\n", - (double)total_sz*array_of_sizes[i], TEST_MAX_INT); - } - TEST_EXIT(-1); - } - total_sz *= array_of_sizes[i]; - sprintf(dimname, "dim_%d", i); - status = ncmpi_def_dim(ncid, dimname, - (MPI_Offset)array_of_sizes[i], dimids+i); - TEST_HANDLE_ERR(status); - } - - if (order == MPI_ORDER_FORTRAN) { - /* reverse the filearray dimension, since NC always use C ORDER */ - TEST_REVERSE(dimids, ndims, int); - } - - status = ncmpi_def_var(ncid, "var_1", nc_etype, ndims, dimids, &varid_1); - TEST_HANDLE_ERR(status); - - TEST_REVERSE(dimids, ndims, int); - status = ncmpi_def_var(ncid, "var_2", nc_etype, ndims, dimids, &varid_2); - TEST_HANDLE_ERR(status); - - status = ncmpi_enddef(ncid); - TEST_HANDLE_ERR(status); - - if (rank == 0) { - printf("\t Filesize = %2.3fMB, MAX_Memory_needed = %2.3fMB\n\n", - 2*total_sz*TEST_NCTYPE_LEN(nc_etype)/1024.0/1024.0, - ( (2*total_sz + 4*total_sz/nprocs)*sizeof(TEST_NATIVE_ETYPE) - + total_sz*TEST_NCTYPE_LEN(nc_etype) )/1024.0/1024.0); - } - - buf1 = (TEST_NATIVE_ETYPE *)malloc(total_sz*sizeof(TEST_NATIVE_ETYPE)*2); - malloc_failure = (buf1 == NULL || - (float)total_sz*sizeof(TEST_NATIVE_ETYPE)*2 > TEST_MAX_INT); - MPI_Allreduce(&malloc_failure, &malloc_failure_any, 1, MPI_INT, - MPI_LOR, MPI_COMM_WORLD); - if (malloc_failure_any) { - if (rank == 0) { - fprintf(stderr, "malloc(%2.3fMB) failed!\n", - (float)total_sz*sizeof(TEST_NATIVE_ETYPE)*2/1024/1024); - fprintf(stderr, "The whole array may be too big for malloc to handle!\n"); - fprintf(stderr, "Please choose smaller array size.\n"); - } - TEST_EXIT(-1); - } - - buf2 = buf1 + total_sz; - for (i=0; i -#include -#include -#include -#include -#include - -#include "test_dtype.h" - -/* Configurable test parameters: edit it as you wish */ -#define TEST_DEFAULT_FILE "test_subarray.nc" /* file to be written/read */ -#define TEST_DIMS 3 /* number of dimensions */ -#define TEST_N 17 /* size for the shortest dimension of the array */ -#define TEST_M 3 /* size of each dimension is increasingly multiplied by M */ -#define TEST_ARRAY_ORDER MPI_ORDER_C - -int ndims = TEST_DIMS; -char *filename = TEST_DEFAULT_FILE; -int test_n = TEST_N; -double test_m = TEST_M; -int order = TEST_ARRAY_ORDER; - -static -void parse_args(int argc, char **argv, int rank) { - extern char * optarg; - int c; - - if (argc == 1) - return; - - while ((c=getopt(argc,argv,"h:f:d:n:m:o:"))!=-1) { - switch(c) { - case 'f': - filename = optarg; - break; - - case 'd': - ndims = (int)strtol(optarg,NULL,10); - break; - - case 'n': - test_n = (int)strtol(optarg,NULL,10); - break; - - case 'm': - test_m = atof(optarg); - break; - - case 'o': - if ( !strncmp(optarg, "MPI_ORDER_C", 11) || !strcmp(optarg, "0") ) - order = MPI_ORDER_C; - else if ( !strncmp(optarg, "MPI_ORDER_FORTRAN", 17) || - !strcmp(optarg, "1") ) - order = MPI_ORDER_FORTRAN; - else { - if (rank == 0) { - fprintf(stderr, - "Invalid order_of_array specified in command line args! \n"); - fprintf(stderr, - "[-o ] 0/1: MPI_ORDER_C/MPI_ORDER_FORTRAN\n"); - } - TEST_EXIT(-1); - } - break; - - case 'h': - default: - if (rank == 0) { - /* print help */ - printf("Usage: %s [options]\n", argv[0]); - printf("or %s [options]\n", argv[0]); - printf(" [-h] [-f ] [-d ]\n"); - printf(" [-n ] [-m ]\n"); - printf(" [-o ]\n\n"); - printf("\t[-help] print this help.\n"); - printf("\t[-f] filename to be used.\n"); - printf("\t NOTE: This test will create/overwrite the file!\n"); - printf("\t[-d] ndims of array to be tested. (int)\n"); - printf("\t[-n] size of the first array dimension. (int)\n"); - printf("\t[-m] multiplier for the size of each later dimension\n"); - printf("\t over the size of previous dimension. (int/float)\n"); - printf("\t[-o] memory layout order of the array\n"); - printf("\t 0/1 for MPI_ORDER_C/MPI_ORDER_FORTRAN.\n\n"); - } - - TEST_EXIT( c != 'h' ); - } - } - - return; -} - -static -void partition_array(int ndims, - int *total_sizes, - int *local_subsizes, - int *local_starts, - int nprocs, - int myrank) -{ - int k; - int odd; - - for (k=0; k 1) { - - /* cut this dimension into two halves: - - [0 : ceiling{nprocs/2}) get first half - - [ceiling{nprocs/2} : nprocs) get second half - */ - - odd = local_subsizes[k] % 2; - local_subsizes[k] /= 2; - if (myrank >= (nprocs+1)/2) { - local_starts[k] += local_subsizes[k]; - local_subsizes[k] += odd; - myrank -= (nprocs+1)/2; /* rank_in_myhalfgroup */ - nprocs /= 2; /* nprocs_in_myhalfgroup */ - } else { - nprocs = (nprocs+1)/2; /* nprocs_in_myhalfgroup */ - } - - /* move to the next dimension */ - if (--k < 0) - k = ndims-1; - } - -} - -int main(int argc, char** argv) { - - int i; - double power_M; - int *array_of_sizes, *array_of_subsizes, *array_of_starts; - int ncid, *dimids, varid_1, varid_2; - MPI_Offset *local_starts, *local_edges, *stride, *imap; - char dimname[20]; - nc_type nc_etype; - MPI_Datatype mpi_etype, mpi_subarray; - TEST_NATIVE_ETYPE *buf1, *buf2, *tmpbuf; - void *packbuf; - int packsz; - int packpos; - int total_sz, local_sz; - int nprocs, rank; - int status; - int success, successall; - int malloc_failure, malloc_failure_any; - int pass1 = 0, pass2 = 0, pass3 = 0; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - /* test initializations: nc_file, nc_variables, dimensions, arrays */ - - parse_args(argc, argv, rank); - TEST_SET_NCMPI_ETYPE(nc_etype, mpi_etype); -#ifdef TEST_NCTYPE - nc_etype = TEST_NCTYPE; -#endif - if (rank == 0) { - printf("testing memory subarray layout ...\n"); - } - - status = ncmpi_create(MPI_COMM_WORLD, filename, NC_CLOBBER, - MPI_INFO_NULL, &ncid); - TEST_HANDLE_ERR(status); - - array_of_sizes = (int *) - malloc(sizeof(int)*ndims*4 + sizeof(MPI_Offset)*ndims*4); - array_of_subsizes = array_of_sizes + ndims; - array_of_starts = array_of_subsizes + ndims; - dimids = array_of_starts + ndims; - local_starts = (MPI_Offset *)(dimids + ndims); - local_edges = local_starts + ndims; - stride = local_edges + ndims; - imap = stride + ndims; - - total_sz = 1; - power_M = 1; - for (i=0; i (double)TEST_MAX_INT ){ - /* upper bound check */ - if (rank == 0) { - fprintf(stderr, "Total size of array is too big to be represented\n"); - fprintf(stderr, "Current size = %f, Max size = %d\n", - (double)total_sz*array_of_sizes[i], TEST_MAX_INT); - } - TEST_EXIT(-1); - } - total_sz *= array_of_sizes[i]; - sprintf(dimname, "dim_%d", i); - status = ncmpi_def_dim(ncid, dimname, - (MPI_Offset)array_of_sizes[i], dimids+i); - TEST_HANDLE_ERR(status); - } - - if (order == MPI_ORDER_FORTRAN) { - /* reverse the filearray dimension, since NC always use C ORDER */ - TEST_REVERSE(dimids, ndims, int); - } - - status = ncmpi_def_var(ncid, "var_1", nc_etype, ndims, dimids, &varid_1); - TEST_HANDLE_ERR(status); - - TEST_REVERSE(dimids, ndims, int); - status = ncmpi_def_var(ncid, "var_2", nc_etype, ndims, dimids, &varid_2); - TEST_HANDLE_ERR(status); - - status = ncmpi_enddef(ncid); - TEST_HANDLE_ERR(status); - - if (rank == 0) { - printf("\t Filesize = %2.3fMB, MAX_Memory_needed = %2.3fMB\n\n", - 2*total_sz*TEST_NCTYPE_LEN(nc_etype)/1024.0/1024.0, - ( (2*total_sz + 4*total_sz/nprocs)*sizeof(TEST_NATIVE_ETYPE) - + total_sz*TEST_NCTYPE_LEN(nc_etype) )/1024.0/1024.0); - } - - buf1 = (TEST_NATIVE_ETYPE *)malloc(total_sz*sizeof(TEST_NATIVE_ETYPE)*2); - malloc_failure = (buf1 == NULL || - (float)total_sz*sizeof(TEST_NATIVE_ETYPE)*2 > TEST_MAX_INT); - MPI_Allreduce(&malloc_failure, &malloc_failure_any, 1, MPI_INT, - MPI_LOR, MPI_COMM_WORLD); - if (malloc_failure_any) { - if (rank == 0) { - fprintf(stderr, "malloc(%2.3fMB) failed!\n", - (float)total_sz*sizeof(TEST_NATIVE_ETYPE)*2/1024/1024); - fprintf(stderr, "The whole array may be too big for malloc to handle!\n"); fprintf(stderr, "Please choose smaller array size.\n"); - } - TEST_EXIT(-1); - } - - buf2 = buf1 + total_sz; - for (i=0; i "memory float" diff --git a/test/Legacy/test_float/test_read.c b/test/Legacy/test_float/test_read.c deleted file mode 100644 index 1af778c82..000000000 --- a/test/Legacy/test_float/test_read.c +++ /dev/null @@ -1,368 +0,0 @@ -/*********************************************************** - * - * This test program reads a netCDF file, and then write it - * out to another netCDF file, using the parallel netCDF - * library using MPI-IO. The two files should be identical. - * - * Input File: "../data/test_float.nc" generated from original netcdf-3. - * Output File: "testread.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * float square(x, y); - * squre: description = "2-D integer array"; - * - * float cube(x,y,z); - * - * float time(time); // coordinate & record variable - * - * float xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses collective APIs to read/write variable data and - * only deals with float variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - printf("%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j; - int status; - int ncid1, ncid2; - int ndims, nvars, ngatts, unlimdimid; - char name[NC_MAX_NAME]; - nc_type type, *vartypes; - MPI_Offset attlen, dimlen, varsize; - MPI_Offset *shape, *start; - void *valuep; - int *dimids, *varids, **vardims, *varndims, *varnatts; - params opts; - - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing read ... "); - parse_read_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - - /* Read a netCDF file and write it out to another file */ - - /** - * Open the input dataset - ncid1: - * File name: "../data/test_float.nc" - * Dataset API: Collective - * And create the output dataset - ncid2: - * File name: "testread.nc" - * Dataset API: Collective - */ - - status = ncmpi_open(comm, opts.infname, 0, MPI_INFO_NULL, &ncid1); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid2); - if (status != NC_NOERR) handle_error(status); - - - /** - * Inquire the dataset definitions of input dataset AND - * Add dataset definitions for output dataset. - */ - - status = ncmpi_inq(ncid1, &ndims, &nvars, &ngatts, &unlimdimid); - if (status != NC_NOERR) handle_error(status); - - - /* Inquire global attributes, assume CHAR attributes. */ - - for (i = 0; i < ngatts; i++) { - status = ncmpi_inq_attname(ncid1, NC_GLOBAL, i, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, NC_GLOBAL, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, NC_GLOBAL, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, NC_GLOBAL, name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, NC_GLOBAL, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, NC_GLOBAL, name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, NC_GLOBAL, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, NC_GLOBAL, name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, NC_GLOBAL, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, NC_GLOBAL, name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, NC_GLOBAL, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, NC_GLOBAL, name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* TODO: handle unexpected types */ - } - } - - /* Inquire dimension */ - dimids = (int*) malloc(ndims * sizeof(int)); - - for (i = 0; i < ndims; i++) { - status = ncmpi_inq_dim(ncid1, i, name, &dimlen); - if (status != NC_NOERR) handle_error(status); - if (i == unlimdimid) - dimlen = NC_UNLIMITED; - status = ncmpi_def_dim(ncid2, name, dimlen, dimids+i); - if (status != NC_NOERR) handle_error(status); - } - free(dimids); - - vartypes = (nc_type*) malloc(nvars * sizeof(nc_type)); - varids = (int*) malloc(nvars * sizeof(int)); - varndims = (int*) malloc(nvars * sizeof(int)); - varnatts = (int*) malloc(nvars * sizeof(int)); - vardims = (int**) malloc(nvars * sizeof(int*)); - - /* Inquire variables */ - - for (i = 0; i < nvars; i++) { - status = ncmpi_inq_varndims(ncid1, i, varndims+i); - if (status != NC_NOERR) handle_error(status); - vardims[i] = (int*) malloc(varndims[i] * sizeof(int)); - - status = ncmpi_inq_var (ncid1, i, name, vartypes+i, varndims+i, vardims[i], varnatts+i); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_def_var(ncid2, name, vartypes[i], varndims[i], vardims[i], varids+i); - if (status != NC_NOERR) handle_error(status); - - /* var attributes, assume CHAR attributes */ - - for (j = 0; j < varnatts[i]; j++) { - status = ncmpi_inq_attname(ncid1, i, j, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, i, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, i, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, varids[i], name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, i, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, varids[i], name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, i, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, varids[i], name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, i, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, varids[i], name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, i, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, varids[i], name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; /* TODO: handle unexpected types */ - } - } - } - - /** - * End Define Mode (switch to data mode) for output dataset - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Read data of variables from input dataset - * (ONLY DEAL WITH: NC_INT, NC_FLOAT, NC_DOUBLE for now) - * Write the data out to the corresponding variables in the output dataset - * - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, *), 25*100 from 100*100 - * cube: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * xytime: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - * - * Data Mode API: collective - */ - - for (i = 0; i < nvars; i++) { - shape = (MPI_Offset*) calloc(varndims[i] * 2, sizeof(MPI_Offset)); - start = shape + varndims[i]; - - varsize = 1; - for (j = 0; j < varndims[i]; j++) { - status = ncmpi_inq_dim(ncid1, vardims[i][j], name, shape + j); - if (status != NC_NOERR) handle_error(status); - if (j == 0) { - shape[j] /= nprocs; - start[j] = shape[j] * rank; - } - varsize *= shape[j]; - } - switch (vartypes[i]) { - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vara_short_all(ncid1, i, start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_short_all(ncid2, varids[i], - start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int_all(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vara_float_all(ncid1, i, start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float_all(ncid2, varids[i], - start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(double)); - status = ncmpi_get_vara_double_all(ncid1, i, start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_double_all(ncid2, varids[i], - start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; /* TODO: handle unexpected types */ - } - free(shape); - free(vardims[i]); - } - - /** - * Close the datasets - * Dataset API: collective - */ - - status = ncmpi_close(ncid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_close(ncid2); - if (status != NC_NOERR) handle_error(status); - - free(vartypes); - free(varids); - free(varndims); - free(varnatts); - free(vardims); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nInput file %s copied to: %s!\n", opts.infname, opts.outfname); - - MPI_Finalize(); - return 0; -} diff --git a/test/Legacy/test_float/test_read_indep.c b/test/Legacy/test_float/test_read_indep.c deleted file mode 100644 index b6b57b37b..000000000 --- a/test/Legacy/test_float/test_read_indep.c +++ /dev/null @@ -1,377 +0,0 @@ -/*********************************************************** - * - * This test program reads a netCDF file, and then write it - * out to another netCDF file, using the parallel netCDF - * library using MPI-IO. The two files should be identical. - * - * Input File: "../data/test_float.nc" generated from original netcdf-3. - * Output File: "testread.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * float square(x, y); - * squre: description = "2-D integer array"; - * - * float cube(x,y,z); - * - * float time(time); // coordinate & record variable - * - * float xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses non-collective APIs to read/write variable data and - * only deals with integer variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - printf("%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j; - int status; - int ncid1, ncid2; - int ndims, nvars, ngatts, unlimdimid; - char name[NC_MAX_NAME]; - nc_type type, *vartypes; - MPI_Offset attlen, dimlen, varsize; - MPI_Offset *shape, *start; - void *valuep; - int *dimids, *varids, **vardims, *varndims, *varnatts; - params opts; - - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing independent read ... "); - parse_read_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - - /* Read a netCDF file and write it out to another file */ - - /** - * Open the input dataset - ncid1: - * File name: "../data/test_float.nc" - * Dataset API: Collective - * And create the output dataset - ncid2: - * File name: "testread.nc" - * Dataset API: Collective - */ - - status = ncmpi_open(comm, opts.infname, 0, MPI_INFO_NULL, &ncid1); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid2); - if (status != NC_NOERR) handle_error(status); - - - /** - * Inquire the dataset definitions of input dataset AND - * Add dataset definitions for output dataset. - */ - - status = ncmpi_inq(ncid1, &ndims, &nvars, &ngatts, &unlimdimid); - if (status != NC_NOERR) handle_error(status); - - - /* Inquire global attributes, assume CHAR attributes. */ - - for (i = 0; i < ngatts; i++) { - status = ncmpi_inq_attname(ncid1, NC_GLOBAL, i, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, NC_GLOBAL, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, NC_GLOBAL, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, NC_GLOBAL, name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, NC_GLOBAL, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, NC_GLOBAL, name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, NC_GLOBAL, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, NC_GLOBAL, name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, NC_GLOBAL, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, NC_GLOBAL, name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, NC_GLOBAL, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, NC_GLOBAL, name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; /* TODO: handle unexpected types */ - } - } - - /* Inquire dimension */ - dimids = (int*) malloc(ndims * sizeof(int)); - - for (i = 0; i < ndims; i++) { - status = ncmpi_inq_dim(ncid1, i, name, &dimlen); - if (status != NC_NOERR) handle_error(status); - if (i == unlimdimid) - dimlen = NC_UNLIMITED; - status = ncmpi_def_dim(ncid2, name, dimlen, dimids+i); - if (status != NC_NOERR) handle_error(status); - } - free(dimids); - - vartypes = (nc_type*) malloc(nvars * sizeof(nc_type)); - varids = (int*) malloc(nvars * sizeof(int)); - varndims = (int*) malloc(nvars * sizeof(int)); - varnatts = (int*) malloc(nvars * sizeof(int)); - vardims = (int**) malloc(nvars * sizeof(int*)); - - /* Inquire variables */ - - for (i = 0; i < nvars; i++) { - status = ncmpi_inq_varndims(ncid1, i, varndims+i); - if (status != NC_NOERR) handle_error(status); - vardims[i] = (int*) malloc(varndims[i] * sizeof(int)); - - status = ncmpi_inq_var (ncid1, i, name, vartypes+i, varndims+i, vardims[i], varnatts+i); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_def_var(ncid2, name, vartypes[i], varndims[i], vardims[i], varids+i); - if (status != NC_NOERR) handle_error(status); - - /* var attributes, assume CHAR attributes */ - - for (j = 0; j < varnatts[i]; j++) { - status = ncmpi_inq_attname(ncid1, i, j, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, i, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, i, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, varids[i], name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, i, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, varids[i], name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, i, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, varids[i], name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, i, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, varids[i], name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, i, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, varids[i], name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - } - } - - /** - * End Define Mode (switch to data mode) for output dataset - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Read data of variables from input dataset (assume INT variables) - * Write the data out to the corresponding variables in the output dataset - * - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, *), 25*100 from 100*100 - * cube: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * xytime: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - * - * Data Mode API: non-collective - */ - - status = ncmpi_begin_indep_data(ncid1); - if (status != NC_NOERR) handle_error(status); - status =ncmpi_begin_indep_data(ncid2); - if (status != NC_NOERR) handle_error(status); - - for (i = 0; i < nvars; i++) { - shape = (MPI_Offset*) calloc(varndims[i] * 2, sizeof(MPI_Offset)); - start = shape + varndims[i]; - - varsize = 1; - for (j = 0; j < varndims[i]; j++) { - status = ncmpi_inq_dim(ncid1, vardims[i][j], name, shape + j); - if (status != NC_NOERR) handle_error(status); - if (j == 0) { - shape[j] /= nprocs; - start[j] = shape[j] * rank; - } - varsize *= shape[j]; - } - switch (vartypes[i]) { - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vara_short(ncid1, i, start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_short(ncid2, varids[i], - start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vara_float(ncid1, i, start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float(ncid2, varids[i], - start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(double)); - status = ncmpi_get_vara_double(ncid1, i, start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_double(ncid2, varids[i], - start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - free(shape); - free(vardims[i]); - } - - status = ncmpi_end_indep_data(ncid1); - if (status != NC_NOERR) handle_error(status); - status =ncmpi_end_indep_data(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Close the datasets - * Dataset API: collective - */ - - status = ncmpi_close(ncid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_close(ncid2); - if (status != NC_NOERR) handle_error(status); - - free(vartypes); - free(varids); - free(varndims); - free(varnatts); - free(vardims); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nInput file %s copied to: %s!\n", opts.infname, opts.outfname); - - MPI_Finalize(); - return 0; -} diff --git a/test/Legacy/test_float/test_write.c b/test/Legacy/test_float/test_write.c deleted file mode 100644 index adaacb9a9..000000000 --- a/test/Legacy/test_float/test_write.c +++ /dev/null @@ -1,233 +0,0 @@ -/*********************************************************** - * - * This test program writes a netCDF file using the parallel - * netCDF library using MPI-IO. - * - * The output file is: "testwrite.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * float square(x, y); - * squre: description = "2-D integer array"; - * - * float cube(x,y,z); - * - * float time(time); // coordinate & record variable - * - * float xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses collective APIs to write variable data and only - * deals with float variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - - - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - fprintf(stderr, "%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j, k; - int status; - int ncid; - int dimid1, dimid2, dimid3, udimid; - int square_dim[2], cube_dim[3], xytime_dim[3], time_dim[1]; - MPI_Offset square_start[2], cube_start[3] = {0, 0, 0}; - MPI_Offset square_count[2] = {50, 50}, cube_count[3] = {100, 50, 50}; - MPI_Offset xytime_start[3] = {0, 0, 0}; - MPI_Offset xytime_count[3] = {100, 50, 50}; - MPI_Offset time_start[1], time_count[1] = {25}; - int square_id, cube_id, xytime_id, time_id; - static char title[] = "example netCDF dataset"; - static char description[] = "2-D integer array"; - float data[100][50][50], buffer[100]; - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - params opts; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing write ... "); - - parse_write_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - /** - * Create the dataset - * File name: "testwrite.nc" - * Dataset API: Collective - */ - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid); - if (status != NC_NOERR) handle_error(status); - - - /** - * Create a global attribute: - * :title = "example netCDF dataset"; - */ - - status = ncmpi_put_att_text (ncid, NC_GLOBAL, "title", - strlen(title), title); - if (status != NC_NOERR) handle_error(status); - - /** - * Add 4 pre-defined dimensions: - * x = 100, y = 100, z = 100, time = NC_UNLIMITED - */ - - status = ncmpi_def_dim(ncid, "x", 100L, &dimid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "y", 100L, &dimid2); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "z", 100L, &dimid3); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "time", NC_UNLIMITED, &udimid); - if (status != NC_NOERR) handle_error(status); - - /** - * Define the dimensionality and then add 4 variables: - * square(x, y), cube(x,y,z), time(time), xytime(time, x, y) - */ - - square_dim[0] = cube_dim[0] = xytime_dim[1] = dimid1; - square_dim[1] = cube_dim[1] = xytime_dim[2] = dimid2; - cube_dim[2] = dimid3; - xytime_dim[0] = udimid; - time_dim[0] = udimid; - status = ncmpi_def_var (ncid, "square", NC_FLOAT, 2, square_dim, &square_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "cube", NC_FLOAT, 3, cube_dim, &cube_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "time", NC_FLOAT, 1, time_dim, &time_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "xytime", NC_FLOAT, 3, xytime_dim, &xytime_id); - if (status != NC_NOERR) handle_error(status); - - /** - * Add an attribute for variable: - * square: decsription = "2-D integer array" - */ - - status = ncmpi_put_att_text (ncid, square_id, "description", - strlen(description), description); - if (status != NC_NOERR) handle_error(status); - - - /** - * End Define Mode (switch to data mode) - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, Block), 50*50 from 100*100 - * cube: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * xytime: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - */ - - square_start[0] = cube_start[1] = xytime_start[1] = (rank/2) * 50; - square_start[1] = cube_start[2] = xytime_start[2] = (rank%2) * 50; - time_start[0] = (rank%4) * 25; - - - /** - * Packing data in the buffer - */ - - /* Data for variable: time */ - for ( i = time_start[0]; i < time_start[0] + time_count[0]; i++ ) - buffer[i - time_start[0]] = i; - - /* Data for variable: square, cube and xytime */ - for ( i = 0; i < 100; i++ ) - for ( j = square_start[0]; j < square_start[0]+square_count[0]; j++ ) - for ( k = square_start[1]; k < square_start[1]+square_count[1]; k++ ) - data[i][j-square_start[0]][k-square_start[1]] = i*100*100 + j*100 + k; - - /** - * Write data into variables: square, cube, time and xytime - * Access Method: subarray - * Data Mode API: collective - */ - - status = ncmpi_put_vara_float_all(ncid, square_id, - square_start, square_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float_all(ncid, cube_id, - cube_start, cube_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float_all(ncid, time_id, - time_start, time_count, - buffer); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float_all(ncid, xytime_id, - xytime_start, xytime_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - - /** - * Close the dataset - * Dataset API: collective - */ - - status = ncmpi_close(ncid); - if (status != NC_NOERR) handle_error(status); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nFile written to: %s!\n", opts.outfname); - - MPI_Finalize(); - return 0; -} - diff --git a/test/Legacy/test_float/test_write_indep.c b/test/Legacy/test_float/test_write_indep.c deleted file mode 100644 index 945cdb03d..000000000 --- a/test/Legacy/test_float/test_write_indep.c +++ /dev/null @@ -1,239 +0,0 @@ -/*********************************************************** - * - * This test program writes a netCDF file using the parallel - * netCDF library using MPI-IO. - * - * The output file is: "testwrite.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * float square(x, y); - * squre: description = "2-D integer array"; - * - * float cube(x,y,z); - * - * float time(time); // coordinate & record variable - * - * float xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses non-collective APIs to write variable data and only - * deals with float variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - - - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - fprintf(stderr, "%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j, k; - int status; - int ncid; - int dimid1, dimid2, dimid3, udimid; - int square_dim[2], cube_dim[3], xytime_dim[3], time_dim[1]; - MPI_Offset square_start[2], cube_start[3] = {0, 0, 0}; - MPI_Offset square_count[2] = {50, 50}, cube_count[3] = {100, 50, 50}; - MPI_Offset xytime_start[3] = {0, 0, 0}; - MPI_Offset xytime_count[3] = {100, 50, 50}; - MPI_Offset time_start[1], time_count[1] = {25}; - int square_id, cube_id, xytime_id, time_id; - static char title[] = "example netCDF dataset"; - static char description[] = "2-D integer array"; - float data[100][50][50], buffer[100]; - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - params opts; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing independent write ... "); - parse_write_args(argc, argv, rank, &opts); - - - /********** START OF NETCDF ACCESS **************/ - - /** - * Create the dataset - * File name: "testwrite.nc" - * Dataset API: Collective - */ - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid); - if (status != NC_NOERR) handle_error(status); - - - /** - * Create a global attribute: - * :title = "example netCDF dataset"; - */ - - status = ncmpi_put_att_text (ncid, NC_GLOBAL, "title", - strlen(title), title); - if (status != NC_NOERR) handle_error(status); - - /** - * Add 4 pre-defined dimensions: - * x = 100, y = 100, z = 100, time = NC_UNLIMITED - */ - - status = ncmpi_def_dim(ncid, "x", 100L, &dimid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "y", 100L, &dimid2); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "z", 100L, &dimid3); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "time", NC_UNLIMITED, &udimid); - if (status != NC_NOERR) handle_error(status); - - /** - * Define the dimensionality and then add 4 variables: - * square(x, y), cube(x,y,z), time(time), xytime(time, x, y) - */ - - square_dim[0] = cube_dim[0] = xytime_dim[1] = dimid1; - square_dim[1] = cube_dim[1] = xytime_dim[2] = dimid2; - cube_dim[2] = dimid3; - xytime_dim[0] = udimid; - time_dim[0] = udimid; - status = ncmpi_def_var (ncid, "square", NC_FLOAT, 2, square_dim, &square_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "cube", NC_FLOAT, 3, cube_dim, &cube_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "time", NC_FLOAT, 1, time_dim, &time_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "xytime", NC_FLOAT, 3, xytime_dim, &xytime_id); - if (status != NC_NOERR) handle_error(status); - - /** - * Add an attribute for variable: - * square: decsription = "2-D integer array" - */ - - status = ncmpi_put_att_text (ncid, square_id, "description", - strlen(description), description); - if (status != NC_NOERR) handle_error(status); - - - /** - * End Define Mode (switch to data mode) - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, Block), 50*50 from 100*100 - * cube: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * xytime: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - */ - - square_start[0] = cube_start[1] = xytime_start[1] = (rank/2) * 50; - square_start[1] = cube_start[2] = xytime_start[2] = (rank%2) * 50; - time_start[0] = (rank%4) * 25; - - - /** - * Packing data in the buffer - */ - - /* Data for variable: time */ - for ( i = time_start[0]; i < time_start[0] + time_count[0]; i++ ) - buffer[i - time_start[0]] = i; - - /* Data for variable: square, cube and xytime */ - for ( i = 0; i < 100; i++ ) - for ( j = square_start[0]; j < square_start[0]+square_count[0]; j++ ) - for ( k = square_start[1]; k < square_start[1]+square_count[1]; k++ ) - data[i][j-square_start[0]][k-square_start[1]] = i*100*100 + j*100 + k; - - /** - * Write data into variables: square, cube, time and xytime - * Access Method: subarray - * Data Mode API: non-collective - */ - - status = ncmpi_begin_indep_data(ncid); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_put_vara_float(ncid, square_id, - square_start, square_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float(ncid, cube_id, - cube_start, cube_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float(ncid, time_id, - time_start, time_count, - buffer); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float(ncid, xytime_id, - xytime_start, xytime_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_end_indep_data(ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Close the dataset - * Dataset API: collective - */ - - status = ncmpi_close(ncid); - if (status != NC_NOERR) handle_error(status); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nFile written to: %s!\n", opts.outfname); - - MPI_Finalize(); - return 0; -} - diff --git a/test/Legacy/test_int/Makefile.am b/test/Legacy/test_int/Makefile.am deleted file mode 100644 index 7dfb8e169..000000000 --- a/test/Legacy/test_int/Makefile.am +++ /dev/null @@ -1,66 +0,0 @@ -# -# Copyright (C) 2003, Northwestern University and Argonne National Laboratory -# See COPYRIGHT notice in top-level directory. -# -# $Id$ -# -# @configure_input@ - -srcdir = @srcdir@ -VPATH = @srcdir@ - -include ../../macros.make - -INCLUDES = -I../../src/lib -I$(srcdir)/../common -LDFLAGS := $(LDFLAGS) -L../common -LIBS := $(LIBRARY) -ltestutils $(LIBS) - -SRCS = test_read.c \ - test_read_indep.c \ - test_write.c \ - test_write_indep.c \ - test_write64.c \ - test_read64.c - -OBJS = $(SRCS:.c=.o) -PROGS = $(SRCS:.c=) - -GARBAGE = $(PROGS) -PACKING_LIST = $(SRCS) Makefile.in README header.txt - -all: $(PROGS) - set -e; cd ../data && $(MAKE) $(MFLAGS) all - -$(OBJS): $(srcdir)/../common/testutils.h - -$(PROGS): ../common/libtestutils.a - -../common/libtestutils.a: - set -e; cd ../common && $(MAKE) $(MFLAGS) all - -test_read: test_read.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -test_read_indep: test_read_indep.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -test_write: test_write.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -test_write_indep: test_write_indep.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -test_write64: test_write64.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -test_read64: test_read64.o $(LIBRARY) - $(LINK.c) $< $(LDFLAGS) $(LIBS) - -testing check verbose_testing: - -ptest ptests ptest2 ptest4 ptest6 ptest8 ptest10: - -include $(srcdir)/../../rules.make - -$(LIBRARY): ; - diff --git a/test/Legacy/test_int/README b/test/Legacy/test_int/README deleted file mode 100644 index 052dfa4bb..000000000 --- a/test/Legacy/test_int/README +++ /dev/null @@ -1,3 +0,0 @@ -These examples test data transfers of: - - "file NC_INT var" <---> "memory int" diff --git a/test/Legacy/test_int/header.txt b/test/Legacy/test_int/header.txt deleted file mode 100644 index 55f6babda..000000000 --- a/test/Legacy/test_int/header.txt +++ /dev/null @@ -1,67 +0,0 @@ -0000000 C D F 001 \0 \0 \0 d \0 \0 \0 \n \0 \0 \0 004 - 4344 4601 0000 0064 0000 000a 0000 0004 - 17220 17921 00000 00100 00000 00010 00000 00004 -0000020 \0 \0 \0 001 x \0 \0 \0 \0 \0 \0 d \0 \0 \0 001 - 0000 0001 7800 0000 0000 0064 0000 0001 - 00000 00001 30720 00000 00000 00100 00000 00001 -0000040 y \0 \0 \0 \0 \0 \0 d \0 \0 \0 001 z \0 \0 \0 - 7900 0000 0000 0064 0000 0001 7a00 0000 - 30976 00000 00000 00100 00000 00001 31232 00000 -0000060 \0 \0 \0 d \0 \0 \0 004 t i m e \0 \0 \0 \0 - 0000 0064 0000 0004 7469 6d65 0000 0000 - 00000 00100 00000 00004 29801 28005 00000 00000 -0000100 \0 \0 \0 \f \0 \0 \0 001 \0 \0 \0 005 t i t l - 0000 000c 0000 0001 0000 0005 7469 746c - 00000 00012 00000 00001 00000 00005 29801 29804 -0000120 e \0 \0 \0 \0 \0 \0 002 \0 \0 \0 026 e x a m - 6500 0000 0000 0002 0000 0016 6578 616d - 25856 00000 00000 00002 00000 00022 25976 24941 -0000140 p l e n e t C D F d a t a s - 706c 6520 6e65 7443 4446 2064 6174 6173 - 28780 25888 28261 29763 17478 08292 24948 24947 -0000160 e t \0 \0 \0 \0 \0 013 \0 \0 \0 004 \0 \0 \0 006 - 6574 0000 0000 000b 0000 0004 0000 0006 - 25972 00000 00000 00011 00000 00004 00000 00006 -0000200 s q u a r e \0 \0 \0 \0 \0 002 \0 \0 \0 \0 - 7371 7561 7265 0000 0000 0002 0000 0000 - 29553 30049 29285 00000 00000 00002 00000 00000 -0000220 \0 \0 \0 001 \0 \0 \0 \f \0 \0 \0 001 \0 \0 \0 013 - 0000 0001 0000 000c 0000 0001 0000 000b - 00000 00001 00000 00012 00000 00001 00000 00011 -0000240 d e s c r i p t i o n \0 \0 \0 \0 002 - 6465 7363 7269 7074 696f 6e00 0000 0002 - 25701 29539 29289 28788 26991 28160 00000 00002 -0000260 \0 \0 \0 021 2 - D i n t e g e r - 0000 0011 322d 4420 696e 7465 6765 7220 - 00000 00017 12845 17440 26990 29797 26469 29216 -0000300 a r r a y \0 \0 \0 \0 \0 \0 004 \0 \0 234 @ - 6172 7261 7900 0000 0000 0004 0000 9c40 - 24946 29281 30976 00000 00000 00004 00000 -25536 -0000320 \0 \0 001 T \0 \0 \0 004 c u b e \0 \0 \0 003 - 0000 0154 0000 0004 6375 6265 0000 0003 - 00000 00340 00000 00004 25461 25189 00000 00003 -0000340 \0 \0 \0 \0 \0 \0 \0 001 \0 \0 \0 002 \0 \0 \0 \0 - 0000 0000 0000 0001 0000 0002 0000 0000 - 00000 00000 00000 00001 00000 00002 00000 00000 -0000360 \0 \0 \0 \0 \0 \0 \0 004 \0 = \t \0 \0 \0 235 224 - 0000 0000 0000 0004 003d 0900 0000 9d94 - 00000 00000 00000 00004 00061 02304 00000 -25196 -0000400 \0 \0 \0 004 t i m e \0 \0 \0 001 \0 \0 \0 003 - 0000 0004 7469 6d65 0000 0001 0000 0003 - 00000 00004 29801 28005 00000 00001 00000 00003 -0000420 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 004 \0 \0 \0 004 - 0000 0000 0000 0000 0000 0004 0000 0004 - 00000 00000 00000 00000 00000 00004 00000 00004 -0000440 \0 = 246 224 \0 \0 \0 006 x y t i m e \0 \0 - 003d a694 0000 0006 7879 7469 6d65 0000 - 00061 -22892 00000 00006 30841 29801 28005 00000 -0000460 \0 \0 \0 003 \0 \0 \0 003 \0 \0 \0 \0 \0 \0 \0 001 - 0000 0003 0000 0003 0000 0000 0000 0001 - 00000 00003 00000 00003 00000 00000 00000 00001 -0000500 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 004 \0 \0 234 @ - 0000 0000 0000 0000 0000 0004 0000 9c40 - 00000 00000 00000 00000 00000 00004 00000 -25536 -0000520 \0 = 246 230 - 003d a698 - 00061 -22888 -0000524 diff --git a/test/Legacy/test_int/test_read.c b/test/Legacy/test_int/test_read.c deleted file mode 100644 index 0467814ef..000000000 --- a/test/Legacy/test_int/test_read.c +++ /dev/null @@ -1,374 +0,0 @@ -/*********************************************************** - * - * This test program reads a netCDF file, and then write it - * out to another netCDF file, using the parallel netCDF - * library using MPI-IO. The two files should be identical. - * - * Input File: "../data/test_int.nc" generated from original netcdf-3. - * Output File: "testread.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * int square(x, y); - * squre: description = "2-D integer array"; - * - * int cube(x,y,z); - * - * int time(time); // coordinate & record variable - * - * int xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses collective APIs to read/write variable data and - * only deals with integer variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - printf("%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j; - int status; - int ncid1, ncid2; - int ndims, nvars, ngatts, unlimdimid; - char name[NC_MAX_NAME]; - nc_type type, *vartypes; - MPI_Offset attlen, dimlen, varsize; - MPI_Offset *shape, *start; - void *valuep; - int *dimids, *varids, **vardims, *varndims, *varnatts; - params opts; - int NC_mode; - - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing read ... "); - parse_read_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - - /* Read a netCDF file and write it out to another file */ - - /** - * Open the input dataset - ncid1: - * File name: "../data/test_int.nc" - * Dataset API: Collective - * And create the output dataset - ncid2: - * File name: "testread.nc" - * Dataset API: Collective - */ - - status = ncmpi_open(comm, opts.infname, 0, MPI_INFO_NULL, &ncid1); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_inq_version(ncid1, &NC_mode); - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER|NC_mode, MPI_INFO_NULL, &ncid2); - -/* status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid2); */ - if (status != NC_NOERR) handle_error(status); - - - /** - * Inquire the dataset definitions of input dataset AND - * Add dataset definitions for output dataset. - */ - - status = ncmpi_inq(ncid1, &ndims, &nvars, &ngatts, &unlimdimid); - if (status != NC_NOERR) handle_error(status); - - - /* Inquire global attributes, assume CHAR attributes. */ - - for (i = 0; i < ngatts; i++) { - status = ncmpi_inq_attname(ncid1, NC_GLOBAL, i, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, NC_GLOBAL, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, NC_GLOBAL, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, NC_GLOBAL, name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, NC_GLOBAL, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, NC_GLOBAL, name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, NC_GLOBAL, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, NC_GLOBAL, name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, NC_GLOBAL, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, NC_GLOBAL, name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, NC_GLOBAL, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, NC_GLOBAL, name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - } - - /* Inquire dimension */ - dimids = (int*) malloc(ndims * sizeof(int)); - - for (i = 0; i < ndims; i++) { - status = ncmpi_inq_dim(ncid1, i, name, &dimlen); - if (status != NC_NOERR) handle_error(status); - if (i == unlimdimid) - dimlen = NC_UNLIMITED; - status = ncmpi_def_dim(ncid2, name, dimlen, dimids+i); - if (status != NC_NOERR) handle_error(status); - } - free(dimids); - - vartypes = (nc_type*) malloc(nvars * sizeof(nc_type)); - varids = (int*) malloc(nvars * sizeof(int)); - varndims = (int*) malloc(nvars * sizeof(int)); - varnatts = (int*) malloc(nvars * sizeof(int)); - vardims = (int**) malloc(nvars * sizeof(int*)); - - /* Inquire variables */ - - for (i = 0; i < nvars; i++) { - status = ncmpi_inq_varndims(ncid1, i, varndims+i); - if (status != NC_NOERR) handle_error(status); - vardims[i] = (int*) malloc(varndims[i] * sizeof(int)); - - status = ncmpi_inq_var (ncid1, i, name, vartypes+i, varndims+i, vardims[i], varnatts+i); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_def_var(ncid2, name, vartypes[i], varndims[i], vardims[i], varids+i); - if (status != NC_NOERR) handle_error(status); - - /* var attributes, assume CHAR attributes */ - - for (j = 0; j < varnatts[i]; j++) { - status = ncmpi_inq_attname(ncid1, i, j, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, i, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, i, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, varids[i], name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, i, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, varids[i], name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, i, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, varids[i], name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, i, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, varids[i], name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, i, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, varids[i], name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - } - } - - /** - * End Define Mode (switch to data mode) for output dataset - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Read data of variables from input dataset - * (ONLY DEAL WITH: NC_INT, NC_FLOAT, NC_DOUBLE for now) - * Write the data out to the corresponding variables in the output dataset - * - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, *), 25*100 from 100*100 - * cube: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * xytime: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - * - * Data Mode API: collective - */ - - for (i = 0; i < nvars; i++) { - shape = (MPI_Offset*) calloc(varndims[i] * 2, sizeof(MPI_Offset)); - start = shape + varndims[i]; - - varsize = 1; - for (j = 0; j < varndims[i]; j++) { - status = ncmpi_inq_dim(ncid1, vardims[i][j], name, shape + j); - if (status != NC_NOERR) handle_error(status); - if (j == 0) { - shape[j] /= nprocs; - start[j] = shape[j] * rank; - } - varsize *= shape[j]; - } - switch (vartypes[i]) { - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vara_short_all(ncid1, i, start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_short_all(ncid2, varids[i], - start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int_all(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vara_float_all(ncid1, i, start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float_all(ncid2, varids[i], - start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(double)); - status = ncmpi_get_vara_double_all(ncid1, i, start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_double_all(ncid2, varids[i], - start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - free(vardims[i]); - free(shape); - } - - /** - * Close the datasets - * Dataset API: collective - */ - - status = ncmpi_close(ncid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_close(ncid2); - if (status != NC_NOERR) handle_error(status); - - free(vartypes); - free(varids); - free(varndims); - free(varnatts); - free(vardims); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nInput file %s copied to: %s!\n", opts.infname, opts.outfname); - - MPI_Finalize(); - return 0; -} diff --git a/test/Legacy/test_int/test_read64.c b/test/Legacy/test_int/test_read64.c deleted file mode 100644 index 4ef04d9bb..000000000 --- a/test/Legacy/test_int/test_read64.c +++ /dev/null @@ -1,376 +0,0 @@ -/*********************************************************** - * - * This test program reads a netCDF file, and then write it - * out to another netCDF file, using the parallel netCDF - * library using MPI-IO. The two files should be identical. - * - * Input File: "../data/test_int.nc" generated from original netcdf-3. - * Output File: "testread.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * int square(x, y); - * squre: description = "2-D integer array"; - * - * int cube(x,y,z); - * - * int time(time); // coordinate & record variable - * - * int xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses collective APIs to read/write variable data and - * only deals with integer variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - printf("%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j; - int status; - int ncid1, ncid2; - int ndims, nvars, ngatts, unlimdimid; - char name[NC_MAX_NAME]; - nc_type type, *vartypes; - MPI_Offset attlen, dimlen, varsize; - MPI_Offset *shape, *start; - void *valuep; - int *dimids, *varids, **vardims, *varndims, *varnatts; - params opts; - - int rank; - int nprocs; - int NC_mode; - MPI_Comm comm = MPI_COMM_WORLD; - - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing read ... "); - parse_read_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - - /* Read a netCDF file and write it out to another file */ - - /** - * Open the input dataset - ncid1: - * File name: "../data/test_int.nc" - * Dataset API: Collective - * And create the output dataset - ncid2: - * File name: "testread.nc" - * Dataset API: Collective - */ - - status = ncmpi_open(comm, opts.infname, 0, MPI_INFO_NULL, &ncid1); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_inq_version(ncid1, &NC_mode); - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER|NC_mode, MPI_INFO_NULL, &ncid2); - if (status != NC_NOERR) handle_error(status); - - - /** - * Inquire the dataset definitions of input dataset AND - * Add dataset definitions for output dataset. - */ - - status = ncmpi_inq(ncid1, &ndims, &nvars, &ngatts, &unlimdimid); - if (status != NC_NOERR) handle_error(status); - - - - /* Inquire global attributes, assume CHAR attributes. */ - - for (i = 0; i < ngatts; i++) { - status = ncmpi_inq_attname(ncid1, NC_GLOBAL, i, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, NC_GLOBAL, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, NC_GLOBAL, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, NC_GLOBAL, name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, NC_GLOBAL, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, NC_GLOBAL, name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, NC_GLOBAL, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, NC_GLOBAL, name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, NC_GLOBAL, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, NC_GLOBAL, name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, NC_GLOBAL, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, NC_GLOBAL, name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - } - - /* Inquire dimension */ - dimids = (int*) malloc(ndims * sizeof(int)); - - for (i = 0; i < ndims; i++) { - status = ncmpi_inq_dim(ncid1, i, name, &dimlen); - if (status != NC_NOERR) handle_error(status); - if (i == unlimdimid) - dimlen = NC_UNLIMITED; - status = ncmpi_def_dim(ncid2, name, dimlen, dimids+i); - if (status != NC_NOERR) handle_error(status); - } - free(dimids); - - vartypes = (nc_type*) malloc(nvars * sizeof(nc_type)); - varids = (int*) malloc(nvars * sizeof(int)); - varndims = (int*) malloc(nvars * sizeof(int)); - varnatts = (int*) malloc(nvars * sizeof(int)); - vardims = (int**) malloc(nvars * sizeof(int*)); - - /* Inquire variables */ - - for (i = 0; i < nvars; i++) { - status = ncmpi_inq_varndims(ncid1, i, varndims+i); - if (status != NC_NOERR) handle_error(status); - vardims[i] = (int*) malloc(varndims[i] * sizeof(int)); - - status = ncmpi_inq_var (ncid1, i, name, vartypes+i, varndims+i, vardims[i], varnatts+i); - if (status != NC_NOERR) handle_error(status); - - - status = ncmpi_def_var(ncid2, name, vartypes[i], varndims[i], vardims[i], varids+i); - if (status != NC_NOERR) handle_error(status); - - /* var attributes, assume CHAR attributes */ - - for (j = 0; j < varnatts[i]; j++) { - status = ncmpi_inq_attname(ncid1, i, j, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, i, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, i, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, varids[i], name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, i, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, varids[i], name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, i, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, varids[i], name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, i, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, varids[i], name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, i, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, varids[i], name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - } - } - - /** - * End Define Mode (switch to data mode) for output dataset - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Read data of variables from input dataset - * (ONLY DEAL WITH: NC_INT, NC_FLOAT, NC_DOUBLE for now) - * Write the data out to the corresponding variables in the output dataset - * - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, *), 25*100 from 100*100 - * cube: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * xytime: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - * - * Data Mode API: collective - */ - - for (i = 0; i < nvars; i++) { - shape = (MPI_Offset*) calloc(varndims[i] * 2, sizeof(MPI_Offset)); - start = shape + varndims[i]; - - varsize = 1; - for (j = 0; j < varndims[i]; j++) { - status = ncmpi_inq_dim(ncid1, vardims[i][j], name, shape + j); - if (status != NC_NOERR) handle_error(status); - if (j == 0) { - shape[j] /= nprocs; - start[j] = shape[j] * rank; - } - varsize *= shape[j]; - } - - switch (vartypes[i]) { - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vara_short_all(ncid1, i, start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_short_all(ncid2, varids[i], - start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int_all(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vara_float_all(ncid1, i, start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float_all(ncid2, varids[i], - start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(double)); - status = ncmpi_get_vara_double_all(ncid1, i, start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_double_all(ncid2, varids[i], - start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - free(vardims[i]); - free(shape); - } - - /** - * Close the datasets - * Dataset API: collective - */ - - status = ncmpi_close(ncid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_close(ncid2); - if (status != NC_NOERR) handle_error(status); - - free(vartypes); - free(varids); - free(varndims); - free(varnatts); - free(vardims); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nInput file %s copied to: %s!\n", opts.infname, opts.outfname); - - MPI_Finalize(); - return 0; -} diff --git a/test/Legacy/test_int/test_read_indep.c b/test/Legacy/test_int/test_read_indep.c deleted file mode 100644 index 89c2bbbe9..000000000 --- a/test/Legacy/test_int/test_read_indep.c +++ /dev/null @@ -1,385 +0,0 @@ -/*********************************************************** - * - * This test program reads a netCDF file, and then write it - * out to another netCDF file, using the parallel netCDF - * library using MPI-IO. The two files should be identical. - * - * Input File: "../data/test_int.nc" generated from original netcdf-3. - * Output File: "testread.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * int square(x, y); - * squre: description = "2-D integer array"; - * - * int cube(x,y,z); - * - * int time(time); // coordinate & record variable - * - * int xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses non-collective APIs to read/write variable data and - * only deals with integer variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - printf("%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j; - int status; - int ncid1, ncid2; - int ndims, nvars, ngatts, unlimdimid; - char name[NC_MAX_NAME]; - nc_type type, *vartypes; - MPI_Offset attlen, varsize, dimlen; - MPI_Offset *shape, *start; - void *valuep; - int *dimids, *varids, **vardims, *varndims, *varnatts; - params opts; - int NC_mode; - - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing independent read ... "); - parse_read_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - - /* Read a netCDF file and write it out to another file */ - - /** - * Open the input dataset - ncid1: - * File name: "../data/test_int.nc" - * Dataset API: Collective - * And create the output dataset - ncid2: - * File name: "testread.nc" - * Dataset API: Collective - */ - - status = ncmpi_open(comm, opts.infname, 0, MPI_INFO_NULL, &ncid1); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_inq_version(ncid1, &NC_mode); - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER|NC_mode, MPI_INFO_NULL, &ncid2); - - if (status != NC_NOERR) handle_error(status); - - - /** - * Inquire the dataset definitions of input dataset AND - * Add dataset definitions for output dataset. - */ - - status = ncmpi_inq(ncid1, &ndims, &nvars, &ngatts, &unlimdimid); - if (status != NC_NOERR) handle_error(status); - - varids = (int*) malloc(nvars * sizeof(int)); - - - /* Inquire global attributes, assume CHAR attributes. */ - - for (i = 0; i < ngatts; i++) { - status = ncmpi_inq_attname(ncid1, NC_GLOBAL, i, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, NC_GLOBAL, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, NC_GLOBAL, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, NC_GLOBAL, name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, NC_GLOBAL, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, NC_GLOBAL, name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, NC_GLOBAL, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, NC_GLOBAL, name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, NC_GLOBAL, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, NC_GLOBAL, name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, NC_GLOBAL, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, NC_GLOBAL, name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - } - - /* Inquire dimension */ - dimids = (int*) malloc(ndims * sizeof(int)); - - for (i = 0; i < ndims; i++) { - status = ncmpi_inq_dim(ncid1, i, name, &dimlen); - if (status != NC_NOERR) handle_error(status); - if (i == unlimdimid) - dimlen = NC_UNLIMITED; - status = ncmpi_def_dim(ncid2, name, dimlen, dimids+i); - if (status != NC_NOERR) handle_error(status); - } - free(dimids); - - vartypes = (nc_type*) malloc(nvars * sizeof(nc_type)); - varids = (int*) malloc(nvars * sizeof(int)); - varndims = (int*) malloc(nvars * sizeof(int)); - varnatts = (int*) malloc(nvars * sizeof(int)); - vardims = (int**) malloc(nvars * sizeof(int*)); - - /* Inquire variables */ - - for (i = 0; i < nvars; i++) { - status = ncmpi_inq_varndims(ncid1, i, varndims+i); - if (status != NC_NOERR) handle_error(status); - vardims[i] = (int*) malloc(varndims[i] * sizeof(int)); - - status = ncmpi_inq_var (ncid1, i, name, vartypes+i, varndims+i, vardims[i], varnatts+i); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_def_var(ncid2, name, vartypes[i], varndims[i], vardims[i], varids+i); - if (status != NC_NOERR) handle_error(status); - - /* var attributes, assume CHAR attributes */ - - for (j = 0; j < varnatts[i]; j++) { - status = ncmpi_inq_attname(ncid1, i, j, name); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_inq_att (ncid1, i, name, &type, &attlen); - if (status != NC_NOERR) handle_error(status); - switch (type) { - case NC_CHAR: - valuep = (void *)malloc(attlen * sizeof(char)); - status = ncmpi_get_att_text(ncid1, i, name, (char*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_text (ncid2, varids[i], name, attlen, (char *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_SHORT: - valuep = (void *)malloc(attlen * sizeof(short)); - status = ncmpi_get_att_short(ncid1, i, name, (short*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_short (ncid2, varids[i], name, type, attlen, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(attlen * sizeof(int)); - status = ncmpi_get_att_int(ncid1, i, name, (int*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_int (ncid2, varids[i], name, type, attlen, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(attlen * sizeof(float)); - status = ncmpi_get_att_float(ncid1, i, name, (float*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_float (ncid2, varids[i], name, type, attlen, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(attlen * sizeof(double)); - status = ncmpi_get_att_double(ncid1, i, name, (double*)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_att_double (ncid2, varids[i], name, type, attlen, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - } - } - - /** - * End Define Mode (switch to data mode) for output dataset - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Read data of variables from input dataset (assume INT variables) - * Write the data out to the corresponding variables in the output dataset - * - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, *), 25*100 from 100*100 - * cube: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * xytime: 3-D, (Block, *, *), 25*100*100 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - * - * Data Mode API: non-collective - */ - - status = ncmpi_begin_indep_data(ncid1); - if (status != NC_NOERR) handle_error(status); - status =ncmpi_begin_indep_data(ncid2); - if (status != NC_NOERR) handle_error(status); - - for (i = 0; i < nvars; i++) { - shape = (MPI_Offset*) calloc(varndims[i] * 2, sizeof(MPI_Offset)); - start = shape + varndims[i]; - - varsize = 1; - for (j = 0; j < varndims[i]; j++) { - status = ncmpi_inq_dim(ncid1, vardims[i][j], name, shape + j); - if (status != NC_NOERR) handle_error(status); - if (j == 0) { - shape[j] /= nprocs; - start[j] = shape[j] * rank; - } - varsize *= shape[j]; - } - switch (vartypes[i]) { - case NC_CHAR: - break; - case NC_SHORT: - valuep = (void *)malloc(varsize * sizeof(short)); - status = ncmpi_get_vara_short(ncid1, i, start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_short(ncid2, varids[i], - start, shape, (short *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_INT: - valuep = (void *)malloc(varsize * sizeof(int)); - status = ncmpi_get_vara_int(ncid1, i, start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid2, varids[i], - start, shape, (int *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_FLOAT: - valuep = (void *)malloc(varsize * sizeof(float)); - status = ncmpi_get_vara_float(ncid1, i, start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_float(ncid2, varids[i], - start, shape, (float *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - case NC_DOUBLE: - valuep = (void *)malloc(varsize * sizeof(double)); - status = ncmpi_get_vara_double(ncid1, i, start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_double(ncid2, varids[i], - start, shape, (double *)valuep); - if (status != NC_NOERR) handle_error(status); - free(valuep); - break; - default: - ; - /* handle unexpected types */ - } - free(vardims[i]); - free(shape); - } - free(varids); - - status = ncmpi_end_indep_data(ncid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_end_indep_data(ncid2); - if (status != NC_NOERR) handle_error(status); - - /** - * Close the datasets - * Dataset API: collective - */ - - status = ncmpi_close(ncid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_close(ncid2); - if (status != NC_NOERR) handle_error(status); - - free(vartypes); - free(varids); - free(varndims); - free(varnatts); - free(vardims); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nInput file %s copied to: %s!\n", opts.infname, opts.outfname); - - MPI_Finalize(); - return 0; -} diff --git a/test/Legacy/test_int/test_write.c b/test/Legacy/test_int/test_write.c deleted file mode 100644 index 503263278..000000000 --- a/test/Legacy/test_int/test_write.c +++ /dev/null @@ -1,251 +0,0 @@ -/*********************************************************** - * - * This test program writes a netCDF file using the parallel - * netCDF library using MPI-IO. - * - * The output file is: "testwrite.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * int square(x, y); - * squre: description = "2-D integer array"; - * - * int cube(x,y,z); - * - * int time(time); // coordinate & record variable - * - * int xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses collective APIs to write variable data and only - * deals with integer variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - - - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - fprintf(stderr, "%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - MPI_Offset i, j, k; - int status; - int ncid; - int dimid1, dimid2, dimid3, udimid; - int square_dim[2], cube_dim[3], xytime_dim[3], time_dim[1]; - MPI_Offset square_start[2], cube_start[3] = {0, 0, 0}; - MPI_Offset square_count[2] = {50, 50}, cube_count[3] = {100, 50, 50}; - MPI_Offset xytime_start[3] = {0, 0, 0}; - MPI_Offset xytime_count[3] = {100, 50, 50}; - MPI_Offset time_start[1], time_count[1] = {25}; - int square_id, cube_id, xytime_id, time_id; - static char title[] = "example netCDF dataset"; - static char description[] = "2-D integer array"; - int data[100][50][50], buffer[100]; - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - double TotalWriteTime; - params opts; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing write ... "); - parse_write_args(argc, argv, rank, &opts); - - MPI_Barrier(MPI_COMM_WORLD); - TotalWriteTime = MPI_Wtime(); - - /********** START OF NETCDF ACCESS **************/ - - /** - * Create the dataset - * File name: "testwrite.nc" - * Dataset API: Collective - */ - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER|NC_64BIT_OFFSET, MPI_INFO_NULL, &ncid); - if (status != NC_NOERR) handle_error(status); - - - /** - * Create a global attribute: - * :title = "example netCDF dataset"; - */ - - status = ncmpi_put_att_text (ncid, NC_GLOBAL, "title", - strlen(title), title); - if (status != NC_NOERR) handle_error(status); - - /** - * Add 4 pre-defined dimensions: - * x = 100, y = 100, z = 100, time = NC_UNLIMITED - */ - - status = ncmpi_def_dim(ncid, "x", 100L, &dimid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "y", 100L, &dimid2); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "z", 100L, &dimid3); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "time", NC_UNLIMITED, &udimid); - if (status != NC_NOERR) handle_error(status); - - /** - * Define the dimensionality and then add 4 variables: - * square(x, y), cube(x,y,z), time(time), xytime(time, x, y) - */ - - square_dim[0] = cube_dim[0] = xytime_dim[1] = dimid1; - square_dim[1] = cube_dim[1] = xytime_dim[2] = dimid2; - cube_dim[2] = dimid3; - xytime_dim[0] = udimid; - time_dim[0] = udimid; - status = ncmpi_def_var (ncid, "square", NC_INT, 2, square_dim, &square_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "cube", NC_INT, 3, cube_dim, &cube_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "time", NC_INT, 1, time_dim, &time_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "xytime", NC_INT, 3, xytime_dim, &xytime_id); - if (status != NC_NOERR) handle_error(status); - - /** - * Add an attribute for variable: - * square: decsription = "2-D integer array" - */ - - status = ncmpi_put_att_text (ncid, square_id, "description", - strlen(description), description); - if (status != NC_NOERR) handle_error(status); - - /** - * End Define Mode (switch to data mode) - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, Block), 50*50 from 100*100 - * cube: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * xytime: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - */ - - square_start[0] = cube_start[1] = xytime_start[1] = (rank/2) * 50; - square_start[1] = cube_start[2] = xytime_start[2] = (rank%2) * 50; - time_start[0] = (rank%4) * 25; - - - /** - * Packing data in the buffer - */ - - /* Data for variable: time */ - for ( i = time_start[0]; i < time_start[0] + time_count[0]; i++ ) - buffer[i - time_start[0]] = i; - - /* Data for variable: square, cube and xytime */ - for ( i = 0; i < 100; i++ ) - for ( j = square_start[0]; j < square_start[0]+square_count[0]; j++ ) - for ( k = square_start[1]; k < square_start[1]+square_count[1]; k++ ) - data[i][j-square_start[0]][k-square_start[1]] = i*100*100 + j*100 + k; - - /** - * Write data into variables: square, cube, time and xytime - * Access Method: subarray - * Data Mode API: collective - */ - - status = ncmpi_put_vara_int_all(ncid, square_id, - square_start, square_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid, cube_id, - cube_start, cube_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid, time_id, - time_start, time_count, - buffer); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid, xytime_id, - xytime_start, xytime_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - -/* -status = ncmpi_sync(ncid); -if (status != NC_NOERR) handle_error(status); -status = ncmpi_redef(ncid); -if (status != NC_NOERR) handle_error(status); -status = ncmpi_del_att(ncid, square_id, "description"); -if (status != NC_NOERR) handle_error(status); -status = ncmpi_enddef(ncid); -if (status != NC_NOERR) handle_error(status); -*/ - - /** - * Close the dataset - * Dataset API: collective - */ - - status = ncmpi_close(ncid); - if (status != NC_NOERR) handle_error(status); - - /******************* END OF NETCDF ACCESS ****************/ - -MPI_Barrier(MPI_COMM_WORLD); -TotalWriteTime = MPI_Wtime() - TotalWriteTime; - -if (rank == 0) { - fprintf(stderr, "OK\nFile written to: %s!\n", opts.outfname); - fprintf(stderr, "Total Write Time = %10.8f\n", TotalWriteTime); -} - - MPI_Finalize(); - return 0; -} - diff --git a/test/Legacy/test_int/test_write64.c b/test/Legacy/test_int/test_write64.c deleted file mode 100644 index e8718fda8..000000000 --- a/test/Legacy/test_int/test_write64.c +++ /dev/null @@ -1,255 +0,0 @@ -/*********************************************************** - * - * This test program writes a netCDF file using the parallel - * netCDF library using MPI-IO. - * - * The output file is: "testwrite.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * int square(x, y); - * squre: description = "2-D integer array"; - * - * int cube(x,y,z); - * - * int time(time); // coordinate & record variable - * - * int xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses collective APIs to write variable data and only - * deals with integer variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - - - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - fprintf(stderr, "%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - long long int i, j, k; - int status; - int ncid; - int dimid1, dimid2, dimid3, udimid; - int square_dim[2], cube_dim[3], xytime_dim[3], time_dim[1]; - MPI_Offset square_start[2], cube_start[3] = {0, 0, 0}; - MPI_Offset square_count[2] = {50, 50}, cube_count[3] = {100, 50, 50}; - MPI_Offset xytime_start[3] = {0, 0, 0}; - MPI_Offset xytime_count[3] = {100, 50, 50}; - MPI_Offset time_start[1], time_count[1] = {25}; - int square_id, cube_id, xytime_id, time_id; - static char title[] = "example netCDF dataset"; - static char description[] = "2-D integer array"; - int data[100][50][50], buffer[100]; - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - double TotalWriteTime; - params opts; - - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing write ... "); - parse_write_args(argc, argv, rank, &opts); - - MPI_Barrier(MPI_COMM_WORLD); - TotalWriteTime = MPI_Wtime(); - - /********** START OF NETCDF ACCESS **************/ - - /** - * Create the dataset - * File name: "testwrite.nc" - * Dataset API: Collective - */ - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER|NC_64BIT_DATA, MPI_INFO_NULL, &ncid); - if (status != NC_NOERR) handle_error(status); - - - /** - * Create a global attribute: - * :title = "example netCDF dataset"; - */ - - status = ncmpi_put_att_text (ncid, NC_GLOBAL, "title", - strlen(title), title); - if (status != NC_NOERR) handle_error(status); - - /** - * Add 4 pre-defined dimensions: - * x = 100, y = 100, z = 100, time = NC_UNLIMITED - */ - - status = ncmpi_def_dim(ncid, "x", 100L, &dimid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "y", 100L, &dimid2); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "z", 100L, &dimid3); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "time", NC_UNLIMITED, &udimid); - if (status != NC_NOERR) handle_error(status); - - /** - * Define the dimensionality and then add 4 variables: - * square(x, y), cube(x,y,z), time(time), xytime(time, x, y) - */ - - square_dim[0] = cube_dim[0] = xytime_dim[1] = dimid1; - square_dim[1] = cube_dim[1] = xytime_dim[2] = dimid2; - cube_dim[2] = dimid3; - xytime_dim[0] = udimid; - time_dim[0] = udimid; - status = ncmpi_def_var (ncid, "square", NC_INT, 2, square_dim, &square_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "cube", NC_INT, 3, cube_dim, &cube_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "time", NC_INT, 1, time_dim, &time_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "xytime", NC_INT, 3, xytime_dim, &xytime_id); - if (status != NC_NOERR) handle_error(status); - - /** - * Add an attribute for variable: - * square: decsription = "2-D integer array" - */ - - status = ncmpi_put_att_text (ncid, square_id, "description", - strlen(description), description); - if (status != NC_NOERR) handle_error(status); - - /** - * End Define Mode (switch to data mode) - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid); - if (status != NC_NOERR) handle_error(status); - MPI_Barrier(MPI_COMM_WORLD); - - /** - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, Block), 50*50 from 100*100 - * cube: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * xytime: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - */ - - square_start[0] = cube_start[1] = xytime_start[1] = (rank/2) * 50; - square_start[1] = cube_start[2] = xytime_start[2] = (rank%2) * 50; - time_start[0] = (rank%4) * 25; - - - /** - * Packing data in the buffer - */ - - /* Data for variable: time */ - for ( i = time_start[0]; i < time_start[0] + time_count[0]; i++ ) - buffer[i - time_start[0]] = i; - - /* Data for variable: square, cube and xytime */ - for ( i = 0; i < 100; i++ ) - for ( j = square_start[0]; j < square_start[0]+square_count[0]; j++ ) - for ( k = square_start[1]; k < square_start[1]+square_count[1]; k++ ) - data[i][j-square_start[0]][k-square_start[1]] = i*100*100 + j*100 + k; - - /** - * Write data into variables: square, cube, time and xytime - * Access Method: subarray - * Data Mode API: collective - */ - - status = ncmpi_put_vara_int_all(ncid, square_id, - square_start, square_count, - &data[0][0][0]); - MPI_Barrier(MPI_COMM_WORLD); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid, cube_id, - cube_start, cube_count, - &data[0][0][0]); - MPI_Barrier(MPI_COMM_WORLD); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid, time_id, - time_start, time_count, - buffer); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int_all(ncid, xytime_id, - xytime_start, xytime_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - -/* -status = ncmpi_sync(ncid); -if (status != NC_NOERR) handle_error(status); -status = ncmpi_redef(ncid); -if (status != NC_NOERR) handle_error(status); -status = ncmpi_del_att(ncid, square_id, "description"); -if (status != NC_NOERR) handle_error(status); -status = ncmpi_enddef(ncid); -if (status != NC_NOERR) handle_error(status); -*/ - - /** - * Close the dataset - * Dataset API: collective - */ - - status = ncmpi_close(ncid); - if (status != NC_NOERR) handle_error(status); - - /******************* END OF NETCDF ACCESS ****************/ - -MPI_Barrier(MPI_COMM_WORLD); -TotalWriteTime = MPI_Wtime() - TotalWriteTime; - -if (rank == 0) { - fprintf(stderr, "OK\nFile written to: %s!\n", opts.outfname); - fprintf(stderr, "Total Write Time = %10.8f\n", TotalWriteTime); -} - - MPI_Finalize(); - return 0; -} - diff --git a/test/Legacy/test_int/test_write_indep.c b/test/Legacy/test_int/test_write_indep.c deleted file mode 100644 index ade0418fb..000000000 --- a/test/Legacy/test_int/test_write_indep.c +++ /dev/null @@ -1,247 +0,0 @@ -/*********************************************************** - * - * This test program writes a netCDF file using the parallel - * netCDF library using MPI-IO. - * - * The output file is: "testwrite.nc" - * - * The CDL notation for the test dataset is shown below: - * - * netcdf test { - * - * dimensions: - * - * x = 100, y = 100, z = 100, time = NC_UNLIMITED; - * - * - * variables: // variable types, names, shapes, attributes - * - * int square(x, y); - * squre: description = "2-D integer array"; - * - * int cube(x,y,z); - * - * int time(time); // coordinate & record variable - * - * int xytime(time, x, y); // record variable - * - * - * // global attributes - * - * :title = "example netCDF dataset"; - * - * - * data: // data written for variables - * square = 0, 1, 2, 3, ... , 9999; - * cube = 0, 1, 2, 3, ... , 999999; - * time = 0, 1, 2, 3, ... , 99; // 100 records - * xytime = 0, 1, 2, 3, ... , 9999; // 100 records - * } - * - * - * - * This test uses non-collective APIs to write variable data and only - * deals with integer variables. - * - * This test assume # of processors = 4 - * - **********************************************************/ - - - -#include -#include -#include -#include -#include "testutils.h" - -/* Prototype for functions used only in this file */ -static void handle_error(int status); - -static void handle_error(int status) { - fprintf(stderr, "%s\n", ncmpi_strerror(status)); -} - -int main(int argc, char **argv) { - - int i, j, k; - int status; - int ncid; - int dimid1, dimid2, dimid3, udimid; - int square_dim[2], cube_dim[3], xytime_dim[3], time_dim[1]; - MPI_Offset square_start[2], cube_start[3] = {0, 0, 0}; - MPI_Offset square_count[2] = {50, 50}, cube_count[3] = {100, 50, 50}; - MPI_Offset xytime_start[3] = {0, 0, 0}; - MPI_Offset xytime_count[3] = {100, 50, 50}; - MPI_Offset time_start[1], time_count[1] = {25}; - int square_id, cube_id, xytime_id, time_id; - static char title[] = "example netCDF dataset"; - static char description[] = "2-D integer array"; - int data[100][50][50], buffer[100]; - int rank; - int nprocs; - MPI_Comm comm = MPI_COMM_WORLD; - params opts; - - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (rank == 0) - fprintf(stderr, "Testing independent write ... "); - parse_write_args(argc, argv, rank, &opts); - - /********** START OF NETCDF ACCESS **************/ - - /** - * Create the dataset - * File name: "testwrite.nc" - * Dataset API: Collective - */ - - status = ncmpi_create(comm, opts.outfname, NC_CLOBBER, MPI_INFO_NULL, &ncid); - if (status != NC_NOERR) handle_error(status); - - - /** - * Create a global attribute: - * :title = "example netCDF dataset"; - */ - - status = ncmpi_put_att_text (ncid, NC_GLOBAL, "title", - strlen(title), title); - if (status != NC_NOERR) handle_error(status); - - /** - * Add 4 pre-defined dimensions: - * x = 100, y = 100, z = 100, time = NC_UNLIMITED - */ - - status = ncmpi_def_dim(ncid, "x", 100L, &dimid1); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "y", 100L, &dimid2); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "z", 100L, &dimid3); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_dim(ncid, "time", NC_UNLIMITED, &udimid); - if (status != NC_NOERR) handle_error(status); - - /** - * Define the dimensionality and then add 4 variables: - * square(x, y), cube(x,y,z), time(time), xytime(time, x, y) - */ - - square_dim[0] = cube_dim[0] = xytime_dim[1] = dimid1; - square_dim[1] = cube_dim[1] = xytime_dim[2] = dimid2; - cube_dim[2] = dimid3; - xytime_dim[0] = udimid; - time_dim[0] = udimid; - status = ncmpi_def_var (ncid, "square", NC_INT, 2, square_dim, &square_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "cube", NC_INT, 3, cube_dim, &cube_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "time", NC_INT, 1, time_dim, &time_id); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_def_var (ncid, "xytime", NC_INT, 3, xytime_dim, &xytime_id); - if (status != NC_NOERR) handle_error(status); - - /** - * Add an attribute for variable: - * square: decsription = "2-D integer array" - */ - -/* - status = ncmpi_put_att_text (ncid, square_id, "description", - strlen(description), description); - if (status != NC_NOERR) handle_error(status); -*/ - - /** - * End Define Mode (switch to data mode) - * Dataset API: Collective - */ - - status = ncmpi_enddef(ncid); - if (status != NC_NOERR) handle_error(status); - - /** - * Data Partition (Assume 4 processors): - * square: 2-D, (Block, Block), 50*50 from 100*100 - * cube: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * xytime: 3-D, (*, Block, Block), 100*50*50 from 100*100*100 - * time: 1-D, Block-wise, 25 from 100 - */ - - square_start[0] = cube_start[1] = xytime_start[1] = (rank/2) * 50; - square_start[1] = cube_start[2] = xytime_start[2] = (rank%2) * 50; - time_start[0] = (rank%4) * 25; - - - /** - * Packing data in the buffer - */ - - /* Data for variable: time */ - for ( i = time_start[0]; i < time_start[0] + time_count[0]; i++ ) - buffer[i - time_start[0]] = i; - - /* Data for variable: square, cube and xytime */ - for ( i = 0; i < 100; i++ ) - for ( j = square_start[0]; j < square_start[0]+square_count[0]; j++ ) - for ( k = square_start[1]; k < square_start[1]+square_count[1]; k++ ) - data[i][j-square_start[0]][k-square_start[1]] = i*100*100 + j*100 + k; - - /** - * Write data into variables: square, cube, time and xytime - * Access Method: subarray - * Data Mode API: non-collective - */ - - status = ncmpi_begin_indep_data(ncid); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_put_vara_int(ncid, square_id, - square_start, square_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid, cube_id, - cube_start, cube_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid, time_id, - time_start, time_count, - buffer); - if (status != NC_NOERR) handle_error(status); - status = ncmpi_put_vara_int(ncid, xytime_id, - xytime_start, xytime_count, - &data[0][0][0]); - if (status != NC_NOERR) handle_error(status); - - status = ncmpi_end_indep_data(ncid); - if (status != NC_NOERR) handle_error(status); - -status = ncmpi_redef(ncid); -if (status != NC_NOERR) handle_error(status); -status = ncmpi_put_att_text (ncid, square_id, "description", - strlen(description), description); -if (status != NC_NOERR) handle_error(status); -status = ncmpi_enddef(ncid); -if (status != NC_NOERR) handle_error(status); - - /** - * Close the dataset - * Dataset API: collective - */ - - status = ncmpi_close(ncid); - if (status != NC_NOERR) handle_error(status); - - /******************* END OF NETCDF ACCESS ****************/ - -if (rank == 0) - fprintf(stderr, "OK\nFile written to: %s!\n", opts.outfname); - - MPI_Finalize(); - return 0; -} - diff --git a/test/testcases/Legacy/geopotential.ncdump b/test/testcases/Legacy/geopotential.ncdump deleted file mode 100644 index 511bef757..000000000 --- a/test/testcases/Legacy/geopotential.ncdump +++ /dev/null @@ -1,48 +0,0 @@ -netcdf r6_geopotential_19010101_100000 { -dimensions: - time = UNLIMITED ; // (3 currently) - cells = 40962 ; - cellneighbors = 6 ; - interfaces = 26 ; - cellcorners = 6 ; -variables: - double time(time) ; - time:long_name = "Time" ; - time:units = "days since 01-01-1901" ; - time:standard_name = "time" ; - time:calendar = "no leap year" ; - float grid_center_lat(cells) ; - grid_center_lat:long_name = "Latitude of cell center" ; - grid_center_lat:units = "radians" ; - grid_center_lat:standard_name = "latitude" ; - grid_center_lat:bounds = "grid_corner_lat" ; - float grid_center_lon(cells) ; - grid_center_lon:long_name = "Longitude of cell center" ; - grid_center_lon:units = "radians" ; - grid_center_lon:standard_name = "longitude" ; - grid_center_lon:bounds = "grid_corner_lon" ; - float area(cells) ; - area:long_name = "Cell area" ; - area:units = "square radians" ; - int cell_neighbors(cells, cellneighbors) ; - cell_neighbors:long_name = "List of neighbors to this cell" ; - cell_neighbors:units = "unitless" ; - float interfaces(interfaces) ; - interfaces:long_name = "Vertical interfaces, in terms of pressure" ; - interfaces:units = "Pa" ; - interfaces:positive = "down" ; - interfaces:axis = "Z" ; - float geopotential(time, cells, interfaces) ; - geopotential:long_name = "Geo Potential" ; - geopotential:units = "m**2/sec**2" ; - geopotential:coordinates = "grid_center_lat grid_center_lon" ; - float grid_corner_lat(cells, cellcorners) ; - grid_corner_lat:long_name = "Latitude of cell corner" ; - grid_corner_lat:units = "radians" ; - float grid_corner_lon(cells, cellcorners) ; - grid_corner_lon:long_name = "Longitude of cell corner" ; - grid_corner_lon:units = "radians" ; - -// global attributes: - :history = "Fri Jan 23 15:41:48 2009: ncks -v grid_corner_lat,grid_corner_lon wind_19010101_100000.nc -A geopotential_19010101_100000.nc" ; -} diff --git a/test/testcases/Legacy/interop1.sh b/test/testcases/Legacy/interop1.sh deleted file mode 100755 index b04fa0c4d..000000000 --- a/test/testcases/Legacy/interop1.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# a test to ensure we can work with files created by serial netcdf. does -# require both ncgen and ncdump to be in your path. - -# Step 0: see if we have the utilities in our path: - -which ncgen >/dev/null - -if [ $? -ne 0 ] ; then - echo "could not find 'ncgen' (from serial netcdf) in path. exiting" - exit 1 -fi - -which ncmpidump >/dev/null - -if [ $? -ne 0 ] ; then - echo "could not find 'ncmpidump' (from parallel-netcdf) in path. exiting" - exit 1 -fi - -OUTPUT=geo-${RANDOM}-${RANDOM}.nc -rm -f $OUTPUT - -# Step 1: create the file: -ncgen -b -v 2 -o $OUTPUT geopotential.ncdump - -# step 2: ensure we can at least parse the header -ncmpidump -h $OUTPUT >/dev/null - -if [ $? -ne 0 ] ; then - echo "error parsing generated netcdf file!" - exit 1 -else - echo " No Errors" - rm $OUTPUT - exit 0 -fi diff --git a/test/testcases/Legacy/redef1.sh b/test/testcases/Legacy/redef1.sh deleted file mode 100755 index b3b03602c..000000000 --- a/test/testcases/Legacy/redef1.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# quick test of re-entering define mode: the file created by ncmpigen and the -# file created by test program should be bit-for-bit identical, else there is -# an error - -if [ $# -ne 2 ] ; then - echo "usage: $0 " - echo "example: $0 redef1 redef-good.ncdump" - exit -1 -fi - -REFERENCE=redef1-a-${RANDOM}-${RANDOM}-${RANDOM}.nc - -# dataset via ncmpigen: -../../src/utils/ncmpigen/ncmpigen -v 2 -o $REFERENCE $2 - -# dataset via test -$1 - -# now compare - -diff $REFERENCE redef1.nc