subroutine globalaverage2d(ngrid,var,globaverage2d) use comgeomfi_h use geometry_mod, only: cell_area implicit none !================================================================== ! Purpose ! ------- ! ! Inputs ! ------ ! ngrid Number of vertical columns ! ! Authors ! ------- ! Tanguy Bertrand 2015 ! !================================================================== #include "dimensions.h" !----------------------------------------------------------------------- ! Arguments INTEGER ngrid REAL var(ngrid) ! LOCAL VARIABLES INTEGER ig ! OUTPUT REAL globaverage2d !----------------------------------------------------------------------- globaverage2d = 0.d0 DO ig=2,ngrid-1 globaverage2d = globaverage2d + var(ig)*cell_area(ig) END DO globaverage2d = globaverage2d + var(1)*cell_area(1)*iim globaverage2d = globaverage2d + var(ngrid)*cell_area(ngrid)*iim globaverage2d = globaverage2d/(totarea+(cell_area(1)+cell_area(ngrid))*(iim-1)) end subroutine globalaverage2d