<p><b>xylar@lanl.gov</b> 2012-01-18 16:23:55 -0700 (Wed, 18 Jan 2012)</p><p>BRANCH COMMIT<br>
<br>
* Added land_ice_lifev module to interface with LifeV finite element solver<br>
   * LifeV calls are currently commented out<br>
<br>
* Modified land_ice_vel subroutines to call land_ice_lifev subroutines<br>
* Separated per block and full domain initializaiton in land_ice_vel (needed by LifeV)<br>
<br>
* Added a call to land_ice_vel_solve in the time integrator, for testing<br>
<br>
Code compliles, but I need an initial condition (or the code for generating one) to test the code<br>
</p><hr noshade><pre><font color="gray">Modified: branches/land_ice/mpas/src/core_land_ice/Makefile
===================================================================
--- branches/land_ice/mpas/src/core_land_ice/Makefile        2012-01-18 22:43:25 UTC (rev 1389)
+++ branches/land_ice/mpas/src/core_land_ice/Makefile        2012-01-18 23:23:55 UTC (rev 1390)
@@ -4,6 +4,7 @@
         mpas_land_ice_test_cases.o \
         mpas_land_ice_time_integration.o \
         mpas_land_ice_vel.o \
+        mpas_land_ice_lifev.o \
         mpas_land_ice_global_diagnostics.o
 
 all: core_land_ice
@@ -15,8 +16,10 @@
 
 mpas_land_ice_time_integration.o: mpas_land_ice_vel.o
 
-mpas_land_ice_vel.o:
+mpas_land_ice_vel.o: mpas_land_ice_lifev.o
 
+mpas_land_ice_lifev.o:
+
 mpas_land_ice_global_diagnostics.o:
 
 mpas_land_ice_mpas_core.o: mpas_land_ice_global_diagnostics.o mpas_land_ice_test_cases.o mpas_land_ice_time_integration.o mpas_land_ice_vel.o

