├── CODEOWNERS ├── cime_config ├── testdefs │ └── testmods_dirs │ │ └── drv │ │ ├── glcnec10 │ │ ├── include_user_mods │ │ └── shell_commands │ │ ├── aoflux_ogrid │ │ └── user_nl_cpl │ │ ├── 5steps │ │ └── shell_commands │ │ ├── y100k │ │ ├── shell_commands │ │ └── README │ │ ├── default │ │ └── shell_commands │ │ ├── som │ │ └── shell_commands │ │ ├── interim_restart │ │ └── shell_commands │ │ ├── asyncio1node │ │ └── shell_commands │ │ └── asyncio1pernode │ │ └── shell_commands ├── user_nl_cpl ├── config_archive.xml ├── runseq │ ├── runseq_TG.py │ ├── gen_runseq.py │ └── runseq_D.py ├── ExpectedTestFails.xml ├── config_compsets.xml ├── buildexe └── config_pes.xml ├── doc ├── .gitignore ├── source │ ├── CMEPS-grid1.png │ ├── CMEPS-grid2.png │ ├── CMEPS-grid3.png │ ├── _templates │ │ ├── layout.html │ │ └── footer.html │ ├── addendum │ │ ├── index.rst │ │ ├── req_attributes.rst │ │ ├── req_attributes_cesm.rst │ │ └── fieldnames.rst │ ├── index.rst │ ├── _static │ │ └── pop_ver.js │ ├── prep.rst │ ├── fractions.rst │ ├── conf.py │ └── generic.rst └── Makefile ├── .travis.yml ├── mediator ├── ESMFVersionDefine.h ├── ESMFConvenienceMacros.h ├── med_constants_mod.F90 ├── med_kind_mod.F90 ├── CMakeLists.txt ├── med_utils_mod.F90 ├── med_phases_post_wav_mod.F90 ├── med_phases_post_ice_mod.F90 ├── med_phases_post_ocn_mod.F90 ├── med_phases_post_lnd_mod.F90 ├── Makefile ├── med_phases_post_atm_mod.F90 └── med_phases_prep_lnd_mod.F90 ├── ufs ├── CMakeLists.txt ├── perf_mod.F90 ├── ccpp │ ├── suites │ │ └── suite_FV3_sfc_ocean.xml │ ├── data │ │ ├── MED_data.F90 │ │ └── MED_data.meta │ ├── driver │ │ └── med_ccpp_driver.F90 │ └── config │ │ └── ccpp_prebuild_config.py ├── ufs_kind_mod.F90 ├── glc_elevclass_mod.F90 └── ufs_const_mod.F90 ├── tcipylint ├── README.md ├── .gitignore ├── .github ├── workflows │ ├── bumpversion.yml │ ├── extbuild.yml │ └── srt.yml └── pull_request_template.md ├── .pre-commit-config.yaml ├── CMakeLists.txt ├── cesm ├── nuopc_cap_share │ ├── esm_utils_mod.F90 │ ├── shr_carma_mod.F90 │ ├── shr_ndep_mod.F90 │ ├── shr_lightning_coupling_mod.F90 │ ├── shr_ozone_coupling_mod.F90 │ └── shr_expr_parser_mod.F90 ├── driver │ ├── util.F90 │ └── t_driver_timers_mod.F90 └── flux_atmocn │ ├── shr_flux_mod.F90 │ └── flux_atmocn_driver_mod.F90 └── cmake ├── FindESMF.cmake ├── FindPIO.cmake └── LibCheck.cmake /CODEOWNERS: -------------------------------------------------------------------------------- 1 | /cesm/flux_atmocn/ @megandevlan 2 | -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/glcnec10/include_user_mods: -------------------------------------------------------------------------------- 1 | ../default 2 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore auto-generated documentation for the addendum 2 | build 3 | -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/glcnec10/shell_commands: -------------------------------------------------------------------------------- 1 | ./xmlchange GLC_NEC=10 -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/aoflux_ogrid/user_nl_cpl: -------------------------------------------------------------------------------- 1 | aoflux_grid = "ogrid" 2 | -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/5steps/shell_commands: -------------------------------------------------------------------------------- 1 | ./xmlchange STOP_OPTION="nsteps" 2 | 3 | -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/y100k/shell_commands: -------------------------------------------------------------------------------- 1 | ./xmlchange RUN_STARTDATE=99999-12-28 2 | -------------------------------------------------------------------------------- /doc/source/CMEPS-grid1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESCOMP/CMEPS/main/doc/source/CMEPS-grid1.png -------------------------------------------------------------------------------- /doc/source/CMEPS-grid2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESCOMP/CMEPS/main/doc/source/CMEPS-grid2.png -------------------------------------------------------------------------------- /doc/source/CMEPS-grid3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESCOMP/CMEPS/main/doc/source/CMEPS-grid3.png -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/default/shell_commands: -------------------------------------------------------------------------------- 1 | ./xmlchange HIST_OPTION=ndays 2 | ./xmlchange HIST_N=1 3 | -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/som/shell_commands: -------------------------------------------------------------------------------- 1 | ./xmlchange DOCN_SOM_FILENAME="pop_frc.1x1d.090130.nc" 2 | 3 | -------------------------------------------------------------------------------- /doc/source/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | 3 | {% set script_files = script_files + ["_static/pop_ver.js"] %} -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/interim_restart/shell_commands: -------------------------------------------------------------------------------- 1 | # use this with the ERR test to test the interim restart capability 2 | ./xmlchange REST_N=2 -------------------------------------------------------------------------------- /doc/source/addendum/index.rst: -------------------------------------------------------------------------------- 1 | .. _addendum: 2 | 3 | Addendum 4 | ======== 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | req_attributes.rst 10 | req_attributes_cesm.rst 11 | fieldnames.rst 12 | -------------------------------------------------------------------------------- /doc/source/_templates/footer.html: -------------------------------------------------------------------------------- 1 | {% extends "!footer.html" %} 2 | {% block extrafooter %} 3 | {{ super() }} 4 | 5 | {% endblock %} 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | install: 4 | - pip install pylint 5 | 6 | python: 7 | - '3.7' 8 | - '3.8' 9 | - '3.9' 10 | 11 | branches: 12 | only: 13 | - master 14 | 15 | script: ./tcipylint 16 | -------------------------------------------------------------------------------- /mediator/ESMFVersionDefine.h: -------------------------------------------------------------------------------- 1 | #if 0 2 | // 3 | // Make this header file available as ESMFVersionDefine.h in order to build 4 | // UFS against an ESMF installation that contains a reference level NUOPC Layer. 5 | // 6 | #endif 7 | 8 | #include "./ESMFConvenienceMacros.h" 9 | -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/y100k/README: -------------------------------------------------------------------------------- 1 | This tests the ability to use 6-digit years. 2 | 3 | As of the time this test was created, the max year is about 214747 - 4 | otherwise we exceed the limit of 4-byte integers when storing dates as 5 | integers (yyyyyymmdd). 6 | -------------------------------------------------------------------------------- /ufs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(CMEPS_share Fortran) 2 | include(ExternalProject) 3 | 4 | add_library(cmeps_share flux_atmocn_mod.F90 glc_elevclass_mod.F90 perf_mod.F90 ufs_const_mod.F90 ufs_kind_mod.F90) 5 | 6 | target_include_directories (cmeps_share PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ESMF_F90COMPILEPATHS} ${PIO_Fortran_INCLUDE_DIRS}) 7 | -------------------------------------------------------------------------------- /tcipylint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | args="--disable=I,C,R,logging-not-lazy,wildcard-import,unused-wildcard-import,fixme,broad-except,bare-except,eval-used,exec-used,global-statement,logging-format-interpolation,no-name-in-module,import-error" 3 | failed=0 4 | for file in cime_config/buildexe cime_config/buildnml cime_config/runseq/* 5 | do 6 | pylint $args $file || failed=$(( failed + 1 )) 7 | done 8 | exit $failed 9 | -------------------------------------------------------------------------------- /mediator/ESMFConvenienceMacros.h: -------------------------------------------------------------------------------- 1 | #if 0 2 | // ----------- ERROR handling macros ------------------------------------------ 3 | #endif 4 | 5 | #define ESMF_ERR_ABORT(rc) if (ESMF_LogFoundError(rc, msg="Aborting UFS", line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) 6 | 7 | #define ESMF_ERR_RETURN(rc,rcOut) if (ESMF_LogFoundError(rc, msg="Breaking out of subroutine", line=__LINE__, file=__FILE__, rcToReturn=rcOut)) return 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CMEPS 2 | NUOPC based Community Mediator for Earth Prediction Systems 3 | 4 | ## Overview and resources 5 | 6 | The Community Mediator for Earth Prediction Systems (CMEPS) is a 7 | NUOPC-compliant Mediator component used for coupling Earth system 8 | model components. It is currently being used in NCAR's Community 9 | Earth System Model (CESM) and NOAA's UFS subseasonal-to-seasonal 10 | coupled system application. 11 | 12 | For documentation see 13 | 14 | https://escomp.github.io/CMEPS/ 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Python compiled files 11 | *.pyc 12 | cime_config/buildnmlc 13 | cime_config/buildexec 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Compiled Dynamic libraries 20 | *.so 21 | *.dylib 22 | *.dll 23 | 24 | # Fortran module files 25 | *.mod 26 | *.smod 27 | 28 | # Compiled Static libraries 29 | *.lai 30 | *.la 31 | *.a 32 | *.lib 33 | 34 | # Executables 35 | *.exe 36 | *.out 37 | *.app 38 | -------------------------------------------------------------------------------- /.github/workflows/bumpversion.yml: -------------------------------------------------------------------------------- 1 | name: Bump version 2 | on: 3 | push: 4 | branches: 5 | - main 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - name: Bump version and push tag 12 | id: tag_version 13 | uses: mathieudutour/github-tag-action@v6.2 14 | with: 15 | github_token: ${{ secrets.GITHUB_TOKEN }} 16 | create_annotated_tag: true 17 | default_bump: patch 18 | dry_run: false 19 | tag_prefix: cmeps 20 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### Description of changes 2 | 3 | ### Specific notes 4 | 5 | Contributors other than yourself, if any: 6 | 7 | CMEPS Issues Fixed (include github issue #): 8 | 9 | Are changes expected to change answers? (specify if bfb, different at roundoff, more substantial) 10 | 11 | Any User Interface Changes (namelist or namelist defaults changes)? 12 | 13 | ### Testing performed 14 | Please describe the tests along with the target model and machine(s) 15 | If possible, please also added hashes that were used in the testing 16 | 17 | -------------------------------------------------------------------------------- /ufs/perf_mod.F90: -------------------------------------------------------------------------------- 1 | module perf_mod 2 | 3 | use ESMF 4 | 5 | implicit none 6 | public 7 | 8 | public t_startf 9 | public t_stopf 10 | 11 | contains 12 | 13 | subroutine t_startf(event, handle) 14 | character(len=*), intent(in) :: event 15 | integer, optional :: handle 16 | call ESMF_TraceRegionEnter(event) 17 | end subroutine t_startf 18 | 19 | subroutine t_stopf(event, handle) 20 | character(len=*), intent(in) :: event 21 | integer, optional :: handle 22 | call ESMF_TraceRegionExit(event) 23 | end subroutine t_stopf 24 | 25 | end module perf_mod 26 | -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/asyncio1node/shell_commands: -------------------------------------------------------------------------------- 1 | # This will add 4 asyncio tasks on the first node 2 | ./xmlchange PIO_ASYNCIO_ROOTPE=0 3 | ./xmlchange PIO_ASYNCIO_STRIDE=1 4 | ./xmlchange PIO_ASYNCIO_NTASKS=4 5 | ./xmlchange PIO_REARRANGER=2 6 | ./xmlchange PIO_ASYNC_INTERFACE=TRUE 7 | for comp in ATM OCN LND ICE CPL GLC ROF 8 | do 9 | rootpe=`./xmlquery --value ROOTPE_$comp` 10 | let newrootpe=rootpe+4 11 | ./xmlchange ROOTPE_$comp=$newrootpe 12 | done 13 | comp_ocn=`./xmlquery --value COMP_OCN` 14 | # MOM ocn has no pio interface 15 | if [[ "$comp_ocn" == "mom" ]]; then 16 | ./xmlchange PIO_ASYNC_INTERFACE_OCN=FALSE; 17 | fi 18 | -------------------------------------------------------------------------------- /ufs/ccpp/suites/suite_FV3_sfc_ocean.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | GFS_surface_composites_pre 7 | 8 | 9 | sfc_diff 10 | GFS_surface_loop_control_part1 11 | sfc_ocean 12 | GFS_surface_loop_control_part2 13 | 14 | 15 | GFS_surface_composites_post 16 | sfc_diag 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = CMEPS 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /doc/source/index.rst: -------------------------------------------------------------------------------- 1 | .. on documentation main file, created by 2 | sphinx-quickstart on Mon May 18 11:50:23 2020. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | CMEPS documentation 7 | =================== 8 | The Community Mediator for Earth Prediction Systems (CMEPS) is a 9 | NUOPC-compliant Mediator component used for coupling Earth system 10 | model components. It is currently being used in NCAR's Community 11 | Earth System Model (CESM) and NOAA's subseasonal-to-seasonal 12 | coupled system. 13 | 14 | Table of contents 15 | ----------------- 16 | .. toctree:: 17 | :maxdepth: 2 18 | :numbered: 19 | 20 | introduction.rst 21 | esmflds.rst 22 | fractions.rst 23 | prep.rst 24 | generic.rst 25 | addendum/index.rst 26 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | exclude: ^utils/.*$ 2 | 3 | repos: 4 | - repo: https://github.com/pre-commit/pre-commit-hooks 5 | rev: v4.0.1 6 | hooks: 7 | - id: check-xml 8 | files: cime_config/ 9 | - id: end-of-file-fixer 10 | exclude: doc/ 11 | - id: trailing-whitespace 12 | exclude: doc/ 13 | - repo: https://github.com/psf/black 14 | rev: 22.3.0 15 | hooks: 16 | - id: black 17 | files: ./ 18 | - repo: https://github.com/PyCQA/pylint 19 | rev: v2.11.1 20 | hooks: 21 | - id: pylint 22 | args: 23 | - --disable=I,C,R,logging-not-lazy,wildcard-import,unused-wildcard-import,fixme,broad-except,bare-except,eval-used,exec-used,global-statement,logging-format-interpolation,no-name-in-module,arguments-renamed,unspecified-encoding,protected-access,import-error,no-member 24 | files: cime_config 25 | -------------------------------------------------------------------------------- /mediator/med_constants_mod.F90: -------------------------------------------------------------------------------- 1 | module med_constants_mod 2 | 3 | use med_kind_mod, only : CX=>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8 4 | #ifdef CESMCOUPLED 5 | use shr_const_mod 6 | #else 7 | use ufs_const_mod 8 | #endif 9 | 10 | implicit none 11 | public 12 | 13 | logical, parameter :: med_constants_statewrite_flag = .false. 14 | real(R8), parameter :: med_constants_spval_init = 0.0_R8 ! spval for initialization 15 | real(R8), parameter :: med_constants_spval = 0.0_R8 ! spval 16 | real(R8), parameter :: med_constants_czero = 0.0_R8 ! spval 17 | integer, parameter :: med_constants_ispval_mask = -987987 ! spval for RH mask values 18 | integer, parameter :: med_constants_SecPerDay = 86400 ! Seconds per day 19 | integer :: med_constants_dbug_flag = 0 20 | 21 | end module med_constants_mod 22 | -------------------------------------------------------------------------------- /cime_config/user_nl_cpl: -------------------------------------------------------------------------------- 1 | !------------------------------------------------------------------------ 2 | ! Users should ONLY USE user_nl_cpl to change namelists variables 3 | ! for namelist variables in drv_in (except for the ones below) and 4 | ! any keyword/values in seq_maps.rc 5 | ! Users should add ALL user specific namelist and seq_maps.rc changes below 6 | ! using the following syntax 7 | ! namelist_var = new_namelist_value 8 | ! or 9 | ! mapname = new_map_name 10 | ! For example to change the default value of ocn2atm_fmapname to 'foo' use 11 | ! ocn2atm_fmapname = 'foo' 12 | ! 13 | ! Note that some namelist variables MAY NOT be changed in user_nl_cpl - 14 | ! they are defined in a $CASEROOT xml file and must be changed with 15 | ! xmlchange. 16 | ! 17 | ! For example, rather than set username to 'foo' in user_nl_cpl, call 18 | ! ./xmlchange USER=foo 19 | !------------------------------------------------------------------------ 20 | -------------------------------------------------------------------------------- /cime_config/testdefs/testmods_dirs/drv/asyncio1pernode/shell_commands: -------------------------------------------------------------------------------- 1 | # This will add one async pio task per node to a test 2 | # does not work for all cases 3 | max2() { printf '%d' $(( $1 > $2 ? $1 : $2 )); } 4 | let totaltasks=0 5 | ./xmlchange --force --force PIO_ASYNC_INTERFACE=TRUE 6 | for comp in ATM OCN LND ICE CPL GLC ROF 7 | do 8 | ntasks=`./xmlquery --value NTASKS_$comp` 9 | rootpe=`./xmlquery --value ROOTPE_$comp` 10 | let maxpe=ntasks+rootpe 11 | totaltasks=$(( $totaltasks > $maxpe ? $totaltasks : $maxpe )) 12 | done 13 | echo "totaltasks is $totaltasks" 14 | tpn=`./xmlquery --value MAX_MPITASKS_PER_NODE` 15 | ./xmlchange --force --force PIO_ASYNCIO_STRIDE=$tpn 16 | let piontasks=totaltasks/tpn 17 | echo "piontasks=$piontasks" 18 | ./xmlchange --force --force PIO_ASYNCIO_NTASKS=$piontasks 19 | let newntasks=totaltasks-piontasks 20 | echo "newntasks=$newntasks" 21 | ./xmlchange --force --force NTASKS=$newntasks 22 | ./xmlchange --force --force PIO_REARRANGER=2 23 | -------------------------------------------------------------------------------- /cime_config/config_archive.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | r 4 | h[ix]?\d*\..*\.nc(\.gz)?$ 5 | unset 6 | 7 | rpointer.cpl$NINST_STRING.$DATENAME 8 | $CASE.cpl$NINST_STRING.r.$DATENAME.nc 9 | 10 | 11 | cpl_0001.log.5548574.chadmin1.180228-124723.gz 12 | casename.cpl.r.1976-01-01-00000.nc 13 | rpointer.cpl_0001.1976-01-01-00000 14 | rpointer.cpl_0001.1976-01-01-43200 15 | rpointer.cpl.1976-01-01-00000 16 | casenamenot.cpl.r.1976-01-01-00000.nc 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /ufs/ufs_kind_mod.F90: -------------------------------------------------------------------------------- 1 | MODULE ufs_kind_mod 2 | 3 | !---------------------------------------------------------------------------- 4 | ! precision/kind constants add data public 5 | !---------------------------------------------------------------------------- 6 | public 7 | integer,parameter :: SHR_KIND_R8 = selected_real_kind(12) ! 8 byte real 8 | integer,parameter :: SHR_KIND_R4 = selected_real_kind( 6) ! 4 byte real 9 | integer,parameter :: SHR_KIND_RN = kind(1.0) ! native real 10 | integer,parameter :: SHR_KIND_I8 = selected_int_kind (13) ! 8 byte integer 11 | integer,parameter :: SHR_KIND_I4 = selected_int_kind ( 6) ! 4 byte integer 12 | integer,parameter :: SHR_KIND_IN = kind(1) ! native integer 13 | integer,parameter :: SHR_KIND_CS = 80 ! short char 14 | integer,parameter :: SHR_KIND_CM = 160 ! mid-sized char 15 | integer,parameter :: SHR_KIND_CL = 256 ! long char 16 | integer,parameter :: SHR_KIND_CX = 512 ! extra-long char 17 | integer,parameter :: SHR_KIND_CXX= 4096 ! extra-extra-long char 18 | 19 | END MODULE ufs_kind_mod 20 | -------------------------------------------------------------------------------- /mediator/med_kind_mod.F90: -------------------------------------------------------------------------------- 1 | module med_kind_mod 2 | 3 | !---------------------------------------------------------------------------- 4 | ! precision/kind constants add data public 5 | !---------------------------------------------------------------------------- 6 | public 7 | integer,parameter :: SHR_KIND_R8 = selected_real_kind(12) ! 8 byte real 8 | integer,parameter :: SHR_KIND_R4 = selected_real_kind( 6) ! 4 byte real 9 | integer,parameter :: SHR_KIND_RN = kind(1.0) ! native real 10 | integer,parameter :: SHR_KIND_I8 = selected_int_kind (13) ! 8 byte integer 11 | integer,parameter :: SHR_KIND_I4 = selected_int_kind ( 6) ! 4 byte integer 12 | integer,parameter :: SHR_KIND_IN = kind(1) ! native integer 13 | integer,parameter :: SHR_KIND_CS = 80 ! short char 14 | integer,parameter :: SHR_KIND_CM = 160 ! mid-sized char 15 | integer,parameter :: SHR_KIND_CL = 256 ! long char 16 | integer,parameter :: SHR_KIND_CX = 512 ! extra-long char 17 | integer,parameter :: SHR_KIND_CXX= 4096 ! extra-extra-long char 18 | 19 | end module med_kind_mod 20 | -------------------------------------------------------------------------------- /ufs/ccpp/data/MED_data.F90: -------------------------------------------------------------------------------- 1 | !> \file MED_data.F90 2 | !! Contains type definitions for CMEPS-related and physics-related variables 3 | 4 | module MED_data 5 | 6 | !> \section arg_table_MED_data 7 | !! \htmlinclude MED_data.html 8 | !! 9 | 10 | use MED_typedefs, only: MED_statein_type 11 | use MED_typedefs, only: MED_stateout_type 12 | use MED_typedefs, only: MED_init_type 13 | use MED_typedefs, only: MED_interstitial_type 14 | use MED_typedefs, only: MED_control_type 15 | use MED_typedefs, only: MED_coupling_type 16 | use MED_typedefs, only: MED_grid_type 17 | use MED_typedefs, only: MED_sfcprop_type 18 | use MED_typedefs, only: MED_diag_type 19 | use ccpp_types, only: ccpp_t 20 | 21 | implicit none 22 | 23 | public physics 24 | 25 | !! \section arg_table_physics_type 26 | !! \htmlinclude physics_type.html 27 | !! 28 | type physics_type 29 | type(MED_init_type) :: init 30 | type(MED_statein_type) :: statein 31 | type(MED_stateout_type) :: stateout 32 | type(MED_interstitial_type) :: interstitial 33 | type(MED_control_type) :: model 34 | type(MED_coupling_type) :: coupling 35 | type(MED_grid_type) :: grid 36 | type(MED_sfcprop_type) :: sfcprop 37 | type(MED_diag_type) :: diag 38 | end type physics_type 39 | 40 | type(physics_type), save, target :: physics 41 | type(ccpp_t), save, target :: cdata 42 | 43 | contains 44 | 45 | end module MED_data 46 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | include(ExternalProject) 3 | 4 | if (DEFINED CIMEROOT) 5 | message("Using CIME in ${CIMEROOT} with compiler ${COMPILER}") 6 | include(${CASEROOT}/Macros.cmake) 7 | if (${PIO_VERSION} LESS 2) 8 | message( FATAL_ERROR "Version 2 of the PIO library required") 9 | endif() 10 | if (${MPILIB} STREQUAL "mpi-serial") 11 | set(CMAKE_C_COMPILER ${SCC}) 12 | set(CMAKE_Fortran_COMPILER ${SFC}) 13 | set(CMAKE_CXX_COMPILER ${SCXX}) 14 | else() 15 | set(CMAKE_C_COMPILER ${MPICC}) 16 | set(CMAKE_Fortran_COMPILER ${MPIFC}) 17 | set(CMAKE_CXX_COMPILER ${MPICXX}) 18 | endif() 19 | set(CMAKE_Fortran_FLAGS "${FFLAGS} -I${LIBROOT}/include -I${LIBROOT}/finclude -I${LIBROOT}/nuopc/esmf/${NINST_VALUE}/include") 20 | else() 21 | set(BLD_STANDALONE TRUE) 22 | endif() 23 | 24 | project(CMEPS LANGUAGES Fortran VERSION 0.1) 25 | 26 | list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) 27 | 28 | message("CMAKE_MODULE_PATH is ${CMAKE_MODULE_PATH}") 29 | 30 | find_package(ESMF REQUIRED) 31 | if (DEFINED PIO) 32 | set(PIO_PATH ${PIO}) 33 | else() 34 | set(PIO_PATH $ENV{PIO}) 35 | endif() 36 | find_package(PIO REQUIRED COMPONENT C Fortran PATH ${PIO_PATH}) 37 | 38 | if (NOT DEFINED MPILIB OR NOT ${MPILIB} STREQUAL "mpi-serial") 39 | find_package(MPI REQUIRED) 40 | endif() 41 | 42 | if(BLD_STANDALONE) 43 | add_subdirectory(ufs) 44 | list(APPEND EXTRA_LIBS cmeps_share) 45 | list(APPEND EXTRA_INCLUDES "${CMAKE_BINARY_DIR}/ufs") 46 | endif() 47 | 48 | add_subdirectory(mediator) 49 | -------------------------------------------------------------------------------- /cesm/nuopc_cap_share/esm_utils_mod.F90: -------------------------------------------------------------------------------- 1 | module esm_utils_mod 2 | 3 | implicit none 4 | public 5 | 6 | logical :: maintask 7 | integer :: logunit 8 | integer :: dbug_flag = 0 9 | 10 | character(*), parameter :: u_FILE_u = & 11 | __FILE__ 12 | 13 | !=============================================================================== 14 | contains 15 | !=============================================================================== 16 | 17 | logical function ChkErr(rc, line, file, mpierr) 18 | #ifndef NO_MPI2 19 | use mpi, only : MPI_ERROR_STRING, MPI_MAX_ERROR_STRING, MPI_SUCCESS 20 | #else 21 | use mpi, only : MPI_SUCCESS 22 | #endif 23 | use ESMF, only : ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU, ESMF_LOGMSG_INFO 24 | use ESMF, only : ESMF_FAILURE, ESMF_LogWrite 25 | 26 | integer, intent(in) :: rc 27 | integer, intent(in) :: line 28 | 29 | character(len=*), intent(in) :: file 30 | logical, optional, intent(in) :: mpierr 31 | #ifdef NO_MPI2 32 | integer, parameter :: MPI_MAX_ERROR_STRING=80 33 | #endif 34 | character(MPI_MAX_ERROR_STRING) :: lstring 35 | integer :: dbrc, lrc, len, ierr 36 | 37 | ChkErr = .false. 38 | lrc = rc 39 | if (present(mpierr)) then 40 | if(mpierr) then 41 | if (rc == MPI_SUCCESS) return 42 | #ifdef USE_MPI2 43 | call MPI_ERROR_STRING(rc, lstring, len, ierr) 44 | #else 45 | write(lstring,*) "ERROR in mct mpi-serial library rc=",rc 46 | #endif 47 | call ESMF_LogWrite("ERROR: "//trim(lstring), ESMF_LOGMSG_INFO, line=line, file=file, rc=dbrc) 48 | lrc = ESMF_FAILURE 49 | endif 50 | endif 51 | 52 | if (ESMF_LogFoundError(rcToCheck=lrc, msg=ESMF_LOGERR_PASSTHRU, line=line, file=file)) then 53 | ChkErr = .true. 54 | endif 55 | end function ChkErr 56 | 57 | end module esm_utils_mod 58 | -------------------------------------------------------------------------------- /mediator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(cmeps Fortran) 2 | 3 | set(SRCFILES esmFldsExchange_cesm_mod.F90 med_fraction_mod.F90 4 | med_methods_mod.F90 med_phases_prep_ice_mod.F90 5 | med_phases_restart_mod.F90 esmFldsExchange_hafs_mod.F90 6 | med_internalstate_mod.F90 med_phases_aofluxes_mod.F90 7 | med_phases_prep_lnd_mod.F90 8 | esmFldsExchange_ufs_mod.F90 med_io_mod.F90 9 | med_phases_history_mod.F90 med_phases_prep_ocn_mod.F90 10 | med_utils_mod.F90 esmFlds.F90 med_kind_mod.F90 11 | med_phases_prep_rof_mod.F90 12 | med_constants_mod.F90 med_map_mod.F90 13 | med_phases_prep_atm_mod.F90 med_phases_prep_wav_mod.F90 14 | med.F90 med_merge_mod.F90 med_phases_prep_glc_mod.F90 15 | med_phases_profile_mod.F90 med_diag_mod.F90 16 | med_phases_post_ocn_mod.F90 med_phases_ocnalb_mod.F90 17 | med_phases_post_atm_mod.F90 med_phases_post_ice_mod.F90 18 | med_phases_post_lnd_mod.F90 med_phases_post_glc_mod.F90 19 | med_phases_post_rof_mod.F90 med_phases_post_wav_mod.F90) 20 | 21 | foreach(FILE ${SRCFILES}) 22 | if(EXISTS "${CASEROOT}/SourceMods/src.cmeps/${FILE}") 23 | list(REMOVE_ITEM SRCFILES ${FILE}) 24 | list(APPEND SRCFILES "${CASEROOT}/SourceMods/src.cmeps/${FILE}") 25 | message("Using ${FILE} from ${CASEROOT}/SourceMods/src.cmeps") 26 | endif() 27 | endforeach() 28 | add_library(cmeps ${SRCFILES}) 29 | 30 | if(BLD_STANDALONE) 31 | add_dependencies(cmeps cmeps_share) 32 | endif() 33 | 34 | target_include_directories (cmeps PUBLIC ${ESMF_F90COMPILEPATHS}) 35 | target_include_directories (cmeps PUBLIC "${CMAKE_BINARY_DIR}/ufs") 36 | target_include_directories (cmeps PUBLIC ${PIO_Fortran_INCLUDE_DIR}) 37 | 38 | install(TARGETS cmeps 39 | LIBRARY DESTINATION lib) 40 | -------------------------------------------------------------------------------- /cime_config/runseq/runseq_TG.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os, shutil, sys 4 | from CIME.utils import expect 5 | from gen_runseq import RunSeq 6 | from driver_config import DriverConfig 7 | 8 | _CIMEROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir,os.pardir,os.pardir,os.pardir)) 9 | sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) 10 | 11 | from standard_script_setup import * 12 | 13 | #pylint:disable=undefined-variable 14 | logger = logging.getLogger(__name__) 15 | 16 | def gen_runseq(case, coupling_times): 17 | 18 | rundir = case.get_value("RUNDIR") 19 | caseroot = case.get_value("CASEROOT") 20 | 21 | driver_config = DriverConfig(case, coupling_times) 22 | run_glc, med_to_glc, glc_cpl_time = driver_config['glc'] 23 | run_lnd, _ , lnd_cpl_time = driver_config['lnd'] 24 | 25 | if lnd_cpl_time != glc_cpl_time: 26 | expect(False,"for TG compset require that lnd_cpl_time equal glc_cpl_time") 27 | 28 | with RunSeq(os.path.join(caseroot, "CaseDocs", "nuopc.runseq")) as runseq: 29 | 30 | runseq.enter_time_loop(glc_cpl_time, True) 31 | 32 | runseq.add_action ("LND" , run_lnd) 33 | runseq.add_action ("LND -> MED :remapMethod=redist" , run_lnd) 34 | runseq.add_action ("MED med_phases_post_lnd" , run_lnd) 35 | runseq.add_action ("MED med_phases_prep_glc" , med_to_glc) 36 | runseq.add_action ("MED -> GLC :remapMethod=redist" , med_to_glc) 37 | runseq.add_action ("GLC" , run_glc) 38 | # Need to do GLC -> MED even if not running GLC; otherwise, we get a 39 | # failure in InitializeRealize ("Object being used before creation") 40 | runseq.add_action ("GLC -> MED :remapMethod=redist" , med_to_glc) 41 | runseq.add_action ("MED med_phases_history_write" , True) 42 | 43 | runseq.leave_time_loop(True) 44 | 45 | shutil.copy(os.path.join(caseroot, "CaseDocs", "nuopc.runseq"), rundir) 46 | -------------------------------------------------------------------------------- /cime_config/ExpectedTestFails.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | FAIL 36 | Mom restarts are offset 37 | 38 | 39 | 40 | 41 | FAIL 42 | Mom restarts are offset 43 | 44 | 45 | 46 | 47 | FAIL 48 | Mom restarts are offset 49 | 50 | 51 | 52 | 53 | FAIL 54 | Debug run fails due to esmf issue 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /cmake/FindESMF.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (DEFINED ENV{ESMFMKFILE}) 3 | message("ESMFMKFILE: $ENV{ESMFMKFILE}") 4 | else() 5 | message(FATAL_ERROR "ESMFMKFILE env variable is not defined") 6 | endif() 7 | 8 | set(ESMFMKFILE $ENV{ESMFMKFILE}) 9 | 10 | # convert esmf.mk makefile variables to cmake variables until ESMF 11 | # provides proper cmake package 12 | file(STRINGS ${ESMFMKFILE} esmf_mk_text) 13 | foreach(line ${esmf_mk_text}) 14 | string(REGEX REPLACE "^[ ]+" "" line ${line}) # strip leading spaces 15 | if (line MATCHES "^ESMF_*") # process only line starting with ESMF_ 16 | string(REGEX MATCH "^ESMF_[^=]+" esmf_name ${line}) 17 | string(REPLACE "${esmf_name}=" "" emsf_value ${line}) 18 | set(${esmf_name} "${emsf_value}") 19 | endif() 20 | endforeach() 21 | string(REPLACE "-I" "" ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS}) 22 | string(REPLACE " " ";" ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS}) 23 | 24 | # We use only these 4 variables in our build system. Make sure they are all set 25 | if(ESMF_VERSION_MAJOR AND 26 | ESMF_F90COMPILEPATHS AND 27 | ESMF_F90ESMFLINKRPATHS AND 28 | ESMF_F90ESMFLINKLIBS) 29 | message(" Found ESMF:") 30 | message("ESMF_VERSION_MAJOR: ${ESMF_VERSION_MAJOR}") 31 | message("ESMF_F90COMPILEPATHS: ${ESMF_F90COMPILEPATHS}") 32 | message("ESMF_F90ESMFLINKRPATHS: ${ESMF_F90ESMFLINKRPATHS}") 33 | message("ESMF_F90ESMFLINKLIBS: ${ESMF_F90ESMFLINKLIBS}") 34 | else() 35 | message("One of the ESMF_ variables is not defined") 36 | endif() 37 | 38 | include(FindPackageHandleStandardArgs) 39 | find_package_handle_standard_args(ESMF 40 | FOUND_VAR 41 | ESMF_FOUND 42 | REQUIRED_VARS 43 | ESMF_F90COMPILEPATHS 44 | ESMF_F90ESMFLINKRPATHS 45 | ESMF_F90ESMFLINKLIBS 46 | VERSION_VAR 47 | ESMF_VERSION_STRING) 48 | -------------------------------------------------------------------------------- /doc/source/_static/pop_ver.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | /* For a URL that looks like 3 | https://blah.github.io/versions/VERSIONFOO/html/bar/index.html, set cur_version_dir to 4 | 'VERSIONFOO' (i.e., the portion of the path following 'versions'). 5 | */ 6 | var proj_end = document.baseURI.indexOf("versions") + 9; 7 | var end = document.baseURI.indexOf("/", proj_end); 8 | var cur_version_dir = document.baseURI.substring(proj_end, end); 9 | var mylist = $("#version-list"); 10 | mylist.empty(); 11 | $.getJSON(version_json_loc, function(data) { 12 | if (data.hasOwnProperty(cur_version_dir)) { 13 | /* First add the current version so that it appears first in the drop-down 14 | menu and starts as the selected element of the menu. If you click on the 15 | current version, you should stay at the current page. 16 | 17 | The conditional around this block should generally be true, but we check it 18 | just in case the current version is missing from the versions.json file for 19 | some reason. 20 | */ 21 | cur_version_name = data[cur_version_dir]; 22 | mylist.append($("