Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / var / da / da_par_util / da_patch_to_global_2d.inc
blob2739c67b64ee0c1bbd65d792a9372b179a4b572e
1 subroutine da_patch_to_global_2d (grid, vlocal, vglobal)
3    !---------------------------------------------------------------------
4    ! Purpose: Gathers local 2D array vlocal into global array vglobal. 
5    !
6    ! Must be called by all MPI tasks.
7    !---------------------------------------------------------------------  
9    implicit none
11    type(domain), intent(in)  :: grid
12    real,         intent(in)  :: vlocal(:,:)
13    real,         intent(out) :: vglobal(:,:)
15    real, allocatable :: vlocal3d(:,:,:), vglobal3d(:,:,:)
17    if (trace_use_frequent) call da_trace_entry("da_patch_to_global_2d")
19    allocate(vlocal3d (ims:ime, jms:jme, 1:1))
20    allocate(vglobal3d(ids:ide, jds:jde, 1:1))
22    vlocal3d(:,:,1) = vlocal(:,:)
23    call da_patch_to_global_3d(grid, vlocal3d, vglobal3d, 1)
24    if (rootproc) then
25       vglobal(:,:) = vglobal3d(:,:,1)
26    end if
28    deallocate(vlocal3d)
29    deallocate(vglobal3d)
31    if (trace_use_frequent) call da_trace_exit("da_patch_to_global_2d")
33 end subroutine da_patch_to_global_2d