Skip to content

Commit

Permalink
Merge pull request #27 from ACCESS-NRI/dougiesquire/issue388-accessom…
Browse files Browse the repository at this point in the history
…-gtracer

Use ACCESS-NRI fork of generic tracers with access couplers
  • Loading branch information
dougiesquire authored Aug 23, 2024
2 parents ca54c1b + 8614b58 commit 6d87686
Show file tree
Hide file tree
Showing 19 changed files with 1,187 additions and 169 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "generic_tracers"]
path = src/access/generic_tracers
url = https://github.com/ACCESS-NRI/GFDL-generic-tracers.git
18 changes: 12 additions & 6 deletions exp/MOM_compile.csh
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ if ( $help ) then
echo " EBM : ocean-seaice-land-atmosphere coupled model with energy balance atmosphere"
echo " ACCESS-CM : ocean component of ACCESS-CM model."
echo " ACCESS-OM : ocean component of ACCESS-OM model."
echo " ACCESS-ESM : ocean component of ACCESS-ESM model with CSIRO BGC (Wombat)."
echo " ACCESS-OM-BGC: ocean component of ACCESS-OM model with CSIRO BGC (Wombat)."
echo " ACCESS-ESM : ocean component of ACCESS-ESM model with support for generic tracer WOMBATlite."
echo " ACCESS-OM-BGC: ocean component of ACCESS-OM model with CSIRO BGC (Wombat). Wombat has now been"
echo " implemented as a generic tracer and is available in the ACCESS-OM model type."
echo " ACCESS-OM-BGC is retained only for legacy."
echo
echo "--platform followed by the platform name that has a corresponding environ file in the ../bin dir, default is gfortran"
echo
Expand Down Expand Up @@ -104,13 +106,13 @@ endif
if ( $type == EBM ) then
set cppDefs = ( "-Duse_netCDF -Duse_netCDF3 -Duse_libMPI -DLAND_BND_TRACERS -DOVERLOAD_C8 -DOVERLOAD_C4 -DOVERLOAD_R4" )
else if( $type == ACCESS-OM ) then
set cppDefs = ( "-Duse_netCDF -Duse_libMPI -DACCESS_OM" )
set cppDefs = ( "-Duse_netCDF -Duse_libMPI -DACCESS_OM -DUSE_OCEAN_BGC" )
else if( $type == ACCESS-OM-BGC ) then
set cppDefs = ( "-Duse_netCDF -Duse_libMPI -DACCESS_OM -DCSIRO_BGC" )
else if( $type == ACCESS-CM ) then
set cppDefs = ( "-Duse_netCDF -Duse_libMPI -DACCESS_CM" )
else if( $type == ACCESS-ESM ) then
set cppDefs = ( "-Duse_netCDF -Duse_libMPI -DACCESS_CM -DCSIRO_BGC" )
set cppDefs = ( "-Duse_netCDF -Duse_libMPI -DACCESS_CM -DUSE_OCEAN_BGC" )
endif

if ( $unit_testing ) then
Expand Down Expand Up @@ -221,12 +223,12 @@ if( $type == MOM_solo ) then
set srcList = ( mom5/drivers )
set libs = "$executable:h:h/lib_ocean/lib_ocean.a $executable:h:h/lib_FMS/lib_FMS.a"
else if( $type == ACCESS-CM || $type == ACCESS-ESM) then
set srcList = ( accesscm_coupler )
set srcList = ( access/accesscm_coupler )
set includes = "-I$executable:h:h/lib_FMS -I$executable:h:h/$type/lib_ocean"
set libs = "$executable:h:h/$type/lib_ocean/lib_ocean.a"
setenv OASIS true
else if( $type == ACCESS-OM || $type == ACCESS-OM-BGC) then
set srcList = ( accessom_coupler )
set srcList = ( access/accessom_coupler )
set includes = "-I$executable:h:h/lib_FMS -I$executable:h:h/$type/lib_ocean"
set libs = "$executable:h:h/$type/lib_ocean/lib_ocean.a $executable:h:h/lib_FMS/lib_FMS.a"
else if( $type == MOM_SIS ) then
Expand Down Expand Up @@ -254,6 +256,10 @@ else
exit 1
endif

if( $type == ACCESS-OM || $type == ACCESS-ESM) then
set srcList = ( $srcList access/shared )
endif

# Always include FMS
set libs = "$libs $executable:h:h/lib_FMS/lib_FMS.a"

Expand Down
4 changes: 3 additions & 1 deletion exp/ocean_compile.csh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ set lib_name = "lib_ocean"

if( $type == ACCESS-OM || $type == ACCESS-CM || $type == ACCESS-OM-BGC || $type == ACCESS-ESM) then
set srcList = ( $srcList mom5/ocean_access )
if( $type == ACCESS-OM-BGC || $type == ACCESS-ESM) then
if( $type == ACCESS-OM-BGC ) then
set srcList = ( $srcList mom5/ocean_csiro_bgc )
else if ( $type == ACCESS-OM || $type == ACCESS-ESM ) then
set srcList = ( $srcList mom5/ocean_bgc access/generic_tracers/generic_tracers access/generic_tracers/mocsy/src )
endif
mkdir -p $executable:h:h/$type/$lib_name
cd $executable:h:h/$type/$lib_name
Expand Down
9 changes: 9 additions & 0 deletions src/access/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ACCESS-specific code

