1 !WRF:MODEL_LAYER:PHYSICS
7 !-------------------------------------------------------------------
8 ! cyl: Implemented a three-dimensional ocean model (DPWP) Chiaying Lee RSMAS/UM
9 !---------------------------------------------------------------------------
10 SUBROUTINE DPWP (ims,ime, jms,jme, kms,kme,its,ite, jts,jte, kts,kte, &
11 ids,ide, jds,jde, kds,kde,okms, okme, &
12 om_tmp,om_s,om_u, om_v, om_density, om_depth, om_ml, &
14 HFX, QFX, GSW, GLW, UST, U_PHY, V_PHY, &
15 STBOLT, DELTSM, TSK, LH, XLAND, &
16 rdx, rdy, msfu, msfv, msft,xtime,om_tini,om_sini,id,omdt)
17 !----------------------------------------------------------------------------
19 !----------------------------------------------------------------------------
20 ! Subroutine DPWP is a three-dimensional full physics ocean circulation model based
21 ! on Price et al. (1994, JPO). This ocean model is coupled with WRF
22 ! at every ocean time step. It is developed as a part of the University of Miami Coupled Model
23 ! (UMCM, Chen et al. 2012, JAS). A detailed description of the coupling process can
24 ! be found in Lee and Chen (2013, MWR).
26 ! This ocean model can be used with multi-nested grids the same manner as in WRF. It is recommended
27 ! to use grid spacing > 3 km for the ocean model while WRF can be configured at smaller
28 ! grid spacing then the ocean model.
30 ! The ocean model can be initialized with observed satellite SST or global model analyzed SST.
31 ! The and upper ocean temperature and sanility profiles can be initialized from climatology,
32 ! in-situ observations, and global ocean model analysis fields.
34 !-- om_tmp 3-dimensional ocean temperature (k)
35 !-- om_s 3-dimensional ocean salinity (psu)
36 !-- om_u 3-dimensional ocean current in x-direction (ms-1)
37 !-- om_v 3-dimensional ocean current in y-direction (ms-1)
38 !-- om_depth 3-dimensional ocean depth (m)
39 !-- om_ml ocean mixed layer depth (m)
40 !-- om_tini temperature reference profile based on ocean initial condition (k)
41 !-- om_sini salinity reference profile based on ocean initial condition (psu)
42 !-- om_dt ocean timestep (s)
43 !-------------------------------------------------------------------------------
45 !logical number to control the dynamics of ocean model
46 integer :: noasym, nonlcl, nodeep, nopg, idia
48 INTEGER , INTENT(IN) :: id
49 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde, &
50 ims,ime, jms,jme, kms,kme, &
51 its,ite, jts,jte, kts,kte
52 REAL , INTENT(IN ) :: rdx, &
54 integer :: i_start, i_end, j_start, j_end
55 !physical variables from WRF
56 REAL , DIMENSION( ims:ime , jms:jme ) , INTENT(IN ) :: msfu, &
60 real :: pscale, hascale, vascale
61 REAL , DIMENSION( ims:ime , jms:jme ) , INTENT(IN ) ::HFX, QFX, LH, GSW, GLW, UST,&
63 REAL , DIMENSION( ims:ime , jms:jme ) , INTENT(INOUT) :: TSK
64 REAL, INTENT(IN ) :: STBOLT, DELTSM
65 REAL , DIMENSION( ims:ime ,kms:kme, jms:jme ),INTENT(IN ) :: U_PHY, V_PHY
67 real :: cp, crbc, cadv, ddx, g
68 real :: d2r, ro, rhoair, cpw, rb, rg, udrag, ucon
69 real , dimension (ims:ime, jms:jme) :: f, dml, tr, sr
71 real , dimension (ims:ime, jms:jme) :: dr, alpha, beta
72 integer :: i, j, k, im, ip,jm,jp,km,kp,kk
75 integer, intent(in) :: okms, okme
76 real, dimension(ims:ime, okms:okme, jms:jme), INTENT(INOUT):: OM_TMP,OM_S,OM_U,OM_V,OM_DEPTH
77 real, dimension(ims:ime, okms:okme, jms:jme), INTENT(IN):: OM_TINI,OM_SINI
78 real, dimension(ims:ime, okms:okme, jms:jme), INTENT(INOUT):: OM_DENSITY
79 real, dimension(ims:ime, okms:okme, jms:jme):: OM_W
80 real, dimension(ims:ime, jms:jme),INTENT(INOUT):: OM_ML, OM_LAT, OM_LON
81 real, dimension(ims:ime, okms:okme, jms:jme):: tt, st, ut, vt, t9, s9, u9,v9
82 real, dimension(ims:ime, okms:okme, jms:jme):: pp, tentm, t0, s0, u0,v0
83 real, dimension(ims:ime, okms:okme, jms:jme):: dz, tham, tvam
84 real :: divu, divv, tha, sha, uha, vha, tva, vva, sva, uva, pgx, pgy
85 real, dimension(okms:okme) :: tb5, sb5, ub5, vb5, tb4, sb4, ub4, vb4
86 real, dimension(ims:ime,okms:okme, jms:jme) :: trr, srr
87 real, dimension(ims:ime, okms:okme, jms:jme)::bbeta, aalpha,sg
89 real :: dt, dti,dt7,vs, us,omdt
90 real :: dtdy, dtdx, dsdy, dsdx, dudy, dudx, dvdy, dvdx, wavg, &
91 dtdz, dsdz, dudz, dvdz
92 integer :: iupw, kvs, kus, ia, ja
94 i_start = max(its,ids+1)
95 i_end = min(ite,ide-2)
96 j_start = max(jts,jds+1)
97 j_end = min(jte,jde-2)
100 print*,'3DPWP domain',id,' run ocean'
127 !----------------------------------------------------------------
128 ! these flags control the dynamics of the model:
130 ! noasym = 1 shuts off the asymmetry of the storm winds
131 ! = 2 also shuts off radial wind component of storm winds
132 ! nonlcl = 1 shuts off horizontal advection,
133 ! = 2 shuts off horizontal and vertical advection,
134 ! = 3 above plus applies spatially constant wind stress
135 ! (useful for testing 1-d dynamics)
136 ! nodeep = 1 shuts off ml deepening by entrainment
137 ! nopg = 1 shuts off pressure gradients
138 ! idia = 1 turns on diagnostics
139 ! to calculate 1D pwp just choose nonlcl = 2, and nopg = 1
141 ! set flags to default values
147 ! set some scales that are used for diagnostics - be careful with these !!
149 if(nopg.eq.1) pscale = 0.
151 if(nonlcl.ge.1) hascale = 0.
157 !------------------------------------------------------------------
159 ! calculate the expansion coefficient
171 do i = i_start-1, i_end+1
172 do j = j_start-1, j_end+1
173 f (i,j)= 2.0*7.29e-5*sin(om_lat(i,j)*d2r)
174 if (om_tmp(i,1,j) .gt. 0.0) then
176 trr(i,k,j) = om_tini(i,k,j)
177 srr(i,k,j) = om_sini(i,k,j)
178 aalpha(i,k,j) = sgt(trr(i,k,j)+0.5, srr(i,k,j), sg(i,k,j))- &
179 sgt(trr(i,k,j)-0.5,srr(i,k,j), sg(i,k,j))
180 bbeta(i,k,j) = sgt(trr(i,k,j), srr(i,k,j)+0.5, sg(i,k,j) )-sgt(trr(i,k,j),srr(i,k,j)-0.5, sg(i,k,j))
193 if (ii .eq. 2) go to 88
194 do i= i_start-1, i_end+1
195 do j = j_start-1, j_end+1
201 t9(i,k,j) = om_tmp(i,k,j)
202 u9(i,k,j) = om_u(i,k,j)
203 v9(i,k,j) = om_v(i,k,j)
204 s9(i,k,j) = om_s(i,k,j)
205 t0(i,k,j) = om_tmp(i,k,j)
206 u0(i,k,j) = om_u(i,k,j)
207 v0(i,k,j) = om_v(i,k,j)
208 s0(i,k,j) = om_s(i,k,j)
221 do i = i_start-1, i_end+1
222 do j = j_start-1, j_end+1
224 t0(i,k,j) = t9(i,k,j)
225 u0(i,k,j) = u9(i,k,j)
226 v0(i,k,j) = v9(i,k,j)
227 s0(i,k,j) = s9(i,k,j)
237 do 635 j = j_start, j_end
238 do 635 i = i_start, i_end
245 if (om_tmp(ip,1,j) .le. 0 .or. om_tmp(im,1,j) .le. 0 .or. om_tmp(i,1,jp) .le. 0 .or. om_tmp(i,1,jm) .le.0 ) then
253 mrdx = rdx* msfu(i,j)
254 mrdy = rdy* msfv(i,j)
256 dz(i,k,j) = om_depth(i,k,j)
258 dz(i,k,j) = om_depth(i,k,j)-om_depth(i,k-1,j)
260 divu = dz(i,k,j)*(om_u(ip,k,j)-om_u(im,k,j))*mrdx/2.0
261 divv = dz(i,k,j)*(om_v(i,k,jp)-om_v(i,k,jm))*mrdy/2.0
262 om_w(i,k,j) = divu+divv
265 om_w(i,k,j) = om_w(i,k,j)+om_w(i,k-1,j)
271 if (jts .eq. jds) then
273 om_w(i,k,jts) = om_w(i,k,jts+1)
276 if (jte .eq. jde-1) then
278 om_w(i,k,jte) = om_w(i,k,jte-1)
281 if (its .eq. ids) then
283 om_w(its,k,j) = om_w(its+1,k,j)
286 if (ite.eq. ide-1) then
288 om_w(ite,k,j) = om_w(ite-1,k,j)
291 if(its.eq. ids.and.jts .eq. jds) then
292 om_w(its,k,jts) = om_w(its+1,k,jts+1)
294 if(its.eq. ids.and.jte .eq. jde-1) then
295 om_w(its,k,jte) = om_w(its+1,k,jte-1)
297 if(ite.eq. ide-1.and.jte .eq. jde-1) then
298 om_w(ite,k,jte) = om_w(ite-1,k,jte-1)
300 if(ite.eq. ide-1.and.jts .eq. jds) then
301 om_w(ite,k,jts) = om_w(ite-1,k,jts+1)
306 ! compute the pressure perturbation by integrating
307 do 6327 i = i_start-1, i_end+1
308 do 6327 j = j_start-1, j_end+1
311 dz(i,k,j) = om_depth(i,k,j)
313 dz(i,k,j) = om_depth(i,k,j)-om_depth(i,k-1,j)
317 if (om_tmp(i,1,j) .gt. 0) then
318 pp (i,okme,j) = -g*dz(i,okme,j)*(aalpha(i,okme,j)*(om_tmp(i,okme,j)-trr(i,okme,j))+ &
319 bbeta(i,okme,j)*(om_s(i,okme,j)-srr(i,okme,j)))
323 pp(i,kk,j) = -g*dz(i,kk,j)*(aalpha(i,kk,j)*(om_tmp(i,kk,j)-trr(i,kk,j))+ &
324 bbeta(i,kk,j)*(om_s(i,kk,j)-srr(i,kk,j)))+pp(i,kk+1,j)
331 do 410 j = j_start, j_end
334 do 410 i = i_start, i_end
338 mrdx = rdx* msfu(i,j)
339 mrdy = rdy* msfv(i,j)
352 ! estimate the tendencies due to horizontal advection
354 if (IUPW .eq. 1) then
355 vs = sign(1.,om_v(i,k,j))
357 us = sign(1.,om_u(i,k,j))
359 dtdy = vs*(om_tmp(i,k,j)-om_tmp(i,k,j+kvs))*mrdy
360 dtdx = us*(om_tmp(i,k,j)-om_tmp(i+kus,k,j))*mrdx
363 dsdy = vs*(om_s(i,k,j)-om_s(i,k,j+kvs))*mrdy
364 dsdx = us*(om_s(i,k,j)-om_s(i+kus,k,j))*mrdx
367 dudy = vs*(om_u(i,k,j)-om_u(i,k,j+kvs))*mrdy
368 dudx = us*(om_u(i,k,j)-om_u(i+kus,k,j))*mrdx
371 dvdy = vs*(om_v(i,k,j)-om_v(i,k,j+kvs))*mrdy
372 dvdx = us*(om_v(i,k,j)-om_v(i+kus,k,j))*mrdx
374 tha =-(om_v(i,k,j)*dtdy + om_u(i,k,j)*dtdx)
375 sha =-(om_v(i,k,j)*dsdy + om_u(i,k,j)*dsdx)
376 uha =-(om_v(i,k,j)*dudy + om_u(i,k,j)*dudx)
377 vha =-(om_v(i,k,j)*dvdy + om_u(i,k,j)*dvdx)
379 ! estimate the tendencies due to vertical advection
380 ! skip if k = 1, assume that there is no vertical advection at surface
382 if ( k .eq. 1) go to 3323
383 wavg = 0.5*(om_w(i,k-1,j) + om_w(i,k,j))
387 if (k .eq. okme) kp = k
388 dtdz = (om_tmp(i,km,j)-om_tmp(i,kp,j))/(om_depth(i,km,j)-om_depth(i,kp,j))
389 dsdz = (om_s(i,km,j)-om_s(i,kp,j))/(om_depth(i,km,j)-om_depth(i,kp,j))
390 dudz = (om_u(i,km,j)-om_u(i,kp,j))/(om_depth(i,km,j)-om_depth(i,kp,j))
391 dvdz = (om_v(i,km,j)-om_v(i,kp,j))/(om_depth(i,km,j)-om_depth(i,kp,j))
401 !calculate pressure gradient
402 pgx = (pp(ip,k,j) - pp(im,k,j))*mrdx/2.0
403 pgy = (pp(i,k,jp) - pp(i,k,jm))*mrdy/2.0
405 if (( i .eq. its .and. its .eq. ids) .or. (i .eq. ite .and. ite .eq. ide-1) .or. &
406 ( j .eq. jts .and. jts .eq. jds) .or. (j .eq. jte .and. jte .eq. jde-1)) then
409 tt(i,k,j) = tt(i,k,j)
410 st(i,k,j) = st(i,k,j)
411 ut(i,k,j) = ut(i,k,j)
412 vt(i,k,j) = vt(i,k,j)
416 tt(i,k,j) = tt(i,k,j) + tha*hascale + tva*vascale
417 st(i,k,j) = st(i,k,j) + sha*hascale + sva*vascale
418 ut(i,k,j) = ut(i,k,j) + uha*hascale + uva*vascale - pgx*pscale/1023.0
419 vt(i,k,j) = vt(i,k,j) + vha*hascale + vva*vascale - pgy*pscale/1023.0
428 if (jts .eq. jds)then
431 crbc = -cp*rdy*msfv(i,j)
433 tt(i,k,j) = tt(i,k,j) + crbc*(om_tmp(i,k,j) - om_tmp(i, k, j+ja))
434 st(i,k,j) = st(i,k,j) + crbc*(om_s(i,k,j) - om_s(i, k, j+ja))
435 ut(i,k,j) = ut(i,k,j) + crbc*(om_u(i,k,j) - om_u(i, k, j+ja))
436 vt(i,k,j) = vt(i,k,j) + crbc*(om_v(i,k,j) - om_v(i, k, j+ja))
440 if (jte .eq. jde-1)then
442 crbc = -cp*rdy*msfv(i,j)
444 tt(i,k,j) = tt(i,k,j) + crbc*(om_tmp(i,k,j) - om_tmp(i, k, j+ja))
445 st(i,k,j) = st(i,k,j) + crbc*(om_s(i,k,j) - om_s(i, k, j+ja))
446 ut(i,k,j) = ut(i,k,j) + crbc*(om_u(i,k,j) - om_u(i, k, j+ja))
447 vt(i,k,j) = vt(i,k,j) + crbc*(om_v(i,k,j) - om_v(i, k, j+ja))
450 if (its .eq. ids)then
453 crbc = -cp*(rdx*msfu(i,j))
455 tt(i,k,j) = tt(i,k,j) + crbc*(om_tmp(i,k,j) - om_tmp(i+ia, k, j))
456 st(i,k,j) = st(i,k,j) + crbc*(om_s(i,k,j) - om_s(i+ia, k, j))
457 ut(i,k,j) = ut(i,k,j) + crbc*(om_u(i,k,j) - om_u(i+ia, k, j))
458 vt(i,k,j) = vt(i,k,j) + crbc*(om_v(i,k,j) - om_v(i+ia, k, j))
461 if (ite .eq. ide-1)then
464 crbc = -cp*(rdx*msfu(i,j))
466 tt(i,k,j) = tt(i,k,j) + crbc*(om_tmp(i,k,j) - om_tmp(i+ia, k, j))
467 st(i,k,j) = st(i,k,j) + crbc*(om_s(i,k,j) - om_s(i+ia, k, j))
468 ut(i,k,j) = ut(i,k,j) + crbc*(om_u(i,k,j) - om_u(i+ia, k, j))
469 vt(i,k,j) = vt(i,k,j) + crbc*(om_v(i,k,j) - om_v(i+ia, k, j))
473 if (its .eq. ids .and. jts .eq. jds) then
474 tt(its,k,jts) = tt(its+1,k,jts+1)
476 if (its .eq. ids .and. jte .eq. jde-1) then
477 tt(its,k,jte) = tt(its+1,k,jte-1)
479 if (ite .eq. ide-1 .and. jte .eq. jde-1) then
480 tt(ite,k,jte) = tt(ite-1,k,jte-1)
482 if (ite .eq. ide-1 .and. jts .eq. jds) then
483 tt(ite,k,jts) = tt(ite-1,k,jts+1)
491 ! apply the wind stress and air-sea heat hluxes, and deepen the mixed layer by 1Dpwp
493 ! do 510 i = i_start, i_end
494 ! do 510 j = j_start, j_end
499 tb5(k) = om_tmp(i,k,j)
523 call PWP(i,j,k,ims, ime, jms, jme, okms,okme,tb4,&
524 sb4,om_density(i,:,j),om_depth(i,:,j),ub4,&
525 vb4,om_ml(i,j),om_lat(i,j),&
526 om_lon(i,j),HFX(i,j), QFX(i,j),LH(i,j), GSW(i,j),&
527 GLW(i,j), UST(i,j),U_PHY(i,kts,j),V_PHY(i,kts,j),&
528 STBOLT,DELTSM,aalpha(i,:,j),bbeta(i,:,j),om_tini(i,:,j),&
529 om_sini(i,:,j),trr(i,:,j),srr(i,:,j),omdt)
530 ! add mixing tendencies
532 tt(i,k,j) = tt(i,k,j) + (tb4(k)-tb5(k))/dt
533 st(i,k,j) = st(i,k,j) + (sb4(k)-sb5(k))/dt
534 ut(i,k,j) = ut(i,k,j) + (ub4(k)-ub5(k))/dt
535 vt(i,k,j) = vt(i,k,j) + (vb4(k)-vb5(k))/dt
544 om_tmp(i,k,j) = t0(i,k,j) + dti*tt(i,k,j)
545 om_s(i,k,j) = s0(i,k,j) + dti*st(i,k,j)
546 om_u(i,k,j) = u0(i,k,j) + dti*ut(i,k,j)
547 om_v(i,k,j) = v0(i,k,j) + dti*vt(i,k,j)
554 if (XLAND(i,j).GE.1.5)then
557 TSK(i,j) = om_tmp(i, 1, j)
568 !------------------------------------------------------------------
570 SUBROUTINE PWP(i,j,k,ims, ime, jms, jme, okms,okme,om_tmp,om_s, &
571 om_density, om_depth,om_u, om_v,om_ml,om_lat, om_lon, &
572 HFX, QFX,LH, GSW, GLW, UST,UAIR,VAIR,STBOLT,DELTSM,aalpha,bbeta,&
573 om_tini, om_sini,trr,srr,omdt)
575 !----------------------------------------------------------------------------
576 ! Subroutine PWP is a one-dimensional vertical mixing scheme used in DPWP
577 ! based on on Price et al. (1994, JPO).
578 !----------------------------------------------------------------------------
582 integer ,intent(in) ::ims, ime, jms, jme, okms,okme !dimensions
584 real, dimension(okms:okme), intent(inout):: om_tmp, om_s, &
586 real, dimension(okms:okme),intent(inout):: om_u, om_v
588 real,intent(inout) :: om_ml
589 real,intent(inout) :: om_lat, om_lon
591 real,intent(in) :: HFX, QFX,LH, GSW, GLW, ust,STBOLT,DELTSM
593 real, dimension(okms:okme)::absrb,u,v
595 real :: tauxair, tauyair, taux, tauy, &
598 real d2r, g, hcon, f, tr, sr, dr, alpha, beta, energy, sg, &
602 real beta1, beta2, ql, qi
604 real rb,rv, rvc, delr, duv,rg,du,dv
605 real sa,ca,uair,vair,rc
607 real, intent(in) :: omdt
608 real, dimension(okms:okme),intent(in)::aalpha,bbeta, om_tini,om_sini,trr,srr
617 f = 2*7.29e-5*sin(om_lat*d2r)
625 dr = sgt(tr,sr,sg) ! unit of density is sigma
626 alpha = sgt(tr+0.5, sr, sg )-sgt(tr-0.5,sr, sg)
627 beta = sgt(tr, sr+0.5, sg )-sgt(tr,sr-0.5, sg)
630 if (udrag .lt. 100) ucon = 1./(86400*udrag)
631 call absorb(i,j, ims, ime,jms,jme,okms,okme, beta1,beta2, &
632 absrb, om_depth,GSW,GLW)
633 ql = -1.*(LH+HFX+STBOLT*om_tmp(1)**4) ! corrected V3.8
636 om_tmp(1) = om_tmp(1) + dt*ql/(om_depth(1)*ro*cpw)
637 om_s(1)=om_s(1)+om_s(1)*QFX*dt/ro/om_depth(1) ! corrected V3.8
639 dz = om_depth(k)-om_depth(k-1)
640 om_tmp(k) = om_tmp(k) + dt*qi*absrb(k)/(dz*ro*cpw)
643 om_density(k) = (dr+1000.0) +alpha*(om_tmp(k)-tr)+ &
647 call mldep(i,j,k,ims,ime,jms,jme,okms,okme, om_density, &
649 if (dml .gt. 100) print*,'mldep1',dml
650 call si (i, j, ims,ime,jms,jme,okms,okme,om_density, &
654 call mix1(om_tmp, ml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
655 call mix1(om_s, ml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
656 call mix1(om_u, ml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
657 call mix1(om_v, ml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
658 call mix1(om_density, ml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
660 ! above this, should be statically stable
666 call rot(i, j,ims,ime,jms,jme,okms,okme, om_u(k), om_v(k), sa, ca)
668 call mldep(i,j,k, ims,ime,jms,jme,okms,okme, om_density, &
673 om_ml = om_depth(ml)+(om_depth(ml) - om_depth(ml-1))/2.
676 wspd = max(sqrt(uair*uair+vair*vair), 0.1)
677 tauxair = ust*ust*uair/wspd
678 taux = rhoair/ro*tauxair
679 tauyair = ust*ust*vair/wspd
680 tauy = rhoair/ro*tauyair
684 om_u(k) = om_u(k) + du
685 om_v(k) = om_v(k) + dv
687 if(ucon .gt. 1.e-10) then
689 om_u(k) = om_u(k)*(1. - dt*ucon)
690 om_v(k) = om_v(k)*(1. - dt*ucon)
693 ! In pwp origional code, Dr. Price turns off the diffusion
694 ! To use it, check the diffusion parameter in subroutine first
695 ! call diffusion(okms,okme,dt,om_tmp,om_depth)
696 ! call diffusion(okms,okme,dt,om_s,om_depth)
697 ! call diffusion(okms,okme,dt,om_u,om_depth)
698 ! call diffusion(okms,okme,dt,om_v,om_depth)
699 ! call diffusion(okms,okme,dt,om_density,om_depth)
700 ! print*,'ca,sa',ca,sa
701 if(rb .le. 0.00001) go to 50
707 dz = om_depth(k) + (om_depth(k) - om_depth(k-1))/2.
709 delr = (om_density(k+1)-om_density(k))/ro
710 duv =(om_u(k+1)-om_u(k))**2+(om_v(k+1) &
713 if (rv .gt. rvc) go to 41
715 call mix1(om_tmp, mml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
716 call mix1(om_s, mml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
717 call mix1(om_u, mml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
718 call mix1(om_v, mml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
719 call mix1(om_density, mml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
723 if (rg .gt. 1.e-4) call rimix(i,j,k,ims,ime,jms,jme,okms, &
725 rg,om_density,om_depth, om_u, om_v, om_s, om_tmp)
727 call rot(i,j,ims,ime,jms,jme,okms,okme, om_u(k), om_v(k), &
730 call mldep(i,j,k, ims,ime,jms,jme,okms,okme, om_density, &
735 om_ml = om_depth(ml)+ (om_depth(ml) - om_depth(ml-1))/2.
741 ! cyl : PWP's subrouting
742 ! cyl--------------------
743 SUBROUTINE absorb(i,j, ims, ime, jms, jme, okms,okme,beta1, &
744 beta2, absrb, om_depth,GSW,GLW)
747 integer ims, ime, jms, jme, okms, okme
748 real, dimension(okms:okme),intent(inout)::absrb, om_depth
749 real abss, rs1, rs2, beta1, beta2, z1b1, z2b1, z2b2, z1b2,&
768 if (z2b1 .lt. 70) absrb(k) = absrb(k) + &
769 rs1*(exp(-z1b1)-exp(-z2b1))
770 if (z2b2 .lt. 70) absrb(k) = absrb(k) + &
771 rs2*(exp(-z1b2)-exp(-z2b2))
772 abss = abss + absrb(k)
775 END SUBROUTINE absorb
776 !cyl--------------------
777 SUBROUTINE mldep (i,j,k, ims,ime,jms,jme,okms,okme, om_density, &
779 integer i,j,k,kk, ims,ime,jms,jme,okms,okme
782 real, dimension(okms:okme),intent(inout)::om_density,om_depth
785 dd = abs(om_density(k+1) - om_density(k))
786 if (dd .gt. deps) go to 71
792 !cyl--------------------
793 SUBROUTINE si(i, j, ims,ime,jms,jme,okms,okme,om_density, &
796 integer i, j, k, ims,ime,jms,jme,okms,okme, mml,ml
797 real, dimension(okms:okme),intent(inout)::om_density, om_depth
798 real, dimension(okms:okme) :: temp_density
801 temp_density(k) = om_density(k)
805 if (om_density(k) .gt. om_density(k-1)) go to 81
806 if (om_density(k) .lt. om_density(k-1))then
808 call mix1(om_density, mml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
816 !cyl--------------------
817 SUBROUTINE mix1(b,mml, i, j,ims,ime,jms,jme,okms,okme,om_depth)
818 integer i, j, k, ims,ime,jms,jme,okms,okme, mml
819 real,dimension(okms:okme),intent(inout) :: b
820 real,dimension(okms:okme),intent(in) :: om_depth
821 real,dimension(okms:okme) :: dz
827 dz(k) = om_depth(k)-om_depth(k-1)
842 !cyl--------------------
843 SUBROUTINE rot(i, j,ims,ime,jms,jme,okms,okme, om_u, om_v, sa, ca)
844 integer i, j, k, ims,ime,jms,jme,okms,okme
845 real,intent(inout)::om_u, om_v
854 !cyl--------------------
855 SUBROUTINE rimix(i,j,k,ims,ime,jms,jme,okms,okme,rc, rg, &
856 om_density,om_depth, om_u, om_v, om_s, om_tmp)
858 integer i,j,k,ims,ime,jms,jme,okms,okme,kcd,nmix,k1,k2,ks
859 real rc, rg,dd,g,dz,dv,ro,rs
860 real,dimension(okms:okme) :: r
861 real, dimension(okms:okme),intent(inout)::om_density, om_u, &
862 om_depth,om_v, om_s, om_tmp
874 dd = om_density(k+1)-om_density(k)
875 if (dd .lt. 1.e-3) dd = 1.e-3
876 dv = (om_u(k+1)-om_u(k))**2 + (om_v(k+1)-om_v(k))**2
877 if(dv .lt. 1.e-6) dv = 1.e-6
879 dz = (om_depth(1) + om_depth(2) - om_depth(1))/2.
881 dz = (om_depth(k)-om_depth(k-1) + om_depth(k+1) - om_depth(k))/2.
883 r(k) = g*dz*dd/(dv*ro)
888 if (r(k) .lt. rs) go to 3
894 if (rs .ge. rc) go to 99
895 if (ks .ge. kcd ) kcd = ks + 1
896 call stir(i,j,ims,ime,jms,jme,okms,okme,rc,rs, om_tmp, ks,om_depth)
897 call stir(i,j,ims,ime,jms,jme,okms,okme,rc,rs, om_s, ks,om_depth)
898 call stir(i,j,ims,ime,jms,jme,okms,okme,rc,rs, om_density, ks,om_depth)
899 call stir(i,j,ims,ime,jms,jme,okms,okme,rc,rs, om_u, ks,om_depth)
900 call stir(i,j,ims,ime,jms,jme,okms,okme,rc,rs, om_v, ks,om_depth)
903 if (k1 .lt. 1) k1 = 1
905 if (k2 .gt. okme-1) k2 = okme -1
912 !cyl--------------------
913 SUBROUTINE diffusion(okms,okme,dt,a,om_depth)
917 real, dimension(okms:okme):: a, work,dconst,om_depth
923 dz = om_depth(k)-om_depth(k-1)
925 dconst(k) = dt*rkz/dz**2
928 work(k) = dconst(k)*(a(k-1)+a(k+1)-2.*a(k))
931 a(k) = a(k) + work(k)
934 END SUBROUTINE diffusion
935 !cyl--------------------
936 SUBROUTINE stir(i,j,ims,ime,jms,jme,okms,okme,rc,rs,a,ks,depth)
938 integer i,j,k,ims,ime,jms,jme,okms,okme,ks,b
939 real, dimension(okms:okme),intent(inout)::a
940 real, dimension(okms:okme),intent(in)::depth
941 real, dimension(okms:okme)::dz
942 real rcon,rc,rs,ff,rnew,da
949 dz(k) = depth(k) -depth(k-1)
952 da = (a(ks+1)- a(ks))*ff/2.
953 b=2./(1.+dz(ks)/dz(ks+1))
954 a(ks+1)= a(ks+1)-da*b*dz(ks)/dz(ks+1)
957 ! print*,'a',a(ks+1),a(ks)
960 !cyl--------------------
964 sg0 = ((6.76786136e-6*s-4.8249614e-4)*s+0.814876577)*s &
968 FUNCTION sgt(tt,s,sg)
973 20 sgt = ((((-1.43803061e-7*t-1.98248399e-3)*t-0.545939111)*t &
974 +4.53168426)*t)/(t+67.26)+((((1.667e-8*t-8.164e-7)*t &
975 +1.803e-5)*t)*sg+((-1.0843e-6*t+9.8185e-5)*t-4.7867e-3)*t &
980 !--------------------
981 END MODULE module_sf_3dpwp