Skip to content

Commit

Permalink
Merge pull request #168 from mvertens/feature/update_dms_exchange
Browse files Browse the repository at this point in the history
Update dms exchange and add 10m winds to mediator

- Update Externals_CAM to point to new oslo_aero code that only computes ocean dms
  flux if its not obtained from the the mediator
- add 10m winds to send to mediator (this is needed for WW3)

Summary: update dms exchange and add 10m winds to mediator

Contributors: mvertens, gold2718
Changes made to build system: None
Changes made to the namelist: None
Changes to the defaults for the boundary datasets: None
Substantial timing or memory changes: None

Testing:
./create_test --xml-category aux_cam_noresm --xml-machine betzy --compare noresm2_5_013_cam6_3_158 --generate noresm2_5_014_cam6_3_158 --baseline-root ~/baselines/cam_develop
The results were bfb.
  • Loading branch information
gold2718 authored Sep 23, 2024
2 parents c06c57a + 302e4cc commit f546468
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Externals_CAM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ required = True

[oslo_aero]
protocol = git
hash = 87f76b3
hash = 2414f85
repo_url = https://github.com/NorESMhub/OSLO_AERO
local_path = src/chemistry/oslo_aero
required = True
Expand Down
12 changes: 12 additions & 0 deletions src/control/camsrfexch.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module camsrfexch
real(r8) :: topo(pcols) ! surface topographic height (m)
real(r8) :: ubot(pcols) ! bot level u wind
real(r8) :: vbot(pcols) ! bot level v wind
real(r8) :: wind_dir(pcols) ! direction of bottom level wind
real(r8) :: qbot(pcols,pcnst) ! bot level specific humidity
real(r8) :: pbot(pcols) ! bot level pressure
real(r8) :: rho(pcols) ! bot level density
Expand Down Expand Up @@ -296,6 +297,7 @@ subroutine atm2hub_alloc( cam_out )
cam_out(c)%topo(:) = 0._r8
cam_out(c)%ubot(:) = 0._r8
cam_out(c)%vbot(:) = 0._r8
cam_out(c)%wind_dir(:) = 0._r8
cam_out(c)%qbot(:,:) = 0._r8
cam_out(c)%pbot(:) = 0._r8
cam_out(c)%rho(:) = 0._r8
Expand Down Expand Up @@ -436,6 +438,7 @@ subroutine cam_export(state,cam_out,pbuf)
integer :: prec_dp_idx, snow_dp_idx, prec_sh_idx, snow_sh_idx
integer :: prec_sed_idx,snow_sed_idx,prec_pcw_idx,snow_pcw_idx
integer :: srf_ozone_idx, lightning_idx
real(r8):: ubot, vbot

real(r8), pointer :: psl(:)

Expand Down Expand Up @@ -503,6 +506,15 @@ subroutine cam_export(state,cam_out,pbuf)
cam_out%pbot(i) = state%pmid(i,pver)
cam_out%psl(i) = psl(i)
cam_out%rho(i) = cam_out%pbot(i)/(rair*cam_out%tbot(i))

