Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisHeimbigner committed May 26, 2024
2 parents 80bdfcb + ddb0043 commit b9d2d41
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main-cmake.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: NetCDF-C CMake CI - Windows

on: [pull_request, workflow_dispatch]
on: [push,pull_request, workflow_dispatch]

env:
REMOTETESTDOWN: no
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

name: Run macOS-based netCDF Tests

on: [pull_request,workflow_dispatch]
on: [push,pull_request,workflow_dispatch]

env:
REMOTETESTDOWN: no
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

name: Run Ubuntu/Linux netCDF Tests

on: [pull_request,workflow_dispatch]
on: [push,pull_request,workflow_dispatch]

env:
REMOTETESTDOWN: no
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests_win_cygwin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run Cygwin-based tests

on: [pull_request,workflow_dispatch]
on: [push,pull_request,workflow_dispatch]

concurrency:
group: ${{ github.workflow}}-${{ github.head_ref }}
Expand Down
13 changes: 6 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -550,21 +550,20 @@ if(NOT USE_NETCDF4)
set(NETCDF_ENABLE_HDF4 OFF)
endif()

# Option Logging, only valid for netcdf4.
# Option Logging, only valid for netcdf4 dispatchers.
option(NETCDF_ENABLE_LOGGING "Enable Logging." OFF)
if(NOT USE_NETCDF4)
set(NETCDF_ENABLE_LOGGING OFF)
endif()
if(NETCDF_ENABLE_LOGGING)
target_compile_definitions(netcdf PRIVATE LOGGING NETCDF_ENABLE_SET_LOG_LEVEL)
set(LOGGING ON)
set(NETCDF_ENABLE_SET_LOG_LEVEL ON)
set(LOGGING ON CACHE BOOL "") # Alias
endif()

option(NETCDF_ENABLE_SET_LOG_LEVEL_FUNC "Enable definition of nc_set_log_level()." ON)
if(NETCDF_ENABLE_NETCDF4 AND NOT NETCDF_ENABLE_LOGGING AND NETCDF_ENABLE_SET_LOG_LEVEL_FUNC)
target_compile_definitions(netcdf PRIVATE -DNETCDF_ENABLE_SET_LOG_LEVEL)
set(NETCDF_ENABLE_SET_LOG_LEVEL ON)
if(LOGGING AND NETCDF_ENABLE_SET_LOG_LEVEL_FUNC)
set(NETCDF_ENABLE_SET_LOG_LEVEL ON CACHE BOOL "")
else()
set(NETCDF_ENABLE_SET_LOG_LEVEL OFF CACHE BOOL "")
endif()

# Option to allow for strict null file padding.
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This file contains a high-level description of this package's evolution. Release
## 4.9.3 - TBD

