diff --git a/.github/workflows/cmp_fortran_to_metadata.yml b/.github/workflows/cmp_fortran_to_metadata.yml new file mode 100644 index 000000000..405c9582a --- /dev/null +++ b/.github/workflows/cmp_fortran_to_metadata.yml @@ -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 \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index b9de8d317..a76057a8d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/ccpp/config/ccpp_prebuild_config.py b/ccpp/config/ccpp_prebuild_config.py index 3f693f8ff..7128acd27 100755 --- a/ccpp/config/ccpp_prebuild_config.py +++ b/ccpp/config/ccpp_prebuild_config.py @@ -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' : '', diff --git a/ccpp/physics b/ccpp/physics index 135a5dda8..47af3a34d 160000 --- a/ccpp/physics +++ b/ccpp/physics @@ -1 +1 @@ -Subproject commit 135a5dda80f383c29c9a1ac937a392c2e74c5683 +Subproject commit 47af3a34d5e71c1876a7c95f8cd76ded3e5aca7b diff --git a/test/test_fortran_to_metadata.py b/test/test_fortran_to_metadata.py new file mode 100755 index 000000000..6beb78934 --- /dev/null +++ b/test/test_fortran_to_metadata.py @@ -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()