From 7befdbc737cf8f1c247dd6ac128f7d6a4eccde95 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sat, 14 Sep 2024 20:49:40 +0200 Subject: [PATCH 1/7] new dms from ocean in nuopc cap --- bld/namelist_files/namelist_definition.xml | 9 +++++++++ src/cpl/nuopc/atm_comp_nuopc.F90 | 4 ++-- src/cpl/nuopc/atm_import_export.F90 | 8 ++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 15594a7cc3..b5543e9b6e 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -9644,6 +9644,12 @@ created from AeroTab AeroTab file AeroTab file + +If true, obtain dms flux from ocean component. +Default: false + + Type of DMS data source @@ -9692,4 +9698,7 @@ Path to ocean file Default: path + + + diff --git a/src/cpl/nuopc/atm_comp_nuopc.F90 b/src/cpl/nuopc/atm_comp_nuopc.F90 index 8b2ba903d0..0fb6a22c68 100644 --- a/src/cpl/nuopc/atm_comp_nuopc.F90 +++ b/src/cpl/nuopc/atm_comp_nuopc.F90 @@ -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 !---------------------------------------------------------------------------- @@ -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 diff --git a/src/cpl/nuopc/atm_import_export.F90 b/src/cpl/nuopc/atm_import_export.F90 index 7eeec9a523..6c57ee1990 100644 --- a/src/cpl/nuopc/atm_import_export.F90 +++ b/src/cpl/nuopc/atm_import_export.F90 @@ -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 @@ -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 @@ -578,6 +581,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)' !--------------------------------------------------------------------------- @@ -886,12 +890,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 From a62f79603e339ed38b52c94b660f64a10c73a468 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Wed, 18 Sep 2024 20:55:28 +0200 Subject: [PATCH 2/7] added 10m winds to wave back in --- src/control/camsrfexch.F90 | 8 ++++++++ src/cpl/nuopc/atm_import_export.F90 | 24 +++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/control/camsrfexch.F90 b/src/control/camsrfexch.F90 index 280774ae51..56b20d863c 100644 --- a/src/control/camsrfexch.F90 +++ b/src/control/camsrfexch.F90 @@ -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 @@ -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 @@ -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(:) @@ -503,6 +506,11 @@ 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) + cam_out%wind_dir(i) = atan2(vbot,ubot) end do do m = 1, pcnst do i = 1, ncol diff --git a/src/cpl/nuopc/atm_import_export.F90 b/src/cpl/nuopc/atm_import_export.F90 index 6c57ee1990..18ce3f2596 100644 --- a/src/cpl/nuopc/atm_import_export.F90 +++ b/src/cpl/nuopc/atm_import_export.F90 @@ -197,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' ) @@ -1033,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(:) @@ -1057,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 @@ -1087,6 +1095,13 @@ 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 + g = 1 do c = begchunk,endchunk do i = 1,get_ncols_p(c) @@ -1100,6 +1115,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 From 8f671e40be2dac1127d9d812acbdbfb132d3b01e Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Thu, 19 Sep 2024 07:31:49 +0200 Subject: [PATCH 3/7] reverted to original namelist_definition.xml --- bld/namelist_files/namelist_definition.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index b5543e9b6e..15594a7cc3 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -9644,12 +9644,6 @@ created from AeroTab AeroTab file AeroTab file - -If true, obtain dms flux from ocean component. -Default: false - - Type of DMS data source @@ -9698,7 +9692,4 @@ Path to ocean file Default: path - - - From 02ecefb392d5c0dcd502f82a5ed73ee8c43a03c0 Mon Sep 17 00:00:00 2001 From: Steve Goldhaber Date: Thu, 19 Sep 2024 14:24:36 +0200 Subject: [PATCH 4/7] Special case for atan2 Provide dms_from_ocn from phys_control instead of coupling layer. --- src/control/camsrfexch.F90 | 6 +++++- src/physics/cam/phys_control.F90 | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/control/camsrfexch.F90 b/src/control/camsrfexch.F90 index 56b20d863c..44812d67ff 100644 --- a/src/control/camsrfexch.F90 +++ b/src/control/camsrfexch.F90 @@ -510,7 +510,11 @@ subroutine cam_export(state,cam_out,pbuf) ! Direction of bottom level wind ubot = state%u(i,pver) vbot = state%v(i,pver) - cam_out%wind_dir(i) = atan2(vbot,ubot) + 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 diff --git a/src/physics/cam/phys_control.F90 b/src/physics/cam/phys_control.F90 index 92ccac1335..6283e32294 100644 --- a/src/physics/cam/phys_control.F90 +++ b/src/physics/cam/phys_control.F90 @@ -10,10 +10,11 @@ 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 +use atm_import_export, only: drv_dms_from_ocn => dms_from_ocn implicit none private @@ -56,7 +57,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 @@ -105,6 +106,9 @@ module phys_control ! Option for Harmonized Emissions Component (HEMCO) logical, public, protected :: use_hemco = .false. +! Take DMS from ocean? +logical, public, protected :: dms_from_ocn = .false. + ! CAM snapshot before/after file numbers and control character(len=32) :: cam_take_snapshot_before = '' ! Physics routine to take a snopshot "before" character(len=32) :: cam_take_snapshot_after = '' ! Physics routine to take a snopshot "after" @@ -277,6 +281,9 @@ subroutine phys_ctl_readnl(nlfile) ! prog_modal_aero determines whether prognostic modal aerosols are present in the run. prog_modal_aero = index(cam_chempkg,'_mam')>0 + ! Set this from the driver namelist (always read first) + dms_from_ocn = drv_dms_from_ocn + end subroutine phys_ctl_readnl !=============================================================================== From 79a150436e3d6c377d7d44a06cd01571fc1924b6 Mon Sep 17 00:00:00 2001 From: Steve Goldhaber Date: Thu, 19 Sep 2024 18:49:15 +0200 Subject: [PATCH 5/7] Remove dms_from_ocn from phys_control --- src/physics/cam/phys_control.F90 | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/physics/cam/phys_control.F90 b/src/physics/cam/phys_control.F90 index 6283e32294..bd723cacf2 100644 --- a/src/physics/cam/phys_control.F90 +++ b/src/physics/cam/phys_control.F90 @@ -14,7 +14,6 @@ module phys_control use cam_logfile, only: iulog use cam_abortutils, only: endrun use shr_kind_mod, only: r8 => shr_kind_r8, cl=>shr_kind_cl -use atm_import_export, only: drv_dms_from_ocn => dms_from_ocn implicit none private @@ -106,9 +105,6 @@ module phys_control ! Option for Harmonized Emissions Component (HEMCO) logical, public, protected :: use_hemco = .false. -! Take DMS from ocean? -logical, public, protected :: dms_from_ocn = .false. - ! CAM snapshot before/after file numbers and control character(len=32) :: cam_take_snapshot_before = '' ! Physics routine to take a snopshot "before" character(len=32) :: cam_take_snapshot_after = '' ! Physics routine to take a snopshot "after" @@ -281,9 +277,6 @@ subroutine phys_ctl_readnl(nlfile) ! prog_modal_aero determines whether prognostic modal aerosols are present in the run. prog_modal_aero = index(cam_chempkg,'_mam')>0 - ! Set this from the driver namelist (always read first) - dms_from_ocn = drv_dms_from_ocn - end subroutine phys_ctl_readnl !=============================================================================== From e4652e13641d7de43a1ae7ff662f427240d2613f Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Mon, 23 Sep 2024 11:34:36 +0200 Subject: [PATCH 6/7] added new comment --- src/cpl/nuopc/atm_import_export.F90 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cpl/nuopc/atm_import_export.F90 b/src/cpl/nuopc/atm_import_export.F90 index 18ce3f2596..07b7f46ae3 100644 --- a/src/cpl/nuopc/atm_import_export.F90 +++ b/src/cpl/nuopc/atm_import_export.F90 @@ -1102,6 +1102,12 @@ subroutine export_fields( gcomp, model_mesh, model_clock, cam_out, rc) 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) From 302e4cc24f9859abc176e80779c24234e52829b5 Mon Sep 17 00:00:00 2001 From: Steve Goldhaber Date: Mon, 23 Sep 2024 11:48:56 +0200 Subject: [PATCH 7/7] Update hash for Oslo Aero --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 0b1d2ce538..9f63646b32 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -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