Skip to content

Commit e6c5ddd

Browse files
Merge pull request #12 from gustavo-marques/fill_ice_ocean_bnd
First draft of fill ice ocean boundary
2 parents a306c90 + 6b6289a commit e6c5ddd

2 files changed

Lines changed: 127 additions & 24 deletions

File tree

config_src/mct_driver/coupler_indices.F90

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module coupler_indices
99

1010
! MOM types
1111
use MOM_grid, only : ocean_grid_type
12+
use MOM_surface_forcing, only: ice_ocean_boundary_type
1213
! MOM functions
1314
use MOM_domains, only : pass_var
1415
use ocean_model_mod, only : ocean_public_type
@@ -18,6 +19,7 @@ module coupler_indices
1819
private
1920

2021
public coupler_indices_init
22+
public fill_ice_ocean_bnd
2123
public ocn_export
2224

2325
type, public :: cpl_indices
@@ -285,4 +287,81 @@ subroutine ocn_export(ind, ocn_public, grid, o2x)
285287

286288
end subroutine ocn_export
287289

290+
291+
subroutine fill_ice_ocean_bnd(ice_ocean_boundary, grid, x2o_o, ind)
292+
type(ice_ocean_boundary_type), intent(in) :: ice_ocean_boundary !< A type for the ice ocean boundary
293+
type(ocean_grid_type), intent(in) :: grid
294+
!type(mct_aVect), intent(in) :: x2o_o
295+
real(kind=8), intent(in) :: x2o_o(:,:)
296+
type(cpl_indices), intent(inout) :: ind
297+
298+
! local variables
299+
integer :: i, j, k, ig, jg
300+
301+
! variable that are not in ice_ocean_boundary:
302+
! latent (x2o_Foxx_lat)
303+
! surface Stokes drift, x-comp. (x2o_Sw_ustokes)
304+
! surface Stokes drift, y-comp. (x2o_Sw_vstokes)
305+
! wave model langmuir multiplier (x2o_Sw_lamult)
306+
307+
! biogeochemistry
308+
! Black Carbon hydrophobic release from sea ice component (x2o_Fioi_bcpho)
309+
! Black Carbon hydrophilic release from sea ice component (x2o_Fioi_bcphi)
310+
! dust release from sea ice component (x2o_Fioi_flxdst)
311+
! Black Carbon hydrophilic dry deposition (x2o_Faxa_bcphidry)
312+
! Black Carbon hydrophobic dry deposition (x2o_Faxa_bcphodry)
313+
! Black Carbon hydrophobic wet deposition (x2o_Faxa_bcphiwet)
314+
! Organic Carbon hydrophilic dry deposition (x2o_Faxa_ocphidry)
315+
! Organic Carbon hydrophobic dry deposition (x2o_Faxa_ocphodry)
316+
! Organic Carbon hydrophilic dry deposition (x2o_Faxa_ocphiwet)
317+
! Sizes 1 to 4 dust - wet deposition (x2o_Faxa_dstwet?)
318+
! Sizes 1 to 4 dust - dry deposition (x2o_Faxa_dstdry?)
319+
320+
321+
! need wind_stress_multiplier?
322+
323+
! Copy from x2o to ice_ocean_boundary. ice_ocean_boundary uses global indexing with no halos.
324+
write(*,*) 'max. k is:', (grid%jec-grid%jsc+1) * (grid%iec-grid%isc+1)
325+
! zonal wind stress (taux)
326+
write(*,*) 'taux', SIZE(x2o_o(ind%x2o_Foxx_taux,:))
327+
write(*,*) 'ice_ocean_boundary%u_flux', SIZE(ice_ocean_boundary%u_flux(:,:))
328+
k = 0
329+
do j = grid%jsc, grid%jec
330+
jg = j + grid%jdg_offset
331+
do i = grid%isc, grid%iec
332+
k = k + 1 ! Increment position within gindex
333+
ig = i + grid%idg_offset
334+
! zonal wind stress (taux)
335+
ice_ocean_boundary%u_flux(i,j) = x2o_o(ind%x2o_Foxx_taux,k)
336+
! meridional wind stress (tauy)
337+
ice_ocean_boundary%v_flux(i,j) = x2o_o(ind%x2o_Foxx_tauy,k)
338+
! sensible heat flux
339+
ice_ocean_boundary%t_flux(i,j) = x2o_o(ind%x2o_Foxx_sen,k)
340+
! salt flux
341+
ice_ocean_boundary%salt_flux(i,j) = x2o_o(ind%x2o_Fioi_salt,k)
342+
! heat flux from snow & ice melt
343+
ice_ocean_boundary%calving_hflx(i,j) = x2o_o(ind%x2o_Fioi_melth,k)
344+
! snow melt flux
345+
ice_ocean_boundary%fprec(i,j) = x2o_o(ind%x2o_Fioi_meltw,k)
346+
! river runoff flux
347+
ice_ocean_boundary%runoff(i,j) = x2o_o(ind%x2o_Foxx_rofl,k)
348+
! ice runoff flux
349+
ice_ocean_boundary%calving(i,j) = x2o_o(ind%x2o_Foxx_rofi,k)
350+
! liquid precipitation (rain)
351+
ice_ocean_boundary%lprec(i,j) = x2o_o(ind%x2o_Faxa_rain,k)
352+
! froze precipitation (snow)
353+
ice_ocean_boundary%fprec(i,j) = x2o_o(ind%x2o_Faxa_snow,k)
354+
!!!!!!! LONGWAVE NEEDS TO BE FIXED !!!!!!!
355+
! longwave radiation (up)
356+
ice_ocean_boundary%lw_flux(i,j) = x2o_o(k,ind%x2o_Foxx_lwup)
357+
! longwave radiation (down)
358+
ice_ocean_boundary%lw_flux(i,j) = x2o_o(k,ind%x2o_Faxa_lwdn)
359+
!!!!!!! SHORTWAVE NEEDS TO BE COMBINED !!!!!!!
360+
! net short-wave heat flux
361+
ice_ocean_boundary%u_flux(i,j) = x2o_o(k,ind%x2o_Foxx_swnet)
362+
enddo
363+
enddo
364+
365+
end subroutine fill_ice_ocean_bnd
366+
288367
end module coupler_indices