Added: branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_lifev.F
===================================================================
--- branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_lifev.F                                (rev 0)
+++ branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_lifev.F        2012-01-18 23:23:55 UTC (rev 1390)
@@ -0,0 +1,377 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+!  land_ice_lifev
+!
+!&gt; \MPAS land-ice velocity driver
+!&gt; \author Xylar Asay-Davis
+!&gt; \date   18 January 2012
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module contains the routines for interfacing with LifeV
+!&gt;
+!
+!-----------------------------------------------------------------------
+
+module land_ice_lifev
+
+   use mpas_grid_types
+   use mpas_configure
+   use mpas_dmpar
+
+   implicit none
+   private
+   save
+
+   !--------------------------------------------------------------------
+   !
+   ! Public parameters
+   !
+   !--------------------------------------------------------------------
+
+   !--------------------------------------------------------------------
+   !
+   ! Public member functions
+   !
+   !--------------------------------------------------------------------
+
+   public :: land_ice_lifev_init, &amp;
+             land_ice_lifev_finalize, &amp;
+             land_ice_lifev_block_init, &amp;
+             land_ice_lifev_solve
+
+   !--------------------------------------------------------------------
+   !
+   ! Private module variables
+   !
+   !--------------------------------------------------------------------
+
+   ! halo exchange arrays
+   integer, dimension(:), pointer :: sendCellsArray, &amp;
+                                     recvCellsArray, &amp;
+                                     sendVerticesArray, &amp;
+                                     recvVerticesArray, &amp;
+                                     sendEdgesArray, &amp;
+                                     recvEdgesArray
+
+!***********************************************************************
+
+contains
+
+!***********************************************************************
+!
+!  routine land_ice_lifev_init
+!
+!&gt; \brief   Initializes velocity solver
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    18 January 2012
+!&gt; \version SVN:$Id$
+!&gt; \details
+!&gt;  This routine initializes the ice velocity solver.
+!
+!-----------------------------------------------------------------------
+
+   subroutine land_ice_lifev_init(domain, err)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      type (domain_type), intent(inout) :: domain
+
+      !-----------------------------------------------------------------
+      !
+      ! input/output variables
+      !
+      !-----------------------------------------------------------------
+
+      !-----------------------------------------------------------------
+      !
+      ! output variables
+      !
+      !-----------------------------------------------------------------
+
+      integer, intent(out) :: err !&lt; Output: error flag
+
+      !-----------------------------------------------------------------
+      !
+      ! local variables
+      !
+      !-----------------------------------------------------------------
+
+      integer :: nCells, nEdges, nVertices, nCellsSolve, nEdgesSolve, nVerticesSolve, nVertLevels
+
+      integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnVertex, verticesOnCell, verticesOnEdge
+
+      real (kind=RKIND), dimension(:), pointer :: xCell, yCell, zCell
+
+      logical, dimension(:), pointer :: verticesMask
+
+      logical :: keepVertex
+
+      err = 0
+
+      ! Note: the following code assumes that blocklist contains a single block
+      ! Significant modification will be needed when multiple blocks per processor
+      ! are supported.
+
+      !extract data from domain
+      nCellsSolve = domain % blocklist % mesh % nCellsSolve
+      nEdgesSolve = domain % blocklist % mesh % nEdgesSolve
+      nVerticesSolve = domain % blocklist % mesh % nVerticesSolve
+
+      nCells = domain % blocklist % mesh % nCells
+      nEdges = domain % blocklist % mesh % nEdges
+      nVertices = domain % blocklist % mesh % nVertices
+      nVertLevels = domain % blocklist % mesh % nVertLevels
+
+      cellsOnEdge =&gt; domain % blocklist % mesh % cellsOnEdge % array
+      cellsOnVertex =&gt; domain % blocklist % mesh % cellsOnVertex % array
+      verticesOnCell =&gt; domain % blocklist % mesh % verticesOnCell % array
+      verticesOnEdge =&gt; domain % blocklist % mesh % verticesOnEdge % array
+
+      xCell =&gt; domain % blocklist % mesh % xCell % array
+      yCell =&gt; domain % blocklist % mesh % yCell % array
+      zCell =&gt; domain % blocklist % mesh % zCell % array
+
+      !allocate(verticesMask(nVertices))
+
+      !verticesMask = .true. ! all vertices are part of the domain, since thickness isn't necessarily valid here
+
+      !call lifev_init(dminfo % comm, nVerteces)
+
+      !build send and receive arrays using exchange_list
+
+      call array_from_exchange_list(domain % blocklist % parinfo % verticesToSend, sendVerticesArray)
+      call array_from_exchange_list(domain % blocklist % parinfo % verticesToRecv, recvVerticesArray)
+      call array_from_exchange_list(domain % blocklist % parinfo % cellsToSend, sendCellsArray)
+      call array_from_exchange_list(domain % blocklist % parinfo % cellsToRecv, recvCellsArray)
+      call array_from_exchange_list(domain % blocklist % parinfo % edgesToSend, sendEdgesArray)
+      call array_from_exchange_list(domain % blocklist % parinfo % edgesToRecv, recvEdgesArray)
+
+      !call lifeV and set the grid of the velocity solver
+
+      !call lifev_set_velocity_solver_grid(nCells, nEdges, nVertices, nCellsSolve, nEdgesSolve, nVerticesSolve, &amp;
+      !  cellsOnEdge, cellsOnVertex, verticesOnCell, verticesOnEdge, verticesMask, xCell, yCell, zCell, &amp;
+      !  sendCellsArray, recvCellsArray, sendEdgesArray, recvEdgesArray, sendVerticesArray, recvVerticesArray)
+
+      !deallocate(verticesMask)
+
+      !call lifev_initialize_L1L2_solver(nVertLevels)
+
+   !--------------------------------------------------------------------
+
+   end subroutine land_ice_lifev_init
+
+!***********************************************************************
+!
+!  routine land_ice_lifev_finalize
+!
+!&gt; \brief   Initializes velocity solver
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    18 January 2012
+!&gt; \version SVN:$Id$
+!&gt; \details
+!&gt;  This routine initializes the ice velocity solver.
+!
+!-----------------------------------------------------------------------
+
+   subroutine land_ice_lifev_finalize(domain, err)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      type (domain_type), intent(inout) :: domain
+
+      !-----------------------------------------------------------------
+      !
+      ! input/output variables
+      !
+      !-----------------------------------------------------------------
+
+      !-----------------------------------------------------------------
+      !
+      ! output variables
+      !
+      !-----------------------------------------------------------------
+
+      integer, intent(out) :: err !&lt; Output: error flag
+
+      !-----------------------------------------------------------------
+      !
+      ! local variables
+      !
+      !-----------------------------------------------------------------
+
+      err = 0
+
+      deallocate(sendCellsArray, &amp;
+                 recvCellsArray, &amp;
+                 sendVerticesArray, &amp;
+                 recvVerticesArray, &amp;
+                 sendEdgesArray, &amp;
+                 recvEdgesArray)
+
+   !--------------------------------------------------------------------
+
+   end subroutine land_ice_lifev_finalize
+
+!***********************************************************************
+!
+!  routine land_ice_lifev_block_init
+!
+!&gt; \brief   Initializes velocity solver
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    18 January 2012
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine initializes each block of the ice velocity solver.
+!
+!-----------------------------------------------------------------------
+
+   subroutine land_ice_lifev_block_init(mesh, err)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      type (mesh_type), intent(in) :: &amp;
+         mesh          !&lt; Input: mesh information
+
+      !-----------------------------------------------------------------
+      !
+      ! input/output variables
+      !
+      !-----------------------------------------------------------------
+
+      !-----------------------------------------------------------------
+      !
+      ! output variables
+      !
+      !-----------------------------------------------------------------
+
+      integer, intent(out) :: err !&lt; Output: error flag
+
+      !-----------------------------------------------------------------
+      !
+      ! local variables
+      !
+      !-----------------------------------------------------------------
+
+      err = 0
+
+   !--------------------------------------------------------------------
+
+   end subroutine land_ice_lifev_block_init
+
+!***********************************************************************
+
+   subroutine land_ice_lifev_solve(mesh, state, err)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      type (mesh_type), intent(in) :: &amp;
+         mesh          !&lt; Input: mesh information
+
+      !-----------------------------------------------------------------
+      !
+      ! input/output variables
+      !
+      !-----------------------------------------------------------------
+
+      type (state_type), intent(in) :: &amp;
+         state          !&lt; Input/Output: state information
+
+      !-----------------------------------------------------------------
+      !
+      ! output variables
+      !
+      !-----------------------------------------------------------------
+
+      integer, intent(out) :: err !&lt; Output: error flag
+
+      !-----------------------------------------------------------------
+      !
+      ! local variables
+      !
+      !-----------------------------------------------------------------
+      real (kind=RKIND), dimension(:), pointer :: &amp;
+         thck, lsrf, beta
+      real (kind=RKIND), dimension(:,:), pointer :: &amp;
+         unorm
+      real (kind=RKIND), dimension(:,:,:), pointer :: &amp;
+         tracers
+
+      integer :: index_temp
+
+
+
+      err = 0
+
+      thck =&gt; state % thck % array
+      lsrf =&gt; state % lsrf % array
+      beta =&gt; state % beta % array
+      tracers =&gt; state % tracers % array
+      unorm =&gt; state % unorm % array
+
+      index_temp = state % index_temp
+
+      ! call lifev_velocity_solver_L1L2(thck, lsrf, beta, tracers(index_temp,:,:), unorm)
+
+   !--------------------------------------------------------------------
+
+   end subroutine land_ice_lifev_solve
+
+
+   ! private subroutines
+
+   subroutine array_from_exchange_list(exlist, array)
+
+     implicit none
+
+     type (exchange_list), pointer, intent(in) :: exlist
+     type (exchange_list), pointer :: listPtr
+
+     integer, dimension(:), pointer, intent(out) :: array
+     integer :: dataSize, offset, i
+
+     dataSize = 1 !in first position we will store the size of the vector
+     listPtr =&gt; exlist
+     do while (associated(listPtr))
+       dataSize = dataSize + (listPtr % nlist) + 2
+       listPtr =&gt; listPtr % next
+     end do
+
+     allocate(array(dataSize))
+
+     array(1) = dataSize;
+     offset = 2;
+     listPtr =&gt; exlist
+     do while (associated(listPtr))
+       array(offset) = listPtr % procID
+       offset = offset + 1
+       array(offset) = listPtr % nlist
+       do i=1,listPtr % nlist
+         array(i+offset) = listPtr % list(i) -1
+       end do
+       offset = offset + listPtr % nlist + 1
+       listPtr =&gt; listPtr % next
+     end do
+
+   end subroutine array_from_exchange_list
+
+!***********************************************************************
+
+end module land_ice_lifev
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Modified: branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_mpas_core.F
===================================================================
--- branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_mpas_core.F        2012-01-18 22:43:25 UTC (rev 1389)
+++ branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_mpas_core.F        2012-01-18 23:23:55 UTC (rev 1390)
@@ -19,6 +19,7 @@
       use mpas_configure
       use mpas_grid_types
       use land_ice_test_cases
