Index: src/init_domainfill.f90
===================================================================
--- src/init_domainfill.f90	(revision 3481cc180a6b19f71d9d2d04240a91d23f0a2800)
+++ src/init_domainfill.f90	(revision ffbe2240661f55a6c32ae64ca5e3e71776abba73)
@@ -206,5 +206,4 @@
                    ztra1(numpart+jj)=height(nz)-0.5
 
-
 ! Interpolate PV to the particle position
 !****************************************
@@ -213,4 +212,8 @@
               ixp=ixm+1
               jyp=jym+1
+              if (jyp.gt.180) then
+                 write (*,*) 'init_domainfill, over: ',jyp,jym,ytra1(numpart+jj),jy,ran1(idummy),ny
+                 jyp=jym
+              endif
               ddx=xtra1(numpart+jj)-real(ixm)
               ddy=ytra1(numpart+jj)-real(jym)
Index: src/netcdf_output_mod.f90
===================================================================
--- src/netcdf_output_mod.f90	(revision 3481cc180a6b19f71d9d2d04240a91d23f0a2800)
+++ src/netcdf_output_mod.f90	(revision ffbe2240661f55a6c32ae64ca5e3e71776abba73)
@@ -33,8 +33,8 @@
   use outg_mod,  only: outheight,oroout,densityoutgrid,factor3d,volume,&
                        wetgrid,wetgridsigma,drygrid,drygridsigma,grid,gridsigma,&
-                       area,arean,volumen, orooutn
+                       area,arean,volumen, orooutn, areaeast
   use par_mod,   only: dep_prec, sp, dp, maxspec, maxreceptor, nclassunc,&
                        unitoutrecept,unitoutreceptppt, nxmax,unittmp
-  use com_mod,   only: path,length,ldirect,ibdate,ibtime,iedate,ietime, &
+  use com_mod,   only: path,length,ldirect,bdate,ibdate,ibtime,iedate,ietime, &
                        loutstep,loutaver,loutsample,outlon0,outlat0,&
                        numxgrid,numygrid,dxout,dyout,numzgrid, height, &
@@ -63,5 +63,5 @@
 
   public :: writeheader_netcdf,concoutput_surf_nest_netcdf,concoutput_netcdf,&
-       &concoutput_nest_netcdf,concoutput_surf_netcdf
+       &concoutput_nest_netcdf,concoutput_surf_netcdf,fluxoutput_netcdf
 
 !  include 'netcdf.inc'
@@ -1424,4 +1424,157 @@
 end subroutine concoutput_surf_nest_netcdf
 
