Skip to content
Permalink
Browse files

adding compatibility with NETCDF 4 files based on HDF5

  • Loading branch information...
jbeezley committed Oct 15, 2010
1 parent 5d75966 commit 06c276f324873bc4c6f82c27298430435989ab97
@@ -56,7 +56,7 @@ REGISTRY = Registry
#NOWIN LIB_EXTERNAL = \
#NOWIN CONFIGURE_NETCDF_LIB_PATH CONFIGURE_PNETCDF_LIB_PATH CONFIGURE_GRIB2_LIB CONFIGURE_ATMPOM_LIB

LIB = $(LIB_BUNDLED) $(LIB_EXTERNAL) $(LIB_LOCAL)
LIB = $(LIB_BUNDLED) $(LIB_EXTERNAL) $(LIB_LOCAL) $(WRFIO_NETCDF_LINKOPTS)
LDFLAGS = $(OMP) $(FCFLAGS) $(LDFLAGS_LOCAL) CONFIGURE_LDFLAGS
ENVCOMPDEFS = CONFIGURE_COMPILEFLAGS
CPPFLAGS = $(ARCHFLAGS) $(ENVCOMPDEFS) -I$(LIBINCLUDE) $(TRADFLAG) CONFIGURE_COMMS_INCLUDE
@@ -513,6 +513,12 @@ if test -n $NETCDF ; then
echo " support in NetCDF, set the environment variable WRFIO_NCD_LARGE_FILE_SUPPORT"
echo " to 1 and run configure again. Set to any other value to avoid this message."
fi
if test -f $NETCDF/bin/nc-config ; then
if test -z "$WRFIO_NETCDF4_LINKOPTS" ; then
WRFIO_NETCDF_LINKOPTS=`$NETCDF/bin/nc-config --flibs`
echo "WRFIO_NETCDF_LINKOPTS=$WRFIO_NETCDF_LINKOPTS" >> configure.wrf
fi
fi
fi
echo " "

@@ -4,7 +4,7 @@ OBJSL = wrf_io.o field_routines.o module_wrfsi_static.o
OBJS = $(OBJSL)
CODE = ext_ncd_get_dom_ti.code ext_ncd_get_var_td.code ext_ncd_get_var_ti.code ext_ncd_put_dom_ti.code ext_ncd_put_var_td.code ext_ncd_put_var_ti.code transpose.code
FFLAGS = $(FCFLAGS) -I$(NETCDFPATH)/include -I../ioapi_share
LIBS = -L$(NETCDFPATH)/lib -lnetcdf
LIBS = -L$(NETCDFPATH)/lib -lnetcdf $(shell $(NETCDFPATH)/bin/nc-config --flibs 2> /dev/null)
CPP1 = $(CPP) -C -P $(TRADFLAG)
M4 = m4 -Uinclude -Uindex -Ulen
AR = ar
@@ -27,6 +27,19 @@ wrf_io.o: wrf_io.F90 $(CODE)
a=$$? ; export a ; \
if [ $$a -a "$$WRFIO_NCD_LARGE_FILE_SUPPORT" = "1" ] ; then \
$(CPP1) -DWRFIO_NCD_LARGE_FILE_SUPPORT -I../ioapi_share wrf_io.F90 | $(M4) - > wrf_io.f ; \
elif [ "$$WRFIO_NETCDF4_FILE_SUPPORT" = "1" ] ; then \
if test -z "$$WRFIO_NETCDF4_GZIP_LEVEL" ; then \
WRFIO_NETCDF4_GZIP_LEVEL=0 ; \
fi ; \
if [ "$$WRFIO_NETCDF4_GZIP_LEVEL" -gt 0 -a -z "$$WRFIO_NETCDF4_SHUFFLE" ] ; then \
WRFIO_NETCDF4_SHUFFLE=1 ; \
else \
WRFIO_NETCDF4_SHUFFLE=0 ; \
fi ; \
$(CPP1) -DWRFIO_NETCDF4_FILE_SUPPORT \
-DWRFIO_NETCDF4_GZIP_LEVEL="$$WRFIO_NETCDF4_GZIP_LEVEL" \
-DWRFIO_NETCDF4_SHUFFLE="$$WRFIO_NETCDF4_SHUFFLE" \
-I../ioapi_share wrf_io.F90 | $(M4) - > wrf_io.f ; \
else \
$(CPP1) -I../ioapi_share wrf_io.F90 | $(M4) - > wrf_io.f ; \
fi
@@ -1279,10 +1279,16 @@ SUBROUTINE ext_ncd_open_for_write_begin(FileName,Comm,IOComm,SysDepInfo,DataHand
endif
DH%TimeIndex = 0
DH%Times = ZeroDate
#ifdef WRFIO_NETCDF4_FILE_SUPPORT
stat = NF_CREATE(FileName, IOR(NF_CLOBBER,NF_NETCDF4), DH%NCID)
#else

#ifdef WRFIO_NCD_LARGE_FILE_SUPPORT
stat = NF_CREATE(FileName, IOR(NF_CLOBBER,NF_64BIT_OFFSET), DH%NCID)
#else
stat = NF_CREATE(FileName, NF_CLOBBER, DH%NCID)
#endif

#endif
call netcdf_err(stat,Status)
if(Status /= WRF_NO_ERR) then
@@ -2518,6 +2524,30 @@ subroutine ext_ncd_write_field(DataHandle,DateStr,Var,Field,FieldTypeIn, &
call wrf_debug ( WARN , TRIM(msg))
return
endif

#ifdef WRFIO_NETCDF4_FILE_SUPPORT

#ifdef WRFIO_NETCDF4_GZIP_LEVEL

#ifndef WRFIO_NETCDF4_SHUFFLE
#define WRFIO_NETCDF4_SHUFFLE 1
#endif

stat = NF_DEF_VAR_DEFLATE(NCID,VarID,WRFIO_NETCDF4_SHUFFLE,1,WRFIO_NETCDF4_GZIP_LEVEL)
call netcdf_err(stat,Status)
if(Status /= WRF_NO_ERR) then
write(msg,*) 'ext_ncd_write_field: NetCDF error for ',TRIM(VarName),' in ',__FILE__,', line', __LINE__
call wrf_debug( WARN, TRIM(msg))
write(msg,*), 'ext_ncd_write_field: Error calling NF_DEF_VAR_DEFLATE with level ', &
WRFIO_NETCDF4_GZIP_LEVEL,', shuffle ',WRFIO_NETCDF4_SHUFFLE
call wrf_debug( WARN, TRIM(msg))
return
endif

#endif

#endif

DH%VarIDs(NVar) = VarID
stat = NF_PUT_ATT_INT(NCID,VarID,'FieldType',NF_INT,1,FieldType)
call netcdf_err(stat,Status)

0 comments on commit 06c276f

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.