+      use land_ice_vel, only: land_ice_vel_init
    
       implicit none
    
@@ -28,7 +29,9 @@
       real (kind=RKIND) :: dt
       type (block_type), pointer :: block
 
+      integer :: err
 
+
       if (.not. config_do_restart) call setup_land_ice_test_case(domain)
 
       !
@@ -38,6 +41,8 @@
 
       call simulation_clock_init(domain, dt, startTimeStamp)
 
+      call land_ice_vel_init(domain, err)
+
       block =&gt; domain % blocklist
       do while (associated(block))
          call mpas_init_block(block, block % mesh, dt)
@@ -115,7 +120,7 @@
       use mpas_rbf_interpolation
       use mpas_vector_reconstruction
       use land_ice_time_integration
-      use land_ice_vel, only: land_ice_vel_init
+      use land_ice_vel, only: land_ice_vel_block_init
 
       implicit none
    
@@ -139,7 +144,7 @@
                        block % state % time_levs(1) % state % uReconstructMeridional % array    &amp;
                       )
    
-      call land_ice_vel_init(mesh, err_tmp)
+      call land_ice_vel_block_init(mesh, err_tmp)
       err = ior(err, err_tmp)
 
       if(err == 1) then
@@ -346,12 +351,15 @@
    subroutine mpas_core_finalize(domain)
    
       use mpas_grid_types
