52 implicit none ;
private 75 function wright_eos_2d(T,S,p)
result(rho)
87 real(kind=8),
dimension(:,:),
intent(in) :: t,s
90 real(kind=8),
dimension(size(T,1),size(T,2)) :: rho
93 real(kind=8) :: a0,a1,a2,b0,b1,b2,b3,b4,b5,c0,c1,c2,c3,c4,c5
94 real(kind=8) :: al0,lam,p0,i_denom
97 a0 = 7.057924e-4; a1 = 3.480336e-7; a2 = -1.112733e-7;
98 b0 = 5.790749e8; b1 = 3.516535e6; b2 = -4.002714e4;
99 b3 = 2.084372e2; b4 = 5.944068e5; b5 = -9.643486e3;
100 c0 = 1.704853e5; c1 = 7.904722e2; c2 = -7.984422;
101 c3 = 5.140652e-2; c4 = -2.302158e2; c5 = -3.079464;
105 al0 = a0 + a1*t(i,k) +a2*s(i,k)
106 p0 = b0 + b4*s(i,k) + t(i,k) * (b1 + t(i,k)*(b2 + &
107 b3*t(i,k)) + b5*s(i,k))
108 lam = c0 +c4*s(i,k) + t(i,k) * (c1 + t(i,k)*(c2 + &
109 c3*t(i,k)) + c5*s(i,k))
110 i_denom = 1.0 / (lam + al0*(p+p0))
111 rho(i,k) = (p + p0) * i_denom
117 end function wright_eos_2d
119 function alpha_wright_eos_2d(T,S,p)
result(drho_dT)
130 real(kind=8),
dimension(:,:),
intent(in) :: t,s
131 real,
intent(in) :: p
132 real(kind=8),
dimension(size(T,1),size(T,2)) :: drho_dt
134 real(kind=8) :: a0,a1,a2,b0,b1,b2,b3,b4,b5,c0,c1,c2,c3,c4,c5
135 real(kind=8) :: al0,lam,p0,i_denom,i_denom2
138 a0 = 7.057924e-4; a1 = 3.480336e-7; a2 = -1.112733e-7;
139 b0 = 5.790749e8; b1 = 3.516535e6; b2 = -4.002714e4;
140 b3 = 2.084372e2; b4 = 5.944068e5; b5 = -9.643486e3;
141 c0 = 1.704853e5; c1 = 7.904722e2; c2 = -7.984422;
142 c3 = 5.140652e-2; c4 = -2.302158e2; c5 = -3.079464;
146 al0 = a0 + a1*t(i,k) +a2*s(i,k)
147 p0 = b0 + b4*s(i,k) + t(i,k) * (b1 + t(i,k)*(b2 + &
148 b3*t(i,k)) + b5*s(i,k))
149 lam = c0 +c4*s(i,k) + t(i,k) * (c1 + t(i,k)*(c2 + &
150 c3*t(i,k)) + c5*s(i,k))
151 i_denom = 1.0 / (lam + al0*(p+p0))
152 i_denom2 = i_denom*i_denom
153 drho_dt(i,k) = i_denom2*(lam*(b1+t(i,k)*(2*b2 + &
154 3*b3*t(i,k)) + b5*s(i,k)) - (p+p0)*((p+p0)*a1 + &
155 (c1+t(i,k)*(2*c2 + 3*c3*t(i,k)) + c5*s(i,k))))
161 end function alpha_wright_eos_2d
163 function beta_wright_eos_2d(T,S,p)
result(drho_dS)
174 real(kind=8),
dimension(:,:),
intent(in) :: t,s
175 real,
intent(in) :: p
177 real(kind=8),
dimension(size(T,1),size(T,2)) :: drho_ds
181 real(kind=8) :: a0,a1,a2,b0,b1,b2,b3,b4,b5,c0,c1,c2,c3,c4,c5
182 real(kind=8) :: al0,lam,p0,i_denom,i_denom2
185 a0 = 7.057924e-4; a1 = 3.480336e-7; a2 = -1.112733e-7;
186 b0 = 5.790749e8; b1 = 3.516535e6; b2 = -4.002714e4;
187 b3 = 2.084372e2; b4 = 5.944068e5; b5 = -9.643486e3;
188 c0 = 1.704853e5; c1 = 7.904722e2; c2 = -7.984422;
189 c3 = 5.140652e-2; c4 = -2.302158e2; c5 = -3.079464;
193 al0 = a0 + a1*t(i,k) +a2*s(i,k)
194 p0 = b0 + b4*s(i,k) + t(i,k) * (b1 + t(i,k)*(b2 + &
195 b3*t(i,k)) + b5*s(i,k))
196 lam = c0 +c4*s(i,k) + t(i,k) * (c1 + t(i,k)*(c2 + &
197 c3*t(i,k)) + c5*s(i,k))
198 i_denom = 1.0 / (lam + al0*(p+p0))
199 i_denom2 = i_denom*i_denom
200 drho_ds(i,k) = i_denom2*(lam*(b4+b5*t(i,k)) - &
201 (p+p0)*((p+p0)*a2 + (c4+c5*t(i,k))))
207 end function beta_wright_eos_2d
213 function tracer_z_init(tr_in,z_edges,e,nkml,nkbl,land_fill,wet,nlay,nlevs,debug,i_debug,j_debug)
result(tr)
237 real,
dimension(:,:,:),
intent(in) :: tr_in
238 real,
dimension(size(tr_in,3)+1),
intent(in) :: z_edges
239 integer,
intent(in) :: nlay
240 real,
dimension(size(tr_in,1),size(tr_in,2),nlay+1),
intent(in) :: e
241 integer,
intent(in) :: nkml,nkbl
242 real,
intent(in) :: land_fill
243 real,
dimension(size(tr_in,1),size(tr_in,2)),
intent(in) :: wet
244 real,
dimension(size(tr_in,1),size(tr_in,2)),
optional,
intent(in) ::nlevs
245 logical,
intent(in),
optional :: debug
246 integer,
intent(in),
optional :: i_debug, j_debug
248 real,
dimension(size(tr_in,1),size(tr_in,2),nlay) :: tr
249 real,
dimension(size(tr_in,3)) :: tr_1d
250 real,
dimension(nlay+1) :: e_1d
251 real,
dimension(nlay) :: tr_
252 integer,
dimension(size(tr_in,1),size(tr_in,2)) :: nlevs_data
254 integer :: n,i,j,k,l,nx,ny,nz,nt,kz
255 integer :: k_top,k_bot,k_bot_prev,kk,kstart
257 real,
dimension(size(tr_in,3)) :: wt,z1,z2
258 logical :: debug_msg, debug_
260 nx =
size(tr_in,1); ny=
size(tr_in,2); nz =
size(tr_in,3)
262 nlevs_data =
size(tr_in,3)
263 if (
PRESENT(nlevs))
then 264 nlevs_data = anint(nlevs)
268 if (
PRESENT(debug))
then 280 if (nlevs_data(i,j) .eq. 0 .or. wet(i,j) .eq. 0.)
then 281 tr(i,j,:) = land_fill
286 tr_1d(k) = tr_in(i,j,k)
292 k_bot = 1 ; k_bot_prev = -1
294 if (e_1d(k+1) > z_edges(1))
then 296 elseif (e_1d(k) < z_edges(nlevs_data(i,j)+1))
then 298 print *,
'*** WARNING : Found interface below valid range of z data ' 299 print *,
'(i,j,z_bottom,interface)= ',&
300 i,j,z_edges(nlevs_data(i,j)+1),e_1d(k)
301 print *,
'z_edges= ',z_edges
303 print *,
'*** I will extrapolate below using the bottom-most valid values' 306 tr(i,j,k) = tr_1d(nlevs_data(i,j))
310 call find_overlap(z_edges, e_1d(k), e_1d(k+1), nlevs_data(i,j), &
311 kstart, k_top, k_bot, wt, z1, z2)
314 if (
PRESENT(i_debug))
then 315 if (i.eq.i_debug.and.j.eq.j_debug)
then 316 print *,
'0001 k,k_top,k_bot,sum(wt),sum(z2-z1) = ',k,k_top,k_bot,sum(wt),sum(z2-z1)
322 if (kz /= k_bot_prev)
then 324 if ((kz < nlevs_data(i,j)) .and. (kz > 1))
then 328 if (kz > nlevs_data(i,j)) kz = nlevs_data(i,j)
330 tr(i,j,k) = wt(kz) * &
331 (tr_1d(kz) + 0.5*sl_tr*(z2(kz) + z1(kz)))
338 if (
PRESENT(i_debug))
then 339 if (i.eq.i_debug.and.j.eq.j_debug)
then 340 print *,
'0002 k,k_top,k_bot,k_bot_prev,sl_tr = ',k,k_top,k_bot,k_bot_prev,sl_tr
345 do kz=k_top+1,k_bot-1
346 tr(i,j,k) = tr(i,j,k) + wt(kz)*tr_1d(kz)
350 if (
PRESENT(i_debug))
then 351 if (i.eq.i_debug.and.j.eq.j_debug)
then 352 print *,
'0003 k,tr = ',k,tr(i,j,k)
357 if (k_bot > k_top)
then 361 if ((kz < nlevs_data(i,j)) .and. (kz > 1))
then 368 tr(i,j,k) = tr(i,j,k) + wt(kz) * &
369 (tr_1d(kz) + 0.5*sl_tr*(z2(kz) + z1(kz)))
374 if (
PRESENT(i_debug))
then 375 if (i.eq.i_debug.and.j.eq.j_debug)
then 376 print *,
'0004 k,kz,nlevs,sl_tr,tr = ',k,kz,nlevs_data(i,j),sl_tr,tr(i,j,k)
377 print *,
'0005 k,kz,tr(kz),tr(kz-1),tr(kz+1) = ',k,kz,tr_1d(kz),tr_1d(kz-1),tr_1d(kz+1),z_edges(kz+2)
389 if (e_1d(k)-e_1d(k+1) .le.
epsln) tr(i,j,k)=tr(i,j,k-1)
413 real,
dimension(:,:),
intent(in) :: a
414 real,
dimension(:),
intent(in) :: x
415 integer,
dimension(size(a,1)),
intent(in),
optional :: lo,hi
416 integer,
dimension(size(a,1),size(x,1)) :: bi_r
418 integer :: mid,num_x,num_a,i
419 integer,
dimension(size(a,1)) :: lo_,hi_,lo0,hi0
422 lo_=1;hi_=
size(a,2);num_x=
size(x,1);bi_r=-1;nprofs=
size(a,1)
424 if (
PRESENT(lo))
then 427 if (
PRESENT(hi))
then 436 do while (lo_(j) < hi_(j))
437 mid = (lo_(j)+hi_(j))/2
438 if (x(i) < a(j,mid))
then 469 real(kind=8),
dimension(:,:,:),
intent(inout) :: temp,salt
470 real(kind=8),
dimension(size(temp,3)),
intent(in) :: R
471 real,
intent(in) :: p_ref
472 integer,
intent(in) :: niter
473 integer,
intent(in) :: k_start
474 real,
intent(in) :: land_fill
475 real(kind=8),
dimension(:,:,:),
intent(in) :: h
477 real(kind=8),
dimension(size(temp,1),size(temp,3)) :: T,S,dT,dS,rho,hin
478 real(kind=8),
dimension(size(temp,1),size(temp,3)) :: drho_dT,drho_dS
479 real(kind=8),
dimension(size(temp,1)) :: press
481 integer :: nx,ny,nz,nt,i,j,k,n,itt
482 logical :: adjust_salt , old_fit
484 real,
parameter :: T_max = 35.0, t_min = -2.0
485 real,
parameter :: S_min = 0.5, s_max=65.0
486 real,
parameter :: tol=1.e-4, max_t_adj=1.0, max_s_adj = 0.5
505 real,
dimension(:,:,:),
intent(inout) :: temp,salt
506 real,
dimension(size(temp,3)),
intent(in) :: R
507 real,
intent(in) :: p_ref
508 integer,
intent(in) :: niter
509 integer,
intent(in) :: k_start
510 real,
intent(in) :: land_fill
511 real,
dimension(:,:,:),
intent(in) :: h
512 type(
eos_type),
pointer,
intent(in) :: eos
514 real(kind=8),
dimension(size(temp,1),size(temp,3)) :: T,S,dT,dS,rho,hin
515 real(kind=8),
dimension(size(temp,1),size(temp,3)) :: drho_dT,drho_dS
516 real(kind=8),
dimension(size(temp,1)) :: press
518 integer :: nx,ny,nz,nt,i,j,k,n,itt
520 logical :: adjust_salt , old_fit
521 real,
parameter :: T_max = 31.0, t_min = -2.0
522 real,
parameter :: S_min = 0.5, s_max=65.0
523 real,
parameter :: tol=1.e-4, max_t_adj=1.0, max_s_adj = 0.5
535 nx=
size(temp,1);ny=
size(temp,2); nz=
size(temp,3)
546 iter_loop:
do itt = 1,niter
548 rho=wright_eos_2d(t,s,p_ref)
549 drho_dt=alpha_wright_eos_2d(t,s,p_ref)
553 call calculate_density_derivs(t(:,k),s(:,k),press,drho_dt(:,k),drho_ds(:,k),1,nx,eos)
560 if (abs(rho(i,k)-r(k))>tol)
then 562 dt(i,k)=(r(k)-rho(i,k))/drho_dt(i,k)
563 if (dt(i,k)>max_t_adj) dt(i,k)=max_t_adj
564 if (dt(i,k)<-1.0*max_t_adj) dt(i,k)=-1.0*max_t_adj
565 t(i,k)=max(min(t(i,k)+dt(i,k),t_max),t_min)
567 dt_ds = 10.0 - min(-drho_dt(i,k)/drho_ds(i,k),10.)
568 ds(i,k) = (r(k)-rho(i,k))/(drho_ds(i,k) - drho_dt(i,k)*dt_ds )
569 dt(i,k)= -dt_ds*ds(i,k)
572 t(i,k)=max(min(t(i,k)+dt(i,k),t_max),t_min)
573 s(i,k)=max(min(s(i,k)+ds(i,k),s_max),s_min)
578 if (maxval(abs(dt)) < tol)
then 579 adjust_salt = .false.
584 if (adjust_salt .and. old_fit)
then 585 iter_loop2:
do itt = 1,niter
587 rho=wright_eos_2d(t,s,p_ref)
588 drho_ds=beta_wright_eos_2d(t,s,p_ref)
592 call calculate_density_derivs(t(:,k),s(:,k),press,drho_dt(:,k),drho_ds(:,k),1,nx,eos)
598 if (abs(rho(i,k)-r(k))>tol )
then 599 ds(i,k)=(r(k)-rho(i,k))/drho_ds(i,k)
600 if (ds(i,k)>max_s_adj) ds(i,k)=max_s_adj
601 if (ds(i,k)<-1.0*max_s_adj) ds(i,k)=-1.0*max_s_adj
602 s(i,k)=max(min(s(i,k)+ds(i,k),s_max),s_min)
606 if (maxval(abs(ds)) < tol)
then 622 subroutine find_overlap(e, Z_top, Z_bot, k_max, k_start, k_top, k_bot, wt, z1, z2)
643 real,
dimension(:),
intent(in) :: e
644 real,
intent(in) :: Z_top, Z_bot
645 integer,
intent(in) :: k_max, k_start
646 integer,
intent(out) :: k_top, k_bot
647 real,
dimension(:),
intent(out) :: wt, z1, z2
649 real :: Ih, e_c, tot_wt, I_totwt
652 wt(:)=0.0; z1(:)=0.0; z2(:)=0.0
653 k_top = k_start; k_bot= k_start; wt(1) = 1.0; z1(1)=-0.5; z2(1) = 0.5
655 do k=k_start,k_max ;
if (e(k+1)<z_top)
exit ;
enddo 661 if (e(k+1)<=z_bot)
then 662 wt(k) = 1.0 ; k_bot = k
663 ih = 1.0 / (e(k)-e(k+1))
664 e_c = 0.5*(e(k)+e(k+1))
665 z1(k) = (e_c - min(e(k),z_top)) * ih
666 z2(k) = (e_c - z_bot) * ih
668 wt(k) = min(e(k),z_top) - e(k+1) ; tot_wt = wt(k)
669 z1(k) = (0.5*(e(k)+e(k+1)) - min(e(k),z_top)) / (e(k)-e(k+1))
673 if (e(k+1)<=z_bot)
then 675 wt(k) = e(k) - z_bot ; z1(k) = -0.5
676 z2(k) = (0.5*(e(k)+e(k+1)) - z_bot) / (e(k)-e(k+1))
678 wt(k) = e(k) - e(k+1) ; z1(k) = -0.5 ; z2(k) = 0.5
680 tot_wt = tot_wt + wt(k)
684 i_totwt = 1.0 / tot_wt
685 do k=k_top,k_bot ; wt(k) = i_totwt*wt(k) ;
enddo 704 real,
dimension(:),
intent(in) :: val
705 real,
dimension(:),
intent(in) :: e
706 integer,
intent(in) :: k
707 real :: slope,amx,bmx,amn,bmn,cmn,dmn
711 if ((val(k)-val(k-1)) * (val(k)-val(k+1)) >= 0.0)
then 714 d1 = 0.5*(e(k-1)-e(k+1)) ; d2 = 0.5*(e(k)-e(k+2))
715 slope = ((d1**2)*(val(k+1) - val(k)) + (d2**2)*(val(k) - val(k-1))) * &
716 (e(k) - e(k+1)) / (d1*d2*(d1+d2))
719 amx=max(val(k-1),val(k))
720 bmx = max(amx,val(k+1))
721 amn = min(abs(slope),2.0*(bmx-val(k)))
722 bmn = min(val(k-1),val(k))
723 cmn = 2.0*(val(k)-min(bmn,val(k+1)))
725 slope = sign(1.0,slope) * dmn
739 function find_interfaces(rho,zin,Rb,depth,nlevs,nkml,nkbl,hml,debug)
result(zi)
749 real,
dimension(:,:,:),
intent(in) :: rho
750 real,
dimension(size(rho,3)),
intent(in) :: zin
751 real,
dimension(:),
intent(in) :: Rb
752 real,
dimension(size(rho,1),size(rho,2)),
intent(in) :: depth
753 real,
dimension(size(rho,1),size(rho,2)),
optional,
intent(in) ::nlevs
754 logical,
optional,
intent(in) :: debug
755 real,
dimension(size(rho,1),size(rho,2),size(Rb,1)) :: zi
756 integer,
intent(in),
optional :: nkml, nkbl
757 real,
intent(in),
optional :: hml
759 real,
dimension(size(rho,1),size(rho,3)) :: rho_
760 real,
dimension(size(rho,1)) :: depth_
763 integer,
dimension(size(rho,1),size(Rb,1)) :: ki_
764 real,
dimension(size(rho,1),size(Rb,1)) :: zi_
765 integer,
dimension(size(rho,1),size(rho,2)) :: nlevs_data
766 integer,
dimension(size(rho,1)) :: lo,hi
767 real :: slope,rsm,drhodz,hml_
768 integer :: n,i,j,k,l,nx,ny,nz,nt
769 integer :: nlay,kk,nkml_,nkbl_
770 logical :: debug_ = .false.
772 real,
parameter :: zoff=0.999
779 if (
PRESENT(debug)) debug_=debug
781 nx =
size(rho,1); ny=
size(rho,2); nz =
size(rho,3)
782 nlevs_data(:,:) =
size(rho,3)
784 nkml_=0;nkbl_=0;hml_=0.0
785 if (
PRESENT(nkml)) nkml_=max(0,nkml)
786 if (
PRESENT(nkbl)) nkbl_=max(0,nkbl)
787 if (
PRESENT(hml)) hml_=hml
789 if (
PRESENT(nlevs))
then 790 nlevs_data(:,:) = nlevs(:,:)
794 rho_(:,:) = rho(:,j,:)
797 print *,
'looking for interfaces, i,j,nlevs= ',i,j,nlevs_data(i,j)
798 print *,
'initial density profile= ', rho_(i,:)
805 do k=2,nlevs_data(i,j)-1
806 if (rho_(i,k) - rho_(i,k-1) < 0.0 )
then 808 rho_(i,k-1)=rho_(i,k)-
epsln 810 drhodz = (rho_(i,k+1)-rho_(i,k-1))/(zin(k+1)-zin(k-1))
811 if (drhodz < 0.0)
then 814 rho_(i,k) = rho_(i,k-1)+drhodz*zoff*(zin(k)-zin(k-1))
820 do k=nlevs_data(i,j)-1,2,-1
821 if (rho_(i,k+1) - rho_(i,k) < 0.0)
then 822 if (k .eq. nlevs_data(i,j)-1)
then 823 rho_(i,k+1)=rho_(i,k-1)+
epsln 825 drhodz = (rho_(i,k+1)-rho_(i,k-1))/(zin(k+1)-zin(k-1))
826 if (drhodz < 0.0)
then 829 rho_(i,k) = rho_(i,k+1)-drhodz*(zin(k+1)-zin(k))
837 print *,
'final density profile= ', rho_(i,:)
843 depth_(:)=-1.0*depth(:,j)
845 hi(:)=nlevs_data(:,j)
847 ki_(:,:) = max(1,ki_(:,:)-1)
850 slope = (zin(ki_(i,l)+1) - zin(ki_(i,l)))/max(rho_(i,ki_(i,l)+1) - rho_(i,ki_(i,l)),
epsln)
851 zi_(i,l) = -1.0*(zin(ki_(i,l)) + slope*(rb(l)-rho_(i,ki_(i,l))))
852 zi_(i,l) = max(zi_(i,l),depth_(i))
853 zi_(i,l) = min(zi_(i,l),-1.0*hml_)
855 zi_(i,nlay+1)=depth_(i)
857 zi_(i,l)=max(((1.0-
real(l))/
real(nkml_))*hml_,depth_(i))
860 if (zi_(i,l) < zi_(i,l+1)+
epsln)
then 861 zi_(i,l)=zi_(i,l+1)+
epsln 863 if (zi_(i,l)>-1.0*hml_)
then 864 zi_(i,l)=max(-1.0*hml_,depth_(i))
881 real,
dimension(:),
intent(in) :: x,y
882 real,
dimension(size(x,1),size(y,1)),
intent(inout) :: x_T,y_T
886 ni=
size(x,1);nj=
size(y,1)
900 subroutine smooth_heights(zi,fill,bad,sor,niter,cyclic_x, tripolar_n)
910 real,
dimension(:,:),
intent(inout) :: zi
911 integer,
dimension(size(zi,1),size(zi,2)),
intent(in) :: fill
912 integer,
dimension(size(zi,1),size(zi,2)),
intent(in) :: bad
913 real,
intent(in) :: sor
914 integer,
intent(in) :: niter
915 logical,
intent(in) :: cyclic_x, tripolar_n
920 real,
dimension(size(zi,1),size(zi,2)) :: res, m
921 integer,
dimension(size(zi,1),size(zi,2),4) :: B
922 real,
dimension(0:size(zi,1)+1,0:size(zi,2)+1) :: mp
923 integer,
dimension(0:size(zi,1)+1,0:size(zi,2)+1) :: nm
927 ni=
size(zi,1); nj=
size(zi,2)
937 if (fill(i,j) .eq. 1)
then 938 b(i,j,1)=1-nm(i+1,j);b(i,j,2)=1-nm(i-1,j)
939 b(i,j,3)=1-nm(i,j+1);b(i,j,4)=1-nm(i,j-1)
947 if (fill(i,j) .eq. 1)
then 948 bsum =
real(b(i,j,1)+b(i,j,2)+b(i,j,3)+b(i,j,4))
950 res(i,j)=isum*(b(i,j,1)*mp(i+1,j)+b(i,j,2)*mp(i-1,j)+&
951 b(i,j,3)*mp(i,j+1)+b(i,j,4)*mp(i,j-1)) - mp(i,j)
955 res(:,:)=res(:,:)*sor
959 mp(i,j)=mp(i,j)+res(i,j)
963 zi(:,:)=mp(1:ni,1:nj)
977 integer,
dimension(:,:),
intent(in) :: m
978 logical,
intent(in) :: cyclic_x, tripolar_n
979 real,
dimension(size(m,1),size(m,2)) :: m_real
980 real,
dimension(0:size(m,1)+1,0:size(m,2)+1) :: mp_real
981 integer,
dimension(0:size(m,1)+1,0:size(m,2)+1) :: mp
997 real,
dimension(:,:),
intent(in) :: m
998 logical,
intent(in) :: cyclic_x, tripolar_n
999 real,
dimension(0:size(m,1)+1,0:size(m,2)+1) :: mp
1001 integer :: ni,nj,i,j
1003 ni=
size(m,1); nj=
size(m,2)
1005 mp(1:ni,1:nj)=m(:,:)
1008 mp(0,1:nj)=m(ni,1:nj)
1009 mp(ni+1,1:nj)=m(1,1:nj)
1011 mp(0,1:nj)=m(1,1:nj)
1012 mp(ni+1,1:nj)=m(ni,1:nj)
1015 mp(1:ni,0)=m(1:ni,1)
1016 if (tripolar_n)
then 1018 mp(i,nj+1)=m(ni-i+1,nj)
1021 mp(1:ni,nj+1)=m(1:ni,nj)
real function, dimension(size(tr_in, 1), size(tr_in, 2), nlay), public tracer_z_init(tr_in, z_edges, e, nkml, nkbl, land_fill, wet, nlay, nlevs, debug, i_debug, j_debug)
integer function, dimension(0:size(m, 1)+1, 0:size(m, 2)+1) fill_boundaries_int(m, cyclic_x, tripolar_n)
real function find_limited_slope(val, e, k)
Calculates density of sea water from T, S and P.
subroutine, public meshgrid(x, y, x_T, y_T)
subroutine smooth_heights(zi, fill, bad, sor, niter, cyclic_x, tripolar_n)
integer function, dimension(size(a, 1), size(x, 1)) bisect_fast(a, x, lo, hi)
subroutine, public calculate_density_derivs(T, S, pressure, drho_dT, drho_dS, start, npts, EOS)
Calls the appropriate subroutine to calculate density derivatives for 1-D array inputs.
Provides subroutines for quantities specific to the equation of state.
subroutine find_overlap(e, Z_top, Z_bot, k_max, k_start, k_top, k_bot, wt, z1, z2)
real function, dimension(size(rho, 1), size(rho, 2), size(rb, 1)), public find_interfaces(rho, zin, Rb, depth, nlevs, nkml, nkbl, hml, debug)
real function, dimension(0:size(m, 1)+1, 0:size(m, 2)+1) fill_boundaries_real(m, cyclic_x, tripolar_n)
subroutine, public determine_temperature(temp, salt, R, p_ref, niter, land_fill, h, k_start, eos)
A control structure for the equation of state.