3 use esmf,
only: esmf_clock, esmf_time, esmf_clockget, esmf_timeget
9 use mpp_domains_mod,
only: mpp_get_compute_domain
18 logical,
parameter ::
debug=.false.
25 subroutine ocn_import(x2o, ind, grid, ice_ocean_boundary, ocean_public, logunit, Eclock, c1, c2, c3, c4)
26 real(kind=8) , intent(in) :: x2o(:,:)
31 integer ,
intent(in) :: logunit
32 type(esmf_clock) ,
intent(in) :: eclock
33 real(kind=8), optional ,
intent(in) :: c1, c2, c3, c4
36 integer :: i, j, isc, iec, jsc, jec
38 integer :: day, secs, rc
39 type(esmf_time) :: currtime
40 character(*),
parameter :: f01 =
"('(ocn_import) ',a,4(i6,2x),d21.14)"
43 isc = grid%isc; iec = grid%iec ; jsc = grid%jsc; jec = grid%jec
52 ice_ocean_boundary%u_flux(i,j) = grid%cos_rot(i,j) * x2o(ind%x2o_Foxx_taux,k) &
53 - grid%sin_rot(i,j) * x2o(ind%x2o_Foxx_tauy,k)
56 ice_ocean_boundary%v_flux(i,j) = grid%cos_rot(i,j) * x2o(ind%x2o_Foxx_tauy,k) &
57 + grid%sin_rot(i,j) * x2o(ind%x2o_Foxx_taux,k)
60 ice_ocean_boundary%lprec(i,j) = x2o(ind%x2o_Faxa_rain,k)
63 ice_ocean_boundary%fprec(i,j) = x2o(ind%x2o_Faxa_snow,k)
66 ice_ocean_boundary%lw_flux(i,j) = (x2o(ind%x2o_Faxa_lwdn,k) + x2o(ind%x2o_Foxx_lwup,k))
69 ice_ocean_boundary%q_flux(i,j) = x2o(ind%x2o_Foxx_evap,k)
72 ice_ocean_boundary%t_flux(i,j) = x2o(ind%x2o_Foxx_sen,k)
75 ice_ocean_boundary%seaice_melt_heat(i,j) = x2o(ind%x2o_Fioi_melth,k)
78 ice_ocean_boundary%seaice_melt(i,j) = x2o(ind%x2o_Fioi_meltw,k)
81 ice_ocean_boundary%rofl_flux(i,j) = x2o(ind%x2o_Foxx_rofl,k) * grid%mask2dT(i,j)
84 ice_ocean_boundary%rofi_flux(i,j) = x2o(ind%x2o_Foxx_rofi,k) * grid%mask2dT(i,j)
87 ice_ocean_boundary%p(i,j) = x2o(ind%x2o_Sa_pslv,k) * grid%mask2dT(i,j)
90 ice_ocean_boundary%salt_flux(i,j) = x2o(ind%x2o_Fioi_salt,k) * grid%mask2dT(i,j)
96 if (
present(c1) .and.
present(c2) .and.
present(c3) .and.
present(c4))
then
98 ice_ocean_boundary%sw_flux_vis_dir(i,j) = x2o(ind%x2o_Foxx_swnet,k) * c1 * grid%mask2dT(i,j)
99 ice_ocean_boundary%sw_flux_vis_dif(i,j) = x2o(ind%x2o_Foxx_swnet,k) * c2 * grid%mask2dT(i,j)
100 ice_ocean_boundary%sw_flux_nir_dir(i,j) = x2o(ind%x2o_Foxx_swnet,k) * c3 * grid%mask2dT(i,j)
101 ice_ocean_boundary%sw_flux_nir_dif(i,j) = x2o(ind%x2o_Foxx_swnet,k) * c4 * grid%mask2dT(i,j)
103 ice_ocean_boundary%sw_flux_vis_dir(i,j) = x2o(ind%x2o_Faxa_swvdr,k) * grid%mask2dT(i,j)
104 ice_ocean_boundary%sw_flux_vis_dif(i,j) = x2o(ind%x2o_Faxa_swvdf,k) * grid%mask2dT(i,j)
105 ice_ocean_boundary%sw_flux_nir_dir(i,j) = x2o(ind%x2o_Faxa_swndr,k) * grid%mask2dT(i,j)
106 ice_ocean_boundary%sw_flux_nir_dif(i,j) = x2o(ind%x2o_Faxa_swndf,k) * grid%mask2dT(i,j)
112 call esmf_clockget(eclock, currtime=currtime, rc=rc)
113 call esmf_timeget(currtime, d=day, s=secs, rc=rc)
115 do j = grid%jsc, grid%jec
116 do i = grid%isc, grid%iec
117 write(logunit,f01)
'import: day, secs, j, i, u_flux = ',day,secs,j,i,ice_ocean_boundary%u_flux(i,j)
118 write(logunit,f01)
'import: day, secs, j, i, v_flux = ',day,secs,j,i,ice_ocean_boundary%v_flux(i,j)
119 write(logunit,f01)
'import: day, secs, j, i, lprec = ',day,secs,j,i,ice_ocean_boundary%lprec(i,j)
120 write(logunit,f01)
'import: day, secs, j, i, lwrad = ',day,secs,j,i,ice_ocean_boundary%lw_flux(i,j)
121 write(logunit,f01)
'import: day, secs, j, i, q_flux = ',day,secs,j,i,ice_ocean_boundary%q_flux(i,j)
122 write(logunit,f01)
'import: day, secs, j, i, t_flux = ',day,secs,j,i,ice_ocean_boundary%t_flux(i,j)
123 write(logunit,f01)
'import: day, secs, j, i, seaice_melt_heat = ',&
124 day,secs,j,i,ice_ocean_boundary%seaice_melt_heat(i,j)
125 write(logunit,f01)
'import: day, secs, j, i, seaice_melt = ',&
126 day,secs,j,i,ice_ocean_boundary%seaice_melt(i,j)
127 write(logunit,f01)
'import: day, secs, j, i, runoff = ',&
128 day,secs,j,i,ice_ocean_boundary%rofl_flux(i,j) + ice_ocean_boundary%rofi_flux(i,j)
129 write(logunit,f01)
'import: day, secs, j, i, psurf = ',&
130 day,secs,j,i,ice_ocean_boundary%p(i,j)
131 write(logunit,f01)
'import: day, secs, j, i, salt_flux = ',&
132 day,secs,j,i,ice_ocean_boundary%salt_flux(i,j)
133 write(logunit,f01)
'import: day, secs, j, i, sw_flux_vis_dir = ',&
134 day,secs,j,i,ice_ocean_boundary%sw_flux_vis_dir(i,j)
135 write(logunit,f01)
'import: day, secs, j, i, sw_flux_vis_dif = ',&
136 day,secs,j,i,ice_ocean_boundary%sw_flux_vis_dif(i,j)
137 write(logunit,f01)
'import: day, secs, j, i, sw_flux_nir_dir = ',&
138 day,secs,j,i,ice_ocean_boundary%sw_flux_nir_dir(i,j)
139 write(logunit,f01)
'import: day, secs, j, i, sw_flux_nir_dif = ',&
140 day,secs,j,i,ice_ocean_boundary%sw_flux_nir_dir(i,j)
150 subroutine ocn_export(ind, ocn_public, grid, o2x, dt_int, ncouple_per_day)
154 real(kind=8), intent(inout) :: o2x(:,:)
155 real(kind=8), intent(in) :: dt_int
157 integer,
intent(in) :: ncouple_per_day
160 real,
dimension(grid%isd:grid%ied,grid%jsd:grid%jed) :: ssh
161 real,
dimension(grid%isd:grid%ied,grid%jsd:grid%jed) :: sshx
162 real,
dimension(grid%isd:grid%ied,grid%jsd:grid%jed) :: sshy
163 integer :: i, j, n, ig, jg
164 real :: slp_l, slp_r, slp_c, slope, u_min, u_max
170 i_time_int = 0.0 ;
if (dt_int > 0.0) i_time_int = 1.0 / dt_int
177 do j=grid%jsc, grid%jec
178 jg = j + grid%jdg_offset
179 do i=grid%isc,grid%iec
181 ig = i + grid%idg_offset
183 o2x(ind%o2x_So_t, n) = ocn_public%t_surf(ig,jg) * grid%mask2dT(i,j)
184 o2x(ind%o2x_So_s, n) = ocn_public%s_surf(ig,jg) * grid%mask2dT(i,j)
186 o2x(ind%o2x_So_u, n) = (grid%cos_rot(i,j) * ocn_public%u_surf(ig,jg) + &
187 grid%sin_rot(i,j) * ocn_public%v_surf(ig,jg)) * grid%mask2dT(i,j)
188 o2x(ind%o2x_So_v, n) = (grid%cos_rot(i,j) * ocn_public%v_surf(ig,jg) - &
189 grid%sin_rot(i,j) * ocn_public%u_surf(ig,jg)) * grid%mask2dT(i,j)
192 o2x(ind%o2x_So_bldepth, n) = ocn_public%OBLD(ig,jg) * grid%mask2dT(i,j)
194 if (ocn_public%frazil(ig,jg) > 0.0)
then
196 o2x(ind%o2x_Fioo_q, n) = ocn_public%frazil(ig,jg) * grid%mask2dT(i,j) * i_time_int
199 o2x(ind%o2x_Fioo_q, n) = -ocn_public%melt_potential(ig,jg) * grid%mask2dT(i,j) * i_time_int
201 if (o2x(ind%o2x_Fioo_q, n) > 0.0) o2x(ind%o2x_Fioo_q, n) = 0.0
205 ssh(i,j) = ocn_public%sea_lev(ig,jg)
213 do j=grid%jsc, grid%jec ;
do i=grid%isc,grid%iec
217 slp_l = (ssh(i,j) - ssh(i-1,j)) * grid%mask2dCu(i-1,j)
218 if (grid%mask2dCu(i-1,j)==0.) slp_l = 0.
219 slp_r = (ssh(i+1,j) - ssh(i,j)) * grid%mask2dCu(i,j)
220 if (grid%mask2dCu(i+1,j)==0.) slp_r = 0.
221 slp_c = 0.5 * (slp_l + slp_r)
222 if ( (slp_l * slp_r) > 0.0 )
then
225 u_min = min( ssh(i-1,j), ssh(i,j), ssh(i+1,j) )
226 u_max = max( ssh(i-1,j), ssh(i,j), ssh(i+1,j) )
227 slope = sign( min( abs(slp_c), 2.*min( ssh(i,j) - u_min, u_max - ssh(i,j) ) ), slp_c )
233 sshx(i,j) = slope * grid%US%m_to_L*grid%IdxT(i,j) * grid%mask2dT(i,j)
234 if (grid%mask2dT(i,j)==0.) sshx(i,j) = 0.0
238 do j=grid%jsc, grid%jec ;
do i=grid%isc,grid%iec
242 slp_l = ssh(i,j) - ssh(i,j-1) * grid%mask2dCv(i,j-1)
243 if (grid%mask2dCv(i,j-1)==0.) slp_l = 0.
245 slp_r = ssh(i,j+1) - ssh(i,j) * grid%mask2dCv(i,j)
246 if (grid%mask2dCv(i,j+1)==0.) slp_r = 0.
248 slp_c = 0.5 * (slp_l + slp_r)
249 if ((slp_l * slp_r) > 0.0)
then
252 u_min = min( ssh(i,j-1), ssh(i,j), ssh(i,j+1) )
253 u_max = max( ssh(i,j-1), ssh(i,j), ssh(i,j+1) )
254 slope = sign( min( abs(slp_c), 2.*min( ssh(i,j) - u_min, u_max - ssh(i,j) ) ), slp_c )
260 sshy(i,j) = slope * grid%US%m_to_L*grid%IdyT(i,j) * grid%mask2dT(i,j)
261 if (grid%mask2dT(i,j)==0.) sshy(i,j) = 0.0
266 do j=grid%jsc, grid%jec ;
do i=grid%isc,grid%iec
268 o2x(ind%o2x_So_dhdx, n) = grid%cos_rot(i,j) * sshx(i,j) + grid%sin_rot(i,j) * sshy(i,j)
269 o2x(ind%o2x_So_dhdy, n) = grid%cos_rot(i,j) * sshy(i,j) - grid%sin_rot(i,j) * sshx(i,j)