+      use land_ice_vel, only: land_ice_vel_finalize
    
       implicit none
 
       type (domain_type), intent(inout) :: domain 
       integer :: ierr
  
+     call land_ice_vel_finalize(domain, ierr)
+
      call mpas_destroy_clock(clock, ierr)
 
    end subroutine mpas_core_finalize

Modified: branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_time_integration.F
===================================================================
--- branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_time_integration.F        2012-01-18 22:43:25 UTC (rev 1389)
+++ branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_time_integration.F        2012-01-18 23:23:55 UTC (rev 1390)
@@ -27,6 +27,8 @@
 
       type (block_type), pointer :: block
 
+      integer :: err
+
 !      if (trim(config_time_integration) == 'RK4') then
 !         call land_ice_rk4(domain, dt)
 !      else
@@ -35,7 +37,12 @@
 !         stop
 !      end if
 
+      ! a temporary test that calls the velocity solver on the state at the current time
+
       block =&gt; domain % blocklist
+      call land_ice_vel_solve(block % mesh, block % state % time_levs(1) % state, err)
+
+      block =&gt; domain % blocklist
       do while (associated(block))
          block % state % time_levs(2) % state % xtime % scalar = timeStamp 
          block =&gt; block % next

Modified: branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_vel.F
===================================================================
--- branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_vel.F        2012-01-18 22:43:25 UTC (rev 1389)
+++ branches/land_ice/mpas/src/core_land_ice/mpas_land_ice_vel.F        2012-01-18 23:23:55 UTC (rev 1390)
@@ -16,6 +16,7 @@
 
    use mpas_grid_types
    use mpas_configure
+   use land_ice_lifev
 
    implicit none
    private
@@ -34,6 +35,8 @@
    !--------------------------------------------------------------------
 
    public :: land_ice_vel_init, &amp;
+             land_ice_vel_finalize, &amp;
+             land_ice_vel_block_init, &amp;
              land_ice_vel_solve
 
    !--------------------------------------------------------------------
@@ -52,15 +55,15 @@
 !  routine land_ice_vel_init
 !
 !&gt; \brief   Initializes velocity solver
-!&gt; \author  William Lipscomb
-!&gt; \date    10 January 2012
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    18 January 2012
 !&gt; \version SVN:$Id$
-!&gt; \details 
+!&gt; \details
 !&gt;  This routine initializes the ice velocity solver.
 !
 !-----------------------------------------------------------------------
 
-   subroutine land_ice_vel_init(grid, err)
+   subroutine land_ice_vel_init(domain, err)
 
       !-----------------------------------------------------------------
       !
@@ -68,8 +71,7 @@
       !
       !-----------------------------------------------------------------
 
-      type (mesh_type), intent(in) :: &amp;
-         grid          !&lt; Input: grid information
+      type (domain_type), intent(inout) :: domain
 
       !-----------------------------------------------------------------
       !
