<p><b>laura@ucar.edu</b> 2010-06-14 10:12:34 -0600 (Mon, 14 Jun 2010)</p><p>Uncommented call to microphysics driver. Added call toadd physics tendencies in the Runge-Kutta loop<br>
</p><hr noshade><pre><font color="gray">Modified: branches/atmos_physics/src/core_hyd_atmos/module_time_integration.F
===================================================================
--- branches/atmos_physics/src/core_hyd_atmos/module_time_integration.F        2010-06-14 16:09:34 UTC (rev 346)
+++ branches/atmos_physics/src/core_hyd_atmos/module_time_integration.F        2010-06-14 16:12:34 UTC (rev 347)
@@ -8,13 +8,14 @@
 
 #ifdef DO_PHYSICS
    use module_microphysics_driver
+   use module_physics_todynamics
 #endif
 
    contains
 
 
 #ifdef DO_PHYSICS
-   subroutine timestep(domain, dt, itimestep)
+   subroutine timestep(domain, dt, itimestep, config_ntimesteps)
 #else
    subroutine timestep(domain, dt)
 #endif
@@ -36,12 +37,12 @@
       type (block_type), pointer :: block
 
 #ifdef DO_PHYSICS
-      integer, intent(in):: itimestep
+      integer, intent(in):: itimestep, config_ntimesteps
 #endif
 
       if (trim(config_time_integration) == 'SRK3') then
 #ifdef DO_PHYSICS
-         call srk3(domain, dt, itimestep)
+         call srk3(domain, dt, itimestep, config_ntimesteps)
 #else
          call srk3(domain, dt)
 #endif
@@ -56,13 +57,12 @@
          block % time_levs(2) % state % xtime % scalar = block % time_levs(1) % state % xtime % scalar + dt
          block =&gt; block % next
       end do
-      write(0,*) '--- end subroutine timestep:'
 
    end subroutine timestep
 
 
 #ifdef DO_PHYSICS
-   subroutine srk3(domain, dt, itimestep)
+   subroutine srk3(domain, dt, itimestep , config_ntimesteps)
 #else
    subroutine srk3(domain, dt)
 #endif
@@ -99,7 +99,7 @@
       real (kind=RKIND) :: global_domain_mass, global_scalar_mass, global_scalar_min, global_scalar_max
 
 #ifdef DO_PHYSICS
-      integer, intent(in):: itimestep
+      integer, intent(in):: itimestep, config_ntimesteps
 #endif
 
       !
@@ -176,10 +176,13 @@
 
         block =&gt; domain % blocklist
         do while (associated(block))
+#ifdef DO_PHYSICS
+!          call physics_addtend( block % intermediate_step(TEND), block % time_levs(2) % state, block % mesh ) 
+#endif
            call compute_dyn_tend( block % intermediate_step(TEND), block % time_levs(2) % state, block % mesh )
            block =&gt; block % next
         end do
-
+        
         if(debug) write(0,*) ' returned from dyn_tend '
 
         !
@@ -392,25 +395,73 @@
       ! LDF end.
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
-!#ifdef DO_PHYSICS
-!     if(config_mp_physics /=0) then
+#ifdef DO_PHYSICS
+      if(config_mp_physics /=0) then
 
-!        block =&gt; domain % blocklist
-!        do while(associated(block))
-!           call microphysics_driver ( block % mesh, block % time_levs(2) % state, itimestep)
-!           block =&gt; block % next
-!        end do         
+         block =&gt; domain % blocklist
+         do while(associated(block))
+            call microphysics_driver ( block % intermediate_step(TEND), block % time_levs(2) % state, &amp;
+                                       block % mesh, itimestep , config_ntimesteps )
 
-!     endif
-!#endif
+            !to be moved into a module:
+            do iCell = 1, block % mesh % nCellsSolve
+               block % time_levs(2) % state % qv_col % array(iCell) = 0.
+               block % time_levs(2) % state % qc_col % array(iCell) = 0.
+               block % time_levs(2) % state % qr_col % array(iCell) = 0.
+               block % time_levs(2) % state % qi_col % array(iCell) = 0.
+               block % time_levs(2) % state % qs_col % array(iCell) = 0.
 
