Skip to content
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
17 changes: 9 additions & 8 deletions .github/workflows/prebuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ jobs:
export PYTHONPATH=$(pwd)/scripts:$(pwd)/scripts/parse_tools
cd test_prebuild
pytest
- 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
# No longer possible because of https://github.com/NCAR/ccpp-framework/pull/659
#- 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
- name: ccpp-prebuild chunked data tests
run: |
cd test_prebuild/test_chunked_data
Expand Down
18 changes: 18 additions & 0 deletions scripts/metadata_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,26 @@ def parse_variable(self, curr_line, known_ddts, skip_ddt_check=False):
pval = []
for dim in porig:
if ':' in dim:
for dim2 in dim.split(':'):
dim_ok = VarDictionary.loop_var_okay(standard_name=dim2,
is_run_phase=self.__section_title.endswith("_run"))
if not dim_ok:
emsg = "horizontal dimension"
self.__pobj.add_syntax_err(emsg, token=dim2)
self.__section_valid = False
var_ok = False
# end if
# end for
pval.append(dim)
else:
dim_ok = VarDictionary.loop_var_okay(standard_name=dim,
is_run_phase=self.__section_title.endswith("_run"))
if not dim_ok:
emsg = "horizontal dimension"
self.__pobj.add_syntax_err(emsg, token=dim)
self.__section_valid = False
var_ok = False
# end if
cone_str = 'ccpp_constant_one:{}'
pval.append(cone_str.format(dim))
# end if
Expand Down
2 changes: 1 addition & 1 deletion test/capgen_test/make_ddt.meta
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[ vmr_array ]
standard_name = array_of_volume_mixing_ratios
units = ppmv
dimensions = (horizontal_loop_extent, number_of_chemical_species)
dimensions = (horizontal_dimension, number_of_chemical_species)
type = real
kind = kind_phys
[ccpp-table-properties]
Expand Down
2 changes: 1 addition & 1 deletion test/capgen_test/temp_set.meta
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
standard_name = array_variable_for_testing
long_name = array variable for testing
units = none
dimensions = (horizontal_dimension,2,4,6)
dimensions = (horizontal_loop_extent,2,4,6)
type = real
kind = kind_phys
intent = inout
Expand Down
2 changes: 1 addition & 1 deletion test/ddthost_test/make_ddt.meta
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[ vmr_array ]
standard_name = array_of_volume_mixing_ratios
units = ppmv
dimensions = (horizontal_loop_extent, number_of_chemical_species)
dimensions = (horizontal_dimension, number_of_chemical_species)
type = real
kind = kind_phys
[ccpp-table-properties]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[ vmr_array ]
standard_name = array_of_volume_mixing_ratios
units = ppmv
dimensions = (horizontal_loop_extent, number_of_chemical_species)
dimensions = (horizontal_dimension, number_of_chemical_species)
type = real
kind = kind_phys

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[ vmr_array ]
standard_name = array_of_volume_mixing_ratios
units = ppmv
dimensions = (horizontal_loop_extent, number_of_chemical_species)
dimensions = (horizontal_dimension, number_of_chemical_species)
type = real
kind = kind_phys

Expand Down
11 changes: 11 additions & 0 deletions test/unit_tests/sample_host_files/mismatch_hdim_mod.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module mismatch_hdim_mod

use ccpp_kinds, only: kind_phys

!> \section arg_table_mismatch_hdim_mod Argument Table
!! \htmlinclude arg_table_mismatch_hdim_mod.html
real(kind_phys) :: ps1
real(kind_phys), allocatable :: xbox(:,:)
real(kind_phys), allocatable :: switch(:,:)