+subroutine fluxoutput_netcdf(itime)
+     
+  !                            i
+  !*****************************************************************************
+  !                                                                            *
+  !     Output of the gridded fluxes.                                          *
+  !     Eastward, westward, northward, southward, upward and downward gross    *
+  !     fluxes are written to output file in either sparse matrix or grid dump *
+  !     format, whichever is more efficient.                                   *
+  !                                                                            *
+  !     Author: A. Stohl                                                       *
+  !                                                                            *
+  !     04 April 2000                                                          *
+  !     netcdfoutput S. Eckhardt, 2020                                         *
+  !                                                                            *
+  !*****************************************************************************
+
+   use flux_mod
+
+  implicit none
+
+  real(kind=dp) :: jul
+  integer :: itime,ix,jy,kz,ks,nage,jjjjmmdd,ihmmss,kp,i
+  
+  character(len=255) :: ncfname
+  character :: adate*8,atime*6,timeunit*32,anspec*3
+
+  integer :: ncid 
+  integer :: timeDimID, latDimID, lonDimID, levDimID
+  integer :: nspecDimID, npointDimID, nageclassDimID, ncharDimID, pointspecDimID
+  integer :: tID, lonID, latID, levID, lageID, fluxID
+  integer, dimension(6)       :: dIDs
+  integer :: cache_size
+  real, allocatable, dimension(:) :: coord
+
+
+  ! Determine current calendar date, needed for the file name
+  !**********************************************************
+
+  jul=bdate+real(itime,kind=dp)/86400._dp
+  call caldate(jul,jjjjmmdd,ihmmss)
+  write(adate,'(i8.8)') jjjjmmdd
+  write(atime,'(i6.6)') ihmmss
+
+  ncfname=path(2)(1:length(2))//'grid_flux_'//adate// &
+       atime//'.nc'
+
+  ! setting cache size in bytes. It is set to 4 times the largest data block that is written
+  !   size_type x nx x ny x nz
+  ! create file
+
+  cache_size = 16 * numxgrid * numygrid * numzgrid
+  call nf90_err(nf90_create(trim(ncfname), cmode = nf90_hdf5, ncid = ncid, &
+    cache_size = cache_size))  
+
+  ! create dimensions:
+  !*************************
+  ! time
+  call nf90_err(nf90_def_dim(ncid, 'time', nf90_unlimited, timeDimID))
+  timeunit = 'seconds since '//adate(1:4)//'-'//adate(5:6)// &
+     '-'//adate(7:8)//' '//atime(1:2)//':'//atime(3:4)
+
+  call nf90_err(nf90_def_dim(ncid, 'longitude', numxgrid, lonDimID))
+  call nf90_err(nf90_def_dim(ncid, 'latitude', numygrid, latDimID))
+  call nf90_err(nf90_def_dim(ncid, 'height', numzgrid, levDimID))
+  call nf90_err(nf90_def_dim(ncid, 'numspec', nspec, nspecDimID))
+  call nf90_err(nf90_def_dim(ncid, 'pointspec', maxpointspec_act, pointspecDimID))
+  call nf90_err(nf90_def_dim(ncid, 'nageclass', nageclass, nageclassDimID))
+  call nf90_err(nf90_def_dim(ncid, 'nchar', 45, ncharDimID))
+  call nf90_err(nf90_def_dim(ncid, 'numpoint', numpoint, npointDimID))
+
+
+  ! create variables
+  !*************************
+
+  ! time
+  call nf90_err(nf90_def_var(ncid, 'time', nf90_int, (/ timeDimID /), tID))
+  call nf90_err(nf90_put_att(ncid, tID, 'units', timeunit))
+  call nf90_err(nf90_put_att(ncid, tID, 'calendar', 'proleptic_gregorian'))
+  timeID = tID
+
+  ! lon
+  call nf90_err(nf90_def_var(ncid, 'longitude', nf90_float, (/ lonDimID /), lonID))
+  call nf90_err(nf90_put_att(ncid, lonID, 'long_name', 'longitude in degree east'))
+  call nf90_err(nf90_put_att(ncid, lonID, 'axis', 'Lon'))
+  call nf90_err(nf90_put_att(ncid, lonID, 'units', 'degrees_east'))
+  call nf90_err(nf90_put_att(ncid, lonID, 'standard_name', 'grid_longitude'))
+  call nf90_err(nf90_put_att(ncid, lonID, 'description', 'grid cell centers'))
+
+  ! lat
+  call nf90_err(nf90_def_var(ncid, 'latitude', nf90_float, (/ latDimID /), latID))
+  call nf90_err(nf90_put_att(ncid, latID, 'long_name', 'latitude in degree north'))
+  call nf90_err(nf90_put_att(ncid, latID, 'axis', 'Lat'))
+  call nf90_err(nf90_put_att(ncid, latID, 'units', 'degrees_north'))
+  call nf90_err(nf90_put_att(ncid, latID, 'standard_name', 'grid_latitude'))
+  call nf90_err(nf90_put_att(ncid, latID, 'description', 'grid cell centers'))
+
+  ! height
+  call nf90_err(nf90_def_var(ncid, 'height', nf90_float, (/ levDimID /), levID))
+  call nf90_err(nf90_put_att(ncid, levID, 'units', 'meters'))
+  call nf90_err(nf90_put_att(ncid, levID, 'positive', 'up'))
+  call nf90_err(nf90_put_att(ncid, levID, 'standard_name', 'height'))
+
+  if (.not.allocated(coord)) allocate(coord(numxgrid)) 
+  do i = 1,numxgrid
+     coord(i) = outlon0 + (i-0.5)*dxout
+  enddo
+  call nf90_err(nf90_put_var(ncid, lonID, coord(1:numxgrid)))
+  deallocate(coord)
+  if (.not.allocated(coord)) allocate(coord(numygrid))
+  do i = 1,numygrid
+     coord(i) = outlat0 + (i-0.5)*dyout
+  enddo
+  call nf90_err(nf90_put_var(ncid, latID, coord(1:numygrid)))
+  deallocate(coord)
+  call nf90_err(nf90_put_var(ncid, levID, outheight(1:numzgrid)))
+
+  ! write time, one field per time - different to the others!
+  call nf90_err(nf90_put_var( ncid, timeID, itime, (/ 1 /)))
+  
+  dIDs = (/ londimid, latdimid, levdimid, timedimid, pointspecdimid, nageclassdimid /)
+
+  do ks=1,nspec
+    do kp=1,maxpointspec_act
+      do nage=1,nageclass
+ 
+         write(anspec,'(i3.3)') ks
+
+ ! East Flux
+        call nf90_err(nf90_def_var(ncid,'flux_east_'//anspec, nf90_float, dIDs, &
+             fluxID))
+
+        do jy=0,numygrid-1
+          do ix=0,numxgrid-1
+            do kz=1, numzgrid
+               grid(ix,jy,kz)=flux(1,ix,jy,kz,ks,kp,nage) 
+            end do
+          end do
+        end do
+
+        call nf90_err(nf90_put_var(ncid,fluxid,1.e12*grid(0:numxgrid-1,0:numygrid-1,1:numzgrid)&
+            /areaeast(0:numxgrid-1,0:numygrid-1,1:numzgrid)/loutstep,&
+           (/ 1,1,1,tpointer,kp,nage /), (/ numxgrid,numygrid,numzgrid,1,1,1 /) ))
+
+      end do
+    end do
+  end do
+
+  ! Close netCDF file
+  call nf90_err(nf90_close(ncid))
+
+end subroutine fluxoutput_netcdf
+
 end module netcdf_output_mod
 
