[mpas-developers] one more if statement change

Mark Petersen mpetersen at lanl.gov
Mon Nov 15 14:18:11 MST 2010


This is similar to issues I raised a few weeks ago.

If a cell is outside of the local domain, it has number nCells+1, and so 
tend_h(k,nCells+1) just accumulates fluxes that are never used. Note that tend 
is indeed dimensioned to nCells+1, so we are not writing out of bounds:  in 
module_grid_types.f90,

       allocate(tend % h % array(nVertLevels, nCells + 1))

Here are the proposed changes.  The hyd_atmos core already includes these 
changes under
!  calculate omega, update theta
The ocean core will have these changes merged from the topography branch.

Mark

******** sw core, old version
       !
       ! Compute height tendency for each cell
       !
       tend_h(:,:) = 0.0
       do iEdge=1,nEdges
             cell1 = cellsOnEdge(1,iEdge)
             cell2 = cellsOnEdge(2,iEdge)
             if (cell1 <= nCells) then
                do k=1,nVertLevels
                   flux = u(k,iEdge) * dvEdge(iEdge) * h_edge(k,iEdge)
                   tend_h(k,cell1) = tend_h(k,cell1) - flux
                end do
             end if
             if (cell2 <= nCells) then
                do k=1,nVertLevels
                   flux = u(k,iEdge) * dvEdge(iEdge) * h_edge(k,iEdge)
                   tend_h(k,cell2) = tend_h(k,cell2) + flux
                end do
             end if
       end do


******** sw core, recommended revised version
       !
       ! Compute height tendency for each cell
       !
       tend_h(:,:) = 0.0
       do iEdge=1,nEdges
          cell1 = cellsOnEdge(1,iEdge)
          cell2 = cellsOnEdge(2,iEdge)
          do k=1,nVertLevels
             flux = u(k,iEdge) * dvEdge(iEdge) * h_edge(k,iEdge)
             tend_h(k,cell1) = tend_h(k,cell1) - flux
             tend_h(k,cell2) = tend_h(k,cell2) + flux
          end do
       end do



More information about the mpas-developers mailing list