<p><b>duda</b> 2010-03-30 18:35:34 -0600 (Tue, 30 Mar 2010)</p><p>BRANCH COMMIT<br>
<br>
Add test code to regular MPAS driver to write input files, one file per<br>
process, for CAM test driver with fields already split into blocks.<br>
This simplifies greatly the work in the test driver needed to create<br>
arrays to pass through CAM-MPAS interface.<br>
<br>
To run the CAM test driver, we now need to first run the normal <br>
hydrostatic model to create test driver input files, then recompile<br>
the CAM test driver (cd src; mv driver driver.orig; mv driver_cam_interface driver) <br>
and run.<br>
<br>
M    src/mpas.F<br>
</p><hr noshade><pre><font color="gray">Modified: branches/mpas_cam_coupling/src/driver/mpas.F
===================================================================
--- branches/mpas_cam_coupling/src/driver/mpas.F        2010-03-30 22:04:00 UTC (rev 172)
+++ branches/mpas_cam_coupling/src/driver/mpas.F        2010-03-31 00:35:34 UTC (rev 173)
@@ -16,6 +16,17 @@
       end subroutine mpas_setup_test_case
    end interface mpas_setup_test_case
 
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Begin changes for writing CAM test driver input
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   integer :: iCell, iEdge, k, j
+   character (len=32) :: filename
+   real (kind=RKIND), allocatable, dimension(:) :: SFC_PRES, SFC_GEO 
+   real (kind=RKIND), allocatable, dimension(:,:) :: T 
+   real (kind=RKIND), allocatable, dimension(:,:,:) :: U 
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! End changes for writing CAM test driver input
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
    type (dm_info), pointer :: dminfo
    type (domain_type), pointer :: domain
@@ -35,6 +46,52 @@
    if (.not. config_do_restart) call mpas_setup_test_case(domain)
    call timer_stop(&quot;initialize&quot;)
 
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! End changes for writing CAM test driver input
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   allocate(SFC_PRES(domain % blocklist % mesh % nCellsSolve))
+   allocate(SFC_GEO(domain % blocklist % mesh % nCellsSolve))
+   allocate(T(domain % blocklist % mesh % nCellsSolve, domain % blocklist % mesh % nVertLevels))
+   allocate(U(domain % blocklist % mesh % nCellsSolve, domain % blocklist % mesh % maxEdges, domain % blocklist % mesh % nVertLevels))
+   
+   do iCell=1, domain % blocklist % mesh % nCellsSolve
+      SFC_PRES(iCell) = domain % blocklist % time_levs(1) % state % surface_pressure % array(iCell)
+      SFC_GEO(iCell) = domain % blocklist % time_levs(1) % state % geopotential % array(1,iCell)
+
+      do k=1, domain % blocklist % mesh % nVertLevels
+         T(iCell,k) = domain % blocklist % time_levs(1) % state % theta % array(k,iCell)
+         T(iCell,k) = T(iCell,k) * (0.5 * (domain % blocklist % time_levs(1) % state % pressure % array(k, iCell) +   &amp;
+                                           domain % blocklist % time_levs(1) % state % pressure % array(k+1, iCell))  &amp;
+                                    / 100000.0                                                                        &amp;
+                                   ) ** (287.0 / 1003.0)
+         do j=1,domain % blocklist % mesh % nEdgesOnCell % array(iCell)
+            iEdge = domain % blocklist % mesh % edgesOnCell % array(j,iCell)
+!NOTE: Might need to adjust sign +/-
+            U(iCell,j,k) = domain % blocklist % time_levs(1) % state % u % array(k,iEdge)
+         end do
+      end do
+   end do
+   
+   write(filename, '(a,i4.4)') 'test_driver_input.', domain % dminfo % my_proc_id
+   open(22, file=trim(filename), form='unformatted')
+   write(22) domain % blocklist % mesh % nCellsSolve
+   write(22) domain % blocklist % mesh % maxEdges
+   write(22) domain % blocklist % mesh % nVertLevels
+   write(22) num_scalars
+   write(22) SFC_PRES
+   write(22) SFC_GEO
+   write(22) T
+   write(22) U
+   close(22)
+   
+   deallocate(SFC_PRES)
+   deallocate(SFC_GEO)
+   deallocate(T)
+   deallocate(U)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! End changes for writing CAM test driver input
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
    call solve(domain) 
 
    call deallocate_domain(domain)

</font>
</pre>