-
Notifications
You must be signed in to change notification settings - Fork 63
Bug fix for unit conversion error in ccpp_prebuild.py (variables that are slices of a n+1 dimensional array have wrong allocation) #600
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
Merged
mkavulich
merged 6 commits into
NCAR:main
from
climbfuji:bugfix/unit_conv_invalid_allocation_prebuild
Oct 22, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c847e9c
Minor updates in test_prebuid/test_blocked_data,test_chunked_data}: f…
climbfuji c628acd
Add test_prebuild/test_unit_conv for testing unit conversions for act…
climbfuji bc78391
In scripts/mkcap.py: always declare host model variables as 'target' …
climbfuji 02b9393
Bug fix in scripts/mkstatic.py: define dim_string_allocate so that te…
climbfuji 8c8b604
Apply suggestions from code review
climbfuji f80f9c9
Fix unmatched parentheses in test_unit_conv/*.F90
climbfuji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,98 @@ | ||
#------------------------------------------------------------------------------ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
project(ccpp_unit_conv | ||
VERSION 1.0.0 | ||
LANGUAGES Fortran) | ||
|
||
#------------------------------------------------------------------------------ | ||
# Request a static build | ||
option(BUILD_SHARED_LIBS "Build a shared library" OFF) | ||
|
||
#------------------------------------------------------------------------------ | ||
# Set MPI flags for C/C++/Fortran with MPI F08 interface | ||
find_package(MPI REQUIRED Fortran) | ||
if(NOT MPI_Fortran_HAVE_F08_MODULE) | ||
message(FATAL_ERROR "MPI implementation does not support the Fortran 2008 mpi_f08 interface") | ||
endif() | ||
|
||
#------------------------------------------------------------------------------ | ||
# 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_unit_conv STATIC ${SCHEMES} ${CAPS} ${API}) | ||
target_link_libraries(ccpp_unit_conv PRIVATE MPI::MPI_Fortran) | ||
# 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_unit_conv PROPERTIES VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR}) | ||
|
||
add_executable(test_unit_conv.x main.F90) | ||
add_dependencies(test_unit_conv.x ccpp_unit_conv) | ||
target_link_libraries(test_unit_conv.x ccpp_unit_conv) | ||
set_target_properties(test_unit_conv.x PROPERTIES LINKER_LANGUAGE Fortran) | ||
|
||
# Define where to install the library | ||
install(TARGETS ccpp_unit_conv | ||
EXPORT ccpp_unit_conv-targets | ||
ARCHIVE DESTINATION lib | ||
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION lib | ||
) | ||
# Export our configuration | ||
install(EXPORT ccpp_unit_conv-targets | ||
FILE ccpp_unit_conv-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 hidden or 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,16 @@ | ||
# How to build the chunked data test | ||
climbfuji marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
1. Set compiler environment as appropriate for your system | ||
2. Run the following commands: | ||
``` | ||
cd test_prebuild/test_chunked_data/ | ||
climbfuji marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
./test_chunked_data.x | ||
climbfuji marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# On systems where linking against the MPI library requires a parallel launcher, | ||
# use 'mpirun -np 1 ./test_chunked_data.x' or 'srun -n 1 ./test_chunked_data.x' etc. | ||
climbfuji marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` |
This file contains hidden or 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 @@ | ||
module ccpp_kinds | ||
|
||
!! \section arg_table_ccpp_kinds | ||
!! \htmlinclude ccpp_kinds.html | ||
!! | ||
|
||
use iso_fortran_env, only: real64 | ||
|
||
implicit none | ||
|
||
integer, parameter :: kind_phys = real64 | ||
|
||
end module ccpp_kinds |
This file contains hidden or 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,15 @@ | ||
[ccpp-table-properties] | ||
name = ccpp_kinds | ||
type = module | ||
dependencies = | ||
|
||
######################################################################## | ||
[ccpp-arg-table] | ||
name = ccpp_kinds | ||
type = module | ||
[kind_phys] | ||
standard_name = kind_phys | ||
long_name = definition of kind_phys | ||
units = none | ||
dimensions = () | ||
type = integer |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.