Skip to content
Open
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
32 changes: 32 additions & 0 deletions .github/workflows/cmp_fortran_to_metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Run Capgen fortran to metadata comparision script

on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
env:
SCM_ROOT: ${{ github.workspace }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Initialize Submodules
run: |
git config --global --add safe.directory ${SCM_ROOT}
cd ${SCM_ROOT}
git submodule update --init --recursive

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Compare Fortran source files to CCPP metadata files
run: |
cp test/test_fortran_to_metadata.py .
./test_fortran_to_metadata.py
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
branch = develop
[submodule "ccpp-physics"]
path = ccpp/physics
url = https://github.com/NCAR/ccpp-physics
branch = scm/dev
url = https://github.com/dustinswales/ccpp-physics
branch = bug/flake_metadata
[submodule "CMakeModules"]
path = CMakeModules
url = https://github.com/noaa-emc/CMakeModules
Expand Down
7 changes: 7 additions & 0 deletions ccpp/config/ccpp_prebuild_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@
},
'module_radsw_parameters' : {
'module_radsw_parameters' : '',
'cmpfsw_type' : '',
'sfcfsw_type' : '',
'profsw_type' : '',
'topfsw_type' : '',
},
'module_radlw_parameters' : {
'module_radlw_parameters' : '',
'sfcflw_type' : '',
'proflw_type' : '',
'topflw_type' : '',
},
'module_ozphys' : {
'module_ozphys' : '',
Expand Down
83 changes: 83 additions & 0 deletions test/test_fortran_to_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python

###############################################################################
# Dependencies
###############################################################################
import argparse
import os
import sys
sys.path.append('ccpp/config')
from ccpp_prebuild_config import SCHEME_FILES, TYPEDEFS_NEW_METADATA, VARIABLE_DEFINITION_FILES

###############################################################################
# Main program
###############################################################################
def main():
# This list of files is not compared since they are known to fail.
files_known_to_not_pass_test = [
'ccpp/physics/physics/MP/GFDL/fv_sat_adj.F90',
'ccpp/physics/physics/Radiation/RRTMG/rrtmg_lw_post.F90',
'ccpp/physics/physics/SFC_Layer/UFS/sfc_diff.f',
'ccpp/physics/physics/SFC_Models/Lake/CLM/clm_lake.f90',
'ccpp/physics/physics/smoke_dust/rrfs_smoke_wrapper.F90']

# Comparison script from framework
script_dir = 'ccpp/framework/scripts/'
f2m_script = script_dir+'/ccpp_fortran_to_metadata.py'

# Create list of known DDTs (using prebuild config script)
ddts = []
for ct, typedefs in enumerate(TYPEDEFS_NEW_METADATA):
for typedef in TYPEDEFS_NEW_METADATA[typedefs]:
ddts.append(typedef)
# end for
# end for

# Create string from DDT list.
init = True
known_ddts = ''
for ddt in ddts:
if (init):
known_ddts = ddt
init = False
else:
known_ddts = known_ddts+','+ddt
# end if
# end for

# Run Fortran-to-metadata comparision script
error_count = 0
error_file = []
com = f2m_script+' --ddt-names '+known_ddts+' '
for scheme_file in SCHEME_FILES:
if (scheme_file not in files_known_to_not_pass_test):
result = os.system(com+scheme_file)
if (result != 0):
error_count = error_count + 1
error_file.append(scheme_file)
# end if
else:
print("skipping ",scheme_file)
# end if
# end for

# Display results
print('------------------------------------------------------------------------------------')
if (error_count == 0):
print("SUCCESS! All metadata and Fortran files are consistent")
sys.exit(0)
else:
print("ERROR! There are differences between the metadata and Fortran source files")
print(" ",str(error_count)+' files have issues:')
for ierror in error_file:
print(" ",ierror)
# end for
print(" See messages above for more details")
sys.exit(1)
# end if
print('------------------------------------------------------------------------------------')

###############################################################################
###############################################################################
if __name__ == '__main__':
main()
Loading