Index: src/outgrid_init_nest.f90
===================================================================
--- src/outgrid_init_nest.f90	(revision e200b7adb07d4dfa7bf42f7cb43e0c85b4dbf894)
+++ src/outgrid_init_nest.f90	(revision 8a65cb0801b09eb0ae933a1afabbe10361a9021b)
@@ -22,21 +22,21 @@
 subroutine outgrid_init_nest
 
-  !*****************************************************************************
-  !                                                                            *
-  !  This routine calculates, for each grid cell of the output nest, the       *
-  !  volume and the surface area.                                              *
-  !                                                                            *
-  !     Author: A. Stohl                                                       *
-  !                                                                            *
-  !    30 August 2004                                                          *
-  !                                                                            *
-  !*****************************************************************************
-  !                                                                            *
-  ! Variables:                                                                 *
-  !                                                                            *
-  ! arean              surface area of all output nest cells                   *
-  ! volumen            volumes of all output nest cells                        *
-  !                                                                            *
-  !*****************************************************************************
+!*****************************************************************************
+!                                                                            *
+!  This routine calculates, for each grid cell of the output nest, the       *
+!  volume and the surface area.                                              *
+!                                                                            *
+!     Author: A. Stohl                                                       *
+!                                                                            *
+!    30 August 2004                                                          *
+!                                                                            *
+!*****************************************************************************
+!                                                                            *
+! Variables:                                                                 *
+!                                                                            *
+! arean              surface area of all output nest cells                   *
+! volumen            volumes of all output nest cells                        *
+!                                                                            *
+!*****************************************************************************
 
   use unc_mod
@@ -55,5 +55,5 @@
 
 
-  ! gridunc,griduncn        uncertainty of outputted concentrations
+! gridunc,griduncn        uncertainty of outputted concentrations
   allocate(griduncn(0:numxgridn-1,0:numygridn-1,numzgrid,maxspec, &
        maxpointspec_act,nclassunc,maxageclass),stat=stat)
@@ -61,15 +61,35 @@
 
   if (ldirect.gt.0) then
-  allocate(wetgriduncn(0:numxgridn-1,0:numygridn-1,maxspec, &
-       maxpointspec_act,nclassunc,maxageclass),stat=stat)
-  if (stat.ne.0) write(*,*)'ERROR:could not allocate nested gridunc'
-  allocate(drygriduncn(0:numxgridn-1,0:numygridn-1,maxspec, &
-       maxpointspec_act,nclassunc,maxageclass),stat=stat)
-  if (stat.ne.0) write(*,*)'ERROR:could not allocate nested gridunc'
+    allocate(wetgriduncn(0:numxgridn-1,0:numygridn-1,maxspec, &
+         maxpointspec_act,nclassunc,maxageclass),stat=stat)
+    if (stat.ne.0) write(*,*)'ERROR:could not allocate nested gridunc'
+    allocate(drygriduncn(0:numxgridn-1,0:numygridn-1,maxspec, &
+         maxpointspec_act,nclassunc,maxageclass),stat=stat)
+    if (stat.ne.0) write(*,*)'ERROR:could not allocate nested gridunc'
   endif
 
-  ! Compute surface area and volume of each grid cell: area, volume;
-  ! and the areas of the northward and eastward facing walls: areaeast, areanorth
-  !***********************************************************************
+! Extra field for totals at MPI root process
+  if (lroot.and.mpi_mode.gt.0) then
+    ! allocate(griduncn0(0:numxgridn-1,0:numygridn-1,numzgrid,maxspec, &
+    !      maxpointspec_act,nclassunc,maxageclass),stat=stat)
+    ! if (stat.ne.0) write(*,*)'ERROR:could not allocate nested gridunc'
+
+    if (ldirect.gt.0) then
+      allocate(wetgriduncn0(0:numxgridn-1,0:numygridn-1,maxspec, &
+           maxpointspec_act,nclassunc,maxageclass),stat=stat)
+      if (stat.ne.0) write(*,*)'ERROR:could not allocate nested gridunc'
+      allocate(drygriduncn0(0:numxgridn-1,0:numygridn-1,maxspec, &
+           maxpointspec_act,nclassunc,maxageclass),stat=stat)
+      if (stat.ne.0) write(*,*)'ERROR:could not allocate nested gridunc'
+    endif
+! allocate a dummy to avoid compilator complaints
+  else if (.not.lroot.and.mpi_mode.gt.0) then
+    allocate(wetgriduncn0(1,1,1,1,1,1),stat=stat)
+    allocate(drygriduncn0(1,1,1,1,1,1),stat=stat)
+  end if
+
+! Compute surface area and volume of each grid cell: area, volume;
+! and the areas of the northward and eastward facing walls: areaeast, areanorth
+!***********************************************************************
 
   do jy=0,numygridn-1
