Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor mc ica #12

Open
wants to merge 77 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
344337f
Added cmake-based build system
FrostyMike Dec 1, 2020
49981f4
Merge pull request #1 from FrostyMike/add_outofsource_build
FrostyMike Dec 2, 2020
cb9af29
Added missing file
FrostyMike Dec 2, 2020
0ff01f6
-
FrostyMike Dec 2, 2020
782123e
Added build type to project name
FrostyMike Dec 2, 2020
75dca0d
Fixed newer cmake errors
Dec 2, 2020
3c37e84
Added XML driver report
Dec 16, 2020
dbf3953
Removed old file
Dec 16, 2020
f1a2c6c
Added reference ci tests
Dec 16, 2020
d7072f6
Added tolerance tests
Dec 16, 2020
a1a091f
Moved tolerance reference testcases
Dec 17, 2020
359d148
Added CPU regression tests
Dec 17, 2020
185a4a2
Fixed cmake NETCDF library
FrostyMike Jan 14, 2021
37fdb38
Fixed PGI compilation
FrostyMike Jan 14, 2021
d53b798
radiation() replaced if with select
FrostyMike Jan 18, 2021
c7d11c9
Refactored solver type enum
FrostyMike Jan 18, 2021
68cd02a
Split radiation_single_level::get_albedos into 2 subroutines to reduc…
FrostyMike Jan 18, 2021
ef219b1
Gfortran compilation fix
Jan 20, 2021
8f1099e
Split radiation_ifs_rrtm::gas_optics into 2 subroutines
Jan 20, 2021
08c18e2
Split radiation_monochromatic::gas_optics into 2 subroutines
Jan 20, 2021
7b8bb48
Split radiation_cloud_optics::cloud_optics into 2 subroutines
Jan 21, 2021
5ceaff7
Split radiation_monochromatic::cloud_optics into 2 subroutines
Jan 21, 2021
58a7c58
Split radiation_aerosol_optics::add_aerosol_optics into 2 subroutines
Jan 21, 2021
9285a07
Split radiation_aerosol_optics::add_aerosol_optics into 2 subroutines…
Jan 21, 2021
ccd0021
Made radiation_interface::radiation() non-recursive
Jan 21, 2021
7db6598
Split radiation_flux::flux_type::calc_surface_spectral into 2 subrout…
Jan 21, 2021
270c3d8
Split radiation::radiation_run into 2 subroutines
Jan 21, 2021
98848a6
Parallelized radiation::radiation_run()
Jan 21, 2021
bbf35e0
Cray compilation fixes
Jan 22, 2021
a33493f
Driver fix: honor block size in serial mode
FrostyMike Jan 24, 2021
75af848
Gfortran build fix
FrostyMike Jan 24, 2021
3840a61
Print fix
FrostyMike Jan 24, 2021
52c7e89
Made array reshaping explicit in rttm
FrostyMike Jan 24, 2021
09f799c
Vectorized radiation_aerosol_optics::add_aerosol_optics_sw
FrostyMike Jan 24, 2021
6cfcfc6
Moved reordering routines into separate module
Jan 25, 2021
e85dd8f
Replaced reshape with explicit transpositions
FrostyMike Jan 26, 2021
b916d72
Added 2 dim reversal util
FrostyMike Jan 27, 2021
462949b
MovFixed bugs in radiation_utils::reverse_dim_2
Jan 27, 2021
5dd434f
Added script calculating size of IO data
Jan 27, 2021
e5c3a33
Added script calculating size of the stack for radiation_run_sw
Jan 28, 2021
6da5f74
Added script calculating size of the stack for radiation_run_lw
Jan 28, 2021
bdb42c8
Added GPU demo app
FrostyMike Jan 29, 2021
b8c43f6
Added GPU demo functionality
FrostyMike Jan 29, 2021
9aeaad5
Refactored gpu_demo into module; added LW functionality
FrostyMike Jan 29, 2021
a7b9635
Merge branch 'refactor_McICA' of https://github.com/MeteoSwiss-APN/ec…
Jan 29, 2021
25ae9f3
Removed OpenMP from gpu_demo
FrostyMike Jan 31, 2021
3c23069
Gpu demo compile fix
FrostyMike Feb 1, 2021
f2660a3
Tsa build fixes
Feb 1, 2021
4de7850
Tsa build fixes (2)
Feb 1, 2021
9d54844
Added memory usage printout to gpu_demo
Feb 1, 2021
bb4f265
Merge branch 'refactor_McICA' of https://github.com/MeteoSwiss-APN/ec…
Feb 1, 2021
763cfc5
Added missing file to git
Feb 2, 2021
ee4d962
Merge branch 'refactor_McICA' of https://github.com/MeteoSwiss-APN/ec…
Feb 2, 2021
14ec502
Added memory pool demo program
Feb 2, 2021
088676c
Removed reinterpret casts and pointer arithmetic from mempool_demo
FrostyMike Feb 2, 2021
fced66b
Added build script for mempool_demo
FrostyMike Feb 2, 2021
e5f84f3
mempool_demo: moved array functions to the same model
FrostyMike Feb 3, 2021
606b30e
mempool_demo: added openacc
FrostyMike Feb 4, 2021
b6c867a
Added functor_demo
FrostyMike Feb 4, 2021
1923596
Added block length tests
Feb 4, 2021
dfd9583
Added block test plot script
Feb 5, 2021
1061cf7
Added script for combining block test len results
Feb 5, 2021
f54b751
Added omp figure to block test plot script
Feb 5, 2021
532d451
Removed py-venv creation from default build
FrostyMike Feb 15, 2021
8fd1c20
Added support for OpenACC to PGI build
FrostyMike Feb 15, 2021
333b60c
Removed dr hook from mcica_lw routines
FrostyMike Feb 15, 2021
f469013
Removed disabled code paths from mcica_lw
FrostyMike Feb 15, 2021
0ed7f42
Turned mcica_lw n_g_lw into a constant
FrostyMike Feb 15, 2021
6af7b7f
Refactored solver_mcica_lw to process one column
FrostyMike Feb 15, 2021
a98dae3
Moved cloud_generator in front of solver_mcica_lw
FrostyMike Feb 16, 2021
07335d2
Added OpenACC to solver_mcica_lw_col
FrostyMike Feb 16, 2021
838d588
Added OpenACC workers to solver_mcica_lw_col
FrostyMike Feb 16, 2021
9e294ba
Added OpenACC to solver_mcica_lw_col (2)
FrostyMike Feb 16, 2021
d2eafac
Added OpenACC to solver_mcica_lw_col (3)
FrostyMike Feb 16, 2021
0651a60
Added gang-level OpenACC to solver_mcica_lw; Increased cuda heap size…
FrostyMike Feb 16, 2021
b565b16
acc_get_device_num fix
FrostyMike Feb 17, 2021
9763ab9
Added GPU registers limit
FrostyMike Feb 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 205 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# This CMakeLists.txt file is the entry point for the configuration and the
# compilation of the ECRAD.

