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

Enable CCPP host model under CMEPS and updates for UFS exchange grid capability #282

Merged
merged 51 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
afd91d4
add new flux computation for UFS model and add new coupling mode for …
uturuncoglu Nov 24, 2021
3758f9f
fix area field for new flux algorithm
uturuncoglu Nov 29, 2021
0f635e1
send fluxes to atmospheric model
uturuncoglu Dec 7, 2021
53ebc24
initial implementation for sending fluxes to UFS ATM
uturuncoglu Dec 19, 2021
7784990
merge with origin/master
uturuncoglu Dec 30, 2021
bba5b4e
update with master
uturuncoglu Jan 6, 2022
cdfbb35
update ccpp aoflux code
uturuncoglu Jan 8, 2022
a80db60
fix upward longwave sign issue
uturuncoglu Jan 11, 2022
2d57af5
mods to solve sign issue in the fluxes
uturuncoglu Jan 12, 2022
7471055
update to use both flux scheme (cesm, ccpp) under UFS
uturuncoglu Jan 13, 2022
5fec3a0
revert mods in prep atm phase
uturuncoglu Jan 13, 2022
22af6e5
initial attempt to have host model for CCPP
uturuncoglu Jan 28, 2022
84be138
Minor updates to get CCPP handshake right
climbfuji Jan 31, 2022
e22ebb6
Merge pull request #1 from climbfuji/exchange_grid_dom_20220130
uturuncoglu Jan 31, 2022
cdb2025
more work for CCPP host model
uturuncoglu Feb 1, 2022
6237d13
Updates and bug fixes to complete ccpp_prebuild.py call
climbfuji Feb 3, 2022
4297d0b
minor fixes
uturuncoglu Feb 4, 2022
699c177
add support for sfc_diff
uturuncoglu Feb 5, 2022
e1dead1
fix namespace collision
uturuncoglu Feb 6, 2022
792be4c
update CCPP host model
uturuncoglu Feb 8, 2022
2a3cb9e
fix latent and sensible heat fluxes and clean code
uturuncoglu Feb 9, 2022
f127fa6
add new coupling mode for side by side flux comparison
uturuncoglu Feb 9, 2022
e813a97
fix CCPP host model for latent and sensible heat fluxes
uturuncoglu Feb 22, 2022
8526e31
do not use biliear and patch under UFS exchnage grid
uturuncoglu Feb 24, 2022
bf9e4b3
add support to get ccpp suite from config file
uturuncoglu Feb 25, 2022
f12b1d9
fix for data configurations
uturuncoglu Apr 6, 2022
6654167
add option to write meshes and update code that retrieve area informa…
uturuncoglu Apr 17, 2022
383f11c
update ccpp host based on recent changes in ccpp framework
uturuncoglu Apr 17, 2022
d56d53b
fix for providing cell area to CCPP host model
uturuncoglu Apr 19, 2022
c99de05
make ccpp physics options configurable
uturuncoglu Apr 19, 2022
bed9c56
update CMEPS and fix to work with latest version of CCPP physics
uturuncoglu May 4, 2022
f2385cc
fix char length issue for gnu compiler
uturuncoglu May 4, 2022
36d880a
Merge remote-tracking branch 'origin/master' into feature/xgrid_dev_host
uturuncoglu May 5, 2022
139047e
make qmin constant
uturuncoglu May 5, 2022
1bef7aa
declare constants as parameters
uturuncoglu May 6, 2022
b0eee2c
fix for UFS OpnReqTests debug test
May 6, 2022
4d91092
Merge branch 'feature/xgrid_dev_host' of https://github.com/uturuncog…
May 6, 2022
d307cd5
fix threading issue in CCPP driver
uturuncoglu May 9, 2022
3fe2c87
update naming convention and use _med suffix in CCPP host model
May 10, 2022
dfdb479
add restart capability to CCPP host model
May 15, 2022
a8bb766
more work to bring restart capability to CCPP host model
May 16, 2022
355557a
fix to write data on exchange grid
uturuncoglu May 18, 2022
31f9316
more work for ccpp restart capability, agrid and ogrid are passing now
May 20, 2022
c90b9f1
fix ccpp restart for xgrid and add support for sfc_diag
May 21, 2022
c7e92a6
update to fix ORT issues
May 25, 2022
54e8ae5
add missing call to read restart file
May 25, 2022
14b8216
fix for gnu compiler
uturuncoglu May 25, 2022
b0e5418
change standard name of new option and couple of minor fix for debug …
uturuncoglu May 26, 2022
e1e91b5
fix conditional to check nproc
uturuncoglu May 26, 2022
2e3f061
fix for initial conditions, default is not to read
uturuncoglu May 26, 2022
81a2807
add new field to adjust new version of physics code
uturuncoglu May 27, 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
68 changes: 66 additions & 2 deletions mediator/esmFldsExchange_nems_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
use esmFlds , only : addmap => med_fldList_AddMap
use esmFlds , only : addmrg => med_fldList_AddMrg
use esmflds , only : fldListTo, fldListFr, fldListMed_aoflux, fldListMed_ocnalb
use med_internalstate_mod , only : InternalState, mastertask, logunit

