diff --git a/.github/workflows/extbuild.yml b/.github/workflows/extbuild.yml index 0614d5ac..e1c69cd7 100644 --- a/.github/workflows/extbuild.yml +++ b/.github/workflows/extbuild.yml @@ -20,13 +20,13 @@ jobs: CPPFLAGS: "-I/usr/include -I/usr/local/include" # Versions of all dependencies can be updated here - ESMF_VERSION: v8.6.0 + ESMF_VERSION: v8.6.1 PNETCDF_VERSION: checkpoint.1.12.3 NETCDF_FORTRAN_VERSION: v4.6.1 PIO_VERSION: pio2_6_2 - CDEPS_VERSION: cdeps1.0.26 + CDEPS_VERSION: cdeps1.0.36 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Build the ESMF library, if the cache contains a previous build # it will be used instead - id: load-env @@ -40,13 +40,13 @@ jobs: sudo apt-get install pnetcdf-bin libpnetcdf-dev sudo apt-get install autotools-dev autoconf - id: cache-esmf - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/ESMF key: ${{ runner.os }}-${{ env.ESMF_VERSION }}-ESMF - name: Cache ParallelIO id: cache-ParallelIO - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/pio key: ${{ runner.os }}-${{ env.PIO_VERSION }}.pio @@ -71,17 +71,21 @@ jobs: parallelio_path: $HOME/pio - name: Cache CDEPS id: cache-cdeps - uses: actions/cache@v3 + uses: actions/cache@v4 with: - path: $HOME/cdeps - key: ${{ runner.os }}-${{ env.CDEPS_VERSION }}.cdeps + path: /homme/runner/work/CMEPS/CMEPS/build-cdeps + key: ${{ runner.os }}-${{ env.CDEPS_VERSION }}.cdeps1 - name: checkout CDEPS - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: ESCOMP/CDEPS path: cdeps-src ref: ${{ env.CDEPS_VERSION }} + - name: get genf90 + run: | + cd cdeps-src + git submodule update --init - name: Build CDEPS if: steps.cache-cdeps.outputs.cache-hit != 'true' uses: ESCOMP/CDEPS/.github/actions/buildcdeps@cdeps1.0.26 @@ -89,13 +93,13 @@ jobs: esmfmkfile: $HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk pio_path: $HOME/pio src_root: ${GITHUB_WORKSPACE}/cdeps-src - cmake_flags: " -Wno-dev -DCMAKE_BUILD_TYPE=DEBUG -DWERROR=ON -DCMAKE_Fortran_FLAGS=\"-DCPRGNU -g -Wall \ + cmake_flags: " -Wno-dev -DDISABLE_FoX=ON -DCMAKE_BUILD_TYPE=DEBUG -DWERROR=ON -DCMAKE_Fortran_FLAGS=\"-DCPRGNU -g -Wall \ -ffree-form -ffree-line-length-none -fallow-argument-mismatch \"" - name: Build CMEPS run: | - export ESMFMKFILE=$HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk export PIO=$HOME/pio + export ESMFMKFILE=$HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk mkdir build-cmeps pushd build-cmeps cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_Fortran_FLAGS="-g -Wall -Werror -ffree-form -ffree-line-length-none -Wno-unused-dummy-argument -I /home/runner/work/CMEPS/CMEPS/build-cdeps/share" ../ diff --git a/.github/workflows/srt.yml b/.github/workflows/srt.yml index 1044661b..efec7ba8 100644 --- a/.github/workflows/srt.yml +++ b/.github/workflows/srt.yml @@ -26,7 +26,7 @@ jobs: CPPFLAGS: "-I/usr/include -I/usr/local/include " LDFLAGS: "-L/usr/lib/x86_64-linux-gnu -lnetcdf -lnetcdff -lpnetcdf" # Versions of all dependencies can be updated here - ESMF_VERSION: v8.6.0 + ESMF_VERSION: v8.6.1 PARALLELIO_VERSION: pio2_6_2 CIME_MODEL: cesm CIME_DRIVER: nuopc @@ -64,13 +64,13 @@ jobs: run: pip install -r requirements.txt # use the latest cesm main - name: cesm checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: ESCOMP/CESM path: cesm # this cmeps commit - name: cmeps checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: cesm/components/cmeps @@ -79,7 +79,7 @@ jobs: - name: checkout externals run: | pushd cesm - ./manage_externals/checkout_externals ccs_config cdeps share mct cpl7 parallelio + ./bin/git-fleximod update ccs_config cdeps share mct parallelio cd ccs_config git checkout main cd ../ @@ -94,72 +94,55 @@ jobs: git submodule update --init cd ../components/cdeps git checkout main + git submodule update --init + cd ../../share + git checkout main - name: Cache ESMF id: cache-esmf - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/ESMF - key: ${{ runner.os }}-${{ env.ESMF_VERSION }}-ESMF1 - # - name: cache pnetcdf - # id: cache-pnetcdf - # uses: actions/cache@v3 - # with: - # path: ~/pnetcdf - # key: ${{ runner.os }}-${{ env.PNETCDF_VERSION}}-pnetcdf - - # - name: Cache netcdf-fortran - # id: cache-netcdf-fortran - # uses: actions/cache@v3 - # with: - # path: ~/netcdf-fortran - # key: ${{ runner.os }}-${{ env.NETCDF_FORTRAN_VERSION }}-netcdf-fortran + key: ${{ runner.os }}-${{ env.ESMF_VERSION }} - name: Cache ParallelIO id: cache-ParallelIO - uses: actions/cache@v3 + uses: actions/cache@v4 with: - path: ~/pio + path: ${GITHUB_WORKSPACE}/pio key: ${{ runner.os }}-${{ env.PARALLELIO_VERSION }}.parallelio + - name: Cache inputdata id: cache-inputdata - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: $HOME/cesm/inputdata key: inputdata - # - name: Build PNetCDF - # if: steps.cache-pnetcdf.outputs.cache-hit != 'true' - # uses: ESCOMP/CDEPS/.github/actions/buildpnetcdf@e06246b560d3132170bb1a5443fa3d65dfbd2040 - # with: - # pnetcdf_version: ${{ env.PNETCDF_VERSION }} - # install_prefix: $HOME/pnetcdf - # - name: Build NetCDF Fortran - # if: steps.cache-netcdf-fortran.outputs.cache-hit != 'true' - # uses: ESCOMP/CDEPS/.github/actions/buildnetcdff@e06246b560d3132170bb1a5443fa3d65dfbd2040 - # with: - # netcdf_fortran_version: ${{ env.NETCDF_FORTRAN_VERSION }} - # install_prefix: $HOME/netcdf-fortran - # netcdf_c_path: /usr + - name: Build ParallelIO if: steps.cache-PARALLELIO.outputs.cache-hit != 'true' uses: NCAR/ParallelIO/.github/actions/parallelio_cmake@05173a6556ea8d80eb34e3881a5014ea8f4b7543 with: parallelio_version: ${{ env.ParallelIO_VERSION }} enable_fortran: True - install_prefix: /home/runner/pio + install_prefix: ${GITHUB_WORKSPACE}/pio - - name: Build ESMF - if: steps.cache-esmf.outputs.cache-hit != 'true' - uses: ESCOMP/CDEPS/.github/actions/buildesmf@e06246b560d3132170bb1a5443fa3d65dfbd2040 + - name: Install ESMF + uses: esmf-org/install-esmf-action@v1 + env: + ESMF_COMPILER: gfortran + ESMF_BOPT: g + ESMF_COMM: openmpi + ESMF_NETCDF: nc-config + ESMF_PNETCDF: pnetcdf-config + ESMF_INSTALL_PREFIX: ${GITHUB_WORKSPACE}/ESMF + ESMF_PIO: external + ESMF_PIO_INCLUDE: ${GITHUB_WORKSPACE}/pio/include + ESMF_PIO_LIBPATH: ${GITHUB_WORKSPACE}/pio/lib with: - esmf_version: ${{ env.ESMF_VERSION }} - esmf_bopt: g - esmf_comm: openmpi - install_prefix: ~/ESMF - netcdf_c_path: /usr - netcdf_fortran_path: /usr - pnetcdf_path: /usr - parallelio_path: ~/pio + version: ${{ env.ESMF_VERSION }} + esmpy: false + cache: true - name: PREP for scripts regression test @@ -169,14 +152,13 @@ jobs: pushd $GITHUB_WORKSPACE/cesm/cime/CIME/tests export SRCROOT=$GITHUB_WORKSPACE/cesm/ export CIME_TEST_PLATFORM=ubuntu-latest - export PIO_INCDIR=$HOME/pio/include - export PIO_LIBDIR=$HOME/pio/lib + export PIO_INCDIR=$GITHUB_WORKSPACE/pio/include + export PIO_LIBDIR=$GITHUB_WORKSPACE/pio/lib export PIO_VERSION_MAJOR=2 export PIO_TYPENAME_VALID_VALUES="netcdf,pnetcdf" export NETCDF_PATH=/usr export PNETCDF_PATH=/usr export LD_LIBRARY_PATH=/usr/lib/libx86_64-linux-gnu/:$LD_LIBRARY_PATH - export ESMFMKFILE=$HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk cat <> $GITHUB_WORKSPACE/cesm/ccs_config/machines/cmake_macros/ubuntu-latest.cmake set(NetCDF_Fortran_INCLUDE_DIR /usr/include) set(NetCDF_Fortran_LIBRARY /usr/lib/x86_64-gnu-Linux/libnetcdff.so) diff --git a/cesm/driver/esm.F90 b/cesm/driver/esm.F90 index a8342f54..e2ed6489 100644 --- a/cesm/driver/esm.F90 +++ b/cesm/driver/esm.F90 @@ -796,7 +796,6 @@ subroutine esm_init_pelayout(driver, maxthreads, rc) #ifndef NO_MPI2 use mpi , only : MPI_COMM_NULL, mpi_comm_size #endif - use m_MCTWorld , only : mct_world_init => init #ifdef MED_PRESENT use med_internalstate_mod , only : med_id @@ -1164,9 +1163,6 @@ subroutine esm_init_pelayout(driver, maxthreads, rc) enddo - call mct_world_init(componentCount+1, GLOBAL_COMM, comms, comps) - - deallocate(petlist, comms, comps, comp_iamin, comp_comm_iam) end subroutine esm_init_pelayout diff --git a/cesm/flux_atmocn/shr_flux_mod.F90 b/cesm/flux_atmocn/shr_flux_mod.F90 index 58f7ae92..d86805a5 100644 --- a/cesm/flux_atmocn/shr_flux_mod.F90 +++ b/cesm/flux_atmocn/shr_flux_mod.F90 @@ -143,7 +143,8 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , & & ocn_surface_flux_scheme, & & add_gusts, & & duu10n, & - & ugust_out, & + & ugust_out, & + & u10res, & & ustar_sv ,re_sv ,ssq_sv, & & missval) @@ -194,6 +195,7 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , & real(R8),intent(out) :: qref (nMax) ! diag: 2m ref humidity (kg/kg) real(R8),intent(out) :: duu10n(nMax) ! diag: 10m wind speed squared (m/s)^2 real(R8),intent(out) :: ugust_out(nMax) ! diag: gustiness addition to U10 (m/s) + real(R8),intent(out) :: u10res(nMax) ! diag: gustiness addition to U10 (m/s) real(R8),intent(out),optional :: ustar_sv(nMax) ! diag: ustar real(R8),intent(out),optional :: re_sv (nMax) ! diag: sqrt of exchange coefficient (water) @@ -243,6 +245,7 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , & real(R8) :: cp ! specific heat of moist air real(R8) :: fac ! vertical interpolation factor real(R8) :: spval ! local missing value + real(R8) :: wind0 ! resolved large-scale 10m wind (no gust added) !!++ COARE only real(R8) :: zo,zot,zoq ! roughness lengths real(R8) :: hsb,hlb ! sens & lat heat flxs at zbot @@ -343,12 +346,13 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , & !--- compute some needed quantities --- if (add_gusts) then - vmag = max(seq_flux_atmocn_minwind, sqrt( (ubot(n)-us(n))**2 + (vbot(n)-vs(n))**2) + ugust(min(rainc(n),6.94444e-4_r8)) ) + vmag = max(seq_flux_atmocn_minwind, sqrt( (ubot(n)-us(n))**2 + (vbot(n)-vs(n))**2 + (1.0_R8*ugust(min(rainc(n),6.94444e-4_r8))**2)) ) ugust_out(n) = ugust(min(rainc(n),6.94444e-4_r8)) else vmag = max(seq_flux_atmocn_minwind, sqrt( (ubot(n)-us(n))**2 + (vbot(n)-vs(n))**2) ) ugust_out(n) = 0.0_r8 end if + wind0 = max(seq_flux_atmocn_minwind, sqrt( (ubot(n)-us(n))**2 + (vbot(n)-vs(n))**2) ) if (use_coldair_outbreak_mod) then ! Cold Air Outbreak Modification: @@ -356,10 +360,14 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , & ! based on Mahrt & Sun 1995,MWR if (tdiff(n).lt.td0) then + ! if add_gusts wind0 and vmag are different, both need this factor. vscl=min((1._R8+alpha*(abs(tdiff(n)-td0)**0.5_R8/abs(vmag))),maxscl) vmag=vmag*vscl + vscl=min((1._R8+alpha*(abs(tdiff(n)-td0)**0.5_R8/abs(wind0))),maxscl) + wind0=wind0*vscl endif endif + ssq = 0.98_R8 * qsat(ts(n)) / rbot(n) ! sea surf hum (kg/kg) delt = thbot(n) - ts(n) ! pot temp diff (K) delq = qbot(n) - ssq ! spec hum dif (kg/kg) @@ -460,6 +468,7 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , & qref(n) = qbot(n) - delq*fac duu10n(n) = u10n*u10n ! 10m wind speed squared + u10res(n) = u10n * (wind0/vmag) ! resolved 10m wind !------------------------------------------------------------ ! optional diagnostics, needed for water tracer fluxes (dcn) @@ -472,6 +481,7 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , & !------------------------------------------------------------ ! no valid data here -- out of domain !------------------------------------------------------------ + sen (n) = spval ! sensible heat flux (W/m^2) lat (n) = spval ! latent heat flux (W/m^2) lwup (n) = spval ! long-wave upward heat flux (W/m^2) @@ -484,7 +494,8 @@ SUBROUTINE flux_atmOcn(logunit, nMax ,zbot ,ubot ,vbot ,thbot , & tref (n) = spval ! 2m reference height temperature (K) qref (n) = spval ! 2m reference height humidity (kg/kg) duu10n(n) = spval ! 10m wind speed squared (m/s)^2 - ugust_out(n) = spval ! gustiness addition (m/s) + ugust_out(n) = spval ! gustiness addition (m/s) + u10res(n) = spval ! 10m resolved wind (no gusts) (m/s) if (present(ustar_sv)) ustar_sv(n) = spval if (present(re_sv )) re_sv (n) = spval diff --git a/cesm/nuopc_cap_share/seq_drydep_mod.F90 b/cesm/nuopc_cap_share/seq_drydep_mod.F90 index 780a6c61..3d6c292e 100644 --- a/cesm/nuopc_cap_share/seq_drydep_mod.F90 +++ b/cesm/nuopc_cap_share/seq_drydep_mod.F90 @@ -1,8 +1,6 @@ module seq_drydep_mod use shr_drydep_mod, only: seq_drydep_setHCoeff=>shr_drydep_setHCoeff - use shr_drydep_mod - implicit none ! method specification diff --git a/cesm/nuopc_cap_share/shr_dust_emis_mod.F90 b/cesm/nuopc_cap_share/shr_dust_emis_mod.F90 new file mode 100644 index 00000000..f7002483 --- /dev/null +++ b/cesm/nuopc_cap_share/shr_dust_emis_mod.F90 @@ -0,0 +1,222 @@ +module shr_dust_emis_mod + + !======================================================================== + ! Module for handling dust emissions. + ! This module is shared by land and atmosphere models for the computation of + ! dust emissions. + !======================================================================== + + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : CS => SHR_KIND_CS + use shr_nl_mod , only : shr_nl_find_group_name + use shr_log_mod , only : shr_log_getLogUnit, errMsg => shr_log_errMsg + + implicit none + private + + ! public member functions + public :: shr_dust_emis_readnl ! Read namelist + public :: is_dust_emis_zender ! If Zender_2003 dust emission method is being used + public :: is_dust_emis_leung ! If Leungr_2023 dust emission method is being used + public :: is_zender_soil_erod_from_land ! If Zender_2003 is being used and soil eroditability is in land + public :: is_zender_soil_erod_from_atm ! If Zender/_2003 is being used and soil eroditability is in atmosphere + + ! The following is only public for the sake of unit testing; it should not be called + ! directly outside this module + public :: dust_emis_set_options ! Set the namelist options directory not through the namelist + public :: is_NOT_initialized ! Check if dust emission has NOT been initialized + + ! private data members: + private :: check_options_finish_init ! Check that the options are correct and finish initialization + + ! PRIVATE DATA: + character(len=CS) :: dust_emis_method = 'Zender_2003' ! Dust emisison method to use: Zender_2003 or Leung_2023 + character(len=CS) :: zender_soil_erod_source = 'none' ! if calculated in lnd or atm (only when Zender_2003 is used) + logical :: dust_emis_initialized=.false. ! If dust emissions have been initiatlized yet or not + + character(len=*), parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +CONTAINS +!=============================================================================== + + subroutine shr_dust_emis_readnl(mpicom, NLFilename) + + !======================================================================== + ! reads dust_emis_inparm namelist to determine how dust emissions will + ! be handled between the land and atmosphere models + !======================================================================== + use shr_mpi_mod, only : shr_mpi_bcast, shr_mpi_commrank + + character(len=*), intent(in) :: NLFilename ! Namelist filename + integer , intent(in) :: mpicom ! MPI communicator for broadcasting all all tasks + + !----- local ----- + integer :: unitn ! namelist unit number + integer :: ierr ! error code + logical :: exists ! if file exists or not + integer :: localPet ! Local processor rank + integer :: s_logunit ! Output log unit + character(*),parameter :: F00 = "('(shr_dust_emis_read) ',8a)" + character(*),parameter :: subName = '(shr_dust_emis_read) ' + !----------------------------------------------------------------------------- + + namelist /dust_emis_inparm/ dust_emis_method, zender_soil_erod_source + + !----------------------------------------------------------------------------- + ! Read namelist, check if namelist file exists first + !----------------------------------------------------------------------------- + + !--- Open and read namelist --- + if ( len_trim(NLFilename) == 0 )then + call shr_sys_abort( subName//'ERROR: nlfilename not set' ) + end if + + call shr_mpi_commrank( mpicom, localPet ) + + call shr_log_getLogUnit(s_logunit) + if (localPet==0) then + inquire( file=trim(NLFileName), exist=exists) + if ( exists ) then + open(newunit=unitn, file=trim(NLFilename), status='old' ) + write(s_logunit,F00) 'Read in dust_emis_inparm namelist from: ', trim(NLFilename) + call shr_nl_find_group_name(unitn, 'dust_emis_inparm', ierr) + if (ierr == 0) then + ! Note that ierr /= 0, no namelist is present. + read(unitn, dust_emis_inparm, iostat=ierr) + if (ierr > 0) then + call shr_sys_abort( subName//'ERROR:: problem on read of dust_emis_inparm ' & + // 'namelist in shr_dust_emis_readnl') + end if + endif + close( unitn ) + end if + end if + call shr_mpi_bcast(dust_emis_method, mpicom) + call shr_mpi_bcast(zender_soil_erod_source, mpicom) + + call check_options_finish_init() + + end subroutine shr_dust_emis_readnl + +!==================================================================================== + + subroutine check_options_finish_init() + ! Some error checking and mark initialization as finished + integer :: s_logunit ! Output log unit + character(*),parameter :: subName = '(check_options_finish_init) ' + + call shr_log_getLogUnit(s_logunit) + if (trim(dust_emis_method) == 'Leung_2023') then + if ( trim(zender_soil_erod_source) /= 'none' )then + write(s_logunit,*) 'ERROR: '//errMsg(u_FILE_u, __LINE__) + call shr_sys_abort(subName//"ERROR: zender_soil_erod_source should NOT be set, when dust_emis_method=Leung_2023" ) + return + end if + else if (trim(dust_emis_method) == 'Zender_2003') then + if ( (trim(zender_soil_erod_source) /= 'lnd') .and. (trim(zender_soil_erod_source) /= 'atm') )then + write(s_logunit,*) 'zender_soil_erod_source is NOT valid = ', trim(zender_soil_erod_source) + write(s_logunit,*) 'ERROR: '//errMsg(u_FILE_u, __LINE__) + call shr_sys_abort(subName//"ERROR: zender_soil_erod_source can only be lnd or atm" ) + return + end if + else + write(s_logunit,*) 'dust_emis_method not recognized = ', trim(dust_emis_method) + write(s_logunit,*) 'ERROR: '//errMsg(u_FILE_u, __LINE__) + call shr_sys_abort(subName//"ERROR: dust_emis_method namelist item is not valid" ) + return + end if + + dust_emis_initialized = .true. + + end subroutine check_options_finish_init + +!==================================================================================== + + logical function is_dust_emis_zender() + ! is_dust_emis_zender – Logical function, true if the Zender 2003 scheme is being used + if ( is_NOT_initialized() ) return + if (trim(dust_emis_method) == 'Zender_2003') then + is_dust_emis_zender = .true. + else + is_dust_emis_zender = .false. + end if + end function is_dust_emis_zender + +!=============================================================================== + + logical function is_dust_emis_leung() + ! is_dust_emis_leung – Logical function, true if the Leung 2023 scheme is being used + if ( is_NOT_initialized() ) return + if (trim(dust_emis_method) == 'Leung_2023') then + is_dust_emis_leung = .true. + else + is_dust_emis_leung = .false. + end if + end function is_dust_emis_leung + +!=============================================================================== + + logical function is_zender_soil_erod_from_land() + ! is_zender_soil_erod_from_land – Logical function, true if the Zender method is being used and soil erodibility is in CTSM + if ( is_NOT_initialized() ) return + if ( is_dust_emis_zender() )then + if (trim(zender_soil_erod_source) == 'lnd') then + is_zender_soil_erod_from_land = .true. + else + is_zender_soil_erod_from_land = .false. + end if + else + is_zender_soil_erod_from_land = .false. + end if + end function is_zender_soil_erod_from_land + +!=============================================================================== + + logical function is_zender_soil_erod_from_atm() + !is_zender_soil_erod_from_atm – Logical function, true if the Zender method is being used and soil erodibility is in CAM + if ( is_NOT_initialized() ) return + if ( is_dust_emis_zender() )then + if ( trim(zender_soil_erod_source) == 'atm') then + is_zender_soil_erod_from_atm = .true. + else + is_zender_soil_erod_from_atm = .false. + end if + else + is_zender_soil_erod_from_atm = .false. + end if + end function is_zender_soil_erod_from_atm + +!=============================================================================== + + logical function is_NOT_initialized() + ! Check if this is NOT initialized and return true if so (false if initialized) + ! Will abort with an error when using in the model + ! For unit testing will return the logical state + integer :: s_logunit ! Output log unit + + if ( dust_emis_initialized )then + is_NOT_initialized = .false. + return + else + is_NOT_initialized = .true. + call shr_log_getLogUnit(s_logunit) + write(s_logunit,*) 'ERROR: '//errMsg(u_FILE_u, __LINE__) + call shr_sys_abort( 'ERROR: dust emission namelist has NOT been read in yet,' // & + ' shr_dust_emis_mod is NOT initialized ' ) + end if + end function is_NOT_initialized + + subroutine dust_emis_set_options( dust_emis_method_in, zender_soil_erod_source_in) + character(len=*), intent(IN) :: dust_emis_method_in ! Dust emisison method to use: Zender_2003 or Leung_2023 + character(len=*), intent(IN) :: zender_soil_erod_source_in ! if calculed in lnd or atm (only when Zender_2003 is used) + + dust_emis_method = dust_emis_method_in + zender_soil_erod_source = zender_soil_erod_source_in + call check_options_finish_init() + end subroutine dust_emis_set_options + +!=============================================================================== + +end module shr_dust_emis_mod diff --git a/cime_config/buildexe b/cime_config/buildexe index 1d736671..4923f016 100755 --- a/cime_config/buildexe +++ b/cime_config/buildexe @@ -108,10 +108,12 @@ def _main_func(): # always relink if os.path.isfile(exename): os.remove(exename) - + exename = os.path.relpath(exename, bld_root) cmd = "{} exec_se -j {} EXEC_SE={} COMP_NAME=driver {} -f {} "\ .format(gmake, gmake_j, exename, gmake_args, makefile) - + pio = os.environ.get("PIO") + if pio: + os.environ["PIO_LIBDIR"] = os.path.join(pio,"lib") rc, out, err = run_cmd(cmd,from_dir=bld_root) expect(rc==0,"Command {} failed rc={}\nout={}\nerr={}".format(cmd,rc,out,err)) diff --git a/cime_config/buildnml b/cime_config/buildnml index ff2553be..bc8585d8 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -106,7 +106,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files): config["COMP_OCN"] = case.get_value("COMP_OCN") config["COMP_ROF"] = case.get_value("COMP_ROF") config["COMP_WAV"] = case.get_value("COMP_WAV") - config["CAMDEV"] = "True" if "CAM%DEV" in case.get_value("COMPSET") else "False" + config["CAMDEV"] = "True" if "CAM70" in case.get_value("COMPSET") else "False" if ( ( @@ -127,7 +127,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files): elif case.get_value("RUN_TYPE") == "branch": config["run_type"] = "branch" - config['wav_ice_coupling'] = config['COMP_WAV'] == 'ww3dev' and config['COMP_ICE'] == 'cice' + config['wav_ice_coupling'] = 'ww3' in config['COMP_WAV'] and config['COMP_ICE'] == 'cice' # ---------------------------------------------------- # Initialize namelist defaults @@ -146,10 +146,10 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files): if config["COMP_OCN"] == "docn" and "aqua" in case.get_value("DOCN_MODE"): nmlgen.set_value("aqua_planet", value=".true.") - # make sure that variable add_gusts is only set to true if compset includes cam_dev + # make sure that variable add_gusts is only set to true if compset includes cam7 physics add_gusts = literal_to_python_value(nmlgen.get_value("add_gusts"), type_="logical") if add_gusts: - expect("CAM%DEV" in case.get_value("COMPSET"),"ERROR: add_gusts can only be set if CAM%DEV in compset {}".format(case.get_value("COMPSET"))) + expect("CAM70" in case.get_value("COMPSET"),"ERROR: add_gusts can only be set if CAM70 in compset {}".format(case.get_value("COMPSET"))) # -------------------------------- # Overwrite: set component coupling frequencies diff --git a/cime_config/config_component.xml b/cime_config/config_component.xml index 938e0e31..33add8b2 100644 --- a/cime_config/config_component.xml +++ b/cime_config/config_component.xml @@ -1389,14 +1389,6 @@ rof2lnd flux mapping file - - char - idmap - run_domain - env_run.xml - rof2ocn flux mapping file - - char idmap @@ -1413,54 +1405,6 @@ rof2ocn runoff mapping file - - char - idmap - run_domain - env_run.xml - glc2ice runoff mapping file - - - - char - idmap - run_domain - env_run.xml - glc2ocn runoff mapping file for liquid runoff - - - - char - idmap - run_domain - env_run.xml - glc2ocn runoff mapping file for ice runoff - - - - char - idmap - run_domain - env_run.xml - ocn2wav state mapping file - - - - char - idmap - run_domain - env_run.xml - ice2wav state mapping file - - - - char - idmap - run_domain - env_run.xml - wav2ocn state mapping file - - char 1.0e-02 diff --git a/cime_config/config_component_cesm.xml b/cime_config/config_component_cesm.xml index dbf3b11e..a1981482 100644 --- a/cime_config/config_component_cesm.xml +++ b/cime_config/config_component_cesm.xml @@ -299,6 +299,7 @@ 1 1 + 1 $ATM_NCPL $ATM_NCPL 1 @@ -537,6 +538,7 @@ FALSE TRUE + TRUE TRUE diff --git a/cime_config/namelist_definition_drv.xml b/cime_config/namelist_definition_drv.xml index 3e4d6bf6..0f8622af 100644 --- a/cime_config/namelist_definition_drv.xml +++ b/cime_config/namelist_definition_drv.xml @@ -620,19 +620,6 @@ - - char - flds - ALLCOMP_attributes - - if the ocean component sends fields at multiple ocean levels to the - land-ice component, these are the colon deliminted level indices - - - 1:10:19:26:30:33:35 - - - char control @@ -885,6 +872,17 @@ off + + logical + control + MED_attributes + + If true, remove negative runoff by downweighting all positive runoff globally. + + + .true. + + integer @@ -2086,6 +2084,80 @@ + + + + + + logical + aux_hist + ALLCOMP_attributes + + .false. + + Auxiliary mediator wav2med average history output every day. + Note that ww3dev will use this configuration variable and send + the fields needed for wav2med auxiliary file + + + char + aux_hist + MED_attributes + + Sw_hs_avg:Sw_Tm1_avg:Sw_thm_avg:Sw_u_avg:Sw_v_avg:Sw_ustokes_avg:Sw_vstokes_avg:Sw_tusx_avg:Sw_tusy_avg:Sw_thp0_avg:Sw_fp0_avg:Sw_phs0_avg:Sw_phs1_avg:Sw_pdir0_avg:Sw_pdir1_avg:Sw_pTm10_avg:Sw_pTm11_avg + + Auxiliary mediator wav2med file1 colon delimited output + fields. NOTE: these are assumed to be time averaged over a day in + the WW3 cap - so the settings of histaux_wav2med_file1_history_n + and histaux_wav2med_file1_history_option should be 1 and ndays, + respectively. + + + char + aux_hist + MED_attributes + + ndays + + Auxiliary mediator wav2med file1 output option + + + integer + aux_hist + MED_attributes + + 1 + + Auxiliary mediator wav2med file1 output frequency (used for option type) + + + logical + aux_hist + MED_attributes + + .false. + + Auxiliary mediator wav2med file1 time averaged flag for file output. + If this flag is set to .false. only instantaneous output will be created in the auxiliary file. + + + char + aux_hist + MED_attributes + + wav.24h.avg + + + + integer + aux_hist + MED_attributes + Number of time samples per file. + + 30 + + + @@ -2195,54 +2267,6 @@ - - char - mapping - abs - MED_attributes - - glc2ocn runoff mapping file for liquid runoff - - - $GLC2OCN_LIQ_RMAPNAME - - - - char - mapping - abs - MED_attributes - - glc to ice runoff conservative mapping file - - - $GLC2ICE_RMAPNAME - - - - char - mapping - abs - MED_attributes - - glc2ocn runoff mapping file for ice runoff - - - $GLC2OCN_ICE_RMAPNAME - - - - char - mapping - abs - MED_attributes - - runoff to ocn area overlap conservative mapping file - - - $ROF2OCN_FMAPNAME - - char mapping @@ -2267,42 +2291,6 @@ $ROF2OCN_ICE_RMAPNAME - - char - mapping - abs - MED_attributes - - ocn to wav state mapping file for states - - - $OCN2WAV_SMAPNAME - - - - char - mapping - abs - MED_attributes - - ice to wav state mapping file for states - - - $ICE2WAV_SMAPNAME - - - - char - mapping - abs - MED_attributes - - wav to ocn state mapping file for states - - - $WAV2OCN_SMAPNAME - - @@ -2635,24 +2623,6 @@ - - - - - - - - - - - - - - - - - - char time @@ -2874,137 +2844,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cime_config/namelist_definition_drv_flds.xml b/cime_config/namelist_definition_drv_flds.xml index 03b6b7c6..4d4ab1ec 100644 --- a/cime_config/namelist_definition_drv_flds.xml +++ b/cime_config/namelist_definition_drv_flds.xml @@ -141,6 +141,33 @@ + + + + + + char*80 + dust_emissions + dust_emis_inparm + Zender_2003,Leung_2023 + + Which dust emission method is going to be used. Either the Zender 2003 scheme or the Leung 2023 + scheme. + + + + + char*80 + dust_emissions + dust_emis_inparm + none,lnd,atm + + Option only applying for the Zender_2003 method for whether the soil erodibility file is handled + in the active LAND model or in the ATM model. + (only used when dust_emis_method is Zender_2003) + + + diff --git a/cime_config/runseq/driver_config.py b/cime_config/runseq/driver_config.py index 9694c750..7b8756e1 100644 --- a/cime_config/runseq/driver_config.py +++ b/cime_config/runseq/driver_config.py @@ -58,7 +58,7 @@ def __compute_glc(self, case, coupling_times): med_to_glc = False elif (comp_glc == 'cism'): if not case.get_value("CISM_EVOLVE"): - med_to_glc = False + run_glc = False # If CISM is not evolving only get data back from cism at the initial time # However will still need to call the exchange at the end if the stop_option @@ -77,6 +77,12 @@ def __compute_glc(self, case, coupling_times): glc_coupling_time = stop_n * 86400 else: glc_coupling_time = 86400 + elif (comp_glc == 'dglc'): + glc_coupling_time = coupling_times["glc_cpl_dt"] + stop_option = case.get_value('STOP_OPTION') + stop_n = case.get_value('STOP_N') + if stop_option == 'nsteps': + glc_coupling_time = stop_n*coupling_times["atm_cpl_dt"] elif (comp_glc == 'xglc'): glc_coupling_time = coupling_times["glc_cpl_dt"] else: diff --git a/cime_config/runseq/runseq_TG.py b/cime_config/runseq/runseq_TG.py index dea8aede..acf56a87 100644 --- a/cime_config/runseq/runseq_TG.py +++ b/cime_config/runseq/runseq_TG.py @@ -34,8 +34,10 @@ def gen_runseq(case, coupling_times): runseq.add_action ("MED med_phases_post_lnd" , run_lnd) runseq.add_action ("MED med_phases_prep_glc" , med_to_glc) runseq.add_action ("MED -> GLC :remapMethod=redist" , med_to_glc) - runseq.add_action ("GLC" , run_glc and med_to_glc) - runseq.add_action ("GLC -> MED :remapMethod=redist" , run_glc) + runseq.add_action ("GLC" , run_glc) + # Need to do GLC -> MED even if not running GLC; otherwise, we get a + # failure in InitializeRealize ("Object being used before creation") + runseq.add_action ("GLC -> MED :remapMethod=redist" , med_to_glc) runseq.add_action ("MED med_phases_history_write" , True) runseq.leave_time_loop(True) diff --git a/cime_config/runseq/runseq_general.py b/cime_config/runseq/runseq_general.py index ddbfca59..04a0d6f4 100644 --- a/cime_config/runseq/runseq_general.py +++ b/cime_config/runseq/runseq_general.py @@ -20,7 +20,7 @@ def gen_runseq(case, coupling_times): cpl_seq_option = case.get_value('CPL_SEQ_OPTION') coupling_mode = case.get_value('COUPLING_MODE') diag_mode = case.get_value('BUDGETS') - xcompset = case.get_value("COMP_ATM") == 'xatm' + xcompset = case.get_value("COMP_ATM") == 'xatm' cpl_add_aoflux = not xcompset and case.get_value('ADD_AOFLUX_TO_RUNSEQ') # It is assumed that if a component will be run it will send information to the mediator @@ -35,19 +35,6 @@ def gen_runseq(case, coupling_times): run_rof, med_to_rof, rof_cpl_time = driver_config['rof'] run_wav, med_to_wav, wav_cpl_time = driver_config['wav'] - comp_glc = case.get_value("COMP_GLC") - run_glc = False - post_glc = False - if (comp_glc == 'cism'): - run_glc = True - if case.get_value("CISM_EVOLVE"): - post_glc = True - else: - post_glc = False - elif (comp_glc == 'xglc'): - run_glc = True - post_glc = True - # Note: assume that atm_cpl_dt, lnd_cpl_dt, ice_cpl_dt and wav_cpl_dt are the same if lnd_cpl_time != atm_cpl_time: @@ -59,18 +46,32 @@ def gen_runseq(case, coupling_times): if rof_cpl_time < ocn_cpl_time: expect(False, "assume that rof_cpl_time is always greater than or equal to ocn_cpl_time") + if run_glc: + # It wouldn't make sense to run GLC unless we also do MED -> GLC to transfer fields to GLC, + # and some of the below logic controlling what appears in the run sequence depends on this + # (i.e., depends on the fact that, if run_glc is True, then med_to_glc is also True). + expect(med_to_glc, "if run_glc is True, then med_to_glc must also be True") + rof_outer_loop = run_rof and rof_cpl_time > atm_cpl_time ocn_outer_loop = run_ocn and ocn_cpl_time > atm_cpl_time + # Note that we do some aspects of the GLC outer loop even if run_glc is False + # (as long as med_to_glc is True). + # + # Note that, in contrast to the other outer_loop variables, this doesn't check glc_cpl_time. + # This is for consistency with the logic that was in place before adding this variable; + # this seems to implicitly assume that glc_cpl_time > atm_cpl_time. + glc_outer_loop = med_to_glc + inner_loop = ((atm_cpl_time < ocn_cpl_time) or (atm_cpl_time < rof_cpl_time) or - (run_glc and atm_cpl_time < glc_cpl_time) or + (glc_outer_loop and atm_cpl_time < glc_cpl_time) or atm_cpl_time == ocn_cpl_time) with RunSeq(os.path.join(caseroot, "CaseDocs", "nuopc.runseq")) as runseq: #------------------ - runseq.enter_time_loop(glc_cpl_time, newtime=run_glc, active=med_to_glc) + runseq.enter_time_loop(glc_cpl_time, newtime=glc_outer_loop) #------------------ #------------------ @@ -199,8 +200,10 @@ def gen_runseq(case, coupling_times): runseq.add_action("MED med_phases_prep_glc" , med_to_glc) runseq.add_action("MED -> GLC :remapMethod=redist" , med_to_glc) - runseq.add_action("GLC" , run_glc and med_to_glc) - runseq.add_action("GLC -> MED :remapMethod=redist" , run_glc) - runseq.add_action("MED med_phases_post_glc" , run_glc and post_glc) + runseq.add_action("GLC" , run_glc) + # Need to do GLC -> MED even if not running GLC; otherwise, we get a + # failure in InitializeRealize ("Object being used before creation") + runseq.add_action("GLC -> MED :remapMethod=redist" , med_to_glc) + runseq.add_action("MED med_phases_post_glc" , run_glc) shutil.copy(os.path.join(caseroot, "CaseDocs", "nuopc.runseq"), rundir) diff --git a/mediator/esmFldsExchange_cesm_mod.F90 b/mediator/esmFldsExchange_cesm_mod.F90 index c7cee8d9..7055fdf7 100644 --- a/mediator/esmFldsExchange_cesm_mod.F90 +++ b/mediator/esmFldsExchange_cesm_mod.F90 @@ -5,10 +5,49 @@ module esmFldsExchange_cesm_mod ! fields exchanged between components and their associated routing, ! mapping and merging ! - ! Merging arguments: - ! mrg_fromN = source component index that for the field to be merged - ! mrg_fldN = souce field name to be merged - ! mrg_typeN = merge type ('copy', 'copy_with_weights', 'sum', 'sum_with_weights', 'merge') + ! ----------------------------------------------------------------------------------------- + ! subroutine med_fldList_addmrg_to(index, fldname, mrg_from, mrg_fld, mrg_type, mrg_fracname, rc) + ! integer , intent(in) :: index + ! character(len=*), intent(in) :: fldname + ! integer , intent(in) :: mrg_from + ! character(len=*), intent(in) :: mrg_fld + ! character(len=*), intent(in) :: mrg_type + ! character(len=*), intent(in) , optional :: mrg_fracname + ! integer , intent(out), optional :: rc + ! + ! index : destination component index that merging will occur to + ! fldname : field name in mediator export field bundle for destination component + ! mrg_from : source component index that will contribute to the merge + ! mrg_fld : field name fom source component field bundle that will be used in merge + ! mrg_type : one of ['copy', 'copy_with_weights', 'sum', 'sum_with_weights', 'merge'] + ! mrg_fracname : if mrg_type is copy_with_weights or merge - + ! fraction name in fraction field bundle to use in merge + ! + ! ----------------------------------------------------------------------------------------- + ! subroutine med_fldList_addmap_from(index, fldname, destcomp, maptype, mapnorm, mapfile) + ! integer , intent(in) :: index + ! character(len=*) , intent(in) :: fldname + ! integer , intent(in) :: destcomp + ! integer , intent(in) :: maptype + ! character(len=*) , intent(in) :: mapnorm + ! character(len=*) , intent(in), optional :: mapfile + ! + ! index : source component index that mapping will occur from + ! fldname : field name in mediator import field for source component + ! destcomp : destination component index + ! maptype : mapping type (see med_internal_state_mod.F90 for the supported mapping types) + ! if maptype is mapfcopy - create a redistribution route handle + ! mapnorm : normalization type, one of ['unset', 'one', 'none', fracname] + ! fracname - is the field name of the field in the fraction field bundle corresponding to the + ! source field that will be used for normalization + ! 'one' - implies that the mapped field is divided by mapping 'one' from the source to the + ! destination mesh + ! 'none' - do not use any normalization - use if maytype is not mapfcopy + ! 'unset' - do not use any normalization - only used if maptype is mapfcopy + ! mapfile : if mapfile is idmap - create a redistribution route nhandle + ! if mapfile is unset then create the mapping route handle at run time + ! + ! ----------------------------------------------------------------------------------------- ! NOTE: ! mrg_from(compmed) can either be for mediator computed fields for atm/ocn fluxes or for ocn albedos ! @@ -20,7 +59,10 @@ module esmFldsExchange_cesm_mod !-------------------------------------- use med_kind_mod , only : CX=>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8 - use med_internalstate_mod , only : logunit, maintask + use med_internalstate_mod , only : logunit, maintask, samegrid_atmlnd + use med_internalstate_mod , only : mrg_fracname_lnd2atm_state, mrg_fracname_lnd2atm_flux, map_fracname_lnd2atm + use med_internalstate_mod , only : mrg_fracname_lnd2rof, map_fracname_lnd2rof + use med_internalstate_mod , only : mrg_fracname_lnd2glc, map_fracname_lnd2glc implicit none public @@ -28,26 +70,23 @@ module esmFldsExchange_cesm_mod public :: esmFldsExchange_cesm ! currently required mapping files - character(len=CX) :: glc2ice_rmap ='unset' - character(len=CX) :: glc2ocn_liq_rmap ='unset' - character(len=CX) :: glc2ocn_ice_rmap ='unset' - character(len=CX) :: rof2ocn_fmap ='unset' character(len=CX) :: rof2ocn_ice_rmap ='unset' character(len=CX) :: rof2ocn_liq_rmap ='unset' - character(len=CX) :: wav2ocn_smap ='unset' - character(len=CX) :: ice2wav_smap ='unset' - character(len=CX) :: ocn2wav_smap ='unset' + character(len=CX) :: rof2lnd_map = 'unset' + character(len=CX) :: lnd2rof_map = 'unset' ! no mapping files (value is 'idmap' or 'unset') - character(len=CX) :: atm2ice_map='unset' - character(len=CX) :: atm2ocn_map='unset' - character(len=CX) :: atm2lnd_map='unset' - character(len=CX) :: ice2atm_map='unset' - character(len=CX) :: ocn2atm_map='unset' - character(len=CX) :: lnd2atm_map='unset' - character(len=CX) :: lnd2rof_map='unset' - character(len=CX) :: rof2lnd_map='unset' - character(len=CX) :: atm2wav_map='unset' + character(len=CX) :: atm2ice_map = 'unset' + character(len=CX) :: atm2ocn_map = 'unset' + character(len=CX) :: atm2lnd_map = 'unset' + character(len=CX) :: atm2wav_map = 'unset' + character(len=CX) :: ice2atm_map = 'unset' + character(len=CX) :: ice2wav_map = 'unset' + character(len=CX) :: lnd2atm_map = 'unset' + character(len=CX) :: ocn2atm_map = 'unset' + character(len=CX) :: ocn2wav_map = 'unset' + character(len=CX) :: rof2ocn_map = 'unset' + character(len=CX) :: wav2ocn_map = 'unset' logical :: mapuv_with_cart3d ! Map U/V vector wind fields from ATM to OCN/ICE by rotating in Cartesian 3D space and then back logical :: flds_i2o_per_cat ! Ice thickness category fields passed to OCN @@ -76,12 +115,11 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) use med_internalstate_mod , only : compice, comprof, compwav, compglc, ncomps use med_internalstate_mod , only : mapbilnr, mapconsf, mapconsd, mappatch, mappatch_uv3d, mapbilnr_nstod use med_internalstate_mod , only : mapfcopy, mapnstod, mapnstod_consd, mapnstod_consf - use med_internalstate_mod , only : map_glc2ocn_ice, map_glc2ocn_liq, map_rof2ocn_ice, map_rof2ocn_liq + use med_internalstate_mod , only : map_rof2ocn_ice, map_rof2ocn_liq use esmFlds , only : addfld_ocnalb => med_fldList_addfld_ocnalb use esmFlds , only : addfld_aoflux => med_fldList_addfld_aoflux use esmFlds , only : addmap_aoflux => med_fldList_addmap_aoflux use esmFlds , only : addmap_ocnalb => med_fldList_addmap_ocnalb - use esmFlds , only : addfld_to => med_fldList_addfld_to use esmFlds , only : addfld_from => med_fldList_addfld_from use esmFlds , only : addmap_from => med_fldList_addmap_from @@ -95,7 +133,12 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) ! local variables: type(InternalState) :: is_local integer :: n, ns + character(len=CL) :: atm_mesh_name + character(len=CL) :: lnd_mesh_name + character(len=CL) :: ice_mesh_name + character(len=CL) :: ocn_mesh_name character(len=CL) :: cvalue + character(len=CS) :: mrgfld_source logical :: wav_coupling_to_cice logical :: ocn2glc_coupling character(len=*) , parameter :: subname=' (esmFldsExchange_cesm) ' @@ -121,51 +164,37 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) if (phase == 'advertise') then - ! mapping to atm - call NUOPC_CompAttributeGet(gcomp, name='ice2atm_map', value=ice2atm_map, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'ice2atm_map = '// trim(ice2atm_map) - call NUOPC_CompAttributeGet(gcomp, name='lnd2atm_map', value=lnd2atm_map, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'lnd2atm_map = '// trim(lnd2atm_map) - call NUOPC_CompAttributeGet(gcomp, name='ocn2atm_map', value=ocn2atm_map, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'ocn2atm_map = '// trim(ocn2atm_map) - - ! mapping to lnd - call NUOPC_CompAttributeGet(gcomp, name='atm2lnd_map', value=atm2lnd_map, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'atm2lnd_map = '// trim(atm2lnd_map) + ! determine if atm and lnd have the same mesh + call NUOPC_CompAttributeGet(gcomp, name='mesh_atm', value=atm_mesh_name, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name='mesh_lnd', value=lnd_mesh_name, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name='mesh_ice', value=ice_mesh_name, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name='mesh_ocn', value=ocn_mesh_name, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (trim(atm_mesh_name) == trim(lnd_mesh_name)) then + atm2lnd_map = 'idmap' + lnd2atm_map = 'idmap' + end if + if (trim(atm_mesh_name) == trim(ocn_mesh_name)) then + atm2ocn_map = 'idmap' + ocn2atm_map = 'idmap' + end if + if (trim(atm_mesh_name) == trim(ice_mesh_name)) then + atm2ice_map = 'idmap' + ice2atm_map = 'idmap' + end if + + ! mapping rof=>lnd and lnd=>rof - the following two maps are needed for MIZUROUTE call NUOPC_CompAttributeGet(gcomp, name='rof2lnd_map', value=rof2lnd_map, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (maintask) write(logunit, '(a)') trim(subname)//'rof2lnd_map = '// trim(rof2lnd_map) - - ! mapping to ice - call NUOPC_CompAttributeGet(gcomp, name='atm2ice_map', value=atm2ice_map, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'atm2ice_map = '// trim(atm2ice_map) - call NUOPC_CompAttributeGet(gcomp, name='glc2ice_rmapname', value=glc2ice_rmap, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'glc2ice_rmapname = '// trim(glc2ice_rmap) - - ! mapping to ocn - call NUOPC_CompAttributeGet(gcomp, name='atm2ocn_map', value=atm2ocn_map, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'atm2ocn_map = '// trim(atm2ocn_map) - call NUOPC_CompAttributeGet(gcomp, name='glc2ocn_liq_rmapname', value=glc2ocn_liq_rmap, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'glc2ocn_liq_rmapname = '// trim(glc2ocn_liq_rmap) - call NUOPC_CompAttributeGet(gcomp, name='glc2ocn_ice_rmapname', value=glc2ocn_ice_rmap, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'glc2ocn_ice_rmapname = '// trim(glc2ocn_ice_rmap) - call NUOPC_CompAttributeGet(gcomp, name='wav2ocn_smapname', value=wav2ocn_smap, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'wav2ocn_smapname = '// trim(wav2ocn_smap) - - call NUOPC_CompAttributeGet(gcomp, name='rof2ocn_fmapname', value=rof2ocn_fmap, rc=rc) + call NUOPC_CompAttributeGet(gcomp, name='lnd2rof_map', value=lnd2rof_map, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'rof2ocn_fmapname = '// trim(rof2ocn_fmap) + if (maintask) write(logunit, '(a)') trim(subname)//'lnd2rof_map = '// trim(lnd2rof_map) + ! mapping to rof => ocn with custom mapping call NUOPC_CompAttributeGet(gcomp, name='rof2ocn_liq_rmapname', value=rof2ocn_liq_rmap, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (maintask) write(logunit, '(a)') trim(subname)//'rof2ocn_liq_rmapname = '// trim(rof2ocn_liq_rmap) @@ -173,23 +202,6 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (maintask) write(logunit, '(a)') trim(subname)//'rof2ocn_ice_rmapname = '// trim(rof2ocn_ice_rmap) - ! mapping to rof - call NUOPC_CompAttributeGet(gcomp, name='lnd2rof_map', value=lnd2rof_map, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit, '(a)') trim(subname)//'lnd2rof_map = '// trim(lnd2rof_map) - - ! mapping to wav - call NUOPC_CompAttributeGet(gcomp, name='atm2wav_map', value=atm2wav_map, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit,'(a)') trim(subname)//'atm2wav_map = '// trim(atm2wav_map) - - call NUOPC_CompAttributeGet(gcomp, name='ice2wav_smapname', value=ice2wav_smap, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit,'(a)') trim(subname)//'ice2wav_smapname = '// trim(ice2wav_smap) - call NUOPC_CompAttributeGet(gcomp, name='ocn2wav_smapname', value=ocn2wav_smap, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (maintask) write(logunit,'(a)') trim(subname)//'ocn2wav_smapname = '// trim(ocn2wav_smap) - ! uv cart3d mapping call NUOPC_CompAttributeGet(gcomp, name='mapuv_with_cart3d', value=cvalue, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -215,13 +227,19 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) call NUOPC_CompAttributeGet(gcomp, name='flds_wiso', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return read(cvalue,*) flds_wiso - ! are water isotope exchanges enabled? + call NUOPC_CompAttributeGet(gcomp, name='flds_r2l_stream_channel_depths', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return read(cvalue,*) flds_r2l_stream_channel_depths ! write diagnostic output if (maintask) then + write(logunit,'(a)' ) ' flds_co2a: prognostic and diagnostic CO2 at lowest atm level is sent to lnd and ocn' + write(logunit,'(a)' ) ' flds_co2b: prognostic and diagnostic CO2 at lowest atm level is sent to lnd and ocn' + write(logunit,'(a)' ) ' and surface flux of CO2 from lnd is sent back to atm' + write(logunit,'(a)' ) ' flds_co2c: prognostic and diagnostic CO2 at lowest atm level is sent to lnd and ocn' + write(logunit,'(a)' ) ' and surface flux of CO2 from lnd is sent back to atm' + write(logunit,'(a)' ) ' and surface flux of CO2 from ocn is sent back to atm' write(logunit,'(a,l7)') trim(subname)//' flds_co2a = ',flds_co2a write(logunit,'(a,l7)') trim(subname)//' flds_co2b = ',flds_co2b write(logunit,'(a,l7)') trim(subname)//' flds_co2c = ',flds_co2c @@ -465,6 +483,32 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) end if end if ! --------------------------------------------------------------------- + ! to lnd: prognostic CO2 at the lowest atm model level + ! --------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_from(compatm, 'Sa_co2prog') + call addfld_to(complnd, 'Sa_co2prog') + else + if ( fldchk(is_local%wrap%FBexp(complnd) , 'Sa_co2prog', rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compatm,compatm ), 'Sa_co2prog', rc=rc)) then + call addmap_from(compatm, 'Sa_co2prog', complnd, mapbilnr, 'one', atm2lnd_map) + call addmrg_to(complnd, 'Sa_co2prog', mrg_from=compatm, mrg_fld='Sa_co2prog', mrg_type='copy') + end if + end if + ! --------------------------------------------------------------------- + ! to lnd: diagnostic CO2 at the lowest atm model level + ! --------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_from(compatm, 'Sa_co2diag') + call addfld_to(complnd, 'Sa_co2diag') + else + if ( fldchk(is_local%wrap%FBexp(complnd) , 'Sa_co2diag', rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compatm,compatm ), 'Sa_co2diag', rc=rc)) then + call addmap_from(compatm, 'Sa_co2diag', complnd, mapbilnr, 'one', atm2lnd_map) + call addmrg_to(complnd, 'Sa_co2diag', mrg_from=compatm, mrg_fld='Sa_co2diag', mrg_type='copy') + end if + end if + ! --------------------------------------------------------------------- ! to lnd: convective and large scale precipitation rate water equivalent from atm ! --------------------------------------------------------------------- if (phase == 'advertise') then @@ -805,9 +849,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) ! Note that for aqua-plant there will be no import from complnd or compice - and the ! current logic below takes care of this. if (fldchk(is_local%wrap%FBImp(complnd,complnd), 'Sl_avsdr', rc=rc)) then - call addmap_from(complnd, 'Sl_avsdr', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd, 'Sl_avsdr', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Sx_avsdr', & - mrg_from=complnd, mrg_fld='Sl_avsdr', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_avsdr', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Si_avsdr', rc=rc)) then call addmap_from(compice, 'Si_avsdr', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -832,9 +876,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) ! Note that for aqua-plant there will be no import from complnd or compice - and the ! current logic below takes care of this. if (fldchk(is_local%wrap%FBImp(complnd,complnd), 'Sl_avsdf', rc=rc)) then - call addmap_from(complnd, 'Sl_avsdf', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd, 'Sl_avsdf', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Sx_avsdf', & - mrg_from=complnd, mrg_fld='Sl_avsdf', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_avsdf', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Si_avsdf', rc=rc)) then call addmap_from(compice, 'Si_avsdf', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -859,9 +903,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) ! Note that for aqua-plant there will be no import from complnd or compice - and the ! current logic below takes care of this. if (fldchk(is_local%wrap%FBImp(complnd,complnd), 'Sl_anidr', rc=rc)) then - call addmap_from(complnd, 'Sl_anidr', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd, 'Sl_anidr', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Sx_anidr', & - mrg_from=complnd, mrg_fld='Sl_anidr', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_anidr', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Si_anidr', rc=rc)) then call addmap_from(compice, 'Si_anidr', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -886,9 +930,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) ! Note that for aqua-plant there will be no import from complnd or compice - and the ! current logic below takes care of this. if (fldchk(is_local%wrap%FBImp(complnd,complnd), 'Sl_anidf', rc=rc)) then - call addmap_from(complnd, 'Sl_anidf', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd, 'Sl_anidf', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Sx_anidf', & - mrg_from=complnd, mrg_fld='Sl_anidf', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_anidf', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Si_anidf', rc=rc)) then call addmap_from(compice, 'Si_anidf', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -918,9 +962,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm), 'Sx_tref', rc=rc)) then if (fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_tref', rc=rc)) then - call addmap_from(complnd , 'Sl_tref', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Sl_tref', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Sx_tref', & - mrg_from=complnd, mrg_fld='Sl_tref', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_tref', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_tref', rc=rc)) then call addmap_from(compice , 'Si_tref', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -945,9 +989,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm), 'Sx_u10', rc=rc)) then if (fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_u10', rc=rc)) then - call addmap_from(complnd , 'Sl_u10', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Sl_u10', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Sx_u10', & - mrg_from=complnd, mrg_fld='Sl_u10', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_u10', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_u10', rc=rc)) then call addmap_from(compice , 'Si_u10', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -972,9 +1016,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm), 'Sx_qref', rc=rc)) then if (fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_qref', rc=rc)) then - call addmap_from(complnd , 'Sl_qref', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Sl_qref', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Sx_qref', & - mrg_from=complnd, mrg_fld='Sl_qref', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_qref', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_qref', rc=rc)) then call addmap_from(compice , 'Si_qref', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1000,9 +1044,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm), 'Sx_qref_wiso', rc=rc)) then if (fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_qref_wiso', rc=rc)) then - call addmap_from(complnd , 'Sl_qref_wiso', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Sl_qref_wiso', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Sx_qref_wiso', & - mrg_from=complnd, mrg_fld='Sl_qref_wiso', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_qref_wiso', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_qref_wiso', rc=rc)) then call addmap_from(compice , 'Si_qref_wiso', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1034,9 +1078,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm), 'Sx_tref', rc=rc)) then if (fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_tref', rc=rc)) then - call addmap_from(complnd , 'Sl_tref', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Sl_tref', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Sx_tref', & - mrg_from=complnd, mrg_fld='Sl_tref', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_tref', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_tref', rc=rc)) then call addmap_from(compice , 'Si_tref', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1061,9 +1105,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm), 'Sx_u10', rc=rc)) then if (fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_u10', rc=rc)) then - call addmap_from(complnd , 'Sl_u10', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Sl_u10', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Sx_u10', & - mrg_from=complnd, mrg_fld='Sl_u10', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_u10', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_u10', rc=rc)) then call addmap_from(compice , 'Si_u10', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1088,9 +1132,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm), 'Sx_qref', rc=rc)) then if (fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_qref', rc=rc)) then - call addmap_from(complnd , 'Sl_qref', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Sl_qref', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Sx_qref', & - mrg_from=complnd, mrg_fld='Sl_qref', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_qref', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_qref', rc=rc)) then call addmap_from(compice , 'Si_qref', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1116,9 +1160,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm), 'Sx_qref_wiso', rc=rc)) then if (fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_qref_wiso', rc=rc)) then - call addmap_from(complnd , 'Sl_qref_wiso', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Sl_qref_wiso', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Sx_qref_wiso', & - mrg_from=complnd, mrg_fld='Sl_qref_wiso', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_qref_wiso', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_qref_wiso', rc=rc)) then call addmap_from(compice , 'Si_qref_wiso', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1152,9 +1196,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if (fldchk(is_local%wrap%FBexp(compatm), 'Faxx_taux', rc=rc)) then if ( fldchk(is_local%wrap%FBImp(complnd,complnd), 'Fall_taux', rc=rc)) then - call addmap_from(complnd , 'Fall_taux', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Fall_taux', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Faxx_taux', & - mrg_from=complnd, mrg_fld='Fall_taux', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Fall_taux', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_flux) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Faii_taux', rc=rc)) then call addmap_from(compice , 'Faii_taux', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1179,9 +1223,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if (fldchk(is_local%wrap%FBexp(compatm), 'Faxx_tauy', rc=rc)) then if ( fldchk(is_local%wrap%FBImp(complnd,complnd), 'Fall_tauy', rc=rc)) then - call addmap_from(complnd , 'Fall_tauy', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Fall_tauy', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Faxx_tauy', & - mrg_from=complnd, mrg_fld='Fall_tauy', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Fall_tauy', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_flux) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Faii_tauy', rc=rc)) then call addmap_from(compice , 'Faii_tauy', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1206,9 +1250,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if (fldchk(is_local%wrap%FBexp(compatm), 'Faxx_lat', rc=rc)) then if ( fldchk(is_local%wrap%FBImp(complnd,complnd), 'Fall_lat', rc=rc)) then - call addmap_from(complnd , 'Fall_lat', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Fall_lat', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Faxx_lat', & - mrg_from=complnd, mrg_fld='Fall_lat', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Fall_lat', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_flux) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Faii_lat', rc=rc)) then call addmap_from(compice , 'Faii_lat', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1233,9 +1277,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if (fldchk(is_local%wrap%FBexp(compatm), 'Faxx_sen', rc=rc)) then if ( fldchk(is_local%wrap%FBImp(complnd,complnd), 'Fall_sen', rc=rc)) then - call addmap_from(complnd , 'Fall_sen', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Fall_sen', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Faxx_sen', & - mrg_from=complnd, mrg_fld='Fall_sen', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Fall_sen', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_flux) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Faii_sen', rc=rc)) then call addmap_from(compice , 'Faii_sen', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1260,9 +1304,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if (fldchk(is_local%wrap%FBexp(compatm), 'Faxx_evap', rc=rc)) then if ( fldchk(is_local%wrap%FBImp(complnd,complnd), 'Fall_evap', rc=rc)) then - call addmap_from(complnd , 'Fall_evap', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Fall_evap', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Faxx_evap', & - mrg_from=complnd, mrg_fld='Fall_evap', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Fall_evap', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_flux) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Faii_evap', rc=rc)) then call addmap_from(compice , 'Faii_evap', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1287,9 +1331,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if (fldchk(is_local%wrap%FBexp(compatm), 'Faxx_lwup', rc=rc)) then if ( fldchk(is_local%wrap%FBImp(complnd,complnd), 'Fall_lwup', rc=rc)) then - call addmap_from(complnd , 'Fall_lwup', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Fall_lwup', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Faxx_lwup', & - mrg_from=complnd, mrg_fld='Fall_lwup', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Fall_lwup', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_flux) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Faii_lwup', rc=rc)) then call addmap_from(compice , 'Faii_lwup', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1315,9 +1359,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if (fldchk(is_local%wrap%FBexp(compatm), 'Faxx_evap_wiso', rc=rc)) then if ( fldchk(is_local%wrap%FBImp(complnd,complnd), 'Fall_evap_wiso', rc=rc)) then - call addmap_from(complnd , 'Fall_evap_wiso', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd , 'Fall_evap_wiso', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm , 'Faxx_evap_wiso', & - mrg_from=complnd, mrg_fld='Fall_evap_wiso', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Fall_evap_wiso', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_flux) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Faii_evap_wiso', rc=rc)) then call addmap_from(compice , 'Faii_evap_wiso', compatm, mapconsf, 'ifrac', ice2atm_map) @@ -1347,9 +1391,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if (fldchk(is_local%wrap%FBexp(compatm), 'Sx_t', rc=rc)) then if (fldchk(is_local%wrap%FBImp(complnd,complnd), 'Sl_t', rc=rc)) then - call addmap_from(complnd, 'Sl_t', compatm, mapconsf , 'lfrin', lnd2atm_map) + call addmap_from(complnd, 'Sl_t', compatm, mapconsf , map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Sx_t', & - mrg_from=complnd, mrg_fld='Sl_t', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Sl_t', mrg_type='merge', mrg_fracname=mrg_fracname_lnd2atm_state) end if if (fldchk(is_local%wrap%FBImp(compice,compice), 'Si_t', rc=rc)) then call addmap_from(compice, 'Si_t', compatm, mapconsf , 'ifrac', ice2atm_map) @@ -1368,7 +1412,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) end if ! --------------------------------------------------------------------- - ! to atm: unmerged ugust_out from ocn + ! to atm: unmerged ugust_out from ocn ! --------------------------------------------------------------------- if (phase == 'advertise') then call addfld_aoflux('So_ugustOut') @@ -1385,6 +1429,39 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) end if end if + ! --------------------------------------------------------------------- + ! to atm: 10 m winds including/excluding gust component + ! --------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_aoflux('So_u10withGust') + call addfld_to(compatm, 'So_u10withGust') + else + if ( fldchk(is_local%wrap%FBexp(compatm), 'So_u10withGust', rc=rc)) then + if (fldchk(is_local%wrap%FBMed_aoflux_o, 'So_u10withGust', rc=rc)) then + if (trim(is_local%wrap%aoflux_grid) == 'ogrid') then + call addmap_aoflux('So_u10withGust', compatm, mapconsf, 'ofrac', ocn2atm_map) + end if + call addmrg_to(compatm , 'So_u10withGust', & + mrg_from=compmed, mrg_fld='So_u10withGust', mrg_type='merge', mrg_fracname='ofrac') + end if + end if + end if + + if (phase == 'advertise') then + call addfld_aoflux('So_u10res') + call addfld_to(compatm, 'So_u10res') + else + if ( fldchk(is_local%wrap%FBexp(compatm), 'So_u10res', rc=rc)) then + if (fldchk(is_local%wrap%FBMed_aoflux_o, 'So_u10res', rc=rc)) then + if (trim(is_local%wrap%aoflux_grid) == 'ogrid') then + call addmap_aoflux('So_u10res', compatm, mapconsf, 'ofrac', ocn2atm_map) + end if + call addmrg_to(compatm , 'So_u10res', & + mrg_from=compmed, mrg_fld='So_u10res', mrg_type='merge', mrg_fracname='ofrac') + end if + end if + end if + ! --------------------------------------------------------------------- ! to atm: surface snow depth from ice (needed for cam) ! to atm: mean ice volume per unit area from ice @@ -1474,7 +1551,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm) , 'Sl_fv', rc=rc) .and. & fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_fv', rc=rc)) then - call addmap_from(complnd, 'Sl_fv', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd, 'Sl_fv', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Sl_fv', mrg_from=complnd, mrg_fld='Sl_fv', mrg_type='copy') end if end if @@ -1484,7 +1561,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm) , 'Sl_ram1', rc=rc) .and. & fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_ram1', rc=rc)) then - call addmap_from(complnd, 'Sl_ram1', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd, 'Sl_ram1', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Sl_ram1', mrg_from=complnd, mrg_fld='Sl_ram1', mrg_type='copy') end if end if @@ -1494,12 +1571,13 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm) , 'Sl_snowh', rc=rc) .and. & fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_snowh', rc=rc)) then - call addmap_from(complnd, 'Sl_snowh', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd, 'Sl_snowh', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Sl_snowh', mrg_from=complnd, mrg_fld='Sl_snowh', mrg_type='copy') end if end if + ! --------------------------------------------------------------------- - ! CARMA fields (volumetric soil water) + ! to atm: CARMA fields (volumetric soil water) from land !----------------------------------------------------------------------------- if (phase == 'advertise') then call addfld_from(complnd, 'Sl_soilw') @@ -1507,10 +1585,11 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBexp(compatm) , 'Sl_soilw', rc=rc) .and. & fldchk(is_local%wrap%FBImp(complnd,complnd ), 'Sl_soilw', rc=rc)) then - call addmap_from(complnd, 'Sl_soilw', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd, 'Sl_soilw', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Sl_soilw', mrg_from=complnd, mrg_fld='Sl_soilw', mrg_type='copy') end if end if + ! --------------------------------------------------------------------- ! to atm: dust fluxes from land (4 sizes) ! --------------------------------------------------------------------- @@ -1520,11 +1599,12 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(complnd, complnd), 'Fall_flxdst', rc=rc) .and. & fldchk(is_local%wrap%FBExp(compatm) , 'Fall_flxdst', rc=rc)) then - call addmap_from(complnd, 'Fall_flxdst', compatm, mapconsf, 'lfrin', lnd2atm_map) + call addmap_from(complnd, 'Fall_flxdst', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Fall_flxdst', & - mrg_from=complnd, mrg_fld='Fall_flxdst', mrg_type='copy_with_weights', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Fall_flxdst', mrg_type='copy_with_weights', mrg_fracname=mrg_fracname_lnd2atm_flux) end if end if + !----------------------------------------------------------------------------- ! to atm: MEGAN emissions fluxes from land !----------------------------------------------------------------------------- @@ -1534,11 +1614,12 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(complnd, complnd), 'Fall_voc', rc=rc) .and. & fldchk(is_local%wrap%FBExp(compatm) , 'Fall_voc', rc=rc)) then - call addmap_from(complnd, 'Fall_voc', compatm, mapconsf, 'one', atm2lnd_map) + call addmap_from(complnd, 'Fall_voc', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Fall_voc', & - mrg_from=complnd, mrg_fld='Fall_voc', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Fall_voc', mrg_type='copy_with_weights', mrg_fracname=mrg_fracname_lnd2atm_flux) end if end if + !----------------------------------------------------------------------------- ! to atm: fire emissions fluxes from land !----------------------------------------------------------------------------- @@ -1549,9 +1630,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(complnd, complnd), 'Fall_fire', rc=rc) .and. & fldchk(is_local%wrap%FBExp(compatm) , 'Fall_fire', rc=rc)) then - call addmap_from(complnd, 'Fall_fire', compatm, mapconsf, 'one', lnd2atm_map) + call addmap_from(complnd, 'Fall_fire', compatm, mapconsf, 'lfrin', lnd2atm_map) call addmrg_to(compatm, 'Fall_fire', & - mrg_from=complnd, mrg_fld='Fall_fire', mrg_type='merge', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Fall_fire', mrg_type='copy_with_weights', mrg_fracname=mrg_fracname_lnd2atm_flux) end if end if ! 'wild fire plume height' @@ -1561,10 +1642,12 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(complnd, complnd), 'Sl_fztop', rc=rc) .and. & fldchk(is_local%wrap%FBExp(compatm) , 'Sl_fztop', rc=rc)) then - call addmap_from(complnd, 'Sl_fztop', compatm, mapconsf, 'one', lnd2atm_map) - call addmrg_to(compatm, 'Sl_fztop', mrg_from=complnd, mrg_fld='Sl_fztop', mrg_type='copy') + call addmap_from(complnd, 'Sl_fztop', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) + call addmrg_to(compatm, 'Sl_fztop', & + mrg_from=complnd, mrg_fld='Sl_fztop', mrg_type='copy') end if end if + !----------------------------------------------------------------------------- ! to atm: dry deposition velocities from land !----------------------------------------------------------------------------- @@ -1574,11 +1657,96 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(complnd, complnd), 'Sl_ddvel', rc=rc) .and. & fldchk(is_local%wrap%FBExp(compatm) , 'Sl_ddvel', rc=rc)) then - call addmap_from(complnd, 'Sl_ddvel', compatm, mapconsf, 'one', lnd2atm_map) + call addmap_from(complnd, 'Sl_ddvel', compatm, mapconsf, map_fracname_lnd2atm, lnd2atm_map) call addmrg_to(compatm, 'Sl_ddvel', mrg_from=complnd, mrg_fld='Sl_ddvel', mrg_type='copy') end if end if + ! --------------------------------------------------------------------- + ! to atm: surface flux of CO2 from land + ! --------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_from(complnd, 'Fall_fco2_lnd') + call addfld_to(compatm, 'Fall_fco2_lnd') + else + if ( fldchk(is_local%wrap%FBImp(compocn,compocn), 'Faoo_co2_lnd', rc=rc) .and. & + fldchk(is_local%wrap%FBexp(compatm) , 'Faoo_co2_lnd', rc=rc)) then + call addmap_from(complnd, 'Fall_fco2_lnd', compatm, mapconsf, 'one', lnd2atm_map) + call addmrg_to(compatm, 'Fall_fco2_lnd', & + mrg_from=complnd, mrg_fld='Fall_fco2_lnd', mrg_type='copy_with_weights', mrg_fracname=mrg_fracname_lnd2atm_flux) + end if + end if + + ! --------------------------------------------------------------------- + ! to atm: surface flux of CO2 from ocn + ! --------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_from(compocn, 'Faoo_fco2_ocn') + call addfld_to(compatm, 'Faoo_fco2_ocn') + else + if ( fldchk(is_local%wrap%FBImp(compocn,compocn), 'Faoo_fco2_ocn', rc=rc) .and. & + fldchk(is_local%wrap%FBexp(compatm) , 'Faoo_fco2_ocn', rc=rc)) then + call addmap_from(compocn, 'Faoo_fco2_ocn', compatm, mapconsd, 'one', ocn2atm_map) + ! custom merge in med_phases_prep_atm + end if + end if + + !----------------------------------------------------------------------------- + ! to atm: surface flux of dms from ocean + !----------------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_from(compocn, 'Faoo_fdms_ocn') + call addfld_to(compatm, 'Faoo_fdms_ocn') + else + if ( fldchk(is_local%wrap%FBImp(compocn,compocn), 'Faoo_fdms_ocn', rc=rc) .and. & + fldchk(is_local%wrap%FBexp(compatm) , 'Faoo_fdms_ocn', rc=rc)) then + call addmap_from(compocn, 'Faoo_fdms_ocn', compocn, mapconsd, 'one', ocn2atm_map) + ! custom merge in med_phases_prep_atm + end if + end if + + !----------------------------------------------------------------------------- + ! to atm: surface flux of bromoform from ocean + !----------------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_from(compocn, 'Faoo_fbrf_ocn') + call addfld_to(compatm, 'Faoo_fbrf_ocn') + else + if ( fldchk(is_local%wrap%FBImp(compocn,compocn), 'Faoo_fbrf_ocn', rc=rc) .and. & + fldchk(is_local%wrap%FBexp(compatm) , 'Faoo_fbrf_ocn', rc=rc)) then + call addmap_from(compocn, 'Faoo_fbrf_ocn', compocn, mapconsd, 'one', ocn2atm_map) + ! custom merge in med_phases_prep_atm + end if + end if + + !----------------------------------------------------------------------------- + ! to atm: surface flux of n2o from ocean + !----------------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_from(compocn, 'Faoo_fn2o_ocn') + call addfld_to(compatm, 'Faoo_fn2o_ocn') + else + if ( fldchk(is_local%wrap%FBImp(compocn,compocn), 'Faoo_fn2o_ocn', rc=rc) .and. & + fldchk(is_local%wrap%FBexp(compatm) , 'Faoo_fn2o_ocn', rc=rc)) then + call addmap_from(compocn, 'Faoo_fn2o_ocn', compocn, mapconsd, 'one', ocn2atm_map) + ! custom merge in med_phases_prep_atm + end if + end if + + !----------------------------------------------------------------------------- + ! to atm: surface flux of nh3 from ocean + !----------------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_from(compocn, 'Faoo_fnh3_ocn') + call addfld_to(compatm, 'Faoo_fnh3_ocn') + else + if ( fldchk(is_local%wrap%FBImp(compocn,compocn), 'Faoo_fnh3_ocn', rc=rc) .and. & + fldchk(is_local%wrap%FBexp(compatm) , 'Faoo_fnh3_ocn', rc=rc)) then + call addmap_from(compocn, 'Faoo_fnh3_ocn', compocn, mapconsd, 'one', ocn2atm_map) + ! custom merge in med_phases_prep_atm + end if + end if + !===================================================================== ! FIELDS TO OCEAN (compocn) !===================================================================== @@ -1804,7 +1972,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) call addfld_from(compatm, 'Faxa_snowl') call addfld_to(compocn, 'Faxa_snow' ) else - ! TODO: why are we not merging Faxa_rain and Faxa_snow if they are sent from atm wiht ofrac + ! TODO: why are we not merging Faxa_rain and Faxa_snow if they are sent from atm with ofrac ! Note that the mediator atm/ocn flux calculation needs Faxa_rainc for the gustiness parameterization ! which by default is not actually used if ( fldchk(is_local%wrap%FBImp(compatm,compatm), 'Faxa_rainl', rc=rc) .and. & @@ -1936,6 +2104,32 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) end if end if + ! --------------------------------------------------------------------- + ! to ocn: prognostic CO2 at the lowest atm model level + ! --------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_from(compatm, 'Sa_co2prog') + call addfld_to(compocn, 'Sa_co2prog') + else + if ( fldchk(is_local%wrap%FBImp(compatm, compatm), 'Sa_co2prog', rc=rc) .and. & + fldchk(is_local%wrap%FBExp(compocn) , 'Sa_co2prog', rc=rc)) then + call addmap_from(compatm, 'Sa_co2prog', compocn, mapbilnr, 'one', atm2ocn_map) + call addmrg_to(compocn, 'Sa_co2prog', mrg_from=compatm, mrg_fld='Sa_co2prog', mrg_type='copy') + end if + end if + ! --------------------------------------------------------------------- + ! to ocn: diagnostic CO2 at the lowest atm model level + ! --------------------------------------------------------------------- + if (phase == 'advertise') then + call addfld_from(compatm, 'Sa_co2diag') + call addfld_to(compocn, 'Sa_co2diag') + else + if ( fldchk(is_local%wrap%FBImp(compatm, compatm), 'Sa_co2diag', rc=rc) .and. & + fldchk(is_local%wrap%FBExp(compocn) , 'Sa_co2diag', rc=rc)) then + call addmap_from(compatm, 'Sa_co2diag', compocn, mapbilnr, 'one', atm2ocn_map) + call addmrg_to(compocn, 'Sa_co2diag', mrg_from=compatm, mrg_fld='Sa_co2diag', mrg_type='copy') + end if + end if ! --------------------------------------------------------------------- ! to ocn: black carbon deposition fluxes from atm ! - hydrophylic black carbon dry deposition flux @@ -2153,134 +2347,118 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) end if !----------------------------- - ! to ocn: liquid runoff from rof and glc components - ! to ocn: frozen runoff flux from rof and glc components + ! to ocn: liquid runoff from rof originating from lnd + ! to ocn: liquid runoff from rof originating from glc + ! to ocn: ice runoff from rof originating from lnd + ! to ocn: ice runoff from rof originating from glc ! to ocn: waterflux back to ocn due to flooding from rof !----------------------------- if (phase == 'advertise') then ! Note that Flrr_flood below needs to be added to - ! fldlistFr(comprof) in order to be mapped correctly but the ocean - ! does not receive it so it is advertised but it will! not be connected - do ns = 1, is_local%wrap%num_icesheets - call addfld_from(compglc(ns), 'Fogg_rofl') - end do + ! fldlistFr(comprof) in order to be mapped correctly to the ocean but the ocean + ! does not receive it so it is advertised but it will not be connected call addfld_from(comprof, 'Forr_rofl') - call addfld_to(compocn, 'Foxx_rofl') - call addfld_to(compocn, 'Flrr_flood') - do ns = 1, is_local%wrap%num_icesheets - call addfld_from(compglc(ns), 'Fogg_rofi') - end do call addfld_from(comprof, 'Forr_rofi') + call addfld_from(comprof, 'Forr_rofl_glc') + call addfld_from(comprof, 'Forr_rofi_glc') + call addfld_to(compocn, 'Foxx_rofl') call addfld_to(compocn, 'Foxx_rofi') + call addfld_to(compocn, 'Forr_rofl_glc') + call addfld_to(compocn, 'Forr_rofi_glc') + call addfld_to(compocn, 'Flrr_flood') else - if ( fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofl' , rc=rc)) then - ! liquid from river and possibly flood from river to ocean - if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofl' , rc=rc)) then - if (trim(rof2ocn_liq_rmap) == 'unset') then - call addmap_from(comprof, 'Forr_rofl', compocn, mapconsd, 'one', 'unset') - else - call addmap_from(comprof, 'Forr_rofl', compocn, map_rof2ocn_liq, 'none', rof2ocn_liq_rmap) - end if - if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Flrr_flood', rc=rc)) then - call addmap_from(comprof, 'Flrr_flood', compocn, mapconsd, 'one', rof2ocn_fmap) - call addmrg_to(compocn, 'Foxx_rofl', mrg_from=comprof, mrg_fld='Forr_rofl:Flrr_flood', mrg_type='sum') - else - call addmrg_to(compocn, 'Foxx_rofl', mrg_from=comprof, mrg_fld='Forr_rofl', mrg_type='sum') - end if - end if - ! liquid from glc to ocean - do ns = 1, is_local%wrap%num_icesheets - if (fldchk(is_local%wrap%FBImp(compglc(ns), compglc(ns)), 'Fogg_rofl' , rc=rc)) then - ! TODO: this custom map needs to be different for every ice sheet - how will this be handled? - call addmap_from(compglc(ns), 'Fogg_rofl', compocn, map_glc2ocn_liq, 'one' , glc2ocn_liq_rmap) - call addmrg_to(compocn, 'Foxx_rofl', mrg_from=compglc(ns), mrg_fld='Fogg_rofl', mrg_type='sum') - end if - end do - end if - if ( fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofi' , rc=rc)) then - ! ice from river to ocean - if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofi' , rc=rc)) then - if (trim(rof2ocn_ice_rmap) == 'unset') then - call addmap_from(comprof, 'Forr_rofi', compocn, mapconsd, 'one', 'unset') - else - call addmap_from(comprof, 'Forr_rofi', compocn, map_rof2ocn_ice, 'none', rof2ocn_ice_rmap) - end if - call addmrg_to(compocn, 'Foxx_rofi', mrg_from=comprof, mrg_fld='Forr_rofi', mrg_type='sum') + ! Liquid runoff from land and glc - mapping + if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofl' , rc=rc)) then + if ( fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofl' , rc=rc)) then + if (trim(rof2ocn_liq_rmap) == 'unset') then + call addmap_from(comprof, 'Forr_rofl', compocn, mapconsd, 'one', 'unset') + else + call addmap_from(comprof, 'Forr_rofl', compocn, map_rof2ocn_liq, 'none', rof2ocn_liq_rmap) + end if + end if + end if + if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Flrr_flood', rc=rc)) then + if ( fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofl' , rc=rc)) then + call addmap_from(comprof, 'Flrr_flood', compocn, mapconsd, 'one', rof2ocn_map) + end if + end if + if ( fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofl_glc', rc=rc)) then + if (fldchk(is_local%wrap%FBExp(compocn), 'Forr_rofl_glc', rc=rc) .or. & + fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofl', rc=rc)) then + if (trim(rof2ocn_liq_rmap) == 'unset') then + call addmap_from(comprof, 'Forr_rofl_glc', compocn, mapconsd, 'one', 'unset') + else + call addmap_from(comprof, 'Forr_rofl_glc', compocn, map_rof2ocn_liq, 'none', rof2ocn_liq_rmap) + end if + end if + end if + + ! Liquid runoff from land and glc - merging + if ( fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofl' , rc=rc)) then + mrgfld_source = 'Forr_rofl' + if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Flrr_flood', rc=rc)) then + mrgfld_source = trim(mrgfld_source) //':Flrr_flood' + end if + if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofl_glc', rc=rc)) then + mrgfld_source = trim(mrgfld_source) //':Forr_rofl_glc' + end if + call addmrg_to(compocn, 'Foxx_rofl', mrg_from=comprof, mrg_fld=trim(mrgfld_source), mrg_type='sum') + end if + + ! Frozen runoff from land and glc - mapping + if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofi' , rc=rc)) then + if ( fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofi' , rc=rc)) then + if (trim(rof2ocn_ice_rmap) == 'unset') then + call addmap_from(comprof, 'Forr_rofi', compocn, mapconsd, 'one', 'unset') + else + call addmap_from(comprof, 'Forr_rofi', compocn, map_rof2ocn_ice, 'none', rof2ocn_ice_rmap) + end if + end if + end if + if ( fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofi_glc', rc=rc)) then + if (fldchk(is_local%wrap%FBExp(compocn), 'Forr_rofi_glc', rc=rc) .or. & + fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofi', rc=rc)) then + if (trim(rof2ocn_ice_rmap) == 'unset') then + call addmap_from(comprof, 'Forr_rofi_glc', compocn, mapconsd, 'one', 'unset') + else + call addmap_from(comprof, 'Forr_rofi_glc', compocn, map_rof2ocn_ice, 'none', rof2ocn_ice_rmap) end if - ! ice from glc to ocean - do ns = 1, is_local%wrap%num_icesheets - if (fldchk(is_local%wrap%FBImp(compglc(ns), compglc(ns)), 'Fogg_rofi' , rc=rc)) then - ! TODO: this custom map needs to be different for every ice sheet - how will this be handled? - call addmap_from(compglc(ns), 'Fogg_rofi', compocn, map_glc2ocn_ice, 'one', glc2ocn_ice_rmap) - call addmrg_to(compocn, 'Foxx_rofi', mrg_from=compglc(ns), mrg_fld='Fogg_rofi', mrg_type='sum') - end if - end do - end if + end if + end if + + ! Frozen runoff from land and glc - merging + if ( fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofi' , rc=rc)) then + mrgfld_source = 'Forr_rofi' + if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofi_glc', rc=rc)) then + mrgfld_source = trim(mrgfld_source) //':Forr_rofi_glc' + end if + call addmrg_to(compocn, 'Foxx_rofi', mrg_from=comprof, mrg_fld=trim(mrgfld_source), mrg_type='sum') + end if end if - if (flds_wiso) then - if (phase == 'advertise') then - do ns = 1, is_local%wrap%num_icesheets - call addfld_from(compglc(ns), 'Fogg_rofl_wiso') - end do - call addfld_from(comprof, 'Forr_rofl_wiso') - call addfld_to(compocn, 'Foxx_rofl_wiso') - call addfld_to(compocn, 'Flrr_flood_wiso') - do ns = 1, is_local%wrap%num_icesheets - call addfld_from(compglc(ns), 'Fogg_rofi_wiso') - end do - call addfld_from(comprof, 'Forr_rofi_wiso') - call addfld_to(compocn, 'Foxx_rofi_wiso') - else - if ( fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofl_wiso' , rc=rc)) then - ! liquid from river and possibly flood from river to ocean - if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofl_wiso' , rc=rc)) then - if (trim(rof2ocn_liq_rmap) == 'unset') then - call addmap_from(comprof, 'Forr_rofl_wiso', compocn, mapconsd, 'none', 'unset') - else - call addmap_from(comprof, 'Forr_rofl_wiso', compocn, map_rof2ocn_liq, 'none', rof2ocn_liq_rmap) - end if - if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Flrr_flood_wiso', rc=rc)) then - call addmap_from(comprof, 'Flrr_flood_wiso', compocn, mapconsd, 'one', rof2ocn_fmap) - call addmrg_to(compocn, 'Foxx_rofl_wiso', & - mrg_from=comprof, mrg_fld='Forr_rofl:Flrr_flood', mrg_type='sum') - else - call addmrg_to(compocn, 'Foxx_rofl_wiso', & - mrg_from=comprof, mrg_fld='Forr_rofl', mrg_type='sum') - end if - end if - ! liquid from glc to ocean - do ns = 1, is_local%wrap%num_icesheets - if (fldchk(is_local%wrap%FBImp(compglc(ns), compglc(ns)), 'Fogg_rofl_wiso' , rc=rc)) then - ! TODO: this custom map needs to be different for every ice sheet - how will this be handled? - call addmap_from(compglc(ns), 'Fogg_rofl_wiso', compocn, map_glc2ocn_liq, 'one' , glc2ocn_liq_rmap) - call addmrg_to(compocn, 'Foxx_rofl_wiso', & - mrg_from=compglc(ns), mrg_fld='Fogg_rofl_wiso', mrg_type='sum') - end if - end do - end if - if ( fldchk(is_local%wrap%FBExp(compocn), 'Foxx_rofi_wiso' , rc=rc)) then - ! ice from river to ocean - if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofi_wiso' , rc=rc)) then - if (trim(rof2ocn_ice_rmap) == 'unset') then - call addmap_from(comprof, 'Forr_rofi_wiso', compocn, mapconsd, 'none', 'unset') - else - call addmap_from(comprof, 'Forr_rofi_wiso', compocn, map_rof2ocn_ice, 'none', rof2ocn_ice_rmap) - end if - call addmrg_to(compocn, 'Foxx_rofi_wiso', mrg_from=comprof, mrg_fld='Forr_rofi', mrg_type='sum') - end if - ! ice from glc to ocean - do ns = 1, is_local%wrap%num_icesheets - if (fldchk(is_local%wrap%FBImp(compglc(ns), compglc(ns)), 'Fogg_rofi_wiso' , rc=rc)) then - ! TODO: this custom map needs to be different for every ice sheet - how will this be handled? - call addmap_from(compglc(ns), 'Fogg_rofi_wiso', compocn, map_glc2ocn_ice, 'one', glc2ocn_ice_rmap) - call addmrg_to(compocn, 'Foxx_rofi_wiso', & - mrg_from=compglc(ns), mrg_fld='Fogg_rofi_wiso', mrg_type='sum') - end if - end do - end if - end if + !----------------------------- + ! from wav: for daily averaged fields for + ! output to auxiliary file only + !----------------------------- + if (phase == 'advertise') then + call addfld_from(compwav, 'Sw_ustokes_avg') + call addfld_from(compwav, 'Sw_vstokes_avg') + call addfld_from(compwav, 'Sw_hs_avg') + call addfld_from(compwav, 'Sw_phs0_avg') + call addfld_from(compwav, 'Sw_phs1_avg') + call addfld_from(compwav, 'Sw_pdir0_avg') + call addfld_from(compwav, 'Sw_pdir1_avg') + call addfld_from(compwav, 'Sw_pTm10_avg') + call addfld_from(compwav, 'Sw_pTm11_avg') + call addfld_from(compwav, 'Sw_Tm1_avg') + call addfld_from(compwav, 'Sw_thm_avg') + call addfld_from(compwav, 'Sw_thp0_avg') + call addfld_from(compwav, 'Sw_fp0_avg') + call addfld_from(compwav, 'Sw_u_avg') + call addfld_from(compwav, 'Sw_v_avg') + call addfld_from(compwav, 'Sw_tusx_avg') + call addfld_from(compwav, 'Sw_tusy_avg') end if !----------------------------- @@ -2292,7 +2470,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_lamult', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_lamult', rc=rc)) then - call addmap_from(compwav, 'Sw_lamult', compocn, mapbilnr_nstod, 'one', wav2ocn_smap) + call addmap_from(compwav, 'Sw_lamult', compocn, mapbilnr_nstod, 'one', wav2ocn_map) call addmrg_to(compocn, 'Sw_lamult', mrg_from=compwav, mrg_fld='Sw_lamult', mrg_type='copy') end if end if @@ -2305,7 +2483,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_ustokes', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_ustokes', rc=rc)) then - call addmap_from(compwav, 'Sw_ustokes', compocn, mapbilnr_nstod, 'one', wav2ocn_smap) + call addmap_from(compwav, 'Sw_ustokes', compocn, mapbilnr_nstod, 'one', wav2ocn_map) call addmrg_to(compocn, 'Sw_ustokes', mrg_from=compwav, mrg_fld='Sw_ustokes', mrg_type='copy') end if end if @@ -2318,7 +2496,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_vstokes', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_vstokes', rc=rc)) then - call addmap_from(compwav, 'Sw_vstokes', compocn, mapbilnr_nstod, 'one', wav2ocn_smap) + call addmap_from(compwav, 'Sw_vstokes', compocn, mapbilnr_nstod, 'one', wav2ocn_map) call addmrg_to(compocn, 'Sw_vstokes', mrg_from=compwav, mrg_fld='Sw_vstokes', mrg_type='copy') end if end if @@ -2331,7 +2509,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_hstokes', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_hstokes', rc=rc)) then - call addmap_from(compwav, 'Sw_hstokes', compocn, mapbilnr_nstod, 'one', wav2ocn_smap) + call addmap_from(compwav, 'Sw_hstokes', compocn, mapbilnr_nstod, 'one', wav2ocn_map) call addmrg_to(compocn, 'Sw_hstokes', mrg_from=compwav, mrg_fld='Sw_hstokes', mrg_type='copy') end if end if @@ -2344,7 +2522,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_pstokes_x', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_pstokes_x', rc=rc)) then - call addmap_from(compwav, 'Sw_pstokes_x', compocn, mapbilnr_nstod, 'one', wav2ocn_smap) + call addmap_from(compwav, 'Sw_pstokes_x', compocn, mapbilnr_nstod, 'one', wav2ocn_map) call addmrg_to(compocn, 'Sw_pstokes_x', mrg_from=compwav, mrg_fld='Sw_pstokes_x', mrg_type='copy') end if end if @@ -2357,7 +2535,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_pstokes_y', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_pstokes_y', rc=rc)) then - call addmap_from(compwav, 'Sw_pstokes_y', compocn, mapbilnr_nstod, 'one', wav2ocn_smap) + call addmap_from(compwav, 'Sw_pstokes_y', compocn, mapbilnr_nstod, 'one', wav2ocn_map) call addmrg_to(compocn, 'Sw_pstokes_y', mrg_from=compwav, mrg_fld='Sw_pstokes_y', mrg_type='copy') end if end if @@ -2800,54 +2978,6 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) end if end if - ! --------------------------------------------------------------------- - ! to ice: frozen runoff from rof and glc - ! --------------------------------------------------------------------- - if (phase == 'advertise') then - call addfld_from(comprof, 'Firr_rofi') ! water flux into sea ice due to runoff (frozen) - do ns = 1, is_local%wrap%num_icesheets - call addfld_from(compglc(ns), 'Figg_rofi') ! glc frozen runoff_iceberg flux to ice - end do - call addfld_to(compice, 'Fixx_rofi') ! total frozen water flux into sea ice - else - if ( fldchk(is_local%wrap%FBExp(compice), 'Fixx_rofi', rc=rc)) then - if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofi', rc=rc)) then - call addmap_from(comprof, 'Forr_rofi', compice, mapconsf, 'none', rof2ocn_ice_rmap) - call addmrg_to(compice, 'Fixx_rofi', mrg_from=comprof, mrg_fld='Firr_rofi', mrg_type='sum') - end if - do ns = 1, is_local%wrap%num_icesheets - if (fldchk(is_local%wrap%FBImp(compglc(ns), compglc(ns)), 'Figg_rofi', rc=rc)) then - call addmap_from(compglc(ns), 'Figg_rofi', compice, mapconsf, 'one' , glc2ice_rmap) - call addmrg_to(compice, 'Fixx_rofi', mrg_from=compglc(ns), mrg_fld='Figg_rofi', mrg_type='sum') - end if - end do - end if - end if - if (flds_wiso) then - if (phase == 'advertise') then - call addfld_from(comprof, 'Firr_rofi_wiso') ! water flux into sea ice due to runoff (frozen) - do ns = 1, is_local%wrap%num_icesheets - call addfld_from(compglc(ns), 'Figg_rofi_wiso') ! glc frozen runoff_iceberg flux to ice - end do - call addfld_to(compice, 'Fixx_rofi_wiso') ! total frozen water flux into sea ice - else - if ( fldchk(is_local%wrap%FBExp(compice), 'Fixx_rofi_wiso', rc=rc)) then - if (fldchk(is_local%wrap%FBImp(comprof, comprof), 'Forr_rofi_wiso', rc=rc)) then - call addmap_from(comprof, 'Forr_rofi_wiso', compice, mapconsf, 'none', rof2ocn_ice_rmap) - call addmrg_to(compice, 'Fixx_rofi_wiso', & - mrg_from=comprof, mrg_fld='Firr_rofi_wiso', mrg_type='sum') - end if - do ns = 1, is_local%wrap%num_icesheets - if (fldchk(is_local%wrap%FBImp(compglc(ns), compglc(ns)), 'Figg_rofi_wiso', rc=rc)) then - call addmap_from(compglc(ns), 'Figg_rofi_wiso', compice, mapconsf, 'one' , glc2ice_rmap) - call addmrg_to(compice, 'Fixx_rofi_wiso', & - mrg_from=compglc(ns), mrg_fld='Figg_rofi_wiso', mrg_type='sum') - end if - end do - end if - end if - end if - ! --------------------------------------------------------------------- ! to ice: wave elevation spectrum (field with ungridded dimensions) ! --------------------------------------------------------------------- @@ -2858,7 +2988,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBExp(compice) , 'Sw_elevation_spectrum', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compwav,compwav), 'Sw_elevation_spectrum', rc=rc)) then - call addmap_from(compwav, 'Sw_elevation_spectrum', compice, mapbilnr, 'one', 'unset') + call addmap_from(compwav, 'Sw_elevation_spectrum', compice, mapbilnr_nstod, 'one', wav2ocn_map) call addmrg_to(compice, 'Sw_elevation_spectrum', & mrg_from=compwav, mrg_fld='Sw_elevation_spectrum', mrg_type='copy') end if @@ -2879,7 +3009,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) if ( fldchk(is_local%wrap%FBexp(compwav) , 'Si_ifrac', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_ifrac', rc=rc)) then ! By default will be using a custom map - but if one is not available, use a generated bilinear instead - call addmap_from(compice, 'Si_ifrac', compwav, mapbilnr, 'one', ice2wav_smap) + call addmap_from(compice, 'Si_ifrac', compwav, mapbilnr, 'one', ice2wav_map) call addmrg_to(compwav, 'Si_ifrac', mrg_from=compice, mrg_fld='Si_ifrac', mrg_type='copy') end if end if @@ -2893,7 +3023,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if (fldchk(is_local%wrap%FBexp(compwav) , 'Si_thick', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_thick', rc=rc)) then - call addmap_from(compice, 'Si_thick', compwav, mapbilnr, 'one', ice2wav_smap) + call addmap_from(compice, 'Si_thick', compwav, mapbilnr, 'one', ice2wav_map) call addmrg_to(compwav, 'Si_thick', mrg_from=compice, mrg_fld='Si_thick', mrg_type='copy') end if end if @@ -2908,7 +3038,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if (fldchk(is_local%wrap%FBexp(compwav) , 'Si_floediam', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compice,compice ), 'Si_floediam', rc=rc)) then - call addmap_from(compice, 'Si_floediam', compwav, mapbilnr, 'one', ice2wav_smap) + call addmap_from(compice, 'Si_floediam', compwav, mapbilnr, 'one', ice2wav_map) call addmrg_to(compwav, 'Si_floediam', mrg_from=compice, mrg_fld='Si_floediam', mrg_type='copy') end if end if @@ -2922,8 +3052,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(compocn, compocn), 'So_t', rc=rc) .and. & fldchk(is_local%wrap%FBExp(compwav) , 'So_t', rc=rc)) then - ! By default will be using a custom map - but if one is not available, use a generated bilinear instead - call addmap_from(compocn, 'So_t', compwav, mapbilnr, 'one', ocn2wav_smap) + call addmap_from(compocn, 'So_t', compwav, mapbilnr, 'one', ocn2wav_map) call addmrg_to(compwav, 'So_t', mrg_from=compocn, mrg_fld='So_t', mrg_type='copy') end if end if @@ -2937,7 +3066,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) if ( fldchk(is_local%wrap%FBImp(compocn, compocn), 'So_u', rc=rc) .and. & fldchk(is_local%wrap%FBExp(compwav) , 'So_u', rc=rc)) then ! By default will be using a custom map - but if one is not available, use a generated bilinear instead - call addmap_from(compocn, 'So_u', compwav, mapbilnr, 'one', ocn2wav_smap) + call addmap_from(compocn, 'So_u', compwav, mapbilnr, 'one', ocn2wav_map) call addmrg_to(compwav, 'So_u', mrg_from=compocn, mrg_fld='So_u', mrg_type='copy') end if end if @@ -2948,7 +3077,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) if ( fldchk(is_local%wrap%FBImp(compocn, compocn), 'So_v', rc=rc) .and. & fldchk(is_local%wrap%FBExp(compwav) , 'So_v', rc=rc)) then ! By default will be using a custom map - but if one is not available, use a generated bilinear instead - call addmap_from(compocn, 'So_v', compwav, mapbilnr, 'one', ocn2wav_smap) + call addmap_from(compocn, 'So_v', compwav, mapbilnr, 'one', ocn2wav_map) call addmrg_to(compwav, 'So_v', mrg_from=compocn, mrg_fld='So_v', mrg_type='copy') end if end if @@ -2963,7 +3092,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) if ( fldchk(is_local%wrap%FBImp(compocn, compocn), 'So_bldepth', rc=rc) .and. & fldchk(is_local%wrap%FBExp(compwav) , 'So_bldepth', rc=rc)) then ! By default will be using a custom map - but if one is not available, use a generated bilinear instead - call addmap_from(compocn, 'So_bldepth', compwav, mapbilnr, 'one', ocn2wav_smap) + call addmap_from(compocn, 'So_bldepth', compwav, mapbilnr, 'one', ocn2wav_map) call addmrg_to(compwav, 'So_bldepth', mrg_from=compocn, mrg_fld='So_bldepth', mrg_type='copy') end if end if @@ -2974,22 +3103,36 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) if (phase == 'advertise') then call addfld_from(compatm, 'Sa_u') call addfld_to(compwav, 'Sa_u') + call addfld_from(compatm, 'Sa_u10m') + call addfld_to(compwav, 'Sa_u10m') else if ( fldchk(is_local%wrap%FBexp(compwav) , 'Sa_u', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compatm,compatm ), 'Sa_u', rc=rc)) then call addmap_from(compatm, 'Sa_u', compwav, mapbilnr, 'one', atm2wav_map) call addmrg_to(compwav, 'Sa_u', mrg_from=compatm, mrg_fld='Sa_u', mrg_type='copy') end if + if ( fldchk(is_local%wrap%FBexp(compwav) , 'Sa_u10m', rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compatm,compatm ), 'Sa_u10m', rc=rc)) then + call addmap_from(compatm, 'Sa_u10m', compwav, mapbilnr, 'one', atm2wav_map) + call addmrg_to(compwav, 'Sa_u10m', mrg_from=compatm, mrg_fld='Sa_u10m', mrg_type='copy') + end if end if if (phase == 'advertise') then call addfld_from(compatm, 'Sa_v') call addfld_to(compwav, 'Sa_v') + call addfld_from(compatm, 'Sa_v10m') + call addfld_to(compwav, 'Sa_v10m') else if ( fldchk(is_local%wrap%FBexp(compwav) , 'Sa_v', rc=rc) .and. & fldchk(is_local%wrap%FBImp(compatm,compatm ), 'Sa_v', rc=rc)) then call addmap_from(compatm, 'Sa_v', compwav, mapbilnr, 'one', atm2wav_map) call addmrg_to(compwav, 'Sa_v', mrg_from=compatm, mrg_fld='Sa_v', mrg_type='copy') end if + if ( fldchk(is_local%wrap%FBexp(compwav) , 'Sa_v10m', rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compatm,compatm ), 'Sa_v10m', rc=rc)) then + call addmap_from(compatm, 'Sa_v10m', compwav, mapbilnr, 'one', atm2wav_map) + call addmrg_to(compwav, 'Sa_v10m', mrg_from=compatm, mrg_fld='Sa_v10m', mrg_type='copy') + end if end if ! --------------------------------------------------------------------- @@ -3018,6 +3161,51 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) ! FIELDS TO RIVER (comprof) !===================================================================== + ! --------------------------------------------------------------------- + ! to rof: liquid and ice from glc + ! --------------------------------------------------------------------- + do ns = 1, is_local%wrap%num_icesheets + if (phase == 'advertise') then + call addfld_from(compglc(ns), 'Fgrg_rofl') + call addfld_from(compglc(ns), 'Fgrg_rofi') + call addfld_to(comprof, 'Fgrg_rofl') + call addfld_to(comprof, 'Fgrg_rofi') + else + ! Note: we are assuming that the rof mesh has a mask of one everywhere + if ( fldchk(is_local%wrap%FBImp(compglc(ns), compglc(ns)), 'Fgrg_rofl', rc=rc) .and. & + fldchk(is_local%wrap%FBExp(comprof) , 'Fgrg_rofl', rc=rc)) then + call addmap_from(compglc(ns), 'Fgrg_rofl', comprof, mapconsd, 'gfrac' , 'unset') + ! Custom merge in med_phases_prep_rof + end if + if (fldchk(is_local%wrap%FBImp(compglc(ns), compglc(ns)), 'Fgrg_rofi', rc=rc) .and. & + fldchk(is_local%wrap%FBExp(comprof) , 'Fgrg_rofi', rc=rc)) then + call addmap_from(compglc(ns), 'Fgrg_rofi', comprof, mapconsd, 'gfrac', 'unset') + ! Custom merge in med_phases_prep_rof + end if + end if + end do + + ! --------------------------------------------------------------------- + ! to rof: liquid and ice from glc water isoptopes + ! --------------------------------------------------------------------- + do ns = 1, is_local%wrap%num_icesheets + if (phase == 'advertise') then + call addfld_from(compglc(ns), 'Fgrg_rofl_wiso') + call addfld_from(compglc(ns), 'Fgrg_rofi_wiso') + call addfld_to(comprof, 'Fgrg_rofl_wiso') + call addfld_to(comprof, 'Fgrg_rofi_wiso') + else + if (fldchk(is_local%wrap%FBImp(compglc(ns), compglc(ns)), 'Fgrg_rofl_wiso' , rc=rc)) then + call addmap_from(compglc(ns), 'Fgrg_rofl_wiso', comprof, mapconsd, 'one' , 'unset') + ! TODO: implement custom merge + end if + if (fldchk(is_local%wrap%FBImp(compglc(ns), compglc(ns)), 'Fgrg_rofi_wiso' , rc=rc)) then + call addmap_from(compglc(ns), 'Fgrg_rofi_wiso', comprof, mapconsd, 'one', 'unset') + ! TODO: implement custom merge + end if + end if + end do + ! --------------------------------------------------------------------- ! to rof: water flux from land (liquid surface) ! --------------------------------------------------------------------- @@ -3027,9 +3215,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(complnd, complnd), 'Flrl_rofsur', rc=rc) .and. & fldchk(is_local%wrap%FBExp(comprof) , 'Flrl_rofsur', rc=rc)) then - call addmap_from(complnd, 'Flrl_rofsur', comprof, mapconsf, 'lfrac', lnd2rof_map) + call addmap_from(complnd, 'Flrl_rofsur', comprof, mapconsf, map_fracname_lnd2rof, 'unset') call addmrg_to(comprof, 'Flrl_rofsur', & - mrg_from=complnd, mrg_fld='Flrl_rofsur', mrg_type='copy_with_weights', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Flrl_rofsur', mrg_type='copy_with_weights', mrg_fracname=mrg_fracname_lnd2rof) end if end if @@ -3042,9 +3230,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(complnd, complnd), 'Flrl_rofi', rc=rc) .and. & fldchk(is_local%wrap%FBExp(comprof) , 'Flrl_rofi', rc=rc)) then - call addmap_from(complnd, 'Flrl_rofi', comprof, mapconsf, 'lfrac', lnd2rof_map) + call addmap_from(complnd, 'Flrl_rofi', comprof, mapconsf, map_fracname_lnd2rof, 'unset') call addmrg_to(comprof, 'Flrl_rofi', & - mrg_from=complnd, mrg_fld='Flrl_rofi', mrg_type='copy_with_weights', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Flrl_rofi', mrg_type='copy_with_weights', mrg_fracname=mrg_fracname_lnd2rof) end if end if @@ -3057,9 +3245,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(complnd, complnd), 'Flrl_rofgwl', rc=rc) .and. & fldchk(is_local%wrap%FBExp(comprof) , 'Flrl_rofgwl', rc=rc)) then - call addmap_from(complnd, 'Flrl_rofgwl', comprof, mapconsf, 'lfrac', lnd2rof_map) + call addmap_from(complnd, 'Flrl_rofgwl', comprof, mapconsf, map_fracname_lnd2rof, 'unset') call addmrg_to(comprof, 'Flrl_rofgwl', & - mrg_from=complnd, mrg_fld='Flrl_rofgwl', mrg_type='copy_with_weights', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Flrl_rofgwl', mrg_type='copy_with_weights', mrg_fracname=mrg_fracname_lnd2rof) end if end if @@ -3072,9 +3260,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(complnd, complnd), 'Flrl_rofsub', rc=rc) .and. & fldchk(is_local%wrap%FBExp(comprof) , 'Flrl_rofsub', rc=rc)) then - call addmap_from(complnd, 'Flrl_rofsub', comprof, mapconsf, 'lfrac', lnd2rof_map) + call addmap_from(complnd, 'Flrl_rofsub', comprof, mapconsf, map_fracname_lnd2rof, 'unset') call addmrg_to(comprof, 'Flrl_rofsub', & - mrg_from=complnd, mrg_fld='Flrl_rofsub', mrg_type='copy_with_weights', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Flrl_rofsub', mrg_type='copy_with_weights', mrg_fracname=mrg_fracname_lnd2rof) end if end if @@ -3087,9 +3275,9 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) else if ( fldchk(is_local%wrap%FBImp(complnd, complnd), 'Flrl_irrig', rc=rc) .and. & fldchk(is_local%wrap%FBExp(comprof) , 'Flrl_irrig', rc=rc)) then - call addmap_from(complnd, 'Flrl_irrig', comprof, mapconsf, 'lfrac', lnd2rof_map) + call addmap_from(complnd, 'Flrl_irrig', comprof, mapconsf, map_fracname_lnd2rof, 'unset') call addmrg_to(comprof, 'Flrl_irrig', & - mrg_from=complnd, mrg_fld='Flrl_irrig', mrg_type='copy_with_weights', mrg_fracname='lfrac') + mrg_from=complnd, mrg_fld='Flrl_irrig', mrg_type='copy_with_weights', mrg_fracname=mrg_fracname_lnd2rof) end if end if @@ -3119,14 +3307,14 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) ! custom mapping, accumulation and merging will be done in prep_glc_mod.F90 do ns = 1,is_local%wrap%num_icesheets if ( fldchk(is_local%wrap%FBImp(complnd,complnd) , 'Flgl_qice_elev', rc=rc)) then - call addmap_from(complnd, 'Flgl_qice_elev', compglc(ns), mapbilnr, 'lfrac', 'unset') + call addmap_from(complnd, 'Flgl_qice_elev', compglc(ns), mapbilnr, map_fracname_lnd2glc, 'unset') end if if ( fldchk(is_local%wrap%FBImp(complnd,complnd) , 'Sl_tsrf_elev' , rc=rc)) then - call addmap_from(complnd, 'Sl_tsrf_elev', compglc(ns), mapbilnr, 'lfrac', 'unset') + call addmap_from(complnd, 'Sl_tsrf_elev', compglc(ns), mapbilnr, map_fracname_lnd2glc, 'unset') end if if ( fldchk(is_local%wrap%FBImp(complnd,complnd) , 'Sl_topo_elev' , rc=rc)) then - ! This is needed just for mappingn to glc - but is not sent as a field - call addmap_from(complnd, 'Sl_topo_elev', compglc(ns), mapbilnr, 'lfrac', 'unset') + ! This is needed just for mapping to glc - but is not sent as a field + call addmap_from(complnd, 'Sl_topo_elev', compglc(ns), mapbilnr, map_fracname_lnd2glc, 'unset') end if end do end if @@ -3156,158 +3344,6 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc) end if end if - !===================================================================== - ! CO2 EXCHANGE - !===================================================================== - - call NUOPC_CompAttributeGet(gcomp, name='flds_co2a', value=cvalue, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) flds_co2a - call ESMF_LogWrite('flds_co2a = '// trim(cvalue), ESMF_LOGMSG_INFO) - - call NUOPC_CompAttributeGet(gcomp, name='flds_co2b', value=cvalue, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) flds_co2b - call ESMF_LogWrite('flds_co2b = '// trim(cvalue), ESMF_LOGMSG_INFO) - - call NUOPC_CompAttributeGet(gcomp, name='flds_co2c', value=cvalue, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) flds_co2c - call ESMF_LogWrite('flds_co2c = '// trim(cvalue), ESMF_LOGMSG_INFO) - - if (flds_co2a) then - ! --------------------------------------------------------------------- - ! to lnd and ocn: prognostic CO2 at the lowest atm model level - ! --------------------------------------------------------------------- - if (phase == 'advertise') then - call addfld_from(compatm, 'Sa_co2prog') - call addfld_to(complnd, 'Sa_co2prog') - call addfld_to(compocn, 'Sa_co2prog') - else - call addmap_from(compatm, 'Sa_co2prog', complnd, mapbilnr, 'one', atm2lnd_map) - call addmap_from(compatm, 'Sa_co2prog', compocn, mapbilnr, 'one', atm2ocn_map) - - call addmrg_to(complnd, 'Sa_co2prog', & - mrg_from=compatm, mrg_fld='Sa_co2prog', mrg_type='copy') - call addmrg_to(compocn, 'Sa_co2prog', & - mrg_from=compatm, mrg_fld='Sa_co2prog', mrg_type='copy') - end if - - ! --------------------------------------------------------------------- - ! to lnd and ocn: diagnostic CO2 at the lowest atm model level - ! --------------------------------------------------------------------- - if (phase == 'advertise') then - call addfld_from(compatm, 'Sa_co2diag') - call addfld_to(complnd, 'Sa_co2diag') - call addfld_to(compocn, 'Sa_co2diag') - else - call addmap_from(compatm, 'Sa_co2diag', complnd, mapbilnr, 'one', atm2lnd_map) - call addmap_from(compatm, 'Sa_co2diag', compocn, mapbilnr, 'one', atm2ocn_map) - - call addmrg_to(complnd, 'Sa_co2diag', & - mrg_from=compatm, mrg_fld='Sa_co2diag', mrg_type='copy') - call addmrg_to(compocn, 'Sa_co2diag', & - mrg_from=compatm, mrg_fld='Sa_co2diag', mrg_type='copy') - end if - - else if (flds_co2b) then - - ! --------------------------------------------------------------------- - ! to lnd: prognostic CO2 at the lowest atm model level - ! --------------------------------------------------------------------- - if (phase == 'advertise') then - call addfld_from(compatm, 'Sa_co2prog') - call addfld_to(complnd, 'Sa_co2prog') - else - call addmap_from(compatm, 'Sa_co2prog', complnd, mapbilnr, 'one', atm2lnd_map) - call addmrg_to(complnd, 'Sa_co2prog', & - mrg_from=compatm, mrg_fld='Sa_co2prog', mrg_type='copy') - end if - - ! --------------------------------------------------------------------- - ! to lnd: diagnostic CO2 at the lowest atm model level - ! --------------------------------------------------------------------- - if (phase == 'advertise') then - call addfld_from(compatm, 'Sa_co2diag') - call addfld_to(complnd, 'Sa_co2diag') - else - call addmap_from(compatm, 'Sa_co2diag', complnd, mapbilnr, 'one', atm2lnd_map) - call addmrg_to(complnd, 'Sa_co2diag', & - mrg_from=compatm, mrg_fld='Sa_co2diag', mrg_type='copy') - end if - - ! --------------------------------------------------------------------- - ! to atm: surface flux of CO2 from land - ! --------------------------------------------------------------------- - if (phase == 'advertise') then - call addfld_from(complnd, 'Fall_fco2_lnd') - call addfld_to(compatm, 'Fall_fco2_lnd') - else - call addmap_from(complnd, 'Fall_fco2_lnd', compatm, mapconsf, 'one', lnd2atm_map) - call addmrg_to(compatm, 'Fall_fco2_lnd', & - mrg_from=complnd, mrg_fld='Fall_fco2_lnd', mrg_type='copy_with_weights', mrg_fracname='lfrac') - end if - - else if (flds_co2c) then - - ! --------------------------------------------------------------------- - ! to lnd and ocn: prognostic CO2 at the lowest atm model level - ! --------------------------------------------------------------------- - if (phase == 'advertise') then - call addfld_from(compatm, 'Sa_co2prog') - call addfld_to(complnd, 'Sa_co2prog') - call addfld_to(compocn, 'Sa_co2prog') - else - call addmap_from(compatm, 'Sa_co2prog', complnd, mapbilnr, 'one', atm2lnd_map) - call addmap_from(compatm, 'Sa_co2prog', compocn, mapbilnr, 'one', atm2ocn_map) - - call addmrg_to(complnd, 'Sa_co2prog', & - mrg_from=compatm, mrg_fld='Sa_co2prog', mrg_type='copy') - call addmrg_to(compocn, 'Sa_co2prog', & - mrg_from=compatm, mrg_fld='Sa_co2prog', mrg_type='copy') - end if - - ! --------------------------------------------------------------------- - ! to lnd and ocn: diagnostic CO2 at the lowest atm model level - ! --------------------------------------------------------------------- - if (phase == 'advertise') then - call addfld_from(compatm, 'Sa_co2diag') - call addfld_to(complnd, 'Sa_co2diag') - call addfld_to(compocn, 'Sa_co2diag') - else - call addmap_from(compatm, 'Sa_co2diag', complnd, mapbilnr, 'one', atm2lnd_map) - call addmap_from(compatm, 'Sa_co2diag', compocn, mapbilnr, 'one', atm2ocn_map) - - call addmrg_to(complnd, 'Sa_co2diag', & - mrg_from=compatm, mrg_fld='Sa_co2diag', mrg_type='copy') - call addmrg_to(compocn, 'Sa_co2diag', & - mrg_from=compatm, mrg_fld='Sa_co2diag', mrg_type='copy') - end if - - ! --------------------------------------------------------------------- - ! to atm: surface flux of CO2 from land - ! --------------------------------------------------------------------- - if (phase == 'advertise') then - call addfld_from(complnd, 'Fall_fco2_lnd') - call addfld_to(compatm, 'Fall_fco2_lnd') - else - call addmap_from(complnd, 'Fall_fco2_lnd', compatm, mapconsf, 'one', lnd2atm_map) - call addmrg_to(compatm, 'Fall_fco2_lnd', & - mrg_from=complnd, mrg_fld='Fall_fco2_lnd', mrg_type='copy_with_weights', mrg_fracname='lfrac') - end if - - ! --------------------------------------------------------------------- - ! to atm: surface flux of CO2 from ocn - ! --------------------------------------------------------------------- - if (phase == 'advertise') then - call addfld_from(compocn, 'Faoo_fco2_ocn') - call addfld_to(compatm, 'Faoo_fco2_ocn') - else - call addmap_from(compocn, 'Faoo_fco2_ocn', compatm, mapconsd, 'one', ocn2atm_map) - ! custom merge in med_phases_prep_atm - end if - endif - end subroutine esmFldsExchange_cesm end module esmFldsExchange_cesm_mod diff --git a/mediator/esmFldsExchange_ufs_mod.F90 b/mediator/esmFldsExchange_ufs_mod.F90 index aa808830..57c266b5 100644 --- a/mediator/esmFldsExchange_ufs_mod.F90 +++ b/mediator/esmFldsExchange_ufs_mod.F90 @@ -131,9 +131,10 @@ subroutine esmFldsExchange_ufs(gcomp, phase, rc) deallocate(flds) ! from med: fields returned by the atm/ocn flux computation, otherwise unadvertised - allocate(flds(8)) - flds = (/'So_tref ', 'So_qref ', 'So_ustar ', 'So_re ','So_ssq ', 'So_u10 ', & - 'So_duu10n', 'Faox_lat '/) + allocate(flds(12)) + flds = (/'So_tref ', 'So_qref ', 'So_ustar ', 'So_re ', 'So_ssq ', & + 'So_u10 ', 'So_duu10n ', 'Faox_lat ', 'So_ugustOut ', 'So_u10withGust', & + 'So_u10res ', 'Faxa_rainc '/) do n = 1,size(flds) fldname = trim(flds(n)) if (phase == 'advertise') then diff --git a/mediator/fd_cesm.yaml b/mediator/fd_cesm.yaml index eaef1dc7..c6d57857 100644 --- a/mediator/fd_cesm.yaml +++ b/mediator/fd_cesm.yaml @@ -3,844 +3,950 @@ institution: National ESPC, CSC & MCL Working Groups description: Community-based dictionary for shared coupling fields entries: - # - #----------------------------------- - # section: mediator export for atm/ocn flux calculation - #----------------------------------- - # + # + #----------------------------------- + # Current the following sections are below + # section: fields computed in med + # section: lnd import to med + # section: lnd export from med (computed in med) + # section: atm import to med + # section: atm export from med (computed in med) + # section: glc import to med + # section: glc export from med (computed in med) + # section: ice import to med + # section: ocn import to med + # section: ocn export from med (computed in med) + # section: river import to med + # section: river export from med (computed in med) + # section: wav import to med + #----------------------------------- + # + #----------------------------------- + # section: fields computed in med + #----------------------------------- + # + - standard_name: cpl_scalars + canonical_units: unitless + # + - standard_name: frac + canonical_units: 1 + # + - standard_name: mask + canonical_units: 1 + # + - standard_name: area + canonical_units: radians**2 + description: med area for component + # - standard_name: Faox_evap alias: mean_evap_rate_atm_into_ocn canonical_units: kg m-2 s-1 - description: mediator export - atm/ocn evaporation water flux + description: med export - atm/ocn evaporation water flux computed in medidator # - standard_name: Faox_evap_wiso canonical_units: kg m-2 s-1 - description: mediator export - atm/ocn evaporation water flux 16O, 18O, HDO + description: med export - atm/ocn evaporation water flux 16O, 18O, HDO computed in medidator # - standard_name: Faox_lat alias: mean_laten_heat_flx_atm_into_ocn canonical_units: W m-2 - description: mediator export - atm/ocn surface latent heat flux + description: med export - atm/ocn surface latent heat flux computed in medidator # - standard_name: Faox_sen alias: mean_sensi_heat_flx_atm_into_ocn canonical_units: W m-2 - description: mediator export - atm/ocn surface sensible heat flux + description: med export - atm/ocn surface sensible heat flux computed in medidator # - standard_name: Faox_lwup alias: mean_up_lw_flx_ocn canonical_units: W m-2 - description: mediator export - long wave radiation flux over the ocean + description: med export - ocn long wave radiation flux over the ocean computed in medidator # - standard_name: Faox_taux alias: stress_on_air_ocn_zonal canonical_units: N m-2 - description: mediator export + description: med export - atm/ocn zonal surface stress computed in medidator # - standard_name: Faox_tauy alias: stress_on_air_ocn_merid canonical_units: N m-2 - description: mediator export + description: med export - atm/ocn meridional surface stress computed in medidator # - - standard_name: area - canonical_units: radians**2 - description: mediator area for component + - standard_name: Fwxx_taux + alias: mean_zonal_moment_flx + canonical_units: N m-2 + description: wave import to med - zonal surface stress + # + - standard_name: Fwxx_tauy + alias: mean_merid_moment_flx + canonical_units: N m-2 + description: wave import to med - meridional surface stress # #----------------------------------- - # section: land export + # section: lnd import to med #----------------------------------- # - standard_name: Fall_evap canonical_units: kg m-2 s-1 - description: land export + description: lnd import to med # - standard_name: Fall_evap_wiso canonical_units: kg m-2 s-1 - description: land export + description: lnd import to med # - standard_name: Fall_fco2_lnd canonical_units: moles m-2 s-1 - description: land export + description: lnd import to med # - standard_name: Fall_fire canonical_units: kg/m2/sec - description: land export - wild fire emission fluxes (1->10) + description: lnd import to med - wild fire emission fluxes (1->10) # - standard_name: Fall_flxdst canonical_units: kg m-2 s-1 - description: land export - dust fluxes from land (sizes 1->4) + description: lnd import to med - dust fluxes from lnd (sizes 1->4) # - standard_name: Fall_lat canonical_units: W m-2 - description: land export + description: lnd import to med # - standard_name: Fall_lwup canonical_units: W m-2 - description: land export + description: lnd import to med # - standard_name: Fall_sen canonical_units: W m-2 - description: land export + description: lnd import to med # - standard_name: Fall_swnet canonical_units: W m-2 - description: land export + description: lnd import to med # - standard_name: Fall_taux canonical_units: N m-2 - description: land export + description: lnd import to med # - standard_name: Fall_tauy canonical_units: N m-2 - description: land export + description: lnd import to med # - standard_name: Fall_voc canonical_units: molecules/m2/sec - description: land export - MEGAN voc emission fluxes from land (1->20) + description: lnd import to med - MEGAN voc emission fluxes from lnd (1->20) # - standard_name: Sl_anidf canonical_units: 1 - description: land export + description: lnd import to med # - standard_name: Sl_anidr canonical_units: 1 - description: land export + description: lnd import to med # - standard_name: Sl_avsdf canonical_units: 1 - description: land export + description: lnd import to med # - standard_name: Sl_avsdr canonical_units: 1 - description: land export + description: lnd import to med # - standard_name: Sl_ddvel canonical_units: cm/sec - description: land export - dry deposition velocities from (1->80) + description: lnd import to med - dry deposition velocities from (1->80) # - standard_name: Sl_fv canonical_units: m s-1 - description: land export + description: lnd import to med # - standard_name: Sl_fztop canonical_units: m - description: land export + description: lnd import to med # - standard_name: Sl_lfrac canonical_units: 1 - description: land export + description: lnd import to med # - standard_name: Sl_lfrin canonical_units: 1 - description: land export + description: lnd import to med # - standard_name: Sl_qref canonical_units: kg kg-1 - description: land export + description: lnd import to med # - standard_name: Sl_qref_wiso canonical_units: kg kg-1 - description: land export + description: lnd import to med # - standard_name: Sl_ram1 canonical_units: s/m - description: land export + description: lnd import to med # - standard_name: Sl_snowh canonical_units: m - description: land export + description: lnd import to med # - standard_name: Sl_snowh_wiso canonical_units: m - description: land export + description: lnd import to med # - standard_name: Sl_soilw canonical_units: m3/m3 - description: land export + description: lnd import to med # - standard_name: Sl_t canonical_units: K - description: land export + description: lnd import to med # - - standard_name: Sl_topo_elev - canonical_units: m - description: land export to mediator in elevation classes (1->glc_nec) + - standard_name: Flrl_irrig + canonical_units: kg m-2 s-1 + description: lnd export to river # - - standard_name: Sl_topo + - standard_name: Flrl_rofdto + canonical_units: kg m-2 s-1 + description: lnd export to river + # + - standard_name: Flrl_rofgwl + canonical_units: kg m-2 s-1 + description: lnd export to river + # + - standard_name: Flrl_rofi + canonical_units: kg m-2 s-1 + description: lnd export to river + # + - standard_name: Flrl_rofsub + canonical_units: kg m-2 s-1 + description: lnd export to river + # + - standard_name: Flrl_rofsur + canonical_units: kg m-2 s-1 + description: lnd export to river + # + - standard_name: Sl_topo_elev canonical_units: m - description: mediator export to glc - no levation classes + description: lnd import to med with elevation classes (1->glc_nec) # - standard_name: Sl_tsrf_elev canonical_units: deg C - description: land export to mediator in elevation classes (1->glc_nec) + description: lnd import to med with elevation classes (1->glc_nec) + # + - standard_name: Flgl_qice_elev + canonical_units: kg m-2 s-1 + description: lnd import to med in elevation classes (1->glc_nec) + # + #----------------------------------- + # section: lnd export from med (computed in med) + #----------------------------------- + # + - standard_name: Sl_topo + canonical_units: m + description: lnd export from med with no elevation classes (computed in med) # - standard_name: Sl_tsrf canonical_units: deg C - description: mediator export to gcl with no elevation classes + description: lnd export from med with no elevation classes (computed in med) # - standard_name: Sl_tref canonical_units: K - description: mediator export to glc - no levation classes + description: lnd export from med with no elevation classes (computed in med) # - standard_name: Sl_u10 canonical_units: m - description: land export + description: lnd import to med with no elevation classes (computed in med) + # + - standard_name: Flgl_qice + canonical_units: kg m-2 s-1 + description: lnd export to med no elevation classes (computed in med) # #----------------------------------- - # section: atmosphere export + # section: atm import to med #----------------------------------- # - standard_name: Faxa_nhx canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_noy canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_bcph canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_ocph canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_dstdry canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_dstwet canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_swdn alias: mean_down_sw_flx canonical_units: W m-2 - description: atmosphere export + description: atm import to med mean downward SW heat flux # - standard_name: Faxa_lwdn alias: mean_down_lw_flx canonical_units: W m-2 - description: atmosphere export + description: atm import to med mean downward SW heat flux # - standard_name: Faxa_ndep canonical_units: kg(N)/m2/sec - description: atmosphere export to land and ocean - currently nhx and noy + description: atm import to med - currently nhx and noy # - standard_name: Faxa_prec_wiso canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_rain alias: mean_prec_rate canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_rain_wiso alias: mean_prec_rate_wiso canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_rainc canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_rainc_wiso canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_rainl canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_rainl_wiso canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_snow alias: mean_fprec_rate canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_snow_wiso canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_snowc canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_snowc_wiso canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_snowl canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_snowl_wiso canonical_units: kg m-2 s-1 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_swnet canonical_units: W m-2 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_lwnet canonical_units: W m-2 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_swndf alias: mean_down_sw_ir_dif_flx canonical_units: W m-2 - description: atmosphere export - mean surface downward nir diffuse flux + description: atm import to med - mean surface downward nir diffuse flux # - standard_name: Faxa_swndr alias: mean_down_sw_ir_dir_flx canonical_units: W m-2 - description: atmosphere export - mean surface downward nir direct flux + description: atm import to med - mean surface downward nir direct flux # - standard_name: Faxa_swvdf alias: mean_down_sw_vis_dif_flx canonical_units: W m-2 - description: atmosphere export - mean surface downward uv+vis diffuse flux + description: atm import to med - mean surface downward uv+vis diffuse flux # - standard_name: Faxa_swvdr alias: mean_down_sw_vis_dir_flx canonical_units: W m-2 - description: atmosphere export - mean surface downward uv+visvdirect flux + description: atm import to med - mean surface downward uv+visvdirect flux # - standard_name: Sa_co2diag canonical_units: 1e-6 mol/mol - description: atmosphere export - diagnostic CO2 at the lowest model level + description: atm import to med - diagnostic CO2 at the lowest model level # - standard_name: Sa_co2prog canonical_units: 1e-6 mol/mol - description: atmosphere export - prognostic CO2 at the lowest model level + description: atm import to med - prognostic CO2 at the lowest model level # - standard_name: Sa_o3 canonical_units: mol/mol - description: atmosphere export - O3 in the lowest model layer (prognosed or prescribed) + description: atm import to med - O3 in the lowest model layer (prognosed or prescribed) # - standard_name: Sa_lightning canonical_units: /min - description: atmosphere export - lightning flash freqency + description: atm import to med - lightning flash freqency # - standard_name: Sa_topo alias: inst_surface_height canonical_units: m - description: atmosphere export - topographic height + description: atm import to med - topographic height # - standard_name: Sa_dens alias: air_density_height_lowest canonical_units: kg m-3 - description: atmosphere export - density at the lowest model layer + description: atm import to med - density at the lowest model layer # - standard_name: Sa_pbot alias: inst_pres_height_lowest canonical_units: Pa - description: atmosphere export - pressure at lowest model layer + description: atm import to med - pressure at lowest model layer # - standard_name: Sa_pslv alias: inst_pres_height_surface canonical_units: Pa - description: atmosphere export + description: atm import to med # - standard_name: Sa_ptem canonical_units: K - description: atmosphere export - bottom layer potential temperature + description: atm import to med - bottom layer potential temperature # - standard_name: Sa_shum alias: inst_spec_humid_height_lowest canonical_units: kg kg-1 - description: atmosphere export - bottom layer specific humidity + description: atm import to med - bottom layer specific humidiaty # - standard_name: Sa_shum_wiso alias: inst_spec_humid_height_lowest_wiso canonical_units: kg kg-1 - description: atmosphere export - bottom layer specific humidity 16O, 18O, HDO + description: atm import to med - bottom layer specific humidity 16O, 18O, HDO # - standard_name: Sa_tbot alias: inst_temp_height_lowest canonical_units: K - description: atmosphere export - bottom layer temperature + description: atm import to med - bottom layer temperature # - standard_name: Sa_tskn alias: inst_temp_skin_temperature canonical_units: K - description: atmosphere export - sea surface skin temperature + description: atm import to med - sea surface skin temperature # - standard_name: Sa_u alias: inst_zonal_wind_height_lowest canonical_units: m s-1 - description: atmosphere export - bottom layer zonal wind + description: atm import to med - bottom layer zonal wind # - standard_name: Sa_v alias: inst_merid_wind_height_lowest canonical_units: m s-1 - description: atmosphere export - bottom layer meridional wind + description: atm import to med - bottom layer meridional wind + # + - standard_name: Sa_u10m + canonical_units: m s-1 + description: atm import to med - 10m zonal wind + # + - standard_name: Sa_v10m + canonical_units: m s-1 + description: atm import to med- 10m meridional wind # - standard_name: Sa_wspd alias: inst_wind_speed_height_lowest canonical_units: m s-1 - description: atmosphere export - bottom layer wind speed + description: atm import to med - bottom layer wind speed # - standard_name: Sa_z alias: inst_height_lowest canonical_units: m - description: atmosphere export - bottom layer height + description: atm import to med - bottom layer height # - standard_name: Faxa_taux alias: mean_zonal_moment_flx_atm canonical_units: N m-2 - description: atmosphere export - zonal component of momentum flux + description: atm import to med - zonal component of momentum flux # - standard_name: Faxa_tauy alias: mean_merid_moment_flx_atm canonical_units: N m-2 - description: atmosphere export - meridional component of momentum flux + description: atm import to med - meridional component of momentum flux # - standard_name: Faxa_lat alias: mean_laten_heat_flx_atm canonical_units: W m-2 - description: atmosphere export + description: atm import to med # - standard_name: Faxa_sen alias: mean_sensi_heat_flx_atm canonical_units: W m-2 - description: atmosphere export + description: atm import to med # #----------------------------------- - # section: atmosphere import + # section: atm export from med (computed in med) #----------------------------------- # - standard_name: Faxx_evap canonical_units: kg m-2 s-1 - description: to atm merged water evaporation flux + description: atm export from meditor - merged water evaporation flux # - standard_name: Faxx_evap_wiso canonical_units: kg m-2 s-1 - description: to atm merged water evaporation flux for 16O, 18O and HDO + description: atm export from med - merged water evaporation flux for 16O, 18O and HDO # - standard_name: Faxx_lat alias: mean_laten_heat_flx canonical_units: W m-2 - description: to to atm merged latent heat flux + description: atm export from med - merged latent heat flux # - standard_name: Faxx_lwup canonical_units: W m-2 - description: to atm merged outgoing longwave radiation + description: atm export from med - merged outgoing longwave radiation # - standard_name: Faxx_sen alias: mean_sensi_heat_flx canonical_units: W m-2 - description: to atm merged sensible heat flux + description: atm export from med - merged sensible heat flux # - standard_name: Faxx_taux alias: mean_zonal_moment_flx canonical_units: N m-2 - description: to atm merged zonal surface stress + description: atm export from med - merged zonal surface stress # - standard_name: Faxx_tauy alias: mean_merid_moment_flx canonical_units: N m-2 - description: to atm merged meridional surface stress + description: atm export from med - merged meridional surface stress # - standard_name: Sx_anidf canonical_units: 1 - description: atmosphere import - description: to atm merged surface diffuse albedo (near-infrared radiation) + description: atm export from med - merged surface diffuse albedo (near-infrared radiation) # - standard_name: Sx_anidr canonical_units: 1 - description: to atm merged direct surface albedo (near-infrared radiation) + description: atm export from med - merged direct surface albedo (near-infrared radiation) # - standard_name: Sx_avsdf canonical_units: 1 - description: to atm merged surface diffuse albedo (visible radation) + description: atm export from med - merged surface diffuse albedo (visible radation) # - standard_name: Sx_avsdr canonical_units: 1 - description: to atm merged direct surface albedo (visible radiation) + description: atm export from med - merged direct surface albedo (visible radiation) # - standard_name: Sx_qref canonical_units: kg kg-1 - description: atmosphere import + description: atm export from med # - standard_name: Sx_qref_wiso canonical_units: kg kg-1 - description: atmosphere import + description: atm export from med # - standard_name: Sx_t alias: surface_temperature canonical_units: K - description: atmosphere import + description: atm export from med # - standard_name: Sx_tref canonical_units: K - description: atmosphere import + description: atm export from med # - standard_name: Sx_u10 canonical_units: m - description: atmosphere import + description: atm export from med # - standard_name: So_ugustOut canonical_units: m/s - description: atmosphere import + description: atm export from med + # + - standard_name: So_u10withGust + canonical_units: m/s + description: atm export from med + # + - standard_name: So_u10res + canonical_units: m/s + description: atm export from med # #----------------------------------- - # section: land-ice export + # section: glc import to med + #----------------------------------- + # # Note that the fields sent from glc->med do NOT have elevation classes, # but the fields from med->lnd are broken into multiple elevation classes - #----------------------------------- + # + - standard_name: Fgrg_rofi + canonical_units: kg m-2 s-1 + description: glc import tomed - glacier frozen_runoff_flux_to_ocean + # + - standard_name: Fgrg_rofi_wiso + canonical_units: kg m-2 s-1 + description: glc import to med - glacier_frozen_runoff_flux_to_ocean for 16O, 18O, HDO + # + - standard_name: Fgrg_rofl + canonical_units: kg m-2 s-1 + description: glc import to med - glacier liquid runoff flux to ocean + # + - standard_name: Fgrg_rofl_wiso + canonical_units: kg m-2 s-1 + description: glc import to med - glacier_frozen_runoff_flux_to_ocean for 16O, 18O, HDO # - standard_name: Figg_rofi canonical_units: kg m-2 s-1 - description: land-ice export - glc frozen runoff_iceberg flux to ice + description: glc import to med - glc frozen runoff_iceberg flux to ice # - standard_name: Figg_rofi_wiso canonical_units: kg m-2 s-1 - description: land-ice export - glc frozen runoff_iceberg flux to ice for 16O, 18O, HDO + description: glc import to med - glc frozen runoff_iceberg flux to ice for 16O, 18O, HDO # - standard_name: Flgg_hflx canonical_units: W m-2 - description: land-ice export to mediator (no elevation classes) - Downward heat flux from glacier interior, from mediator, elev class 0 - # - - standard_name: Flgg_hflx_elev - canonical_units: W m-2 - description: mediator land-ice export to lnd (elevation classes 1->glc_nec) - Downward heat flux from glacier interior, from mediator, elev class 1->glc_nec + description: glc import to med to med (no elevation classes) + Downward heat flux from glacier interior, from med, elev class 0 # - standard_name: Sg_area canonical_units: area internal to the CISM grid in radians**2 - description: land-ice export to mediator (no elevation classes) + description: glc import to med to med (no elevation classes) # - standard_name: Sg_ice_covered canonical_units: 1 - description: land-ice export to mediator (no elevation classes) - # - - standard_name: Sg_ice_covered_elev - canonical_units: 1 - description: mediator land-ice export to lnd (elevation classes 1->glc_nec) + description: glc import to med (no elevation classes) # - standard_name: Sg_icemask canonical_units: 1 - description: land-ice export + description: glc import to med # - standard_name: Sg_icemask_coupled_fluxes canonical_units: 1 - description: land-ice export + description: glc import to med # - standard_name: Sg_topo canonical_units: m - description: land-ice export to mediator (no elevation classes) + description: glc import to med (no elevation classes) # - - standard_name: Sg_topo_elev - canonical_units: m - description: mediator land-ice export to lnd (elevation classes 1->glc_nec) - # - - standard_name: Fogg_rofi - canonical_units: kg m-2 s-1 - description: land-ice export - glacier_frozen_runoff_flux_to_ocean + #----------------------------------- + # section: glc export from med (computed in med) + #----------------------------------- # - - standard_name: Fogg_rofi_wiso - canonical_units: kg m-2 s-1 - description: land-ice export - glacier_frozen_runoff_flux_to_ocean for 16O, 18O, HDO + - standard_name: Flgg_hflx_elev + canonical_units: W m-2 + description: glc export from med (elevation classes 1->glc_nec) + Downward heat flux from glacier interior, from med, elev class 1->glc_nec # - - standard_name: Fogg_rofl - canonical_units: kg m-2 s-1 - description: land-ice export - glacier liquid runoff flux to ocean + - standard_name: Sg_ice_covered_elev + canonical_units: 1 + description: glc export from med (elevation classes 1->glc_nec) # - - standard_name: Fogg_rofl_wiso - canonical_units: kg m-2 s-1 - description: land-ice export - glacier_frozen_runoff_flux_to_ocean for 16O, 18O, HDO + - standard_name: Sg_topo_elev + canonical_units: m + description: glc export from med (elevation classes 1->glc_nec) # #----------------------------------- - # section: sea-ice export + # section: ice import to med #----------------------------------- # - standard_name: Faii_evap alias: mean_evap_rate_atm_into_ice canonical_units: kg m-2 s-1 - description: sea-ice export + description: ice import to med # - standard_name: Faii_evap_wiso canonical_units: kg m-2 s-1 - description: sea-ice export for 16O, 18O, HDO + description: ice import to med for 16O, 18O, HDO # - standard_name: Faii_lat alias: mean_laten_heat_flx_atm_into_ice canonical_units: W m-2 - description: sea-ice export to atm - atm/ice latent heat flux + description: ice import to med - atm/ice latent heat flux # - standard_name: Faii_sen alias: mean_sensi_heat_flx_atm_into_ice canonical_units: W m-2 - description: sea-ice export to atm - atm/ice sensible heat flux + description: ice import to med - atm/ice sensible heat flux # - standard_name: Faii_lwup alias: mean_up_lw_flx_ice canonical_units: W m-2 - description: sea-ice export -outgoing logwave radiation + description: ice import to med -outgoing logwave radiation # - standard_name: Faii_swnet canonical_units: W m-2 - description: sea-ice export to atm + description: ice import to med to atm # - standard_name: Faii_taux alias: stress_on_air_ice_zonal canonical_units: N m-2 - description: sea-ice export to atm - air ice zonal stress + description: ice import to med - air ice zonal stress # - standard_name: Faii_tauy alias: stress_on_air_ice_merid canonical_units: N m-2 - description: sea-ice export - air ice meridional stress + description: ice import to med - air ice meridional stress # - standard_name: Fioi_bcphi canonical_units: kg m-2 s-1 - description: sea-ice export to ocean - hydrophilic black carbon flux to ocean + description: ice import to med to ocean - hydrophilic black carbon flux to ocean # - standard_name: Fioi_bcpho canonical_units: kg m-2 s-1 - description: sea-ice export to ocean - hydrophobic black carbon flux to ocean + description: ice import to med to ocean - hydrophobic black carbon flux to ocean # - standard_name: Fioi_flxdst canonical_units: kg m-2 s-1 - description: sea-ice export to ocean - dust aerosol flux to ocean + description: ice import to med to ocean - dust aerosol flux to ocean # - standard_name: Fioi_melth alias: net_heat_flx_to_ocn canonical_units: W m-2 - description: sea-ice export to ocean - net heat flux to ocean + description: ice import to med to ocean - net heat flux to ocean # - standard_name: Fioi_melth_wiso canonical_units: kg m-2 s-1 - description: sea-ice export to ocean - isotope head flux to ocean for 16O, 18O, HDO + description: ice import to med to ocean - isotope head flux to ocean for 16O, 18O, HDO # - standard_name: Fioi_melth_HDO canonical_units: kg m-2 s-1 - description: sea-ice export to ocean - isotope head flux to ocean + description: ice import to med to ocean - isotope head flux to ocean # - standard_name: Fioi_meltw alias: mean_fresh_water_to_ocean_rate canonical_units: kg m-2 s-1 - description: sea-ice export to ocean - fresh water to ocean (h2o flux from melting) + description: ice import to med to ocean - fresh water to ocean (h2o flux from melting) # - standard_name: Fioi_meltw_wiso alias: mean_fresh_water_to_ocean_rate_wiso canonical_units: kg m-2 s-1 - description: sea-ice export to ocean - fresh water to ocean (h2o flux from melting) for 16O, 18O, HDO + description: ice import to med to ocean - fresh water to ocean (h2o flux from melting) for 16O, 18O, HDO # - standard_name: Fioi_salt alias: mean_salt_rate canonical_units: kg m-2 s-1 - description: sea-ice export to ocean - salt to ocean (salt flux from melting) + description: ice import to med - salt to ocean (salt flux from melting) # - standard_name: Fioi_swpen alias: mean_sw_pen_to_ocn canonical_units: W m-2 - description: sea-ice export to ocean - flux of shortwave through ice to ocean + description: ice import to med - flux of shortwave through ice to ocean # - standard_name: Fioi_swpen_vdr alias: mean_sw_pen_to_ocn_vis_dir_flx canonical_units: W m-2 - description: sea-ice export to ocean - flux of vis dir shortwave through ice to ocean + description: ice import to med - flux of vis dir shortwave through ice to ocean # - standard_name: Fioi_swpen_vdf alias: mean_sw_pen_to_ocn_vis_dif_flx canonical_units: W m-2 - description: sea-ice export to ocean - flux of vif dir shortwave through ice to ocean + description: ice import to med - flux of vif dir shortwave through ice to ocean # - standard_name: Fioi_swpen_idr alias: mean_sw_pen_to_ocn_ir_dir_flx canonical_units: W m-2 - description: sea-ice export to ocean - flux of ir dir shortwave through ice to ocean + description: ice import to med - flux of ir dir shortwave through ice to ocean # - standard_name: Fioi_swpen_idf alias: mean_sw_pen_to_ocn_ir_dif_flx canonical_units: W m-2 - description: sea-ice export to ocean - flux of ir dif shortwave through ice to ocean + description: ice import to med - flux of ir dif shortwave through ice to ocean # - standard_name: Fioi_taux alias: stress_on_ocn_ice_zonal canonical_units: N m-2 - description: sea-ice export to ocean - ice ocean zonal stress + description: ice import to med - ice ocean zonal stress # - standard_name: Fioi_tauy alias: stress_on_ocn_ice_merid canonical_units: N m-2 - description: sea-ice export to ocean - ice ocean meridional stress + description: ice import to med - ice ocean meridional stress # - standard_name: Si_anidf alias: inst_ice_ir_dif_albedo canonical_units: 1 - description: sea-ice export to atm + description: ice import to med # - standard_name: Si_anidr alias: inst_ice_ir_dir_albedo canonical_units: 1 - description: sea-ice export to atm + description: ice import to med # - standard_name: Si_avsdf alias: inst_ice_vis_dif_albedo canonical_units: 1 - description: sea-ice export to atm + description: ice import to med # - standard_name: Si_avsdr alias: inst_ice_vis_dir_albedo canonical_units: 1 - description: sea-ice export to atm + description: ice import to med # - standard_name: Si_ifrac alias: ice_fraction canonical_units: 1 - description: sea-ice export to atm - ice fraction (varies with time) + description: ice import to med - ice fraction (varies with time) # - standard_name: Si_ifrac_n alias: ice_fraction_n canonical_units: 1 - description: sea-ice export - ice fraction per category (varies with time) + description: ice import to med - ice fraction per category (varies with time) # - standard_name: Si_imask alias: ice_mask canonical_units: 1 - description: sea-ice export - ice mask + description: ice import to med - ice mask # - standard_name: Si_qref canonical_units: kg kg-1 - description: sea-ice export to atm + description: ice import to med # - standard_name: Si_qref_wiso canonical_units: kg kg-1 - description: sea-ice export to atm + description: ice import to med # - standard_name: Si_t alias: sea_ice_surface_temperature canonical_units: K - description: sea-ice export + description: ice import to med # - standard_name: Si_tref canonical_units: K - description: sea-ice export + description: ice import to med # - standard_name: Si_u10 canonical_units: m - description: sea-ice export + description: ice import to med # - standard_name: Si_vice alias: mean_ice_volume canonical_units: m - description: sea-ice export - volume of ice per unit area + description: ice import to med - volume of ice per unit area # - standard_name: Si_snowh canonical_units: m - description: sea-ice export - surface_snow_water_equivalent + description: ice import to med - surface_snow_water_equivalent # - standard_name: Si_vsno alias: mean_snow_volume canonical_units: m - description: sea-ice export - volume of snow per unit area + description: ice import to med - volume of snow per unit area # - standard_name: Si_thick canonical_units: m - description: sea-ice export - ice thickness + description: ice import to med - ice thickness # - standard_name: Si_floediam canonical_units: m - description: sea-ice export - ice floe diameter + description: ice import to med - ice floe diameter # #----------------------------------- - # section: ocean export to mediator + # section: ocn import to med #----------------------------------- # - standard_name: Fioo_q alias: freezing_melting_potential canonical_units: W m-2 - description: ocean export + description: ocn import to med # - standard_name: Faoo_fco2_ocn canonical_units: moles m-2 s-1 - description: ocean export + description: ocn import to med - surface flux of CO2 (downward positive) + # + - standard_name: Faoo_fdms_ocn + canonical_units: moles m-2 s-1 + description: ocn import to med - surface flux of DMS (downward positive) + # + - standard_name: Faoo_fbrf_ocn + canonical_units: moles m-2 s-1 + description: ocn import to med - surface flux of Bromoform (downward positive) + # + - standard_name: Faoo_fn2o_ocn + canonical_units: moles m-2 s-1 + description: ocn import to med - surface flux of N2O (downward positive) + # + - standard_name: Faoo_fnh3_ocn + canonical_units: moles m-2 s-1 + description: ocn import to med - surface flux of NH3 (downward positive) # - standard_name: So_anidf canonical_units: 1 - description: ocean export + description: ocn import to med # - standard_name: So_anidr canonical_units: 1 - description: ocean export + description: ocn import to med # - standard_name: So_avsdf canonical_units: 1 - description: ocean export + description: ocn import to med # - standard_name: So_avsdr canonical_units: 1 - description: ocean export + description: ocn import to med # - standard_name: So_bldepth alias: mixed_layer_depth canonical_units: m - description: ocean export + description: ocn import to med # - standard_name: So_dhdx alias: sea_surface_slope_zonal canonical_units: m m-1 - description: ocean export + description: ocn import to med # - standard_name: So_dhdy alias: sea_surface_slope_merid canonical_units: m m-1 - description: ocean export + description: ocn import to med # - standard_name: So_duu10n canonical_units: m2 s-2 - description: ocean export + description: ocn import to med # - standard_name: So_fswpen canonical_units: 1 - description: ocean export + description: ocn import to med # - standard_name: So_ofrac canonical_units: 1 - description: ocean export + description: ocn import to med # - standard_name: So_omask alias: ocean_mask canonical_units: 1 - description: ocean export + description: ocn import to med # - standard_name: So_qref canonical_units: kg kg-1 - description: ocean export + description: ocn import to med # - standard_name: So_qref_wiso canonical_units: kg kg-1 - description: ocean export + description: ocn import to med # - standard_name: So_re canonical_units: 1 - description: ocean export + description: ocn import to med # - standard_name: So_qref_wiso canonical_units: kg kg-1 - description: ocean export + description: ocn import to med # - standard_name: So_roce_wiso canonical_units: unitless - description: ocean export + description: ocn import to med # - standard_name: So_s alias: s_surf canonical_units: g kg-1 - description: ocean export + description: ocn import to med # - standard_name: So_s_depth alias: s_surf_depths @@ -849,12 +955,12 @@ # - standard_name: So_ssq canonical_units: kg kg-1 - description: ocean export + description: ocn import to med # - standard_name: So_t alias: sea_surface_temperature canonical_units: K - description: ocean export + description: ocn import to med # - standard_name: So_t_depth alias: sea_surface_temperature_depths @@ -863,292 +969,244 @@ # - standard_name: So_tref canonical_units: K - description: ocean export + description: ocn import to med # - standard_name: So_u alias: ocn_current_zonal canonical_units: m s-1 - description: ocean export + description: ocn import to med # - standard_name: So_u10 canonical_units: m - description: ocean export + description: ocn import to med # - standard_name: So_ustar canonical_units: m s-1 - description: ocean export + description: ocn import to med # - standard_name: So_v alias: ocn_current_merid canonical_units: m s-1 - description: ocean export - # - #----------------------------------- - # section: river export - #----------------------------------- - # - - standard_name: Firr_rofi - canonical_units: kg m-2 s-1 - description: river export - water flux into sea ice due to runoff (frozen) - # - - standard_name: Firr_rofi_wiso - canonical_units: kg m-2 s-1 - description: river export - water flux into sea ice due to runoff (frozen) for 16O, 18O, HDO - # - - standard_name: Fixx_rofi - canonical_units: kg m-2 s-1 - description: frozen runoff to ice from river and land-ice - # - - standard_name: Fixx_rofi_wiso - canonical_units: kg m-2 s-1 - description: frozen runoff to ice from river and land-ice for 16O, 18O, HDO + description: ocn import to med # #----------------------------------- - # section: lnd export to glc - #----------------------------------- - # - - standard_name: Flgl_qice - canonical_units: kg m-2 s-1 - description: mediator export to glc no elevation classes - # - - standard_name: Flgl_qice_elev - canonical_units: kg m-2 s-1 - description: land export to mediator in elevation classes (1->glc_nec) - # - #----------------------------------- - # section: lnd export to river - #----------------------------------- - # - - standard_name: Flrl_irrig - canonical_units: kg m-2 s-1 - description: land export to river - # - - standard_name: Flrl_rofdto - canonical_units: kg m-2 s-1 - description: land export to river - # - - standard_name: Flrl_rofgwl - canonical_units: kg m-2 s-1 - description: land export to river - # - - standard_name: Flrl_rofi - canonical_units: kg m-2 s-1 - description: land export to river - # - - standard_name: Flrl_rofsub - canonical_units: kg m-2 s-1 - description: land export to river - # - - standard_name: Flrl_rofsur - canonical_units: kg m-2 s-1 - description: land export to river - # - #----------------------------------- - # section: river export - #----------------------------------- - # - - standard_name: Flrr_flood - canonical_units: kg m-2 s-1 - description: river export to land - water flux due to flooding - # - - standard_name: Flrr_flood_wiso - canonical_units: kg m-2 s-1 - description: river export to land - water flux due to flooding for 16O, 18O, HDO - # - - standard_name: Flrr_volr - canonical_units: m - description: river export to land - river channel total water volume - # - - standard_name: Flrr_volr_wiso - canonical_units: m - description: river export to land - river channel total water volume from 16O, 18O, HDO - # - - standard_name: Flrr_volrmch - canonical_units: m - description: river export to land - river channel main channel water volume - # - - standard_name: Flrr_volrmch_wiso - canonical_units: m - description: river export to land - river channel main channel water volume from 16O, 18O, HDO - # - - standard_name: Sr_tdepth - canonical_units: m - description: river export to land - tributary channel water depth - # - - standard_name: Sr_tdepth_max - canonical_units: m - description: river export to land - tributary channel bankfull depth - # - - standard_name: Forr_rofi - canonical_units: kg m-2 s-1 - description: river export to ocean - water flux due to runoff (frozen) - # - - standard_name: Forr_rofi_wiso - canonical_units: kg m-2 s-1 - description: river export to ocean - water flux due to runoff (frozen) for 16O, 18O, HDO - # - - standard_name: Forr_rofl - canonical_units: kg m-2 s-1 - description: river export to ocean - water flux due to runoff (liquid) - # - - standard_name: Forr_rofl_wiso - canonical_units: kg m-2 s-1 - description: river export to ocean - water flux due to runoff (frozen) for 16O, 18O, HDO - # - #----------------------------------- - # section: ocean import + # section: ocn export from med (computed in med) #----------------------------------- # - standard_name: Foxx_hrain alias: heat_content_lprec canonical_units: W m-2 - description: to ocn heat content of rain + description: med export to ocn heat content of rain # - standard_name: Foxx_hsnow alias: heat_content_fprec canonical_units: W m-2 - description: to ocn heat content of snow + description: med export to ocn heat content of snow # - standard_name: Foxx_hevap alias: heat_content_evap canonical_units: W m-2 - description: to ocn heat content of evaporation + description: med export to ocn heat content of evaporation # - standard_name: Foxx_hcond alias: heat_content_cond canonical_units: W m-2 - description: to ocn heat content of condensation + description: med export to ocn heat content of condensation # - standard_name: Foxx_hrofl alias: heat_content_rofl canonical_units: W m-2 - description: to ocn heat content of liquid runoff + description: med export to ocn heat content of liquid runoff # - standard_name: Foxx_hrofi alias: heat_content_rofi canonical_units: W m-2 - description: to ocn heat content of ice runoff + description: med export to ocn heat content of ice runoff # - standard_name: Foxx_evap alias: mean_evap_rate canonical_units: kg m-2 s-1 - description: ocean import - specific humidity flux + description: med export to ocn - specific humidity flux # - standard_name: Foxx_evap_wiso alias: mean_evap_rate_wiso canonical_units: kg m-2 s-1 - description: ocean import - specific humidity flux 16O, 18O, HDO + description: med export to ocn - specific humidity flux 16O, 18O, HDO # - standard_name: Foxx_lat canonical_units: W m-2 - description: ocean import - latent heat flux into ocean + description: med export to ocn - latent heat flux into ocean # - standard_name: Foxx_lat_wiso canonical_units: W m-2 - description: ocean import - latent heat flux into ocean for 16O, 18O, HDO + description: med export to ocn - latent heat flux into ocean for 16O, 18O, HDO # - standard_name: Foxx_lat canonical_units: W m-2 - description: ocean import - latent heat flux into ocean for HDO + description: med export to ocn - latent heat flux into ocean for HDO # - standard_name: Foxx_sen alias: mean_sensi_heat_flx canonical_units: W m-2 - description: ocean import - sensible heat flux into ocean + description: med export to ocn - sensible heat flux into ocean # - standard_name: Foxx_lwup canonical_units: W m-2 - description: ocean import - surface upward longwave heat flux + description: med export to ocn - surface upward longwave heat flux # - standard_name: Foxx_lwnet alias: mean_net_lw_flx canonical_units: W m-2 - description: ocean import - mean NET long wave radiation flux to ocean + description: med export to ocn - mean NET long wave radiation flux to ocean # - standard_name: mean_runoff_rate canonical_units: kg m-2 s-1 - description: ocean import - total runoff to ocean + description: med export to ocn - total runoff to ocean # - standard_name: mean_runoff_heat_flux canonical_units: kg m-2 s-1 - description: ocean import - heat content of runoff + description: med export to ocn - heat content of runoff # - standard_name: mean_calving_rate canonical_units: kg m-2 s-1 - description: ocean import - total calving to ocean + description: med export to ocn - total calving to ocean # - standard_name: mean_calving_heat_flux canonical_units: kg m-2 s-1 - description: ocean import - heat content of calving + description: med export to ocn - heat content of calving # - standard_name: Foxx_rofi canonical_units: kg m-2 s-1 - description: ocean import - water flux due to runoff (frozen) + description: med export to ocn - water flux due to runoff (frozen) # - standard_name: Foxx_rofi_wiso canonical_units: kg m-2 s-1 - description: ocean import - water flux due to runoff (frozen) for 16O, 18O, HDO + description: med export to ocn - water flux due to runoff (frozen) for 16O, 18O, HDO # - standard_name: Foxx_rofl alias: mean_runoff_rate canonical_units: kg m-2 s-1 - description: ocean import - water flux due to runoff (liquid) + description: med export to ocn - water flux due to runoff (liquid) # - standard_name: Foxx_rofl_wiso canonical_units: kg m-2 s-1 - description: ocean import - water flux due to runoff (liquid) for 16O, 18O, HDO + description: med export to ocn - water flux due to runoff (liquid) for 16O, 18O, HDO # - standard_name: Foxx_swnet alias: mean_net_sw_flx canonical_units: W m-2 - description: ocean import - net shortwave radiation to ocean + description: med export to ocn - net shortwave radiation to ocean # - standard_name: Foxx_swnet_vdr alias: mean_net_sw_vis_dir_flx canonical_units: W m-2 - description: ocean import - net shortwave visible direct radiation to ocean + description: med export to ocn - net shortwave visible direct radiation to ocean # - standard_name: Foxx_swnet_vdf alias: mean_net_sw_vis_dif_flx canonical_units: W m-2 - description: ocean import - net shortwave visible diffuse radiation to ocean + description: med export to ocn - net shortwave visible diffuse radiation to ocean # - standard_name: Foxx_swnet_idr alias: mean_net_sw_ir_dir_flx canonical_units: W m-2 - description: ocean import - net shortwave ir direct radiation to ocean + description: med export to ocn - net shortwave ir direct radiation to ocean # - standard_name: Foxx_swnet_idf alias: mean_net_sw_ir_dif_flx canonical_units: W m-2 - description: ocean import - net shortwave ir diffuse radiation to ocean + description: med export to ocn - net shortwave ir diffuse radiation to ocean # - standard_name: Foxx_swnet_afracr canonical_units: W m-2 - description: ocean import - net shortwave radiation times atmosphere fraction + description: med export to ocn - net shortwave radiation times atmosphere fraction # - standard_name: Foxx_taux alias: mean_zonal_moment_flx canonical_units: N m-2 - description: ocean import - zonal surface stress + description: med export to ocn - zonal surface stress # - standard_name: Foxx_tauy alias: mean_merid_moment_flx canonical_units: N m-2 - description: ocean import - meridional surface stress + description: med export to ocn - meridional surface stress # - standard_name: Fioi_swpen_ifrac_n alias: mean_sw_pen_to_ocn_ifrac_n canonical_units: W m-2 - description: ocean import - net shortwave radiation penetrating into ice and ocean times ice fraction for thickness category 1 + description: med export to ocn - net shortwave radiation penetrating into ice and ocean times ice fraction for thickness category 1 # - standard_name: Sf_afrac canonical_units: 1 - description: ocean import - fractional atmosphere coverage wrt ocean + description: med export to ocn - fractional atmosphere coverage wrt ocean # - standard_name: Sf_afracr canonical_units: 1 - description: ocean import - fractional atmosphere coverage used in radiation computations wrt ocean + description: med export to ocn - fractional atmosphere coverage used in radiation computations wrt ocean + # + #----------------------------------- + # section: river import to med + #----------------------------------- + # + - standard_name: Flrr_flood + canonical_units: kg m-2 s-1 + description: river import to med - water flux due to flooding + # + - standard_name: Flrr_flood_wiso + canonical_units: kg m-2 s-1 + description: river import to med - water flux due to flooding for 16O, 18O, HDO + # + - standard_name: Flrr_volr + canonical_units: m + description: river import to med - river channel total water volume + # + - standard_name: Flrr_volr_wiso + canonical_units: m + description: river import to med - river channel total water volume from 16O, 18O, HDO + # + - standard_name: Flrr_volrmch + canonical_units: m + description: river import to med - river channel main channel water volume + # + - standard_name: Flrr_volrmch_wiso + canonical_units: m + description: river import to med - river channel main channel water volume from 16O, 18O, HDO + # + - standard_name: Sr_tdepth + canonical_units: m + description: river import to med - tributary channel water depth + # + - standard_name: Sr_tdepth_max + canonical_units: m + description: river import to med - tributary channel bankfull depth + # + - standard_name: Forr_rofi + canonical_units: kg m-2 s-1 + description: river export to ocean - water flux due to runoff (frozen) + # + - standard_name: Forr_rofi_glc + canonical_units: kg m-2 s-1 + description: river export to ocean - water flux due to runoff originating from glc (frozen) + # + - standard_name: Forr_rofi_wiso + canonical_units: kg m-2 s-1 + description: river import to med - water flux due to runoff (frozen) for 16O, 18O, HDO + # + - standard_name: Forr_rofl + canonical_units: kg m-2 s-1 + description: river import to med - water flux due to runoff (liquid) + # + - standard_name: Forr_rofl_glc + canonical_units: kg m-2 s-1 + description: river import to med - water flux due to runoff originating from glc (liquid) + # + - standard_name: Forr_rofl_wiso + canonical_units: kg m-2 s-1 + description: river import to med - water flux due to runoff (frozen) for 16O, 18O, HDO + # + #----------------------------------- + # section: wav import to med + #----------------------------------- # - standard_name: Sw_hstokes canonical_units: m @@ -1173,37 +1231,76 @@ - standard_name: Sw_pstokes_y canonical_units: m/s description: Northward partitioned stokes drift components - # - standard_name: Sw_elevation_spectrum alias: wave_elevation_spectrum canonical_units: m2/s description: wave elevation spectrum - # - #----------------------------------- - # section: wave import - #----------------------------------- + - standard_name: Sw_ustokes_avg + canonical_units: m/s + description: Daily averaged stokes drift u component (only needed for med history output) # - - standard_name: Fwxx_taux - alias: mean_zonal_moment_flx - canonical_units: N m-2 - description: wave import - zonal surface stress + - standard_name: Sw_vstokes_avg + canonical_units: m/s + description: Daily averaged stokes drift v component (only needed for med history output) # - - standard_name: Fwxx_tauy - alias: mean_merid_moment_flx - canonical_units: N m-2 - description: wave import - meridional surface stress - - #----------------------------------- - # mediator fields - #----------------------------------- + - standard_name: Sw_hs_avg + canonical_units: m + description: Daily averaged significant wave hight (only needed for med history output) # - - standard_name: cpl_scalars - canonical_units: unitless + - standard_name: Sw_phs0_avg + canonical_units: m + description: Daily averaged averaged wind sea swh (only needed for med history output) # - - standard_name: frac - canonical_units: 1 + - standard_name: Sw_phs1_avg + canonical_units: m + description: Daily averaged swell swh (only needed for med history output) # - - standard_name: mask - canonical_units: 1 + - standard_name: Sw_pdir0_avg + canonical_units: degrees + description: Daily averaged wind sea swh (only needed for med history output) + # + - standard_name: Sw_pdir1_avg + canonical_units: degrees + description: Daily averaged swell swh (only needed for med history output) + # + - standard_name: Sw_pTm10_avg + canonical_units: s + description: Daily averaged wind sea mean wave Tm1 period (only needed for med history output) + # + - standard_name: Sw_pTm11_avg + canonical_units: s + description: Daily average swell mean wave Tm1 period (only needed for med history output) + # + - standard_name: Sw_Tm1_avg + canonical_units: s + description: Daily averaged mean wave period of the first moment (only needed for med history output) + # + - standard_name: Sw_thm_avg + canonical_units: degrees + description: Daily averaged mean wave direction (only needed for med history output) + # + - standard_name: Sw_thp0_avg + canonical_units: degrees + description: Daily averaged peak wave direction (only needed for med history output) + # + - standard_name: Sw_fp0_avg + canonical_units: 1/s + description: Daily averaged peak wave frequency (only needed for med history output) + # + - standard_name: Sw_u_avg + canonical_units: m/s + description: Daily averaged surface wind zonal (only needed for med history output) + # + - standard_name: Sw_v_avg + canonical_units: m/s + description: Daily averaged surface wind meridional (only needed for med history output) + # + - standard_name: Sw_tusx_avg + canonical_units: m2/s + description: Daily averaged stokes zonal transport vector (only needed for med history output) + # + - standard_name: Sw_tusy_avg + canonical_units: m2/s + description: Daily averaged stokes meridional transport vector (only needed for med history output) diff --git a/mediator/med.F90 b/mediator/med.F90 index dc0f68cf..4e1f916f 100644 --- a/mediator/med.F90 +++ b/mediator/med.F90 @@ -1622,7 +1622,7 @@ subroutine DataInitialize(gcomp, rc) use med_phases_post_lnd_mod , only : med_phases_post_lnd use med_phases_post_glc_mod , only : med_phases_post_glc use med_phases_post_ocn_mod , only : med_phases_post_ocn - use med_phases_post_rof_mod , only : med_phases_post_rof + use med_phases_post_rof_mod , only : med_phases_post_rof_init, med_phases_post_rof use med_phases_post_wav_mod , only : med_phases_post_wav use med_phases_ocnalb_mod , only : med_phases_ocnalb_run use med_phases_aofluxes_mod , only : med_phases_aofluxes_init_fldbuns @@ -1924,6 +1924,10 @@ subroutine DataInitialize(gcomp, rc) call med_phases_prep_rof_init(gcomp, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if + if (is_local%wrap%comp_present(comprof)) then + call med_phases_post_rof_init(gcomp, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if !--------------------------------------- ! Set the data initialize flag to false !--------------------------------------- @@ -2122,7 +2126,7 @@ subroutine DataInitialize(gcomp, rc) do n1 = 1,ncomps if (maintask) then write(logunit,*) - write(logunit,'(a)') trim(subname)//" "//trim(compname(n1)) + write(logunit,'(a,2L2)') trim(subname)//" "//trim(compname(n1)), is_local%wrap%comp_present(n1), ESMF_StateIsCreated(is_local%wrap%NStateImp(n1),rc=rc) end if if (is_local%wrap%comp_present(n1) .and. ESMF_StateIsCreated(is_local%wrap%NStateImp(n1),rc=rc)) then call State_GetScalar(scalar_value=real_nx, & @@ -2150,12 +2154,14 @@ subroutine DataInitialize(gcomp, rc) end if is_local%wrap%nx(n1) = nint(real_nx) is_local%wrap%ny(n1) = nint(real_ny) + endif + if (is_local%wrap%comp_present(n1)) then write(msgString,'(3i8)') is_local%wrap%nx(n1), is_local%wrap%ny(n1), is_local%wrap%ntile(n1) if (maintask) then write(logunit,'(a)') 'global nx,ny,ntile sizes for '//trim(compname(n1))//":"//trim(msgString) end if call ESMF_LogWrite(trim(subname)//":"//trim(compname(n1))//":"//trim(msgString), ESMF_LOGMSG_INFO) - end if + endif end do if (maintask) write(logunit,*) diff --git a/mediator/med_diag_mod.F90 b/mediator/med_diag_mod.F90 index 8ea6651e..69ff44f2 100644 --- a/mediator/med_diag_mod.F90 +++ b/mediator/med_diag_mod.F90 @@ -27,7 +27,7 @@ module med_diag_mod use med_constants_mod , only : shr_const_rearth, shr_const_pi, shr_const_latice, shr_const_latvap use med_constants_mod , only : shr_const_ice_ref_sal, shr_const_ocn_ref_sal, shr_const_isspval use med_kind_mod , only : CX=>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8 - use med_internalstate_mod , only : InternalState, logunit, maintask, diagunit + use med_internalstate_mod , only : InternalState, logunit, maintask, diagunit, samegrid_atmlnd use med_methods_mod , only : fldbun_getdata2d => med_methods_FB_getdata2d use med_methods_mod , only : fldbun_getdata1d => med_methods_FB_getdata1d use med_methods_mod , only : fldbun_fldChk => med_methods_FB_FldChk @@ -666,8 +666,13 @@ subroutine med_phases_diag_atm(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return ! Get fractions on atm mesh - call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'lfrac', lfrac, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (samegrid_atmlnd) then + call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'lfrac', lfrac, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'lfrin', lfrac, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'ifrac', ifrac, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'ofrac', ofrac, rc=rc) @@ -986,7 +991,7 @@ subroutine med_phases_diag_lnd( gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return ! get fractions on lnd mesh - call fldbun_getdata1d(is_local%wrap%FBfrac(complnd), 'lfrac', lfrac, rc=rc) + call fldbun_getdata1d(is_local%wrap%FBfrac(complnd), 'lfrin', lfrac, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return areas => is_local%wrap%mesh_info(complnd)%areas @@ -1197,8 +1202,15 @@ subroutine med_phases_diag_rof( gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call diag_rof(is_local%wrap%FBImp(comprof,comprof), 'Forr_rofi' , f_watr_ioff, ic, areas, budget_local, minus=.true., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call diag_rof(is_local%wrap%FBImp(comprof,comprof), 'Firr_rofi' , f_watr_ioff, ic, areas, budget_local, minus=.true., rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if ( fldbun_fldchk(is_local%wrap%FBImp(comprof,comprof), 'Forr_rofl_glc', rc=rc)) then + call diag_rof(is_local%wrap%FBImp(comprof,comprof), 'Forr_rofi_glc' , f_watr_roff, ic, areas, budget_local, minus=.true., rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if + if ( fldbun_fldchk(is_local%wrap%FBImp(comprof,comprof), 'Forr_rofi_glc', rc=rc)) then + call diag_rof(is_local%wrap%FBImp(comprof,comprof), 'Forr_rofi_glc' , f_watr_ioff, ic, areas, budget_local, minus=.true., rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if if (flds_wiso) then call diag_rof_wiso(is_local%wrap%FBExp(comprof), 'Forr_flood_wiso', & @@ -1231,6 +1243,14 @@ subroutine med_phases_diag_rof( gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call diag_rof(is_local%wrap%FBExp(comprof), 'Flrl_rofi' , f_watr_ioff, ic, areas, budget_local, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (fldbun_fldchk(is_local%wrap%FBExp(comprof), 'Fgrg_rofl', rc=rc)) then + call diag_rof(is_local%wrap%FBExp(comprof), 'Fgrg_rofl' , f_watr_roff, ic, areas, budget_local, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if + if (fldbun_fldchk(is_local%wrap%FBExp(comprof), 'Fgrg_rofi', rc=rc)) then + call diag_rof(is_local%wrap%FBExp(comprof), 'Fgrg_rofi' , f_watr_ioff, ic, areas, budget_local, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if if (flds_wiso) then call diag_rof_wiso(is_local%wrap%FBExp(comprof), 'Flrl_rofl_wiso', & @@ -1352,9 +1372,9 @@ subroutine med_phases_diag_glc( gcomp, rc) do ns = 1,is_local%wrap%num_icesheets areas => is_local%wrap%mesh_info(compglc(ns))%areas - call diag_glc(is_local%wrap%FBImp(compglc(ns),compglc(ns)), 'Fogg_rofl', f_watr_roff, ic, areas, budget_local, minus=.true., rc=rc) + call diag_glc(is_local%wrap%FBImp(compglc(ns),compglc(ns)), 'Fgrg_rofl', f_watr_roff, ic, areas, budget_local, minus=.true., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call diag_glc(is_local%wrap%FBImp(compglc(ns),compglc(ns)), 'Fogg_rofi', f_watr_ioff, ic, areas, budget_local, minus=.true., rc=rc) + call diag_glc(is_local%wrap%FBImp(compglc(ns),compglc(ns)), 'Fgrg_rofi', f_watr_ioff, ic, areas, budget_local, minus=.true., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call diag_glc(is_local%wrap%FBImp(compglc(ns),compglc(ns)), 'Figg_rofi', f_watr_ioff, ic, areas, budget_local, minus=.true., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -1533,11 +1553,21 @@ subroutine med_phases_diag_ocn( gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call diag_ocn(is_local%wrap%FBExp(compocn), 'Faxa_snow' , f_watr_snow , ic, areas, sfrac, budget_local, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + call diag_ocn(is_local%wrap%FBExp(compocn), 'Foxx_rofl' , f_watr_roff , ic, areas, sfrac, budget_local, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call diag_ocn(is_local%wrap%FBExp(compocn), 'Foxx_rofi' , f_watr_ioff , ic, areas, sfrac, budget_local, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + if ( fldbun_fldchk(is_local%wrap%FBExp(compocn), 'Forr_rofl_glc' , rc=rc)) then + call diag_ocn(is_local%wrap%FBExp(compocn), 'Forr_rofl_glc' , f_watr_roff , ic, areas, sfrac, budget_local, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if + if ( fldbun_fldchk(is_local%wrap%FBExp(compocn), 'Forr_rofi_glc' , rc=rc)) then + call diag_ocn(is_local%wrap%FBExp(compocn), 'Forr_rofi_glc' , f_watr_ioff , ic, areas, sfrac, budget_local, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if + if (flds_wiso) then call diag_ocn_wiso(is_local%wrap%FBMed_aoflux_o, 'Faox_evap_wiso', & f_watr_evap_16O, f_watr_evap_18O, f_watr_evap_HDO, ic, areas, ofrac, budget_local, rc=rc) @@ -1893,8 +1923,6 @@ subroutine med_phases_diag_ice_med2ice( gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call diag_ice_send(is_local%wrap%FBExp(compice), 'Faxa_snow', f_watr_snow, areas, lats, ifrac, budget_local, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call diag_ice_send(is_local%wrap%FBExp(compice), 'Fixx_rofi', f_watr_ioff, areas, lats, ifrac, budget_local, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return if ( fldbun_fldchk(is_local%wrap%FBExp(compice), 'Fioo_q', rc=rc)) then call fldbun_getdata1d(is_local%wrap%FBExp(compice), 'Fioo_q', data, rc=rc) @@ -1913,14 +1941,12 @@ subroutine med_phases_diag_ice_med2ice( gcomp, rc) ic = c_inh_send budget_local(f_heat_latf,ic,ip) = -budget_local(f_watr_snow,ic,ip)*shr_const_latice - budget_local(f_heat_ioff,ic,ip) = -budget_local(f_watr_ioff,ic,ip)*shr_const_latice if (trim(budget_table_version) == 'v0') then budget_local(f_watr_frz ,ic,ip) = budget_local(f_heat_frz ,ic,ip)*HFLXtoWFLX end if ic = c_ish_send budget_local(f_heat_latf,ic,ip) = -budget_local(f_watr_snow,ic,ip)*shr_const_latice - budget_local(f_heat_ioff,ic,ip) = -budget_local(f_watr_ioff,ic,ip)*shr_const_latice if (trim(budget_table_version) == 'v0') then budget_local(f_watr_frz ,ic,ip) = budget_local(f_heat_frz ,ic,ip)*HFLXtoWFLX end if diff --git a/mediator/med_fraction_mod.F90 b/mediator/med_fraction_mod.F90 index b0cd53a6..3755b8f7 100644 --- a/mediator/med_fraction_mod.F90 +++ b/mediator/med_fraction_mod.F90 @@ -10,6 +10,11 @@ module med_fraction_mod ! ifrad = fraction of ocn on a grid at last radiation time ! ofrad = fraction of ice on a grid at last radiation time ! + ! ofrad = fraction of ice on a grid at last radiation time + ! afrac, lfrac, ifrac, and ofrac are the self-consistent values in the + ! system. lfrin is the fraction on the land grid and is allowed to + ! vary from the self-consistent value as descibed below. ifrad + ! and ofrad are needed for the swnet calculation. ! lfrac, ifrac, and ofrac: ! are the self-consistent values in the system ! ifrad and ofrad: @@ -17,12 +22,12 @@ module med_fraction_mod ! ! the fractions fields are defined for each grid in the fraction bundles as ! needed as follows. - ! character(*),parameter :: fraclist_a = 'ifrac:ofrac:lfrac:aofrac + ! character(*),parameter :: fraclist_a = 'ifrac:ofrac:lfrac:lfrin:aofrac ! character(*),parameter :: fraclist_o = 'ifrac:ofrac:ifrad:ofrad' ! character(*),parameter :: fraclist_i = 'ifrac:ofrac' - ! character(*),parameter :: fraclist_l = 'lfrac' - ! character(*),parameter :: fraclist_g = 'gfrac:lfrac' - ! character(*),parameter :: fraclist_r = 'lfrac:rfrac' + ! character(*),parameter :: fraclist_l = 'lfrac:lfrin' + ! character(*),parameter :: fraclist_g = 'gfrac:lfrac:lfrin' + ! character(*),parameter :: fraclist_r = 'rfrac:lfrac:lfrin' ! ! we assume ocean and ice are on the same grids, same masks ! we assume ocn2atm and ice2atm are masked maps @@ -44,6 +49,9 @@ module med_fraction_mod ! where fractions_* are a bundle of fractions on a particular grid and ! *frac is the fraction of a particular component in the bundle. ! + ! in general, on every grid, + ! fractions_*(ifrac) + fractions_*(ofrac) + fractions_*(lfrac) = 1.0 + ! ! the fractions are computed fundamentally as follows (although the ! detailed implementation might be slightly different) ! @@ -52,8 +60,12 @@ module med_fraction_mod ! fractions_*(ifrac) = 0.0 ! fractions/masks provided by surface components ! fractions_o(ofrac) = ocean "mask" provided by ocean + ! fractions_l(lfrin) = Sl_lfrin ! land model fraction computed as + ! map of ocean mask to land grid ! then mapped to the atm model ! fractions_a(ofrac) = mapo2a(fractions_o(ofrac)) + ! fractions_a(lfrin) = mapl2a(fractions_l(lfrin)) + ! ! and a few things are then derived ! fractions_a(lfrac) = 1.0 - fractions_a(ofrac) ! this is truncated to zero for very small values (< 0.001) @@ -79,8 +91,8 @@ module med_fraction_mod ! fraction corrections in mapping are as follows ! mapo2a uses *fractions_o(ofrac) and /fractions_a(ofrac) ! mapi2a uses *fractions_i(ifrac) and /fractions_a(ifrac) - ! mapl2a uses *fractions_l(lfrac) - ! mapl2g weights by fractions_l(lfrac) with normalization and multiplies by fractions_g(lfrac) + ! mapl2a uses *fractions_l(lfrin) and /fractions_a(lfrin) + ! mapl2g weights by fractions_l(lfrin) with normalization and multiplies by fractions_g(lfrin) ??? ! ! run time: ! fractions_a(lfrac) + fractions_a(ofrac) + fractions_a(ifrac) ~ 1.0 @@ -95,6 +107,19 @@ module med_fraction_mod ! is_local%wrap%FBImp(compocn,compocn) => 'So_omask' ! is_local%wrap%FBImp(compice,compice) => 'Si_ifrac' (runtime) ! + ! NOTE: In trigrid configurations, lfrin MUST be defined as the + ! conservative o2l mapping of the complement of the ocean mask. + ! In non-trigrid configurations, lfrin is generally associated with + ! the fraction of land grid defined by the surface dataset and might + ! be 1 everywhere for instance. In many cases, the non-trigrid + ! lfrin is defined to be the conservative o2a mapping of the complement + ! of the ocean mask. In this case, it is defined the same as the + ! trigrid. But to support all cases, + ! for trigrid: + ! mapping from the land grid should use the lfrin field (same in non-trigrid) + ! budget diagnostics should use lfrin (lfrac in non-trigrid) + ! merges in the atm should use lfrac (same in non-trigrid) + ! the runoff should use the lfrin fraction in the runoff merge (lfrac in non-trigrid) !----------------------------------------------------------------------------- use med_kind_mod , only : CX =>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8 @@ -109,7 +134,7 @@ module med_fraction_mod use med_methods_mod , only : fldbun_init => med_methods_FB_init use med_methods_mod , only : fldbun_reset => med_methods_FB_reset use med_map_mod , only : med_map_field - use med_internalstate_mod , only : ncomps + use med_internalstate_mod , only : ncomps, samegrid_atmlnd implicit none private @@ -118,15 +143,15 @@ module med_fraction_mod public med_fraction_init public med_fraction_set - integer, parameter :: nfracs = 5 - character(len=6),allocatable :: fraclist(:,:) - character(len=6),parameter,dimension(4) :: fraclist_a = (/'ifrac ','ofrac ','lfrac ','aofrac'/) - character(len=6),parameter,dimension(4) :: fraclist_o = (/'ifrac ','ofrac ','ifrad ','ofrad '/) - character(len=6),parameter,dimension(2) :: fraclist_i = (/'ifrac ','ofrac '/) - character(len=6),parameter,dimension(1) :: fraclist_l = (/'lfrac '/) - character(len=6),parameter,dimension(2) :: fraclist_g = (/'gfrac ','lfrac '/) - character(len=6),parameter,dimension(2) :: fraclist_r = (/'rfrac ','lfrac '/) - character(len=6),parameter,dimension(1) :: fraclist_w = (/'wfrac '/) + integer, parameter :: nfracs = 5 + character(len=6),allocatable :: fraclist(:,:) + character(len=6),parameter :: fraclist_a(5) = (/'ifrac ','ofrac ','lfrac ','lfrin ','aofrac'/) + character(len=6),parameter :: fraclist_o(4) = (/'ifrac ','ofrac ','ifrad ','ofrad '/) + character(len=6),parameter :: fraclist_i(2) = (/'ifrac ','ofrac '/) + character(len=6),parameter :: fraclist_l(2) = (/'lfrac ','lfrin '/) + character(len=6),parameter :: fraclist_g(3) = (/'gfrac ','lfrac ','lfrin '/) + character(len=6),parameter :: fraclist_r(3) = (/'rfrac ','lfrac ','lfrin '/) + character(len=6),parameter :: fraclist_w(1) = (/'wfrac '/) !--- standard --- real(R8) , parameter :: eps_fraclim = 1.0e-03 ! truncation limit in fractions_a(lfrac) @@ -169,6 +194,7 @@ subroutine med_fraction_init(gcomp, rc) real(R8), pointer :: ofrac(:) real(R8), pointer :: aofrac(:) real(R8), pointer :: lfrac(:) + real(R8), pointer :: lfrin(:) real(R8), pointer :: ifrac(:) real(R8), pointer :: gfrac(:) real(R8), pointer :: rfrac(:) @@ -251,7 +277,8 @@ subroutine med_fraction_init(gcomp, rc) endif !--------------------------------------- - ! Set 'lfrac' for FBFrac(complnd) - this might be overwritten later + ! Set 'lfrac' in FBFrac(complnd) - this might be overwritten later + ! Set 'lfrin' in FBFrac(complnd) !--------------------------------------- if (is_local%wrap%comp_present(complnd)) then @@ -262,6 +289,11 @@ subroutine med_fraction_init(gcomp, rc) if (associated(lfrac)) then lfrac(:) = Sl_lfrin(:) end if + call fldbun_getdata1d(is_local%wrap%FBFrac(complnd) , 'lfrin', lfrin, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (associated(lfrin)) then + lfrin(:) = Sl_lfrin(:) + end if end if !--------------------------------------- @@ -378,7 +410,40 @@ subroutine med_fraction_init(gcomp, rc) end if !--------------------------------------- - ! Set 'lfrac' in FBFrac(compatm) and correct 'ofrac' in FBFrac(compatm) + ! Set 'lfrin' in FBFrac(compatm) + ! --------------------------------------- + + if ( is_local%wrap%comp_present(compatm) .and. & + is_local%wrap%comp_present(complnd) .and. & + is_local%wrap%med_coupling_active(complnd,compatm)) then + + if (med_map_RH_is_created(is_local%wrap%RH(complnd,compatm,:),mapfcopy, rc=rc)) then + maptype = mapfcopy + else + maptype = mapconsd + if (.not. med_map_RH_is_created(is_local%wrap%RH(complnd,compatm,:),maptype, rc=rc)) then + if (ESMF_FieldBundleIsCreated(is_local%wrap%FBImp(complnd,compatm))) then + call med_map_routehandles_init( complnd, compatm, & + FBSrc=is_local%wrap%FBImp(complnd,complnd), & + FBDst=is_local%wrap%FBImp(complnd,compatm), & + mapindex=maptype, RouteHandle=is_local%wrap%RH, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if + end if + end if + + call ESMF_FieldBundleGet(is_local%wrap%FBfrac(complnd), 'lfrin', field=field_src, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldBundleGet(is_local%wrap%FBfrac(compatm), 'lfrin', field=field_dst, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call med_map_field(field_src, field_dst, is_local%wrap%RH(complnd,compatm,:), maptype, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + end if + + !--------------------------------------- + ! Set 'lfrac' in FBFrac(compatm) + ! Reset 'ofrac' in FBFrac(compatm) if appropriate ! --------------------------------------- ! These should actually be mapo2a of ofrac and lfrac but we can't ! map lfrac from o2a due to masked mapping weights. So we have to @@ -389,7 +454,7 @@ subroutine med_fraction_init(gcomp, rc) if (is_local%wrap%comp_present(compocn) .or. is_local%wrap%comp_present(compice)) then - ! Ocean is present + ! Ocean or ice is present call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'lfrac', lfrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'ofrac', ofrac, rc) @@ -431,20 +496,26 @@ subroutine med_fraction_init(gcomp, rc) call med_map_field(field_src, field_dst, is_local%wrap%RH(complnd,compatm,:), maptype, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'lfrac', lfrac, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! Reset ofrac in FBFrac(compatm) + if (samegrid_atmlnd) then + call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'lfrac', lfrac, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'lfrin', lfrac, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'ofrac', ofrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (associated(ofrac)) then - do n = 1,size(lfrac) - ofrac(n) = 1.0_R8 - lfrac(n) - if (abs(ofrac(n)) < eps_fraclim) then - ofrac(n) = 0.0_R8 - end if - end do + do n = 1,size(lfrac) + ofrac(n) = 1.0_R8 - lfrac(n) + if (abs(ofrac(n)) < eps_fraclim) then + ofrac(n) = 0.0_R8 + end if + end do end if - end if + end if end if !--------------------------------------- @@ -502,7 +573,7 @@ subroutine med_fraction_init(gcomp, rc) endif endif - ! Set 'lfrac' in FBFrac(comprof) + ! Set 'lfrac' and 'lfrin' in FBFrac(comprof) if (is_local%wrap%comp_present(complnd)) then maptype = mapconsd if (.not. med_map_RH_is_created(is_local%wrap%RH(complnd,comprof,:),maptype, rc=rc)) then @@ -512,17 +583,25 @@ subroutine med_fraction_init(gcomp, rc) mapindex=maptype, RouteHandle=is_local%wrap%RH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if + call ESMF_FieldBundleGet(is_local%wrap%FBfrac(complnd), 'lfrac', field=field_src, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_FieldBundleGet(is_local%wrap%FBfrac(comprof), 'lfrac', field=field_dst, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call med_map_field(field_src, field_dst, is_local%wrap%RH(complnd,comprof,:), maptype, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call ESMF_FieldBundleGet(is_local%wrap%FBfrac(complnd), 'lfrin', field=field_src, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldBundleGet(is_local%wrap%FBfrac(comprof), 'lfrin', field=field_dst, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call med_map_field(field_src, field_dst, is_local%wrap%RH(complnd,comprof,:), maptype, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return endif endif !--------------------------------------- - ! Set 'gfrac' and 'lfrac' for FBFrac(compglc) + ! Set 'gfrac', 'lfrac' and 'lfrin' in FBFrac(compglc) !--------------------------------------- do ns = 1,is_local%wrap%num_icesheets @@ -547,7 +626,7 @@ subroutine med_fraction_init(gcomp, rc) endif endif - ! Set 'lfrac' in FBFrac(compglc(ns)) + ! Set 'lfrac' and 'lfrin' in FBFrac(compglc(ns)) if ( is_local%wrap%comp_present(complnd) .and. is_local%wrap%med_coupling_active(complnd,compglc(ns))) then maptype = mapconsd if (.not. med_map_RH_is_created(is_local%wrap%RH(complnd,compglc(ns),:),maptype, rc=rc)) then @@ -557,12 +636,20 @@ subroutine med_fraction_init(gcomp, rc) mapindex=maptype, RouteHandle=is_local%wrap%RH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if + call ESMF_FieldBundleGet(is_local%wrap%FBfrac(complnd), 'lfrac', field=field_src, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_FieldBundleGet(is_local%wrap%FBfrac(compglc(ns)), 'lfrac', field=field_dst, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call med_map_field(field_src, field_dst, is_local%wrap%RH(complnd,compglc(ns),:), maptype, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call ESMF_FieldBundleGet(is_local%wrap%FBfrac(complnd), 'lfrin', field=field_src, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldBundleGet(is_local%wrap%FBfrac(compglc(ns)), 'lfrin', field=field_dst, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call med_map_field(field_src, field_dst, is_local%wrap%RH(complnd,compglc(ns),:), maptype, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return endif endif end do diff --git a/mediator/med_internalstate_mod.F90 b/mediator/med_internalstate_mod.F90 index e45331f7..d09903be 100644 --- a/mediator/med_internalstate_mod.F90 +++ b/mediator/med_internalstate_mod.F90 @@ -115,6 +115,15 @@ module med_internalstate_mod real(r8), pointer :: lons(:) => null() end type mesh_info_type + logical , public :: samegrid_atmlnd = .true. ! true=>atm and lnd are on the same grid + character(len=CS), public :: mrg_fracname_lnd2atm_state + character(len=CS), public :: mrg_fracname_lnd2atm_flux + character(len=CS), public :: map_fracname_lnd2atm + character(len=CS), public :: mrg_fracname_lnd2rof + character(len=CS), public :: map_fracname_lnd2rof + character(len=CS), public :: mrg_fracname_lnd2glc + character(len=CS), public :: map_fracname_lnd2glc + ! private internal state to keep instance data type InternalStateStruct @@ -191,11 +200,11 @@ module med_internalstate_mod type(mesh_info_type) , pointer :: mesh_info(:) type(ESMF_FieldBundle) , pointer :: FBArea(:) ! needed for mediator history writes - end type InternalStateStruct + end type InternalStateStruct - type, public :: InternalState + type, public :: InternalState type(InternalStateStruct), pointer :: wrap - end type InternalState + end type InternalState character(len=*), parameter :: u_FILE_u = & __FILE__ @@ -223,6 +232,10 @@ subroutine med_internalstate_init(gcomp, rc) character(len=CX) :: msgString character(len=3) :: name integer :: num_icesheets + character(len=CL) :: atm_mesh_name + character(len=CL) :: lnd_mesh_name + logical :: isPresent_lnd, isSet_lnd + logical :: isPresent_atm, isSet_atm character(len=*),parameter :: subname=' (internalstate init) ' !----------------------------------------------------------- @@ -230,6 +243,53 @@ subroutine med_internalstate_init(gcomp, rc) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! determine if atm and lnd have the same mesh + call NUOPC_CompAttributeGet(gcomp, name='mesh_atm', value=atm_mesh_name, & + isPresent=isPresent_atm, isSet=isSet_atm, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name='mesh_lnd', value=lnd_mesh_name, & + isPresent=isPresent_lnd, isSet=isSet_lnd, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if ((isPresent_lnd .and. isSet_lnd) .and. (isPresent_atm .and. isSet_atm)) then + if (trim(atm_mesh_name) == trim(lnd_mesh_name)) then + samegrid_atmlnd = .true. + else + samegrid_atmlnd = .false. + end if + else + samegrid_atmlnd = .true. + end if + + ! See med_fraction_mod for the following definitions + if (samegrid_atmlnd) then + map_fracname_lnd2atm = 'lfrin' ! in fraclist_a + mrg_fracname_lnd2atm_state = 'lfrac' ! in fraclist_a + mrg_fracname_lnd2atm_flux = 'lfrac' ! in fraclist_a + map_fracname_lnd2rof = 'lfrac' ! in fraclist_r + mrg_fracname_lnd2rof = 'lfrac' ! in fraclist_r + map_fracname_lnd2glc = 'lfrac' ! in fraclist_g + mrg_fracname_lnd2glc = 'lfrac' ! in fraclist_g + else + map_fracname_lnd2atm = 'lfrin' ! in fraclist_a + mrg_fracname_lnd2atm_state = 'lfrac' ! in fraclist_a + mrg_fracname_lnd2atm_flux = 'lfrin' ! in fraclist_a + map_fracname_lnd2rof = 'lfrin' ! in fraclist_r + mrg_fracname_lnd2rof = 'lfrin' ! in fraclist_r + map_fracname_lnd2glc = 'lfrin' ! in fraclist_g + mrg_fracname_lnd2rof = 'lfrin' ! in fraclist_g + endif + + if (maintask) then + write(logunit,'(a,i8)') trim(subname)//' map_fracname_lnd2atm = '//trim(map_fracname_lnd2atm) //' in fraclist_a' + write(logunit,'(a,i8)') trim(subname)//' mrg_fracname_lnd2atm_state = '//trim(mrg_fracname_lnd2atm_state)//' in fraclist_a' + write(logunit,'(a,i8)') trim(subname)//' mrg_fracname_lnd2atm_flux = '//trim(mrg_fracname_lnd2atm_flux) //' in fraclist_a' + write(logunit,'(a,i8)') trim(subname)//' map_fracname_lnd2rof = '//trim(map_fracname_lnd2rof) //' in fraclist_r' + write(logunit,'(a,i8)') trim(subname)//' mrg_fracname_lnd2rof = '//trim(mrg_fracname_lnd2rof) //' in fraclist_r' + write(logunit,'(a,i8)') trim(subname)//' map_fracname_lnd2glc = '//trim(map_fracname_lnd2glc) //' in fraclist_g' + write(logunit,'(a,i8)') trim(subname)//' mrg_fracname_lnd2rof = '//trim(mrg_fracname_lnd2rof) //' in fraclist_g' + end if + ! Determine if glc is present call NUOPC_CompAttributeGet(gcomp, name='GLC_model', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -451,9 +511,6 @@ subroutine med_internalstate_coupling(gcomp, rc) med_coupling_allowed(compice,compocn) = .true. med_coupling_allowed(comprof,compocn) = .true. med_coupling_allowed(compwav,compocn) = .true. - do ns = 1,is_local%wrap%num_icesheets - med_coupling_allowed(compglc(ns),compocn) = .true. - end do ! to ice med_coupling_allowed(compatm,compice) = .true. @@ -466,6 +523,9 @@ subroutine med_internalstate_coupling(gcomp, rc) ! to river med_coupling_allowed(complnd,comprof) = .true. + do ns = 1,is_local%wrap%num_icesheets + med_coupling_allowed(compglc(ns),comprof) = .true. + end do ! to wave med_coupling_allowed(compatm,compwav) = .true. @@ -477,7 +537,7 @@ subroutine med_internalstate_coupling(gcomp, rc) isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then - ! are multiple ocean depths for temperature and salinity sent from the ocn to glc? + ! multiple ocean depths for temperature and salinity sent from the ocn to glc read(cvalue,*) is_local%wrap%ocn2glc_coupling else is_local%wrap%ocn2glc_coupling = .false. diff --git a/mediator/med_phases_aofluxes_mod.F90 b/mediator/med_phases_aofluxes_mod.F90 index 5252e6ed..406160cb 100644 --- a/mediator/med_phases_aofluxes_mod.F90 +++ b/mediator/med_phases_aofluxes_mod.F90 @@ -149,6 +149,8 @@ module med_phases_aofluxes_mod real(R8) , pointer :: u10 (:) => null() ! diagnostic: 10m wind speed real(R8) , pointer :: duu10n (:) => null() ! diagnostic: 10m wind speed squared real(R8) , pointer :: ugust_out (:) => null() ! diagnostic: gust wind added + real(R8) , pointer :: u10_withGust(:) => null() ! diagnostic: gust wind added + real(R8) , pointer :: u10res (:) => null() ! diagnostic: no gust wind added real(R8) , pointer :: ustar (:) => null() ! saved ustar real(R8) , pointer :: re (:) => null() ! saved re real(R8) , pointer :: ssq (:) => null() ! saved sq @@ -1073,8 +1075,9 @@ 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, & add_gusts=add_gusts, & - duu10n=aoflux_out%duu10n, & + duu10n=aoflux_out%duu10n, & ugust_out = aoflux_out%ugust_out, & + u10res = aoflux_out%u10res, & ustar_sv=aoflux_out%ustar, re_sv=aoflux_out%re, ssq_sv=aoflux_out%ssq, & missval=0.0_r8) @@ -1099,7 +1102,7 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc) 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, & + duu10n=aoflux_out%duu10n, & missval=0.0_r8) #ifdef UFS_AOFLUX end if @@ -1109,7 +1112,8 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc) do n = 1,aoflux_in%lsize if (aoflux_in%mask(n) /= 0) then - aoflux_out%u10(n) = sqrt(aoflux_out%duu10n(n)) + aoflux_out%u10(n) = aoflux_out%u10res(n) + aoflux_out%u10_withGust(n) = sqrt(aoflux_out%duu10n(n)) end if enddo @@ -1712,6 +1716,13 @@ subroutine set_aoflux_out_pointers(fldbun, lsize, aoflux_out, xgrid, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call fldbun_getfldptr(fldbun, 'So_duu10n', aoflux_out%duu10n, xgrid=xgrid, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fldbun_getfldptr(fldbun, 'So_ugustOut', aoflux_out%ugust_out, xgrid=xgrid, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call fldbun_getfldptr(fldbun, 'So_u10withGust', aoflux_out%u10_withGust, xgrid=xgrid, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call fldbun_getfldptr(fldbun, 'So_u10res', aoflux_out%u10res, xgrid=xgrid, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return call fldbun_getfldptr(fldbun, 'Faox_taux', aoflux_out%taux, xgrid=xgrid, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call fldbun_getfldptr(fldbun, 'Faox_tauy', aoflux_out%tauy, xgrid=xgrid, rc=rc) diff --git a/mediator/med_phases_cdeps_mod.F90 b/mediator/med_phases_cdeps_mod.F90 index 72ac560c..4f37b6f7 100644 --- a/mediator/med_phases_cdeps_mod.F90 +++ b/mediator/med_phases_cdeps_mod.F90 @@ -7,7 +7,6 @@ module med_phases_cdeps_mod use ESMF, only: ESMF_Field, ESMF_FieldGet use ESMF, only: ESMF_FieldBundleGet, ESMF_FieldBundleIsCreated use ESMF, only: ESMF_FieldBundleCreate - use ESMF, only: ESMF_GridCompGetInternalState use ESMF, only: ESMF_SUCCESS, ESMF_LOGMSG_INFO use med_internalstate_mod, only: InternalState @@ -180,12 +179,12 @@ subroutine med_phases_cdeps_run(gcomp, rc) ! Fill file abd variable lists with data do l = 1, sdat_config%stream(streamid)%nfiles fileList(l) = trim(sdat_config%stream(streamid)%file(l)%name) - if (maintask) write(logunit,'(a,i2,x,a)') trim(subname)//": file ", l, trim(fileList(l)) + if (maintask) write(logunit,'(a,i2,2x,a)') trim(subname)//": file ", l, trim(fileList(l)) end do do l = 1, sdat_config%stream(streamid)%nvars varList(l,1) = trim(sdat_config%stream(streamid)%varlist(l)%nameinfile) varList(l,2) = trim(sdat_config%stream(streamid)%varlist(l)%nameinmodel) - if (maintask) write(logunit,'(a,i2,x,a)') trim(subname)//": variable ", l, trim(varList(l,1))//" -> "//trim(varList(l,2)) + if (maintask) write(logunit,'(a,i2,2x,a)') trim(subname)//": variable ", l, trim(varList(l,1))//" -> "//trim(varList(l,2)) end do ! Set PIO related variables diff --git a/mediator/med_phases_history_mod.F90 b/mediator/med_phases_history_mod.F90 index 52b20c03..0a6a7775 100644 --- a/mediator/med_phases_history_mod.F90 +++ b/mediator/med_phases_history_mod.F90 @@ -519,19 +519,20 @@ subroutine med_phases_history_write_med(gcomp, rc) end subroutine med_phases_history_write_med !=============================================================================== - subroutine med_phases_history_write_lnd2glc(gcomp, fldbun, rc) + subroutine med_phases_history_write_lnd2glc(gcomp, fldbun_lnd, rc, fldbun_glc) - ! Write yearly average of lnd -> glc fields + ! Write yearly average of lnd -> glc fields on both land and glc grids - use med_internalstate_mod, only : complnd + use med_internalstate_mod, only : complnd, compglc use med_constants_mod , only : SecPerDay => med_constants_SecPerDay use med_io_mod , only : med_io_write_time, med_io_define_time use med_io_mod , only : med_io_date2yyyymmdd, med_io_sec2hms, med_io_ymd2date ! input/output variables type(ESMF_GridComp) , intent(in) :: gcomp - type(ESMF_FieldBundle) , intent(in) :: fldbun + type(ESMF_FieldBundle) , intent(in) :: fldbun_lnd integer , intent(out) :: rc + type(ESMF_FieldBundle) , intent(in), optional :: fldbun_glc(:) ! local variables type(file_desc_t) :: io_file @@ -550,7 +551,7 @@ subroutine med_phases_history_write_lnd2glc(gcomp, fldbun, rc) real(r8) :: time_val ! time coordinate output real(r8) :: time_bnds(2) ! time bounds output character(len=CL) :: hist_file - integer :: m + integer :: m,n logical :: isPresent character(len=*), parameter :: subname='(med_phases_history_write_lnd2glc)' !--------------------------------------- @@ -623,9 +624,21 @@ subroutine med_phases_history_write_lnd2glc(gcomp, fldbun, rc) call med_io_write_time(io_file, time_val, time_bnds, nt=1, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if - call med_io_write(io_file, fldbun, whead(m), wdata(m), is_local%wrap%nx(complnd), is_local%wrap%ny(complnd), & + + call med_io_write(io_file, fldbun_lnd, whead(m), wdata(m), & + is_local%wrap%nx(complnd), is_local%wrap%ny(complnd), & nt=1, pre=trim(compname(complnd))//'Imp', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (present(fldbun_glc)) then + do n = 1,size(fldbun_glc) + call med_io_write(io_file, fldbun_glc(n), whead(m), wdata(m), & + is_local%wrap%nx(compglc(n)), is_local%wrap%ny(compglc(n)), & + nt=1, pre=trim(compname(compglc(n)))//'Exp', rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do ! end of loop over m ! Close history file diff --git a/mediator/med_phases_post_glc_mod.F90 b/mediator/med_phases_post_glc_mod.F90 index ac32ae8b..959f2873 100644 --- a/mediator/med_phases_post_glc_mod.F90 +++ b/mediator/med_phases_post_glc_mod.F90 @@ -68,7 +68,7 @@ module med_phases_post_glc_mod logical :: cism_evolve = .false. logical :: glc2lnd_coupling = .false. - logical :: glc2ocn_coupling = .false. + logical :: glc2rof_coupling = .false. logical :: glc2ice_coupling = .false. character(*) , parameter :: u_FILE_u = & @@ -120,8 +120,8 @@ subroutine med_phases_post_glc(gcomp, rc) end do ! determine if there will be any glc to ocn coupling do ns = 1,is_local%wrap%num_icesheets - if (is_local%wrap%med_coupling_active(compglc(ns),compocn)) then - glc2ocn_coupling = .true. + if (is_local%wrap%med_coupling_active(compglc(ns),comprof)) then + glc2rof_coupling = .true. exit end if end do @@ -134,7 +134,7 @@ subroutine med_phases_post_glc(gcomp, rc) end do if (maintask) then write(logunit,'(a,L1)') trim(subname) // 'glc2lnd_coupling is ',glc2lnd_coupling - write(logunit,'(a,L1)') trim(subname) // 'glc2ocn_coupling is ',glc2ocn_coupling + write(logunit,'(a,L1)') trim(subname) // 'glc2rof_coupling is ',glc2rof_coupling write(logunit,'(a,L1)') trim(subname) // 'glc2ice_coupling is ',glc2ice_coupling end if @@ -152,19 +152,19 @@ subroutine med_phases_post_glc(gcomp, rc) end if !--------------------------------------- - ! glc->ocn mapping - ! merging with rof->ocn fields is done in med_phases_prep_ocn + ! glc->rof mapping !--------------------------------------- - if (glc2ocn_coupling) then + + if (glc2rof_coupling) then do ns = 1,is_local%wrap%num_icesheets - if (is_local%wrap%med_coupling_active(compglc(ns),compocn)) then + if (is_local%wrap%med_coupling_active(compglc(ns),comprof)) then call med_map_field_packed( & FBSrc=is_local%wrap%FBImp(compglc(ns),compglc(ns)), & - FBDst=is_local%wrap%FBImp(compglc(ns),compocn), & + FBDst=is_local%wrap%FBImp(compglc(ns),comprof), & FBFracSrc=is_local%wrap%FBFrac(compglc(ns)), & - field_normOne=is_local%wrap%field_normOne(compglc(ns),compocn,:), & - packed_data=is_local%wrap%packed_data(compglc(ns),compocn,:), & - routehandles=is_local%wrap%RH(compglc(ns),compocn,:), rc=rc) + field_normOne=is_local%wrap%field_normOne(compglc(ns),comprof,:), & + packed_data=is_local%wrap%packed_data(compglc(ns),comprof,:), & + routehandles=is_local%wrap%RH(compglc(ns),comprof,:), rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if end do diff --git a/mediator/med_phases_post_ocn_mod.F90 b/mediator/med_phases_post_ocn_mod.F90 index bfc23450..b253de66 100644 --- a/mediator/med_phases_post_ocn_mod.F90 +++ b/mediator/med_phases_post_ocn_mod.F90 @@ -83,6 +83,7 @@ subroutine med_phases_post_ocn(gcomp, rc) ! Accumulate ocn input for glc if there is ocn->glc coupling if (is_local%wrap%ocn2glc_coupling) then + call ESMF_LogWrite(subname//' DEBUG: calling med_phases_prep_glc_accum_ocn', ESMF_LOGMSG_INFO) call med_phases_prep_glc_accum_ocn(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if diff --git a/mediator/med_phases_post_rof_mod.F90 b/mediator/med_phases_post_rof_mod.F90 index aafeec01..f58c901d 100644 --- a/mediator/med_phases_post_rof_mod.F90 +++ b/mediator/med_phases_post_rof_mod.F90 @@ -2,10 +2,49 @@ module med_phases_post_rof_mod ! Post rof phase, if appropriate, map initial rof->lnd, rof->ocn, rof->ice + use NUOPC_Mediator , only : NUOPC_MediatorGet + use NUOPC , only : NUOPC_CompAttributeGet + use ESMF , only : ESMF_Clock, ESMF_ClockIsCreated + use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_LOGMSG_ERROR, ESMF_SUCCESS, ESMF_FAILURE + use ESMF , only : ESMF_GridComp, ESMF_GridCompGet + use ESMF , only : ESMF_Mesh, ESMF_MESHLOC_ELEMENT, ESMF_TYPEKIND_R8 + use ESMF , only : ESMF_Field, ESMF_FieldCreate + use ESMF , only : ESMF_FieldBundle, ESMF_FieldBundleCreate + use ESMF , only : ESMF_FieldBundleGet, ESMF_FieldBundleAdd + use ESMF , only : ESMF_VM, ESMF_VMAllreduce, ESMF_REDUCE_SUM + use med_kind_mod , only : CX=>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8 + use med_internalstate_mod , only : complnd, compocn, compice, comprof + use med_internalstate_mod , only : InternalState, maintask, logunit + use med_utils_mod , only : chkerr => med_utils_ChkErr + use med_constants_mod , only : dbug_flag => med_constants_dbug_flag + use med_phases_history_mod, only : med_phases_history_write_comp + use med_map_mod , only : med_map_field_packed + use med_methods_mod , only : fldbun_getdata1d => med_methods_FB_getdata1d + use med_methods_mod , only : fldbun_getmesh => med_methods_FB_getmesh + use perf_mod , only : t_startf, t_stopf + use shr_sys_mod , only : shr_sys_abort + implicit none private - public :: med_phases_post_rof + public :: med_phases_post_rof_init + public :: med_phases_post_rof + private :: med_phases_post_rof_create_rof_field_bundle + private :: med_phases_post_rof_remove_negative_runoff + + ! A local FieldBundle to hold a copy of rof fields, so that when we modify them, we + ! aren't modifying the import fields in-place. + type(ESMF_FieldBundle) :: FBrof_r + integer :: num_rof_fields + character(len=CS), allocatable :: rof_field_names(:) + + logical :: remove_negative_runoff + + character(len=13), parameter :: fields_to_remove_negative_runoff(4) = & + ['Forr_rofl ', & + 'Forr_rofi ', & + 'Forr_rofl_glc', & + 'Forr_rofi_glc'] character(*) , parameter :: u_FILE_u = & __FILE__ @@ -14,20 +53,62 @@ module med_phases_post_rof_mod contains !================================================================================================ - subroutine med_phases_post_rof(gcomp, rc) + subroutine med_phases_post_rof_init(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(CL) :: cvalue + logical :: isPresent, isSet + logical :: flds_wiso + + character(len=*), parameter :: subname='(med_phases_post_rof_init)' + !--------------------------------------- - use NUOPC_Mediator , only : NUOPC_MediatorGet - use ESMF , only : ESMF_Clock, ESMF_ClockIsCreated - use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_LOGMSG_ERROR, ESMF_SUCCESS, ESMF_FAILURE - use ESMF , only : ESMF_GridComp, ESMF_GridCompGet - use med_kind_mod , only : CX=>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8 - use med_internalstate_mod , only : complnd, compocn, compice, comprof - use med_utils_mod , only : chkerr => med_utils_ChkErr - use med_constants_mod , only : dbug_flag => med_constants_dbug_flag - use med_internalstate_mod , only : InternalState - use med_phases_history_mod, only : med_phases_history_write_comp - use med_map_mod , only : med_map_field_packed - use perf_mod , only : t_startf, t_stopf + rc = ESMF_SUCCESS + + call t_startf('MED:'//subname) + if (dbug_flag > 20) then + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) + end if + + call med_phases_post_rof_create_rof_field_bundle(gcomp, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call NUOPC_CompAttributeGet(gcomp, name='remove_negative_runoff', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + read(cvalue,*) remove_negative_runoff + else + remove_negative_runoff = .false. + end if + + ! remove_negative_runoff isn't yet set up to handle isotope fields, so ensure that + ! this isn't set along with flds_wiso + call NUOPC_CompAttributeGet(gcomp, name='flds_wiso', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + read(cvalue,*) flds_wiso + else + flds_wiso = .false. + end if + if (remove_negative_runoff .and. flds_wiso) then + call shr_sys_abort('remove_negative_runoff must be set to false when flds_wiso is true') + end if + + if (maintask) then + write(logunit,'(a,l7)') trim(subname)//' remove_negative_runoff = ', remove_negative_runoff + end if + + if (dbug_flag > 20) then + call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) + end if + call t_stopf('MED:'//subname) + end subroutine med_phases_post_rof_init + + subroutine med_phases_post_rof(gcomp, rc) ! input/output variables type(ESMF_GridComp) :: gcomp @@ -36,6 +117,10 @@ subroutine med_phases_post_rof(gcomp, rc) ! local variables type(InternalState) :: is_local type(ESMF_Clock) :: dClock + real(r8), pointer :: data_orig(:) + real(r8), pointer :: data_copy(:) + integer :: n + logical :: exists character(len=*), parameter :: subname='(med_phases_post_rof)' !--------------------------------------- @@ -50,11 +135,30 @@ subroutine med_phases_post_rof(gcomp, rc) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + do n = 1, num_rof_fields + call fldbun_getdata1d(is_local%wrap%FBImp(comprof,comprof), trim(rof_field_names(n)), data_orig, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call fldbun_getdata1d(FBrof_r, trim(rof_field_names(n)), data_copy, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + data_copy(:) = data_orig(:) + end do + + if (remove_negative_runoff) then + do n = 1, size(fields_to_remove_negative_runoff) + call ESMF_FieldBundleGet(FBrof_r, fieldName=trim(fields_to_remove_negative_runoff(n)), isPresent=exists, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (exists) then + call med_phases_post_rof_remove_negative_runoff(gcomp, fields_to_remove_negative_runoff(n), rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if + end do + end if + ! map rof to lnd if (is_local%wrap%med_coupling_active(comprof,complnd)) then call t_startf('MED:'//trim(subname)//' map_rof2lnd') call med_map_field_packed( & - FBSrc=is_local%wrap%FBImp(comprof,comprof), & + FBSrc=FBrof_r, & FBDst=is_local%wrap%FBImp(comprof,complnd), & FBFracSrc=is_local%wrap%FBFrac(comprof), & field_normOne=is_local%wrap%field_normOne(comprof,complnd,:), & @@ -67,7 +171,7 @@ subroutine med_phases_post_rof(gcomp, rc) if (is_local%wrap%med_coupling_active(comprof,compocn)) then call t_startf('MED:'//trim(subname)//' map_rof2ocn') call med_map_field_packed( & - FBSrc=is_local%wrap%FBImp(comprof,comprof), & + FBSrc=FBrof_r, & FBDst=is_local%wrap%FBImp(comprof,compocn), & FBFracSrc=is_local%wrap%FBFrac(comprof), & field_normOne=is_local%wrap%field_normOne(comprof,compocn,:), & @@ -80,7 +184,7 @@ subroutine med_phases_post_rof(gcomp, rc) if (is_local%wrap%med_coupling_active(comprof,compice)) then call t_startf('MED:'//trim(subname)//' map_rof2ice') call med_map_field_packed( & - FBSrc=is_local%wrap%FBImp(comprof,comprof), & + FBSrc=FBrof_r, & FBDst=is_local%wrap%FBImp(comprof,compice), & FBFracSrc=is_local%wrap%FBFrac(comprof), & field_normOne=is_local%wrap%field_normOne(comprof,compice,:), & @@ -105,4 +209,196 @@ subroutine med_phases_post_rof(gcomp, rc) end subroutine med_phases_post_rof + subroutine med_phases_post_rof_create_rof_field_bundle(gcomp, rc) + !--------------------------------------------------------------- + ! Create FBrof_r + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(InternalState) :: is_local + integer :: n + type(ESMF_Mesh) :: mesh + type(ESMF_Field) :: field + integer, parameter :: dbug_threshold = 20 ! threshold for writing debug information in this subroutine + character(len=*), parameter :: subname='(med_phases_post_rof_mod: med_phases_post_rof_create_rof_field_bundle)' + !--------------------------------------- + + rc = ESMF_SUCCESS + + call t_startf('MED:'//subname) + if (dbug_flag > dbug_threshold) then + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) + end if + + nullify(is_local%wrap) + call ESMF_GridCompGetInternalState(gcomp, is_local, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call fldbun_getmesh(is_local%wrap%FBImp(comprof,comprof), mesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_FieldBundleGet(is_local%wrap%FBImp(comprof,comprof), fieldCount=num_rof_fields, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(rof_field_names(num_rof_fields)) + call ESMF_FieldBundleGet(is_local%wrap%FBImp(comprof,comprof), fieldNameList=rof_field_names, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Note that, for simplicity, we'll add all rof fields to this local FieldBundle, even + ! though we only need to modify a subset of the fields. + FBrof_r = ESMF_FieldBundleCreate(name='FBrof_r', rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + do n = 1, num_rof_fields + field = ESMF_FieldCreate(mesh, ESMF_TYPEKIND_R8, name=rof_field_names(n), meshloc=ESMF_MESHLOC_ELEMENT, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldBundleAdd(FBrof_r, (/field/), rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end do + + if (dbug_flag > dbug_threshold) then + call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) + end if + call t_stopf('MED:'//subname) + + end subroutine med_phases_post_rof_create_rof_field_bundle + + subroutine med_phases_post_rof_remove_negative_runoff(gcomp, field_name, rc) + !--------------------------------------------------------------- + ! For one runoff field, remove negative runoff by downweighting all positive runoff to + ! spread the negative runoff globally. + + ! input/output variables + type(ESMF_GridComp) :: gcomp + character(len=*), intent(in) :: field_name ! name of runoff flux field to process + integer, intent(out) :: rc + + ! local variables + type(InternalState) :: is_local + type(ESMF_VM) :: vm + real(r8), pointer :: runoff_flux(:) ! temporary 1d pointer + real(r8), pointer :: areas(:) + real(r8) :: local_positive(1), global_positive(1) + real(r8) :: local_negative(1), global_negative(1) + real(r8) :: global_sum + real(r8) :: multiplier + real(r8) :: local_positive_final(1), global_positive_final(1) + real(r8) :: local_negative_final(1), global_negative_final(1) + real(r8) :: global_sum_final + integer :: n + + integer, parameter :: dbug_threshold = 20 ! threshold for writing debug information in this subroutine + character(len=*), parameter :: subname='(med_phases_post_rof_mod: med_phases_post_rof_remove_negative_runoff)' + !--------------------------------------- + + rc = ESMF_SUCCESS + + call t_startf('MED:'//subname) + if (dbug_flag > dbug_threshold) then + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) + end if + + nullify(is_local%wrap) + call ESMF_GridCompGetInternalState(gcomp, is_local, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Note that we don't use rof fractions in the global sum. This is consistent with the + ! global budget calculations in med_diag_mod and is because the rof fractions are 1 + ! everywhere. + areas => is_local%wrap%mesh_info(comprof)%areas + + call fldbun_getdata1d(FBrof_r, trim(field_name), runoff_flux, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + local_positive(1) = 0.0_r8 + local_negative(1) = 0.0_r8 + do n = 1, size(runoff_flux) + if (runoff_flux(n) >= 0.0_r8) then + local_positive(1) = local_positive(1) + areas(n) * runoff_flux(n) + else + local_negative(1) = local_negative(1) + areas(n) * runoff_flux(n) + end if + end do + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMAllreduce(vm, senddata=local_positive, recvdata=global_positive, count=1, & + reduceflag=ESMF_REDUCE_SUM, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMAllreduce(vm, senddata=local_negative, recvdata=global_negative, count=1, & + reduceflag=ESMF_REDUCE_SUM, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + global_sum = global_positive(1) + global_negative(1) + if (maintask .and. dbug_flag > dbug_threshold) then + write(logunit,'(a)') subname//' Before correction: '//trim(field_name) + write(logunit,'(a,e27.17)') subname//' global_positive = ', global_positive(1) + write(logunit,'(a,e27.17)') subname//' global_negative = ', global_negative(1) + write(logunit,'(a,e27.17)') subname//' global_sum = ', global_sum + end if + + if (global_sum > 0.0_r8) then + ! There is enough positive runoff to absorb all of the negative runoff; so set + ! negative runoff to 0 and downweight positive runoff to conserve. + multiplier = global_sum/global_positive(1) + do n = 1, size(runoff_flux) + if (runoff_flux(n) > 0.0_r8) then + runoff_flux(n) = runoff_flux(n) * multiplier + else + runoff_flux(n) = 0.0_r8 + end if + end do + else if (global_sum < 0.0_r8) then + ! There is more negative than positive runoff. Hopefully this happens rarely, if + ! ever; so set positive runoff to 0 and downweight negative runoff to minimize + ! negative runoff and conserve. + multiplier = global_sum/global_negative(1) + do n = 1, size(runoff_flux) + if (runoff_flux(n) < 0.0_r8) then + runoff_flux(n) = runoff_flux(n) * multiplier + else + runoff_flux(n) = 0.0_r8 + end if + end do + else + ! global_sum == 0 - i.e., positive and negative exactly balance (very rare, unless + ! the fluxes are already 0 everywhere!); set all fluxes to 0 in this case. + do n = 1, size(runoff_flux) + runoff_flux(n) = 0.0_r8 + end do + end if + + if (dbug_flag > dbug_threshold) then + ! Recompute positives, negatives and total sum for output diagnostic purposes + local_positive_final(1) = 0.0_r8 + local_negative_final(1) = 0.0_r8 + do n = 1, size(runoff_flux) + if (runoff_flux(n) >= 0.0_r8) then + local_positive_final(1) = local_positive_final(1) + areas(n) * runoff_flux(n) + else + local_negative_final(1) = local_negative_final(1) + areas(n) * runoff_flux(n) + end if + end do + call ESMF_VMAllreduce(vm, senddata=local_positive_final, recvdata=global_positive_final, count=1, & + reduceflag=ESMF_REDUCE_SUM, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMAllreduce(vm, senddata=local_negative_final, recvdata=global_negative_final, count=1, & + reduceflag=ESMF_REDUCE_SUM, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + global_sum_final = global_positive_final(1) + global_negative_final(1) + if (maintask) then + write(logunit,'(a)') subname//' After correction: '//trim(field_name) + write(logunit,'(a,e27.17)') subname//' global_positive_final = ', global_positive_final(1) + write(logunit,'(a,e27.17)') subname//' global_negative_final = ', global_negative_final(1) + write(logunit,'(a,e27.17)') subname//' global_sum_final = ', global_sum_final + end if + end if + + if (dbug_flag > dbug_threshold) then + call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) + end if + call t_stopf('MED:'//subname) + + end subroutine med_phases_post_rof_remove_negative_runoff + end module med_phases_post_rof_mod diff --git a/mediator/med_phases_prep_atm_mod.F90 b/mediator/med_phases_prep_atm_mod.F90 index b9e7582e..c4d872d1 100644 --- a/mediator/med_phases_prep_atm_mod.F90 +++ b/mediator/med_phases_prep_atm_mod.F90 @@ -17,7 +17,7 @@ module med_phases_prep_atm_mod use med_methods_mod , only : FB_check_for_nans => med_methods_FB_check_for_nans use med_merge_mod , only : med_merge_auto use med_map_mod , only : med_map_field_packed - use med_internalstate_mod , only : InternalState, maintask, logunit + use med_internalstate_mod , only : InternalState, maintask, logunit, samegrid_atmlnd use med_internalstate_mod , only : compatm, compocn, compice, compname, coupling_mode use esmFlds , only : med_fldlist_GetfldListTo, med_fldlist_type use perf_mod , only : t_startf, t_stopf @@ -32,6 +32,9 @@ module med_phases_prep_atm_mod real(r8), public :: global_htot_corr(1) = 0._r8 ! enthalpy correction from med_phases_prep_ocn + character(len=13) :: fldnames_from_ocn(5) = (/'Faoo_fbrf_ocn','Faoo_fdms_ocn','Faoo_fco2_ocn',& + 'Faoo_fn2o_ocn','Faoo_fnh3_ocn'/) + character(*), parameter :: u_FILE_u = & __FILE__ @@ -52,7 +55,7 @@ subroutine med_phases_prep_atm(gcomp, rc) real(R8), pointer :: dataPtr2(:) real(R8), pointer :: ifrac(:) real(R8), pointer :: ofrac(:) - integer :: n + integer :: n,nf type(med_fldlist_type), pointer :: fldList character(len=*),parameter :: subname='(med_phases_prep_atm)' !------------------------------------------------------------------------------- @@ -183,8 +186,13 @@ subroutine med_phases_prep_atm(gcomp, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call ESMF_FieldGet(lfield, farrayPtr=dataptr1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldBundleGet(is_local%wrap%FBFrac(compatm), fieldName='lfrac', field=lfield, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + if (samegrid_atmlnd) then + call ESMF_FieldBundleGet(is_local%wrap%FBFrac(compatm), fieldName='lfrac', field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + call ESMF_FieldBundleGet(is_local%wrap%FBFrac(compatm), fieldName='lfrin', field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if call ESMF_FieldGet(lfield, farrayPtr=dataptr2, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return do n = 1,size(dataptr1) @@ -194,30 +202,33 @@ subroutine med_phases_prep_atm(gcomp, rc) ! Note - the following needs a custom merge since Faoo_fco2_ocn is scaled by (ifrac+ofrac) ! in the merge to the atm - if ( FB_FldChk(is_local%wrap%FBExp(compatm) , 'Faoo_fco2_ocn', rc=rc) .and. & - FB_FldChk(is_local%wrap%FBImp(compocn,compocn), 'Faoo_fco2_ocn', rc=rc)) then - call ESMF_FieldGet(lfield, farrayPtr=dataptr1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldBundleGet(is_local%wrap%FBFrac(compatm), fieldName='ifrac', field=lfield, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldGet(lfield, farrayPtr=ifrac, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldBundleGet(is_local%wrap%FBFrac(compatm), fieldName='ofrac', field=lfield, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldGet(lfield, farrayPtr=ofrac, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldBundleGet(is_local%wrap%FBImp(compocn,compatm), fieldName='Faoo_fco2_ocn', field=lfield, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldGet(lfield, farrayPtr=dataptr1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldBundleGet(is_local%wrap%FBExp(compatm), fieldName='Faoo_fco2_ocn', field=lfield, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldGet(lfield, farrayPtr=dataptr2, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - do n = 1,size(dataptr2) + call ESMF_FieldBundleGet(is_local%wrap%FBFrac(compatm), fieldName='ifrac', field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldGet(lfield, farrayPtr=ifrac, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldBundleGet(is_local%wrap%FBFrac(compatm), fieldName='ofrac', field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldGet(lfield, farrayPtr=ofrac, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + do nf = 1,size(fldnames_from_ocn) + if ( FB_FldChk(is_local%wrap%FBExp(compatm) , trim(fldnames_from_ocn(nf)), rc=rc) .and. & + FB_FldChk(is_local%wrap%FBImp(compocn,compocn), trim(fldnames_from_ocn(nf)), rc=rc)) then + call ESMF_FieldBundleGet(is_local%wrap%FBImp(compocn,compatm), & + fieldName=trim(fldnames_from_ocn(nf)), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldGet(lfield, farrayPtr=dataptr1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldBundleGet(is_local%wrap%FBExp(compatm), & + fieldName=trim(fldnames_from_ocn(nf)), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldGet(lfield, farrayPtr=dataptr2, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do n = 1,size(dataptr2) dataptr2(n) = (ifrac(n) + ofrac(n)) * dataptr1(n) - end do - end if + end do + end if + end do ! Add enthalpy correction to sensible heat if appropriate if (FB_FldChk(is_local%wrap%FBExp(compatm), 'Faxx_sen', rc=rc)) then diff --git a/mediator/med_phases_prep_glc_mod.F90 b/mediator/med_phases_prep_glc_mod.F90 index 920fb415..1681aa9b 100644 --- a/mediator/med_phases_prep_glc_mod.F90 +++ b/mediator/med_phases_prep_glc_mod.F90 @@ -20,9 +20,9 @@ module med_phases_prep_glc_mod use ESMF , only : ESMF_Field, ESMF_FieldGet, ESMF_FieldCreate use ESMF , only : ESMF_Mesh, ESMF_MESHLOC_ELEMENT, ESMF_TYPEKIND_R8, ESMF_KIND_R8 use ESMF , only : ESMF_DYNAMICMASK, ESMF_DynamicMaskSetR8R8R8, ESMF_DYNAMICMASKELEMENTR8R8R8 - use ESMF , only : ESMF_FieldRegrid + use ESMF , only : ESMF_FieldRegrid, ESMF_REGION_EMPTY use med_internalstate_mod , only : complnd, compocn, mapbilnr, mapconsd, compname, compglc - use med_internalstate_mod , only : InternalState, maintask, logunit + use med_internalstate_mod , only : InternalState, maintask, logunit, map_fracname_lnd2glc use med_map_mod , only : med_map_routehandles_init, med_map_rh_is_created use med_map_mod , only : med_map_field_normalized, med_map_field use med_constants_mod , only : dbug_flag => med_constants_dbug_flag @@ -37,6 +37,7 @@ module med_phases_prep_glc_mod use med_methods_mod , only : FB_check_for_nans => med_methods_FB_check_for_nans use med_methods_mod , only : field_getdata2d => med_methods_Field_getdata2d use med_methods_mod , only : field_getdata1d => med_methods_Field_getdata1d + use med_methods_mod , only : fldchk => med_methods_FB_FldChk use med_utils_mod , only : chkerr => med_utils_ChkErr use med_time_mod , only : med_time_alarmInit use glc_elevclass_mod , only : glc_get_num_elevation_classes @@ -106,7 +107,7 @@ module med_phases_prep_glc_mod integer , public :: ocnAccum2glc_cnt character(len=14) :: fldnames_fr_ocn(2) = (/'So_t_depth','So_s_depth'/) ! TODO: what else needs to be added here type(ESMF_DynamicMask) :: dynamicOcnMask - integer, parameter :: num_ocndepths = 7 + integer, parameter :: num_ocndepths = 30 type(ESMF_Clock) :: prepglc_clock character(*), parameter :: u_FILE_u = & @@ -319,7 +320,7 @@ subroutine med_phases_prep_glc_init(gcomp, rc) end if ! ------------------------------- - ! If ocn->glc couplng is active + ! If ocn->glc coupling is active ! ------------------------------- if (is_local%wrap%ocn2glc_coupling) then @@ -355,8 +356,8 @@ subroutine med_phases_prep_glc_init(gcomp, rc) ! Create a dynamic mask object ! The dynamic mask object further holds a pointer to the routine that will be called in order to ! handle dynamically masked elements - in this case its DynOcnMaskProc (see below) - call ESMF_DynamicMaskSetR8R8R8(dynamicOcnMask, dynamicSrcMaskValue=czero, & - dynamicMaskRoutine=DynOcnMaskProc, rc=rc) + call ESMF_DynamicMaskSetR8R8R8(dynamicOcnMask, dynamicMaskRoutine=DynOcnMaskProc, & + dynamicSrcMaskValue=1.e30_r8, handleAllElements=.true., rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return end if @@ -520,6 +521,7 @@ subroutine med_phases_prep_glc_avg(gcomp, rc) logical :: isPresent, isSet logical :: write_histaux_l2x1yrg character(len=*) , parameter :: subname=' (med_phases_prep_glc) ' + !--------------------------------------- call t_startf('MED:'//subname) @@ -618,36 +620,22 @@ subroutine med_phases_prep_glc_avg(gcomp, rc) if (do_avg) then ! Always average import from accumulated land import data do n = 1, size(fldnames_fr_lnd) - call fldbun_getdata2d(FBlndAccum2glc_l, fldnames_fr_lnd(n), data2d, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (lndAccum2glc_cnt > 0) then - ! If accumulation count is greater than 0, do the averaging - data2d(:,:) = data2d(:,:) / real(lndAccum2glc_cnt) - else - ! If accumulation count is 0, then simply set the averaged field bundle values from the land - ! to the import field bundle values - call fldbun_getdata2d(is_local%wrap%FBImp(complnd,complnd), fldnames_fr_lnd(n), data2d_import, rc) + if (fldchk(FBlndAccum2glc_l, fldnames_fr_lnd(n), rc=rc)) then + call fldbun_getdata2d(FBlndAccum2glc_l, fldnames_fr_lnd(n), data2d, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - data2d(:,:) = data2d_import(:,:) + if (lndAccum2glc_cnt > 0) then + ! If accumulation count is greater than 0, do the averaging + data2d(:,:) = data2d(:,:) / real(lndAccum2glc_cnt) + else + ! If accumulation count is 0, then simply set the averaged field bundle values from the land + ! to the import field bundle values + call fldbun_getdata2d(is_local%wrap%FBImp(complnd,complnd), fldnames_fr_lnd(n), data2d_import, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + data2d(:,:) = data2d_import(:,:) + end if end if end do - ! Write auxiliary history file if flag is set and accumulation is being done - if (lndAccum2glc_cnt > 0) then - call NUOPC_CompAttributeGet(gcomp, name="histaux_l2x1yrg", value=cvalue, & - isPresent=isPresent, isSet=isSet, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (isPresent .and. isSet) then - read(cvalue,*) write_histaux_l2x1yrg - else - write_histaux_l2x1yrg = .false. - end if - if (write_histaux_l2x1yrg) then - call med_phases_history_write_lnd2glc(gcomp, FBlndAccum2glc_l, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - end if - end if - if (is_local%wrap%ocn2glc_coupling) then ! Average import from accumulated ocn import data do n = 1, size(fldnames_fr_ocn) @@ -679,8 +667,13 @@ subroutine med_phases_prep_glc_avg(gcomp, rc) if (chkErr(rc,__LINE__,u_FILE_u)) return ! Do mapping of ocn to glc with dynamic masking call ESMF_FieldRegrid(lfield_src, lfield_dst, & - routehandle=is_local%wrap%RH(compocn,compglc(ns),mapbilnr), dynamicMask=dynamicOcnMask, rc=rc) + routehandle=is_local%wrap%RH(compocn,compglc(ns),mapbilnr), dynamicMask=dynamicOcnMask, & + zeroregion=ESMF_REGION_EMPTY, rc=rc) if (chkErr(rc,__LINE__,u_FILE_u)) return + call fldbun_getdata2d(is_local%wrap%FBExp(compglc(ns)), fldnames_fr_ocn(n), data2d, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + ! reset values of 0 to spval + where (data2d == 0._r8) data2d = shr_const_spval end do end do ocnAccum2glc_cnt = 0 @@ -688,15 +681,39 @@ subroutine med_phases_prep_glc_avg(gcomp, rc) if (chkErr(rc,__LINE__,u_FILE_u)) return end if + ! Determine if auxiliary file will be written + write_histaux_l2x1yrg = .false. + if (lndAccum2glc_cnt > 0) then + call NUOPC_CompAttributeGet(gcomp, name="histaux_l2x1yrg", value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + read(cvalue,*) write_histaux_l2x1yrg + end if + end if + + ! Write auxiliary history file if flag is set and accumulation is being done if (is_local%wrap%lnd2glc_coupling) then ! Map accumulated field bundle from land grid (with elevation classes) to glc grid (without elevation classes) ! and set FBExp(compglc(ns)) data ! Zero land accumulator and accumulated field bundles on land grid call med_phases_prep_glc_map_lnd2glc(gcomp, rc) if (chkErr(rc,__LINE__,u_FILE_u)) return + + if (write_histaux_l2x1yrg) then + call med_phases_history_write_lnd2glc(gcomp, FBlndAccum2glc_l, & + fldbun_glc=is_local%wrap%FBExp(compglc(:)), rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if + lndAccum2glc_cnt = 0 call fldbun_reset(FBlndAccum2glc_l, value=czero, rc=rc) if (chkErr(rc,__LINE__,u_FILE_u)) return + else + if (write_histaux_l2x1yrg) then + call med_phases_history_write_lnd2glc(gcomp, FBlndAccum2glc_l, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if end if if (dbug_flag > 1) then @@ -795,8 +812,8 @@ subroutine med_phases_prep_glc_map_lnd2glc(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return ! get land fraction field on land mesh - call ESMF_FieldBundleGet(is_local%wrap%FBFrac(complnd), 'lfrac', field=field_lfrac_l, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldBundleGet(is_local%wrap%FBFrac(complnd), fieldName=map_fracname_lnd2glc, field=field_lfrac_l, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return ! map accumlated land fields to each ice sheet (normalize by the land fraction in the mapping) do ns = 1,is_local%wrap%num_icesheets @@ -1035,7 +1052,7 @@ subroutine med_phases_prep_glc_renormalize_smb(gcomp, ns, rc) real(r8) , pointer :: frac_l_ec(:,:) ! EC fractions (Sg_ice_covered) on land grid real(r8) , pointer :: icemask_g(:) ! icemask on glc grid real(r8) , pointer :: icemask_l(:) ! icemask on land grid - real(r8) , pointer :: lfrac(:) ! land fraction on land grid + real(r8) , pointer :: lndfrac(:) ! land fraction on land grid real(r8) , pointer :: dataptr1d(:) ! temporary 1d pointer integer :: ec ! loop index over elevation classes integer :: n @@ -1049,7 +1066,7 @@ subroutine med_phases_prep_glc_renormalize_smb(gcomp, ns, rc) ! renormalization factors (should be close to 1, e.g. in range 0.95 to 1.05) real(r8) :: accum_renorm_factor ! ratio between global accumulation on the two grids real(r8) :: ablat_renorm_factor ! ratio between global ablation on the two grids - real(r8) :: effective_area ! grid cell area multiplied by min(lfrac,icemask_l). + real(r8) :: effective_area ! grid cell area multiplied by min(lndfrac,icemask_l). real(r8), pointer :: area_g(:) ! areas on glc grid character(len=*), parameter :: subname=' (renormalize_smb) ' !--------------------------------------------------------------- @@ -1129,8 +1146,8 @@ subroutine med_phases_prep_glc_renormalize_smb(gcomp, ns, rc) call field_getdata2d(field_frac_l_ec, frac_l_ec, rc) if (chkErr(rc,__LINE__,u_FILE_u)) return - ! determine fraction on land grid, lfrac(:) - call fldbun_getdata1d(is_local%wrap%FBFrac(complnd), 'lfrac', lfrac, rc) + ! determine fraction on land grid, lndfrac(:) + call fldbun_getdata1d(is_local%wrap%FBFrac(complnd), map_fracname_lnd2glc, lndfrac, rc) if (chkErr(rc,__LINE__,u_FILE_u)) return ! get qice_l_ec @@ -1139,9 +1156,9 @@ subroutine med_phases_prep_glc_renormalize_smb(gcomp, ns, rc) local_accum_lnd(1) = 0.0_r8 local_ablat_lnd(1) = 0.0_r8 - do n = 1, size(lfrac) + do n = 1, size(lndfrac) ! Calculate effective area for sum - need the mapped icemask_l - effective_area = min(lfrac(n), icemask_l(n)) * is_local%wrap%mesh_info(complnd)%areas(n) + effective_area = min(lndfrac(n), icemask_l(n)) * is_local%wrap%mesh_info(complnd)%areas(n) if (effective_area > 0.0_r8) then do ec = 1, ungriddedCount if (qice_l_ec(ec,n) >= 0.0_r8) then @@ -1236,7 +1253,7 @@ subroutine dynOcnMaskProc(dynamicMaskList, dynamicSrcMaskValue, dynamicDstMaskVa integer , intent(out) :: rc ! local variables - integer :: i, j + integer :: no, ni real(ESMF_KIND_R8) :: renorm !--------------------------------------------------------------- @@ -1246,20 +1263,22 @@ subroutine dynOcnMaskProc(dynamicMaskList, dynamicSrcMaskValue, dynamicDstMaskVa ! the regridding (which is done explicitly here) if (associated(dynamicMaskList)) then - do i=1, size(dynamicMaskList) - dynamicMaskList(i)%dstElement = czero ! set to zero + do no = 1, size(dynamicMaskList) + dynamicMaskList(no)%dstElement = czero ! set to zero renorm = 0.d0 ! reset - do j = 1, size(dynamicMaskList(i)%factor) - if (dynamicSrcMaskValue /= dynamicMaskList(i)%srcElement(j)) then - dynamicMaskList(i)%dstElement = dynamicMaskList(i)%dstElement + & - (dynamicMaskList(i)%factor(j) * dynamicMaskList(i)%srcElement(j)) - renorm = renorm + dynamicMaskList(i)%factor(j) + do ni = 1, size(dynamicMaskList(no)%factor) + ! Need to multiply by .90 to handle averaging of input fields before remapping is called + if ( dynamicMaskList(no)%srcElement(ni) > 0.d0 .and. & + dynamicMaskList(no)%srcElement(ni) < dynamicSrcMaskValue*.90) then + dynamicMaskList(no)%dstElement = dynamicMaskList(no)%dstElement + & + (dynamicMaskList(no)%factor(ni) * dynamicMaskList(no)%srcElement(ni)) + renorm = renorm + dynamicMaskList(no)%factor(ni) endif enddo if (renorm > 0.d0) then - dynamicMaskList(i)%dstElement = dynamicMaskList(i)%dstElement / renorm + dynamicMaskList(no)%dstElement = dynamicMaskList(no)%dstElement / renorm else if (present(dynamicSrcMaskValue)) then - dynamicMaskList(i)%dstElement = dynamicSrcMaskValue + dynamicMaskList(no)%dstElement = dynamicSrcMaskValue else rc = ESMF_RC_ARG_BAD ! error detected return diff --git a/mediator/med_phases_prep_rof_mod.F90 b/mediator/med_phases_prep_rof_mod.F90 index 55b2dae8..f0ec87c3 100644 --- a/mediator/med_phases_prep_rof_mod.F90 +++ b/mediator/med_phases_prep_rof_mod.F90 @@ -12,7 +12,7 @@ module med_phases_prep_rof_mod use med_kind_mod , only : CX=>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8 use ESMF , only : ESMF_FieldBundle, ESMF_Field - use med_internalstate_mod , only : complnd, comprof, mapconsf, mapconsd, mapfcopy + use med_internalstate_mod , only : complnd, compglc, comprof, mapconsf, mapfcopy use med_internalstate_mod , only : InternalState, maintask, logunit use med_constants_mod , only : dbug_flag => med_constants_dbug_flag use med_constants_mod , only : czero => med_constants_czero @@ -23,6 +23,7 @@ module med_phases_prep_rof_mod use med_methods_mod , only : fldbun_reset => med_methods_FB_reset use med_methods_mod , only : fldbun_average => med_methods_FB_average use med_methods_mod , only : field_getdata1d => med_methods_Field_getdata1d + use med_methods_mod , only : fldbun_fldchk => med_methods_FB_fldchk use med_methods_mod , only : FB_check_for_nans => med_methods_FB_check_for_nans use perf_mod , only : t_startf, t_stopf @@ -61,6 +62,8 @@ module med_phases_prep_rof_mod type(ESMF_FieldBundle), public :: FBlndAccum2rof_l type(ESMF_FieldBundle), public :: FBlndAccum2rof_r + character(len=9) :: fldnames_fr_glc(2) = (/'Fgrg_rofl', 'Fgrg_rofi'/) + character(*) , parameter :: u_FILE_u = & __FILE__ @@ -276,11 +279,11 @@ subroutine med_phases_prep_rof(gcomp, rc) ! local variables type(InternalState) :: is_local - integer :: n + integer :: n,ns,nf integer :: count logical :: exists - real(r8), pointer :: dataptr(:) - real(r8), pointer :: dataptr1d(:) + real(r8), pointer :: dataptr_in(:) + real(r8), pointer :: dataptr_out(:) type(ESMF_Field) :: lfield type(med_fldList_type), pointer :: fldList character(len=*),parameter :: subname='(med_phases_prep_rof_mod: med_phases_prep_rof)' @@ -319,12 +322,12 @@ subroutine med_phases_prep_rof(gcomp, rc) if (exists) then call ESMF_FieldBundleGet(FBlndAccum2rof_l, fieldName=trim(lnd2rof_flds(n)), field=lfield, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call field_getdata1d(lfield, dataptr1d, rc=rc) + call field_getdata1d(lfield, dataptr_out, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (count == 0) then - dataptr1d(:) = czero + dataptr_out(:) = czero else - dataptr1d(:) = dataptr1d(:) / real(count, r8) + dataptr_out(:) = dataptr_out(:) / real(count, r8) end if end if end do @@ -359,12 +362,12 @@ subroutine med_phases_prep_rof(gcomp, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return else ! This will ensure that no irrig is sent from the land - call fldbun_getdata1d(FBlndAccum2rof_r, irrig_flux_field, dataptr, rc) - dataptr(:) = czero + call fldbun_getdata1d(FBlndAccum2rof_r, irrig_flux_field, dataptr_out, rc) + dataptr_out(:) = czero end if !--------------------------------------- - ! auto merges to create FBExp(comprof) - assumes that all data is coming from FBlndAccum2rof_r + ! create FBExp(comprof) !--------------------------------------- if (dbug_flag > 1) then @@ -373,10 +376,35 @@ subroutine med_phases_prep_rof(gcomp, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return end if + ! data coming from FBlndAccum2rof_r call med_merge_auto(compsrc=complnd, FBout=is_local%wrap%FBExp(comprof), & FBfrac=is_local%wrap%FBFrac(comprof), FBin=FBlndAccum2rof_r, fldListTo=fldList, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + ! custom merge for glc->rof + ! glc->rof is mapped in med_phases_post_glc + do ns = 1,is_local%wrap%num_icesheets + if (is_local%wrap%med_coupling_active(compglc(ns),comprof)) then + do nf = 1,size(fldnames_fr_glc) + if ( fldbun_fldchk(is_local%wrap%FBImp(compglc(ns),comprof), fldnames_fr_glc(nf), rc=rc) .and. & + fldbun_fldchk(is_local%wrap%FBExp(comprof), fldnames_fr_glc(nf), rc=rc) ) then + call fldbun_getdata1d(is_local%wrap%FBImp(compglc(ns),comprof), & + trim(fldnames_fr_glc(nf)), dataptr_in, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call fldbun_getdata1d(is_local%wrap%FBExp(comprof), & + trim(fldnames_fr_glc(nf)), dataptr_out , rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + ! Determine export data + if (ns == 1) then + dataptr_out(:) = dataptr_in(:) + else + dataptr_out(:) = dataptr_out(:) + dataptr_in(:) + end if + end if + end do + end if + end do + ! Check for nans in fields export to rof call FB_check_for_nans(is_local%wrap%FBExp(comprof), maintask, logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -402,9 +430,9 @@ subroutine med_phases_prep_rof(gcomp, rc) if (exists) then call ESMF_FieldBundleGet(FBlndAccum2rof_l, fieldName=trim(lnd2rof_flds(n)), field=lfield, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call field_getdata1d(lfield, dataptr1d, rc=rc) + call field_getdata1d(lfield, dataptr_out, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - dataptr1d(:) = czero + dataptr_out(:) = czero end if end do diff --git a/mediator/med_phases_profile_mod.F90 b/mediator/med_phases_profile_mod.F90 index dadfb989..dee849ae 100644 --- a/mediator/med_phases_profile_mod.F90 +++ b/mediator/med_phases_profile_mod.F90 @@ -41,7 +41,7 @@ subroutine med_phases_profile(gcomp, rc) use ESMF , only : ESMF_TimeInterval, ESMF_AlarmGet, ESMF_TimeIntervalGet use ESMF , only : ESMF_ClockGetNextTime, ESMF_TimeGet, ESMF_ClockGet use ESMF , only : ESMF_ClockAdvance, ESMF_ClockSet, ESMF_ClockIsStopTime - use ESMF , only : operator(-) + use ESMF , only : operator(-), ESMF_CALKIND_GREGORIAN use NUOPC , only : NUOPC_CompAttributeGet ! write profile output @@ -170,12 +170,13 @@ subroutine med_phases_profile(gcomp, rc) call ESMF_TimeGet(nexttime, timestring=nexttimestr, rc=rc) if (med_utils_ChkErr(rc,__LINE__,u_FILE_u)) return ! get current wall clock time - call ESMF_TimeSet(wallclocktime, rc=rc) + ! s=0 is to prevent an internal divide by 0 error in esmf + call ESMF_TimeSet(wallclockTime, calkindflag=ESMF_CALKIND_GREGORIAN, s=0, rc=rc) if (med_utils_chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSyncToRealTime(wallclocktime, rc=rc) + call ESMF_TimeSyncToRealTime(wallclockTime, rc=rc) if (med_utils_chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeGet(wallclocktime,timeString=walltimestr, rc=rc) + call ESMF_TimeGet(wallclockTime,timeString=walltimestr, rc=rc) if (med_utils_ChkErr(rc,__LINE__,u_FILE_u)) return ! 1 model day/ x seconds = 1/365 yrs/ (wallclockelapsed s/86400spd diff --git a/mediator/med_phases_restart_mod.F90 b/mediator/med_phases_restart_mod.F90 index 1bbbb0fb..6bbdb6b7 100644 --- a/mediator/med_phases_restart_mod.F90 +++ b/mediator/med_phases_restart_mod.F90 @@ -342,13 +342,14 @@ subroutine med_phases_restart_write(gcomp, rc) call med_io_write(io_file, next_tod , 'curr_tod' , whead(m), wdata(m), rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - do n = 1,ncomps + do n = 2,ncomps if (is_local%wrap%comp_present(n)) then - nx = is_local%wrap%nx(n) - ny = is_local%wrap%ny(n) if (is_local%wrap%ntile(n) > 0) then nx = is_local%wrap%ntile(n)*is_local%wrap%ny(n)*is_local%wrap%nx(n) ny = 1 + else + nx = is_local%wrap%nx(n) + ny = is_local%wrap%ny(n) end if ! Write import field bundles if (ESMF_FieldBundleIsCreated(is_local%wrap%FBimp(n,n),rc=rc)) then