Merge pull request #22 from wirc-sjsu/develop-w21
[WRF-Fire-merge.git] / phys / module_sf_ocean_driver.F
blobc3a8e827e8ffeb95322777c5808f6831bf909320
1 !WRF:MODEL_LAYER:PHYSICS
3 MODULE module_sf_ocean_driver
5 CONTAINS
7 !----------------------------------------------------------------
8    SUBROUTINE OCEAN_DRIVER(tml,t0ml,hml,h0ml,huml,hvml,ust,u_phy,v_phy, &
9                       tmoml,f,g,oml_gamma,                         &
10                       XLAND,HFX,LH,TSK,GSW,GLW,EMISS,              &
11                       DELTSM,STBOLT,OML_RELAXATION_TIME,           &
12                       ids,ide, jds,jde, kds,kde,                   &
13                       ims,ime, jms,jme, kms,kme,                   &
14                       its,ite, jts,jte, kts,kte,                   &
15                       sf_ocean_physics,okms, okme,                 & !cyl
16                       om_tmp,om_s,om_u, om_v, om_depth, om_ml,     & !cyl
17                       om_lat, om_lon,                              & !cyl
18                       QFX,                                         & !cyl 
19                       rdx, rdy, msfu, msfv, msft,xtime,om_tini,om_sini,id,omdt, & !cyl
20                       itimestep)
22 !----------------------------------------------------------------
23 #if ( EM_CORE==1)
24    USE module_state_description, ONLY : OMLSCHEME , PWP3DSCHEME
25    USE module_sf_oml
26    USE module_sf_3dpwp
27 #endif
29    IMPLICIT NONE
30 !----------------------------------------------------------------
32 !  SUBROUTINE OCEANML CALCULATES THE SEA SURFACE TEMPERATURE (TSK)
33 !  FROM A SIMPLE OCEAN MIXED LAYER MODEL BASED ON
34 !  (Pollard, Rhines and Thompson (1973).
36 !-- TML         ocean mixed layer temperature (K)
37 !-- T0ML        ocean mixed layer temperature (K) at initial time
38 !-- TMOML       top 200 m ocean mean temperature (K) at initial time
39 !-- HML         ocean mixed layer depth (m)
40 !-- H0ML        ocean mixed layer depth (m) at initial time
41 !-- HUML        ocean mixed layer u component of wind
42 !-- HVML        ocean mixed layer v component of wind
43 !-- OML_GAMMA   deep water lapse rate (K m-1)
44 !-- OML_RELAXATION_TIME    Time scale (s) to relax TML to T0ML, H to H0,
45 !                          HUML and HVML to 0; value <=0 means no relaxation
46 !-- UAIR,VAIR   lowest model level wind component
47 !-- UST         frictional velocity
48 !-- HFX         upward heat flux at the surface (W/m^2)
49 !-- LH          latent heat flux at the surface (W/m^2)
50 !-- TSK         surface temperature (K)
51 !-- GSW         downward short wave flux at ground surface (W/m^2)
52 !-- GLW         downward long wave flux at ground surface (W/m^2)
53 !-- EMISS       emissivity of the surface
54 !-- XLAND       land mask (1 for land, 2 for water)
55 !-- STBOLT      Stefan-Boltzmann constant (W/m^2/K^4)
56 !-- F           Coriolis parameter
57 !-- DT          time step (second)
58 !-- G           acceleration due to gravity
60    INTEGER,  INTENT(IN   )   ::     ids,ide, jds,jde, kds,kde,  &
61                                     ims,ime, jms,jme, kms,kme,  &
62                                     its,ite, jts,jte, kts,kte
64    REAL,     INTENT(IN   )   ::     DELTSM, STBOLT
66    REAL,    DIMENSION( ims:ime, jms:jme )                     , &
67             INTENT(IN   )    ::                          EMISS, &
68                                                          XLAND, &
69                                                            GSW, &
70                                                            GLW, &
71                                                            HFX, &
72                                                             LH
74    REAL,    DIMENSION( ims:ime, jms:jme )                     , &
75             INTENT(INOUT)    ::                            TSK
77    REAL,    DIMENSION( ims:ime, jms:jme ), INTENT(INOUT) ::     &
78                                     TML,T0ML,HML,H0ML,HUML,HVML
80    REAL,    DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(IN   ) ::     &
81                                              U_PHY,V_PHY
83    REAL,    DIMENSION( ims:ime, jms:jme ), INTENT(IN   ) ::     &
84                                              UST, F, TMOML
86    REAL,    INTENT(IN   )   ::     G
87    REAL,    INTENT(IN   )   ::     OML_GAMMA, OML_RELAXATION_TIME
89 ! LOCAL VARS
91    INTEGER ::  I,J
93 ! variables for subrouting Dpwp
95   INTEGER, OPTIONAL, INTENT(IN )::  sf_ocean_physics
96   integer :: okms, okme
97   real, dimension(ims:ime, okms:okme, jms:jme), INTENT(INOUT):: OM_TMP,OM_S,OM_U,OM_V,OM_DEPTH
98   real, dimension(ims:ime, okms:okme, jms:jme):: om_density 
99   real, dimension(ims:ime, okms:okme, jms:jme), INTENT(IN):: OM_TINI,OM_SINI
100   real, dimension(ims:ime, jms:jme),INTENT(INOUT):: OM_ML, OM_LAT, OM_LON
101   REAL, INTENT(IN   ) :: rdx, rdy,xtime,omdt
102   REAL , DIMENSION( ims:ime , jms:jme ) , INTENT(IN   ) :: msfu, msfv, msft,qfx
103   INTEGER , INTENT(IN)        :: id,itimestep
104   integer :: stepom
106 #if ( EM_CORE==1)
107 ! calculate the steps of om
109   stepom=nint(omdt*60/deltsm)
110   stepom = max(stepom,1) 
112 ! cyl:OML1D or DPWP
114 if ( sf_ocean_physics .eq. OMLSCHEME ) then
116    DO J=jts,jte
118          DO i=its,ite
119             IF (XLAND(I,J).GT.1.5) THEN
120                CALL OML1D(I,J,TML(i,j),T0ML(i,j),HML(i,j),H0ML(i,j),           &
121                           HUML(i,j),HVML(i,j),TSK(i,j),HFX(i,j),               &
122                           LH(i,j),GSW(i,j),GLW(i,j),TMOML(i,j),                &
123                           U_PHY(i,kts,j),V_PHY(i,kts,j),UST(i,j),F(i,j),       &
124                           EMISS(i,j),STBOLT,G,DELTSM,OML_GAMMA,                &
125                           OML_RELAXATION_TIME,                                 &
126                           ids,ide, jds,jde, kds,kde,                           &
127                           ims,ime, jms,jme, kms,kme,                           &
128                           its,ite, jts,jte, kts,kte                            )
129             ENDIF
130          ENDDO
132    ENDDO
134 ! call 3DPWP
136 elseif ( sf_ocean_physics .eq. PWP3DSCHEME ) then 
137        call wrf_debug ( 100, 'call 3DPWP' )
138        if ( itimestep .eq. 1 .or. mod(itimestep, stepom) .eq. 0 ) then
139          ! run 3DPWP only when the grid resolution larger than 3.0 km
140           print*,'dx',1.0/rdx
141           if ( 1.0/rdx .ge. 3000.0 .and. 1.0/rdy .ge. 3000.0 ) then  
142              call DPWP(ims,ime, jms,jme, kms,kme,its,ite, jts,jte, kts,kte, &
143                     ids,ide, jds,jde, kds,kde,okms, okme,                   &
144                     om_tmp,om_s,om_u, om_v, om_density, om_depth, om_ml,    &
145                     om_lat, om_lon,                                         &
146                     HFX, QFX, GSW, GLW, UST, U_PHY, V_PHY,                  &
147                     STBOLT, DELTSM, TSK, LH, XLAND,                         &
148                     rdx, rdy, msfu, msfv, msft,xtime,om_tini,om_sini,id,omdt)
149           else
150               print*,'Domain',id,' no ocean'
151               do  i = its, ite
152                   do  j = jts, jte
153                       if (XLAND(i,j).GE.1.5)then
154                          TSK(i,j) = om_tmp(i, 1, j)
155                       endif
156                   enddo
157               enddo
159           endif 
160        endif
161 endif 
162 #endif
164    END SUBROUTINE OCEAN_DRIVER
166 !----------------------------------------------------------------
168 END MODULE module_sf_ocean_driver