Skip to content

Commit

Permalink
Combine PROD and REPRO build options into 'Release' build type (#1171)
Browse files Browse the repository at this point in the history
Combined PROD and REPRO build modes into 'Release' build type. Now only 'Debug' and 'Release' build type are supported.
Both build types must produce bit-for-bit reproducible outputs using different number of threads, mpi tasks, different domain decomposition, have reproducible restarts etc.
  • Loading branch information
DusanJovic-NOAA authored May 3, 2022
1 parent 07edf4c commit 846f0e4
Show file tree
Hide file tree
Showing 18 changed files with 3,909 additions and 3,972 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ set(MULTI_GASES OFF CACHE BOOL "Enable MULTI_GASES")
set(MOVING_NEST OFF CACHE BOOL "Enable moving nest code")
set(OPENMP ON CACHE BOOL "Enable OpenMP threading")
set(PARALLEL_NETCDF OFF CACHE BOOL "Enable parallel NetCDF")
set(REPRO OFF CACHE BOOL "Enable REPRO mode")
set(JEDI_DRIVER OFF CACHE BOOL "Enable JEDI as top level driver")

set(CMAKE_Platform $ENV{CMAKE_Platform})
Expand All @@ -90,7 +89,6 @@ message("MULTI_GASES ...... ${MULTI_GASES}")
message("MOVING_NEST ...... ${MOVING_NEST}")
message("OPENMP ........... ${OPENMP}")
message("PARALLEL_NETCDF .. ${PARALLEL_NETCDF}")
message("REPRO ............ ${REPRO}")
message("JEDI_DRIVER ...... ${JEDI_DRIVER}")
message("")

Expand Down
2 changes: 1 addition & 1 deletion FV3
21 changes: 2 additions & 19 deletions cmake/GNU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,7 @@ if(DEBUG)
add_definitions(-DDEBUG)
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -O0 -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans -ffpe-trap=invalid,zero,overflow -fbounds-check")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
elseif(REPRO)
add_definitions(-DREPRO)
if (APPLE)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_RELEASE "-O2")
endif()

# For ccpp
set(CMAKE_C_FLAGS_RELEASE "-O2 -fPIC" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -fPIC" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -fPIC" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_BITFORBIT "-O2 -fPIC" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_BITFORBIT "-O2 -fPIC" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_BITFORBIT "-O2 -fPIC" CACHE STRING "" FORCE)
35 changes: 10 additions & 25 deletions cmake/Intel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,23 @@ if(DEBUG)
endif()
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ftrapuv")
elseif(REPRO)
add_definitions(-DREPRO)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2 -debug minimal -fp-model consistent -qoverride-limits")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -debug minimal")
else()
if(32BIT)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2 -debug minimal -fp-model source -qoverride-limits -qopt-prefetch=3")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2 -debug minimal -fp-model source -qoverride-limits -qopt-prefetch=3 -no-prec-div -no-prec-sqrt")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -debug minimal")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -debug minimal -qoverride-limits")
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -fp-model consistent")
set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal")
set(FAST "-fast-transcendentals")
if(AVX2)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -march=core-avx2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=core-avx2")
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -march=core-avx2")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -march=core-avx2")
elseif(SIMDMULTIARCH)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -axSSE4.2,CORE-AVX2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -axSSE4.2,CORE-AVX2")
elseif(AVX)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -march=core-avx-i")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=core-avx-i")
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -axSSE4.2,CORE-AVX2")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -axSSE4.2,CORE-AVX2")
elseif(AVX)
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -march=core-avx-i")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -march=core-avx-i")
endif()
endif()

# For ccpp
set(CMAKE_C_FLAGS_RELEASE "-O2 -fPIC" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -fPIC" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -fPIC" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_BITFORBIT "-O2 -fPIC" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_BITFORBIT "-O2 -fPIC" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_BITFORBIT "-O2 -fPIC" CACHE STRING "" FORCE)

if(APPLE)
# The linker on macOS does not include `common symbols` by default
# Passing the -c flag includes them and fixes an error with undefined symbols
Expand Down
Loading

0 comments on commit 846f0e4

Please sign in to comment.