FUNCTION(PREPEND var prefix)
SET(listVar "")
FOREACH(f ${ARGN})
LIST(APPEND listVar "${prefix}/${f}")
ENDFOREACH(f)
SET(${var} "${listVar}" PARENT_SCOPE)
ENDFUNCTION()

cmake_minimum_required(VERSION 3.0)

set(DEFAULT_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
endif()

IF(CMAKE_BUILD_TYPE MATCHES Debug)
message("Debug build")
set(BUILD_TYPE "Debug")
ELSEIF(CMAKE_BUILD_TYPE MATCHES Release)
message("Release build")
set(BUILD_TYPE "Release")
ELSE()
message( FATAL_ERROR "Unsupported build type ${CMAKE_BUILD_TYPE}")
ENDIF()

project("ECRAD-MCH ${BUILD_TYPE}" VERSION 1.4.0)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/module")

enable_language(Fortran)
enable_language(CXX)

set(NETCDF_F90 "YES")
find_package(NetCDF REQUIRED)

option(GPU_ACC "Compile for GPU target using OpenACC" OFF)

set(GPU_ACC_TARGET_CC "" CACHE STRING "Compute capability of the GPU target")
set(GPU_ACC_TARGET_MAXREGCOUNT "32" CACHE STRING "Maximum number of registers per thread for GPU target")

if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "PGI")
include(cmake/compiler/pgi.cmake)
elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel")
include(cmake/compiler/intel.cmake)
elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Cray")
include(cmake/compiler/cray.cmake)
else()
include(cmake/compiler/gnu.cmake)
endif()

