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

ccpp_prebuild: Update CCPP metadata for error flag variable and constant one #428

Merged
merged 18 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ad510d3
Merge pull request #414 from climbfuji/merge_main_into_feature_capgen…
climbfuji Nov 7, 2021
48bcb75
Add nested subroutine using 'contains' to temp_calc_adjust_run
climbfuji Jan 4, 2022
ef7a984
Fix parsing of CCPP schemes that contain nested subroutines in 'conta…
climbfuji Jan 4, 2022
5c4d312
Do not require label on end subroutine statement
Jan 4, 2022
aacab9d
Merge pull request #1 from gold2718/fix_parsing_nested_subroutines_co…
climbfuji Jan 4, 2022
e88f77a
Merge pull request #424 from climbfuji/fix_parsing_nested_subroutines…
climbfuji Jan 4, 2022
18d0072
Merge branch 'main' of https://github.com/NCAR/ccpp-framework into HEAD
climbfuji Jan 10, 2022
47f0b72
Revert changes that should be in main only
climbfuji Jan 10, 2022
4694d8d
Merge pull request #426 from climbfuji/update_feature_capgen_from_mai…
climbfuji Jan 10, 2022
aa5dec4
Change unit of errmsg from '1' to 'none'
climbfuji Jan 13, 2022
40e0d2f
Remove executable permissions from scripts/metadata_table.py and scri…
climbfuji Jan 13, 2022
565ede6
Merge pull request #427 from climbfuji/feature_capgen_errmsg_unit_update
climbfuji Jan 13, 2022
3d2f7cd
Restore CODEOWNERS file
climbfuji Jan 14, 2022
db3b9c1
Change standard_name and unit of CCPP error flag variable in ccpp_pre…
climbfuji Jan 16, 2022
f228064
Add system test for doxygen comments and blank lines between metadata…
climbfuji Jan 17, 2022
0c69a9c
Merge pull request #429 from climbfuji/test_doxygen_between_metadata_…
climbfuji Jan 17, 2022
96bebbf
Merge branch 'feature/capgen' of https://github.com/NCAR/ccpp-framewo…
climbfuji Jan 17, 2022
fee2198
Remove executable flags from scripts/fortran_tools/parse_fortran_file.py
climbfuji Jan 26, 2022
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
6 changes: 3 additions & 3 deletions doc/HelloWorld/hello_scheme.meta
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand All @@ -65,7 +65,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand All @@ -83,7 +83,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand Down
2 changes: 1 addition & 1 deletion doc/HelloWorld/hello_world_host.meta
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand Down
6 changes: 3 additions & 3 deletions doc/HelloWorld/temp_adjust.meta
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand All @@ -52,7 +52,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand All @@ -70,7 +70,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand Down
4 changes: 2 additions & 2 deletions scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
CCPP_STAGES['finalize'] = 'final'

CCPP_CONSTANT_ONE = 'ccpp_constant_one'
CCPP_ERROR_FLAG_VARIABLE = 'ccpp_error_flag'
CCPP_ERROR_CODE_VARIABLE = 'ccpp_error_code'
CCPP_ERROR_MSG_VARIABLE = 'ccpp_error_message'
CCPP_LOOP_COUNTER = 'ccpp_loop_counter'
CCPP_LOOP_EXTENT = 'ccpp_loop_extent'
Expand Down Expand Up @@ -50,7 +50,7 @@

