From 45a3ec2becca89c8a96c6d083586d226403e0073 Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Tue, 8 Aug 2023 18:02:28 -0700 Subject: [PATCH 1/4] Clean-up and simplifications. --- ESMX_AtmOcnProto/Lumo/CMakeLists.txt | 22 +++++++++++++------ ESMX_AtmOcnProto/Makefile | 5 +++-- ESMX_ExternalDriverAPIProto/CMakeLists.txt | 1 + .../Lumo/CMakeLists.txt | 22 +++++++++++++------ ESMX_ExternalDriverAPIProto/Makefile | 4 ++-- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/ESMX_AtmOcnProto/Lumo/CMakeLists.txt b/ESMX_AtmOcnProto/Lumo/CMakeLists.txt index a8cda0cc..04a8435d 100644 --- a/ESMX_AtmOcnProto/Lumo/CMakeLists.txt +++ b/ESMX_AtmOcnProto/Lumo/CMakeLists.txt @@ -1,19 +1,27 @@ cmake_minimum_required(VERSION 3.19) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -find_package(ESMF 8.4.0 MODULE REQUIRED) +find_package(ESMF 8.5.0 MODULE REQUIRED) -if(NOT DEFINED CMAKE_Fortran_COMPILER) - set(CMAKE_Fortran_COMPILER "${ESMF_F90COMPILER}") -endif() -if(NOT DEFINED CMAKE_Fortran_FLAGS) - set(CMAKE_Fortran_FLAGS "${ESMF_F90COMPILEOPTS}") -endif() +set(CMAKE_Fortran_COMPILER "${ESMF_F90COMPILER}") project(Lumo VERSION 1.0 LANGUAGES Fortran) +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(CMAKE_Fortran_FLAGS "-ffree-line-length-none -Wall -Wextra -Wconversion -Wno-unused -Wno-unused-dummy-argument") + set(CMAKE_Fortran_FLAGS_RELEASE "-Ofast") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -fbacktrace -0fast") + set(CMAKE_Fortran_FLAGS_DEBUG "-g -fbacktrace -O0 -fcheck=all -ffpe-trap=invalid,zero,overflow,underflow") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + set(CMAKE_Fortran_FLAGS_RELEASE "-O2") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -traceback -O2") + set(CMAKE_Fortran_FLAGS_DEBUG "-g -traceback -O0 -check all -fpe0 -ftrapuv -init=snan,arrays") +else() + message(WARNING "${CMAKE_Fortran_COMPILER_ID} Fortran compiler will be used with default options") +endif() + add_library(Lumo lumo.F90) target_link_libraries(Lumo ESMF) diff --git a/ESMX_AtmOcnProto/Makefile b/ESMX_AtmOcnProto/Makefile index a066785c..066b528d 100644 --- a/ESMX_AtmOcnProto/Makefile +++ b/ESMX_AtmOcnProto/Makefile @@ -30,9 +30,10 @@ ESMF_INTERNAL_MPIRUN := $(shell echo $(ESMF_INTERNAL_MPIRUN)) ################################################################################ ################################################################################ EXE = install/bin/esmx_app +.PHONY: $(EXE) -$(EXE): esmxBuild.yaml - $(ESMF_APPSDIR)/ESMX_Builder +$(EXE): + $(ESMF_APPSDIR)/ESMX_Builder -v # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- diff --git a/ESMX_ExternalDriverAPIProto/CMakeLists.txt b/ESMX_ExternalDriverAPIProto/CMakeLists.txt index b1ac436f..4426884b 100644 --- a/ESMX_ExternalDriverAPIProto/CMakeLists.txt +++ b/ESMX_ExternalDriverAPIProto/CMakeLists.txt @@ -24,6 +24,7 @@ add_subdirectory(${ESMF_ESMXDIR}/Driver ./ESMX_Driver) add_executable(externalApp externalApp.F90) target_include_directories(externalApp PUBLIC ${PROJECT_BINARY_DIR}) target_link_libraries(externalApp PUBLIC esmx_driver) +set_target_properties(externalApp PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) # Install executable install( diff --git a/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt b/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt index a8cda0cc..04a8435d 100644 --- a/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt +++ b/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt @@ -1,19 +1,27 @@ cmake_minimum_required(VERSION 3.19) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -find_package(ESMF 8.4.0 MODULE REQUIRED) +find_package(ESMF 8.5.0 MODULE REQUIRED) -if(NOT DEFINED CMAKE_Fortran_COMPILER) - set(CMAKE_Fortran_COMPILER "${ESMF_F90COMPILER}") -endif() -if(NOT DEFINED CMAKE_Fortran_FLAGS) - set(CMAKE_Fortran_FLAGS "${ESMF_F90COMPILEOPTS}") -endif() +set(CMAKE_Fortran_COMPILER "${ESMF_F90COMPILER}") project(Lumo VERSION 1.0 LANGUAGES Fortran) +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(CMAKE_Fortran_FLAGS "-ffree-line-length-none -Wall -Wextra -Wconversion -Wno-unused -Wno-unused-dummy-argument") + set(CMAKE_Fortran_FLAGS_RELEASE "-Ofast") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -fbacktrace -0fast") + set(CMAKE_Fortran_FLAGS_DEBUG "-g -fbacktrace -O0 -fcheck=all -ffpe-trap=invalid,zero,overflow,underflow") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + set(CMAKE_Fortran_FLAGS_RELEASE "-O2") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -traceback -O2") + set(CMAKE_Fortran_FLAGS_DEBUG "-g -traceback -O0 -check all -fpe0 -ftrapuv -init=snan,arrays") +else() + message(WARNING "${CMAKE_Fortran_COMPILER_ID} Fortran compiler will be used with default options") +endif() + add_library(Lumo lumo.F90) target_link_libraries(Lumo ESMF) diff --git a/ESMX_ExternalDriverAPIProto/Makefile b/ESMX_ExternalDriverAPIProto/Makefile index 57a51715..bf26525c 100644 --- a/ESMX_ExternalDriverAPIProto/Makefile +++ b/ESMX_ExternalDriverAPIProto/Makefile @@ -30,9 +30,9 @@ ESMF_INTERNAL_MPIRUN := $(shell echo $(ESMF_INTERNAL_MPIRUN)) ################################################################################ ################################################################################ EXE = install/bin/externalApp +.PHONY: $(EXE) - -$(EXE): externalApp.F90 esmxBuild.yaml +$(EXE): cmake -S. -Bbuild -DESMF_ESMXDIR=$(ESMF_ESMXDIR) -DCMAKE_INSTALL_PREFIX=install cmake --build ./build cmake --install ./build From f83ffcb8a938ec34294feafe7c4a689ded44e7eb Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Tue, 15 Aug 2023 12:00:34 -0700 Subject: [PATCH 2/4] Correct typo in compiler option, and align GCC/Intel to -Ofast. --- ESMX_AtmOcnProto/Lumo/CMakeLists.txt | 6 +++--- ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ESMX_AtmOcnProto/Lumo/CMakeLists.txt b/ESMX_AtmOcnProto/Lumo/CMakeLists.txt index 04a8435d..a573c11f 100644 --- a/ESMX_AtmOcnProto/Lumo/CMakeLists.txt +++ b/ESMX_AtmOcnProto/Lumo/CMakeLists.txt @@ -12,11 +12,11 @@ project(Lumo if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") set(CMAKE_Fortran_FLAGS "-ffree-line-length-none -Wall -Wextra -Wconversion -Wno-unused -Wno-unused-dummy-argument") set(CMAKE_Fortran_FLAGS_RELEASE "-Ofast") - set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -fbacktrace -0fast") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -fbacktrace -Ofast") set(CMAKE_Fortran_FLAGS_DEBUG "-g -fbacktrace -O0 -fcheck=all -ffpe-trap=invalid,zero,overflow,underflow") elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") - set(CMAKE_Fortran_FLAGS_RELEASE "-O2") - set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -traceback -O2") + set(CMAKE_Fortran_FLAGS_RELEASE "-Ofast") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -traceback -Ofast") set(CMAKE_Fortran_FLAGS_DEBUG "-g -traceback -O0 -check all -fpe0 -ftrapuv -init=snan,arrays") else() message(WARNING "${CMAKE_Fortran_COMPILER_ID} Fortran compiler will be used with default options") diff --git a/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt b/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt index 04a8435d..a573c11f 100644 --- a/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt +++ b/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt @@ -12,11 +12,11 @@ project(Lumo if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") set(CMAKE_Fortran_FLAGS "-ffree-line-length-none -Wall -Wextra -Wconversion -Wno-unused -Wno-unused-dummy-argument") set(CMAKE_Fortran_FLAGS_RELEASE "-Ofast") - set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -fbacktrace -0fast") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -fbacktrace -Ofast") set(CMAKE_Fortran_FLAGS_DEBUG "-g -fbacktrace -O0 -fcheck=all -ffpe-trap=invalid,zero,overflow,underflow") elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") - set(CMAKE_Fortran_FLAGS_RELEASE "-O2") - set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -traceback -O2") + set(CMAKE_Fortran_FLAGS_RELEASE "-Ofast") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -traceback -Ofast") set(CMAKE_Fortran_FLAGS_DEBUG "-g -traceback -O0 -check all -fpe0 -ftrapuv -init=snan,arrays") else() message(WARNING "${CMAKE_Fortran_COMPILER_ID} Fortran compiler will be used with default options") From 333d3a663a15b1c4ae00bf0840ffaa8e81a56c93 Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Tue, 15 Aug 2023 12:06:49 -0700 Subject: [PATCH 3/4] Bump ESMF required version to 8.6.0. --- ESMX_AtmOcnProto/Lumo/CMakeLists.txt | 2 +- ESMX_ExternalDriverAPIProto/CMakeLists.txt | 2 +- ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ESMX_AtmOcnProto/Lumo/CMakeLists.txt b/ESMX_AtmOcnProto/Lumo/CMakeLists.txt index a573c11f..4aa0292c 100644 --- a/ESMX_AtmOcnProto/Lumo/CMakeLists.txt +++ b/ESMX_AtmOcnProto/Lumo/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.19) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -find_package(ESMF 8.5.0 MODULE REQUIRED) +find_package(ESMF 8.6.0 MODULE REQUIRED) set(CMAKE_Fortran_COMPILER "${ESMF_F90COMPILER}") diff --git a/ESMX_ExternalDriverAPIProto/CMakeLists.txt b/ESMX_ExternalDriverAPIProto/CMakeLists.txt index 4426884b..722e2da5 100644 --- a/ESMX_ExternalDriverAPIProto/CMakeLists.txt +++ b/ESMX_ExternalDriverAPIProto/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.22) list(APPEND CMAKE_MODULE_PATH "${ESMF_ESMXDIR}/Driver/cmake") # Find ESMF -find_package(ESMF 8.5.0 MODULE REQUIRED) +find_package(ESMF 8.6.0 MODULE REQUIRED) # Set compilers consistent with ESMF set(CMAKE_Fortran_COMPILER "${ESMF_F90COMPILER}") diff --git a/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt b/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt index a573c11f..4aa0292c 100644 --- a/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt +++ b/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.19) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -find_package(ESMF 8.5.0 MODULE REQUIRED) +find_package(ESMF 8.6.0 MODULE REQUIRED) set(CMAKE_Fortran_COMPILER "${ESMF_F90COMPILER}") From 2adbad11c4bc4dbafef4c0d45af0bd22aee6d1a4 Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Tue, 15 Aug 2023 12:23:54 -0700 Subject: [PATCH 4/4] Enable OpenMP for Lumo component via CMake. --- ESMX_AtmOcnProto/Lumo/CMakeLists.txt | 5 ++++- ESMX_AtmOcnProto/esmxBuild.yaml | 3 +++ ESMX_ExternalDriverAPIProto/CMakeLists.txt | 3 +++ ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt | 5 ++++- ESMX_ExternalDriverAPIProto/externalApp.F90 | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ESMX_AtmOcnProto/Lumo/CMakeLists.txt b/ESMX_AtmOcnProto/Lumo/CMakeLists.txt index 4aa0292c..ebf11396 100644 --- a/ESMX_AtmOcnProto/Lumo/CMakeLists.txt +++ b/ESMX_AtmOcnProto/Lumo/CMakeLists.txt @@ -9,6 +9,8 @@ project(Lumo VERSION 1.0 LANGUAGES Fortran) +find_package(OpenMP REQUIRED) + if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") set(CMAKE_Fortran_FLAGS "-ffree-line-length-none -Wall -Wextra -Wconversion -Wno-unused -Wno-unused-dummy-argument") set(CMAKE_Fortran_FLAGS_RELEASE "-Ofast") @@ -23,7 +25,8 @@ else() endif() add_library(Lumo lumo.F90) -target_link_libraries(Lumo ESMF) +target_link_libraries(Lumo PUBLIC ESMF) +target_link_libraries(Lumo PUBLIC OpenMP::OpenMP_Fortran) install(TARGETS Lumo EXPORT Lumo diff --git a/ESMX_AtmOcnProto/esmxBuild.yaml b/ESMX_AtmOcnProto/esmxBuild.yaml index 8eff360e..b274dcc5 100644 --- a/ESMX_AtmOcnProto/esmxBuild.yaml +++ b/ESMX_AtmOcnProto/esmxBuild.yaml @@ -1,3 +1,6 @@ +application: + link_packages: OpenMP + components: Lumo: diff --git a/ESMX_ExternalDriverAPIProto/CMakeLists.txt b/ESMX_ExternalDriverAPIProto/CMakeLists.txt index 722e2da5..c85d476d 100644 --- a/ESMX_ExternalDriverAPIProto/CMakeLists.txt +++ b/ESMX_ExternalDriverAPIProto/CMakeLists.txt @@ -17,6 +17,9 @@ project(ExternalDriverAPIProto LANGUAGES Fortran CXX C ) +# Find required packages +find_package(OpenMP REQUIRED) + # Add ESMX driver add_subdirectory(${ESMF_ESMXDIR}/Driver ./ESMX_Driver) diff --git a/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt b/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt index 4aa0292c..ebf11396 100644 --- a/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt +++ b/ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt @@ -9,6 +9,8 @@ project(Lumo VERSION 1.0 LANGUAGES Fortran) +find_package(OpenMP REQUIRED) + if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") set(CMAKE_Fortran_FLAGS "-ffree-line-length-none -Wall -Wextra -Wconversion -Wno-unused -Wno-unused-dummy-argument") set(CMAKE_Fortran_FLAGS_RELEASE "-Ofast") @@ -23,7 +25,8 @@ else() endif() add_library(Lumo lumo.F90) -target_link_libraries(Lumo ESMF) +target_link_libraries(Lumo PUBLIC ESMF) +target_link_libraries(Lumo PUBLIC OpenMP::OpenMP_Fortran) install(TARGETS Lumo EXPORT Lumo diff --git a/ESMX_ExternalDriverAPIProto/externalApp.F90 b/ESMX_ExternalDriverAPIProto/externalApp.F90 index 85890ddd..aeafac8a 100644 --- a/ESMX_ExternalDriverAPIProto/externalApp.F90 +++ b/ESMX_ExternalDriverAPIProto/externalApp.F90 @@ -36,7 +36,7 @@ program externalApp ! Initialize ESMF call ESMF_Initialize(logkindflag=ESMF_LOGKIND_MULTI, & - defaultCalkind=ESMF_CALKIND_GREGORIAN, rc=rc) + defaultCalkind=ESMF_CALKIND_GREGORIAN, globalResourceControl=.true., rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=FILENAME)) &