end module mismatch_hdim_mod
25 changes: 25 additions & 0 deletions test/unit_tests/sample_host_files/mismatch_hdim_mod.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[ccpp-table-properties]
name = mismatch_hdim_mod
type = module
[ccpp-arg-table]
name = mismatch_hdim_mod
type = module
[ ps1 ]
standard_name = play_station
state_variable = true
type = real | kind = kind_phys
units = Pa
dimensions = ()
[ xbox ]
standard_name = xbox
state_variable = true
type = real | kind = kind_phys
units = m s-1
dimensions = (horizontal_loop_extent, vertical_layer_dimension)
[ switch ]
standard_name = nintendo_switch
long_name = Incompatible junk
state_variable = true
type = real | kind = kind_phys
units = m s-1
dimensions = (horizontal_loop_being:horizontal_loop_end, vertical_layer_dimension)
48 changes: 48 additions & 0 deletions test/unit_tests/sample_scheme_files/mismatch_hdim.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
! Test parameterization with no vertical level
!

MODULE mismatch_hdim

USE ccpp_kinds, ONLY: kind_phys

IMPLICIT NONE
PRIVATE

PUBLIC :: mismatch_hdim_init
PUBLIC :: mismatch_hdim_run

CONTAINS

!> \section arg_table_mismatch_hdim_run Argument Table
!! \htmlinclude arg_table_mismatch_hdim_run.html
!!
subroutine mismatch_hdim_run(tsfc, errmsg, errflg)

real(kind_phys), intent(inout) :: tsfc(:)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg

errmsg = ''
errflg = 0

tsfc = tsfc-1.0_kind_phys

END SUBROUTINE mismatch_hdim_run

!> \section arg_table_mismatch_hdim_init Argument Table
!! \htmlinclude arg_table_mismatch_hdim_init.html
!!
subroutine mismatch_hdim_init (tsfc, errmsg, errflg)

real(kind_phys), intent(inout) :: tsfc(:)
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg

tsfc = tsfc+1.0_kind_phys

errmsg = ''
errflg = 0

end subroutine mismatch_hdim_init

END MODULE mismatch_hdim
55 changes: 55 additions & 0 deletions test/unit_tests/sample_scheme_files/mismatch_hdim.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[ccpp-table-properties]
name = mismatch_hdim
type = scheme

########################################################################
[ccpp-arg-table]
name = mismatch_hdim_run
type = scheme
[ tsfc ]
standard_name = temperature_at_surface
units = K
dimensions = (horizontal_dimension)
type = real
kind = kind_phys
intent = inout
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = none
dimensions = ()
type = character
kind = len=512
intent = out
[ errflg ]
standard_name = ccpp_error_code
long_name = Error flag for error handling in CCPP
units = 1
dimensions = ()
type = integer
intent = out
[ccpp-arg-table]
name = mismatch_hdim_init
type = scheme
[ tsfc ]
standard_name = temperature_at_surface
units = K
dimensions = (horizontal_loop_extent)
type = real
kind = kind_phys
intent = inout
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = none
dimensions = ()
type = character
kind = len=512
intent = out
[ errflg ]
standard_name = ccpp_error_code
long_name = Error flag for error handling in CCPP
units = 1
dimensions = ()
type = integer
intent = out
21 changes: 20 additions & 1 deletion test/unit_tests/test_metadata_host_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
two DDT definitions
- Correctly parse and match a simple module file with
two DDT definitions and a data block
- "Test correct use of loop variables (horizontal
dimensions) in host metadata

Assumptions:

Expand Down Expand Up @@ -249,13 +251,30 @@ def test_module_with_two_ddts_and_extra_var(self):
# Check error messages
except_str = str(context.exception)
emsgs = ["Variable mismatch in ddt2_t, variables missing from Fortran ddt.",

"No Fortran variable for bogus in ddt2_t",
"2 errors found comparing"]
for emsg in emsgs:
self.assertTrue(emsg in except_str)
# end for