@@ -93,22 +95,27 @@
 
       err = 0
 
-!      cellsOnEdge =&gt; grid % cellsOnEdge % array
-!      edgesOnEdge =&gt; grid % edgesOnEdge % array
-!      nEdgesSolve = grid % nEdgesSolve
+      call land_ice_lifev_init(domain, err)
 
-!      do iEdge=1,grid % nEdgesSolve
-!         cell1 = cellsOnEdge(1,iEdge)
-!         cell2 = cellsOnEdge(2,iEdge)
-!      end do
 
    !--------------------------------------------------------------------
 
    end subroutine land_ice_vel_init
 
 !***********************************************************************
+!
+!  routine land_ice_vel_finalize
+!
+!&gt; \brief   Initializes velocity solver
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    18 January 2012
+!&gt; \version SVN:$Id$
+!&gt; \details
+!&gt;  This routine initializes the ice velocity solver.
+!
+!-----------------------------------------------------------------------
 
-   subroutine land_ice_vel_solve(grid, thck, unorm, err)
+   subroutine land_ice_vel_finalize(domain, err)
 
       !-----------------------------------------------------------------
       !
@@ -116,20 +123,109 @@
       !
       !-----------------------------------------------------------------
 
+      type (domain_type), intent(inout) :: domain
+
+      !-----------------------------------------------------------------
+      !
+      ! input/output variables
+      !
+      !-----------------------------------------------------------------
+
+      !-----------------------------------------------------------------
+      !
+      ! output variables
+      !
+      !-----------------------------------------------------------------
+
+      integer, intent(out) :: err !&lt; Output: error flag
+
+      !-----------------------------------------------------------------
+      !
+      ! local variables
+      !
+      !-----------------------------------------------------------------
+
+      err = 0
+
+      call land_ice_lifev_finalize(domain, err)
+
+   !--------------------------------------------------------------------
+
+   end subroutine land_ice_vel_finalize
+
+!***********************************************************************
+!
+!  routine land_ice_vel_block_init
+!
+!&gt; \brief   Initializes velocity solver
+!&gt; \author  William Lipscomb
+!&gt; \date    10 January 2012
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine initializes each block of the ice velocity solver.
+!
+!-----------------------------------------------------------------------
+
+   subroutine land_ice_vel_block_init(mesh, err)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
       type (mesh_type), intent(in) :: &amp;
-         grid          !&lt; Input: grid information
+         mesh          !&lt; Input: mesh information
 
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         thck          !&lt; Input: Thickness at cell center
+      !-----------------------------------------------------------------
+      !
+      ! input/output variables
+      !
+      !-----------------------------------------------------------------
 
       !-----------------------------------------------------------------
       !
+      ! output variables
+      !
+      !-----------------------------------------------------------------
+
+      integer, intent(out) :: err !&lt; Output: error flag
+
+      !-----------------------------------------------------------------
+      !
+      ! local variables
+      !
+      !-----------------------------------------------------------------
+
+      err = 0
+
+      call land_ice_lifev_block_init(mesh, err)
+
+   !--------------------------------------------------------------------
+
+   end subroutine land_ice_vel_block_init
+
+!***********************************************************************
+
+   subroutine land_ice_vel_solve(mesh, state, err)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      type (mesh_type), intent(in) :: &amp;
+         mesh          !&lt; Input: mesh information
+
+      !-----------------------------------------------------------------
+      !
       ! input/output variables
       !
       !-----------------------------------------------------------------
 
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         unorm         !&lt; Input/Output: Normal velocity at cell edge
+      type (state_type), intent(in) :: &amp;
+         state          !&lt; Input/Output: state information
 
       !-----------------------------------------------------------------
       !
@@ -147,15 +243,8 @@
 
       err = 0
 
-!      cellsOnEdge =&gt; grid % cellsOnEdge % array
-!      edgesOnEdge =&gt; grid % edgesOnEdge % array
-!      nEdgesSolve = grid % nEdgesSolve
+      call land_ice_lifev_solve(mesh, state, err)
 
-!      do iEdge=1,grid % nEdgesSolve
-!         cell1 = cellsOnEdge(1,iEdge)
-!         cell2 = cellsOnEdge(2,iEdge)
-!      end do
-
    !--------------------------------------------------------------------
 
    end subroutine land_ice_vel_solve

</font>
</pre>