Skip to content

Commit

Permalink
Merge pull request #2293 from GEOS-ESM/hotfix/tclune/#2292-nag+esmf-c…
Browse files Browse the repository at this point in the history
…onfig

Fixes #2292 - NAG + Darwin issue for ESMF_Config
  • Loading branch information
mathomp4 committed Aug 3, 2023
2 parents 1afeb43 + e427561 commit f8d54ac
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 96 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ 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
Expand Down
5 changes: 5 additions & 0 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<$<COMPILE_LANGUAGE:Fortran>:${DISABLE_GLOBAL_NAME_WARNING}>)
endif()
Expand Down
119 changes: 24 additions & 95 deletions base/MAPL_Config.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f8d54ac

Please sign in to comment.