def test_mismatch_hdim(self):
"""Test correct use of loop variables (horizontal dimensions)
in host metadata."""
# Setup
module_files = [os.path.join(self._sample_files_dir, "mismatch_hdim_mod.meta")]
# Exercise
hname = 'host_name_mismatch_hdim'
with self.assertRaises(CCPPError) as context:
_ = parse_host_model_files(module_files, hname, self._run_env)
# end with
# Check error messages
except_str = str(context.exception)
emsgs = ["Invalid horizontal dimension, 'horizontal_loop_extent'",
"Invalid horizontal dimension, 'horizontal_loop_end'"]
for emsg in emsgs:
self.assertTrue(emsg in except_str)
# end for

if __name__ == "__main__":
unittest.main()

18 changes: 18 additions & 0 deletions test/unit_tests/test_metadata_scheme_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
- Correctly interpret Fortran with preprocessor logic
which affects the subroutine statement and/or the dummy
argument statements resulting in incorrect Fortran
- Test correct use of loop variables (horizontal dimensions)
in scheme metadata. The allowed values depend on the phase
(run phase or not)

Assumptions:

Expand Down Expand Up @@ -343,6 +346,21 @@ def test_scheme_ddt_only(self):
scheme_headers, table_dict = parse_scheme_files(scheme_files,
self._run_env_ccpp)

def test_mismatch_hdim(self):
"""Test correct use of loop variables (horizontal dimensions)
in scheme metadata. The allowed values depend on the phase
(run phase or not)"""
# Setup
scheme_files = [os.path.join(self._sample_files_dir, "mismatch_hdim.meta")]
# Exercise
with self.assertRaises(CCPPError) as context:
_, _ = parse_scheme_files(scheme_files, self._run_env_ccpp)
# Verify 2 correct error messages returned
emsg = "Invalid horizontal dimension, 'horizontal_dimension'"
self.assertTrue(emsg in str(context.exception))
emsg = "Invalid horizontal dimension, 'horizontal_loop_extent'"
self.assertTrue(emsg in str(context.exception))

if __name__ == "__main__":
unittest.main()

3 changes: 2 additions & 1 deletion test_prebuild/run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ set -e

echo "" && echo "Running unit_tests " && cd unit_tests && ./run_tests.sh && cd ..
echo "" && echo "Running test_opt_arg " && cd test_opt_arg && ./run_test.sh && cd ..
echo "" && echo "Running test_blocked_data" && cd test_blocked_data && ./run_test.sh && cd ..
# No longer possible because of https://github.com/NCAR/ccpp-framework/pull/659
#echo "" && echo "Running test_blocked_data" && cd test_blocked_data && ./run_test.sh && cd ..
echo "" && echo "Running test_chunked_data" && cd test_chunked_data && ./run_test.sh && cd ..
echo "" && echo "Running test_unit_conv" && cd test_unit_conv && ./run_test.sh && cd ..

Expand Down
8 changes: 4 additions & 4 deletions test_prebuild/test_track_variables/scheme_3.meta
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@
standard_name = air_pressure
long_name = mean layer pressure
units = Pa
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = out
[ps]
standard_name = surface_air_pressure
long_name = surface pressure
units = Pa
dimensions = (horizontal_loop_extent)
dimensions = (horizontal_dimension)
type = real
kind = kind_phys
intent = inout
Expand All @@ -128,15 +128,15 @@
standard_name = air_pressure
long_name = mean layer pressure
units = Pa
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
dimensions = (horizontal_dimension,vertical_layer_dimension)
type = real
kind = kind_phys
intent = out
[ps]
standard_name = surface_air_pressure
long_name = surface pressure
units = Pa
dimensions = (horizontal_loop_extent)
dimensions = (horizontal_dimension)
type = real
kind = kind_phys
intent = out
Expand Down
3 changes: 2 additions & 1 deletion test_prebuild/test_unit_conv/data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ module data

private

public ncols, nspecies
public ncols, ncolsrun, nspecies
public cdata, data_array, data_array2, opt_array_flag

integer, parameter :: ncols = 4
integer, parameter :: ncolsrun = ncols
integer, parameter :: nspecies = 2
type(ccpp_t), target :: cdata
real(kind_phys), dimension(1:ncols,1:nspecies) :: data_array
Expand Down
Loading