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

Update pre-commit config #112

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 7 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
rev: "v5.0.0"
hooks:
- id: trailing-whitespace
args: ['--markdown-linebreak-ext=md,markdown']
- id: end-of-file-fixer
- id: check-yaml

- repo: https://github.com/zmoon/findent-pre-commit
rev: "65627b8"
rev: "17b1b07"
hooks:
# NOTE: doesn't work on Windows currently
- id: findent-pypi
additional_dependencies: [findent==4.3.1]
args: ['-i3']
exclude: |
(?x)^(
Expand All @@ -29,16 +29,11 @@ repos:
src/external/GOCART/.*
)$

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
- repo: https://github.com/BlankSpruce/gersemi
rev: "0.18.1"
hooks:
- id: cmake-format
additional_dependencies: [PyYAML]
exclude: (?x)^(
cmake/FindNetCDF.cmake
)$
- id: cmake-lint
additional_dependencies: [PyYAML]
- id: gersemi
args: [--in-place, --indent=2]
exclude: (?x)^(
cmake/FindNetCDF.cmake
)$
Expand Down
27 changes: 18 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.5)

project(
CATChem
VERSION 0.1.0
LANGUAGES Fortran)
project(CATChem VERSION 0.1.0 LANGUAGES Fortran)

include(CMakePrintHelpers)

Expand All @@ -13,9 +10,16 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
cmake_print_variables(CMAKE_Fortran_COMPILER CMAKE_Fortran_COMPILER_ID CMAKE_BUILD_TYPE)
cmake_print_variables(
CMAKE_Fortran_COMPILER
CMAKE_Fortran_COMPILER_ID
CMAKE_BUILD_TYPE
)
set(_catchem_compiler_options "")
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU|G95" AND CMAKE_BUILD_TYPE MATCHES "Debug")
if(
CMAKE_Fortran_COMPILER_ID MATCHES "GNU|G95"
AND CMAKE_BUILD_TYPE MATCHES "Debug"
)
list(
APPEND
_catchem_compiler_options
Expand All @@ -26,8 +30,12 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU|G95" AND CMAKE_BUILD_TYPE MATCHES "Deb
-fcheck=all
-ffpe-trap=invalid,zero,overflow
-fbacktrace
-fmax-errors=0)
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel" AND CMAKE_BUILD_TYPE MATCHES "Debug")
-fmax-errors=0
)
elseif(
CMAKE_Fortran_COMPILER_ID MATCHES "Intel"
AND CMAKE_BUILD_TYPE MATCHES "Debug"
)
list(
APPEND
_catchem_compiler_options
Expand All @@ -42,7 +50,8 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel" AND CMAKE_BUILD_TYPE MATCHES "D
-error-limit
0
-diag-disable
6379,10448)
6379,10448
)
endif()

add_subdirectory(src)
Expand Down
5 changes: 4 additions & 1 deletion src/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ target_link_libraries(${_lib} PUBLIC CATChem_process_dust)
target_link_libraries(${_lib} PUBLIC CATChem_process_seasalt)
target_link_libraries(${_lib} PUBLIC CATChem_process_plumerise)
target_link_libraries(${_lib} PUBLIC CATChem_process_drydep)
set_target_properties(${_lib} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
${_lib}
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)
target_compile_options(${_lib} PRIVATE ${_catchem_compiler_options})
41 changes: 23 additions & 18 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
set(_srcs
charpak_mod.F90
chemstate_mod.F90
cmn_size_mod.F90
config_mod.F90
config_opt_mod.F90
constants.F90
diagstate_mod.F90
emisstate_mod.F90
error_mod.F90
gridstate_mod.F90
init_mod.F90
metstate_mod.F90
precision_mod.F90
qfyaml_mod.F90
species_mod.F90
state_mod.F90)
set(
_srcs
charpak_mod.F90
chemstate_mod.F90
cmn_size_mod.F90
config_mod.F90
config_opt_mod.F90
constants.F90
diagstate_mod.F90
emisstate_mod.F90
error_mod.F90
gridstate_mod.F90
init_mod.F90
metstate_mod.F90
precision_mod.F90
qfyaml_mod.F90
species_mod.F90
state_mod.F90
)

add_library(CATChem_core ${_srcs})
set_target_properties(CATChem_core PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
CATChem_core
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)
target_compile_options(CATChem_core PRIVATE ${_catchem_compiler_options})
11 changes: 9 additions & 2 deletions src/external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
set(_srcs GOCART/Process_Library/GOCART2G_Process.F90 GOCART/Process_Library/GOCART2G_MieMod.F90)
set(
_srcs
GOCART/Process_Library/GOCART2G_Process.F90
GOCART/Process_Library/GOCART2G_MieMod.F90
)
set(_lib GOCART2G)

add_library(${_lib} ${_srcs})
Expand All @@ -11,4 +15,7 @@ find_package(NetCDF REQUIRED COMPONENTS Fortran)
target_link_libraries(${_lib} NetCDF::NetCDF_Fortran)
# target_link_libraries(${_lib} PUBLIC CATChem_core)