Index: src/timemanager.f90
===================================================================
--- src/timemanager.f90	(revision 3481cc180a6b19f71d9d2d04240a91d23f0a2800)
+++ src/timemanager.f90	(revision ffbe2240661f55a6c32ae64ca5e3e71776abba73)
@@ -82,5 +82,5 @@
 #ifdef USE_NCF
   use netcdf_output_mod, only: concoutput_netcdf,concoutput_nest_netcdf,&
-       &concoutput_surf_netcdf,concoutput_surf_nest_netcdf
+       &concoutput_surf_netcdf,concoutput_surf_nest_netcdf,fluxoutput_netcdf
 #endif
 
@@ -429,5 +429,6 @@
         endif
         if ((iout.eq.4).or.(iout.eq.5)) call plumetraj(itime)
-        if (iflux.eq.1) call fluxoutput(itime)
+        if ((iflux.eq.1).and.(lnetcdfout.eq.0)) call fluxoutput(itime)
+        if ((iflux.eq.1).and.(lnetcdfout.eq.1)) call fluxoutput_netcdf(itime)
         write(*,45) itime,numpart,gridtotalunc,wetgridtotalunc,drygridtotalunc
  
Index: src/timemanager_mpi.f90
===================================================================
--- src/timemanager_mpi.f90	(revision 3481cc180a6b19f71d9d2d04240a91d23f0a2800)
+++ src/timemanager_mpi.f90	(revision ffbe2240661f55a6c32ae64ca5e3e71776abba73)
@@ -536,5 +536,6 @@
         endif
         if ((iout.eq.4).or.(iout.eq.5)) call plumetraj(itime)
-        if (iflux.eq.1) call fluxoutput(itime)
+        if ((iflux.eq.1).and.(lnetcdfout.eq.0)) call fluxoutput(itime)
+        if ((iflux.eq.1).and.(lnetcdfout.eq.1)) call fluxoutput_netcdf(itime)
         if (mp_measure_time) call mpif_mtime('iotime',1)
 