config_src/mct_driver/ocn_comp_mct.F90

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ module ocn_comp_mct
1111
! !REVISION HISTORY:
1212
!
1313
! !USES:
14-
use ESMF, only: ESMF_clock, ESMF_time, ESMF_timeInterval
15-
use ESMF, only: ESMF_ClockGet, ESMF_TimeGet, ESMF_TimeIntervalGet
16-
use seq_cdata_mod, only: seq_cdata
17-
use seq_cdata_mod, only: seq_cdata_setptrs
18-
use mct_mod, only: mct_gsMap, mct_gsmap_init, mct_gsMap_lsize, mct_gsmap_orderedpoints
19-
use mct_mod, only: mct_aVect, mct_aVect_init, mct_aVect_zero, mct_aVect_nRattr
20-
use mct_mod, only: mct_gGrid, mct_gGrid_init, mct_gGrid_importRAttr, mct_gGrid_importIAttr
21-
use seq_flds_mod, only: seq_flds_x2o_fields, &
14+
use ESMF, only: ESMF_clock, ESMF_time, ESMF_timeInterval
15+
use ESMF, only: ESMF_ClockGet, ESMF_TimeGet, ESMF_TimeIntervalGet
16+
use seq_cdata_mod, only: seq_cdata
17+
use seq_cdata_mod, only: seq_cdata_setptrs
18+
use mct_mod, only: mct_gsMap, mct_gsmap_init, mct_gsMap_lsize, mct_gsmap_orderedpoints
19+
use mct_mod, only: mct_aVect, mct_aVect_init, mct_aVect_zero, mct_aVect_nRattr
20+
use mct_mod, only: mct_gGrid, mct_gGrid_init, mct_gGrid_importRAttr, mct_gGrid_importIAttr
21+
use seq_flds_mod, only: seq_flds_x2o_fields, &
2222
seq_flds_o2x_fields, &
2323
SEQ_FLDS_DOM_COORD, &
2424
SEQ_FLDS_DOM_other
25-
use seq_infodata_mod, only: seq_infodata_type, &
25+
use seq_infodata_mod, only: seq_infodata_type, &
2626
seq_infodata_GetData, &
2727
seq_infodata_start_type_start, &
2828
seq_infodata_start_type_cont, &
2929
seq_infodata_start_type_brnch, &
3030
seq_infodata_PutData
31-
use seq_comm_mct, only: seq_comm_name, seq_comm_inst, seq_comm_suffix
32-
use seq_timemgr_mod, only: seq_timemgr_EClockGetData, seq_timemgr_RestartAlarmIsOn
33-
use perf_mod, only: t_startf, t_stopf
34-
use shr_kind_mod, only: SHR_KIND_R8
31+
use seq_comm_mct, only: seq_comm_name, seq_comm_inst, seq_comm_suffix
32+
use seq_timemgr_mod, only: seq_timemgr_EClockGetData, seq_timemgr_RestartAlarmIsOn
33+
use perf_mod, only: t_startf, t_stopf
34+
use shr_kind_mod, only: SHR_KIND_R8
3535

