From 195531f0d889237cd3daa8163a284632ee2ce133 Mon Sep 17 00:00:00 2001 From: Tom Clune Date: Wed, 2 Aug 2023 12:39:34 -0400 Subject: [PATCH 1/4] Fixes #2292 - NAG + Darwin issue for ESMF_Config --- CHANGELOG.md | 2 + base/CMakeLists.txt | 5 ++ base/MAPL_Config.F90 | 119 +++++++++---------------------------------- 3 files changed, 31 insertions(+), 95 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc9bdd1a8b83..5e10c681179a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Undoing previous workaround for NAG + `MAPL_Config.F90` That workaround was not portable to Linux. Instead have fixed with compiler flags in `ESMA_cmake`. But did a wee bit of refactoring while I was in the file. + ### Removed ### Deprecated diff --git a/base/CMakeLists.txt b/base/CMakeLists.txt index abfccdcf963f..f07b14195333 100644 --- a/base/CMakeLists.txt +++ b/base/CMakeLists.txt @@ -76,6 +76,11 @@ if (NOT CMAKE_Fortran_COMPILER_ID MATCHES "NAG") target_link_libraries(${this} PRIVATE OpenMP::OpenMP_Fortran) endif () +# Workaround for bizarre switch in ESMF +if (ESMF_HAS_ACHAR_BUG) + set_source_files_properties(MAPL_Config.F90 PROPERTIES COMPILE_DEFINITIONS ESMF_HAS_ACHAR_BUG) +endif() + if(DISABLE_GLOBAL_NAME_WARNING) target_compile_options (${this} PRIVATE $<$:${DISABLE_GLOBAL_NAME_WARNING}>) endif() diff --git a/base/MAPL_Config.F90 b/base/MAPL_Config.F90 index 48840ca33343..9cae1e8cdb2c 100644 --- a/base/MAPL_Config.F90 +++ b/base/MAPL_Config.F90 @@ -33,6 +33,29 @@ module MAPL_ConfigMod module procedure :: MAPL_ConfigSetAttribute_string end interface + integer, parameter :: LSZ = max (1024,ESMF_MAXPATHLEN) ! Maximum line size + integer, parameter :: MSZ = 256 ! Used to size buffer; this is + ! usually *less* than the number + ! of non-blank/comment lines + ! (because most lines are shorter + ! then LSZ) + + integer, parameter :: NBUF_MAX = MSZ*LSZ ! max size of buffer + integer, parameter :: NATT_MAX = NBUF_MAX/64 ! max # attributes; + ! assumes an average line + ! size of 16, the code + ! will do a bound check + + character, parameter :: BLK = achar(32) ! blank (space) + character, parameter :: TAB = achar(09) ! TAB +#if defined(ESMF_HAS_ACHAR_BUG) + character, parameter :: EOL = achar(12) ! end of line mark (cr) +#else + character, parameter :: EOL = achar(10) ! end of line mark (newline) +#endif + character, parameter :: EOB = achar(00) ! end of buffer mark (null) + character, parameter :: NUL = achar(00) ! what it says + contains function MAPL_ConfigCreate(unusable, rc) result(config) @@ -42,7 +65,7 @@ function MAPL_ConfigCreate(unusable, rc) result(config) integer, optional, intent(out) :: rc character, parameter :: EOB = achar(00) !! end of buffer mark (null) -#if defined(ESMF_HAS_ACHAR_BUG) | defined(__NAG_COMPILER_BUILD) +#if defined(__NAG_COMPILER_BUILD) && defined(__DARWIN) character, parameter :: EOL = achar(12) !! end of line mark (cr) #else character, parameter :: EOL = achar(10) !! end of line mark (newline) @@ -79,29 +102,6 @@ subroutine MAPL_ConfigSetAttribute_real64( config, value, label, rc ) character(len=*), intent(in), optional :: label integer, intent(out), optional :: rc ! - !integer, parameter :: LSZ = 256 ! Maximum line size - integer, parameter :: LSZ = max (1024,ESMF_MAXPATHLEN) ! Maximum line size - integer, parameter :: MSZ = 256 ! Used to size buffer; this is - ! usually *less* than the number - ! of non-blank/comment lines - ! (because most lines are shorter - ! then LSZ) - - integer, parameter :: NBUF_MAX = MSZ*LSZ ! max size of buffer - integer, parameter :: NATT_MAX = NBUF_MAX/64 ! max # attributes; - ! assumes an average line - ! size of 16, the code - ! will do a bound check - - character, parameter :: BLK = achar(32) ! blank (space) - character, parameter :: TAB = achar(09) ! TAB -#if defined(ESMF_HAS_ACHAR_BUG) | defined(__NAG_COMPILER_BUILD) - character, parameter :: EOL = achar(12) ! end of line mark (cr) -#else - character, parameter :: EOL = achar(10) ! end of line mark (newline) -#endif - character, parameter :: EOB = achar(00) ! end of buffer mark (null) - character, parameter :: NUL = achar(00) ! what it says !$$ character(len=ESMF_MAXSTR) :: Iam = 'MAPL_ConfigSetAttribute_int32' @@ -248,29 +248,6 @@ subroutine MAPL_ConfigSetAttribute_real32( config, value, label, rc ) character(len=*), intent(in), optional :: label integer, intent(out), optional :: rc ! - !integer, parameter :: LSZ = 256 ! Maximum line size - integer, parameter :: LSZ = max (1024,ESMF_MAXPATHLEN) ! Maximum line size - integer, parameter :: MSZ = 256 ! Used to size buffer; this is - ! usually *less* than the number - ! of non-blank/comment lines - ! (because most lines are shorter - ! then LSZ) - - integer, parameter :: NBUF_MAX = MSZ*LSZ ! max size of buffer - integer, parameter :: NATT_MAX = NBUF_MAX/64 ! max # attributes; - ! assumes an average line - ! size of 16, the code - ! will do a bound check - - character, parameter :: BLK = achar(32) ! blank (space) - character, parameter :: TAB = achar(09) ! TAB -#if defined(ESMF_HAS_ACHAR_BUG) | defined(__NAG_COMPILER_BUILD) - character, parameter :: EOL = achar(12) ! end of line mark (cr) -#else - character, parameter :: EOL = achar(10) ! end of line mark (newline) -#endif - character, parameter :: EOB = achar(00) ! end of buffer mark (null) - character, parameter :: NUL = achar(00) ! what it says !$$ character(len=ESMF_MAXSTR) :: Iam = 'MAPL_ConfigSetAttribute_int32' @@ -417,29 +394,6 @@ subroutine MAPL_ConfigSetAttribute_int32( config, value, label, rc ) character(len=*), intent(in), optional :: label integer, intent(out), optional :: rc ! - !integer, parameter :: LSZ = 256 ! Maximum line size - integer, parameter :: LSZ = max (1024,ESMF_MAXPATHLEN) ! Maximum line size - integer, parameter :: MSZ = 256 ! Used to size buffer; this is - ! usually *less* than the number - ! of non-blank/comment lines - ! (because most lines are shorter - ! then LSZ) - - integer, parameter :: NBUF_MAX = MSZ*LSZ ! max size of buffer - integer, parameter :: NATT_MAX = NBUF_MAX/64 ! max # attributes; - ! assumes an average line - ! size of 16, the code - ! will do a bound check - - character, parameter :: BLK = achar(32) ! blank (space) - character, parameter :: TAB = achar(09) ! TAB -#if defined(ESMF_HAS_ACHAR_BUG) | defined(__NAG_COMPILER_BUILD) - character, parameter :: EOL = achar(12) ! end of line mark (cr) -#else - character, parameter :: EOL = achar(10) ! end of line mark (newline) -#endif - character, parameter :: EOB = achar(00) ! end of buffer mark (null) - character, parameter :: NUL = achar(00) ! what it says !$$ character(len=ESMF_MAXSTR) :: Iam = 'MAPL_ConfigSetAttribute_int32' @@ -581,7 +535,6 @@ subroutine MAPL_ConfigSetAttribute_ints32( config, value, label, rc ) ! !INTERFACE: ! Private name; call using MAPL_ConfigSetAttribute() - integer, parameter :: LSZ = max (1024,ESMF_MAXPATHLEN) ! Maximum line size character(len=LSZ) :: buffer character(len=12) :: tmpStr, newVal integer :: count, i, j @@ -626,7 +579,6 @@ subroutine MAPL_ConfigSetAttribute_reals32( config, value, label, rc ) ! 18 is needed for gfortran ! Hopefully 32 is large enough to fit-all. #define IWSZ 32 - integer, parameter :: LSZ = max (1024,ESMF_MAXPATHLEN) ! Maximum line size character(len=LSZ) :: buffer character(len=IWSZ) :: tmpStr, newVal integer :: count, i, j @@ -662,29 +614,6 @@ subroutine MAPL_ConfigSetAttribute_string(config, value, label, rc) character(len=*), intent(in), optional :: label integer, intent(out), optional :: rc ! - !integer, parameter :: LSZ = 256 ! Maximum line size - integer, parameter :: LSZ = max (1024,ESMF_MAXPATHLEN) ! Maximum line size - integer, parameter :: MSZ = 256 ! Used to size buffer; this is - ! usually *less* than the number - ! of non-blank/comment lines - ! (because most lines are shorter - ! then LSZ) - - integer, parameter :: NBUF_MAX = MSZ*LSZ ! max size of buffer - integer, parameter :: NATT_MAX = NBUF_MAX/64 ! max # attributes; - ! assumes an average line - ! size of 16, the code - ! will do a bound check - - character, parameter :: BLK = achar(32) ! blank (space) - character, parameter :: TAB = achar(09) ! TAB -#if defined(ESMF_HAS_ACHAR_BUG) | defined(__NAG_COMPILER_BUILD) - character, parameter :: EOL = achar(12) ! end of line mark (cr) -#else - character, parameter :: EOL = achar(10) ! end of line mark (newline) -#endif - character, parameter :: EOB = achar(00) ! end of buffer mark (null) - character, parameter :: NUL = achar(00) ! what it says !$$ character(len=ESMF_MAXSTR) :: Iam = 'MAPL_ConfigSetAttribute_string' From 4dc9989631fbd4ea854d7231d8a7c17f658756ce Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 2 Aug 2023 19:03:46 -0400 Subject: [PATCH 2/4] Update FindESMF.cmake file to match ESMF 8.5.0 --- CHANGELOG.md | 6 ++++++ CMakeLists.txt | 2 +- cmake/FindESMF.cmake | 8 ++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc9bdd1a8b83..2127e393ec35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated +## [2.40.3] - 2023-08-03 + +### Fixed + +- Updated `FindESMF.cmake` file to match that of ESMF v8.5.0 + ## [2.40.2] - 2023-08-01 ### Fixed diff --git a/CMakeLists.txt b/CMakeLists.txt index 825bba06abca..b37803868b14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ endif () project ( MAPL - VERSION 2.40.2 + VERSION 2.40.3 LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF # Set the possible values of build type for cmake-gui diff --git a/cmake/FindESMF.cmake b/cmake/FindESMF.cmake index 161654428d88..23efbb31d078 100644 --- a/cmake/FindESMF.cmake +++ b/cmake/FindESMF.cmake @@ -96,13 +96,17 @@ if(EXISTS ${ESMFMKFILE}) message(WARNING "Static ESMF library (libesmf.a) not found in \ ${ESMF_LIBSDIR}. Try setting USE_ESMF_STATIC_LIBS=OFF") endif() - add_library(ESMF STATIC IMPORTED) + if(NOT TARGET ESMF) + add_library(ESMF STATIC IMPORTED) + endif() else() find_library(ESMF_LIBRARY_LOCATION NAMES esmf PATHS ${ESMF_LIBSDIR} NO_DEFAULT_PATH) if(ESMF_LIBRARY_LOCATION MATCHES "ESMF_LIBRARY_LOCATION-NOTFOUND") message(WARNING "ESMF library not found in ${ESMF_LIBSDIR}.") endif() - add_library(ESMF UNKNOWN IMPORTED) + if(NOT TARGET ESMF) + add_library(ESMF UNKNOWN IMPORTED) + endif() endif() # Add ESMF include directories From e4275613fbf0035f7127f0b4253c625eac022c11 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 3 Aug 2023 12:40:00 -0400 Subject: [PATCH 3/4] Update to ESMA_cmake v3.31.1 --- CHANGELOG.md | 5 ++++- components.yaml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e10c681179a..bda06f7f428a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Update `components.yaml` + - ESMA_cmake v3.31.1 (Fixes for NAG) + ### Fixed -- Undoing previous workaround for NAG + `MAPL_Config.F90` That workaround was not portable to Linux. Instead have fixed with compiler flags in `ESMA_cmake`. But did a wee bit of refactoring while I was in the file. +- Undoing previous workaround for NAG + `MAPL_Config.F90` in v2.40.1 which was a workaround was not portable to Linux. Instead, this uses changes in ESMA_cmake v3.31.1 for flags with NAG. ### Removed diff --git a/components.yaml b/components.yaml index 6192688644d7..4ba3b008c8de 100644 --- a/components.yaml +++ b/components.yaml @@ -11,7 +11,7 @@ ESMA_env: ESMA_cmake: local: ./ESMA_cmake remote: ../ESMA_cmake.git - tag: v3.31.0 + tag: v3.31.1 develop: develop ecbuild: From ca62617138769fce8b1aba3b9995abd321e4ab85 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 3 Aug 2023 14:49:51 -0400 Subject: [PATCH 4/4] Fix up changelog --- CHANGELOG.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b2146ed9fa8..a68810e478e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,21 +11,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Update `components.yaml` - - ESMA_cmake v3.31.1 (Fixes for NAG) - ### Fixed -- Undoing previous workaround for NAG + `MAPL_Config.F90` in v2.40.1 which was a workaround was not portable to Linux. Instead, this uses changes in ESMA_cmake v3.31.1 for flags with NAG. - ### Removed ### Deprecated ## [2.40.3] - 2023-08-03 +### Changed + +- Update `components.yaml` + - ESMA_cmake v3.31.1 (Fixes for NAG) + ### Fixed +- Undoing previous workaround for NAG + `MAPL_Config.F90` in v2.40.1 which was a workaround was not portable to Linux. Instead, this uses changes in ESMA_cmake v3.31.1 for flags with NAG. - Updated `FindESMF.cmake` file to match that of ESMF v8.5.0 ## [2.40.2] - 2023-08-01