! Direction of bottom level wind
ubot = state%u(i,pver)
vbot = state%v(i,pver)
if ((ubot == 0.0_r8) .and. (vbot == 0.0_r8)) then
cam_out%wind_dir(i) = 0.0_r8 ! Default to U for zero wind
else
cam_out%wind_dir(i) = atan2(vbot,ubot)
end if
end do
do m = 1, pcnst
do i = 1, ncol
Expand Down
4 changes: 2 additions & 2 deletions src/cpl/nuopc/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call set_component_logging(gcomp, localpet==0, iulog, shrlogunit, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call shr_log_setLogUnit (iulog)

!----------------------------------------------------------------------------
! advertise import/export fields
!----------------------------------------------------------------------------
Expand Down Expand Up @@ -316,6 +314,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call shr_sys_abort(subname//'Need to set attribute mediator_present')
endif

! reset shr logging to original values
call shr_log_setLogUnit (shrlogunit)
if (dbug_flag > 5) then
call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO)
end if
Expand Down
38 changes: 35 additions & 3 deletions src/cpl/nuopc/atm_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ module atm_import_export
use shr_mpi_mod , only : shr_mpi_min, shr_mpi_max
use nuopc_shr_methods , only : chkerr
use cam_logfile , only : iulog
use cam_history , only: outfld
use spmd_utils , only : masterproc, mpicom
use constituents , only : cnst_get_ind, sflxnam
use srf_field_check , only : set_active_Sl_ram1
use srf_field_check , only : set_active_Sl_fv
use srf_field_check , only : set_active_Sl_soilw
Expand Down Expand Up @@ -155,6 +157,7 @@ subroutine advertise_fields(gcomp, flds_scalar_name, rc)
dms_from_ocn = .false.
end if
if (masterproc) write(iulog,'(a,l)') trim(subname)//'dms_from_ocn = ',dms_from_ocn
write(6,'(a,l)')trim(subname)//'dms_from_ocn = ',dms_from_ocn

call NUOPC_CompAttributeGet(gcomp, name='flds_brf', value=cvalue, ispresent=ispresent, isset=isset, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -194,6 +197,8 @@ subroutine advertise_fields(gcomp, flds_scalar_name, rc)
call fldlist_add(fldsFrAtm_num, fldsFrAtm, 'Sa_z' )
call fldlist_add(fldsFrAtm_num, fldsFrAtm, 'Sa_u' )
call fldlist_add(fldsFrAtm_num, fldsFrAtm, 'Sa_v' )
call fldlist_add(fldsFrAtm_num, fldsFrAtm, 'Sa_u10m' )
call fldlist_add(fldsFrAtm_num, fldsFrAtm, 'Sa_v10m' )
call fldlist_add(fldsFrAtm_num, fldsFrAtm, 'Sa_tbot' )
call fldlist_add(fldsFrAtm_num, fldsFrAtm, 'Sa_ptem' )
call fldlist_add(fldsFrAtm_num, fldsFrAtm, 'Sa_shum' )
Expand Down Expand Up @@ -578,6 +583,7 @@ subroutine import_fields( gcomp, cam_in, restart_init, rc)
real(r8), pointer :: fldptr_tauy(:)
real(r8), pointer :: fldptr_sen(:)
real(r8), pointer :: fldptr_evap(:)
integer :: pndx_fdms ! DMS surface flux physics index
logical, save :: first_time = .true.
character(len=*), parameter :: subname='(atm_import_export:import_fields)'
!---------------------------------------------------------------------------
Expand Down Expand Up @@ -886,12 +892,16 @@ subroutine import_fields( gcomp, cam_in, restart_init, rc)

call state_getfldptr(importState, 'Faoo_fdms_ocn', fldptr=fldptr1d, exists=exists, rc=rc)
if (exists) then
call cnst_get_ind('DMS', pndx_fdms, abort=.true.)
g = 1
do c = begchunk,endchunk
do i = 1,get_ncols_p(c)
cam_in(c)%fdms(i) = -fldptr1d(g) * med2mod_areacor(g)
cam_in(c)%cflx(i,pndx_fdms) = cam_in(c)%fdms(i)
g = g + 1
end do
ncols = get_ncols_p(c)
call outfld( sflxnam(pndx_fdms), cam_in(c)%cflx(:ncols,pndx_fdms), ncols, c)
end do
end if

Expand Down Expand Up @@ -1025,17 +1035,19 @@ subroutine export_fields( gcomp, model_mesh, model_clock, cam_out, rc)

! local variables
type(ESMF_State) :: exportState
type(ESMF_State) :: importState
type(ESMF_Clock) :: clock
integer :: i,m,c,n,g ! indices
integer :: ncols ! Number of columns
integer :: nstep
logical :: exists
real(r8) :: scale_ndep
! 2d pointers
real(r8) :: wind_dir
! 2d output pointers
real(r8), pointer :: fldptr_ndep(:,:)
real(r8), pointer :: fldptr_bcph(:,:) , fldptr_ocph(:,:)
real(r8), pointer :: fldptr_dstwet(:,:), fldptr_dstdry(:,:)
! 1d pointers
! 1d output pointers
real(r8), pointer :: fldptr_soll(:) , fldptr_sols(:)
real(r8), pointer :: fldptr_solld(:) , fldptr_solsd(:)
real(r8), pointer :: fldptr_snowc(:) , fldptr_snowl(:)
Expand All @@ -1049,13 +1061,17 @@ subroutine export_fields( gcomp, model_mesh, model_clock, cam_out, rc)
real(r8), pointer :: fldptr_co2prog(:) , fldptr_co2diag(:)
real(r8), pointer :: fldptr_ozone(:)
real(r8), pointer :: fldptr_lght(:)
real(r8), pointer :: fldptr_u10m(:)
real(r8), pointer :: fldptr_v10m(:)
! import state pointer
real(r8), pointer :: fldptr_wind10m(:)
character(len=*), parameter :: subname='(atm_import_export:export_fields)'
!---------------------------------------------------------------------------

rc = ESMF_SUCCESS

! Get export state
call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc)
call NUOPC_ModelGet(gcomp, exportState=exportState, importState=importState, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! required export state variables
Expand All @@ -1079,6 +1095,19 @@ subroutine export_fields( gcomp, model_mesh, model_clock, cam_out, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getfldptr(exportState, 'Sa_pslv', fldptr=fldptr_pslv, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getfldptr(exportState, 'Sa_u10m', fldptr=fldptr_u10m, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getfldptr(exportState, 'Sa_v10m', fldptr=fldptr_v10m, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getfldptr(importState, 'Sx_u10' , fldptr=fldptr_wind10m, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! The 10m wind speed over ocean obtained from the atm/ocn flux computation in the mediator
! and is merged with the 10m wind speed obtained from the land ice ice components
! This computation for 10m wind speed will have used the bottom level winds from cam sent
! at the previous time
! The decomposition of the 10m wind into its zonal and meridional components is done using
! the bottom level u and v fields from cam (at the current time)
g = 1
do c = begchunk,endchunk
do i = 1,get_ncols_p(c)
Expand All @@ -1092,6 +1121,9 @@ subroutine export_fields( gcomp, model_mesh, model_clock, cam_out, rc)
fldptr_dens(g) = cam_out(c)%rho(i)
fldptr_ptem(g) = cam_out(c)%thbot(i)
fldptr_pslv(g) = cam_out(c)%psl(i)
wind_dir = cam_out(c)%wind_dir(i)
fldptr_u10m(g) = fldptr_wind10m(g)*cos(wind_dir)
fldptr_v10m(g) = fldptr_wind10m(g)*sin(wind_dir)
g = g + 1
end do
end do
Expand Down
10 changes: 5 additions & 5 deletions src/physics/cam/phys_control.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ module phys_control
! Add vars to indicate physics version and chemistry type.
!-----------------------------------------------------------------------

use spmd_utils, only: masterproc
use cam_logfile, only: iulog
use cam_abortutils, only: endrun
use shr_kind_mod, only: r8 => shr_kind_r8, cl=>shr_kind_cl
use spmd_utils, only: masterproc
use cam_logfile, only: iulog
use cam_abortutils, only: endrun
use shr_kind_mod, only: r8 => shr_kind_r8, cl=>shr_kind_cl

implicit none
private
Expand Down Expand Up @@ -56,7 +56,7 @@ module phys_control
logical :: history_aerosol = .false. ! output the MAM aerosol variables and tendencies
logical :: history_aero_optics = .false. ! output the aerosol
logical :: history_eddy = .false. ! output the eddy variables
logical :: history_budget = .false. ! output tendencies and state variables for T, water vapor,
logical :: history_budget = .false. ! output tendencies and state variables for T, water vapor,
! cloud ice and cloud liquid budgets
logical :: convproc_do_aer = .false. ! switch for new convective scavenging treatment for modal aerosols

Expand Down

0 comments on commit f546468

Please sign in to comment.