Skip to content

Commit

Permalink
Merge pull request #514 from billsacks/allocate_psfc
Browse files Browse the repository at this point in the history
Fix logic for adding psfc to aoflux_in

### Description of changes

Fix the logic for adding psfc to aoflux_in, particularly needed for cases using the exchange grid.

This is needed to avoid a segmentation fault in the call to flux_atmocn in SMS_Ld2.ne30pg3_t232.BMT1850.derecho_gnu.allactive-defaultio when running with aoflux_grid=xgrid. (This shows up when running with xgrid because the FB_fldchk can't be used in this situation - see details in my [comment below](#514 (comment)).)

### Specific notes

Contributors other than yourself, if any:

CMEPS Issues Fixed (include github issue #):

Are changes expected to change answers? No

Any User Interface Changes (namelist or namelist defaults changes)? No

### Testing performed

SMS_Ld2.ne30pg3_t232.BMT1850.derecho_gnu.allactive-defaultio with aoflux_grid="xgrid", from cesm3_0_beta03

Also ran many other tests from the CESM prealpha and prebeta test suite.
  • Loading branch information
billsacks authored Oct 23, 2024
2 parents 1355710 + d9255d5 commit 0de751f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mediator/med_phases_aofluxes_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,13 @@ subroutine set_aoflux_in_pointers(fldbun_a, fldbun_o, aoflux_in, lsize, xgrid, r
if (chkerr(rc,__LINE__,u_FILE_u)) return
end if

if (FB_fldchk(fldbun_a, 'Sa_pslv', rc=rc)) then
! The following conditional captures the cases where aoflux_in%psfc is needed in calls
! to flux_atmocn / flux_atmocn_ccpp. Note that coupling_mode=='cesm' is equivalent to
! the CESMCOUPLED CPP token, and coupling_mode(1:3)=='ufs' is roughly equivalent to
! the UFS_AOFLUX CPP token (noting that we should only be in this subroutine if using
! one of the aoflux variants of the ufs coupling_mode).
if ((trim(coupling_mode) == 'cesm') .or. &
(coupling_mode(1:3) == 'ufs' .and. trim(aoflux_code) == 'ccpp')) then
call fldbun_getfldptr(fldbun_a, 'Sa_pslv', aoflux_in%psfc, xgrid=xgrid, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
end if
Expand All @@ -1653,10 +1659,6 @@ subroutine set_aoflux_in_pointers(fldbun_a, fldbun_o, aoflux_in, lsize, xgrid, r
if (compute_atm_dens .or. compute_atm_thbot) then
call fldbun_getfldptr(fldbun_a, 'Sa_pbot', aoflux_in%pbot, xgrid=xgrid, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (trim(coupling_mode) == 'ufs.frac.aoflux') then
call fldbun_getfldptr(fldbun_a, 'Sa_pslv', aoflux_in%psfc, xgrid=xgrid, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
end if
end if

if (flds_wiso) then
Expand Down

0 comments on commit 0de751f

Please sign in to comment.