option(SINGLE_PRECISION "Use single precision" OFF)
option(USE_OPENMP "Use OpenMP" ON)
option(USE_DR_HOOK "Use Dr Hook profiling system" OFF)

option(USE_REPORT "Generate XML report" ON)

#if("${NetCDF_VERSION}" VERSION_GREATER_EQUAL "4")
set(FC_FPPFLAGS "${FC_FPPFLAGS} -DNC_NETCDF")
#endif()

if(SINGLE_PRECISION)
set(FC_FPPFLAGS "${FC_FPPFLAGS} -DSINGLE_PRECISION")
endif()

if(USE_DR_HOOK)
message( FATAL_ERROR "Dr hook not supported in this build")
endif()

set(Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/mod)

if(USE_REPORT)
set(FC_FPPFLAGS "${FC_FPPFLAGS} -DXML_REPORT_SUPPORTED")
endif()

set(CMAKE_Fortran_FLAGS_RELEASE "${FC_RELEASE_WARNFLAGS} ${FC_BASIC_FLAGS} ${FC_FPPFLAGS} ${FC_RELEASE_OPTFLAGS} ${FC_RELEASE_DEBUGFLAGS} -I ${Fortran_MODULE_DIRECTORY}")
set(CMAKE_Fortran_FLAGS_RELEASE "${FC_RELEASE_WARNFLAGS} ${FC_BASIC_FLAGS} ${FC_FPPFLAGS} ${FC_RELEASE_OPTFLAGS} ${FC_RELEASE_DEBUGFLAGS} -I ${Fortran_MODULE_DIRECTORY}")
set(CMAKE_Fortran_FLAGS_DEBUG "${FC_DEBUG_WARNFLAGS} ${FC_BASIC_FLAGS} ${FC_FPPFLAGS} ${FC_DEBUG_OPTFLAGS} ${FC_DEBUG_DEBUGFLAGS} -I ${Fortran_MODULE_DIRECTORY}")

set(CMAKE_CXX_FLAGS_RELEASE "-fpic")

if(USE_OPENMP)
find_package(OpenMP REQUIRED)
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} ${OpenMP_Fortran_FLAGS}")
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${OpenMP_Fortran_FLAGS}")
endif()

include_directories(${CMAKE_SOURCE_DIR}/include ${NETCDF_INCLUDES})

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

add_library(ifsaux)
set_target_properties( ifsaux PROPERTIES Fortran_MODULE_DIRECTORY "${Fortran_MODULE_DIRECTORY}" )
add_subdirectory(ifsaux)

add_library(drhook)
set_target_properties( drhook PROPERTIES Fortran_MODULE_DIRECTORY "${Fortran_MODULE_DIRECTORY}" )
add_subdirectory(drhook)
add_dependencies(drhook ifsaux)

add_library(ifsrrtm)
set_target_properties( ifsrrtm PROPERTIES Fortran_MODULE_DIRECTORY "${Fortran_MODULE_DIRECTORY}" )
add_subdirectory(ifsrrtm)
add_dependencies(ifsrrtm drhook)

add_library(utilities)
set_target_properties( utilities PROPERTIES Fortran_MODULE_DIRECTORY "${Fortran_MODULE_DIRECTORY}" )
add_subdirectory(utilities)
add_dependencies(utilities drhook ifsaux)

