Index: pathnames
===================================================================
--- pathnames	(revision a756649aa5143665ab2654ea5dd5e713950bb1a2)
+++ pathnames	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -1,4 +1,4 @@
-./options_test/
-./output_test/
-/
-/xnilu_wrk/flex_wrk/WIND_FIELDS/AVAILABLE_ECMWF_OPER_fields_global
+./options/
+./output/
+./preprocess/flex_extract/work/
+./AVAILABLE
Index: src/FLEXPART.f90
===================================================================
--- src/FLEXPART.f90	(revision a756649aa5143665ab2654ea5dd5e713950bb1a2)
+++ src/FLEXPART.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -83,6 +83,4 @@
   verbosity=0
 
-  write(*,*) "flexversion: ", flexversion
-
   ! Read the pathnames where input/output files are stored
   !*******************************************************
Index: src/concoutput_mpi.f90
===================================================================
--- src/concoutput_mpi.f90	(revision 6741557b2e77046144879c12ca45ea39587f7099)
+++ src/concoutput_mpi.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -77,4 +77,7 @@
   real :: sp_fact
   real :: outnum,densityoutrecept(maxreceptor),xl,yl
+! RLT
+  real :: densitydryrecept(maxreceptor)
+  real :: factor_dryrecept(maxreceptor)
 
 !real densityoutgrid(0:numxgrid-1,0:numygrid-1,numzgrid),
@@ -111,4 +114,5 @@
   character(LEN=8),save :: file_stat='REPLACE'
   logical :: ldates_file
+  logical :: lexist
   integer :: ierr
   character(LEN=100) :: dates_char
@@ -212,4 +216,7 @@
         densityoutgrid(ix,jy,kz)=(rho(iix,jjy,kzz,mind)*dz1+ &
              rho(iix,jjy,kzz-1,mind)*dz2)/dz
+! RLT
+        densitydrygrid(ix,jy,kz)=(rho_dry(iix,jjy,kzz,mind)*dz1+ &
+             rho_dry(iix,jjy,kzz-1,mind)*dz2)/dz  
       end do
     end do
@@ -223,6 +230,12 @@
     !densityoutrecept(i)=rho(iix,jjy,1,2)
     densityoutrecept(i)=rho(iix,jjy,1,mind)
+! RLT
+    densitydryrecept(i)=rho_dry(iix,jjy,1,mind)
   end do
 
+! RLT
+! conversion factor for output relative to dry air
+  factor_drygrid=densityoutgrid/densitydrygrid
+  factor_dryrecept=densityoutrecept/densitydryrecept
 
 ! Output is different for forward and backward simulations
@@ -277,9 +290,7 @@
         write(unitoutgrid) itime
       endif
