<p><b>duda</b> 2012-02-10 10:58:31 -0700 (Fri, 10 Feb 2012)</p><p>BRANCH COMMIT<br>
<br>
Add routine compute_restart_diagnostics() to compute updated values<br>
for theta and rho before they are written to the restart file; these<br>
fields are used for DA restarts but not for regular restarts.<br>
<br>
<br>
M    src/core_nhyd_atmos/mpas_atm_mpas_core.F<br>
</p><hr noshade><pre><font color="gray">Modified: branches/atmos_physics/src/core_nhyd_atmos/mpas_atm_mpas_core.F
===================================================================
--- branches/atmos_physics/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2012-02-10 00:44:25 UTC (rev 1495)
+++ branches/atmos_physics/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2012-02-10 17:58:31 UTC (rev 1496)
@@ -334,6 +334,12 @@
          if (mpas_is_alarm_ringing(clock, restartAlarmID, ierr=ierr)) then
             call mpas_reset_clock_alarm(clock, restartAlarmID, ierr=ierr)
 
+            block_ptr =&gt; domain % blocklist
+            do while (associated(block_ptr))
+               call atm_compute_restart_diagnostics(block_ptr % state % time_levs(1) % state, block_ptr % diag, block_ptr % mesh)
+               block_ptr =&gt; block_ptr % next
+            end do
+
             ! Write one restart time per file
             call mpas_output_state_init(restart_obj, domain, &quot;RESTART&quot;, trim(timeStamp))
             call mpas_output_state_for_domain(restart_obj, domain, 1)
@@ -389,7 +395,7 @@
    
    subroutine atm_compute_output_diagnostics(state, diag, grid)
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! Compute diagnostic fields for a domain
+   ! Compute diagnostic fields for a domain to be written to history files
    !
    ! Input: state - contains model prognostic fields
    !        grid  - contains grid metadata
@@ -418,6 +424,37 @@
    end subroutine atm_compute_output_diagnostics
    
    
+   subroutine atm_compute_restart_diagnostics(state, diag, grid)
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   ! Compute diagnostic fields for a domain to be written to restart files
+   !
+   ! Input: state - contains model prognostic fields
+   !        grid  - contains grid metadata
+   !
+   ! Output: state - upon returning, diagnostic fields will have be computed
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   
+      use mpas_grid_types
+   
+      implicit none
+   
+      type (state_type), intent(inout) :: state
+      type (diag_type), intent(inout) :: diag
+      type (mesh_type), intent(in) :: grid
+   
+      integer :: i, eoe
+      integer :: iCell, k
+
+      do iCell=1,grid%nCells
+         do k=1,grid%nVertLevels
+            diag % theta % array(k,iCell) = state % theta_m % array(k,iCell) / (1.0 + 1.61 * state % scalars % array(state % index_qv,k,iCell))
+            diag % rho % array(k,iCell) = state % rho_zz % array(k,iCell) * grid % zz % array(k,iCell)
+         end do
+      end do
+   
+   end subroutine atm_compute_restart_diagnostics
+   
+   
    subroutine atm_do_timestep(domain, dt, itimestep)
    
       use mpas_grid_types

</font>
</pre>