add_library(radiation)
set_target_properties( radiation PROPERTIES Fortran_MODULE_DIRECTORY "${Fortran_MODULE_DIRECTORY}" )
add_subdirectory(radiation)
add_dependencies(radiation utilities)

add_library(radsurf STATIC)
set_target_properties( radsurf PROPERTIES Fortran_MODULE_DIRECTORY "${Fortran_MODULE_DIRECTORY}" )
add_subdirectory(radsurf)
add_dependencies(radsurf radiation)

add_subdirectory(driver)
message(
STATUS
"NETCDF_LIBRARIES_F90: ${NETCDF_LIBRARIES_F90}"
)

if(USE_REPORT)
add_library(driver_report_c)

add_library(driver_report_fortran_wrapper SHARED)
set_target_properties( driver_report_fortran_wrapper PROPERTIES Fortran_MODULE_DIRECTORY "${Fortran_MODULE_DIRECTORY}" )
add_dependencies(driver_report_fortran_wrapper driver_report_c)
target_link_libraries(driver_report_fortran_wrapper PRIVATE driver_report_c)
endif()

add_executable(ecrad ${ecrad_SRC})
set_target_properties( ecrad PROPERTIES Fortran_MODULE_DIRECTORY "${Fortran_MODULE_DIRECTORY}" )
set(STATIC_LIBS ifsaux drhook ifsrrtm utilities radiation radsurf)
if(USE_REPORT)
set(STATIC_LIBS ${STATIC_LIBS})
endif()
set(ECRAD_LIBS ${STATIC_LIBS} ${NETCDF_LIBRARIES_F90})
if(USE_OPENMP)
set(ECRAD_LIBS ${ECRAD_LIBS} ${OpenMP_Fortran_LIBRARIES})
endif()

target_link_libraries(ecrad PRIVATE ${ECRAD_LIBS} ${ECRAD_LIBS} ${ECRAD_LIBS} driver_report_fortran_wrapper)

find_package(Python 3.6 REQUIRED)

set(PY_VENV_DIR "${CMAKE_BINARY_DIR}/pyenv")

set(PY_PACKAGES xarray numpy netCDF4 generateDS py-cpuinfo matplotlib)

add_custom_target(create-python-virtual-environment)
add_custom_command(
TARGET create-python-virtual-environment
COMMAND echo "${Python_EXECUTABLE} -m venv ${PY_VENV_DIR}"
COMMAND ${Python_EXECUTABLE} -m venv ${PY_VENV_DIR}
COMMAND ${PY_VENV_DIR}/bin/pip3 install ${PY_PACKAGES}
COMMENT "Creating python virtual environment"
)

# Regenerate serialization code for driver report
add_custom_target(update-driver-report-format)
add_subdirectory(driver_report)

# Regenerate serialization code for test reports
add_custom_target(update-test-report-formats)

add_custom_target(reset-ci-tests)
add_dependencies(reset-ci-tests ecrad create-python-virtual-environment)
add_subdirectory(ci_tests)
add_custom_command(
TARGET reset-ci-tests
COMMAND ${PY_VENV_DIR}/bin/python3 ${CI_TESTS_RUNTIME_DIR}/tests_runner.py --reset-ci-tests
COMMENT "Generate reference results for ci testcases"
)

add_custom_target(run-ci-tests)
add_dependencies(run-ci-tests ecrad create-python-virtual-environment)
add_custom_command(
TARGET run-ci-tests
COMMAND ${PY_VENV_DIR}/bin/python3 ${CI_TESTS_RUNTIME_DIR}/tests_runner.py --run-ci-tests
COMMENT "Running continious integration tests"
)

add_custom_target(run-cpu-regression-tests)
add_dependencies(run-cpu-regression-tests ecrad create-python-virtual-environment)
add_custom_command(
TARGET run-cpu-regression-tests
COMMAND ${PY_VENV_DIR}/bin/python3 ${CI_TESTS_RUNTIME_DIR}/tests_runner.py --run-cpu-reg-tests
COMMENT "Running continious integration CPU regression tests"
)




Loading