mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-06 15:34:44 +08:00
4636584d5b
re: https://github.com/Unidata/netcdf-c/issues/1154 Inadvertently, the behavior of NC_DISKLESS with nc_create() was changed in release 4.6.1. Previously, the NC_WRITE flag needed to be explicitly used with NC_DISKLESS in order to cause the created file to be persisted to disk. Additional analyis indicated that the current NC_DISKLESS implementation was seriously flawed. This PR attempts to clean up and regularize the situation with respect to NC_DISKLESS control. One important aspect of diskless operation is that there are two different notions of write. 1. The file is read-write vs read-only when using the netcdf API. 2. The file is persisted or not to disk at nc_close(). Previously, these two were conflated. The rules now are as follows. 1. NC_DISKLESS + NC_WRITE means that the file is read/write using the netcdf API 2. NC_DISKLESS + NC_PERSIST means that the file is persisted to a disk file at nc_close. 3. NC_DISKLESS + NC_PERSIST + NC_WRITE means both 1 and 2. The NC_PERSIST flag is new and takes over the obsolete NC_MPIPOSIX flag. NC_MPIPOSIX is still defined, but is now an alias for the NC_MPIIO flag. It is also now the case that for netcdf-4, NC_DISKLESS is independent of NC_INMEMORY and in fact it is an error to specify both flags simultaneously. Finally, the MMAP code was fixed to use NC_PERSIST as well. Also marked MMAP as deprecated. Also added a test case to test various combinations of NC_DISKLESS, NC_PERSIST, and NC_WRITE. This PR affects a number of files and especially test cases that used NC_DISKLESS. Misc. Unrelated fixes 1. fixed some warnings in ncdump/dumplib.c
120 lines
2.8 KiB
Bash
Executable File
120 lines
2.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
|
. ../test_common.sh
|
|
|
|
set -e
|
|
|
|
# Get the target OS and CPU
|
|
CPU=`uname -p`
|
|
OS=`uname`
|
|
|
|
#Constants
|
|
FILE1=tst_diskless.nc
|
|
FILE2=tst_diskless2.nc
|
|
FILE3=tst_diskless3.nc
|
|
|
|
echo ""
|
|
echo "*** Testing in-memory (diskless) files with and without persistence"
|
|
|
|
HASNC4=`${top_builddir}/nc-config --has-nc4`
|
|
|
|
echo "**** Test diskless netCDF classic file without persistence"
|
|
${execdir}/tst_diskless
|
|
echo "PASS: diskless netCDF classic file without persistence"
|
|
|
|
if test "x$HASNC4" = "xyes" ; then
|
|
echo ""
|
|
echo "**** Test diskless netCDF enhanced file without persistence"
|
|
${execdir}/tst_diskless netcdf4
|
|
echo "PASS: diskless netCDF enhanced file without persistence"
|
|
fi #HASNC4
|
|
|
|
echo ""
|
|
echo "**** Test diskless netCDF classic file with persistence"
|
|
rm -f $FILE1
|
|
${execdir}/tst_diskless persist
|
|
if test -f $FILE1 ; then
|
|
echo "**** $FILE1 created"
|
|
# ${NCDUMP} $FILE1
|
|
echo "PASS: diskless netCDF classic file with persistence"
|
|
else
|
|
echo "#### $FILE1 not created"
|
|
echo "FAIL: diskless netCDF classic file with persistence"
|
|
fi
|
|
|
|
if test "x$HASNC4" = "xyes" ; then
|
|
echo ""
|
|
echo "**** Test diskless netCDF enhanced file with persistence"
|
|
rm -f $FILE1
|
|
${execdir}/tst_diskless netcdf4 persist
|
|
if test -f $FILE1 ; then
|
|
echo "**** $FILE1 created"
|
|
# ${NCDUMP} $FILE1
|
|
echo "PASS: diskless netCDF enhanced file with persistence"
|
|
else
|
|
echo "$FILE1 not created"
|
|
echo "FAIL: diskless netCDF enhanced file with persistence"
|
|
fi
|
|
|
|
fi #HASNC4
|
|
|
|
# Do extended netcdf enhanced test
|
|
if test "x$HASNC4" = "xyes" ; then
|
|
|
|
ok=""
|
|
echo ""
|
|
echo "**** Test extended enhanced diskless netCDF with persistence"
|
|
rm -f $FILE2 tst_diskless2.cdl
|
|
${execdir}/tst_diskless2
|
|
if test -f $FILE2 ; then
|
|
echo "**** $FILE2 created"
|
|
# Do a cyle test
|
|
if ${NCDUMP} $FILE2 |sed -e s/tst_diskless2/tmp1/ > tmp1.cdl ; then
|
|
if ${NCGEN} -k nc4 -o tmp1.nc tmp1.cdl ;then
|
|
if ${NCDUMP} tmp1.nc >tmp2.cdl ; then
|
|
if diff -wb tmp1.cdl tmp2.cdl ; then
|
|
ok=yes
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
else
|
|
echo "#### $FILE2 not created"
|
|
fi
|
|
rm -f tmp1.cdl tmp2.cdl tmp1.nc tmp2.nc
|
|
|
|
if test "x$ok" = xyes ; then
|
|
echo "PASS: extended enhanced diskless netCDF with persistence"
|
|
else
|
|
echo "FAIL: extended enhanced diskless netCDF with persistence"
|
|
fi
|
|
|
|
fi #HASNC4
|
|
|
|
echo ""
|
|
echo "**** Testing nc_open in-memory (diskless) files"
|
|
|
|
# clear old files
|
|
rm -f tst_diskless3_file.cdl tst_diskless3_memory.cdl
|
|
|
|
echo ""
|
|
echo "**** Create baseline cdl"
|
|
rm -f $FILE3
|
|
${execdir}/tst_diskless3 file
|
|
${NCDUMP} $FILE3 >tst_diskless3_file.cdl
|
|
|
|
echo ""
|
|
echo "**** Create and modify file using diskless"
|
|
rm -f $FILE3
|
|
${execdir}/tst_diskless3 diskless persist
|
|
${NCDUMP} $FILE3 >tst_diskless3_memory.cdl
|
|
|
|
# compare
|
|
diff tst_diskless3_file.cdl tst_diskless3_memory.cdl
|
|
|
|
# cleanup
|
|
rm -f $FILE3 tst_diskless3_file.cdl tst_diskless3_memory.cdl
|
|
|
|
exit 0
|