From f67c83b2873ca595da9fd94d3fcf2c1f1bb622df Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 22 Mar 2020 19:54:43 +0000 Subject: [PATCH] ECC-1094: Implement a way to check if an instance of ecCodes has been compiled with thread support --- examples/F90/get_product_kind.f90 | 8 ++ fortran/CMakeLists.txt | 2 + fortran/eccodes_constants.h | 138 +++++++++++++++--------------- fortran/eccodes_f90_head.f90 | 1 + fortran/eccodes_settings.h.in | 6 ++ 5 files changed, 86 insertions(+), 69 deletions(-) create mode 100644 fortran/eccodes_settings.h.in diff --git a/examples/F90/get_product_kind.f90 b/examples/F90/get_product_kind.f90 index d446fde6b..f04dd0edb 100644 --- a/examples/F90/get_product_kind.f90 +++ b/examples/F90/get_product_kind.f90 @@ -30,6 +30,14 @@ program get_product_kind call codes_get_api_version(version) write(*,*) 'API version: ',version + write(*,*) 'ecCodes settings: ' + write(*,*) ' ECCODES_POSIX_THREADS: ',ECCODES_SETTINGS_POSIX_THREADS + write(*,*) ' ECCODES_OMP_THREADS: ',ECCODES_SETTINGS_OMP_THREADS + write(*,*) ' ECCODES_SETTINGS_MEMFS: ',ECCODES_SETTINGS_MEMFS + write(*,*) ' ECCODES_SETTINGS_JPEG: ',ECCODES_SETTINGS_JPEG + write(*,*) ' ECCODES_SETTINGS_PNG: ',ECCODES_SETTINGS_PNG + write(*,*) ' ECCODES_SETTINGS_AEC: ',ECCODES_SETTINGS_AEC + ! the first message is loaded from file ! ihandle is the message id to be used in subsequent calls call codes_new_from_file(ifile,ihandle,CODES_PRODUCT_ANY,iret) diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index c0099c342..2117f7e2d 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -1,5 +1,7 @@ if( HAVE_FORTRAN ) + configure_file( eccodes_settings.h.in eccodes_settings.h @ONLY ) + set( srcdir ${CMAKE_CURRENT_SOURCE_DIR} ) set( bindir ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/fortran/eccodes_constants.h b/fortran/eccodes_constants.h index 512718826..a57288446 100644 --- a/fortran/eccodes_constants.h +++ b/fortran/eccodes_constants.h @@ -1,69 +1,69 @@ - integer, parameter,public :: CODES_FUNCTIONALITY_NOT_ENABLED = -67 - integer, parameter,public :: CODES_WRONG_BITMAP_SIZE = -66 - integer, parameter,public :: CODES_OUT_OF_RANGE = -65 - integer, parameter,public :: CODES_UNSUPPORTED_EDITION = -64 - integer, parameter,public :: CODES_ATTRIBUTE_NOT_FOUND = -63 - integer, parameter,public :: CODES_TOO_MANY_ATTRIBUTES = -62 - integer, parameter,public :: CODES_ATTRIBUTE_CLASH = -61 - integer, parameter,public :: CODES_NULL_POINTER = -60 - integer, parameter,public :: CODES_MISSING_BUFR_ENTRY = -59 - integer, parameter,public :: CODES_WRONG_CONVERSION = -58 - integer, parameter,public :: CODES_STRING_TOO_SMALL = -57 - integer, parameter,public :: CODES_INVALID_KEY_VALUE = -56 - integer, parameter,public :: CODES_VALUE_DIFFERENT = -55 - integer, parameter,public :: CODES_DIFFERENT_EDITION = -54 - integer, parameter,public :: CODES_INVALID_BPV = -53 - integer, parameter,public :: CODES_CORRUPTED_INDEX = -52 - integer, parameter,public :: CODES_MESSAGE_MALFORMED = -51 - integer, parameter,public :: CODES_UNDERFLOW = -50 - integer, parameter,public :: CODES_SWITCH_NO_MATCH = -49 - integer, parameter,public :: CODES_CONSTANT_FIELD = -48 - integer, parameter,public :: CODES_MESSAGE_TOO_LARGE = -47 - integer, parameter,public :: CODES_INTERNAL_ARRAY_TOO_SMALL = -46 - integer, parameter,public :: CODES_PREMATURE_END_OF_FILE = -45 - integer, parameter,public :: CODES_NULL_INDEX = -44 - integer, parameter,public :: CODES_END_OF_INDEX = -43 - integer, parameter,public :: CODES_WRONG_GRID = -42 - integer, parameter,public :: CODES_NO_VALUES = -41 - integer, parameter,public :: CODES_END = -40 - integer, parameter,public :: CODES_WRONG_TYPE = -39 - integer, parameter,public :: CODES_NO_DEFINITIONS = -38 - integer, parameter,public :: CODES_HASH_ARRAY_NO_MATCH = -37 - integer, parameter,public :: CODES_CONCEPT_NO_MATCH = -36 - integer, parameter,public :: CODES_OUT_OF_AREA = -35 - integer, parameter,public :: CODES_MISSING_KEY = -34 - integer, parameter,public :: CODES_INVALID_ORDERBY = -33 - integer, parameter,public :: CODES_INVALID_NEAREST = -32 - integer, parameter,public :: CODES_INVALID_KEYS_ITERATOR = -31 - integer, parameter,public :: CODES_INVALID_ITERATOR = -30 - integer, parameter,public :: CODES_INVALID_INDEX = -29 - integer, parameter,public :: CODES_INVALID_GRIB = -28 - integer, parameter,public :: CODES_INVALID_FILE = -27 - integer, parameter,public :: CODES_WRONG_STEP_UNIT = -26 - integer, parameter,public :: CODES_WRONG_STEP = -25 - integer, parameter,public :: CODES_INVALID_TYPE = -24 - integer, parameter,public :: CODES_WRONG_LENGTH = -23 - integer, parameter,public :: CODES_VALUE_CANNOT_BE_MISSING = -22 - integer, parameter,public :: CODES_INVALID_SECTION_NUMBER = -21 - integer, parameter,public :: CODES_NULL_HANDLE = -20 - integer, parameter,public :: CODES_INVALID_ARGUMENT = -19 - integer, parameter,public :: CODES_READ_ONLY = -18 - integer, parameter,public :: CODES_OUT_OF_MEMORY = -17 - integer, parameter,public :: CODES_GEOCALCULUS_PROBLEM = -16 - integer, parameter,public :: CODES_NO_MORE_IN_SET = -15 - integer, parameter,public :: CODES_ENCODING_ERROR = -14 - integer, parameter,public :: CODES_DECODING_ERROR = -13 - integer, parameter,public :: CODES_INVALID_MESSAGE = -12 - integer, parameter,public :: CODES_IO_PROBLEM = -11 - integer, parameter,public :: CODES_NOT_FOUND = -10 - integer, parameter,public :: CODES_WRONG_ARRAY_SIZE = -9 - integer, parameter,public :: CODES_CODE_NOT_FOUND_IN_TABLE = -8 - integer, parameter,public :: CODES_FILE_NOT_FOUND = -7 - integer, parameter,public :: CODES_ARRAY_TOO_SMALL = -6 - integer, parameter,public :: CODES_7777_NOT_FOUND = -5 - integer, parameter,public :: CODES_NOT_IMPLEMENTED = -4 - integer, parameter,public :: CODES_BUFFER_TOO_SMALL = -3 - integer, parameter,public :: CODES_INTERNAL_ERROR = -2 - integer, parameter,public :: CODES_END_OF_FILE = -1 - integer, parameter,public :: CODES_SUCCESS = 0 - integer, parameter,public :: CODES_NULL = -1 + integer, parameter,public :: CODES_FUNCTIONALITY_NOT_ENABLED = -67 + integer, parameter,public :: CODES_WRONG_BITMAP_SIZE = -66 + integer, parameter,public :: CODES_OUT_OF_RANGE = -65 + integer, parameter,public :: CODES_UNSUPPORTED_EDITION = -64 + integer, parameter,public :: CODES_ATTRIBUTE_NOT_FOUND = -63 + integer, parameter,public :: CODES_TOO_MANY_ATTRIBUTES = -62 + integer, parameter,public :: CODES_ATTRIBUTE_CLASH = -61 + integer, parameter,public :: CODES_NULL_POINTER = -60 + integer, parameter,public :: CODES_MISSING_BUFR_ENTRY = -59 + integer, parameter,public :: CODES_WRONG_CONVERSION = -58 + integer, parameter,public :: CODES_STRING_TOO_SMALL = -57 + integer, parameter,public :: CODES_INVALID_KEY_VALUE = -56 + integer, parameter,public :: CODES_VALUE_DIFFERENT = -55 + integer, parameter,public :: CODES_DIFFERENT_EDITION = -54 + integer, parameter,public :: CODES_INVALID_BPV = -53 + integer, parameter,public :: CODES_CORRUPTED_INDEX = -52 + integer, parameter,public :: CODES_MESSAGE_MALFORMED = -51 + integer, parameter,public :: CODES_UNDERFLOW = -50 + integer, parameter,public :: CODES_SWITCH_NO_MATCH = -49 + integer, parameter,public :: CODES_CONSTANT_FIELD = -48 + integer, parameter,public :: CODES_MESSAGE_TOO_LARGE = -47 + integer, parameter,public :: CODES_INTERNAL_ARRAY_TOO_SMALL = -46 + integer, parameter,public :: CODES_PREMATURE_END_OF_FILE = -45 + integer, parameter,public :: CODES_NULL_INDEX = -44 + integer, parameter,public :: CODES_END_OF_INDEX = -43 + integer, parameter,public :: CODES_WRONG_GRID = -42 + integer, parameter,public :: CODES_NO_VALUES = -41 + integer, parameter,public :: CODES_END = -40 + integer, parameter,public :: CODES_WRONG_TYPE = -39 + integer, parameter,public :: CODES_NO_DEFINITIONS = -38 + integer, parameter,public :: CODES_HASH_ARRAY_NO_MATCH = -37 + integer, parameter,public :: CODES_CONCEPT_NO_MATCH = -36 + integer, parameter,public :: CODES_OUT_OF_AREA = -35 + integer, parameter,public :: CODES_MISSING_KEY = -34 + integer, parameter,public :: CODES_INVALID_ORDERBY = -33 + integer, parameter,public :: CODES_INVALID_NEAREST = -32 + integer, parameter,public :: CODES_INVALID_KEYS_ITERATOR = -31 + integer, parameter,public :: CODES_INVALID_ITERATOR = -30 + integer, parameter,public :: CODES_INVALID_INDEX = -29 + integer, parameter,public :: CODES_INVALID_GRIB = -28 + integer, parameter,public :: CODES_INVALID_FILE = -27 + integer, parameter,public :: CODES_WRONG_STEP_UNIT = -26 + integer, parameter,public :: CODES_WRONG_STEP = -25 + integer, parameter,public :: CODES_INVALID_TYPE = -24 + integer, parameter,public :: CODES_WRONG_LENGTH = -23 + integer, parameter,public :: CODES_VALUE_CANNOT_BE_MISSING = -22 + integer, parameter,public :: CODES_INVALID_SECTION_NUMBER = -21 + integer, parameter,public :: CODES_NULL_HANDLE = -20 + integer, parameter,public :: CODES_INVALID_ARGUMENT = -19 + integer, parameter,public :: CODES_READ_ONLY = -18 + integer, parameter,public :: CODES_OUT_OF_MEMORY = -17 + integer, parameter,public :: CODES_GEOCALCULUS_PROBLEM = -16 + integer, parameter,public :: CODES_NO_MORE_IN_SET = -15 + integer, parameter,public :: CODES_ENCODING_ERROR = -14 + integer, parameter,public :: CODES_DECODING_ERROR = -13 + integer, parameter,public :: CODES_INVALID_MESSAGE = -12 + integer, parameter,public :: CODES_IO_PROBLEM = -11 + integer, parameter,public :: CODES_NOT_FOUND = -10 + integer, parameter,public :: CODES_WRONG_ARRAY_SIZE = -9 + integer, parameter,public :: CODES_CODE_NOT_FOUND_IN_TABLE = -8 + integer, parameter,public :: CODES_FILE_NOT_FOUND = -7 + integer, parameter,public :: CODES_ARRAY_TOO_SMALL = -6 + integer, parameter,public :: CODES_7777_NOT_FOUND = -5 + integer, parameter,public :: CODES_NOT_IMPLEMENTED = -4 + integer, parameter,public :: CODES_BUFFER_TOO_SMALL = -3 + integer, parameter,public :: CODES_INTERNAL_ERROR = -2 + integer, parameter,public :: CODES_END_OF_FILE = -1 + integer, parameter,public :: CODES_SUCCESS = 0 + integer, parameter,public :: CODES_NULL = -1 diff --git a/fortran/eccodes_f90_head.f90 b/fortran/eccodes_f90_head.f90 index a93c62faa..36e73b40d 100644 --- a/fortran/eccodes_f90_head.f90 +++ b/fortran/eccodes_f90_head.f90 @@ -15,6 +15,7 @@ module eccodes implicit none include "eccodes_constants.h" include "eccodes_visibility.h" + include "eccodes_settings.h" real(8), parameter,public :: CODES_MISSING_DOUBLE = -1.D+100 integer(4), parameter,public :: CODES_MISSING_LONG = 2147483647 diff --git a/fortran/eccodes_settings.h.in b/fortran/eccodes_settings.h.in new file mode 100644 index 000000000..2a0229726 --- /dev/null +++ b/fortran/eccodes_settings.h.in @@ -0,0 +1,6 @@ +integer, parameter, public :: ECCODES_SETTINGS_POSIX_THREADS = @HAVE_ECCODES_THREADS@ +integer, parameter, public :: ECCODES_SETTINGS_OMP_THREADS = @HAVE_ECCODES_OMP_THREADS@ +integer, parameter, public :: ECCODES_SETTINGS_MEMFS = @HAVE_MEMFS@ +integer, parameter, public :: ECCODES_SETTINGS_JPEG = @HAVE_JPEG@ +integer, parameter, public :: ECCODES_SETTINGS_PNG = @HAVE_PNG@ +integer, parameter, public :: ECCODES_SETTINGS_AEC = @HAVE_AEC@