! input/output parameters:
type(ESMF_GridComp) :: gcomp
Expand Down Expand Up @@ -132,6 +133,39 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
deallocate(flds)
end if

if (trim(coupling_mode) == 'nems_frac_aoflux' .or. trim(coupling_mode) == 'nems_frac_aoflux_sbs') then
allocate(flds(12))
flds = (/'Sa_u ', 'Sa_v ', 'Sa_z ', 'Sa_tbot ', 'Sa_pbot ', &
'Sa_pslv ', 'Sa_shum ', 'Sa_ptem ', 'Sa_dens ', 'Sa_u10m ', &
'Sa_v10m ', 'Faxa_lwdn'/)
do n = 1,size(flds)
fldname = trim(flds(n))
if (phase == 'advertise') then
if (is_local%wrap%comp_present(compatm) )then
call addfld(fldListFr(compatm)%flds, trim(fldname))
end if
else
if ( fldchk(is_local%wrap%FBImp(compatm,compatm), trim(fldname), rc=rc)) then
call addmap(fldListFr(compatm)%flds, trim(fldname), compocn, maptype, 'one', 'unset')
end if
end if
end do
deallocate(flds)

! fields returned by the atm/ocn flux computation which are otherwise unadvertised
allocate(flds(13))
flds = (/'So_tref ', 'So_qref ','So_u10 ', 'So_ustar ','So_ssq ', &
'So_re ', 'So_duu10n','Faox_lwup', 'Faox_sen ','Faox_lat ', &
'Faox_evap', 'Faox_taux','Faox_tauy'/)
do n = 1,size(flds)
fldname = trim(flds(n))
if (phase == 'advertise') then
call addfld(fldListMed_aoflux%flds, trim(fldname))
end if
end do
deallocate(flds)
end if

! TODO: unused, but required to maintain B4B repro for mediator restarts; should be removed
if (phase == 'advertise') then
call addfld(fldListFr(compice)%flds, 'mean_sw_pen_to_ocn')
Expand Down Expand Up @@ -215,6 +249,35 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
end if
end if

