Skip to content
Draft
Show file tree
Hide file tree
Changes from 122 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
c2b1f9b
Initial commit. Work in progress
Sep 22, 2023
a3353c7
Working.
Oct 11, 2023
bb86f8b
Housekeeping
Oct 11, 2023
92d00d8
Working with compatability object
Oct 20, 2023
adb0c38
Merge branch 'feature_capgen_unit_conversions_temp' into feature_capg…
Oct 20, 2023
eecc620
Revert change
Oct 20, 2023
592e15f
Omission from previous commit
Oct 20, 2023
a4b1c99
Omission from previous commit. again...
Oct 20, 2023
62a9d12
Omission from previous commit. again...
Oct 20, 2023
b603972
Merge branch 'feature/capgen' of https://github.com/NCAR/ccpp-framewo…
Oct 20, 2023
8d8589e
Cleanup VarCompatObj creation
dustinswales Oct 23, 2023
3e14fa8
Vertical flipping working w/ new metadata attribute. Work in progress
dustinswales Oct 24, 2023
c29b0c0
Some more changes. Vertical flipping working
dustinswales Oct 25, 2023
19f6a30
Housekeeping
dustinswales Oct 25, 2023
aae4b43
Add kind transform to transform test
dustinswales Oct 25, 2023
c3d2b3a
Add local declaration of vertical extent, needed for vertical flipping
dustinswales Oct 26, 2023
ea01a47
Everything but getting the correct local variable name for the vertic…
dustinswales Oct 30, 2023
e47bf8f
Add snippet from Steve G. to get correct local_name for vertical_laye…
dustinswales Oct 31, 2023
253ad3a
Address reviewers comments
Nov 13, 2023
fe5f213
Address reviewers comments again
Nov 13, 2023
fc337a9
Address reviewers comments again again
Nov 13, 2023
3b04594
Merge branch 'feature/capgen' of https://github.com/NCAR/ccpp-framewo…
Nov 13, 2023
998cc7b
Merge branch 'main' of https://github.com/NCAR/ccpp-framework into fe…
Dec 4, 2023
8d3af68
Merge branch 'feature/capgen' of https://github.com/NCAR/ccpp-framewo…
Dec 4, 2023
9b206f1
Revert "Merge branch 'main' of https://github.com/NCAR/ccpp-framework…
Dec 4, 2023
b5cc909
Activate var_action_test
Dec 4, 2023
e6ffbd5
Fix unit tests for variable transformations. Reorganization a bit to …
Dec 4, 2023
e9c79eb
Cleanup forward/reverse transform terminology
Dec 4, 2023
bb4975a
Doc tests for transformations
Dec 4, 2023
265a05b
Add more inline documentation. Address reviewers comments.
Dec 5, 2023
0d0cfcd
Address reviewer comment
Dec 5, 2023
f280ef5
Update authors in CMakeList.
Dec 5, 2023
54e5462
Update authors in CMakeList.
Dec 5, 2023
1cc6da4
Address reviewer comment
Dec 5, 2023
44f005f
Address comments
Dec 12, 2023
4aae9ad
Rename var_action test var_compatability
Dec 12, 2023
44d834b
Merge branch 'main' of https://github.com/NCAR/ccpp-framework into fe…
Dec 12, 2023
186e1c6
Commit before updating
Dec 18, 2023
7e15f6f
Merge branch 'main' of https://github.com/NCAR/ccpp-framework into HEAD
Dec 18, 2023
9d29b3d
Merge branch 'feature_capgen_unit_conversions' of https://github.com/…
Dec 18, 2023
d097911
Revert "Merge branch 'main' of https://github.com/NCAR/ccpp-framework…
Dec 18, 2023
c98e5d0
Omissions from previous merge
Dec 18, 2023
1a2e173
Commit before sync
Jan 2, 2024
57e0781
Remove declaration of ccpp_constant_one from ccpp_types. In Capgen pa…
dustinswales Jan 30, 2024
ec5d4e3
Add makefile generation and kinds file
dustinswales Jan 30, 2024
7c69e52
Merge branch 'feature/capgen' of https://github.com/NCAR/ccpp-framewo…
dustinswales Jan 30, 2024
74473ec
Bug in module use statements
dustinswales Jan 31, 2024
c1e2981
Merge branch 'main' of https://github.com/dustinswales/ccpp-framework…
dustinswales Apr 9, 2024
8fee333
Remove ccpp standard variable one from ccpp_type
dustinswales Apr 9, 2024
afc998a
Some changes
dustinswales Aug 7, 2024
cdbbead
Merge branch 'main' of https://github.com/NCAR/ccpp-framework into ca…
dustinswales Aug 7, 2024
9cf1c6c
More changes for the SCM. Work in progress.
dustinswales Aug 13, 2024
ace5f1a
Caps building!
dustinswales Sep 13, 2024
40deb94
Fixed the piece to add host model DDT entries recursivelygit add ddt_…
dustinswales Sep 26, 2024
114dc9d
Merge branch 'develop' of https://github.com/NCAR/ccpp-framework into…
dustinswales Sep 30, 2024
08cf508
Some more cleanup. Isolation of SCM/UFS scpecific code and Capgen.
dustinswales Sep 30, 2024
6a5e38f
Housekeeping. Remove old unnecessary changes.
dustinswales Sep 30, 2024
6786590
More housekeeping
dustinswales Sep 30, 2024
1643c76
More housekeeping
dustinswales Sep 30, 2024
ac9cb78
Housekeeping.
dustinswales Sep 30, 2024
3f2dbd7
Remove alphabetic sorting when writting suite_part_list
Oct 1, 2024
bbc505c
Remove active requirement on optional scheme arguments. Allow for num…
dustinswales Dec 5, 2024
ebe51b5
Merge branch 'main' of https://github.com/NCAR/ccpp-framework into ca…
dustinswales Dec 5, 2024
7ab1e27
Merge branch 'develop' of https://github.com/NCAR/ccpp-framework into…
dustinswales Dec 5, 2024
e1c7ead
A few more changes
dustinswales Dec 5, 2024
1795a84
Bugfix for Groups with multiple references to local pointer. Modify h…
dustinswales Jan 7, 2025
26e7aba
Bugfix for scheme ordering in non run phases.
dustinswales Jan 8, 2025
28903cf
Merge branch 'develop' of https://github.com/NCAR/ccpp-framework into…
dustinswales Jan 8, 2025
50dd342
Housekeeping
dustinswales Jan 10, 2025
8c19646
Changes to handle threading with optional variables.
dustinswales Jan 13, 2025
3355004
Some fixes to get Capgen tests working. Not finished
Jan 14, 2025
e6769a8
Fix broken test. Bogus dependency files?
Jan 14, 2025
a8b8124
Bug to allow modules with different names than source file
Jan 15, 2025
5aeae32
some more changes to get capgen tests and SCM to both pass
Jan 16, 2025
0d4ec50
Increase depth of python interpreter
Jan 16, 2025
7f1ea00
Exend maximum line length
Jan 16, 2025
66f887e
Allow numerical dimensions in debug checks
Jan 17, 2025
5f4ec5a
revert some changes
Jan 17, 2025
7408bd8
A fewmore small changes
Jan 17, 2025
d03683c
Bug fix
Jan 17, 2025
9dcee4d
Move suite part use statements
dustinswales Jan 21, 2025
aab8038
Reduce debug checks on character arrays
dustinswales Jan 21, 2025
1b8c5f2
Merge branch 'develop' of https://github.com/NCAR/ccpp-framework into…
dustinswales Feb 4, 2025
4102bdb
Merge pull request #638 from dustinswales/swales_sync_main
mkavulich Feb 4, 2025
b71055d
New implementation of differing module name
Feb 28, 2025
7573d18
Fix doctests
Feb 28, 2025
1ababab
Fix unit test failure caused by previous error message cleanup
Feb 28, 2025
0895e8b
Add scheme file with different module name as test
Feb 28, 2025
8dccc9c
Merge branch 'develop' of https://github.com/NCAR/ccpp-framework into…
dustinswales Mar 3, 2025
393efb9
Revert changes in #637
dustinswales Mar 3, 2025
16ee97a
Merge branch 'source_module_ddt_fixes' of https://github.com/gold2718…
dustinswales Mar 3, 2025
a808f8d
Merge branch 'develop' of https://github.com/NCAR/ccpp-framework into…
Mar 4, 2025
3f7883f
Some small changes
Mar 5, 2025
07c2adf
Merge branch 'capgen_in_scm' of https://github.com/dustinswales/ccpp-…
dustinswales Mar 5, 2025
ce553c0
Some more changes. Working
dustinswales Mar 7, 2025
8be38db
DEBUG MODE WORKING!
dustinswales Mar 13, 2025
6b59f76
Added MPI_Comm to registered DDT types
dustinswales Mar 13, 2025
b140da3
Update src/CMakeLists.txt: use modern cmake features to install Fortr…
climbfuji Mar 12, 2025
463d5ad
Add missing 'include(GNUInstallDirs)' in src/CMakeLists.txt
climbfuji Mar 19, 2025
11359cb
Update src/CMakeLists.txt: use modern cmake features to install Fortr…
grantfirl Apr 16, 2025
c8fd894
Merge branch 'develop' of https://github.com/ncar/ccpp-framework into…
climbfuji Jul 24, 2025
57f08b8
Merge branch 'develop' of https://github.com/NCAR/ccpp-framework into…
dustinswales Aug 19, 2025
cd2c99b
Merge branch 'develop' of https://github.com/ncar/ccpp-framework into…
climbfuji Aug 21, 2025
3256121
Update main from develop 2025/07/24 --> 2025/08/21 (#668)
mkavulich Aug 28, 2025
55a7052
Framework working with older SCM
dustinswales Sep 16, 2025
9e0d036
Extend maximum line length for fortran writer
dustinswales Sep 17, 2025
f2d0cfb
Some mooore changes for optional arguments
dustinswales Sep 17, 2025
8d2e5d4
WOrking
dustinswales Sep 18, 2025
aab86a3
Bug fix for host DDT parsing.
dustinswales Sep 19, 2025
f12e654
Turn fortran-to-metadata comparison on
dustinswales Sep 22, 2025
98cea68
Only do metadata comparison in DEBUG mode
dustinswales Sep 22, 2025
6f03f54
Some cleanup
dustinswales Sep 23, 2025
7c345a6
Added timers to ccpp_capgen
dustinswales Sep 23, 2025
17e9d3d
Revert changes to ccpp_suite.py
dustinswales Sep 23, 2025
f3cefdb
Remove threading from optional arguments in Group caps.
dustinswales Sep 23, 2025
0db8d93
One more small change
dustinswales Nov 26, 2025
a6a5751
Merge branch 'main' of https://github.com/NCAR/ccpp-framework into HEAD
dustinswales Nov 26, 2025
ff944b6
Merge branch 'develop' of https://github.com/NCAR/ccpp-framework into…
Feb 2, 2026
bdafd92
Merge comflict resoled
Feb 2, 2026
bee099d
Cleanup CMakeLists.
Feb 3, 2026
474e5e9
Turn off DEPENDENCIES check?
Feb 3, 2026
682dcac
Change in fortran2metadat comparison test
Feb 3, 2026
14af9ed
Revert some changes
Feb 3, 2026
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
254 changes: 212 additions & 42 deletions scripts/ccpp_capgen.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/ccpp_fortran_to_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def parse_fortran_files(filenames, run_env, output_dir, sep, logger):
for filename in filenames:
logger.info('Looking for arg_tables from {}'.format(filename))
reset_standard_name_counter()
ftables, _ = parse_fortran_file(filename, run_env)
ftables, _, __ = parse_fortran_file(filename, run_env)
# Create metadata filename
filepath = '.'.join(os.path.basename(filename).split('.')[0:-1])
fname = filepath + '.meta'
Expand Down
5 changes: 3 additions & 2 deletions scripts/ddt_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,10 @@ def collect_ddt_fields(self, var_dict, var, run_env,
# end if
dvtype = dvar.get_prop_value('type')
if (dvar.is_ddt()) and (dvtype in self):
# If DDT in our library, we need to add sub-fields recursively.
# If DDT in our library, we need to add sub-fields recursively,
# unless sub-fields already added to library previously.
subddt = self[dvtype]
self.collect_ddt_fields(var_dict, dvar, run_env, parent=var, ddt=subddt)
self.collect_ddt_fields(var_dict, dvar, run_env, parent=var, ddt=subddt, skip_duplicates=skip_duplicates)
# end if
# add_variable only checks the current dictionary. By default,
# for a DDT, the variable also cannot be in our parent
Expand Down
4 changes: 3 additions & 1 deletion scripts/fortran_tools/fortran_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"""

import math
import sys
sys.setrecursionlimit(1500)

class FortranWriter:
"""Class to turn output into properly continued and indented Fortran code
Expand All @@ -25,7 +27,7 @@ class FortranWriter:

__LINE_FILL = 97 # Target line length

__LINE_MAX = 130 # Max line length
__LINE_MAX = 195 # Max line length

# CCPP copyright statement to be included in all generated Fortran files
__COPYRIGHT = '''!
Expand Down
6 changes: 3 additions & 3 deletions scripts/fortran_tools/parse_fortran_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ def parse_module(pobj, statements, run_env):
if errors:
raise CCPPError('\n'.join(errors))
# end if
return statements, mtables, additional_subroutines
return statements, mtables, mod_name,additional_subroutines

########################################################################

Expand All @@ -1060,14 +1060,14 @@ def parse_fortran_file(filename, run_env):
elif _MODULE_RE.match(statement) is not None:
# push statement back so parse_module can use it
statements.insert(0, statement)
statements, ptables, additional_routines = parse_module(pobj, statements, run_env)
statements, ptables, mod_name, additional_routines = parse_module(pobj, statements, run_env)
mtables.extend(ptables)
# end if
if (statements is not None) and (len(statements) == 0):
statements = read_statements(pobj)
# end if
# end while
return mtables, additional_routines
return mtables, mod_name, additional_routines

########################################################################

Expand Down
18 changes: 17 additions & 1 deletion scripts/framework_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, logger, ndict=None, verbose=0, clean=False,
preproc_directives=[], generate_docfiles=False, host_name='',
kind_types=[], use_error_obj=False, force_overwrite=False,
output_root=os.getcwd(), ccpp_datafile="datatable.xml",
debug=False):
debug=False, ccpp_cfgfile=None):
"""Initialize a new CCPPFrameworkEnv object from the input arguments.
<ndict> is a dict with the parsed command-line arguments (or a
dictionary created with the necessary arguments).
Expand Down Expand Up @@ -199,6 +199,13 @@ def __init__(self, logger, ndict=None, verbose=0, clean=False,
self.__datatable_file = os.path.join(self.output_dir,
self.datatable_file)
# end if
# Are we provided a CCPP configuration file?
if ndict and ('ccpp_cfgfile' in ndict):
self.__ccpp_cfgfile = ndict['ccpp_cfgfile']
del ndict['ccpp_cfgfile']
else:
self.__ccpp_cfgfile = ccpp_cfgfile
# endif
# Enable or disable variable allocation checks
if ndict and ('debug' in ndict):
self.__debug = ndict['debug']
Expand Down Expand Up @@ -319,6 +326,12 @@ def datatable_file(self):
CCPPFrameworkEnv object."""
return self.__datatable_file

@property
def ccpp_cfgfile(self):
"""Return the <ccpp_cfg_file> property for this
CCPPFrameworkEnv object."""
return self.__ccpp_cfgfile

@property
def debug(self):
"""Return the <debug> property for this
Expand Down Expand Up @@ -368,6 +381,9 @@ def parse_command_line(args, description, logger=None):
default="datatable.xml",
help="Filename for information on content generated by the CCPP Framework")

parser.add_argument('--ccpp-cfgfile', type=str, default=None,
help='path to CCPP prebuild configuration file')

parser.add_argument("--output-root", type=str,
metavar='<directory for generated files>',
default=os.getcwd(),
Expand Down
60 changes: 46 additions & 14 deletions scripts/host_cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,39 @@ def suite_part_call_list(host_model, const_dict, suite_part, subst_loop_vars,
# End if
if stdname not in CCPP_CONSTANT_VARS:
lname = var_dict.var_call_string(hvar, loop_vars=loop_vars)
# DJS2025: Check to see if call_string for variable <hvar> contains any
# array references with a standard_name, <sname_sub>. If so, replace
# <hvar_sub> with full reference, <var_call_string(<hvar_sub>)>.
str_start = 0
while True:
dimdA = lname.find('(',str_start)
dimdB = lname.find(')',str_start)
if (dimdA > 0 and dimdB > 0):
if (dimdB > dimdA):
sname_sub = lname[dimdA+1:dimdB]
hvar_sub = vdict.find_variable(standard_name=sname_sub, any_scope=True)
if (hvar_sub):
lnameA = lname[0:dimdA+1]
lnameB = lname[dimdB::]
lname = lnameA + var_dict.var_call_string(hvar_sub, loop_vars=loop_vars) + lnameB
# end if
# end if
else:
break
# end if
str_start += dimdB+1
# end while
# Also check if {sp_lname} has an array reference to a loop varaible, if so,
# remove array reference from LHS call_string.
if stdname in CCPP_LOOP_VAR_STDNAMES:
dimdA = sp_lname.find('(',0)
if (dimdA > 0):
sp_lname = sp_lname[0:dimdA]
# endif
# endif
hmvars.append(f"{sp_lname}={lname}")
# End if
# end if
# end if
# End for
return ', '.join(hmvars)

Expand Down Expand Up @@ -543,14 +574,23 @@ def write_host_cap(host_model, api, module_name, output_dir, run_env):
mspc = (maxmod - len(mod[0]))*' '
cap.write("use {}, {}only: {}".format(mod[0], mspc, mod[1]), 1)
# End for
# Write out any suite part use statements
max_suite_len = host_model.ddt_lib.max_mod_name_len
for suite in api.suites:
max_suite_len = max(max_suite_len, len(suite.module))
mspc = (max_suite_len - len(suite.module))*' '
for stage in CCPP_STATE_MACH.transitions():
spart_list = suite_part_list(suite, stage)
for _, spart in sorted(enumerate(spart_list)):
stmt = "use {}, {}only: {}"
cap.write(stmt.format(suite.module, mspc, spart.name), 1)
# end for
# end for
# end for
mspc = ' '*(maxmod - len(CONST_DDT_MOD))
cap.write(f"use {CONST_DDT_MOD}, {mspc}only: {CONST_DDT_NAME}", 1)
cap.write(f"use {CONST_DDT_MOD}, {mspc}only: {CONST_PROP_TYPE}", 1)
cap.write_preamble()
max_suite_len = host_model.ddt_lib.max_mod_name_len
for suite in api.suites:
max_suite_len = max(max_suite_len, len(suite.module))
# End for
cap.comment("Public Interfaces", 1)
# CCPP_STATE_MACH.transitions represents the host CCPP interface
for stage in CCPP_STATE_MACH.transitions():
Expand Down Expand Up @@ -667,15 +707,7 @@ def write_host_cap(host_model, api, module_name, output_dir, run_env):
cap.write(_SUBHEAD.format(api_vars=api_vlist,
host_model=host_model.name,
stage=stage), 1)
# Write out any suite part use statements
for suite in api.suites:
mspc = (max_suite_len - len(suite.module))*' '
spart_list = suite_part_list(suite, stage)
for _, spart in sorted(enumerate(spart_list)):
stmt = "use {}, {}only: {}"
cap.write(stmt.format(suite.module, mspc, spart.name), 2)
# End for
# End for

# Write out any host model DDT input var use statements
host_model.ddt_lib.write_ddt_use_statements(hdvars, cap, 2,
pad=max_suite_len)
Expand Down
12 changes: 10 additions & 2 deletions scripts/host_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ def __init__(self, meta_tables, name_in, run_env):
lname = var.get_prop_value('local_name')
self.__var_locations[lname] = modname
self.ddt_lib.check_ddt_type(var, header, lname=lname)
# DDTs may be used more than once by the host, so
# skip duplicate sub-field entries. These fields were
# encountered earlier and already added to library.
if var.is_ddt():
self.ddt_lib.collect_ddt_fields(self.__ddt_dict, var,
run_env)
run_env,
skip_duplicates=True)
# End if
# End for
elif header.header_type == 'host':
Expand All @@ -73,8 +77,12 @@ def __init__(self, meta_tables, name_in, run_env):
self.add_variable(var, run_env)
self.ddt_lib.check_ddt_type(var, header)
if var.is_ddt():
# DDTs may be used more than once by the host, so
# skip duplicate sub-field entries. These fields were
# encountered earlier and already added to library.
self.ddt_lib.collect_ddt_fields(self.__ddt_dict, var,
run_env)
run_env,
skip_duplicates=True)
# End if
# End for
loop_vars = header.variable_list(std_vars=False,
Expand Down
2 changes: 1 addition & 1 deletion scripts/metadata2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def convert_to_html(filename_in, outdir, logger, run_env):
if not os.path.isfile(filename_in):
raise Exception("Metadata file {} not found".format(filename_in))
logger.info("Converting file {} to HTML".format(filename_in))
metadata_headers = parse_metadata_file(filename_in,
metadata_headers, metadata_titles = parse_metadata_file(filename_in,
known_ddts=registered_fortran_ddt_names(),
run_env=run_env)
for metadata_header in metadata_headers:
Expand Down
2 changes: 1 addition & 1 deletion scripts/metadata_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def read_new_metadata(filename, module_name, table_name, scheme_name = None, sub
if filename in NEW_METADATA_SAVE.keys():
new_metadata_headers = NEW_METADATA_SAVE[filename]
else:
new_metadata_headers = parse_metadata_file(filename, known_ddts=registered_fortran_ddt_names(),
new_metadata_headers, new_metadata_titles = parse_metadata_file(filename, known_ddts=registered_fortran_ddt_names(),
run_env=_DUMMY_RUN_ENV)
NEW_METADATA_SAVE[filename] = new_metadata_headers

Expand Down
18 changes: 12 additions & 6 deletions scripts/metadata_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
from parse_tools import check_fortran_ref, check_fortran_id
from parse_tools import check_fortran_intrinsic
from parse_tools import register_fortran_ddt_name, unique_standard_name
from parse_tools import registered_fortran_ddt_name

########################################################################

Expand Down Expand Up @@ -222,7 +223,7 @@ def parse_metadata_file(filename, known_ddts, run_env, skip_ddt_check=False, rel
context=parse_obj)
# end if
# end while
return meta_tables
return meta_tables, table_titles

########################################################################

Expand Down Expand Up @@ -979,13 +980,18 @@ def parse_variable(self, curr_line, known_ddts, skip_ddt_check=False):
if skip_ddt_check:
register_fortran_ddt_name(pval_str)
# end if
pval = pval_str.lower()
Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise we get this error:
communicator: 'mpi_comm' is not a valid derived Fortran type

pval = pval_str
pname = 'ddt_type'
else:
errmsg = "Unknown DDT type, {}".format(pval_str)
self.__pobj.add_syntax_err(errmsg)
self.__section_valid = False
var_ok = False
if registered_fortran_ddt_name(pval_str):
pval = pval_str.lower()
pname = 'ddt_type'
else:
errmsg = "Unknown DDT type, {}".format(pval_str)
self.__pobj.add_syntax_err(errmsg)
self.__section_valid = False
var_ok = False
# end if
# end if
else:
# Make sure this is a match
Expand Down
Loading
Loading