set_target_properties(${_lib} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
${_lib}
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)
5 changes: 4 additions & 1 deletion src/process/drydep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ add_library(${_lib} ${_srcs})
target_link_libraries(${_lib} PUBLIC CATChem_core)
target_link_libraries(${_lib} PUBLIC GOCART2G)

set_target_properties(${_lib} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
${_lib}
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)
14 changes: 11 additions & 3 deletions src/process/dust/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
set(_srcs CCPr_Dust_Mod.F90 ccpr_dust_common_mod.F90 ccpr_scheme_fengsha_mod.F90
ccpr_scheme_ginoux_mod.F90)
set(
_srcs
CCPr_Dust_Mod.F90
ccpr_dust_common_mod.F90
ccpr_scheme_fengsha_mod.F90
ccpr_scheme_ginoux_mod.F90
)

set(_lib CATChem_process_dust)

add_library(${_lib} ${_srcs})
target_link_libraries(${_lib} PUBLIC CATChem_core)
set_target_properties(${_lib} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
${_lib}
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)
12 changes: 10 additions & 2 deletions src/process/plumerise/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
set(_srcs CCPr_Plumerise_Mod.F90 CCPr_Scheme_Briggs_mod.F90 CCPr_Scheme_Sofiev_mod.F90)
set(
_srcs
CCPr_Plumerise_Mod.F90
CCPr_Scheme_Briggs_mod.F90
CCPr_Scheme_Sofiev_mod.F90
)

set(_lib CATChem_process_plumerise)

add_library(${_lib} ${_srcs})
target_link_libraries(${_lib} PUBLIC CATChem_core)
set_target_properties(${_lib} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
${_lib}
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)
15 changes: 12 additions & 3 deletions src/process/seasalt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
set(_srcs CCPr_SeaSalt_Mod.F90 ccpr_seasalt_common_mod.F90 ccpr_scheme_gong03_mod.F90
ccpr_scheme_gong97_mod.F90 ccpr_scheme_geos12_mod.F90)
set(
_srcs
CCPr_SeaSalt_Mod.F90
ccpr_seasalt_common_mod.F90
ccpr_scheme_gong03_mod.F90
ccpr_scheme_gong97_mod.F90
ccpr_scheme_geos12_mod.F90
)

set(_lib CATChem_process_seasalt)

add_library(${_lib} ${_srcs})
target_link_libraries(${_lib} PUBLIC CATChem_core)
set_target_properties(${_lib} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
${_lib}
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)
52 changes: 38 additions & 14 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,70 +1,94 @@
include(CTest)

add_compile_options(${_catchem_compiler_options})

add_library(testing testing_mod.f90)
target_link_libraries(testing PRIVATE CATChem_core)
set_target_properties(testing PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)

enable_testing()
set_target_properties(
testing
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)

add_executable(test_main test_main.F90)
target_link_libraries(test_main PRIVATE CATChem_core)
target_link_libraries(test_main PRIVATE CATChem)
target_link_libraries(test_main PRIVATE testing)
set_target_properties(test_main PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
test_main
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)

add_test(
NAME test_main
COMMAND test_main
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

add_test(
NAME test_main_missing_config
COMMAND test_main
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_property(TEST test_main_missing_config PROPERTY WILL_FAIL TRUE)

add_executable(test_dust test_dust.f90)
target_link_libraries(test_dust PRIVATE CATChem_core)
target_link_libraries(test_dust PRIVATE CATChem)
target_link_libraries(test_dust PRIVATE CATChem_process_dust)
target_link_libraries(test_dust PRIVATE testing)
set_target_properties(test_dust PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
test_dust
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)

add_test(
NAME test_ccpr_dust
COMMAND test_dust
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

add_executable(test_seasalt test_seasalt.F90)
target_link_libraries(test_seasalt PRIVATE CATChem_core)
target_link_libraries(test_seasalt PRIVATE CATChem)
target_link_libraries(test_seasalt PRIVATE CATChem_process_seasalt)
target_link_libraries(test_seasalt PRIVATE testing)
set_target_properties(test_seasalt PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
test_seasalt
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)

add_test(
NAME test_ccpr_seasalt
COMMAND test_seasalt
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

add_executable(test_prise test_plumerise.F90)
target_link_libraries(test_prise PRIVATE CATChem_core)
target_link_libraries(test_prise PRIVATE CATChem)
target_link_libraries(test_prise PRIVATE testing)
set_target_properties(test_prise PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
test_prise
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)

add_test(
NAME test_plumerise
COMMAND test_prise
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

add_executable(test_drydep test_drydep.f90)
target_link_libraries(test_drydep PRIVATE CATChem_core)
target_link_libraries(test_drydep PRIVATE CATChem)
target_link_libraries(test_drydep PRIVATE testing)
set_target_properties(test_drydep PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
set_target_properties(
test_drydep
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include
)

add_test(
NAME test_drydep
COMMAND test_drydep
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
Loading