# List of internal variables provided by the CCPP
CCPP_INTERNAL_VARIABLES = {
CCPP_ERROR_FLAG_VARIABLE : 'cdata%errflg',
CCPP_ERROR_CODE_VARIABLE : 'cdata%errflg',
CCPP_ERROR_MSG_VARIABLE : 'cdata%errmsg',
CCPP_LOOP_COUNTER : 'cdata%loop_cnt',
CCPP_BLOCK_NUMBER : 'cdata%blk_no',
Expand Down
17 changes: 12 additions & 5 deletions scripts/fortran_tools/parse_fortran_file.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ def parse_scheme_metadata(statements, pobj, spec_name, table_name, run_env):
# Find the subroutine line, should be first executable statement
inpreamble = False
insub = True
seen_contains = False
if run_env.logger and run_env.logger.isEnabledFor(logging.DEBUG):
ctx = context_string(pobj, nodir=True)
msg = "Parsing specification of {}{}"
Expand All @@ -629,6 +630,10 @@ def parse_scheme_metadata(statements, pobj, spec_name, table_name, run_env):
esmatch = _END_SUBROUTINE_RE.match(statement)
pmatch = _ENDMODULE_RE.match(statement)
asmatch = _ARG_TABLE_START_RE.match(statement)
seen_contains = seen_contains or is_contains_statement(statement, insub)
if seen_contains:
inpreamble = False
# End if
if asmatch is not None:
# We have run off the end of something, hope that is okay
# Put this statement back for the caller to deal with
Expand All @@ -642,7 +647,7 @@ def parse_scheme_metadata(statements, pobj, spec_name, table_name, run_env):
insub = False
break
# End if
if smatch is not None:
if smatch is not None and not seen_contains:
scheme_name = smatch.group(1)
inpreamble = scheme_name.lower() == table_name.lower()
if inpreamble:
Expand Down Expand Up @@ -674,14 +679,16 @@ def parse_scheme_metadata(statements, pobj, spec_name, table_name, run_env):
# End for
psrc = ParseSource(scheme_name, 'scheme', pobj)
# End if
elif inpreamble:
elif inpreamble or seen_contains:
# Process a preamble statement (use or argument declaration)
if esmatch is not None:
inpreamble = False
seen_contains = False
insub = False
elif ((not is_comment_statement(statement)) and
(not parse_use_statement(statement, run_env)) and
is_dummy_argument_statement(statement)):
elif (inpreamble and
((not is_comment_statement(statement)) and
(not parse_use_statement(statement, run_env)) and
is_dummy_argument_statement(statement))):
dvars = parse_fortran_var_decl(statement, psrc, run_env)
for var in dvars:
lname = var.get_prop_value('local_name').lower()
Expand Down
17 changes: 9 additions & 8 deletions scripts/metadata_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
sys.path.append(os.path.join(os.path.split(__file__)[0], 'fortran_tools'))
from parse_fortran import FtypeTypeDecl
from parse_checkers import registered_fortran_ddt_names
from parse_tools import init_log
from metadata_table import MetadataTable, parse_metadata_file
from framework_env import CCPPFrameworkEnv

_DUMMY_RUN_ENV = CCPPFrameworkEnv(None, ndict={'host_files':'',
'scheme_files':'',
'suites':''})

_API_LOGGING = init_log('metadata_parser')
_DUMMY_RUN_ENV = CCPPFrameworkEnv(_API_LOGGING, ndict={'host_files':'',
'scheme_files':'',
'suites':''})
Comment on lines +21 to +24
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can come back to feature/capgen

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, prebuild script. Will come back with the next update of feature/capgen from main.


# Output: This routine converts the argument tables for all subroutines / typedefs / kind / module variables
# into dictionaries suitable to be used with ccpp_prebuild.py (which generates the fortran code for the caps)
Expand Down Expand Up @@ -48,10 +49,10 @@
intent = 'out',
active = 'T',
),
'ccpp_error_flag' : Var(local_name = 'ierr',
standard_name = 'ccpp_error_flag',
long_name = 'error flag for error handling in CCPP',
units = 'flag',
'ccpp_error_code' : Var(local_name = 'ierr',
standard_name = 'ccpp_error_code',
long_name = 'error code for error handling in CCPP',
units = '1',
Comment on lines +52 to +55
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to get back to feature/capgen, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right. Next formal update of feature/capgen from main. This is the prebuild side of things, not used by capgen.

type = 'integer',
dimensions = [],
rank = '',
Expand Down
2 changes: 1 addition & 1 deletion scripts/metadata_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand Down
2 changes: 1 addition & 1 deletion scripts/metavar.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'ccpp_error_message' :
{'local_name' : 'errmsg', 'standard_name' : 'ccpp_error_message',
'long_name' : "CCPP error message",
'units' : '1', 'dimensions' : '()', 'type' : 'character',
'units' : 'none', 'dimensions' : '()', 'type' : 'character',
'kind' : 'len=512'},
'horizontal_dimension' :
{'local_name' : 'total_columns',
Expand Down
1 change: 0 additions & 1 deletion scripts/mkcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import getopt
import xml.etree.ElementTree as ET

from common import CCPP_ERROR_FLAG_VARIABLE
from common import CCPP_INTERNAL_VARIABLES
from common import STANDARD_VARIABLE_TYPES, STANDARD_CHARACTER_TYPE
from common import isstring, string_to_python_identifier
Expand Down
4 changes: 2 additions & 2 deletions scripts/mkstatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from common import encode_container
from common import CCPP_STAGES
from common import CCPP_ERROR_FLAG_VARIABLE, CCPP_ERROR_MSG_VARIABLE, CCPP_LOOP_COUNTER, CCPP_LOOP_EXTENT
from common import CCPP_ERROR_CODE_VARIABLE, CCPP_ERROR_MSG_VARIABLE, CCPP_LOOP_COUNTER, CCPP_LOOP_EXTENT
from common import CCPP_BLOCK_NUMBER, CCPP_BLOCK_COUNT, CCPP_BLOCK_SIZES, CCPP_THREAD_NUMBER, CCPP_INTERNAL_VARIABLES
from common import CCPP_CONSTANT_ONE, CCPP_HORIZONTAL_DIMENSION, CCPP_HORIZONTAL_LOOP_EXTENT
from common import FORTRAN_CONDITIONAL_REGEX_WORDS, FORTRAN_CONDITIONAL_REGEX
Expand Down Expand Up @@ -908,7 +908,7 @@ def write(self, metadata_request, metadata_define, arguments, debug):
ccpp_loop_extent_target_name = metadata_request[CCPP_LOOP_EXTENT][0].target
else:
ccpp_loop_extent_target_name = None
ccpp_error_flag_target_name = metadata_request[CCPP_ERROR_FLAG_VARIABLE][0].target
ccpp_error_flag_target_name = metadata_request[CCPP_ERROR_CODE_VARIABLE][0].target
ccpp_error_msg_target_name = metadata_request[CCPP_ERROR_MSG_VARIABLE][0].target
#
module_use = ''
Expand Down
8 changes: 0 additions & 8 deletions scripts/parse_tools/parse_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ def check_units(test_val, prop_dict, error):
test_val = None
# end if
# end if

# DH* 20210812
# Temporary workaround to convert unit 'none' (used for
# dimensionless quantities in ccpp-physics/UFS/SCM) to '1'
if test_val and test_val.lower() == 'none':
test_val = '1'
# *DH 20210812

return test_val

def check_dimensions(test_val, prop_dict, error, max_len=0):
Expand Down
8 changes: 4 additions & 4 deletions src/ccpp_types.meta
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
name = ccpp_t
type = ddt
[errflg]
standard_name = ccpp_error_flag
long_name = error flag for error handling in CCPP
units = flag
standard_name = ccpp_error_code
long_name = error code for error handling in CCPP
units = 1
dimensions = ()
type = integer
[errmsg]
Expand Down Expand Up @@ -64,6 +64,6 @@
[one]
standard_name = ccpp_constant_one
long_name = definition of constant one
units = none
units = 1
dimensions = ()
type = integer
23 changes: 23 additions & 0 deletions test/advection_test/cld_ice.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ MODULE cld_ice

PUBLIC :: cld_ice_init
PUBLIC :: cld_ice_run
PUBLIC :: cld_ice_final

real(kind_phys), private :: tcld = HUGE(1.0_kind_phys)

Expand Down Expand Up @@ -71,4 +72,26 @@ subroutine cld_ice_init(tfreeze, cld_ice, errmsg, errflg)

end subroutine cld_ice_init

!> \section arg_table_cld_ice_final Argument Table
!! \htmlinclude arg_table_cld_ice_final.html
!!

!> @{
!! This routine does nothing, but it tests if blank
!! lines and doxygen comments between metadata hooks
!! and the subroutine are parsed correctly.
!! @{

subroutine cld_ice_final(errmsg, errflg)

character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg

errmsg = ''
errflg = 0

end subroutine cld_ice_final
!! @}
!! @}

END MODULE cld_ice
22 changes: 20 additions & 2 deletions test/advection_test/cld_ice.meta
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand All @@ -66,7 +66,7 @@
[ccpp-arg-table]
name = cld_ice_init
type = scheme
[ tfreeze]
[ tfreeze ]
standard_name = water_temperature_at_freezing
long_name = Freezing temperature of water at sea level
units = K
Expand All @@ -84,8 +84,26 @@
[ 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 = cld_ice_final
type = scheme
[ 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
Expand Down
4 changes: 2 additions & 2 deletions test/advection_test/cld_liq.meta
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand Down Expand Up @@ -96,7 +96,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand Down
2 changes: 1 addition & 1 deletion test/advection_test/test_host.meta
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand Down
6 changes: 3 additions & 3 deletions test/capgen_test/environ_conditions.meta
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand Down Expand Up @@ -66,7 +66,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand Down Expand Up @@ -96,7 +96,7 @@
[ errmsg ]
standard_name = ccpp_error_message
long_name = Error message for error handling in CCPP
units = 1
units = none
dimensions = ()
type = character
kind = len=512
Expand Down
Loading