! to atm: unmerged from mediator, merge will be done under FV3/CCPP composite step
! - zonal surface stress, meridional surface stress
! - surface latent heat flux,
! - surface sensible heat flux
! - surface upward longwave heat flux
! - evaporation water flux from water, not in the list do we need to send it to atm?
if (trim(coupling_mode) == 'nems_frac_aoflux') then
if (is_local%wrap%comp_present(compocn) .and. is_local%wrap%comp_present(compatm)) then
allocate(flds(5))
flds = (/ 'lat ', 'sen ', 'lwup', 'taux', 'tauy' /)
if (phase == 'advertise') then
do n = 1,size(flds)
call addfld(fldListMed_aoflux%flds , 'Faox_'//trim(flds(n)))
call addfld(fldListTo(compatm)%flds, 'Faox_'//trim(flds(n)))
end do
else
do n = 1,size(flds)
if (fldchk(is_local%wrap%FBMed_aoflux_o, 'Faox_'//trim(flds(n)), rc=rc)) then
if (trim(is_local%wrap%aoflux_grid) == 'ogrid') then
call addmap(fldListMed_aoflux%flds, 'Faox_'//trim(flds(n)), compatm, maptype, 'ofrac', 'unset')
end if
call addmrg(fldListTo(compatm)%flds, 'Faox_'//trim(flds(n)), mrg_from=compmed, mrg_fld='Faox_'//trim(flds(n)), mrg_type='copy')
end if
end do
end if
deallocate(flds)
end if
end if

! to atm: surface roughness length from wav
if (phase == 'advertise') then
if (is_local%wrap%comp_present(compwav) .and. is_local%wrap%comp_present(compatm)) then
Expand Down Expand Up @@ -310,7 +373,8 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
end do
deallocate(flds)

if (trim(coupling_mode) == 'nems_orig' .or. trim(coupling_mode) == 'nems_frac') then
if (trim(coupling_mode) == 'nems_orig' .or. trim(coupling_mode) == 'nems_frac' .or. &
trim(coupling_mode) == 'nems_frac_aoflux_sbs') then
! to ocn: merge surface stress (custom merge calculation in med_phases_prep_ocn)
allocate(oflds(2))
allocate(aflds(2))
Expand Down Expand Up @@ -379,7 +443,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
call addmap(fldListFr(compatm)%flds, 'Faxa_lat', compocn, mapconsf_aofrac, 'aofrac', 'unset')
end if
end if
else
else if (trim(coupling_mode) == 'nems_orig_data' .or. trim(coupling_mode) == 'nems_frac_aoflux') then
! nems_orig_data
! to ocn: surface stress from mediator and ice stress via auto merge
allocate(flds(2))
Expand Down
32 changes: 31 additions & 1 deletion mediator/med.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module MED
use med_internalstate_mod , only : med_internalstate_defaultmasks, logunit, mastertask
use med_internalstate_mod , only : ncomps, compname
use med_internalstate_mod , only : compmed, compatm, compocn, compice, complnd, comprof, compwav, compglc
use med_internalstate_mod , only : coupling_mode
use med_internalstate_mod , only : coupling_mode, aoflux_code, aoflux_ccpp_suite
use esmFlds , only : fldListMed_ocnalb
use esmFlds , only : med_fldList_GetNumFlds, med_fldList_GetFldNames, med_fldList_GetFldInfo
use esmFlds , only : med_fldList_Document_Mapping, med_fldList_Document_Merging
Expand Down Expand Up @@ -762,6 +762,36 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc)
end if
is_local%wrap%aoflux_grid = trim(cvalue)

! Determine aoflux scheme that will be used to compute atmosphere-ocean fluxes [cesm|ccpp]
! TODO: If ccpp is not available it will be always run in cesm mode independent from aoflux_code option
call NUOPC_CompAttributeGet(gcomp, name='aoflux_code', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (.not. isPresent .and. .not. isSet) then
cvalue = 'cesm'
end if
aoflux_code = trim(cvalue)
if (mastertask) then
write(logunit,*) '========================================================'
write(logunit,'(a)')trim(subname)//' Mediator aoflux scheme is '//trim(aoflux_code)
write(logunit,*) '========================================================'
end if

! Determine CCPP suite if aoflux scheme set to 'ccpp'
if (trim(aoflux_code) == 'ccpp') then
call NUOPC_CompAttributeGet(gcomp, name='aoflux_ccpp_suite', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (.not. isPresent .and. .not. isSet) then
call ESMF_LogWrite("aoflux_ccpp_suite need to be provided when aoflux_code is set to 'ccpp'", ESMF_LOGMSG_INFO)
call ESMF_Finalize(endflag=ESMF_END_ABORT)
end if
aoflux_ccpp_suite = trim(cvalue)
if (mastertask) then
write(logunit,*) '========================================================'
write(logunit,'(a)')trim(subname)//' Mediator aoflux CCPP suite is '//trim(aoflux_ccpp_suite)
write(logunit,*) '========================================================'
end if
end if

!------------------
! Initialize mediator flds
!------------------
Expand Down
10 changes: 8 additions & 2 deletions mediator/med_fraction_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ subroutine med_fraction_init(gcomp, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

! Set 'aofrac' in FBfrac(compatm)
if (trim(coupling_mode) == 'nems_orig' .or. trim(coupling_mode) == 'nems_frac') then
if (trim(coupling_mode) == 'nems_orig' .or. &
trim(coupling_mode) == 'nems_frac' .or. &
trim(coupling_mode) == 'nems_frac_aoflux' .or. &
trim(coupling_mode) == 'nems_frac_aoflux_sbs') then
call fldbun_getdata1d(is_local%wrap%FBImp(compatm,compatm), 'Sa_ofrac', Sa_ofrac, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call fldbun_getdata1d(is_local%wrap%FBFrac(compatm), 'aofrac', aofrac, rc)
Expand Down Expand Up @@ -789,7 +792,10 @@ subroutine med_fraction_set(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
! Set 'aofrac' from FBImp(compatm) to FBfrac(compatm)
if (trim(coupling_mode) == 'nems_orig' .or. trim(coupling_mode) == 'nems_frac') then
if (trim(coupling_mode) == 'nems_orig' .or. &
trim(coupling_mode) == 'nems_frac' .or. &
trim(coupling_mode) == 'nems_frac_aoflux' .or. &
trim(coupling_mode) == 'nems_frac_aoflux_sbs') then
call fldbun_getdata1d(is_local%wrap%FBImp(compatm,compatm), 'Sa_ofrac', Sa_ofrac, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call fldbun_getdata1d(is_local%wrap%FBFrac(compatm), 'aofrac', aofrac, rc)
Expand Down
11 changes: 9 additions & 2 deletions mediator/med_internalstate_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module med_internalstate_mod
!-----------------------------------------------------------------------------

use ESMF , only : ESMF_RouteHandle, ESMF_FieldBundle, ESMF_State, ESMF_Field, ESMF_VM
use ESMF , only : ESMF_GridComp, ESMF_MAXSTR, ESMF_LOGMSG_INFO, ESMF_LOGWRITE
use ESMF , only : ESMF_GridComp, ESMF_Mesh, ESMF_MAXSTR, ESMF_LOGMSG_INFO, ESMF_LOGWRITE
use med_kind_mod , only : CX=>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8
use med_utils_mod, only : chkerr => med_utils_ChkErr

Expand Down Expand Up @@ -47,7 +47,13 @@ module med_internalstate_mod
character(len=CS), public :: glc_name = ''

! Coupling mode
character(len=CS), public :: coupling_mode ! valid values are [cesm,nems_orig,nems_frac,nems_orig_data,hafs]
character(len=CS), public :: coupling_mode ! valid values are [cesm,nems_orig,nems_frac,nems_orig_data,hafs,nems_frac_aoflux,nems_frac_aoflux_sbs]

! Atmosphere-ocean flux algorithm
character(len=CS), public :: aoflux_code ! valid values are [cesm,ccpp]

! Atmosphere-ocean CCPP suite name
character(len=CL), public :: aoflux_ccpp_suite

! Default src and destination masks for mapping
integer, public, allocatable :: defaultMasks(:,:)
Expand Down Expand Up @@ -153,6 +159,7 @@ module med_internalstate_mod

! Mediator field bundles and other info for atm/ocn flux computation
character(len=CS) :: aoflux_grid ! 'ogrid', 'agrid' or 'xgrid'
type(ESMF_Mesh) :: aoflux_mesh ! Mesh used for atm/ocn flux computation
type(ESMF_FieldBundle) :: FBMed_aoflux_a ! Ocn/Atm flux output fields on atm grid
type(ESMF_FieldBundle) :: FBMed_aoflux_o ! Ocn/Atm flux output fields on ocn grid
type(packed_data_type), pointer :: packed_data_aoflux_o2a(:) ! packed data for mapping ocn->atm
Expand Down
6 changes: 4 additions & 2 deletions mediator/med_io_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1111,12 +1111,14 @@ subroutine med_io_write_FB(filename, FB, whead, wdata, nx, ny, nt, &
call pio_write_darray(io_file(lfile_ind), varid, iodesc, fldptr2(n,:), rcode, fillval=lfillvalue)
end if
end do
else if (rank == 1) then
else if (rank == 1 .or. rank == 0) then
name1 = trim(lpre)//'_'//trim(itemc)
rcode = pio_inq_varid(io_file(lfile_ind), trim(name1), varid)
call pio_setframe(io_file(lfile_ind),varid,frame)
! fix for writing data on exchange grid, which has no data in some PETs
if (rank == 0) nullify(fldptr1)
call pio_write_darray(io_file(lfile_ind), varid, iodesc, fldptr1, rcode, fillval=lfillvalue)
end if ! end if rank is 2 or 1
end if ! end if rank is 2 or 1 or 0

end if ! end if not "hgt"
end do ! end loop over fields in FB
Expand Down
Loading