Codebase list r-cran-rnetcdf / upstream/latest
New upstream version 2.1-1 Andreas Tille 4 years ago
21 changed file(s) with 337 addition(s) and 207 deletion(s). Raw diff Collapse all Expand all
00 Package: RNetCDF
1 Version: 2.0-3
2 Date: 2019-10-05
3 Title: Interface to NetCDF Datasets
1 Version: 2.1-1
2 Date: 2019-10-18
3 Title: Interface to 'NetCDF' Datasets
44 Authors@R: c(person("Pavel", "Michna", role = "aut",
55 email = "rnetcdf-devel@bluewin.ch"),
66 person("Milton", "Woods", role = c("aut", "cre"),
88 Depends: R (>= 3.0.0)
99 SystemRequirements: netcdf udunits-2
1010 Suggests: bit64
11 Description: An interface to the NetCDF file format designed by Unidata
11 Description: An interface to the 'NetCDF' file formats designed by Unidata
1212 for efficient storage of array-oriented scientific data and descriptions.
13 This R interface is closely based on the C API of the NetCDF4 library,
14 and it includes calendar conversions from the Unidata UDUNITS2 library.
13 Most capabilities of 'NetCDF' version 4 are supported. Optional conversions
14 of time units are enabled by 'UDUNITS' version 2, also from Unidata.
1515 License: GPL (>= 2) | file LICENSE
1616 URL: https://github.com/mjwoods/RNetCDF
1717 http://www.unidata.ucar.edu/software/netcdf/
1818 http://www.unidata.ucar.edu/software/udunits/
1919 BugReports: https://github.com/mjwoods/RNetCDF/issues
2020 NeedsCompilation: yes
21 Packaged: 2019-10-05 22:44:39 UTC; mwoods
21 Packaged: 2019-10-19 08:59:31 UTC; mwoods
2222 Author: Pavel Michna [aut],
2323 Milton Woods [aut, cre]
2424 Maintainer: Milton Woods <miltonjwoods@gmail.com>
2525 Repository: CRAN
26 Date/Publication: 2019-10-08 07:10:02 UTC
26 Date/Publication: 2019-10-20 07:20:11 UTC
3838 =====================
3939
4040 R CMD INSTALL --configure-args="CPPFLAGS=-I/sw/include \
41 LDFLAGS=-L/sw/lib LIBS=-lhdf5" RNetCDF_2.0-3.tar.gz
41 LDFLAGS=-L/sw/lib LIBS=-lhdf5" RNetCDF_2.1-1.tar.gz
4242
4343
4444 LD_LIBRARY_PATH
6767 ===================
6868
6969 R CMD check --install-args="--configure-args='CPPFLAGS=-I/sw/include \
70 LDFLAGS=-L/sw/lib'" RNetCDF_2.0-3.tar.gz
70 LDFLAGS=-L/sw/lib'" RNetCDF_2.1-1.tar.gz
7171
7272
7373 Time units
+20
-20
MD5 less more
00 b234ee4d69f5fce4486a80fdaf4a4263 *COPYING
1 449179fe269f50d0d79eaa4815066cfe *DESCRIPTION
2 136914770d3e4026d18b3dd49d588038 *INSTALL
1 b89039bd7dafb780af33bbd049af8d3e *DESCRIPTION
2 18f138b6e63657f37e2ac2dfc2507f23 *INSTALL
33 a65f65191aacb737b62d6e354faf6b4e *LICENSE
44 537ae4d17831bfa5e4bb053c53bcd933 *NAMESPACE
5 838f80f0df2e2ffc53353406cf2a2727 *NEWS
5 fde09d0f394474aee5a0ba3f1294502b *NEWS
66 899c70973b35f89c7a048b87a6cadb31 *R/RNetCDF.R
77 900ad9ec5d6b3f465f65621c2ac90b3f *R/load.R
88 3ee2d313b01e8c75dd118451997b2fee *README.md
99 a38544db104bdfa10be73ab380052d1e *cleanup
10 a35141ee27726142c26e1933f6fc9952 *configure
11 aa8739f3b4023474443d221708c10bd5 *configure.ac
10 e0952877b15035d3c52d9354f4477230 *configure
11 8e1d722d55807ec1eda95a4900dbbc58 *configure.ac
1212 d41d8cd98f00b204e9800998ecf8427e *configure.win
1313 5bac89bca74222d4bb68c09e5981202d *inst/udunits/udunits2.xml
1414 05c4596a4b2d91c91a8a878ec641c169 *man/00RNetCDF.Rd
4242 10b6bd5b00a98838be31d23035c7d48a *man/var.put.nc.Rd
4343 4abff3b45abf39350509758c00433787 *man/var.rename.nc.Rd
4444 6cc969080e30d435ab12eb4cd6b30180 *src/Makevars.in
45 198fecb1d4ef6972d4219bfd753b0baf *src/Makevars.win
46 9c94e213207fd74eb35c982ab9a3b272 *src/RNetCDF.h
47 5916c894d8c90846f42bc26b480420ee *src/attribute.c
48 756b51dc456dca5d679ca8314a270bda *src/common.c
49 a69e6993a641eecf67af049aee6f1b47 *src/common.h
50 198ee6dee9b5416207de07d1a62b0427 *src/convert.c
51 2d0cabec60534512cb8b3848279596f2 *src/convert.h
52 890dc27d97d27597786767db994ed692 *src/dataset.c
53 ae1849efb37a762d375769f115658d1f *src/dimension.c
54 b81c14cd7be97293b8a70a4f76f4fdf6 *src/group.c
55 1bf8e53806d91d0d3cfb13e6cd5591ea *src/init.c
56 ebc3c34618f8858e4e408b079ac5632f *src/type.c
57 438526f6dcbe08248bdf473a71c9cb3e *src/udunits.c
58 692567db12760d150ea589a334e432dd *src/variable.c
59 ee932d4c585f85e7cb4e9e38f0f89340 *tests/RNetCDF-test.R
45 37b01015145664927959b56a1b82a4cd *src/Makevars.win
46 d6261a0184183dccb6558ead351e9108 *src/RNetCDF.h
47 d5c46cdd5b4d3ee52051438777f67f93 *src/attribute.c
48 0beda9a493f5e9acb5d32440c840b18d *src/common.c
49 70e91b6f756df48f6119e886865ecab5 *src/common.h
50 cc9335fd4f012e138e71ae8acb5a0e3d *src/convert.c
51 cfb9f41418e87ece79a6a7a894c774ed *src/convert.h
52 f28b44ca0f78e990b95b3e2326627604 *src/dataset.c
53 328d1274c24456401bd77dd1042a2f2d *src/dimension.c
54 8d1d415642b07edc9c17a216930ec42f *src/group.c
55 f278b50c8764beafff3556f6df8a7236 *src/init.c
56 380df8dfcd53391b00d090e7410f69a3 *src/type.c
57 892998a4f14e30050120e4c7f9fbdd1a *src/udunits.c
58 eb7d81ed7fb7c32c7172a3dbc59d8d31 *src/variable.c
59 d2159dbfee3f7709f0856eb17baabde7 *tests/RNetCDF-test.R
6060 b501f8ce4175db84ae9b49d876742144 *tools/winlibs.R
0 Version 2.1-1, 2019-10-18
1 * Remove automatic handling of fill values in user-defined types
2 * Link rwinlib libraries by pathname to fix r-hub Windows builds
3 * Correct quoting of external software names in DESCRIPTION
4
5 Version 2.0-4, 2019-10-13
6 * Fix OSX packages by linking expat library
7
08 Version 2.0-3, 2019-10-05
19 * Support NetCDF-4 features for reading and writing of datasets.
210 * Suggest bit64 package for NC_INT64 and NC_UINT64 types.
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69 for RNetCDF 2.0-3.
2 # Generated by GNU Autoconf 2.69 for RNetCDF 2.1-1.
33 #
44 #
55 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
576576 # Identity of this package.
577577 PACKAGE_NAME='RNetCDF'
578578 PACKAGE_TARNAME='rnetcdf'
579 PACKAGE_VERSION='2.0-3'
580 PACKAGE_STRING='RNetCDF 2.0-3'
579 PACKAGE_VERSION='2.1-1'
580 PACKAGE_STRING='RNetCDF 2.1-1'
581581 PACKAGE_BUGREPORT=''
582582 PACKAGE_URL=''
583583
12221222 # Omit some internal or obsolete options to make the list less imposing.
12231223 # This message is too long to be a string in the A/UX 3.1 sh.
12241224 cat <<_ACEOF
1225 \`configure' configures RNetCDF 2.0-3 to adapt to many kinds of systems.
1225 \`configure' configures RNetCDF 2.1-1 to adapt to many kinds of systems.
12261226
12271227 Usage: $0 [OPTION]... [VAR=VALUE]...
12281228
12831283
12841284 if test -n "$ac_init_help"; then
12851285 case $ac_init_help in
1286 short | recursive ) echo "Configuration of RNetCDF 2.0-3:";;
1286 short | recursive ) echo "Configuration of RNetCDF 2.1-1:";;
12871287 esac
12881288 cat <<\_ACEOF
12891289
13681368 test -n "$ac_init_help" && exit $ac_status
13691369 if $ac_init_version; then
13701370 cat <<\_ACEOF
1371 RNetCDF configure 2.0-3
1371 RNetCDF configure 2.1-1
13721372 generated by GNU Autoconf 2.69
13731373
13741374 Copyright (C) 2012 Free Software Foundation, Inc.
17331733 This file contains any messages produced by compilers while
17341734 running configure, to aid debugging if configure makes a mistake.
17351735
1736 It was created by RNetCDF $as_me 2.0-3, which was
1736 It was created by RNetCDF $as_me 2.1-1, which was
17371737 generated by GNU Autoconf 2.69. Invocation command line was
17381738
17391739 $ $0 $@
20872087 #-------------------------------------------------------------------------------#
20882088
20892089 : ${R_HOME=`R RHOME`}
2090 if test -z "${R_HOME}"; then
2091 echo "could not determine R_HOME"
2092 exit 1
2090 if test -z "${R_HOME}"; then :
2091 as_fn_error $? "could not determine R_HOME" "$LINENO" 5
2092
20932093 fi
20942094 CC=`"${R_HOME}/bin/R" CMD config CC`
20952095 CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
33703370 _ACEOF
33713371
33723372 else
3373 as_fn_error $? "\"netcdf.h was not compiled - defining CPPFLAGS may help\"" "$LINENO" 5
3373 as_fn_error $? "netcdf.h was not compiled - defining CPPFLAGS may help" "$LINENO" 5
33743374 fi
33753375
33763376 done
34333433 test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
34343434
34353435 else
3436 as_fn_error $? "\"netcdf library was not linked - defining LDFLAGS may help\"" "$LINENO" 5
3436 as_fn_error $? "netcdf library was not linked - defining LDFLAGS may help" "$LINENO" 5
34373437 fi
34383438
34393439
34563456 # Find UDUNITS2 library and header files #
34573457 #-------------------------------------------------------------------------------#
34583458
3459 # Prepend the library to LIBS if it is not already being linked,
3460 # and define preprocessor macro HAVE_LIBUDUNITS2.
3461 # Also search for udunits2.h,
3462 # and define macro HAVE_UDUNITS2_H or HAVE_UDUNITS2_UDUNITS2_H accordingly.
3463 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ut_decode_time" >&5
3464 $as_echo_n "checking for library containing ut_decode_time... " >&6; }
3465 if ${ac_cv_search_ut_decode_time+:} false; then :
3459 # The udunits2 library depends on expat, which may need to be linked explicitly:
3460 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing XML_ErrorString" >&5
3461 $as_echo_n "checking for library containing XML_ErrorString... " >&6; }
3462 if ${ac_cv_search_XML_ErrorString+:} false; then :
34663463 $as_echo_n "(cached) " >&6
34673464 else
34683465 ac_func_search_save_LIBS=$LIBS
34753472 #ifdef __cplusplus
34763473 extern "C"
34773474 #endif
3478 char ut_decode_time ();
3475 char XML_ErrorString ();
34793476 int
34803477 main ()
34813478 {
3482 return ut_decode_time ();
3479 return XML_ErrorString ();
3480 ;
3481 return 0;
3482 }
3483 _ACEOF
3484 for ac_lib in '' expat; do
3485 if test -z "$ac_lib"; then
3486 ac_res="none required"
3487 else
3488 ac_res=-l$ac_lib
3489 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
3490 fi
3491 if ac_fn_c_try_link "$LINENO"; then :
3492 ac_cv_search_XML_ErrorString=$ac_res
3493 fi
3494 rm -f core conftest.err conftest.$ac_objext \
3495 conftest$ac_exeext
3496 if ${ac_cv_search_XML_ErrorString+:} false; then :
3497 break
3498 fi
3499 done
3500 if ${ac_cv_search_XML_ErrorString+:} false; then :
3501
3502 else
3503 ac_cv_search_XML_ErrorString=no
3504 fi
3505 rm conftest.$ac_ext
3506 LIBS=$ac_func_search_save_LIBS
3507 fi
3508 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_XML_ErrorString" >&5
3509 $as_echo "$ac_cv_search_XML_ErrorString" >&6; }
3510 ac_res=$ac_cv_search_XML_ErrorString
3511 if test "$ac_res" != no; then :
3512 test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
3513
3514 fi
3515
3516
3517 # Check that selected routines from udunits2 can be used in programs,
3518 # including udunits2 in LIBS if needed.
3519 # Also search for udunits2.h on its own or in a subdirectory,
3520 # and define macro HAVE_UDUNITS2_H or HAVE_UDUNITS2_UDUNITS2_H accordingly.
3521 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ut_read_xml" >&5
3522 $as_echo_n "checking for library containing ut_read_xml... " >&6; }
3523 if ${ac_cv_search_ut_read_xml+:} false; then :
3524 $as_echo_n "(cached) " >&6
3525 else
3526 ac_func_search_save_LIBS=$LIBS
3527 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3528 /* end confdefs.h. */
3529
3530 /* Override any GCC internal prototype to avoid an error.
3531 Use char because int might match the return type of a GCC
3532 builtin and then its argument prototype would still apply. */
3533 #ifdef __cplusplus
3534 extern "C"
3535 #endif
3536 char ut_read_xml ();
3537 int
3538 main ()
3539 {
3540 return ut_read_xml ();
34833541 ;
34843542 return 0;
34853543 }
34923550 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
34933551 fi
34943552 if ac_fn_c_try_link "$LINENO"; then :
3495 ac_cv_search_ut_decode_time=$ac_res
3553 ac_cv_search_ut_read_xml=$ac_res
34963554 fi
34973555 rm -f core conftest.err conftest.$ac_objext \
34983556 conftest$ac_exeext
3499 if ${ac_cv_search_ut_decode_time+:} false; then :
3557 if ${ac_cv_search_ut_read_xml+:} false; then :
35003558 break
35013559 fi
35023560 done
3503 if ${ac_cv_search_ut_decode_time+:} false; then :
3504
3505 else
3506 ac_cv_search_ut_decode_time=no
3561 if ${ac_cv_search_ut_read_xml+:} false; then :
3562
3563 else
3564 ac_cv_search_ut_read_xml=no
35073565 fi
35083566 rm conftest.$ac_ext
35093567 LIBS=$ac_func_search_save_LIBS
35103568 fi
3511 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ut_decode_time" >&5
3512 $as_echo "$ac_cv_search_ut_decode_time" >&6; }
3513 ac_res=$ac_cv_search_ut_decode_time
3569 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ut_read_xml" >&5
3570 $as_echo "$ac_cv_search_ut_read_xml" >&6; }
3571 ac_res=$ac_cv_search_ut_read_xml
35143572 if test "$ac_res" != no; then :
35153573 test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
3516 $as_echo "#define HAVE_LIBUDUNITS2 1" >>confdefs.h
3517
3518 fi
3519
3520 for ac_header in udunits2.h udunits2/udunits2.h
3574 ac_fn_c_check_func "$LINENO" "ut_offset_by_time" "ac_cv_func_ut_offset_by_time"
3575 if test "x$ac_cv_func_ut_offset_by_time" = xyes; then :
3576 ac_fn_c_check_func "$LINENO" "ut_decode_time" "ac_cv_func_ut_decode_time"
3577 if test "x$ac_cv_func_ut_decode_time" = xyes; then :
3578 ac_fn_c_check_func "$LINENO" "ut_encode_time" "ac_cv_func_ut_encode_time"
3579 if test "x$ac_cv_func_ut_encode_time" = xyes; then :
3580 for ac_header in udunits2.h udunits2/udunits2.h
35213581 do :
35223582 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
35233583 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
35253585 cat >>confdefs.h <<_ACEOF
35263586 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
35273587 _ACEOF
3528 break
3588 enable_calendar=yes; break
3589
35293590 fi
35303591
35313592 done
35323593
3594
3595 fi
3596
3597
3598 fi
3599
3600
3601 fi
3602
3603
3604 fi
3605
3606
3607 # Define HAVE_LIBUDUNITS2 if all udunits2 checks were successful:
3608 if test "x$enable_calendar" == xyes; then :
3609 $as_echo "#define HAVE_LIBUDUNITS2 1" >>confdefs.h
3610
3611 else
3612 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: disabling calendar functions in RNetCDF" >&5
3613 $as_echo "$as_me: WARNING: disabling calendar functions in RNetCDF" >&2;}
3614
3615 fi
35333616
35343617 #-------------------------------------------------------------------------------#
35353618 # Do substitution #
40794162 # report actual input values of CONFIG_FILES etc. instead of their
40804163 # values after options handling.
40814164 ac_log="
4082 This file was extended by RNetCDF $as_me 2.0-3, which was
4165 This file was extended by RNetCDF $as_me 2.1-1, which was
40834166 generated by GNU Autoconf 2.69. Invocation command line was
40844167
40854168 CONFIG_FILES = $CONFIG_FILES
41324215 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
41334216 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
41344217 ac_cs_version="\\
4135 RNetCDF config.status 2.0-3
4218 RNetCDF config.status 2.1-1
41364219 configured by $0, generated by GNU Autoconf 2.69,
41374220 with options \\"\$ac_cs_config\\"
41384221
11 # Initialize #
22 #-------------------------------------------------------------------------------#
33
4 AC_INIT([RNetCDF], [2.0-3])
4 AC_INIT([RNetCDF], [2.1-1])
55
66 #-------------------------------------------------------------------------------#
77 # Find the compiler and compiler options to use for tests #
88 #-------------------------------------------------------------------------------#
99
1010 : ${R_HOME=`R RHOME`}
11 if test -z "${R_HOME}"; then
12 echo "could not determine R_HOME"
13 exit 1
14 fi
11 AS_IF([test -z "${R_HOME}"],
12 AC_MSG_ERROR([could not determine R_HOME])
13 )
1514 CC=`"${R_HOME}/bin/R" CMD config CC`
1615 CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
1716
5049
5150 # Check that netcdf header files can be compiled:
5251 AC_CHECK_HEADERS(netcdf.h, [],
53 AC_MSG_ERROR("netcdf.h was not compiled - defining CPPFLAGS may help"))
52 AC_MSG_ERROR([netcdf.h was not compiled - defining CPPFLAGS may help]))
5453
5554 # Check that netcdf library can be found.
5655 # Linker flags are prepended to LIBS if needed.
5756 AC_SEARCH_LIBS(nc_open, netcdf, [],
58 AC_MSG_ERROR("netcdf library was not linked - defining LDFLAGS may help"))
57 AC_MSG_ERROR([netcdf library was not linked - defining LDFLAGS may help]))
5958
6059 # Check for the existence of optional netcdf routines.
6160 # C preprocessor macros HAVE_routine are defined for existing routines.
6564 # Find UDUNITS2 library and header files #
6665 #-------------------------------------------------------------------------------#
6766
68 # Prepend the library to LIBS if it is not already being linked,
69 # and define preprocessor macro HAVE_LIBUDUNITS2.
70 # Also search for udunits2.h,
67 # The udunits2 library depends on expat, which may need to be linked explicitly:
68 AC_SEARCH_LIBS(XML_ErrorString, expat)
69
70 # Check that selected routines from udunits2 can be used in programs,
71 # including udunits2 in LIBS if needed.
72 # Also search for udunits2.h on its own or in a subdirectory,
7173 # and define macro HAVE_UDUNITS2_H or HAVE_UDUNITS2_UDUNITS2_H accordingly.
72 AC_SEARCH_LIBS(ut_decode_time, udunits2, AC_DEFINE(HAVE_LIBUDUNITS2))
73 AC_CHECK_HEADERS(udunits2.h udunits2/udunits2.h, [break])
74 AC_SEARCH_LIBS(ut_read_xml, udunits2,
75 AC_CHECK_FUNC(ut_offset_by_time,
76 AC_CHECK_FUNC(ut_decode_time,
77 AC_CHECK_FUNC(ut_encode_time,
78 AC_CHECK_HEADERS(udunits2.h udunits2/udunits2.h,
79 [enable_calendar=yes; break]
80 )
81 )
82 )
83 )
84 )
85
86 # Define HAVE_LIBUDUNITS2 if all udunits2 checks were successful:
87 AS_IF([test "x$enable_calendar" == xyes],
88 AC_DEFINE(HAVE_LIBUDUNITS2),
89 AC_MSG_WARN([disabling calendar functions in RNetCDF])
90 )
7491
7592 #-------------------------------------------------------------------------------#
7693 # Do substitution #
55 -DHAVE_NC_INQ_VAR_SZIP \
66 -DHAVE_NC_INQ_VAR_ENDIAN \
77
8 PKG_LIBS = -L../windows/netcdf-${VERSION}/lib${R_ARCH} \
9 -lnetcdf -lcurl -lhdf5_hl -lhdf5 -ludunits2 -lexpat -lszip -lz \
10 -lws2_32 -lcrypt32 -lwldap32
8 WINLIBS = ../windows/netcdf-${VERSION}/lib${R_ARCH}
9
10 PKG_LIBS = $(WINLIBS)/libnetcdf.a $(WINLIBS)/libcurl.a \
11 $(WINLIBS)/libhdf5_hl.a $(WINLIBS)/libhdf5.a $(WINLIBS)/libszip.a \
12 $(WINLIBS)/libudunits2.a $(WINLIBS)/libexpat.a \
13 -lz -lws2_32 -lcrypt32 -lwldap32
1114
1215 all: clean winlibs
1316
11 *
22 * Name: RNetCDF.h
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: Declare RNetCDF functions callable from R
77 *
11 *
22 * Name: attribute.c
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: NetCDF attribute functions for RNetCDF
77 *
173173
174174 /*-- Allocate memory and read attribute from file ---------------------------*/
175175 buf = R_nc_c2r_init (&io, NULL, ncid, xtype, -1, &cnt,
176 israw, isfit, NULL, NULL, NULL, NULL, NULL);
176 israw, isfit, 0, NULL, NULL, NULL, NULL, NULL);
177177 if (cnt > 0) {
178178 R_nc_check (nc_get_att (ncid, varid, attname, buf));
179179 }
316316
317317 /* -- Write attribute to file -----------------------------------------------*/
318318 if (cnt > 0) {
319 buf = R_nc_r2c (data, ncid, xtype, 1, &cnt, NULL, NULL, NULL);
319 buf = R_nc_r2c (data, ncid, xtype, 1, &cnt, 0, NULL, NULL, NULL);
320320 R_nc_check (nc_put_att (ncid, varid, attname, xtype, cnt, buf));
321321 }
322322
11 *
22 * Name: common.c
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: Common definitions for RNetCDF functions
77 *
11 *
22 * Name: common.h
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: Common definitions for RNetCDF functions
77 *
11 *
22 * Name: convert.c
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: Type conversions for RNetCDF
77 *
356356 NATEST, MINTEST, MINVAL, MAXTEST, MAXVAL) \
357357 static const OTYPE* \
358358 FUN (SEXP rv, int ndim, const size_t *xdim, \
359 const OTYPE *fill, const double *scale, const double *add) \
359 size_t fillsize, const OTYPE *fill, \
360 const double *scale, const double *add) \
360361 { \
361362 size_t ii, cnt; \
362363 int erange=0, efill=0; \
384385 offset = 0.0; \
385386 } \
386387 if (fill) { \
388 if (fillsize != sizeof(OTYPE)) { \
389 R_nc_error ("Size of fill value does not match output type"); \
390 } \
387391 fillval = *fill; \
388392 } \
389393 for (ii=0; ii<cnt; ii++) { \
535539 ii = xlength (io->rxp); \
536540 in = (ITYPE *) io->cbuf; \
537541 out = (OTYPE *) io->rbuf; \
542 if ((io->fill || io->min || io->max ) && io->fillsize != sizeof(ITYPE)) { \
543 R_nc_error ("Size of fill value does not match input type"); \
544 } \
538545 if (io->fill) { \
539546 fillval = *((ITYPE *) io->fill); \
540547 } \
638645 } else { \
639646 offset = 0.0; \
640647 } \
648 if ((io->fill || io->min || io->max) && io->fillsize != sizeof(ITYPE)) { \
649 R_nc_error ("Size of fill value does not match input type"); \
650 } \
641651 if (io->fill) { \
642652 fillval = *((ITYPE *) io->fill); \
643653 } \
695705 An error is raised if input values cannot be converted to the vlen base type.
696706 */
697707 static nc_vlen_t *
698 R_nc_vecsxp_vlen (SEXP rv, int ncid, nc_type xtype, int ndim, const size_t *xdim,
699 const void *fill, const double *scale, const double *add)
708 R_nc_vecsxp_vlen (SEXP rv, int ncid, nc_type xtype, int ndim, const size_t *xdim)
700709 {
701710 size_t ii, cnt, len, size;
702711 int baseclass;
734743 vbuf[ii].len = len;
735744 if (len > 0) {
736745 vbuf[ii].p = (void *) R_nc_r2c (item, ncid, basetype,
737 -1, &len, fill, scale, add);
746 -1, &len, 0, NULL, NULL, NULL);
738747 } else {
739748 vbuf[ii].p = NULL;
740749 }
779788
780789 for (ii=0; ii<cnt; ii++) {
781790 R_nc_c2r_init (&tmpio, vbuf[ii].p, io->ncid, basetype, -1, &(vbuf[ii].len),
782 io->rawchar, io->fitnum, io->fill, io->min, io->max,
783 io->scale, io->add);
791 io->rawchar, io->fitnum, 0, NULL, NULL, NULL, NULL, NULL);
784792 SET_VECTOR_ELT (io->rxp, ii, R_nc_c2r (&tmpio));
785793 nc_free_vlen(&(vbuf[ii]));
786794 }
856864 Memory for the result is allocated if necessary (and freed by R).
857865 */
858866 static void *
859 R_nc_factor_enum (SEXP rv, int ncid, nc_type xtype, int ndim, const size_t *xdim,
860 const void *fill)
867 R_nc_factor_enum (SEXP rv, int ncid, nc_type xtype, int ndim, const size_t *xdim)
861868 {
862869 SEXP levels;
863870 size_t size, imem, nmem, ilev, nlev, *ilev2mem, ifac, nfac;
916923
917924 for (ifac=0; ifac<nfac; ifac++) {
918925 inval = in[ifac];
919 if (inval==NA_INTEGER && fill) {
920 memcpy(out + ifac*size, fill, size);
921 } else if (0 < inval && inval <= nlev) {
926 if (0 < inval && inval <= nlev) {
922927 imem = ilev2mem[inval-1];
923928 memcpy(out + ifac*size, memvals + imem*size, size);
924929 } else {
968973 {
969974 SEXP levels, classname, env, cmd, symbol, value;
970975 size_t size, nmem, ifac, nfac;
971 char *memname, *memval, *work, *inval, *fill;
976 char *memname, *memval, *work, *inval;
972977 int ncid, imem, imemmax, *out;
973978 nc_type xtype;
974979
10011006 UNPROTECT(2);
10021007 }
10031008
1004 /* Add fill value (if defined) to the hashed environment.
1005 */
1006 fill = io->fill;
1007 if (fill) {
1008 symbol = PROTECT (R_nc_char_symbol (fill, size, work));
1009 value = PROTECT (ScalarInteger (NA_INTEGER));
1010 defineVar (symbol, value, env);
1011 UNPROTECT(2);
1012 }
1013
10141009 /* Convert netcdf enum values to R indices.
10151010 Use hashed environment prepared above for efficient lookups.
10161011 */
11121107 dimsizefld[idimfld+1] = dimlenfld[idimfld];
11131108 }
11141109 buffld = R_nc_r2c (VECTOR_ELT (rv, ilist), ncid, typefld, ndimfld+1, dimsizefld,
1115 NULL, NULL, NULL);
1110 0, NULL, NULL, NULL);
11161111
11171112 /* Copy elements from the field array into the compound array */
11181113 fldcnt = R_nc_length (ndimfld, dimsizefld+1);
12261221
12271222 /* Prepare to convert field data from C to R */
12281223 buffld = R_nc_c2r_init (&iofld, NULL, ncid, typefld, ndimslice, dimslice,
1229 io->rawchar, io->fitnum, NULL, NULL, NULL, NULL, NULL);
1224 io->rawchar, io->fitnum, 0, NULL, NULL, NULL, NULL, NULL);
12301225
12311226 /* Copy elements from the compound array into the field array */
12321227 fldlen = fldsize * fldcnt;
12521247
12531248 const void *
12541249 R_nc_r2c (SEXP rv, int ncid, nc_type xtype, int ndim, const size_t *xdim,
1255 const void *fill, const double *scale, const double *add)
1250 size_t fillsize, const void *fill,
1251 const double *scale, const double *add)
12561252 {
12571253 int class;
12581254
12641260 case INTSXP:
12651261 switch (xtype) {
12661262 case NC_BYTE:
1267 return R_nc_r2c_int_schar (rv, ndim, xdim, fill, scale, add);
1263 return R_nc_r2c_int_schar (rv, ndim, xdim, fillsize, fill, scale, add);
12681264 case NC_UBYTE:
1269 return R_nc_r2c_int_uchar (rv, ndim, xdim, fill, scale, add);
1265 return R_nc_r2c_int_uchar (rv, ndim, xdim, fillsize, fill, scale, add);
12701266 case NC_SHORT:
1271 return R_nc_r2c_int_short (rv, ndim, xdim, fill, scale, add);
1267 return R_nc_r2c_int_short (rv, ndim, xdim, fillsize, fill, scale, add);
12721268 case NC_USHORT:
1273 return R_nc_r2c_int_ushort (rv, ndim, xdim, fill, scale, add);
1269 return R_nc_r2c_int_ushort (rv, ndim, xdim, fillsize, fill, scale, add);
12741270 case NC_INT:
1275 return R_nc_r2c_int_int (rv, ndim, xdim, fill, scale, add);
1271 return R_nc_r2c_int_int (rv, ndim, xdim, fillsize, fill, scale, add);
12761272 case NC_UINT:
1277 return R_nc_r2c_int_uint (rv, ndim, xdim, fill, scale, add);
1273 return R_nc_r2c_int_uint (rv, ndim, xdim, fillsize, fill, scale, add);
12781274 case NC_INT64:
1279 return R_nc_r2c_int_ll (rv, ndim, xdim, fill, scale, add);
1275 return R_nc_r2c_int_ll (rv, ndim, xdim, fillsize, fill, scale, add);
12801276 case NC_UINT64:
1281 return R_nc_r2c_int_ull (rv, ndim, xdim, fill, scale, add);
1277 return R_nc_r2c_int_ull (rv, ndim, xdim, fillsize, fill, scale, add);
12821278 case NC_FLOAT:
1283 return R_nc_r2c_int_float (rv, ndim, xdim, fill, scale, add);
1279 return R_nc_r2c_int_float (rv, ndim, xdim, fillsize, fill, scale, add);
12841280 case NC_DOUBLE:
1285 return R_nc_r2c_int_dbl (rv, ndim, xdim, fill, scale, add);
1281 return R_nc_r2c_int_dbl (rv, ndim, xdim, fillsize, fill, scale, add);
12861282 }
12871283 if (xtype > NC_MAX_ATOMIC_TYPE &&
12881284 class == NC_ENUM &&
12891285 R_nc_inherits (rv, "factor")) {
1290 return R_nc_factor_enum (rv, ncid, xtype, ndim, xdim, fill);
1286 return R_nc_factor_enum (rv, ncid, xtype, ndim, xdim);
12911287 }
12921288 break;
12931289 case REALSXP:
12941290 if (R_nc_inherits (rv, "integer64")) {
12951291 switch (xtype) {
12961292 case NC_BYTE:
1297 return R_nc_r2c_bit64_schar (rv, ndim, xdim, fill, scale, add);
1293 return R_nc_r2c_bit64_schar (rv, ndim, xdim, fillsize, fill, scale, add);
12981294 case NC_UBYTE:
1299 return R_nc_r2c_bit64_uchar (rv, ndim, xdim, fill, scale, add);
1295 return R_nc_r2c_bit64_uchar (rv, ndim, xdim, fillsize, fill, scale, add);
13001296 case NC_SHORT:
1301 return R_nc_r2c_bit64_short (rv, ndim, xdim, fill, scale, add);
1297 return R_nc_r2c_bit64_short (rv, ndim, xdim, fillsize, fill, scale, add);
13021298 case NC_USHORT:
1303 return R_nc_r2c_bit64_ushort (rv, ndim, xdim, fill, scale, add);
1299 return R_nc_r2c_bit64_ushort (rv, ndim, xdim, fillsize, fill, scale, add);
13041300 case NC_INT:
1305 return R_nc_r2c_bit64_int (rv, ndim, xdim, fill, scale, add);
1301 return R_nc_r2c_bit64_int (rv, ndim, xdim, fillsize, fill, scale, add);
13061302 case NC_UINT:
1307 return R_nc_r2c_bit64_uint (rv, ndim, xdim, fill, scale, add);
1303 return R_nc_r2c_bit64_uint (rv, ndim, xdim, fillsize, fill, scale, add);
13081304 case NC_INT64:
1309 return R_nc_r2c_bit64_ll (rv, ndim, xdim, fill, scale, add);
1305 return R_nc_r2c_bit64_ll (rv, ndim, xdim, fillsize, fill, scale, add);
13101306 case NC_UINT64:
1311 return R_nc_r2c_bit64_ull (rv, ndim, xdim, fill, scale, add);
1307 return R_nc_r2c_bit64_ull (rv, ndim, xdim, fillsize, fill, scale, add);
13121308 case NC_FLOAT:
1313 return R_nc_r2c_bit64_float (rv, ndim, xdim, fill, scale, add);
1309 return R_nc_r2c_bit64_float (rv, ndim, xdim, fillsize, fill, scale, add);
13141310 case NC_DOUBLE:
1315 return R_nc_r2c_bit64_dbl (rv, ndim, xdim, fill, scale, add);
1311 return R_nc_r2c_bit64_dbl (rv, ndim, xdim, fillsize, fill, scale, add);
13161312 }
13171313 } else {
13181314 switch (xtype) {
13191315 case NC_BYTE:
1320 return R_nc_r2c_dbl_schar (rv, ndim, xdim, fill, scale, add);
1316 return R_nc_r2c_dbl_schar (rv, ndim, xdim, fillsize, fill, scale, add);
13211317 case NC_UBYTE:
1322 return R_nc_r2c_dbl_uchar (rv, ndim, xdim, fill, scale, add);
1318 return R_nc_r2c_dbl_uchar (rv, ndim, xdim, fillsize, fill, scale, add);
13231319 case NC_SHORT:
1324 return R_nc_r2c_dbl_short (rv, ndim, xdim, fill, scale, add);
1320 return R_nc_r2c_dbl_short (rv, ndim, xdim, fillsize, fill, scale, add);
13251321 case NC_USHORT:
1326 return R_nc_r2c_dbl_ushort (rv, ndim, xdim, fill, scale, add);
1322 return R_nc_r2c_dbl_ushort (rv, ndim, xdim, fillsize, fill, scale, add);
13271323 case NC_INT:
1328 return R_nc_r2c_dbl_int (rv, ndim, xdim, fill, scale, add);
1324 return R_nc_r2c_dbl_int (rv, ndim, xdim, fillsize, fill, scale, add);
13291325 case NC_UINT:
1330 return R_nc_r2c_dbl_uint (rv, ndim, xdim, fill, scale, add);
1326 return R_nc_r2c_dbl_uint (rv, ndim, xdim, fillsize, fill, scale, add);
13311327 case NC_INT64:
1332 return R_nc_r2c_dbl_ll (rv, ndim, xdim, fill, scale, add);
1328 return R_nc_r2c_dbl_ll (rv, ndim, xdim, fillsize, fill, scale, add);
13331329 case NC_UINT64:
1334 return R_nc_r2c_dbl_ull (rv, ndim, xdim, fill, scale, add);
1330 return R_nc_r2c_dbl_ull (rv, ndim, xdim, fillsize, fill, scale, add);
13351331 case NC_FLOAT:
1336 return R_nc_r2c_dbl_float (rv, ndim, xdim, fill, scale, add);
1332 return R_nc_r2c_dbl_float (rv, ndim, xdim, fillsize, fill, scale, add);
13371333 case NC_DOUBLE:
1338 return R_nc_r2c_dbl_dbl (rv, ndim, xdim, fill, scale, add);
1334 return R_nc_r2c_dbl_dbl (rv, ndim, xdim, fillsize, fill, scale, add);
13391335 }
13401336 }
13411337 break;
13581354 if (xtype > NC_MAX_ATOMIC_TYPE) {
13591355 switch (class) {
13601356 case NC_VLEN:
1361 return R_nc_vecsxp_vlen (rv, ncid, xtype, ndim, xdim, fill, scale, add);
1357 return R_nc_vecsxp_vlen (rv, ncid, xtype, ndim, xdim);
13621358 case NC_COMPOUND:
13631359 return R_nc_vecsxp_compound (rv, ncid, xtype, ndim, xdim);
13641360 }
13711367 void * \
13721368 R_nc_c2r_init (R_nc_buf *io, void *cbuf,
13731369 int ncid, nc_type xtype, int ndim, const size_t *xdim,
1374 int rawchar, int fitnum,
1370 int rawchar, int fitnum, size_t fillsize,
13751371 const void *fill, const void *min, const void *max,
13761372 const double *scale, const double *add)
13771373 {
13781374 int class;
1379 size_t size;
13801375
13811376 if (!io) {
13821377 RERROR ("Pointer to R_nc_buf must not be NULL in R_nc_c2r_init");
13921387 io->rawchar = rawchar;
13931388 io->fitnum = fitnum;
13941389 io->xdim = NULL;
1390 io->fillsize = fillsize;
13951391 io->fill = NULL;
13961392 io->min = NULL;
13971393 io->max = NULL;
14101406 /* Scalar has no dimensions */
14111407 }
14121408
1413 if (fill || min || max) {
1414 R_nc_check (nc_inq_type (ncid, xtype, NULL, &size));
1415 }
1416
14171409 if (fill) {
1418 io->fill = R_alloc (1, size);
1419 memcpy (io->fill, fill, size);
1410 io->fill = R_alloc (1, fillsize);
1411 memcpy (io->fill, fill, fillsize);
14201412 }
14211413
14221414 if (min) {
1423 io->min = R_alloc (1, size);
1424 memcpy (io->min, min, size);
1415 io->min = R_alloc (1, fillsize);
1416 memcpy (io->min, min, fillsize);
14251417 }
14261418
14271419 if (max) {
1428 io->max = R_alloc (1, size);
1429 memcpy (io->max, max, size);
1420 io->max = R_alloc (1, fillsize);
1421 memcpy (io->max, max, fillsize);
14301422 }
14311423
14321424 if (scale) {
16781670 /* Copy R elements to cv */ \
16791671 if (isReal (rv)) { \
16801672 if (R_nc_inherits (rv, "integer64")) { \
1681 voidbuf = R_nc_r2c_bit64_##TYPENAME (rv, 1, &nr, &fillval, NULL, NULL); \
1673 voidbuf = R_nc_r2c_bit64_##TYPENAME (rv, 1, &nr, sizeof(TYPE), &fillval, NULL, NULL); \
16821674 } else { \
1683 voidbuf = R_nc_r2c_dbl_##TYPENAME (rv, 1, &nr, &fillval, NULL, NULL); \
1675 voidbuf = R_nc_r2c_dbl_##TYPENAME (rv, 1, &nr, sizeof(TYPE), &fillval, NULL, NULL); \
16841676 } \
16851677 } else if (isInteger (rv)) { \
1686 voidbuf = R_nc_r2c_int_##TYPENAME (rv, 1, &nr, &fillval, NULL, NULL); \
1678 voidbuf = R_nc_r2c_int_##TYPENAME (rv, 1, &nr, sizeof(TYPE), &fillval, NULL, NULL); \
16871679 } else { \
16881680 RERROR ("Unsupported R type in R_NC_DIM_R2C"); \
16891681 } \
11 *
22 * Name: convert.h
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: Type conversions for RNetCDF
77 *
6060 void *cbuf, *rbuf;
6161 nc_type xtype;
6262 int ncid, ndim, rawchar, fitnum;
63 size_t *xdim;
63 size_t *xdim, fillsize;
6464 void *fill, *min, *max;
6565 double *scale, *add;
6666 } R_nc_buf;
7777 */
7878 const void *
7979 R_nc_r2c (SEXP rv, int ncid, nc_type xtype, int ndim, const size_t *xdim,
80 const void *fill, const double *scale, const double *add);
80 size_t fillsize, const void *fill,
81 const double *scale, const double *add);
8182
8283
8384 /* Convert an array of netcdf external type (xtype) to R.
9899 void * \
99100 R_nc_c2r_init (R_nc_buf *io, void *cbuf,
100101 int ncid, nc_type xtype, int ndim, const size_t *xdim,
101 int rawchar, int fitnum,
102 int rawchar, int fitnum, size_t fillsize,
102103 const void *fill, const void *min, const void *max,
103104 const double *scale, const double *add);
104105
11 *
22 * Name: dataset.c
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: NetCDF dataset functions for RNetCDF
77 *
11 *
22 * Name: dimension.c
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: NetCDF dimension functions for RNetCDF
77 *
11 *
22 * Name: group.c
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: NetCDF group functions for RNetCDF.
77 *
11 *
22 * Name: common.c
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: RNetCDF initialisation
77 *
11 *
22 * Name: type.c
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: NetCDF type functions for RNetCDF
77 *
168168 R_nc_error ("Lengths of names and values must match");
169169 }
170170
171 cvals = R_nc_r2c (values, ncid, xtype, 1, &nval, NULL, NULL, NULL);
171 cvals = R_nc_r2c (values, ncid, xtype, 1, &nval, 0, NULL, NULL, NULL);
172172
173173 /*-- Enter define mode ------------------------------------------------------*/
174174 R_nc_check (R_nc_redef (ncid));
271271
272272 if (class == NC_ENUM) {
273273 if (!isNull (value)) {
274 tmpval = R_nc_r2c (value, ncid, xtype, 0, NULL, NULL, NULL, NULL);
274 tmpval = R_nc_r2c (value, ncid, xtype, 0, NULL, 0, NULL, NULL, NULL);
275275 } else {
276276 RERROR ("No value given for enumerated type");
277277 }
412412 /* Read named vector of member values */
413413 fieldnames = R_nc_protect (allocVector (STRSXP, nfields));
414414 cval = R_nc_c2r_init (&io, NULL, ncid, basetype, -1, &nfields,
415 0, 1, NULL, NULL, NULL, NULL, NULL);
415 0, 1, 0, NULL, NULL, NULL, NULL, NULL);
416416
417417 imax = nfields; // netcdf member index is int
418418 for (ii=0; ii < imax; ii++, cval+=size) {
11 *
22 * Name: udunits.c
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: udunits2 functions for RNetCDF.
77 *
11 *
22 * Name: variable.c
33 *
4 * Version: 2.0-3
4 * Version: 2.1-1
55 *
66 * Purpose: NetCDF variable functions for RNetCDF
77 *
5858 SEXP filter_params)
5959 {
6060 int ncid, ii, jj, *dimids, ndims, varid, chunkmode, format, withnc4;
61 int deflate_mode, deflate_level, shuffle_mode, endian_mode, fletcher_mode;
62 int filter_mode, filtid, *filtparm;
61 int deflate_mode, deflate_level, shuffle_mode, fletcher_mode;
6362 size_t *chunksize_t;
6463 nc_type xtype;
6564 const char *varnamep;
6665 SEXP result;
66
67 #ifdef HAVE_NC_INQ_VAR_ENDIAN
68 int endian_mode;
69 #endif
70 #ifdef HAVE_NC_INQ_VAR_FILTER
71 int filter_mode, filtid, *filtparm;
72 #endif
6773
6874 /*-- Convert arguments to netcdf ids ----------------------------------------*/
6975 ncid = asInteger (nc);
118124
119125 fletcher_mode = (asLogical (fletcher32) == TRUE);
120126
127 #ifdef HAVE_NC_INQ_VAR_FILTER
121128 filtid = asInteger (filter_id);
122129 filter_mode = (filtid != NA_INTEGER);
123130 filtparm = INTEGER (filter_params);
131 #endif
124132 }
125133
126134 /*-- Enter define mode ------------------------------------------------------*/
193201 /* Find attributes related to missing values for a netcdf variable.
194202 On exit, relevant parameters are returned via double pointers to
195203 fill, min and max, which are either NULL or allocated by R_alloc.
204 The function returns the in-memory size (bytes) of a missing value.
196205 Argument mode specifies the attributes used for missing values:
197206 0 - _FillValue, or missing_value
198207 1 - _FillValue only
202211 http://www.unidata.ucar.edu/software/netcdf/docs/attribute_conventions.html
203212 Example: R_nc_miss_att (ncid, varid, mode, &fill, &min, &max);
204213 */
205 static void
214 static size_t
206215 R_nc_miss_att (int ncid, int varid, int mode,
207216 void **fill, void **min, void **max)
208217 {
209218 size_t cnt, size;
210 int class;
211 nc_type atype, xtype, basetype;
219 nc_type atype, xtype;
212220 char *range;
213221 *fill = NULL;
214222 *min = NULL;
215223 *max = NULL;
216224
217 /* Get details about type of netcdf variable */
225 /* Get details about type and size of netcdf variable */
218226 R_nc_check (nc_inq_vartype (ncid, varid, &xtype));
219 if (xtype > NC_MAX_ATOMIC_TYPE) {
220 /* Use base type of vlen or enum type */
221 R_nc_check (nc_inq_user_type (ncid, xtype, NULL, NULL, &basetype, NULL, &class));
222 if (class == NC_ENUM || class == NC_VLEN) {
223 xtype = basetype;
224 } else {
225 /* Other user-defined types can be handled by users,
226 based on any convention they choose.
227 */
228 return;
229 }
227 if (xtype == NC_CHAR ||
228 xtype == NC_STRING ||
229 xtype > NC_MAX_ATOMIC_TYPE) {
230 /* NetCDF attribute conventions describe the handling of missing values
231 in atomic numeric types. Let users handle other types as needed.
232 */
233 return 0;
230234 }
231235 R_nc_check (nc_inq_type (ncid, xtype, NULL, &size));
232236
246250
247251 } else if (mode == 3) {
248252 /* Let user code handle missing values */
249 return;
253 return 0;
250254
251255 } else if (mode == 4) {
252256
371375 **(unsigned long long **) fill = NC_FILL_UINT64;
372376 break;
373377 default:
374 return;
378 R_nc_error ("Default fill value not implemented");
375379 }
376380 }
377381
405409 FILL2RANGE_REAL(double, DBL_EPSILON);
406410 break;
407411 default:
408 return;
412 R_nc_error ("Default valid range not implemented");
409413 }
410414 }
411415
414418 R_nc_error ("Unknown mode for handling missing values");
415419
416420 }
421 return size;
417422 }
418423
419424
456461 R_nc_buf io;
457462 double add, scale, *addp=NULL, *scalep=NULL;
458463 void *fillp=NULL, *minp=NULL, *maxp=NULL;
464 size_t fillsize;
465
466 #ifdef HAVE_NC_GET_VAR_CHUNK_CACHE
459467 size_t bytes, slots;
460468 float preemption;
461469 double bytes_in, slots_in, preempt_in;
470 #endif
462471
463472 /*-- Convert arguments ------------------------------------------------------*/
464473 ncid = asInteger (nc);
506515 }
507516
508517 /*-- Get fill attributes (if any) -------------------------------------------*/
509 R_nc_miss_att (ncid, varid, inamode, &fillp, &minp, &maxp);
518 fillsize = R_nc_miss_att (ncid, varid, inamode, &fillp, &minp, &maxp);
510519
511520 /*-- Get packing attributes (if any) ----------------------------------------*/
512521 if (isunpack) {
520529
521530 /*-- Allocate memory and read variable from file ----------------------------*/
522531 buf = R_nc_c2r_init (&io, NULL, ncid, xtype, ndims, ccount,
523 israw, isfit, fillp, minp, maxp, scalep, addp);
532 israw, isfit, fillsize, fillp, minp, maxp, scalep, addp);
524533
525534 if (R_nc_length (ndims, ccount) > 0) {
526535 R_nc_check (nc_get_vara (ncid, varid, cstart, ccount, buf));
539548 R_nc_inq_var (SEXP nc, SEXP var)
540549 {
541550 int ncid, varid, idim, ndims, natts, *dimids, storeprop, format, withnc4;
542 int shuffle, deflate, deflate_level, endian, fletcher;
543 int status, szip_options, szip_bits;
544 int filter_id;
545 size_t filter_nparams;
546 size_t *chunksize_t, cache_bytes, cache_slots;
547 float cache_preemption;
551 int shuffle, deflate, deflate_level, fletcher;
552 int status;
553 size_t *chunksize_t;
548554 double *chunkdbl;
549555 char varname[NC_MAX_NAME + 1], vartype[NC_MAX_NAME+1];
550556 nc_type xtype;
551557 SEXP result, rdimids, rchunks, rbytes, rslots, rpreempt,
552558 rshuffle, rdeflate, rendian, rfletcher,
553559 rszip_options, rszip_bits, rfilter_id, rfilter_params;
560
561 #ifdef HAVE_NC_GET_VAR_CHUNK_CACHE
562 size_t cache_bytes, cache_slots;
563 float cache_preemption;
564 #endif
565 #ifdef HAVE_NC_INQ_VAR_ENDIAN
566 int endian;
567 #endif
568 #ifdef HAVE_NC_INQ_VAR_SZIP
569 int szip_options, szip_bits;
570 #endif
571 #ifdef HAVE_NC_INQ_VAR_FILTER
572 int filter_id;
573 size_t filter_nparams;
574 #endif
554575
555576 /*-- Convert arguments to netcdf ids ----------------------------------------*/
556577 ncid = asInteger (nc);
744765 const void *buf;
745766 double scale, add, *scalep=NULL, *addp=NULL;
746767 void *fillp=NULL, *minp=NULL, *maxp=NULL;
768 size_t fillsize;
769
770 #ifdef HAVE_NC_GET_VAR_CHUNK_CACHE
747771 size_t bytes, slots;
748772 float preemption;
749773 double bytes_in, slots_in, preempt_in;
774 #endif
750775
751776 /*-- Convert arguments to netcdf ids ----------------------------------------*/
752777 ncid = asInteger (nc);
792817 }
793818
794819 /*-- Get fill attributes (if any) -------------------------------------------*/
795 R_nc_miss_att (ncid, varid, inamode, &fillp, &minp, &maxp);
820 fillsize = R_nc_miss_att (ncid, varid, inamode, &fillp, &minp, &maxp);
796821
797822 /*-- Get packing attributes (if any) ----------------------------------------*/
798823 if (ispack) {
806831
807832 /*-- Write variable to file -------------------------------------------------*/
808833 if (R_nc_length (ndims, ccount) > 0) {
809 buf = R_nc_r2c (data, ncid, xtype, ndims, ccount, fillp, scalep, addp);
834 buf = R_nc_r2c (data, ncid, xtype, ndims, ccount,
835 fillsize, fillp, scalep, addp);
810836 R_nc_check (nc_put_vara (ncid, varid, cstart, ccount, buf));
811837 }
812838
11 #
22 # Name: RNetCDF-test.R
33 #
4 # Version: 2.0-3
4 # Version: 2.1-1
55 #
66 # Purpose: Test functions to the NetCDF interface for R.
77 #