* Add experimental support for the Zarr Version 3 storage format. This code willl change as the Zarr Version 3 Specification evolves. See [Github #????](https://github.com/Unidata/netcdf-c/pull/????).
* Cleanup the option code for NETCDF_ENABLE_SET_LOG_LEVEL\[_FUNC\] See [Github #2931](https://github.com/Unidata/netcdf-c/issues/2931) for more information.
* Fix duplicate definition when using aws-sdk-cpp. See [Github #2928](https://github.com/Unidata/netcdf-c/issues/2928) for more information.
* Cleanup various obsolete options and do some code refactoring. See [Github #2926](https://github.com/Unidata/netcdf-c/issues/2926) for more information.
* Convert the Zarr-related ENABLE_XXX options to NETCDF_ENABLE_XXX options (part of the cmake overhaul). See [Github #2923](https://github.com/Unidata/netcdf-c/issues/2923) for more information.
* Refactor macro `_FillValue` to `NC_FillValue` to avoid conflict with libc++ headers. See [Github #2858](https://github.com/Unidata/netcdf-c/issues/2858) for more information.
Expand Down
3 changes: 0 additions & 3 deletions config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,6 @@ with zip */
/* If true, define nc_set_log_level. */
#cmakedefine NETCDF_ENABLE_SET_LOG_LEVEL 1

/* If true, define nc_set_log_level_func */
#cmakedefine NETCDF_ENABLE_SET_LOG_LEVEL_FUNC 1

/* min blocksize for posixio. */
#cmakedefine NCIO_MINBLOCKSIZE ${NCIO_MINBLOCKSIZE}

Expand Down
26 changes: 18 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,26 @@ AC_ARG_ENABLE([logging],
test "x$enable_logging" = xyes || enable_logging=no
AC_MSG_RESULT([$enable_logging])

# Does the user want to turn off nc_set_log_level() function? (It will
# always be defined if --enable-logging is used.)
AC_MSG_CHECKING([whether nc_set_log_level() function is included (will do nothing unless enable-logging is also used)])
AC_ARG_ENABLE([set_log_level_func], [AS_HELP_STRING([--disable-set-log-level-func],
# Does the user want to disable the nc_set_log_level() function? (It will
# always be defined (possibly as a no-op) if --enable-logging is used.)
AC_MSG_CHECKING([whether nc_set_log_level() function is enabled (will do nothing unless enable-logging is also used)])
AC_ARG_ENABLE([set-log-level-func], [AS_HELP_STRING([--disable-set-log-level-func],
[disable the nc_set_log_level function])])
test "x$enable_set_log_level_func" = xno -a "x$enable_logging" = xno || enable_set_log_level_func=yes
if test "x$enable_set_log_level_func" = xyes -a "x$enable_hdf5" = xyes; then
AC_DEFINE([ENABLE_SET_LOG_LEVEL], 1, [If true, define nc_set_log_level.])
test "x$enable_set_log_level_func" = xno || enable_set_log_level_func=yes
if test "x$enable_logging" = xno; then
enable_set_log_level_func=no
fi

# alias to enable_set_log_level
if test "x$enable_set_log_level_func" = xyes; then
enable_set_log_level=yes
else
enable_set_log_level=no
fi
AC_MSG_RESULT($enable_set_log_level)
if test "x$enable_set_log_level" = xyes ; then
AC_DEFINE([NETCDF_ENABLE_SET_LOG_LEVEL], 1, [If true, enable nc_set_log_level function.])
fi
AC_MSG_RESULT($enable_set_log_level_func)

# CURLOPT_USERNAME is not defined until curl version 7.19.1
# CURLOPT_PASSWORD is not defined until curl version 7.19.1
Expand Down
2 changes: 0 additions & 2 deletions include/nc_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ void nc_log(int severity, const char *fmt, ...);

#define BAIL_QUIET BAIL

#ifdef USE_NETCDF4
#ifndef NETCDF_ENABLE_SET_LOG_LEVEL
/* Define away any calls to nc_set_log_level(), if its not enabled. */
#define nc_set_log_level(e)
#endif /* NETCDF_ENABLE_SET_LOG_LEVEL */
#endif

#endif /* LOGGING */

Expand Down
4 changes: 2 additions & 2 deletions include/ncs3sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct NCglobalstate;
extern "C" {
#endif

/* API for ncs3sdk_XXX.[c|cpp] */
EXTERNL int NC_s3sdkinitialize(void);
EXTERNL int NC_s3sdkfinalize(void);
EXTERNL void* NC_s3sdkcreateclient(NCS3INFO* context);
Expand All @@ -64,8 +65,7 @@ EXTERNL int NC_s3sdklistall(void* s3client0, const char* bucket, const char* pre
EXTERNL int NC_s3sdkdeletekey(void* client0, const char* bucket, const char* pathkey, char** errmsgp);

/* From ds3util.c */
EXTERNL int NC_s3sdkinitialize(void);
EXTERNL int NC_s3sdkfinalize(void);
EXTERNL void NC_s3sdkenvironment(void);

EXTERNL int NC_getdefaults3region(NCURI* uri, const char** regionp);
EXTERNL int NC_s3urlprocess(NCURI* url, NCS3INFO* s3, NCURI** newurlp);
Expand Down
48 changes: 14 additions & 34 deletions libdispatch/ds3util.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ enum URLFORMAT {UF_NONE=0, UF_VIRTUAL=1, UF_PATH=2, UF_S3=3, UF_OTHER=4};
static const char* awsconfigfiles[] = {".aws/config",".aws/credentials",NULL};
#define NCONFIGFILES (sizeof(awsconfigfiles)/sizeof(char*))

static int ncs3_initialized = 0;
static int ncs3_finalized = 0;

/**************************************************/
/* Forward */

Expand All @@ -54,38 +51,21 @@ static int awsparse(const char* text, NClist* profiles);

/* Capture environmental Info */

EXTERNL int
NC_s3sdkinitialize(void)
{
if(!ncs3_initialized) {
ncs3_initialized = 1;
ncs3_finalized = 0;
}
{
/* Get various environment variables as defined by the AWS sdk */
NCglobalstate* gs = NC_getglobalstate();
if(getenv("AWS_REGION")!=NULL)
gs->aws.default_region = nulldup(getenv("AWS_REGION"));
else if(getenv("AWS_DEFAULT_REGION")!=NULL)
gs->aws.default_region = nulldup(getenv("AWS_DEFAULT_REGION"));
else if(gs->aws.default_region == NULL)
gs->aws.default_region = nulldup(AWS_GLOBAL_DEFAULT_REGION);
gs->aws.access_key_id = nulldup(getenv("AWS_ACCESS_KEY_ID"));
gs->aws.config_file = nulldup(getenv("AWS_CONFIG_FILE"));
gs->aws.profile = nulldup(getenv("AWS_PROFILE"));
gs->aws.secret_access_key = nulldup(getenv("AWS_SECRET_ACCESS_KEY"));
}
return NC_NOERR;
}

EXTERNL int
NC_s3sdkfinalize(void)
EXTERNL void
NC_s3sdkenvironment(void)
{
if(!ncs3_finalized) {
ncs3_initialized = 0;
ncs3_finalized = 1;
}
return NC_NOERR;
/* Get various environment variables as defined by the AWS sdk */
NCglobalstate* gs = NC_getglobalstate();
if(getenv("AWS_REGION")!=NULL)
gs->aws.default_region = nulldup(getenv("AWS_REGION"));
else if(getenv("AWS_DEFAULT_REGION")!=NULL)
gs->aws.default_region = nulldup(getenv("AWS_DEFAULT_REGION"));
else if(gs->aws.default_region == NULL)
gs->aws.default_region = nulldup(AWS_GLOBAL_DEFAULT_REGION);
gs->aws.access_key_id = nulldup(getenv("AWS_ACCESS_KEY_ID"));
gs->aws.config_file = nulldup(getenv("AWS_CONFIG_FILE"));
gs->aws.profile = nulldup(getenv("AWS_PROFILE"));
gs->aws.secret_access_key = nulldup(getenv("AWS_SECRET_ACCESS_KEY"));
}

/**************************************************/
Expand Down
9 changes: 5 additions & 4 deletions libdispatch/ncs3sdk_aws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,19 @@ NC_s3sdkinitialize(void)
if(!ncs3_initialized) {
ncs3_initialized = 1;
ncs3_finalized = 0;


#ifdef DEBUG
//ncs3options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
//ncs3options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
ncs3options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;
ncs3options.httpOptions.installSigPipeHandler = true;
ncs3options.loggingOptions.logger_create_fn = [] { return std::make_shared<Aws::Utils::Logging::ConsoleLogSystem>(Aws::Utils::Logging::LogLevel::Trace); };

#endif
Aws::InitAPI(ncs3options);

/* Get environment information */
NC_s3sdkenvironment();

}
return NCUNTRACE(NC_NOERR);
}
Expand Down Expand Up @@ -500,7 +502,6 @@ NC_s3sdkwriteobject(void* s3client0, const char* bucket, const char* pathkey, s
int stat = NC_NOERR;
const char* key = NULL;

const char* mcontent = (char*)content;
NCTRACE(11,"bucket=%s pathkey=%s count=%lld content=%p",bucket,pathkey,count,content);

AWSS3CLIENT s3client = (AWSS3CLIENT)s3client0;
Expand Down Expand Up @@ -535,7 +536,7 @@ NC_s3sdkwriteobject(void* s3client0, const char* bucket, const char* pathkey, s
put_request.SetContentLength((long long)count);

std::shared_ptr<Aws::IOStream> data = std::shared_ptr<Aws::IOStream>(new Aws::StringStream());
data->rdbuf()->pubsetbuf((char*)content,count);
data->rdbuf()->pubsetbuf((char*)content,(std::streamsize)count);
put_request.SetBody(data);
auto put_result = AWSS3GET(s3client)->PutObject(put_request);
if(!put_result.IsSuccess()) {
Expand Down
31 changes: 31 additions & 0 deletions libdispatch/ncs3sdk_h5.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,37 @@ static int queryinsert(NClist* list, char* ekey, char* evalue);

#define NT(x) ((x)==NULL?"null":x)

/**************************************************/

static int ncs3_initialized = 0;
static int ncs3_finalized = 0;

EXTERNL int
NC_s3sdkinitialize(void)
{
if(!ncs3_initialized) {
ncs3_initialized = 1;
ncs3_finalized = 0;
}

/* Get environment information */
NC_s3sdkenvironment(void);

return NC_NOERR;
}

EXTERNL int
NC_s3sdkfinalize(void)
{
if(!ncs3_finalized) {
ncs3_initialized = 0;
ncs3_finalized = 1;
}
return NC_NOERR;
}

/**************************************************/

#if 0
static void
dumps3info(NCS3INFO* s3info, const char* tag)
Expand Down
5 changes: 4 additions & 1 deletion nczarr_test/run_corrupt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ testnoshape2() {
}

testnoshape1
if test "x$FEATURE_S3TESTS" = xyes ; then testnoshape2; fi
if test "x$FEATURE_S3TESTS" = xyes && test "x$FEATURE_S3_INTERNAL" = xyes ; then
# The aws-sdk-cpp driver does not support google storage
testnoshape2
fi

0 comments on commit b9d2d41

Please sign in to comment.