3636

3737
! From MOM6
@@ -44,8 +44,7 @@ module ocn_comp_mct
4444
use MOM_error_handler, only: MOM_error, FATAL, is_root_pe
4545
use MOM_time_manager, only: time_type, set_date, set_calendar_type, NOLEAP
4646
use coupler_indices, only: coupler_indices_init, cpl_indices
47-
use coupler_indices, only: ocn_export
48-
47+
use coupler_indices, only: ocn_export, fill_ice_ocean_bnd
4948
!
5049
! !PUBLIC MEMBER FUNCTIONS:
5150
implicit none
@@ -70,8 +69,9 @@ module ocn_comp_mct
7069
type MCT_MOM_Data
7170
type(ocean_state_type), pointer :: ocn_state => NULL() !< Private state of ocean
7271
type(ocean_public_type), pointer :: ocn_public => NULL() !< Public state of ocean
73-
type(ocean_grid_type), pointer :: grid => NULL() ! A pointer to a grid structure
74-
72+
type(ocean_grid_type), pointer :: grid => NULL() !< A pointer to a grid structure
73+
type(surface), pointer :: ocn_surface => NULL() !< A pointer to the ocean surface state
74+
type(ice_ocean_boundary_type) :: ice_ocean_boundary !< A pointer to the ice ocean boundary type
7575
type(seq_infodata_type), pointer :: infodata
7676

7777
type(cpl_indices), public :: ind !< Variable IDs
@@ -123,7 +123,8 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
123123
integer :: lsize, nsend, nrecv
124124
logical :: ldiag_cpl = .false.
125125
integer :: ni, nj
126-
126+
integer :: isc, iec, jsc, jec !< Indices for the start and end of the domain
127+
!! in the x and y dir., respectively.
127128
! mct variables (these are local for now)
128129
integer :: MOM_MCT_ID
129130
type(mct_gsMap), pointer :: MOM_MCT_gsMap => NULL() ! 2d, points to cdata
@@ -241,6 +242,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
241242

242243
call t_stopf('MOM_init')
243244

245+
244246
!---------------------------------------------------------------------
245247
! Initialize MCT attribute vectors and indices
246248
!---------------------------------------------------------------------
@@ -311,6 +313,29 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
311313
! Size of global domain
312314
call get_global_grid_size(glb%grid, ni, nj)
313315