@@ -81,7 +101,7 @@
     else
 
-  ! Calculate area of grid cell with formula M=2*pi*R*h*dx/360,
-  ! see Netz, Formeln der Mathematik, 5. Auflage (1983), p.90
-  !************************************************************
+! Calculate area of grid cell with formula M=2*pi*R*h*dx/360,
+! see Netz, Formeln der Mathematik, 5. Auflage (1983), p.90
+!************************************************************
 
       cosfactp=cos(ylatp*pi180)
@@ -100,6 +120,6 @@
 
 
-  ! Surface are of a grid cell at a latitude ylat
-  !**********************************************
+! Surface are of a grid cell at a latitude ylat
+!**********************************************
 
     gridarea=2.*pi*r_earth*hzone*dxoutn/360.
@@ -108,6 +128,6 @@
       arean(ix,jy)=gridarea
 
-  ! Volume = area x box height
-  !***************************
+! Volume = area x box height
+!***************************
 
       volumen(ix,jy,1)=arean(ix,jy)*outheight(1)
@@ -119,10 +139,10 @@
 
 
-  !**************************************************************************
-  ! Determine average height of model topography in nesteed output grid cells
-  !**************************************************************************
-
-  ! Loop over all output grid cells
-  !********************************
+!**************************************************************************
+! Determine average height of model topography in nesteed output grid cells
+!**************************************************************************
+
+! Loop over all output grid cells
+!********************************
 
   do jjy=0,numygridn-1
@@ -130,6 +150,6 @@
       oroh=0.
 
-  ! Take 100 samples of the topography in every grid cell
-  !******************************************************
+! Take 100 samples of the topography in every grid cell
+!******************************************************
 
       do j1=1,10
@@ -140,6 +160,6 @@
           xl=(xlon-xlon0)/dx
 
-  ! Determine the nest we are in
-  !*****************************
+! Determine the nest we are in
+!*****************************
 
           ngrid=0
@@ -153,6 +173,6 @@
 43        continue
 
-  ! Determine (nested) grid coordinates and auxiliary parameters used for interpolation
-  !*****************************************************************************
+! Determine (nested) grid coordinates and auxiliary parameters used for interpolation
+!*****************************************************************************
 
           if (ngrid.gt.0) then
@@ -192,6 +212,6 @@
       end do
 
-  ! Divide by the number of samples taken
-  !**************************************
+! Divide by the number of samples taken
+!**************************************
 
       orooutn(iix,jjy)=oroh/100.
@@ -201,22 +221,23 @@
 
 
-  !*******************************
-  ! Initialization of output grids
-  !*******************************
+!*******************************
+! Initialization of output grids
+!*******************************
 
   do kp=1,maxpointspec_act
-  do ks=1,nspec
-    do nage=1,nageclass
-      do jy=0,numygridn-1
-        do ix=0,numxgridn-1
-          do l=1,nclassunc
-  ! Deposition fields
-            if (ldirect.gt.0) then
-              wetgriduncn(ix,jy,ks,kp,l,nage)=0.
-              drygriduncn(ix,jy,ks,kp,l,nage)=0.
-            endif
-  ! Concentration fields
-            do kz=1,numzgrid
-              griduncn(ix,jy,kz,ks,kp,l,nage)=0.
+    do ks=1,nspec
+      do nage=1,nageclass
+        do jy=0,numygridn-1
+          do ix=0,numxgridn-1
+            do l=1,nclassunc
+! Deposition fields
+              if (ldirect.gt.0) then
+                wetgriduncn(ix,jy,ks,kp,l,nage)=0.
+                drygriduncn(ix,jy,ks,kp,l,nage)=0.
+              endif
+! Concentration fields
+              do kz=1,numzgrid
+                griduncn(ix,jy,kz,ks,kp,l,nage)=0.
+              end do
             end do
           end do
@@ -225,5 +246,4 @@
     end do
   end do
-  end do
 
 
