diff --git a/cesm/flux_atmocn/shr_flux_mod.F90 b/cesm/flux_atmocn/shr_flux_mod.F90 index edf62fe31..87d8be9d5 100644 --- a/cesm/flux_atmocn/shr_flux_mod.F90 +++ b/cesm/flux_atmocn/shr_flux_mod.F90 @@ -1,11 +1,10 @@ -module flux_atmocn_mod +module shr_flux_mod ! atm/ocn/flux calculations ! !USES: - use shr_kind_mod , only : R8=>SHR_KIND_R8, IN=>SHR_KIND_IN ! shared kinds - use med_internalstate_mod , only : logunit + use shr_kind_mod, only : R8=>SHR_KIND_R8, IN=>SHR_KIND_IN ! shared kinds use shr_const_mod ! shared constants use shr_sys_mod ! shared system routines @@ -23,10 +22,10 @@ module flux_atmocn_mod public :: flux_atmOcn_diurnal ! computes atm/ocn fluxes with diurnal cycle public :: flux_atmOcn_UA ! computes atm/ocn fluxes using University of Ariz algorithm (Zeng et al., 1998) public :: flux_MOstability ! boundary layer stability scales/functions - public :: flux_adjust_constants ! adjust constant values used in flux calculations. + public :: shr_flux_adjust_constants ! adjust constant values used in flux calculations. (used by CAM as well) ! !PRIVATE MEMBER FUNCTIONS: - private :: psi_ua + private :: psi_ua private :: qsat_ua private :: rough_ua private :: cuberoot @@ -78,7 +77,7 @@ module flux_atmocn_mod contains !=============================================================================== - subroutine flux_adjust_constants( & + subroutine shr_flux_adjust_constants( & zvir, cpair, cpvir, karman, gravit, & latvap, latice, stebol, flux_convergence_tolerance, & flux_convergence_max_iteration, & @@ -111,7 +110,7 @@ subroutine flux_adjust_constants( & if (present(flux_convergence_max_iteration)) flux_con_max_iter = flux_convergence_max_iteration if (present(coldair_outbreak_mod)) use_coldair_outbreak_mod = coldair_outbreak_mod - end subroutine flux_adjust_constants + end subroutine shr_flux_adjust_constants !=============================================================================== ! !IROUTINE: flux_atmOcn -- internal atm/ocn flux calculation @@ -133,7 +132,7 @@ end subroutine flux_adjust_constants ! (ocn_surface_flux_scheme .eq. 1) based on code from ! Thomas Toniazzo (Bjerknes Centre, Bergen) ” !=============================================================================== - SUBROUTINE flux_atmOcn(nMax ,zbot ,ubot ,vbot ,thbot , & + SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , & & qbot ,s16O ,sHDO ,s18O ,rbot , & & tbot ,us ,vs , & & ts ,mask , seq_flux_atmocn_minwind, & @@ -142,8 +141,8 @@ SUBROUTINE flux_atmOcn(nMax ,zbot ,ubot ,vbot ,thbot , & & evap ,evap_16O, evap_HDO, evap_18O, & & taux ,tauy ,tref ,qref , & & ocn_surface_flux_scheme, & - & duu10n, ustar_sv ,re_sv ,ssq_sv, & - & missval ) + & duu10n, ustar_sv ,re_sv ,ssq_sv, & + & missval) ! !USES: use water_isotopes, only: wiso_flxoce !subroutine used to calculate water isotope fluxes. @@ -153,7 +152,8 @@ SUBROUTINE flux_atmOcn(nMax ,zbot ,ubot ,vbot ,thbot , & ! !INPUT/OUTPUT PARAMETERS: !--- input arguments -------------------------------- - integer(IN),intent(in) :: nMax ! data vector length + integer ,intent(in) :: logunit + integer(IN),intent(in) :: nMax ! data vector length integer(IN),intent(in) :: mask (nMax) ! ocn domain mask 0 <=> out of domain integer(IN),intent(in) :: ocn_surface_flux_scheme real(R8) ,intent(in) :: zbot (nMax) ! atm level height (m) @@ -192,7 +192,7 @@ SUBROUTINE flux_atmOcn(nMax ,zbot ,ubot ,vbot ,thbot , & real(R8),intent(out),optional :: re_sv (nMax) ! diag: sqrt of exchange coefficient (water) real(R8),intent(out),optional :: ssq_sv (nMax) ! diag: sea surface humidity (kg/kg) - real(R8),intent(in) ,optional :: missval ! masked value + real(R8),intent(in) ,optional :: missval ! masked value !--- local constants -------------------------------- real(R8),parameter :: zref = 10.0_R8 ! reference height (m) @@ -584,7 +584,7 @@ END subroutine flux_atmOcn ! 2019-May-08 - J. Reeves Eyre - remove convective gustiness ! and add cold air outbreak modification. !=============================================================================== - SUBROUTINE flux_atmOcn_UA( & + SUBROUTINE flux_atmOcn_UA(logunit, & & nMax ,zbot ,ubot ,vbot ,thbot , & & qbot ,s16O ,sHDO ,s18O ,rbot , & & tbot , pslv ,us , vs , & @@ -593,7 +593,7 @@ SUBROUTINE flux_atmOcn_UA( & & evap ,evap_16O, evap_HDO, evap_18O, & & taux ,tauy ,tref ,qref , & & duu10n, ustar_sv ,re_sv ,ssq_sv, & - & missval ) + & missval) ! !USES: @@ -604,8 +604,9 @@ SUBROUTINE flux_atmOcn_UA( & ! !INPUT/OUTPUT PARAMETERS: !--- input arguments -------------------------------- - integer(IN),intent(in) :: nMax ! data vector length - integer(IN),intent(in) :: mask (nMax) ! ocn domain mask 0 <=> out of domain + integer ,intent(in) :: logunit + integer ,intent(in) :: nMax ! data vector length + integer ,intent(in) :: mask (nMax) ! ocn domain mask 0 <=> out of domain real(R8) ,intent(in) :: zbot (nMax) ! atm level height (m) real(R8) ,intent(in) :: ubot (nMax) ! atm u wind (m/s) real(R8) ,intent(in) :: vbot (nMax) ! atm v wind (m/s) @@ -1128,7 +1129,7 @@ end function cuberoot ! 2006-Nov-07 - B. Kauffman - code migrated from cpl6 to share !=============================================================================== SUBROUTINE flux_atmOcn_diurnal & - (nMax ,zbot ,ubot ,vbot ,thbot , & + (logunit, nMax ,zbot ,ubot ,vbot ,thbot , & qbot ,s16O ,sHDO ,s18O ,rbot , & tbot ,us ,vs , & ts ,mask , seq_flux_atmocn_minwind, & @@ -1155,7 +1156,8 @@ SUBROUTINE flux_atmOcn_diurnal & ! !INPUT/OUTPUT PARAMETERS: !--- input arguments -------------------------------- - integer(IN),intent(in) :: nMax ! data vector length + integer ,intent(in) :: logunit + integer(IN),intent(in) :: nMax ! data vector length integer(IN),intent(in) :: mask (nMax) ! ocn domain mask 0 <=> out of domain real(R8) ,intent(in) :: zbot (nMax) ! atm level height (m) real(R8) ,intent(in) :: ubot (nMax) ! atm u wind (m/s) @@ -1891,15 +1893,15 @@ END subroutine flux_atmOcn_diurnal ! !REVISION HISTORY: ! 2007-Sep-19 - B. Kauffman, Bill Large - first version !=============================================================================== - subroutine flux_MOstability(option,arg1,arg2,arg3,arg4,arg5) + subroutine flux_MOstability(logunit,option,arg1,arg2,arg3,arg4,arg5) ! !USES: implicit none ! !INPUT/OUTPUT PARAMETERS: - - integer(IN),intent(in) :: option ! shr_flux_MOwScales or MOfunctions + integer ,intent(in) :: logunit + integer ,intent(in) :: option ! shr_flux_MOwScales or MOfunctions real(R8) ,intent(in) :: arg1 ! scales: uStar (in) funct: zeta (in) real(R8) ,intent(inout) :: arg2 ! scales: zkB (in) funct: phim (out) real(R8) ,intent(out) :: arg3 ! scales: phim (out) funct: phis (out) @@ -2294,4 +2296,4 @@ real (R8) function psit_30(zet) endif end FUNCTION psit_30 -end module flux_atmocn_mod +end module shr_flux_mod diff --git a/mediator/med_phases_aofluxes_mod.F90 b/mediator/med_phases_aofluxes_mod.F90 index 3c0345269..d8aa7acdd 100644 --- a/mediator/med_phases_aofluxes_mod.F90 +++ b/mediator/med_phases_aofluxes_mod.F90 @@ -312,8 +312,11 @@ subroutine med_aofluxes_init(gcomp, aoflux_in, aoflux_out, rc) use ESMF , only : ESMF_Field, ESMF_FieldGet, ESMF_FieldBundle use esmFlds , only : coupling_mode use med_methods_mod , only : FB_fldchk => med_methods_FB_FldChk +#ifdef CESMCOUPLED + use shr_flux_mod , only : shr_flux_adjust_constants +#else use flux_atmocn_mod , only : flux_adjust_constants - +#endif !----------------------------------------------------------------------- ! Initialize pointers to the module variables !----------------------------------------------------------------------- @@ -421,10 +424,18 @@ subroutine med_aofluxes_init(gcomp, aoflux_in, aoflux_out, rc) else flux_convergence = 0.0_r8 end if + +#ifdef CESMCOUPLED + call shr_flux_adjust_constants(& + flux_convergence_tolerance=flux_convergence, & + flux_convergence_max_iteration=flux_max_iteration, & + coldair_outbreak_mod=coldair_outbreak_mod) +#else call flux_adjust_constants(& flux_convergence_tolerance=flux_convergence, & flux_convergence_max_iteration=flux_max_iteration, & coldair_outbreak_mod=coldair_outbreak_mod) +#endif if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) @@ -858,7 +869,11 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc) use ESMF , only : ESMF_GridComp use ESMF , only : ESMF_LogWrite, ESMF_LogMsg_Info, ESMF_SUCCESS use med_map_mod , only : med_map_field_packed, med_map_rh_is_created +#ifdef CESMCOUPLED + use shr_flux_mod , only : flux_atmocn +#else use flux_atmocn_mod, only : flux_atmocn +#endif ! Arguments type(ESMF_GridComp) :: gcomp @@ -1002,7 +1017,8 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc) !---------------------------------- #ifdef CESMCOUPLED - call flux_atmocn (& + + call flux_atmocn (logunit=logunit, & nMax=aoflux_in%lsize, & zbot=aoflux_in%zbot, ubot=aoflux_in%ubot, vbot=aoflux_in%vbot, thbot=aoflux_in%thbot, qbot=aoflux_in%shum, & s16O=aoflux_in%shum_16O, sHDO=aoflux_in%shum_HDO, s18O=aoflux_in%shum_18O, rbot=aoflux_in%dens, & @@ -1014,17 +1030,19 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc) taux=aoflux_out%taux, tauy=aoflux_out%tauy, tref=aoflux_out%tref, qref=aoflux_out%qref, & ocn_surface_flux_scheme=ocn_surface_flux_scheme, & duu10n=aoflux_out%duu10n, ustar_sv=aoflux_out%ustar, re_sv=aoflux_out%re, ssq_sv=aoflux_out%ssq, & - missval = 0.0_r8) + missval=0.0_r8) #else - call flux_atmocn (& + + call flux_atmocn (logunit=logunit, & nMax=aoflux_in%lsize, mask=aoflux_in%mask, & zbot=aoflux_in%zbot, ubot=aoflux_in%ubot, vbot=aoflux_in%vbot, thbot=aoflux_in%thbot, qbot=aoflux_in%shum, & rbot=aoflux_in%dens, tbot=aoflux_in%tbot, us=aoflux_in%uocn, vs=aoflux_in%vocn, ts=aoflux_in%tocn, & ocn_surface_flux_scheme=ocn_surface_flux_scheme, & sen=aoflux_out%sen, lat=aoflux_out%lat, lwup=aoflux_out%lwup, evap=aoflux_out%evap, & taux=aoflux_out%taux, tauy=aoflux_out%tauy, tref=aoflux_out%tref, qref=aoflux_out%qref, & - duu10n=aoflux_out%duu10n, missval = 0.0_r8) + duu10n=aoflux_out%duu10n, missval=0.0_r8) + #endif do n = 1,aoflux_in%lsize diff --git a/ufs/flux_atmocn_mod.F90 b/ufs/flux_atmocn_mod.F90 index a5f5416b8..2485c0d75 100644 --- a/ufs/flux_atmocn_mod.F90 +++ b/ufs/flux_atmocn_mod.F90 @@ -2,8 +2,7 @@ module flux_atmocn_mod use med_kind_mod ! shared kinds use ufs_const_mod ! shared constants - use med_internalstate_mod , only : logunit - use ESMF , only : ESMF_FINALIZE, ESMF_END_ABORT + use ESMF, only : ESMF_FINALIZE, ESMF_END_ABORT implicit none @@ -18,11 +17,8 @@ module flux_atmocn_mod integer,parameter :: R8 = SHR_KIND_R8 ! 8 byte real integer,parameter :: IN = SHR_KIND_IN ! native/default integer - ! The follow variables are not declared as parameters so that they can be - ! adjusted to support aquaplanet and potentially other simple model modes. - ! The shr_flux_adjust_constants subroutine is called to set the desired - ! values. The default values are from shr_const_mod. Currently they are - ! only used by the flux_atmocn routine. + ! The follow variables are not declared as parameters so that they can be adjusted. + ! The default values are from ufs_const_mod. real(R8) :: loc_zvir = shr_const_zvir real(R8) :: loc_cpdair = shr_const_cpdair real(R8) :: loc_cpvir = shr_const_cpvir @@ -51,43 +47,23 @@ module flux_atmocn_mod contains !=============================================================================== - subroutine flux_adjust_constants( & - zvir, cpair, cpvir, karman, gravit, & - latvap, latice, stebol, flux_convergence_tolerance, & - flux_convergence_max_iteration, & - coldair_outbreak_mod) + subroutine flux_adjust_constants( flux_convergence_tolerance, & + flux_convergence_max_iteration, coldair_outbreak_mod) ! Adjust local constants. Used to support simple models. - - real(R8), optional, intent(in) :: zvir - real(R8), optional, intent(in) :: cpair - real(R8), optional, intent(in) :: cpvir - real(R8), optional, intent(in) :: karman - real(R8), optional, intent(in) :: gravit - real(R8), optional, intent(in) :: latvap - real(R8), optional, intent(in) :: latice - real(R8), optional, intent(in) :: stebol - real(r8), optional, intent(in) :: flux_convergence_tolerance - integer(in), optional, intent(in) :: flux_convergence_max_iteration - logical, optional, intent(in) :: coldair_outbreak_mod + real(r8) , optional, intent(in) :: flux_convergence_tolerance + integer(in) , optional, intent(in) :: flux_convergence_max_iteration + logical , optional, intent(in) :: coldair_outbreak_mod !---------------------------------------------------------------------------- - if (present(zvir)) loc_zvir = zvir - if (present(cpair)) loc_cpdair = cpair - if (present(cpvir)) loc_cpvir = cpvir - if (present(karman)) loc_karman = karman - if (present(gravit)) loc_g = gravit - if (present(latvap)) loc_latvap = latvap - if (present(latice)) loc_latice = latice - if (present(stebol)) loc_stebol = stebol if (present(flux_convergence_tolerance)) flux_con_tol = flux_convergence_tolerance if (present(flux_convergence_max_iteration)) flux_con_max_iter = flux_convergence_max_iteration - if(present(coldair_outbreak_mod)) use_coldair_outbreak_mod = coldair_outbreak_mod + if (present(coldair_outbreak_mod)) use_coldair_outbreak_mod = coldair_outbreak_mod end subroutine flux_adjust_constants !=============================================================================== - subroutine flux_atmOcn(nMax,zbot ,ubot ,vbot ,thbot , & + subroutine flux_atmOcn(logunit, nMax,zbot ,ubot ,vbot ,thbot , & & qbot , rbot ,tbot ,us ,vs , & & ts , mask ,sen ,lat ,lwup , & & evap , taux ,tauy ,tref ,qref , & @@ -96,6 +72,7 @@ subroutine flux_atmOcn(nMax,zbot ,ubot ,vbot ,thbot , & implicit none !--- input arguments -------------------------------- + integer ,intent(in) :: logunit integer(IN),intent(in) :: nMax ! data vector length integer(IN),intent(in) :: mask (nMax) ! ocn domain mask 0 <=> out of domain real(R8) ,intent(in) :: zbot (nMax) ! atm level height (m)