316+
! allocate ice_ocean_boundary
317+
isc = glb%grid%isc; iec = glb%grid%iec;
318+
jsc = glb%grid%jsc; jec = glb%grid%jec;
319+
allocate(glb%ice_ocean_boundary%u_flux(isc:iec,jsc:jec)); glb%ice_ocean_boundary%u_flux(:,:) = 0.0
320+
allocate(glb%ice_ocean_boundary%v_flux(isc:iec,jsc:jec)); glb%ice_ocean_boundary%v_flux(:,:) = 0.0
321+
allocate(glb%ice_ocean_boundary%t_flux(isc:iec,jsc:jec)); glb%ice_ocean_boundary%t_flux(:,:) = 0.0
322+
allocate(glb%ice_ocean_boundary%q_flux(isc:iec,jsc:jec)); glb%ice_ocean_boundary%q_flux(:,:) = 0.0
323+
allocate(glb%ice_ocean_boundary%salt_flux(isc:iec,jsc:jec)); glb%ice_ocean_boundary%salt_flux(:,:) = 0.0
324+
allocate(glb%ice_ocean_boundary%lw_flux(isc:iec,jsc:jec)); glb%ice_ocean_boundary%lw_flux(:,:) = 0.0
325+
allocate(glb%ice_ocean_boundary%sw_flux_vis_dir(isc:iec,jsc:jec)); glb%ice_ocean_boundary%sw_flux_vis_dir(:,:) = 0.0
326+
allocate(glb%ice_ocean_boundary%sw_flux_vis_dif(isc:iec,jsc:jec)); glb%ice_ocean_boundary%sw_flux_vis_dif(:,:) = 0.0
327+
allocate(glb%ice_ocean_boundary%sw_flux_nir_dir(isc:iec,jsc:jec)); glb%ice_ocean_boundary%sw_flux_nir_dir(:,:) = 0.0
328+
allocate(glb%ice_ocean_boundary%sw_flux_nir_dif(isc:iec,jsc:jec)); glb%ice_ocean_boundary%sw_flux_nir_dif(:,:) = 0.0
329+
allocate(glb%ice_ocean_boundary%lprec(isc:iec,jsc:jec)); glb%ice_ocean_boundary%lprec(:,:) = 0.0
330+
allocate(glb%ice_ocean_boundary%fprec(isc:iec,jsc:jec)); glb%ice_ocean_boundary%fprec(:,:) = 0.0
331+
allocate(glb%ice_ocean_boundary%runoff(isc:iec,jsc:jec)); glb%ice_ocean_boundary%runoff(:,:) = 0.0
332+
allocate(glb%ice_ocean_boundary%calving(isc:iec,jsc:jec)); glb%ice_ocean_boundary%calving(:,:) = 0.0
333+
allocate(glb%ice_ocean_boundary%runoff_hflx(isc:iec,jsc:jec)); glb%ice_ocean_boundary%runoff_hflx(:,:) = 0.0
334+
allocate(glb%ice_ocean_boundary%calving_hflx(isc:iec,jsc:jec)); glb%ice_ocean_boundary%calving_hflx(:,:) = 0.0
335+
allocate(glb%ice_ocean_boundary%p(isc:iec,jsc:jec)); glb%ice_ocean_boundary%p(:,:) = 0.0
336+
allocate(glb%ice_ocean_boundary%mi(isc:iec,jsc:jec)); glb%ice_ocean_boundary%mi(:,:) = 0.0
337+
338+
314339
if (debug .and. root_pe().eq.pe_here()) print *, "calling seq_infodata_putdata"
315340

316341
call seq_infodata_PutData( glb%infodata, &
@@ -341,9 +366,6 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
341366
type(time_type) :: coupling_timestep ! Coupled time interval to pass to MOM6
342367
character(len=128) :: err_msg
343368

344-
! Might need to be in glb to live on heap
345-
type(ice_ocean_boundary_type) :: Ice_ocean_boundary
346-
347369
! Translate the current time (start of coupling interval)
348370
call ESMF_ClockGet(EClock, currTime=current_time, rc=rc)
349371
call ESMF_TimeGet(current_time, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
@@ -380,10 +402,12 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
380402
! \todo Let MOM6 know to write restart...
381403
if (debug .and. is_root_pe()) write(6,*) 'ocn_run_mct, write_restart_at_eod=', write_restart_at_eod
382404

383-
!call ocn_imprt goes her
405+
! fill ice ocean boundary
406+
call fill_ice_ocean_bnd(glb%ice_ocean_boundary, glb%grid, x2o_o%rattr, glb%ind)
407+
if (debug .and. is_root_pe()) write(6,*) 'fill_ice_ocean_bnd'
384408

385-
!call update_ocean_model(ice_ocean_boundary, glb%ocn_state, glb%ocn_public, &
386-
! time_start, coupling_timestep)
409+
! call update_ocean_model(glb%ice_ocean_boundary, glb%ocn_state, glb%ocn_public, &
410+
! time_start, coupling_timestep)
387411

388412
end subroutine ocn_run_mct
389413

0 commit comments

Comments
 (0)