New upstream version 2.1-1
Andreas Tille
4 years ago
0 | 0 | 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 | |
4 | 4 | Authors@R: c(person("Pavel", "Michna", role = "aut", |
5 | 5 | email = "rnetcdf-devel@bluewin.ch"), |
6 | 6 | person("Milton", "Woods", role = c("aut", "cre"), |
8 | 8 | Depends: R (>= 3.0.0) |
9 | 9 | SystemRequirements: netcdf udunits-2 |
10 | 10 | 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 | |
12 | 12 | 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. | |
15 | 15 | License: GPL (>= 2) | file LICENSE |
16 | 16 | URL: https://github.com/mjwoods/RNetCDF |
17 | 17 | http://www.unidata.ucar.edu/software/netcdf/ |
18 | 18 | http://www.unidata.ucar.edu/software/udunits/ |
19 | 19 | BugReports: https://github.com/mjwoods/RNetCDF/issues |
20 | 20 | NeedsCompilation: yes |
21 | Packaged: 2019-10-05 22:44:39 UTC; mwoods | |
21 | Packaged: 2019-10-19 08:59:31 UTC; mwoods | |
22 | 22 | Author: Pavel Michna [aut], |
23 | 23 | Milton Woods [aut, cre] |
24 | 24 | Maintainer: Milton Woods <miltonjwoods@gmail.com> |
25 | 25 | Repository: CRAN |
26 | Date/Publication: 2019-10-08 07:10:02 UTC | |
26 | Date/Publication: 2019-10-20 07:20:11 UTC |
38 | 38 | ===================== |
39 | 39 | |
40 | 40 | 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 | |
42 | 42 | |
43 | 43 | |
44 | 44 | LD_LIBRARY_PATH |
67 | 67 | =================== |
68 | 68 | |
69 | 69 | 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 | |
71 | 71 | |
72 | 72 | |
73 | 73 | Time units |
0 | 0 | b234ee4d69f5fce4486a80fdaf4a4263 *COPYING |
1 | 449179fe269f50d0d79eaa4815066cfe *DESCRIPTION | |
2 | 136914770d3e4026d18b3dd49d588038 *INSTALL | |
1 | b89039bd7dafb780af33bbd049af8d3e *DESCRIPTION | |
2 | 18f138b6e63657f37e2ac2dfc2507f23 *INSTALL | |
3 | 3 | a65f65191aacb737b62d6e354faf6b4e *LICENSE |
4 | 4 | 537ae4d17831bfa5e4bb053c53bcd933 *NAMESPACE |
5 | 838f80f0df2e2ffc53353406cf2a2727 *NEWS | |
5 | fde09d0f394474aee5a0ba3f1294502b *NEWS | |
6 | 6 | 899c70973b35f89c7a048b87a6cadb31 *R/RNetCDF.R |
7 | 7 | 900ad9ec5d6b3f465f65621c2ac90b3f *R/load.R |
8 | 8 | 3ee2d313b01e8c75dd118451997b2fee *README.md |
9 | 9 | a38544db104bdfa10be73ab380052d1e *cleanup |
10 | a35141ee27726142c26e1933f6fc9952 *configure | |
11 | aa8739f3b4023474443d221708c10bd5 *configure.ac | |
10 | e0952877b15035d3c52d9354f4477230 *configure | |
11 | 8e1d722d55807ec1eda95a4900dbbc58 *configure.ac | |
12 | 12 | d41d8cd98f00b204e9800998ecf8427e *configure.win |
13 | 13 | 5bac89bca74222d4bb68c09e5981202d *inst/udunits/udunits2.xml |
14 | 14 | 05c4596a4b2d91c91a8a878ec641c169 *man/00RNetCDF.Rd |
42 | 42 | 10b6bd5b00a98838be31d23035c7d48a *man/var.put.nc.Rd |
43 | 43 | 4abff3b45abf39350509758c00433787 *man/var.rename.nc.Rd |
44 | 44 | 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 | |
60 | 60 | 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 | ||
0 | 8 | Version 2.0-3, 2019-10-05 |
1 | 9 | * Support NetCDF-4 features for reading and writing of datasets. |
2 | 10 | * Suggest bit64 package for NC_INT64 and NC_UINT64 types. |
0 | 0 | #! /bin/sh |
1 | 1 | # 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. | |
3 | 3 | # |
4 | 4 | # |
5 | 5 | # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. |
576 | 576 | # Identity of this package. |
577 | 577 | PACKAGE_NAME='RNetCDF' |
578 | 578 | 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' | |
581 | 581 | PACKAGE_BUGREPORT='' |
582 | 582 | PACKAGE_URL='' |
583 | 583 | |
1222 | 1222 | # Omit some internal or obsolete options to make the list less imposing. |
1223 | 1223 | # This message is too long to be a string in the A/UX 3.1 sh. |
1224 | 1224 | 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. | |
1226 | 1226 | |
1227 | 1227 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1228 | 1228 | |
1283 | 1283 | |
1284 | 1284 | if test -n "$ac_init_help"; then |
1285 | 1285 | 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:";; | |
1287 | 1287 | esac |
1288 | 1288 | cat <<\_ACEOF |
1289 | 1289 | |
1368 | 1368 | test -n "$ac_init_help" && exit $ac_status |
1369 | 1369 | if $ac_init_version; then |
1370 | 1370 | cat <<\_ACEOF |
1371 | RNetCDF configure 2.0-3 | |
1371 | RNetCDF configure 2.1-1 | |
1372 | 1372 | generated by GNU Autoconf 2.69 |
1373 | 1373 | |
1374 | 1374 | Copyright (C) 2012 Free Software Foundation, Inc. |
1733 | 1733 | This file contains any messages produced by compilers while |
1734 | 1734 | running configure, to aid debugging if configure makes a mistake. |
1735 | 1735 | |
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 | |
1737 | 1737 | generated by GNU Autoconf 2.69. Invocation command line was |
1738 | 1738 | |
1739 | 1739 | $ $0 $@ |
2087 | 2087 | #-------------------------------------------------------------------------------# |
2088 | 2088 | |
2089 | 2089 | : ${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 | ||
2093 | 2093 | fi |
2094 | 2094 | CC=`"${R_HOME}/bin/R" CMD config CC` |
2095 | 2095 | CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS` |
3370 | 3370 | _ACEOF |
3371 | 3371 | |
3372 | 3372 | 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 | |
3374 | 3374 | fi |
3375 | 3375 | |
3376 | 3376 | done |
3433 | 3433 | test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" |
3434 | 3434 | |
3435 | 3435 | 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 | |
3437 | 3437 | fi |
3438 | 3438 | |
3439 | 3439 | |
3456 | 3456 | # Find UDUNITS2 library and header files # |
3457 | 3457 | #-------------------------------------------------------------------------------# |
3458 | 3458 | |
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 : | |
3466 | 3463 | $as_echo_n "(cached) " >&6 |
3467 | 3464 | else |
3468 | 3465 | ac_func_search_save_LIBS=$LIBS |
3475 | 3472 | #ifdef __cplusplus |
3476 | 3473 | extern "C" |
3477 | 3474 | #endif |
3478 | char ut_decode_time (); | |
3475 | char XML_ErrorString (); | |
3479 | 3476 | int |
3480 | 3477 | main () |
3481 | 3478 | { |
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 (); | |
3483 | 3541 | ; |
3484 | 3542 | return 0; |
3485 | 3543 | } |
3492 | 3550 | LIBS="-l$ac_lib $ac_func_search_save_LIBS" |
3493 | 3551 | fi |
3494 | 3552 | 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 | |
3496 | 3554 | fi |
3497 | 3555 | rm -f core conftest.err conftest.$ac_objext \ |
3498 | 3556 | conftest$ac_exeext |
3499 | if ${ac_cv_search_ut_decode_time+:} false; then : | |
3557 | if ${ac_cv_search_ut_read_xml+:} false; then : | |
3500 | 3558 | break |
3501 | 3559 | fi |
3502 | 3560 | 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 | |
3507 | 3565 | fi |
3508 | 3566 | rm conftest.$ac_ext |
3509 | 3567 | LIBS=$ac_func_search_save_LIBS |
3510 | 3568 | 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 | |
3514 | 3572 | if test "$ac_res" != no; then : |
3515 | 3573 | 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 | |
3521 | 3581 | do : |
3522 | 3582 | as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` |
3523 | 3583 | ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" |
3525 | 3585 | cat >>confdefs.h <<_ACEOF |
3526 | 3586 | #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 |
3527 | 3587 | _ACEOF |
3528 | break | |
3588 | enable_calendar=yes; break | |
3589 | ||
3529 | 3590 | fi |
3530 | 3591 | |
3531 | 3592 | done |
3532 | 3593 | |
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 | |
3533 | 3616 | |
3534 | 3617 | #-------------------------------------------------------------------------------# |
3535 | 3618 | # Do substitution # |
4079 | 4162 | # report actual input values of CONFIG_FILES etc. instead of their |
4080 | 4163 | # values after options handling. |
4081 | 4164 | 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 | |
4083 | 4166 | generated by GNU Autoconf 2.69. Invocation command line was |
4084 | 4167 | |
4085 | 4168 | CONFIG_FILES = $CONFIG_FILES |
4132 | 4215 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
4133 | 4216 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
4134 | 4217 | ac_cs_version="\\ |
4135 | RNetCDF config.status 2.0-3 | |
4218 | RNetCDF config.status 2.1-1 | |
4136 | 4219 | configured by $0, generated by GNU Autoconf 2.69, |
4137 | 4220 | with options \\"\$ac_cs_config\\" |
4138 | 4221 |
1 | 1 | # Initialize # |
2 | 2 | #-------------------------------------------------------------------------------# |
3 | 3 | |
4 | AC_INIT([RNetCDF], [2.0-3]) | |
4 | AC_INIT([RNetCDF], [2.1-1]) | |
5 | 5 | |
6 | 6 | #-------------------------------------------------------------------------------# |
7 | 7 | # Find the compiler and compiler options to use for tests # |
8 | 8 | #-------------------------------------------------------------------------------# |
9 | 9 | |
10 | 10 | : ${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 | ) | |
15 | 14 | CC=`"${R_HOME}/bin/R" CMD config CC` |
16 | 15 | CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS` |
17 | 16 | |
50 | 49 | |
51 | 50 | # Check that netcdf header files can be compiled: |
52 | 51 | 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])) | |
54 | 53 | |
55 | 54 | # Check that netcdf library can be found. |
56 | 55 | # Linker flags are prepended to LIBS if needed. |
57 | 56 | 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])) | |
59 | 58 | |
60 | 59 | # Check for the existence of optional netcdf routines. |
61 | 60 | # C preprocessor macros HAVE_routine are defined for existing routines. |
65 | 64 | # Find UDUNITS2 library and header files # |
66 | 65 | #-------------------------------------------------------------------------------# |
67 | 66 | |
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, | |
71 | 73 | # 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 | ) | |
74 | 91 | |
75 | 92 | #-------------------------------------------------------------------------------# |
76 | 93 | # Do substitution # |
5 | 5 | -DHAVE_NC_INQ_VAR_SZIP \ |
6 | 6 | -DHAVE_NC_INQ_VAR_ENDIAN \ |
7 | 7 | |
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 | |
11 | 14 | |
12 | 15 | all: clean winlibs |
13 | 16 |
1 | 1 | * |
2 | 2 | * Name: RNetCDF.h |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: Declare RNetCDF functions callable from R |
7 | 7 | * |
1 | 1 | * |
2 | 2 | * Name: attribute.c |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: NetCDF attribute functions for RNetCDF |
7 | 7 | * |
173 | 173 | |
174 | 174 | /*-- Allocate memory and read attribute from file ---------------------------*/ |
175 | 175 | 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); | |
177 | 177 | if (cnt > 0) { |
178 | 178 | R_nc_check (nc_get_att (ncid, varid, attname, buf)); |
179 | 179 | } |
316 | 316 | |
317 | 317 | /* -- Write attribute to file -----------------------------------------------*/ |
318 | 318 | 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); | |
320 | 320 | R_nc_check (nc_put_att (ncid, varid, attname, xtype, cnt, buf)); |
321 | 321 | } |
322 | 322 |
1 | 1 | * |
2 | 2 | * Name: common.c |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: Common definitions for RNetCDF functions |
7 | 7 | * |
1 | 1 | * |
2 | 2 | * Name: common.h |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: Common definitions for RNetCDF functions |
7 | 7 | * |
1 | 1 | * |
2 | 2 | * Name: convert.c |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: Type conversions for RNetCDF |
7 | 7 | * |
356 | 356 | NATEST, MINTEST, MINVAL, MAXTEST, MAXVAL) \ |
357 | 357 | static const OTYPE* \ |
358 | 358 | 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) \ | |
360 | 361 | { \ |
361 | 362 | size_t ii, cnt; \ |
362 | 363 | int erange=0, efill=0; \ |
384 | 385 | offset = 0.0; \ |
385 | 386 | } \ |
386 | 387 | if (fill) { \ |
388 | if (fillsize != sizeof(OTYPE)) { \ | |
389 | R_nc_error ("Size of fill value does not match output type"); \ | |
390 | } \ | |
387 | 391 | fillval = *fill; \ |
388 | 392 | } \ |
389 | 393 | for (ii=0; ii<cnt; ii++) { \ |
535 | 539 | ii = xlength (io->rxp); \ |
536 | 540 | in = (ITYPE *) io->cbuf; \ |
537 | 541 | 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 | } \ | |
538 | 545 | if (io->fill) { \ |
539 | 546 | fillval = *((ITYPE *) io->fill); \ |
540 | 547 | } \ |
638 | 645 | } else { \ |
639 | 646 | offset = 0.0; \ |
640 | 647 | } \ |
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 | } \ | |
641 | 651 | if (io->fill) { \ |
642 | 652 | fillval = *((ITYPE *) io->fill); \ |
643 | 653 | } \ |
695 | 705 | An error is raised if input values cannot be converted to the vlen base type. |
696 | 706 | */ |
697 | 707 | 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) | |
700 | 709 | { |
701 | 710 | size_t ii, cnt, len, size; |
702 | 711 | int baseclass; |
734 | 743 | vbuf[ii].len = len; |
735 | 744 | if (len > 0) { |
736 | 745 | vbuf[ii].p = (void *) R_nc_r2c (item, ncid, basetype, |
737 | -1, &len, fill, scale, add); | |
746 | -1, &len, 0, NULL, NULL, NULL); | |
738 | 747 | } else { |
739 | 748 | vbuf[ii].p = NULL; |
740 | 749 | } |
779 | 788 | |
780 | 789 | for (ii=0; ii<cnt; ii++) { |
781 | 790 | 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); | |
784 | 792 | SET_VECTOR_ELT (io->rxp, ii, R_nc_c2r (&tmpio)); |
785 | 793 | nc_free_vlen(&(vbuf[ii])); |
786 | 794 | } |
856 | 864 | Memory for the result is allocated if necessary (and freed by R). |
857 | 865 | */ |
858 | 866 | 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) | |
861 | 868 | { |
862 | 869 | SEXP levels; |
863 | 870 | size_t size, imem, nmem, ilev, nlev, *ilev2mem, ifac, nfac; |
916 | 923 | |
917 | 924 | for (ifac=0; ifac<nfac; ifac++) { |
918 | 925 | 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) { | |
922 | 927 | imem = ilev2mem[inval-1]; |
923 | 928 | memcpy(out + ifac*size, memvals + imem*size, size); |
924 | 929 | } else { |
968 | 973 | { |
969 | 974 | SEXP levels, classname, env, cmd, symbol, value; |
970 | 975 | size_t size, nmem, ifac, nfac; |
971 | char *memname, *memval, *work, *inval, *fill; | |
976 | char *memname, *memval, *work, *inval; | |
972 | 977 | int ncid, imem, imemmax, *out; |
973 | 978 | nc_type xtype; |
974 | 979 | |
1001 | 1006 | UNPROTECT(2); |
1002 | 1007 | } |
1003 | 1008 | |
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 | ||
1014 | 1009 | /* Convert netcdf enum values to R indices. |
1015 | 1010 | Use hashed environment prepared above for efficient lookups. |
1016 | 1011 | */ |
1112 | 1107 | dimsizefld[idimfld+1] = dimlenfld[idimfld]; |
1113 | 1108 | } |
1114 | 1109 | buffld = R_nc_r2c (VECTOR_ELT (rv, ilist), ncid, typefld, ndimfld+1, dimsizefld, |
1115 | NULL, NULL, NULL); | |
1110 | 0, NULL, NULL, NULL); | |
1116 | 1111 | |
1117 | 1112 | /* Copy elements from the field array into the compound array */ |
1118 | 1113 | fldcnt = R_nc_length (ndimfld, dimsizefld+1); |
1226 | 1221 | |
1227 | 1222 | /* Prepare to convert field data from C to R */ |
1228 | 1223 | 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); | |
1230 | 1225 | |
1231 | 1226 | /* Copy elements from the compound array into the field array */ |
1232 | 1227 | fldlen = fldsize * fldcnt; |
1252 | 1247 | |
1253 | 1248 | const void * |
1254 | 1249 | 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) | |
1256 | 1252 | { |
1257 | 1253 | int class; |
1258 | 1254 | |
1264 | 1260 | case INTSXP: |
1265 | 1261 | switch (xtype) { |
1266 | 1262 | 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); | |
1268 | 1264 | 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); | |
1270 | 1266 | 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); | |
1272 | 1268 | 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); | |
1274 | 1270 | 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); | |
1276 | 1272 | 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); | |
1278 | 1274 | 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); | |
1280 | 1276 | 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); | |
1282 | 1278 | 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); | |
1284 | 1280 | 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); | |
1286 | 1282 | } |
1287 | 1283 | if (xtype > NC_MAX_ATOMIC_TYPE && |
1288 | 1284 | class == NC_ENUM && |
1289 | 1285 | 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); | |
1291 | 1287 | } |
1292 | 1288 | break; |
1293 | 1289 | case REALSXP: |
1294 | 1290 | if (R_nc_inherits (rv, "integer64")) { |
1295 | 1291 | switch (xtype) { |
1296 | 1292 | 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); | |
1298 | 1294 | 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); | |
1300 | 1296 | 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); | |
1302 | 1298 | 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); | |
1304 | 1300 | 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); | |
1306 | 1302 | 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); | |
1308 | 1304 | 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); | |
1310 | 1306 | 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); | |
1312 | 1308 | 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); | |
1314 | 1310 | 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); | |
1316 | 1312 | } |
1317 | 1313 | } else { |
1318 | 1314 | switch (xtype) { |
1319 | 1315 | 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); | |
1321 | 1317 | 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); | |
1323 | 1319 | 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); | |
1325 | 1321 | 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); | |
1327 | 1323 | 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); | |
1329 | 1325 | 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); | |
1331 | 1327 | 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); | |
1333 | 1329 | 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); | |
1335 | 1331 | 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); | |
1337 | 1333 | 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); | |
1339 | 1335 | } |
1340 | 1336 | } |
1341 | 1337 | break; |
1358 | 1354 | if (xtype > NC_MAX_ATOMIC_TYPE) { |
1359 | 1355 | switch (class) { |
1360 | 1356 | 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); | |
1362 | 1358 | case NC_COMPOUND: |
1363 | 1359 | return R_nc_vecsxp_compound (rv, ncid, xtype, ndim, xdim); |
1364 | 1360 | } |
1371 | 1367 | void * \ |
1372 | 1368 | R_nc_c2r_init (R_nc_buf *io, void *cbuf, |
1373 | 1369 | int ncid, nc_type xtype, int ndim, const size_t *xdim, |
1374 | int rawchar, int fitnum, | |
1370 | int rawchar, int fitnum, size_t fillsize, | |
1375 | 1371 | const void *fill, const void *min, const void *max, |
1376 | 1372 | const double *scale, const double *add) |
1377 | 1373 | { |
1378 | 1374 | int class; |
1379 | size_t size; | |
1380 | 1375 | |
1381 | 1376 | if (!io) { |
1382 | 1377 | RERROR ("Pointer to R_nc_buf must not be NULL in R_nc_c2r_init"); |
1392 | 1387 | io->rawchar = rawchar; |
1393 | 1388 | io->fitnum = fitnum; |
1394 | 1389 | io->xdim = NULL; |
1390 | io->fillsize = fillsize; | |
1395 | 1391 | io->fill = NULL; |
1396 | 1392 | io->min = NULL; |
1397 | 1393 | io->max = NULL; |
1410 | 1406 | /* Scalar has no dimensions */ |
1411 | 1407 | } |
1412 | 1408 | |
1413 | if (fill || min || max) { | |
1414 | R_nc_check (nc_inq_type (ncid, xtype, NULL, &size)); | |
1415 | } | |
1416 | ||
1417 | 1409 | 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); | |
1420 | 1412 | } |
1421 | 1413 | |
1422 | 1414 | 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); | |
1425 | 1417 | } |
1426 | 1418 | |
1427 | 1419 | 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); | |
1430 | 1422 | } |
1431 | 1423 | |
1432 | 1424 | if (scale) { |
1678 | 1670 | /* Copy R elements to cv */ \ |
1679 | 1671 | if (isReal (rv)) { \ |
1680 | 1672 | 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); \ | |
1682 | 1674 | } 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); \ | |
1684 | 1676 | } \ |
1685 | 1677 | } 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); \ | |
1687 | 1679 | } else { \ |
1688 | 1680 | RERROR ("Unsupported R type in R_NC_DIM_R2C"); \ |
1689 | 1681 | } \ |
1 | 1 | * |
2 | 2 | * Name: convert.h |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: Type conversions for RNetCDF |
7 | 7 | * |
60 | 60 | void *cbuf, *rbuf; |
61 | 61 | nc_type xtype; |
62 | 62 | int ncid, ndim, rawchar, fitnum; |
63 | size_t *xdim; | |
63 | size_t *xdim, fillsize; | |
64 | 64 | void *fill, *min, *max; |
65 | 65 | double *scale, *add; |
66 | 66 | } R_nc_buf; |
77 | 77 | */ |
78 | 78 | const void * |
79 | 79 | 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); | |
81 | 82 | |
82 | 83 | |
83 | 84 | /* Convert an array of netcdf external type (xtype) to R. |
98 | 99 | void * \ |
99 | 100 | R_nc_c2r_init (R_nc_buf *io, void *cbuf, |
100 | 101 | int ncid, nc_type xtype, int ndim, const size_t *xdim, |
101 | int rawchar, int fitnum, | |
102 | int rawchar, int fitnum, size_t fillsize, | |
102 | 103 | const void *fill, const void *min, const void *max, |
103 | 104 | const double *scale, const double *add); |
104 | 105 |
1 | 1 | * |
2 | 2 | * Name: dataset.c |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: NetCDF dataset functions for RNetCDF |
7 | 7 | * |
1 | 1 | * |
2 | 2 | * Name: dimension.c |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: NetCDF dimension functions for RNetCDF |
7 | 7 | * |
1 | 1 | * |
2 | 2 | * Name: group.c |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: NetCDF group functions for RNetCDF. |
7 | 7 | * |
1 | 1 | * |
2 | 2 | * Name: common.c |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: RNetCDF initialisation |
7 | 7 | * |
1 | 1 | * |
2 | 2 | * Name: type.c |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: NetCDF type functions for RNetCDF |
7 | 7 | * |
168 | 168 | R_nc_error ("Lengths of names and values must match"); |
169 | 169 | } |
170 | 170 | |
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); | |
172 | 172 | |
173 | 173 | /*-- Enter define mode ------------------------------------------------------*/ |
174 | 174 | R_nc_check (R_nc_redef (ncid)); |
271 | 271 | |
272 | 272 | if (class == NC_ENUM) { |
273 | 273 | 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); | |
275 | 275 | } else { |
276 | 276 | RERROR ("No value given for enumerated type"); |
277 | 277 | } |
412 | 412 | /* Read named vector of member values */ |
413 | 413 | fieldnames = R_nc_protect (allocVector (STRSXP, nfields)); |
414 | 414 | 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); | |
416 | 416 | |
417 | 417 | imax = nfields; // netcdf member index is int |
418 | 418 | for (ii=0; ii < imax; ii++, cval+=size) { |
1 | 1 | * |
2 | 2 | * Name: udunits.c |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: udunits2 functions for RNetCDF. |
7 | 7 | * |
1 | 1 | * |
2 | 2 | * Name: variable.c |
3 | 3 | * |
4 | * Version: 2.0-3 | |
4 | * Version: 2.1-1 | |
5 | 5 | * |
6 | 6 | * Purpose: NetCDF variable functions for RNetCDF |
7 | 7 | * |
58 | 58 | SEXP filter_params) |
59 | 59 | { |
60 | 60 | 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; | |
63 | 62 | size_t *chunksize_t; |
64 | 63 | nc_type xtype; |
65 | 64 | const char *varnamep; |
66 | 65 | 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 | |
67 | 73 | |
68 | 74 | /*-- Convert arguments to netcdf ids ----------------------------------------*/ |
69 | 75 | ncid = asInteger (nc); |
118 | 124 | |
119 | 125 | fletcher_mode = (asLogical (fletcher32) == TRUE); |
120 | 126 | |
127 | #ifdef HAVE_NC_INQ_VAR_FILTER | |
121 | 128 | filtid = asInteger (filter_id); |
122 | 129 | filter_mode = (filtid != NA_INTEGER); |
123 | 130 | filtparm = INTEGER (filter_params); |
131 | #endif | |
124 | 132 | } |
125 | 133 | |
126 | 134 | /*-- Enter define mode ------------------------------------------------------*/ |
193 | 201 | /* Find attributes related to missing values for a netcdf variable. |
194 | 202 | On exit, relevant parameters are returned via double pointers to |
195 | 203 | 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. | |
196 | 205 | Argument mode specifies the attributes used for missing values: |
197 | 206 | 0 - _FillValue, or missing_value |
198 | 207 | 1 - _FillValue only |
202 | 211 | http://www.unidata.ucar.edu/software/netcdf/docs/attribute_conventions.html |
203 | 212 | Example: R_nc_miss_att (ncid, varid, mode, &fill, &min, &max); |
204 | 213 | */ |
205 | static void | |
214 | static size_t | |
206 | 215 | R_nc_miss_att (int ncid, int varid, int mode, |
207 | 216 | void **fill, void **min, void **max) |
208 | 217 | { |
209 | 218 | size_t cnt, size; |
210 | int class; | |
211 | nc_type atype, xtype, basetype; | |
219 | nc_type atype, xtype; | |
212 | 220 | char *range; |
213 | 221 | *fill = NULL; |
214 | 222 | *min = NULL; |
215 | 223 | *max = NULL; |
216 | 224 | |
217 | /* Get details about type of netcdf variable */ | |
225 | /* Get details about type and size of netcdf variable */ | |
218 | 226 | 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; | |
230 | 234 | } |
231 | 235 | R_nc_check (nc_inq_type (ncid, xtype, NULL, &size)); |
232 | 236 | |
246 | 250 | |
247 | 251 | } else if (mode == 3) { |
248 | 252 | /* Let user code handle missing values */ |
249 | return; | |
253 | return 0; | |
250 | 254 | |
251 | 255 | } else if (mode == 4) { |
252 | 256 | |
371 | 375 | **(unsigned long long **) fill = NC_FILL_UINT64; |
372 | 376 | break; |
373 | 377 | default: |
374 | return; | |
378 | R_nc_error ("Default fill value not implemented"); | |
375 | 379 | } |
376 | 380 | } |
377 | 381 | |
405 | 409 | FILL2RANGE_REAL(double, DBL_EPSILON); |
406 | 410 | break; |
407 | 411 | default: |
408 | return; | |
412 | R_nc_error ("Default valid range not implemented"); | |
409 | 413 | } |
410 | 414 | } |
411 | 415 | |
414 | 418 | R_nc_error ("Unknown mode for handling missing values"); |
415 | 419 | |
416 | 420 | } |
421 | return size; | |
417 | 422 | } |
418 | 423 | |
419 | 424 | |
456 | 461 | R_nc_buf io; |
457 | 462 | double add, scale, *addp=NULL, *scalep=NULL; |
458 | 463 | void *fillp=NULL, *minp=NULL, *maxp=NULL; |
464 | size_t fillsize; | |
465 | ||
466 | #ifdef HAVE_NC_GET_VAR_CHUNK_CACHE | |
459 | 467 | size_t bytes, slots; |
460 | 468 | float preemption; |
461 | 469 | double bytes_in, slots_in, preempt_in; |
470 | #endif | |
462 | 471 | |
463 | 472 | /*-- Convert arguments ------------------------------------------------------*/ |
464 | 473 | ncid = asInteger (nc); |
506 | 515 | } |
507 | 516 | |
508 | 517 | /*-- 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); | |
510 | 519 | |
511 | 520 | /*-- Get packing attributes (if any) ----------------------------------------*/ |
512 | 521 | if (isunpack) { |
520 | 529 | |
521 | 530 | /*-- Allocate memory and read variable from file ----------------------------*/ |
522 | 531 | 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); | |
524 | 533 | |
525 | 534 | if (R_nc_length (ndims, ccount) > 0) { |
526 | 535 | R_nc_check (nc_get_vara (ncid, varid, cstart, ccount, buf)); |
539 | 548 | R_nc_inq_var (SEXP nc, SEXP var) |
540 | 549 | { |
541 | 550 | 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; | |
548 | 554 | double *chunkdbl; |
549 | 555 | char varname[NC_MAX_NAME + 1], vartype[NC_MAX_NAME+1]; |
550 | 556 | nc_type xtype; |
551 | 557 | SEXP result, rdimids, rchunks, rbytes, rslots, rpreempt, |
552 | 558 | rshuffle, rdeflate, rendian, rfletcher, |
553 | 559 | 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 | |
554 | 575 | |
555 | 576 | /*-- Convert arguments to netcdf ids ----------------------------------------*/ |
556 | 577 | ncid = asInteger (nc); |
744 | 765 | const void *buf; |
745 | 766 | double scale, add, *scalep=NULL, *addp=NULL; |
746 | 767 | void *fillp=NULL, *minp=NULL, *maxp=NULL; |
768 | size_t fillsize; | |
769 | ||
770 | #ifdef HAVE_NC_GET_VAR_CHUNK_CACHE | |
747 | 771 | size_t bytes, slots; |
748 | 772 | float preemption; |
749 | 773 | double bytes_in, slots_in, preempt_in; |
774 | #endif | |
750 | 775 | |
751 | 776 | /*-- Convert arguments to netcdf ids ----------------------------------------*/ |
752 | 777 | ncid = asInteger (nc); |
792 | 817 | } |
793 | 818 | |
794 | 819 | /*-- 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); | |
796 | 821 | |
797 | 822 | /*-- Get packing attributes (if any) ----------------------------------------*/ |
798 | 823 | if (ispack) { |
806 | 831 | |
807 | 832 | /*-- Write variable to file -------------------------------------------------*/ |
808 | 833 | 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); | |
810 | 836 | R_nc_check (nc_put_vara (ncid, varid, cstart, ccount, buf)); |
811 | 837 | } |
812 | 838 |