forked from NCAR/ccpp-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NCAR#515 from climbfuji/feature/ccpp_prebuild_bloc…
…ked_data_ci_tests ccpp-prebuild: add blocked data tests and run prebuild tests in CI
- Loading branch information
Showing
12 changed files
with
722 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: ccpp-prebuild | ||
|
||
on: | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
unit-tests: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: ccpp-prebuild unit tests | ||
run: | | ||
export PYTHONPATH=$(pwd)/scripts:$(pwd)/scripts/parse_tools | ||
cd test_prebuild | ||
python3 test_metadata_parser.py | ||
python3 test_mkstatic.py | ||
- name: ccpp-prebuild blocked data tests | ||
run: | | ||
cd test_prebuild/test_blocked_data | ||
python3 ../../scripts/ccpp_prebuild.py --config=ccpp_prebuild_config.py --builddir=build | ||
cd build | ||
cmake .. | ||
make | ||
./test_blocked_data.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#------------------------------------------------------------------------------ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
project(ccpp_blocked_data | ||
VERSION 1.0.0 | ||
LANGUAGES Fortran) | ||
|
||
#------------------------------------------------------------------------------ | ||
# Request a static build | ||
option(BUILD_SHARED_LIBS "Build a shared library" OFF) | ||
|
||
#------------------------------------------------------------------------------ | ||
# Set the sources: physics type definitions | ||
set(TYPEDEFS $ENV{CCPP_TYPEDEFS}) | ||
if(TYPEDEFS) | ||
message(STATUS "Got CCPP TYPEDEFS from environment variable: ${TYPEDEFS}") | ||
else(TYPEDEFS) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/CCPP_TYPEDEFS.cmake) | ||
message(STATUS "Got CCPP TYPEDEFS from cmakefile include file: ${TYPEDEFS}") | ||
endif(TYPEDEFS) | ||
|
||
# Generate list of Fortran modules from the CCPP type | ||
# definitions that need need to be installed | ||
foreach(typedef_module ${TYPEDEFS}) | ||
list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/${typedef_module}) | ||
endforeach() | ||
|
||
#------------------------------------------------------------------------------ | ||
# Set the sources: physics schemes | ||
set(SCHEMES $ENV{CCPP_SCHEMES}) | ||
if(SCHEMES) | ||
message(STATUS "Got CCPP SCHEMES from environment variable: ${SCHEMES}") | ||
else(SCHEMES) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/CCPP_SCHEMES.cmake) | ||
message(STATUS "Got CCPP SCHEMES from cmakefile include file: ${SCHEMES}") | ||
endif(SCHEMES) | ||
|
||
# Set the sources: physics scheme caps | ||
set(CAPS $ENV{CCPP_CAPS}) | ||
if(CAPS) | ||
message(STATUS "Got CCPP CAPS from environment variable: ${CAPS}") | ||
else(CAPS) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/CCPP_CAPS.cmake) | ||
message(STATUS "Got CCPP CAPS from cmakefile include file: ${CAPS}") | ||
endif(CAPS) | ||
|
||
# Set the sources: physics scheme caps | ||
set(API $ENV{CCPP_API}) | ||
if(API) | ||
message(STATUS "Got CCPP API from environment variable: ${API}") | ||
else(API) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/CCPP_API.cmake) | ||
message(STATUS "Got CCPP API from cmakefile include file: ${API}") | ||
endif(API) | ||
|
||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0 -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans -ffpe-trap=invalid,zero,overflow -fbounds-check -ggdb -fbacktrace -ffree-line-length-none") | ||
|
||
#------------------------------------------------------------------------------ | ||
add_library(ccpp_blocked_data STATIC ${SCHEMES} ${CAPS} ${API}) | ||
# Generate list of Fortran modules from defined sources | ||
foreach(source_f90 ${CAPS} ${API}) | ||
get_filename_component(tmp_source_f90 ${source_f90} NAME) | ||
string(REGEX REPLACE ".F90" ".mod" tmp_module_f90 ${tmp_source_f90}) | ||
string(TOLOWER ${tmp_module_f90} module_f90) | ||
list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/${module_f90}) | ||
endforeach() | ||
|
||
set_target_properties(ccpp_blocked_data PROPERTIES VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR}) | ||
|
||
add_executable(test_blocked_data.x main.F90) | ||
add_dependencies(test_blocked_data.x ccpp_blocked_data) | ||
target_link_libraries(test_blocked_data.x ccpp_blocked_data) | ||
set_target_properties(test_blocked_data.x PROPERTIES LINKER_LANGUAGE Fortran) | ||
|
||
# Define where to install the library | ||
install(TARGETS ccpp_blocked_data | ||
EXPORT ccpp_blocked_data-targets | ||
ARCHIVE DESTINATION lib | ||
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION lib | ||
) | ||
# Export our configuration | ||
install(EXPORT ccpp_blocked_data-targets | ||
FILE ccpp_blocked_data-config.cmake | ||
DESTINATION lib/cmake | ||
) | ||
# Define where to install the C headers and Fortran modules | ||
#install(FILES ${HEADERS_C} DESTINATION include) | ||
install(FILES ${MODULES_F90} DESTINATION include) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# How to build the blocked data test | ||
|
||
1. Set compiler environment as appropriate for your system | ||
2. Run the following commands: | ||
``` | ||
cd test_prebuild/test_blocked_data/ | ||
rm -fr build | ||
mkdir build | ||
../../scripts/ccpp_prebuild.py --config=ccpp_prebuild_config.py --builddir=build | ||
cd build | ||
cmake .. 2>&1 | tee log.cmake | ||
make 2>&1 | tee log.make | ||
``` |
118 changes: 118 additions & 0 deletions
118
test_prebuild/test_blocked_data/blocked_data_scheme.F90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
!>\file blocked_data_scheme.F90 | ||
!! This file contains a blocked_data_scheme CCPP scheme that does nothing | ||
!! except requesting the minimum, mandatory variables. | ||
|
||
module blocked_data_scheme | ||
|
||
use, intrinsic :: iso_fortran_env, only: error_unit | ||
implicit none | ||
|
||
private | ||
public :: blocked_data_scheme_init, & | ||
blocked_data_scheme_timestep_init, & | ||
blocked_data_scheme_run, & | ||
blocked_data_scheme_timestep_finalize, & | ||
blocked_data_scheme_finalize | ||
|
||
! This is for unit testing only | ||
integer, parameter, dimension(4) :: data_array_sizes = (/6,6,6,3/) | ||
|
||
contains | ||
|
||
!! \section arg_table_blocked_data_scheme_init Argument Table | ||
!! \htmlinclude blocked_data_scheme_init.html | ||
!! | ||
subroutine blocked_data_scheme_init(data_array, errmsg, errflg) | ||
character(len=*), intent(out) :: errmsg | ||
integer, intent(out) :: errflg | ||
integer, intent(in) :: data_array(:) | ||
! Initialize CCPP error handling variables | ||
errmsg = '' | ||
errflg = 0 | ||
! Check size of data array | ||
write(error_unit,'(a,i3)') 'In blocked_data_scheme_init: checking size of data array to be', sum(data_array_sizes) | ||
if (size(data_array)/=sum(data_array_sizes)) then | ||
write(errmsg,'(2(a,i3))') "Error, expected size(data_array)==", sum(data_array_sizes), "but got ", size(data_array) | ||
errflg = 1 | ||
return | ||
end if | ||
end subroutine blocked_data_scheme_init | ||
|
||
!! \section arg_table_blocked_data_scheme_timestep_init Argument Table | ||
!! \htmlinclude blocked_data_scheme_timestep_init.html | ||
!! | ||
subroutine blocked_data_scheme_timestep_init(data_array, errmsg, errflg) | ||
character(len=*), intent(out) :: errmsg | ||
integer, intent(out) :: errflg | ||
integer, intent(in) :: data_array(:) | ||
! Initialize CCPP error handling variables | ||
errmsg = '' | ||
errflg = 0 | ||
! Check size of data array | ||
write(error_unit,'(a,i3)') 'In blocked_data_scheme_timestep_init: checking size of data array to be', sum(data_array_sizes) | ||
if (size(data_array)/=sum(data_array_sizes)) then | ||
write(errmsg,'(2(a,i3))') "Error, expected size(data_array)==", sum(data_array_sizes), " but got ", size(data_array) | ||
errflg = 1 | ||
return | ||
end if | ||
end subroutine blocked_data_scheme_timestep_init | ||
|
||
!! \section arg_table_blocked_data_scheme_run Argument Table | ||
!! \htmlinclude blocked_data_scheme_run.html | ||
!! | ||
subroutine blocked_data_scheme_run(nb, data_array, errmsg, errflg) | ||
character(len=*), intent(out) :: errmsg | ||
integer, intent(out) :: errflg | ||
integer, intent(in) :: nb | ||
integer, intent(in) :: data_array(:) | ||
! Initialize CCPP error handling variables | ||
errmsg = '' | ||
errflg = 0 | ||
! Check size of data array | ||
write(error_unit,'(2(a,i3))') 'In blocked_data_scheme_run: checking size of data array for block', nb, ' to be', data_array_sizes(nb) | ||
if (size(data_array)/=data_array_sizes(nb)) then | ||
write(errmsg,'(a,i4)') "Error in blocked_data_scheme_run, expected size(data_array)==6, got ", size(data_array) | ||
errflg = 1 | ||
return | ||
end if | ||
end subroutine blocked_data_scheme_run | ||
|
||
!! \section arg_table_blocked_data_scheme_timestep_finalize Argument Table | ||
!! \htmlinclude blocked_data_scheme_timestep_finalize.html | ||
!! | ||
subroutine blocked_data_scheme_timestep_finalize(data_array, errmsg, errflg) | ||
character(len=*), intent(out) :: errmsg | ||
integer, intent(out) :: errflg | ||
integer, intent(in) :: data_array(:) | ||
! Initialize CCPP error handling variables | ||
errmsg = '' | ||
errflg = 0 | ||
! Check size of data array | ||
write(error_unit,'(a,i3)') 'In blocked_data_scheme_timestep_finalize: checking size of data array to be', sum(data_array_sizes) | ||
if (size(data_array)/=sum(data_array_sizes)) then | ||
write(errmsg,'(2(a,i3))') "Error, expected size(data_array)==", sum(data_array_sizes), "but got ", size(data_array) | ||
errflg = 1 | ||
return | ||
end if | ||
end subroutine blocked_data_scheme_timestep_finalize | ||
|
||
!! \section arg_table_blocked_data_scheme_finalize Argument Table | ||
!! \htmlinclude blocked_data_scheme_finalize.html | ||
!! | ||
subroutine blocked_data_scheme_finalize(data_array, errmsg, errflg) | ||
character(len=*), intent(out) :: errmsg | ||
integer, intent(out) :: errflg | ||
integer, intent(in) :: data_array(:) | ||
! Initialize CCPP error handling variables | ||
errmsg = '' | ||
errflg = 0 | ||
! Check size of data array | ||
write(error_unit,'(a,i3)') 'In blocked_data_scheme_finalize: checking size of data array to be', sum(data_array_sizes) | ||
if (size(data_array)/=sum(data_array_sizes)) then | ||
write(errmsg,'(2(a,i3))') "Error, expected size(data_array)==", sum(data_array_sizes), "but got ", size(data_array) | ||
errflg = 1 | ||
return | ||
end if | ||
end subroutine blocked_data_scheme_finalize | ||
|
||
end module blocked_data_scheme |
Oops, something went wrong.