<p><b>laura@ucar.edu</b> 2010-07-23 15:17:51 -0600 (Fri, 23 Jul 2010)</p><p>manages physics arrays and variables on the wrf-like grid<br>
</p><hr noshade><pre><font color="gray">Added: branches/atmos_physics/src/core_physics/module_physics_manager.F
===================================================================
--- branches/atmos_physics/src/core_physics/module_physics_manager.F                                (rev 0)
+++ branches/atmos_physics/src/core_physics/module_physics_manager.F        2010-07-23 21:17:51 UTC (rev 413)
@@ -0,0 +1,176 @@
+!=============================================================================================
+ module module_physics_manager
+ use configure
+ use grid_types

+ use module_convection_deep
+ use module_microphysics
+ use module_pbl
+ use module_physics_sfclayer
+ use module_physics_vars
+
+ implicit none
+ private
+ public:: physics_timetracker,physics_wrf_interface,physics_wrf_deallocate
+
+ logical, public:: l_physics
+
+
+ contains
+
+!=============================================================================================
+ subroutine physics_timetracker(itimestep)
+!=============================================================================================
+
+!input arguments:
+!----------------
+ integer,intent(in):: itimestep
+
+!=============================================================================================
+ write(6,*) '--- enter subroutine physics_timetracker'
+ write(6,*) '--- itimestep=', itimestep
+
+ l_physics = .false.
+ if(mod(itimestep-1,config_n_physics) == 0) l_physics = .true.
+ write(6,*) '--- physics_control:',itimestep,config_n_physics,l_physics
+ write(6,*)
+
+ end subroutine physics_timetracker
+
+!=============================================================================================
+ subroutine physics_wrf_interface(mesh)
+!=============================================================================================
+
+!input arguments:
+!----------------
+ type(grid_meta),intent(in):: mesh
+
+!=============================================================================================
+ write(6,*)
+ write(6,*) '--- enter subroutine physics_wrf_interface:'
+
+!initialization of wrf dimensions:
+ ims=1 ; ime = mesh % ncellssolve
+ jms=1 ; jme=1
+ kms=1 ; kme = mesh % nvertlevels+1
+
+ ids=ims ; jds=jms ; kds=kms ; its=ims ; jts=jms ; kts=kms
+ ide=ime ; jde=jme ; kde=kme ; ite=ime ; jte=jme ; kte=kme
+ itf=ite ; jtf=jte ; ktf=kte-1
+
+ write(6,*) '    ims= ',ims,' ime=',ime
+ write(6,*) '    jms= ',jms,' jme=',jme
+ write(6,*) '    kms= ',kms,' kme=',kme
+ write(6,*)
+ write(6,*) '    ids= ',ids,' ide=',ide
+ write(6,*) '    jds= ',jds,' jde=',jde
+ write(6,*) '    kds= ',kds,' kde=',kde
+ write(6,*)
+ write(6,*) '    its= ',its,' ite=',ite
+ write(6,*) '    jts= ',jts,' jte=',jte
+ write(6,*) '    kts= ',kts,' kte=',kte
+
+!initialization of physics time-steps:
+ dt_dyn     = config_dt
+ n_physics  = config_n_physics
+ n_microp   = config_n_microp
+ n_cu       = config_n_conv
+ n_pbl      = config_n_pbl
+
+ dt_physics = dt_dyn*n_physics        
+ dt_microp  = nint(dt_dyn/n_microp) !for now.
+ dt_cu      = dt_physics            !for now.
+ dt_pbl     = dt_physics            !for now.
+
+!allocation of all physics arrays:
+ call physics_allocate_all
+
+!initialization of variables and allocation of arrays related to microphysics:
+ if(config_microp_scheme .ne. 'off') then
+
+    if(config_microp_scheme .eq. 'kessler' ) microp_scheme = microp_kessler
+    if(config_microp_scheme .eq. 'thompson') microp_scheme = microp_thompson