-
       if ((iout.eq.2).or.(iout.eq.3)) then      ! mixing ratio
         open(unitoutgridppt,file=path(2)(1:length(2))//'grid_pptv_'//adate// &
              atime//'_'//anspec,form='unformatted')
-
         write(unitoutgridppt) itime
       endif
@@ -625,4 +636,47 @@
   end do
 
+! RLT Aug 2017
+! Write out conversion factor for dry air
+  inquire(file=path(2)(1:length(2))//'factor_drygrid',exist=lexist)
+  if (lexist) then
+    ! open and append
+    open(unitoutfactor,file=path(2)(1:length(2))//'factor_drygrid',form='unformatted',&
+            status='old',action='write',access='append')
+  else
+    ! create new
+    open(unitoutfactor,file=path(2)(1:length(2))//'factor_drygrid',form='unformatted',&
+            status='new',action='write')
+  endif
+  sp_count_i=0
+  sp_count_r=0
+  sp_fact=-1.
+  sp_zer=.true.
+  do kz=1,numzgrid
+    do jy=0,numygrid-1
+      do ix=0,numxgrid-1
+        if (factor_drygrid(ix,jy,kz).gt.(1.+smallnum).or.factor_drygrid(ix,jy,kz).lt.(1.-smallnum)) then
+          if (sp_zer.eqv..true.) then ! first value not equal to one
+            sp_count_i=sp_count_i+1
+            sparse_dump_i(sp_count_i)= &
+                  ix+jy*numxgrid+kz*numxgrid*numygrid
+            sp_zer=.false.
+            sp_fact=sp_fact*(-1.)
+          endif
+          sp_count_r=sp_count_r+1
+          sparse_dump_r(sp_count_r)= &
+               sp_fact*factor_drygrid(ix,jy,kz)
+        else ! factor is one
+          sp_zer=.true.
+        endif
+      end do
+    end do
+  end do
+  write(unitoutfactor) sp_count_i
+  write(unitoutfactor) (sparse_dump_i(i),i=1,sp_count_i)
+  write(unitoutfactor) sp_count_r
+  write(unitoutfactor) (sparse_dump_r(i),i=1,sp_count_r)
+  close(unitoutfactor)
+
+
   if (gridtotal.gt.0.) gridtotalunc=gridsigmatotal/gridtotal
   if (wetgridtotal.gt.0.) wetgridtotalunc=wetgridsigmatotal/ &
@@ -651,5 +705,21 @@
   endif
 
-
+! RLT Aug 2017
+! Write out conversion factor for dry air
+  if (numreceptor.gt.0) then
+    inquire(file=path(2)(1:length(2))//'factor_dryreceptor',exist=lexist)
+     if (lexist) then
+     ! open and append
+      open(unitoutfactor,file=path(2)(1:length(2))//'factor_dryreceptor',form='unformatted',&
+              status='old',action='write',access='append')
+    else
+      ! create new
+      open(unitoutfactor,file=path(2)(1:length(2))//'factor_dryreceptor',form='unformatted',&
+              status='new',action='write')
+    endif
+    write(unitoutfactor) itime
+    write(unitoutfactor) (factor_dryrecept(i),i=1,numreceptor)
+    close(unitoutfactor)
+  endif
 
 ! Reinitialization of grid
Index: src/concoutput_nest.f90
===================================================================
--- src/concoutput_nest.f90	(revision 2eefa58ac797f119acc28fade41beff352006040)
+++ src/concoutput_nest.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -606,5 +606,4 @@
   close(unitoutfactor)
 
-
   ! Reinitialization of grid
   !*************************
Index: src/concoutput_nest_mpi.f90
===================================================================
--- src/concoutput_nest_mpi.f90	(revision 16b61a5e2d3b1020be1cff080e479ba26f3f7063)
+++ src/concoutput_nest_mpi.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -58,5 +58,4 @@
   !*****************************************************************************
 
-
   use unc_mod
   use point_mod
@@ -74,4 +73,7 @@
   real :: sp_fact
   real :: outnum,densityoutrecept(maxreceptor),xl,yl
+! RLT
+  real :: densitydryrecept(maxreceptor)
+  real :: factor_dryrecept(maxreceptor)
 
   !real densityoutgrid(0:numxgrid-1,0:numygrid-1,numzgrid),
@@ -100,4 +102,5 @@
   character :: adate*8,atime*6
   character(len=3) :: anspec
+  logical :: lexist
   integer :: mind 
 ! mind        eso:added to ensure identical results between 2&3-fields versions
@@ -176,4 +179,7 @@
         densityoutgrid(ix,jy,kz)=(rho(iix,jjy,kzz,mind)*dz1+ &
              rho(iix,jjy,kzz-1,mind)*dz2)/dz
+! RLT
+        densitydrygrid(ix,jy,kz)=(rho_dry(iix,jjy,kzz,mind)*dz1+ &
+             rho_dry(iix,jjy,kzz-1,mind)*dz2)/dz
       end do
     end do
@@ -187,6 +193,12 @@
     !densityoutrecept(i)=rho(iix,jjy,1,2)
     densityoutrecept(i)=rho(iix,jjy,1,mind)
+! RLT
+    densitydryrecept(i)=rho_dry(iix,jjy,1,mind)
   end do
 
+! RLT
+! conversion factor for output relative to dry air
+  factor_drygrid=densityoutgrid/densitydrygrid
+  factor_dryrecept=densityoutrecept/densitydryrecept
 
   ! Output is different for forward and backward simulations
@@ -211,4 +223,14 @@
 
   write(anspec,'(i3.3)') ks
+ 
+  if (DRYBKDEP.or.WETBKDEP) then !scavdep output
+      if (DRYBKDEP) &
+      open(unitoutgrid,file=path(2)(1:length(2))//'grid_drydep_nest_'//adate// &
+           atime//'_'//anspec,form='unformatted')
+      if (WETBKDEP) &
+      open(unitoutgrid,file=path(2)(1:length(2))//'grid_wetdep_nest_'//adate// &
+           atime//'_'//anspec,form='unformatted')
+      write(unitoutgrid) itime
+  else
   if ((iout.eq.1).or.(iout.eq.3).or.(iout.eq.5)) then
     if (ldirect.eq.1) then
@@ -223,4 +245,5 @@
      write(unitoutgrid) itime
    endif
+  endif
 
   if ((iout.eq.2).or.(iout.eq.3)) then      ! mixing ratio
@@ -553,28 +576,70 @@
   end do
 
-
-
-  ! Reinitialization of grid
-  !*************************
-
-  do ks=1,nspec
-    do kp=1,maxpointspec_act
-      do i=1,numreceptor
-        creceptor(i,ks)=0.
-      end do
-      do jy=0,numygridn-1
-        do ix=0,numxgridn-1
-          do l=1,nclassunc
-            do nage=1,nageclass
-              do kz=1,numzgrid
-                griduncn(ix,jy,kz,ks,kp,l,nage)=0.
-              end do
-            end do
-          end do
-        end do
+! RLT Aug 2017
+! Write out conversion factor for dry air
+  inquire(file=path(2)(1:length(2))//'factor_drygrid_nest',exist=lexist)
+  if (lexist) then
+    ! open and append
+    open(unitoutfactor,file=path(2)(1:length(2))//'factor_drygrid_nest',form='unformatted',&
+            status='old',action='write',access='append')
+  else
+    ! create new
+    open(unitoutfactor,file=path(2)(1:length(2))//'factor_drygrid_nest',form='unformatted',&
+            status='new',action='write')
+  endif
+  sp_count_i=0
+  sp_count_r=0
+  sp_fact=-1.
+  sp_zer=.true.
+  do kz=1,numzgrid
+    do jy=0,numygridn-1
+      do ix=0,numxgridn-1
+        if (factor_drygrid(ix,jy,kz).gt.(1.+smallnum).or.factor_drygrid(ix,jy,kz).lt.(1.-smallnum)) then
+          if (sp_zer.eqv..true.) then ! first value not equal to one
+            sp_count_i=sp_count_i+1
+            sparse_dump_i(sp_count_i)= &
+                  ix+jy*numxgridn+kz*numxgridn*numygridn
+            sp_zer=.false.
+            sp_fact=sp_fact*(-1.)
+          endif
+          sp_count_r=sp_count_r+1
+          sparse_dump_r(sp_count_r)= &
+               sp_fact*factor_drygrid(ix,jy,kz)
+        else ! factor is one
+          sp_zer=.true.
+        endif
       end do
     end do
   end do
-
+  write(unitoutfactor) sp_count_i
+  write(unitoutfactor) (sparse_dump_i(i),i=1,sp_count_i)
+  write(unitoutfactor) sp_count_r
+  write(unitoutfactor) (sparse_dump_r(i),i=1,sp_count_r)
+  close(unitoutfactor)
+
+  ! Reinitialization of grid
+  !*************************
+
+  ! do ks=1,nspec
+  !   do kp=1,maxpointspec_act
+  !     do i=1,numreceptor
+  !       creceptor(i,ks)=0.
+  !     end do
+  !     do jy=0,numygridn-1
+  !       do ix=0,numxgridn-1
+  !         do l=1,nclassunc
+  !           do nage=1,nageclass
+  !             do kz=1,numzgrid
+  !               griduncn(ix,jy,kz,ks,kp,l,nage)=0.
+  !             end do
+  !           end do
+  !         end do
+  !       end do
+  !     end do
+  !   end do
+  ! end do
+  creceptor(:,:)=0.
+  griduncn(:,:,:,:,:,:,:)=0.
+  
   if (mp_measure_time) call mpif_mtime('iotime',1)
   ! if (mp_measure_time) then
Index: src/concoutput_surf_nest_mpi.f90
===================================================================
--- src/concoutput_surf_nest_mpi.f90	(revision 38b7917d85662f40709488fecd7eafd06615a08c)
+++ src/concoutput_surf_nest_mpi.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -651,14 +651,15 @@
 
   do ks=1,nspec
-  do kp=1,maxpointspec_act
-    do i=1,numreceptor
-      creceptor(i,ks)=0.
-    end do
-    do jy=0,numygridn-1
-      do ix=0,numxgridn-1
-        do l=1,nclassunc
-          do nage=1,nageclass
-            do kz=1,numzgrid
-              griduncn(ix,jy,kz,ks,kp,l,nage)=0.
+    do kp=1,maxpointspec_act
+      do i=1,numreceptor
+        creceptor(i,ks)=0.
+      end do
+      do jy=0,numygridn-1
+        do ix=0,numxgridn-1
+          do l=1,nclassunc
+            do nage=1,nageclass
+              do kz=1,numzgrid
+                griduncn(ix,jy,kz,ks,kp,l,nage)=0.
+              end do
             end do
           end do
@@ -666,5 +667,4 @@
       end do
     end do
-  end do
   end do
 
Index: src/makefile
===================================================================
--- src/makefile	(revision c56da455adc4af0f5c28c039f48f7b6b73595ced)
+++ src/makefile	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -63,12 +63,14 @@
 else 
 # Compiled libraries under user ~flexpart, gfortran v5.4
-	ROOT_DIR = /homevip/flexpart/
+#	ROOT_DIR = /homevip/flexpart/
 
 	F90	  = /usr/bin/gfortran
 	MPIF90    = /usr/bin/mpifort
 
-	INCPATH1  = ${ROOT_DIR}/gcc-5.4.0/include	
+# INCPATH1  = ${ROOT_DIR}/gcc-5.4.0/include	
+# INCPATH2  = /usr/include
+# LIBPATH1 = ${ROOT_DIR}/gcc-5.4.0/lib
+	INCPATH1  = /usr/include	
 	INCPATH2  = /usr/include
-	LIBPATH1 = ${ROOT_DIR}/gcc-5.4.0/lib
 endif
 
@@ -92,6 +94,5 @@
 
 ## LIBRARIES
-#LIBS = -lgrib_api_f90 -lgrib_api -lm -ljasper -lnetcdff
-LIBS = -lgrib_api_f90 -lgrib_api -lm -ljasper $(NCOPT)
+LIBS = -leccodes -leccodes_f90 -lm  $(NCOPT)
 
 FFLAGS   = -I$(INCPATH1) -I$(INCPATH2) -O$(O_LEV) -g -cpp -m64 -mcmodel=medium -fconvert=little-endian -frecord-marker=4 -fmessage-length=0 -flto=jobserver -O$(O_LEV) $(NCOPT) $(FUSER)  #-Warray-bounds -fcheck=all # -march=native
@@ -128,8 +129,8 @@
 	redist.o		\
 	concoutput_surf.o	concoutput_surf_nest.o	\
-	concoutput_inversion_nest.o 	\
-	concoutput_inversion.o \
 	getfields.o \
-        readwind_ecmwf.o
+        readwind_ecmwf.o \
+	initial_cond_output.o \
+	initial_cond_output_inversion.o
 
 ## For MPI version 
@@ -145,9 +146,12 @@
 	concoutput_surf_mpi.o	concoutput_surf_nest_mpi.o	\
 	getfields_mpi.o \
-        readwind_ecmwf_mpi.o 
+        readwind_ecmwf_mpi.o \
+	initial_cond_output_mpi.o \
+	initial_cond_output_inversion_mpi.o
 
 OBJECTS_NCF = netcdf_output_mod.o
 
 OBJECTS = \
+initial_cond_calc.o \
 advance.o		initialize.o		\
 writeheader.o		writeheader_txt.o  	\
@@ -202,8 +206,10 @@
 drydepokernel_nest.o    zenithangle.o \
 ohreaction.o            getvdep_nests.o \
-initial_cond_calc.o     initial_cond_output.o initial_cond_output_inversion.o \
 dynamic_viscosity.o     get_settling.o	\
 initialize_cbl_vel.o	re_initialize_particle.o \
-cbl.o
+cbl.o \
+concoutput_inversion_nest.o 	\
+concoutput_inversion.o \
+
 
 ifeq ($(ncf), yes)
@@ -325,6 +331,10 @@
 init_domainfill_mpi.o: com_mod.o mpi_mod.o par_mod.o point_mod.o random_mod.o
 initial_cond_calc.o: com_mod.o outg_mod.o par_mod.o unc_mod.o
+initial_cond_calc_mpi.o: com_mod.o outg_mod.o par_mod.o unc_mod.o
 initial_cond_output.o: com_mod.o outg_mod.o par_mod.o point_mod.o unc_mod.o
+initial_cond_output_mpi.o: com_mod.o outg_mod.o par_mod.o point_mod.o unc_mod.o mpi_mod.o
 initial_cond_output_inversion.o: com_mod.o outg_mod.o par_mod.o point_mod.o \
+	unc_mod.o
+initial_cond_output_inversion_mpi.o: com_mod.o outg_mod.o par_mod.o point_mod.o \
 	unc_mod.o
 initialize.o: com_mod.o hanna_mod.o interpol_mod.o par_mod.o random_mod.o
Index: src/mpi_mod.f90
===================================================================
--- src/mpi_mod.f90	(revision 0c8c7f2f1bd07179b6e1be5a302d9e2d52633f9e)
+++ src/mpi_mod.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -2597,4 +2597,56 @@
 601 end subroutine mpif_tm_reduce_grid_nest
 
+
+  subroutine mpif_tm_reduce_initcond
+!***********************************************************************
+! Collect init_cond to PID 0, adding from all processes.
+!
+!
+!***********************************************************************
+    use com_mod
+    use unc_mod
+    use par_mod
+
+    implicit none
+
+    integer :: grid_size
+
+!**********************************************************************
+
+    grid_size=numxgrid*numygrid*numzgrid*maxspec* &
+         & maxpointspec_act
+
+! Time for MPI communications
+    if (mp_measure_time) call mpif_mtime('commtime',0)
+
+
+#ifdef USE_MPIINPLACE
+! Using in-place reduction
+    if (lroot) then
+      call MPI_Reduce(MPI_IN_PLACE, init_cond, grid_size, mp_sp, MPI_SUM, id_root, &
+           & mp_comm_used, mp_ierr)
+      if (mp_ierr /= 0) goto 600
+    else
+      call MPI_Reduce(init_cond, 0, grid_size, mp_sp, MPI_SUM, id_root, &
+           & mp_comm_used, mp_ierr)
+      if (mp_ierr /= 0) goto 600
+    end if
+
+#else
+    call MPI_Reduce(init_cond, init_cond0, grid_size, mp_sp, MPI_SUM, id_root, &
+         & mp_comm_used, mp_ierr)
+    if (mp_ierr /= 0) goto 600
+!    if (lroot) init_cond = init_cond0
+#endif
+
+    if (mp_measure_time) call mpif_mtime('commtime',1)
+
+    goto 601
+
+600 write(*,*) "mpi_mod> mp_ierr \= 0", mp_ierr
+    stop
+
+601 end subroutine mpif_tm_reduce_initcond
+    
 
   subroutine mpif_mtime(ident,imode)
Index: src/outgrid_init.f90
===================================================================
--- src/outgrid_init.f90	(revision 2eefa58ac797f119acc28fade41beff352006040)
+++ src/outgrid_init.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -315,4 +315,12 @@
          maxpointspec_act),stat=stat)
     if (stat.ne.0) write(*,*)'ERROR: could not allocate init_cond'
+    if (mpi_mode.gt.0) then
+      if (lroot) then
+        allocate(init_cond0(0:numxgrid-1,0:numygrid-1,numzgrid,maxspec, &
+             maxpointspec_act),stat=stat)
+      else
+        allocate(init_cond0(1,1,1,1,1))
+      end if
+    end if
   endif
 
Index: src/timemanager.f90
===================================================================
--- src/timemanager.f90	(revision a756649aa5143665ab2654ea5dd5e713950bb1a2)
+++ src/timemanager.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -108,9 +108,10 @@
   implicit none
 
+  integer(selected_int_kind(16)) :: idummy,idummy2
   integer :: metdata_format
   integer :: j,ks,kp,l,n,itime=0,nstop,nstop1
 ! integer :: ksp
   integer :: loutnext,loutstart,loutend
-  integer :: ix,jy,ldeltat,itage,nage,idummy,idummy2
+  integer :: ix,jy,ldeltat,itage,nage
   integer :: i_nan=0,ii_nan,total_nan_intl=0  !added by mc to check instability in CBL scheme 
   real :: outnum,weight,prob_rec(maxspec),prob(maxspec),decfact,wetscav
@@ -397,9 +398,9 @@
               call concoutput(itime,outnum,gridtotalunc,wetgridtotalunc,drygridtotalunc)
             endif
-          else  
+          else ! surf only  
             if (verbosity.eq.1) then
-             print*,'call concoutput_surf '
-             call system_clock(count_clock)
-             write(*,*) 'system clock',count_clock - count_clock0   
+              print*,'call concoutput_surf '
+              call system_clock(count_clock)
+              write(*,*) 'system clock',count_clock - count_clock0   
             endif
             if (lnetcdfout.eq.1) then
@@ -416,5 +417,5 @@
                 endif
               else
-              call concoutput_surf(itime,outnum,gridtotalunc,wetgridtotalunc,drygridtotalunc)
+                call concoutput_surf(itime,outnum,gridtotalunc,wetgridtotalunc,drygridtotalunc)
               endif
               if (verbosity.eq.1) then
@@ -434,6 +435,6 @@
                   call concoutput_inversion_nest(itime,outnum)
                 else 
-                call concoutput_surf_nest(itime,outnum)
-              endif
+                  call concoutput_surf_nest(itime,outnum)
+                endif
               endif
             else
Index: src/timemanager_mpi.f90
===================================================================
--- src/timemanager_mpi.f90	(revision 0c8c7f2f1bd07179b6e1be5a302d9e2d52633f9e)
+++ src/timemanager_mpi.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -109,4 +109,5 @@
   implicit none
 
+  integer(selected_int_kind(16)) :: idummy,idummy2
   integer :: metdata_format
   logical :: reqv_state=.false. ! .true. if waiting for a MPI_Irecv to complete
@@ -115,5 +116,5 @@
   integer :: ip,irec
   integer :: loutnext,loutstart,loutend
-  integer :: ix,jy,ldeltat,itage,nage,idummy
+  integer :: ix,jy,ldeltat,itage,nage
   integer :: i_nan=0,ii_nan,total_nan_intl=0  !added by mc to check instability in CBL scheme 
   integer :: numpart_tot_mpi ! for summing particles on all processes
@@ -177,5 +178,5 @@
 !********************************************************************
 
-    if (mp_dbg_mode) write(*,*) 'myid, itime: ',mp_pid,itime
+!    if (mp_dbg_mode) write(*,*) 'myid, itime: ',mp_pid,itime
     
     if (WETDEP .and. itime .ne. 0 .and. numpart .gt. 0) then
@@ -298,5 +299,5 @@
 
     if (lmpreader.and.lmp_use_reader) then
-      if (itime.lt.ideltas*ldirect) then
+      if (abs(itime).lt.ideltas*ldirect) then
         cycle
       else
@@ -498,5 +499,5 @@
               creceptor(:,:)=0.
             end if
-          else 
+          else ! surf only 
             if (lroot) then
               if (lnetcdfout.eq.1) then
@@ -506,5 +507,9 @@
 #endif
               else
-                call concoutput_surf(itime,outnum,gridtotalunc,wetgridtotalunc,drygridtotalunc)
+                if (linversionout.eq.1) then
+                  call concoutput_inversion(itime,outnum,gridtotalunc,wetgridtotalunc,drygridtotalunc)
+                else
+                  call concoutput_surf(itime,outnum,gridtotalunc,wetgridtotalunc,drygridtotalunc)
+                end if
               end if
             else
@@ -534,5 +539,17 @@
 
               else
-                call concoutput_surf_nest(itime,outnum)
+                if(linversionout.eq.1) then
+                  if (lroot) then
+                    call concoutput_inversion_nest(itime,outnum)
+                  else
+                    griduncn(:,:,:,:,:,:,:)=0.
+                  end if
+                else
+                  if (lroot) then
+                    call concoutput_surf_nest(itime,outnum)
+                  else
+                    griduncn(:,:,:,:,:,:,:)=0.
+                  end if
+                end if
               end if
             else
@@ -742,5 +759,5 @@
        do ks=1,nspec
          if  ((xscav_frac1(j,ks).lt.0)) then
-            call get_wetscav(itime,lsynctime,loutnext,j,ks,grfraction,idummy,idummy,wetscav)
+            call get_wetscav(itime,lsynctime,loutnext,j,ks,grfraction,idummy,idummy2,wetscav)
             if (wetscav.gt.0) then
                 xscav_frac1(j,ks)=wetscav* &
@@ -895,13 +912,11 @@
 !*****************************************************************************
 
-! eso :TODO: this not implemented yet (transfer particles to PID 0 or rewrite)
-! the tools to do this are already in mpi_mod.f90
-  if (lroot) then 
-    do j=1,numpart
-      if (linit_cond.ge.1) call initial_cond_calc(itime,j)
-    end do
-  end if
-
-
+  do j=1,numpart
+    if (linit_cond.ge.1) call initial_cond_calc(itime,j)
+  end do
+
+! Transfer sum of init_cond field to root process, for output
+  call mpif_tm_reduce_initcond
+    
   if (ipout.eq.2) then
 ! MPI process 0 creates the file, the other processes append to it
@@ -915,6 +930,12 @@
   end if
 
-! eso :TODO: MPI
-  if (linit_cond.ge.1.and.lroot) call initial_cond_output(itime)   ! dump initial cond. field
+  
+  if (linit_cond.ge.1.and.lroot) then
+    if(linversionout.eq.1) then
+      call initial_cond_output_inversion(itime)   ! dump initial cond. field
+    else
+      call initial_cond_output(itime)   ! dump initial cond. fielf
+    endif
+  endif
 
 
Index: src/unc_mod.f90
===================================================================
--- src/unc_mod.f90	(revision 0ecc1fed9f7c7c07cef687094373915d51c69489)
+++ src/unc_mod.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -53,4 +53,5 @@
 
   real,allocatable, dimension (:,:,:,:,:) :: init_cond
+  real,allocatable, dimension (:,:,:,:,:) :: init_cond0 ! for MPI
 
 end module unc_mod
Index: src/writeheader.f90
===================================================================
--- src/writeheader.f90	(revision a756649aa5143665ab2654ea5dd5e713950bb1a2)
+++ src/writeheader.f90	(revision f3054ea95b97388f57786fce68d9556e51c62ff2)
@@ -100,6 +100,4 @@
   !*****************************************************************************
 
-  write(*,*) "writeheader/nspec", nspec
-  
   write(unitheader) 3*nspec,maxpointspec_act
   do i=1,nspec