This directory includes code that is specific to ACCESS-models.

[ACCESS-specific generic tracers](https://github.com/ACCESS-NRI/GFDL-generic-tracers) are included as a git submodule. To retrieve the code for the submodule run:

```bash
git submodule update --init --recursive
```
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ module mom_oasis3_interface_mod
ocean_public_type, &
ocean_domain_type
use time_manager_mod, only: time_type
use gtracer_flux_mod, only: set_coupler_type_data, extract_coupler_type_data
use coupler_types_mod, only: coupler_2d_bc_type, ind_pcair, ind_u10, ind_psurf, ind_csurf, ind_flux
use constants_mod, only: WTMCO2, hlv

! Timing

Expand Down Expand Up @@ -355,7 +358,7 @@ subroutine coupler_init(Dom, Time, Time_step_coupled, Run_len, dt_cpld)
mom_name_write(6)='frazil'
mom_name_write(7)='dssldx'
mom_name_write(8)='dssldy'
mom_name_write(9)='co2_o'
mom_name_write(9)='co2_o' ! Ocean surface pCO2 is not used by any other models
mom_name_write(10)='co2fx_o'


Expand Down Expand Up @@ -486,7 +489,7 @@ subroutine coupler_init(Dom, Time, Time_step_coupled, Run_len, dt_cpld)
end subroutine coupler_init

!=======================================================================
subroutine into_coupler(step, Ocean_sfc, Time, before_ocean_update)
subroutine into_coupler(step, Ocean_sfc, Ice_ocean_boundary, Time, before_ocean_update)
!------------------------------------------!

use ocean_operators_mod, only : GRAD_BAROTROPIC_P !GRAD_SURF_sealev
Expand All @@ -496,6 +499,7 @@ subroutine into_coupler(step, Ocean_sfc, Time, before_ocean_update)
implicit none

type (ocean_public_type) :: Ocean_sfc
type (ice_ocean_boundary_type) :: Ice_ocean_boundary
type (time_type),optional :: Time

integer, intent(in) :: step
Expand Down Expand Up @@ -561,9 +565,17 @@ subroutine into_coupler(step, Ocean_sfc, Time, before_ocean_update)
case('dssldy')
vtmp(iisd:iied,jjsd:jjed) = Ocean_sfc%gradient(iisd:iied,jjsd:jjed,2)
case('co2_o')
! Note, this is not actually used by the other models
! If this is needed in the future with generic WOMBATlite, it can be calculated from the csurf
! and alpha fields in the Ocean_sfc%fields coupler_bc_type "co2_flux" boundary condition:
! pco2 [ppmv] = 1e6 * (co2_csurf / co2_alpha)
vtmp(iisd:iied,jjsd:jjed) = Ocean_sfc%co2(iisd:iied,jjsd:jjed)
case('co2fx_o')
vtmp(iisd:iied,jjsd:jjed) = Ocean_sfc%co2flux(iisd:iied,jjsd:jjed)
! vtmp(iisd:iied,jjsd:jjed) = Ocean_sfc%co2flux(iisd:iied,jjsd:jjed)
! Extract the flux field in the IOB%fluxes coupler_bc_type "co2_flux" boundary condition,
! converting from [mol/m^2/s] to [kg(CO2)/m^2/s] and to positive downwards
call extract_coupler_type_data(Ice_ocean_boundary%fluxes, "co2_flux", ind_flux, vtmp, &
scale_factor=-1.e-3*WTMCO2, idim=(/iisc,iisc,iiec,iiec/), jdim=(/jjsc,jjsc,jjec,jjec/))
case DEFAULT
call mpp_error(FATAL,&
'==>Error from into_coupler: Unknown quantity.')
Expand Down Expand Up @@ -611,16 +623,16 @@ subroutine into_coupler(step, Ocean_sfc, Time, before_ocean_update)
end subroutine into_coupler

!-----------------------------------------------------------------------------------
subroutine from_coupler(step,Ocean_sfc,Ice_ocean_boundary, Time)
subroutine from_coupler(step,Ocean_sfc,Ice_ocean_boundary, Atm_fields, Time)

! This is all highly user dependent.

use constants_mod, only : hlv ! 2.500e6 J/kg
use auscom_ice_mod, only : chk_i2o_fields, chk_fields_period, chk_fields_start_time
implicit none

type (ocean_public_type) :: Ocean_sfc
type (ice_ocean_boundary_type) :: Ice_ocean_boundary
type (coupler_2d_bc_type) :: Atm_fields
type (time_type),optional :: Time

real, dimension(isg:ieg,jsg:jeg) :: gtmp
Expand All @@ -631,7 +643,7 @@ subroutine from_coupler(step,Ocean_sfc,Ice_ocean_boundary, Time)
frac_nir_dir=0.5*0.57, frac_nir_dif=0.5*0.57 ! shortwave partitioning

character*80 :: fname = 'fields_i2o_in_ocn.nc'
integer :: ncid,currstep,ll,ilout
integer :: ncid,currstep,ll,ilout,n
data currstep/0/
save currstep

Expand Down Expand Up @@ -723,7 +735,11 @@ subroutine from_coupler(step,Ocean_sfc,Ice_ocean_boundary, Time)
case('wfiform')
Ice_ocean_boundary%wfiform(iisc:iiec,jjsc:jjec) = vwork(iisc:iiec,jjsc:jjec)
case('co2_io')
Ice_ocean_boundary%co2(iisc:iiec,jjsc:jjec) = vwork(iisc:iiec,jjsc:jjec)
! Ice_ocean_boundary%co2(iisc:iiec,jjsc:jjec) = vwork(iisc:iiec,jjsc:jjec)
! Set the pcair field in the Atm_fields coupler_bc_type "co2_flux" boundary condition,
! converting from [ppmv] to [mol/mol]
call set_coupler_type_data(vwork, "co2_flux", ind_pcair, Atm_fields, &
scale_factor=1.e-6, idim=(/iisc,iisc,iiec,iiec/), jdim=(/jjsc,jjsc,jjec,jjec/))
case('wnd_io')
Ice_ocean_boundary%wnd(iisc:iiec,jjsc:jjec) = vwork(iisc:iiec,jjsc:jjec)
!20171024: 2 more i2o fields: water and heat fluxes due to land ice discharge into ocean
Expand Down Expand Up @@ -752,6 +768,18 @@ subroutine from_coupler(step,Ocean_sfc,Ice_ocean_boundary, Time)

if(jf .ne. 1) call mpp_clock_end(id_oasis_recv1)
enddo !jf

! Set the u10 and psurf fields in the Atm_fields coupler_bc_types
do n = 1, Atm_fields%num_bcs
if ((Atm_fields%bc(n)%flux_type .eq. 'air_sea_gas_flux_generic') .or. &
(Atm_fields%bc(n)%flux_type .eq. 'air_sea_gas_flux')) then
call set_coupler_type_data(ice_ocean_boundary%wnd, Atm_fields%bc(n)%name, ind_u10, &
Atm_fields, idim=(/iisc,iisc,iiec,iiec/), jdim=(/jjsc,jjsc,jjec,jjec/))
call set_coupler_type_data(ice_ocean_boundary%p, Atm_fields%bc(n)%name, ind_psurf, &
Atm_fields, idim=(/iisc,iisc,iiec,iiec/), jdim=(/jjsc,jjsc,jjec,jjec/))
endif
enddo

call mpp_clock_end(id_oasis_recv)

if (chk_i2o_fields .and. (mod(step, chk_fields_period) == 0) .and. (step >= chk_fields_start_time) .and. (mpp_pe() == mpp_root_pe())) then
Expand All @@ -761,13 +789,14 @@ subroutine from_coupler(step,Ocean_sfc,Ice_ocean_boundary, Time)
end subroutine from_coupler

!-----------------------------------------------------------------------------------
subroutine write_coupler_restart(step,Ocean_sfc,write_restart)
subroutine write_coupler_restart(step,Ocean_sfc,Ice_ocean_boundary,write_restart)

use auscom_ice_mod, only : auscom_ice_heatflux_new

logical, intent(in) :: write_restart
integer, intent(in) :: step
type (ocean_public_type) :: Ocean_sfc
type (ice_ocean_boundary_type) :: Ice_ocean_boundary

integer :: ncid,ll,ilout
real, dimension(iisd:iied,jjsd:jjed) :: vtmp
Expand All @@ -794,7 +823,13 @@ subroutine write_coupler_restart(step,Ocean_sfc,write_restart)
case('dssldy'); vtmp = Ocean_sfc%gradient(iisd:iied,jjsd:jjed,2); fld_ice='ssly_i'
case('frazil'); vtmp = Ocean_sfc%frazil(iisd:iied,jjsd:jjed); fld_ice='pfmice_i'
case('co2_o'); vtmp = Ocean_sfc%co2(iisd:iied,jjsd:jjed); fld_ice='co2_oi'
case('co2fx_o'); vtmp = Ocean_sfc%co2flux(iisd:iied,jjsd:jjed); fld_ice='co2fx_oi'
case('co2fx_o')
! vtmp = Ocean_sfc%co2flux(iisd:iied,jjsd:jjed); fld_ice='co2fx_oi'
! Extract the flux field in the IOB%fluxes coupler_bc_type "co2_flux" boundary condition,
! converting from [mol/m^2/s] to [kg(CO2)/m^2/s] and to positive downwards
call extract_coupler_type_data(Ice_ocean_boundary%fluxes, "co2_flux", ind_flux, vtmp, &
scale_factor=-1.e-3*WTMCO2, idim=(/iisc,iisc,iiec,iiec/), jdim=(/jjsc,jjsc,jjec,jjec/))
fld_ice='co2fx_oi'
end select

if (parallel_coupling) then
Expand Down
Loading

0 comments on commit 6d87686

Please sign in to comment.