diff --git a/include/nc_tests.h b/include/nc_tests.h index 731123616..f4f815057 100644 --- a/include/nc_tests.h +++ b/include/nc_tests.h @@ -29,6 +29,11 @@ int total_err = 0, err = 0; char *format_name[] = {"", "classic", "64-bit offset", "netCDF-4", "netCDF-4 classic model"}; +#define BAIL(e) do { \ +printf ("Bailing out in file %s, line %d, error:%s.\n", __FILE__, __LINE__, nc_strerror(e)); \ +return -1; \ +} while (0) + /* This macro prints an error message with line number and name of * test program. */ #define ERR do { \ diff --git a/nc_test4/cdm_sea_soundings.c b/nc_test4/cdm_sea_soundings.c index a641e1052..3fe2511db 100644 --- a/nc_test4/cdm_sea_soundings.c +++ b/nc_test4/cdm_sea_soundings.c @@ -7,7 +7,7 @@ $Id: cdm_sea_soundings.c,v 1.5 2010/05/25 13:53:04 ed Exp $ */ -#include +#include #define FILE_NAME "cdm_sea_soundings.nc" #define DIM_NAME "Sounding" diff --git a/nc_test4/tests.h b/nc_test4/tests.h deleted file mode 100644 index 1b48f0cd9..000000000 --- a/nc_test4/tests.h +++ /dev/null @@ -1,66 +0,0 @@ -/* This is part of the netCDF package. - Copyright 2005 University Corporation for Atmospheric Research/Unidata - See COPYRIGHT file for conditions of use. - - Common includes, defines, etc., for test code in the nc_test4 - directory. - - $Id: tests.h,v 1.6 2010/05/25 13:53:04 ed Exp $ -*/ -#ifndef _NC_TEST4_TESTS_ -#define _NC_TEST4_TESTS_ - -#include -#include -#include -#include -#include - -#ifdef USE_PARALLEL -#include -#include -#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ -#include -#endif -#endif -#include - -int total_err = 0, err = 0; - -/* This is handy for print statements. */ -char *format_name[] = {"", "classic", "64-bit offset", "netCDF-4", "netCDF-4 strict NC3"}; - -#define BAIL(e) do { \ -printf ("Bailing out in file %s, line %d, error:%s.\n", __FILE__, __LINE__, nc_strerror(e)); \ -return -1; \ -} while (0) - -#define ERR do { \ -fflush(stdout); /* Make sure our stdout is synced with stderr. */ \ -err++; \ -fprintf(stderr, "unexpected result, %s, line: %d\n", __FILE__, __LINE__); \ -} while (0) - -#define SUMMARIZE_ERR do { \ - if (err) \ - { \ - printf("%d failures\n", err); \ - total_err += err; \ - err = 0; \ - } \ - else \ - printf("ok.\n"); \ -} while (0) - -/* Print out our number of errors, if any, and exit badly. */ -#define FINAL_RESULTS do { \ - if (total_err) \ - { \ - printf("%d errors detected! Sorry!\n", total_err); \ - return 2; \ - } \ - printf("*** Tests successful!\n"); \ - return 0; \ -} while (0) - -#endif /* _NC_TEST4_TESTS_ */ diff --git a/nc_test4/tst_mpi_parallel.c b/nc_test4/tst_mpi_parallel.c index 434961cba..de76c5958 100644 --- a/nc_test4/tst_mpi_parallel.c +++ b/nc_test4/tst_mpi_parallel.c @@ -7,7 +7,7 @@ $Id: tst_mpi_parallel.c,v 1.2 2009/08/19 15:58:57 ed Exp $ */ -#include "tests.h" +#include #include #define FILE "tst_mpi_parallel.bin" diff --git a/nc_test4/tst_nc4perf.c b/nc_test4/tst_nc4perf.c index 5d1200429..47af70ef7 100644 --- a/nc_test4/tst_nc4perf.c +++ b/nc_test4/tst_nc4perf.c @@ -9,7 +9,7 @@ Dennis Nadeau. $Id: tst_nc4perf.c,v 1.4 2009/08/19 15:58:57 ed Exp $ */ -#include "tests.h" +#include "nc_tests.h" #define FILENAME "tst_nc4perf.nc" #define NDIMS1 2 diff --git a/nc_test4/tst_parallel.c b/nc_test4/tst_parallel.c index 7d5cfae8c..831397850 100644 --- a/nc_test4/tst_parallel.c +++ b/nc_test4/tst_parallel.c @@ -13,7 +13,7 @@ $Id: tst_parallel.c,v 1.7 2009/08/19 15:58:57 ed Exp $ * clog2TOslog2) and then used in the analysis program jumpshot. */ /*#define USE_MPE 1*/ -#include "tests.h" +#include #include #ifdef USE_MPE #include diff --git a/nc_test4/tst_parallel2.c b/nc_test4/tst_parallel2.c index 8c324509f..1df22b75a 100644 --- a/nc_test4/tst_parallel2.c +++ b/nc_test4/tst_parallel2.c @@ -9,7 +9,7 @@ * clog2TOslog2) and then used in the analysis program jumpshot. */ /*#define USE_MPE 1*/ -#include "tests.h" +#include #include #include diff --git a/nc_test4/tst_parallel3.c b/nc_test4/tst_parallel3.c index a1ff30754..5187fcaf1 100644 --- a/nc_test4/tst_parallel3.c +++ b/nc_test4/tst_parallel3.c @@ -18,7 +18,7 @@ * */ -#include "tests.h" +#include #define FILE_NAME "tst_parallel3.nc" diff --git a/nc_test4/tst_parallel4.c b/nc_test4/tst_parallel4.c index f31d6e498..7e3bb1a63 100644 --- a/nc_test4/tst_parallel4.c +++ b/nc_test4/tst_parallel4.c @@ -9,7 +9,7 @@ * clog2TOslog2) and then used in the analysis program jumpshot. */ /*#define USE_MPE 1*/ -#include "tests.h" +#include #include #ifdef USE_MPE #include diff --git a/nf_test/Makefile.am b/nf_test/Makefile.am index 7c0af8d8d..6d9f03ed9 100644 --- a/nf_test/Makefile.am +++ b/nf_test/Makefile.am @@ -149,13 +149,12 @@ endif #BUILD_BENCHMARKS # Test parallel I/O. if TEST_PARALLEL check_PROGRAMS += f90tst_parallel f90tst_parallel2 f90tst_parallel3 \ -f90tst_nc4_par f90tst_nc4_par1 +f90tst_nc4_par #f90tst_parallel_fill f90tst_parallel_SOURCES = f90tst_parallel.f90 f90tst_parallel2_SOURCES = f90tst_parallel2.f90 f90tst_parallel3_SOURCES = f90tst_parallel3.f90 f90tst_nc4_par_SOURCES = f90tst_nc4_par.f90 -f90tst_nc4_par1_SOURCES = f90tst_nc4_par1.f90 #f90tst_parallel_fill_SOURCES = f90tst_parallel_fill.f90 TESTS += run_f90_par_test.sh CLEANFILES += f90tst_parallel*.nc diff --git a/nf_test/f90tst_nc4_par.f90 b/nf_test/f90tst_nc4_par.f90 new file mode 100644 index 000000000..4f3daa771 --- /dev/null +++ b/nf_test/f90tst_nc4_par.f90 @@ -0,0 +1,82 @@ +! This parallel test was contributed by Jim Edwards at UCAR. Thanks Jim! +program f90tst_nc4_par + use netcdf + use mpi + implicit none + + character (len = *), parameter :: FILE_NAME = "f90tst_nc4_par.nc" + integer :: nmode, ierr, fh, my_task, nprocs, i, varid + integer :: dimid(3), start(3), count(3) + real :: f(3) + + + call MPI_INIT(ierr) + call MPI_COMM_RANK(MPI_COMM_WORLD, my_task, ierr) + call MPI_COMM_SIZE(MPI_COMM_WORLD, nprocs, ierr) + + if(nprocs/=8)then + stop 'requires 8 tasks' + end if + + + nmode = ior(NF90_CLOBBER,NF90_NETCDF4) + nmode = IOR(nmode, nf90_mpiio) + + call handle_err(nf90_create(FILE_NAME, nmode, fh, & + comm = MPI_COMM_WORLD, info = MPI_INFO_NULL)) + + call handle_err(nf90_set_fill(fh, NF90_NOFILL, nmode)) + + + call handle_err(nf90_def_dim(fh, 'dim1', 6, dimid(1))) + call handle_err(nf90_def_dim(fh, 'dim2', 4, dimid(2))) + call handle_err(nf90_def_dim(fh, 'dim3', 1, dimid(3))) + + + call handle_err(nf90_def_var(fh, 'var1', NF90_DOUBLE, dimid, varid)) + call handle_err(nf90_enddef(fh)) + + + do i=1,3 + f(i) = my_task*3+i + end do + + count = (/3,1,1/) + start(1) = mod(my_task,2)*3+1 + start(2) = my_task/2+1 + start(3) = 1 + + print *,my_task, start, count, f + + call handle_err(nf90_put_var(fh, varid, f,start=start,count=count)) + + call handle_err(nf90_close(fh)) + + ! Reopen the file and check it. + call handle_err(nf90_open(FILE_NAME, NF90_MPIIO, fh, & + comm = MPI_COMM_WORLD, info = MPI_INFO_NULL)) + + call handle_err(nf90_get_var(fh, varid, f, start=start, count=count)) + do i=1,3 + if (f(i) .ne. my_task*3+i) stop 3 + end do + + call handle_err(nf90_close(fh)) + call MPI_Finalize(ierr) + +contains + ! This subroutine handles errors by printing an error message and + ! exiting with a non-zero status. + subroutine handle_err(errcode) + use netcdf + implicit none + integer, intent(in) :: errcode + + if(errcode /= nf90_noerr) then + print *, 'Error: ', trim(nf90_strerror(errcode)) + stop 2 + endif + end subroutine handle_err + +end program f90tst_nc4_par + diff --git a/nf_test/ftst_parallel.F b/nf_test/ftst_parallel.F index 52308849b..e6f171075 100644 --- a/nf_test/ftst_parallel.F +++ b/nf_test/ftst_parallel.F @@ -22,10 +22,9 @@ integer NUM_PROC parameter (NUM_PROC = 4) integer ncid, varid, dimids(MAX_DIMS) - integer x_dimid, y_dimid, contig + integer x_dimid, y_dimid integer data_out(NY / 2, NX / 2), data_in(NY / 2, NX / 2) integer mode_flag - integer nvars, ngatts, ndims, unlimdimid, file_format integer x, y, retval integer p, my_rank, ierr integer start(MAX_DIMS), count(MAX_DIMS)