Skip to content

Commit

Permalink
Merge branch 'fix/esmx-cleanup-and-openmp' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
theurich committed Sep 6, 2023
2 parents a9dbc76 + 2adbad1 commit 9a42b88
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 22 deletions.
27 changes: 19 additions & 8 deletions ESMX_AtmOcnProto/Lumo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
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.6.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)

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")
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 "-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")
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
Expand Down
5 changes: 3 additions & 2 deletions ESMX_AtmOcnProto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions ESMX_AtmOcnProto/esmxBuild.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
application:
link_packages: OpenMP

components:

Lumo:
Expand Down
6 changes: 5 additions & 1 deletion ESMX_ExternalDriverAPIProto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -17,13 +17,17 @@ project(ExternalDriverAPIProto
LANGUAGES Fortran CXX C
)

# Find required packages
find_package(OpenMP REQUIRED)

# Add ESMX driver
add_subdirectory(${ESMF_ESMXDIR}/Driver ./ESMX_Driver)

# Create executable
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(
Expand Down
27 changes: 19 additions & 8 deletions ESMX_ExternalDriverAPIProto/Lumo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
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.6.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)

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")
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 "-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")
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
Expand Down
4 changes: 2 additions & 2 deletions ESMX_ExternalDriverAPIProto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ESMX_ExternalDriverAPIProto/externalApp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)) &
Expand Down

0 comments on commit 9a42b88

Please sign in to comment.