+               do k=1, block % mesh % nVertLevelsSolve
+                  block % time_levs(2) % state % qv_col % array(iCell) = &amp;
+                        block % time_levs(2) % state % qv_col % array(iCell)              &amp;
+                      - block % time_levs(2) % state % scalars % array (index_qv,k,iCell) &amp;
+                      * block % time_levs(2) % state % h % array (k,iCell)                &amp;
+                      * block % mesh % dnw % array (k)
+
+                  block % time_levs(2) % state % qc_col % array(iCell) = &amp;
+                        block % time_levs(2) % state % qc_col % array(iCell)              &amp;
+                      - block % time_levs(2) % state % scalars % array (index_qc,k,iCell) &amp;
+                      * block % time_levs(2) % state % h % array (k,iCell)                &amp;
+                      * block % mesh % dnw % array (k)
+
+                  block % time_levs(2) % state % qr_col % array(iCell) = &amp;
+                        block % time_levs(2) % state % qr_col % array(iCell)              &amp;
+                      - block % time_levs(2) % state % scalars % array (index_qr,k,iCell) &amp;
+                      * block % time_levs(2) % state % h % array (k,iCell)                &amp;
+                      * block % mesh % dnw % array (k)
+
+                  block % time_levs(2) % state % qi_col % array(iCell) = &amp;
+                        block % time_levs(2) % state % qi_col % array(iCell)              &amp;
+                      - block % time_levs(2) % state % scalars % array (index_qi,k,iCell) &amp;
+                      * block % time_levs(2) % state % h % array (k,iCell)                &amp;
+                      * block % mesh % dnw % array (k)
+
+                  block % time_levs(2) % state % qs_col % array(iCell) = &amp;
+                        block % time_levs(2) % state % qs_col % array(iCell)              &amp;
+                      - block % time_levs(2) % state % scalars % array (index_qs,k,iCell) &amp;
+                      * block % time_levs(2) % state % h % array (k,iCell)                &amp;
+                      * block % mesh % dnw % array (k)
+
+                  block % time_levs(2) % state % qg_col % array(iCell) = &amp;
+                        block % time_levs(2) % state % qg_col % array(iCell)              &amp;
+                      - block % time_levs(2) % state % scalars % array (index_qg,k,iCell) &amp;
+                      * block % time_levs(2) % state % h % array (k,iCell)                &amp;
+                      * block % mesh % dnw % array (k)
+               enddo
+            enddo
+
+            block =&gt; block % next
+         end do         
+
+      endif
+#endif
+
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
       ! LDF begin (04-26-2010):
       ! CALL TO CLOUD MICROPHYISCS SCHEMES ENDS HERE:
       ! LDF end.
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
-      write(0,*) '--- end subroutine srk3:'
 
    end subroutine srk3
 
@@ -612,6 +663,7 @@
       pv_edge      =&gt; s % pv_edge % array
       geopotential =&gt; s % geopotential % array
       theta        =&gt; s % theta % array
+      h_diabatic   =&gt; s % h_diabatic % array
 
       weightsOnEdge     =&gt; grid % weightsOnEdge % array
       cellsOnEdge       =&gt; grid % cellsOnEdge % array  
@@ -628,7 +680,7 @@
       vh          =&gt; tend % vh % array
       tend_u      =&gt; tend % u % array
       tend_theta  =&gt; tend % theta % array
-      h_diabatic  =&gt; grid % h_diabatic % array
+!     h_diabatic  =&gt; grid % h_diabatic % array
 
       ww          =&gt; s % ww % array
       rdnu        =&gt; grid % rdnu % array
@@ -868,9 +920,10 @@
 
 !----------- rhs for theta
 
+!#ifndef DO_PHYSICS
       tend_theta(:,:) = 0.
+!#endif
 
-
       !
       !  horizontal mixing for theta - we could combine this with advection directly (i.e. as a turbulent flux),
       !  but here we can also code in hyperdiffusion if we wish (2nd order at present)
@@ -1371,8 +1424,9 @@
 
       nVertLevels = grid % nVertLevels
 
+#ifndef DO_PHYSICS
       scalar_tend = 0.  !  testing purposes - we have no sources or sinks
-
+#endif
       !
       ! Runge Kutta integration, so we compute fluxes from scalar_new values, update starts form scalar_old
       !

</font>
</pre>