+    call microphysics_allocate
+    
+ endif
+
+!initialization of variables and allocation of arrays related to deep convection:
+
+ if(config_conv_deep_scheme .ne. 'off') then 
+    if(config_conv_deep_scheme .eq. 'kain_fritsch') conv_deep_scheme = conv_deep_kf
+    call convection_deep_allocate
+ endif
+
+!initialization of variables and allocation of arrays related to shallow convection:
+
+ if(config_conv_shallow_scheme .ne. 'off') then 
+    if(config_conv_shallow_scheme .eq. 'uw') conv_deep_scheme = conv_shallow_uw
+ endif
+
+!initialization of variables and allocation of arrays related to pbl processes:
+
+ if(config_pbl_scheme .ne. 'off') then
+
+    if(config_pbl_scheme .eq. 'ysu') pbl_scheme = pbl_ysu
+    call pbl_allocate
+
+ endif
+
+!initialization of variables and allocation of arrays related to surface processes:
+
+ if(config_sfclay_scheme .ne. 'off') then
+
+    if(config_sfclay_scheme .eq. 'monin_obukhov') sfclayer_scheme = sfc_mnkhov
+    call sfclayer_allocate
+
+ endif
+
+ end subroutine physics_wrf_interface
+
+!=============================================================================================
+ subroutine physics_allocate_all
+!=============================================================================================
+ if(.not.allocated(u_p)  )  allocate(u_p(ims:ime,kms:kme,jms:jme)  )
+ if(.not.allocated(v_p)  )  allocate(v_p(ims:ime,kms:kme,jms:jme)  )
+ if(.not.allocated(w_p)  )  allocate(w_p(ims:ime,kms:kme,jms:jme)  )
+ if(.not.allocated(p_p)  )  allocate(p_p(ims:ime,kms:kme,jms:jme)  )
+ if(.not.allocated(pi_p) )  allocate(pi_p(ims:ime,kms:kme,jms:jme) )
+ if(.not.allocated(z_p)  )  allocate(z_p(ims:ime,kms:kme,jms:jme)  )
+ if(.not.allocated(dz_p) )  allocate(dz_p(ims:ime,kms:kme,jms:jme) )
+ if(.not.allocated(t_p)  )  allocate(t_p(ims:ime,kms:kme,jms:jme)  )
+ if(.not.allocated(th_p) )  allocate(th_p(ims:ime,kms:kme,jms:jme) )
+ if(.not.allocated(al_p) )  allocate(al_p(ims:ime,kms:kme,jms:jme) )
+ if(.not.allocated(rho_p))  allocate(rho_p(ims:ime,kms:kme,jms:jme))
+
+ if(.not.allocated(rthten_p)) allocate(rthten_p(ims:ime,kms:kme,jms:jme))
+ if(.not.allocated(rqten_p) ) allocate(rqten_p(ims:ime,kms:kme,jms:jme,num_scalars))
+
+ end subroutine physics_allocate_all
+
+!=============================================================================================
+ subroutine physics_wrf_deallocate
+!=============================================================================================
+
+!de-allocation of all physics arrays:
+ if(allocated(u_p)     ) deallocate(u_p     )
+ if(allocated(v_p)     ) deallocate(v_p     )
+ if(allocated(w_p)     ) deallocate(w_p     )
+ if(allocated(p_p)     ) deallocate(p_p     )
+ if(allocated(pi_p)    ) deallocate(pi_p    )
+ if(allocated(z_p)     ) deallocate(z_p     )
+ if(allocated(dz_p)    ) deallocate(dz_p    )
+ if(allocated(t_p)     ) deallocate(t_p     )
+ if(allocated(th_p)    ) deallocate(th_p    )
+ if(allocated(al_p)    ) deallocate(al_p    )
+ if(allocated(rho_p)   ) deallocate(rho_p   ) 
+
+ if(allocated(rthten_p)) deallocate(rthten_p)
+ if(allocated(rqten_p) ) deallocate(rqten_p )
+
+ end subroutine physics_wrf_deallocate
+
+!=============================================================================================
+ end module module_physics_manager
+!=============================================================================================


</font>
</pre>