-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
183 changed files
with
857 additions
and
408 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,73 @@ | ||
name: Fortran Unit Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- development | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
gcc-toolchain: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: [12, 13, 14] | ||
env: | ||
CC: gcc-${{ matrix.version }} | ||
CXX: g++-${{ matrix.version }} | ||
FC: gfortran-${{ matrix.version }} | ||
steps: | ||
- name: Checkout cam-sima | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build pFUnit | ||
run: | | ||
git clone --depth 1 --branch v4.10.0 https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git | ||
cd pFUnit | ||
cmake -B./build -S. | ||
cd build | ||
make install | ||
- name: Build cam-sima | ||
run: | | ||
cmake \ | ||
-DCMAKE_PREFIX_PATH=/home/runner/work/CAM-SIMA/CAM-SIMA/pFUnit/build/installed \ | ||
-DCAM_SIMA_ENABLE_CODE_COVERAGE=ON \ | ||
-B./build \ | ||
-S./test/unit/fortran | ||
cd build | ||
make | ||
- name: Run fortran unit tests | ||
run: | | ||
cd build && ctest -V --output-on-failure --output-junit test_results.xml | ||
- name: Upload unit test results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: unit-test-results-${{ env.FC }} | ||
path: build/test_results.xml | ||
|
||
- name: Setup GCov | ||
run: | | ||
python3 -m venv venv | ||
source venv/bin/activate | ||
pip3 install gcovr | ||
- name: Run Gcov | ||
run: | | ||
source venv/bin/activate | ||
cd build | ||
gcovr --gcov-executable gcov-${{ matrix.version }} -r .. --filter '\.\./src' --html cam_sima_code_coverage.html --txt | ||
- name: Upload code coverage results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: code-coverage-results-${{ env.FC }} | ||
path: build/cam_sima_code_coverage.html |
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
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
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
cime_config/testdefs/testmods_dirs/cam/outfrq_kessler_derecho/shell_commands
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 |
---|---|---|
@@ -1 +1 @@ | ||
./xmlchange CAM_CONFIG_OPTS="--dyn none --physics-suites kessler" | ||
./xmlchange CAM_CONFIG_OPTS="--dyn none --physics-suites kessler_test" |
1 change: 1 addition & 0 deletions
1
cime_config/testdefs/testmods_dirs/cam/outfrq_zm_derecho/shell_commands
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 @@ | ||
./xmlchange CAM_CONFIG_OPTS="--dyn none --physics-suites zhang_mcfarlane" |
16 changes: 16 additions & 0 deletions
16
cime_config/testdefs/testmods_dirs/cam/outfrq_zm_derecho/user_nl_cam
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,16 @@ | ||
ncdata='/glade/campaign/cesm/community/amwg/sima_baselines/cam_sima_test_snapshots/cam_ne3pg3_ZM_snapshot_derecho_gnu_before_c20250116.nc' | ||
ncdata_check='/glade/campaign/cesm/community/amwg/sima_baselines/cam_sima_test_snapshots/cam_ne3pg3_ZM_snapshot_derecho_gnu_after_c20250116.nc' | ||
debug_output=0 | ||
pver=32 | ||
zmconv_momcd=.7D0 | ||
zmconv_momcu=.7D0 | ||
zmconv_num_cin=1 | ||
hist_add_inst_fields;h1: ZMDT, ZMDQ, CAPE, FREQZM, CMFMC_DP, ZMMU, ZMMD, DLFZM, PCONVT, PCONVB, ZMFLXPRC, ZMFLXSNW | ||
hist_add_inst_fields;h1: ZMNTPRPD, ZMNTSNPD, ZMEIHEAT, PRECCDZM, PRECZ | ||
hist_add_inst_fields;h1: ZMUPGU, ZMUPGD, ZMVPGU, ZMVPGD, ZMICUU, ZMICUD, ZMICVU, ZMICVD | ||
hist_add_inst_fields;h1: EVAPTZM, FZSNTZM, EVSNTZM, EVAPQZM | ||
hist_add_inst_fields;h1: ZMMTU, ZMMTV, ZMMTT | ||
hist_add_inst_fields;h1: ZMDLIQ, ZMDICE | ||
hist_output_frequency;h1: 1*nstep | ||
hist_precision;h1: REAL64 | ||
hist_max_frames;h1: 1 |
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,9 @@ | ||
set(CORE_UTILS_SRC string_core_utils.F90) | ||
|
||
# core_utils is not integrated into the CMake build of any top level | ||
# project yet and this CMake is for testing purposes only. | ||
# Making a change to this project's CMake will not impact the build of | ||
# a parent project at this time. | ||
add_library(core_utils ${CORE_UTILS_SRC}) | ||
target_include_directories(core_utils PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
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,162 @@ | ||
module string_core_utils | ||
|
||
implicit none | ||
private | ||
|
||
public :: core_to_str ! Convert integer to left justified string | ||
public :: core_int_date_to_yyyymmdd ! Convert encoded date integer to "yyyy-mm-dd" format | ||
public :: core_int_seconds_to_hhmmss ! Convert integer seconds past midnight to "hh:mm:ss" format | ||
public :: core_stringify ! Convert one or more values of any intrinsic data types to a character string for pretty printing | ||
|
||
CONTAINS | ||
|
||
character(len=10) pure function core_to_str(n) | ||
! return default integer as a left justified string | ||
|
||
integer, intent(in) :: n | ||
|
||
write(core_to_str,'(i0)') n | ||
|
||
end function core_to_str | ||
|
||
character(len=10) pure function core_int_date_to_yyyymmdd (date) | ||
! Undefined behavior if date <= 0 | ||
|
||
! Input arguments | ||
integer, intent(in) :: date | ||
|
||
! Local variables | ||
integer :: year ! year of yyyy-mm-dd | ||
integer :: month ! month of yyyy-mm-dd | ||
integer :: day ! day of yyyy-mm-dd | ||
|
||
year = date / 10000 | ||
month = (date - year*10000) / 100 | ||
day = date - year*10000 - month*100 | ||
|
||
write(core_int_date_to_yyyymmdd, '(i4.4,A,i2.2,A,i2.2)') & | ||
year,'-',month,'-',day | ||
|
||
end function core_int_date_to_yyyymmdd | ||
|
||
character(len=8) pure function core_int_seconds_to_hhmmss (seconds) | ||
! Undefined behavior if seconds outside [0, 86400] | ||
|
||
! Input arguments | ||
integer, intent(in) :: seconds | ||
|
||
! Local variables | ||
integer :: hours ! hours of hh:mm:ss | ||
integer :: minutes ! minutes of hh:mm:ss | ||
integer :: secs ! seconds of hh:mm:ss | ||
|
||
hours = seconds / 3600 | ||
minutes = (seconds - hours*3600) / 60 | ||
secs = (seconds - hours*3600 - minutes*60) | ||
|
||
write(core_int_seconds_to_hhmmss,'(i2.2,A,i2.2,A,i2.2)') & | ||
hours,':',minutes,':',secs | ||
|
||
end function core_int_seconds_to_hhmmss | ||
|
||
!> Convert one or more values of any intrinsic data types to a character string for pretty printing. | ||
!> If `value` contains more than one element, the elements will be stringified, delimited by `separator`, then concatenated. | ||
!> If `value` contains exactly one element, the element will be stringified without using `separator`. | ||
!> If `value` contains zero element or is of unsupported data types, an empty character string is produced. | ||
!> If `separator` is not supplied, it defaults to `, ` (i.e., a comma and a space). | ||
!> (KCW, 2024-02-04) | ||
pure function core_stringify(value, separator) | ||
use, intrinsic :: iso_fortran_env, only: int32, int64, real32, real64 | ||
|
||
class(*), intent(in) :: value(:) | ||
character(*), optional, intent(in) :: separator | ||
character(:), allocatable :: core_stringify | ||
|
||
integer, parameter :: sizelimit = 1024 | ||
|
||
character(:), allocatable :: buffer, delimiter, format | ||
integer :: i, n, offset | ||
|
||
if (present(separator)) then | ||
delimiter = separator | ||
else | ||
delimiter = ', ' | ||
end if | ||
|
||
n = min(size(value), sizelimit) | ||
|
||
if (n == 0) then | ||
core_stringify = '' | ||
return | ||
end if | ||
|
||
select type (value) | ||
type is (character(*)) | ||
allocate(character(len(value) * n + len(delimiter) * (n - 1)) :: buffer) | ||
|
||
buffer(:) = '' | ||
offset = 0 | ||
|
||
do i = 1, n | ||
if (len(delimiter) > 0 .and. i > 1) then | ||
buffer(offset + 1:offset + len(delimiter)) = delimiter | ||
offset = offset + len(delimiter) | ||
end if | ||
|
||
if (len_trim(adjustl(value(i))) > 0) then | ||
buffer(offset + 1:offset + len_trim(adjustl(value(i)))) = trim(adjustl(value(i))) | ||
offset = offset + len_trim(adjustl(value(i))) | ||
end if | ||
end do | ||
type is (integer(int32)) | ||
allocate(character(11 * n + len(delimiter) * (n - 1)) :: buffer) | ||
allocate(character(17 + len(delimiter) + floor(log10(real(n))) + 1) :: format) | ||
|
||
write(format, '(a, i0, 3a)') '(ss, ', n, '(i0, :, "', delimiter, '"))' | ||
write(buffer, format) value | ||
type is (integer(int64)) | ||
allocate(character(20 * n + len(delimiter) * (n - 1)) :: buffer) | ||
allocate(character(17 + len(delimiter) + floor(log10(real(n))) + 1) :: format) | ||
|
||
write(format, '(a, i0, 3a)') '(ss, ', n, '(i0, :, "', delimiter, '"))' | ||
write(buffer, format) value | ||
type is (logical) | ||
allocate(character(1 * n + len(delimiter) * (n - 1)) :: buffer) | ||
allocate(character(13 + len(delimiter) + floor(log10(real(n))) + 1) :: format) | ||
|
||
write(format, '(a, i0, 3a)') '(', n, '(l1, :, "', delimiter, '"))' | ||
write(buffer, format) value | ||
type is (real(real32)) | ||
allocate(character(13 * n + len(delimiter) * (n - 1)) :: buffer) | ||
|
||
if (maxval(abs(value)) < 1.0e5_real32) then | ||
allocate(character(20 + len(delimiter) + floor(log10(real(n))) + 1) :: format) | ||
write(format, '(a, i0, 3a)') '(ss, ', n, '(f13.6, :, "', delimiter, '"))' | ||
else | ||
allocate(character(23 + len(delimiter) + floor(log10(real(n))) + 1) :: format) | ||
write(format, '(a, i0, 3a)') '(ss, ', n, '(es13.6e2, :, "', delimiter, '"))' | ||
end if | ||
|
||
write(buffer, format) value | ||
type is (real(real64)) | ||
allocate(character(13 * n + len(delimiter) * (n - 1)) :: buffer) | ||
|
||
if (maxval(abs(value)) < 1.0e5_real64) then | ||
allocate(character(20 + len(delimiter) + floor(log10(real(n))) + 1) :: format) | ||
write(format, '(a, i0, 3a)') '(ss, ', n, '(f13.6, :, "', delimiter, '"))' | ||
else | ||
allocate(character(23 + len(delimiter) + floor(log10(real(n))) + 1) :: format) | ||
write(format, '(a, i0, 3a)') '(ss, ', n, '(es13.6e2, :, "', delimiter, '"))' | ||
end if | ||
|
||
write(buffer, format) value | ||
class default | ||
core_stringify = '' | ||
return | ||
end select | ||
|
||
core_stringify = trim(buffer) | ||
|
||
end function core_stringify | ||
|
||
end module string_core_utils |
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
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
Oops, something went wrong.