Index: branches/petra/src/readcommand.f90
===================================================================
--- branches/petra/src/readcommand.f90	(revision 33)
+++ branches/petra/src/readcommand.f90	(revision 36)
@@ -1,4 +1,4 @@
 !**********************************************************************
-! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010         *
+! Copyright 1998-2015                                                 *
 ! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa,             *
 ! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann   *
@@ -29,6 +29,8 @@
   !                                                                            *
   !     18 May 1996                                                            *
-  !     HSO, 1 July 2014                                                       *
-  !     Added optional namelist input                                          *
+  !
+  !     HSO, 1 July 2014: Added optional namelist input
+  !     PS 2/2015: add ldep_incr as optional command input
+  !                make new parameters (last 3) optional for bwd compatibility
   !                                                                            *
   !*****************************************************************************
@@ -69,4 +71,6 @@
   ! mdomainfill          1 use domain-filling option, 0 not, 2 use strat. O3   *
   !                                                                            *
+  ! ldep_incr            .true.  for incremental, 
+  !                      .false. for accumulated deposition output (DEFAULT)
   ! Constants:                                                                 *
   ! unitcommand          unit connected to file COMMAND                        *
@@ -79,8 +83,8 @@
   implicit none
 
-  real(kind=dp) :: juldate
-  character(len=50) :: line
+  real (kind=dp) :: juldate
+  character (len=50) :: line
   logical :: old
-  integer :: readerror
+  integer :: ireaderror, icmdstat
 
   namelist /command/ &
@@ -110,35 +114,37 @@
   linit_cond, &
   lnetcdfout, &
-  surf_only    
-
-  ! Presetting namelist command
-  ldirect=0
-  ibdate=20000101
-  ibtime=0
-  iedate=20000102
-  ietime=0
-  loutstep=10800
-  loutaver=10800
-  loutsample=900
-  itsplit=999999999
-  lsynctime=900
-  ctl=-5.0
-  ifine=4
-  iout=3
-  ipout=0
-  lsubgrid=1
-  lconvection=1
-  lagespectra=0
-  ipin=1
-  ioutputforeachrelease=1
-  iflux=1
-  mdomainfill=0
-  ind_source=1
-  ind_receptor=1
-  mquasilag=0
-  nested_output=0
-  linit_cond=0
-  lnetcdfout=0
-  surf_only=0 
+  surf_only, &
+  ldep_incr
+
+  ! Set default values for namelist command
+  ldirect = 0
+  ibdate = 20000101
+  ibtime = 0
+  iedate = 20000102
+  ietime = 0
+  loutstep = 10800
+  loutaver = 10800
+  loutsample = 900
+  itsplit = 999999999
+  lsynctime = 900
+  ctl = -5.0
+  ifine = 4
+  iout = 3
+  ipout = 0
+  lsubgrid = 1
+  lconvection = 1
+  lagespectra = 0
+  ipin = 1
+  ioutputforeachrelease = 1
+  iflux = 1
+  mdomainfill = 0
+  ind_source = 1
+  ind_receptor = 1
+  mquasilag = 0
+  nested_output = 0
+  linit_cond = 0
+  lnetcdfout = 0
+  surf_only = 0 
+  ldep_incr = .false.
 
   ! Open the command file and read user options
@@ -148,9 +154,11 @@
 
   ! try namelist input (default)
-  read(unitcommand,command,iostat=readerror)
+  read(unitcommand,command,iostat=ireaderror)
   close(unitcommand)
 
   ! distinguish namelist from fixed text input
-  if ((readerror.ne.0).or.(ldirect.eq.0)) then ! parse as text file format
+  if ((ireaderror .ne. 0) .or. (ldirect .eq. 0)) then 
+    
+    ! parse as text file format
  
     open(unitcommand,file=path(1)(1:length(1))//'COMMAND',status='old', err=999)
@@ -225,7 +233,15 @@
     read(unitcommand,*) nested_output
     if (old) call skplin(3,unitcommand)
-    read(unitcommand,*) linit_cond
-    if (old) call skplin(3,unitcommand)
-    read(unitcommand,*) surf_only
+    read(unitcommand,*,iostat=icmdstat) linit_cond
+    if (icmdstat .gt. 0) &
+      print*, 'readcommand: linit_cond not read properly',icmdstat,linit_cond
+    if (old) call skplin(3,unitcommand)
+    read(unitcommand,*,iostat=icmdstat) surf_only
+    if (icmdstat .gt. 0) &
+      print*, 'readcommand: linit_cond not read properly',icmdstat,surf_only
+    if (old) call skplin(3,unitcommand)
+    read(unitcommand,*,iostat=icmdstat) ldep_incr
+    if (icmdstat .gt. 0) &
+      print*, 'readcommand: linit_cond not read properly',icmdstat, ldep_incr
     close(unitcommand)
 
@@ -233,5 +249,5 @@
 
   ! write command file in namelist format to output directory if requested
-  if (nmlout.eqv..true.) then
+  if (nmlout .eqv. .true.) then
     open(unitcommand,file=path(2)(1:length(2))//'COMMAND.namelist',err=1000)
     write(unitcommand,nml=command)
@@ -244,5 +260,5 @@
   !***************************************************************
 
-  if (ctl.ge.0.1) then
+  if (ctl .ge. 0.1) then
     turbswitch=.true.
   else
@@ -308,6 +324,6 @@
   !************************************************************************
 
-  if (ldirect.eq.1) linit_cond=0
-  if ((linit_cond.lt.0).or.(linit_cond.gt.2)) then
+  if (ldirect .eq. 1) linit_cond=0
+  if ((linit_cond .lt. 0) .or. (linit_cond .gt. 2)) then
     write(*,*) ' #### FLEXPART MODEL ERROR! INVALID OPTION    #### '
     write(*,*) ' #### FOR LINIT_COND IN FILE "COMMAND".       #### '
@@ -318,5 +334,5 @@
   !******************
 
-  if (iedate.lt.ibdate) then
+  if (iedate .lt. ibdate) then
     write(*,*) ' #### FLEXPART MODEL ERROR! BEGINNING DATE    #### '
     write(*,*) ' #### IS LARGER THAN ENDING DATE. CHANGE      #### '
@@ -324,6 +340,6 @@
     write(*,*) ' #### "COMMAND".                              #### '
     stop
-  else if (iedate.eq.ibdate) then
-    if (ietime.lt.ibtime) then
+  else if (iedate .eq. ibdate) then
+    if (ietime .lt. ibtime) then
     write(*,*) ' #### FLEXPART MODEL ERROR! BEGINNING TIME    #### '
     write(*,*) ' #### IS LARGER THAN ENDING TIME. CHANGE      #### '
@@ -338,5 +354,5 @@
   !************************************
 
-  if (ctl.gt.0.) then
+  if (ctl .gt. 0.) then
     method=1
     mintime=minstep
@@ -347,5 +363,5 @@
 
 !  check for netcdf output switch (use for non-namelist input only!)
-  if (iout.ge.8) then
+  if (iout .ge. 8) then
      lnetcdfout = 1
      iout = iout - 8
@@ -360,5 +376,5 @@
   !**********************************************************************
 
-  if ((iout.lt.1).or.(iout.gt.5)) then
+  if ((iout .lt. 1) .or.  (iout .gt. 5)) then
     write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND:     #### '
     write(*,*) ' #### IOUT MUST BE 1, 2, 3, 4, OR 5 FOR       #### '
@@ -369,6 +385,6 @@
 
   !AF check consistency between units and volume mixing ratio
-  if ( ((iout.eq.2).or.(iout.eq.3)).and. &
-       (ind_source.gt.1 .or.ind_receptor.gt.1) ) then
+  if ( ((iout .eq. 2) .or.  (iout .eq. 3)) .and.  &
+       (ind_source .gt. 1 .or. ind_receptor .gt. 1) ) then
     write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND:     #### '
     write(*,*) ' #### VOLUME MIXING RATIO ONLY SUPPORTED      #### '
@@ -381,5 +397,5 @@
   !*****************************************************************************
 
-  if ((ioutputforeachrelease.eq.1).and.(mquasilag.eq.1)) then
+  if ((ioutputforeachrelease .eq. 1) .and. (mquasilag .eq. 1)) then
       write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
       write(*,*) '#### OUTPUTFOREACHRELEASE AND QUASILAGRANGIAN####'
@@ -392,5 +408,5 @@
   !*****************************************************************************
 
-  if ((ldirect.lt.0).and.(mquasilag.eq.1)) then
+  if ((ldirect .lt. 0) .and. (mquasilag .eq. 1)) then
       write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
       write(*,*) '#### FOR BACKWARD RUNS, QUASILAGRANGIAN MODE ####'
@@ -404,5 +420,5 @@
   !*****************************************************************************
 
-  if ((ldirect.lt.0).and.(ioutputforeachrelease.eq.0)) then
+  if ((ldirect .lt. 0) .and. (ioutputforeachrelease .eq. 0)) then
       write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
       write(*,*) '#### FOR BACKWARD RUNS, IOUTPUTFOREACHRLEASE ####'
@@ -416,5 +432,5 @@
   !*****************************************************************************
 
-  if ((mdomainfill.eq.1).and.(ioutputforeachrelease.eq.1)) then
+  if ((mdomainfill .eq. 1) .and. (ioutputforeachrelease .eq. 1)) then
       write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
       write(*,*) '#### FOR DOMAIN FILLING RUNS OUTPUT FOR      ####'
@@ -429,6 +445,6 @@
   !*****************************************************************************
 
-  if (ldirect.lt.0) then
-    if ((iout.eq.2).or.(iout.eq.3)) then
+  if (ldirect .lt. 0) then
+    if ((iout .eq. 2) .or. (iout .eq. 3)) then
       write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
       write(*,*) '#### FOR BACKWARD RUNS, IOUT MUST BE 1,4,OR 5####'
@@ -442,6 +458,6 @@
   !*****************************************************************************
 
-  if (mdomainfill.ge.1) then
-    if ((iout.eq.4).or.(iout.eq.5)) then
+  if (mdomainfill .ge. 1) then
+    if ((iout .eq. 4) .or. (iout .eq. 5)) then
       write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
       write(*,*) '#### FOR DOMAIN-FILLING TRAJECTORY OPTION,   ####'
@@ -456,5 +472,5 @@
   !****************************************************************
 
-  if ((ipout.ne.0).and.(ipout.ne.1).and.(ipout.ne.2)) then
+  if ((ipout .ne. 0) .and. (ipout .ne. 1) .and. (ipout .ne. 2)) then
     write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND:     #### '
     write(*,*) ' #### IPOUT MUST BE 1, 2 OR 3!                #### '
@@ -462,5 +478,5 @@
   endif
 
-  if(lsubgrid.ne.1.and.verbosity.eq.0) then
+  if(lsubgrid .ne. 1 .and. verbosity .eq. 0) then
     write(*,*) '             ----------------               '
     write(*,*) ' INFORMATION: SUBGRIDSCALE TERRAIN EFFECT IS'
@@ -473,5 +489,5 @@
   !***********************************************************
 
-  if ((lconvection.ne.0).and.(lconvection.ne.1)) then
+  if ((lconvection .ne. 0) .and. (lconvection .ne. 1)) then
     write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND:     #### '
     write(*,*) ' #### LCONVECTION MUST BE SET TO EITHER 1 OR 0#### '
@@ -483,5 +499,5 @@
   !*************************************************************
 
-  if (lsynctime.gt.(idiffnorm/2)) then
+  if (lsynctime .gt. (idiffnorm/2)) then
     write(*,*) ' #### FLEXPART MODEL ERROR! SYNCHRONISATION   #### '
     write(*,*) ' #### TIME IS TOO LONG. MAKE IT SHORTER.      #### '
@@ -494,5 +510,5 @@
   !*****************************************************************************
 
-  if (loutaver.eq.0) then
+  if (loutaver .eq. 0) then
     write(*,*) ' #### FLEXPART MODEL ERROR! TIME AVERAGE OF   #### '
     write(*,*) ' #### CONCENTRATION FIELD OUTPUT MUST NOT BE  #### '
@@ -502,5 +518,5 @@
   endif
 
-  if (loutaver.gt.loutstep) then
+  if (loutaver .gt. loutstep) then
     write(*,*) ' #### FLEXPART MODEL ERROR! TIME AVERAGE OF   #### '
     write(*,*) ' #### CONCENTRATION FIELD OUTPUT MUST NOT BE  #### '
@@ -510,5 +526,5 @@
   endif
 
-  if (loutsample.gt.loutaver) then
+  if (loutsample .gt. loutaver) then
     write(*,*) ' #### FLEXPART MODEL ERROR! SAMPLING TIME OF  #### '
     write(*,*) ' #### CONCENTRATION FIELD OUTPUT MUST NOT BE  #### '
@@ -518,5 +534,5 @@
   endif
 
-  if (mod(loutaver,lsynctime).ne.0) then
+  if (mod(loutaver,lsynctime) .ne. 0) then
     write(*,*) ' #### FLEXPART MODEL ERROR! AVERAGING TIME OF #### '
     write(*,*) ' #### CONCENTRATION FIELD MUST BE A MULTIPLE  #### '
@@ -525,5 +541,5 @@
   endif
 
-  if ((loutaver/lsynctime).lt.2) then
+  if ((loutaver/lsynctime) .lt. 2) then
     write(*,*) ' #### FLEXPART MODEL ERROR! AVERAGING TIME OF #### '
     write(*,*) ' #### CONCENTRATION FIELD MUST BE AT LEAST    #### '
@@ -532,5 +548,5 @@
   endif
 
-  if (mod(loutstep,lsynctime).ne.0) then
+  if (mod(loutstep,lsynctime) .ne. 0) then
     write(*,*) ' #### FLEXPART MODEL ERROR! INTERVAL BETWEEN  #### '
     write(*,*) ' #### CONCENTRATION FIELDS MUST BE A MULTIPLE #### '
@@ -539,5 +555,5 @@
   endif
 
-  if ((loutstep/lsynctime).lt.2) then
+  if ((loutstep/lsynctime) .lt. 2) then
     write(*,*) ' #### FLEXPART MODEL ERROR! INTERVAL BETWEEN  #### '
     write(*,*) ' #### CONCENTRATION FIELDS MUST BE AT LEAST   #### '
@@ -546,5 +562,5 @@
   endif
 
-  if (mod(loutsample,lsynctime).ne.0) then
+  if (mod(loutsample,lsynctime) .ne. 0) then
     write(*,*) ' #### FLEXPART MODEL ERROR! SAMPLING TIME OF  #### '
     write(*,*) ' #### CONCENTRATION FIELD MUST BE A MULTIPLE  #### '
@@ -553,5 +569,5 @@
   endif
 
-  if (itsplit.lt.loutaver) then
+  if (itsplit .lt. loutaver) then
     write(*,*) ' #### FLEXPART MODEL ERROR! SPLITTING TIME FOR#### '
     write(*,*) ' #### PARTICLES IS TOO SHORT. PLEASE INCREASE #### '
@@ -560,5 +576,5 @@
   endif
 
-  if ((mquasilag.eq.1).and.(iout.ge.4)) then
+  if ((mquasilag .eq. 1) .and. (iout .ge. 4)) then
     write(*,*) ' #### FLEXPART MODEL ERROR! CONFLICTING       #### '
     write(*,*) ' #### OPTIONS: IF MQUASILAG=1, PLUME          #### '
@@ -571,9 +587,9 @@
 
   outstep=real(abs(loutstep))
-  if (ldirect.eq.1) then
+  if (ldirect .eq. 1) then
     bdate=juldate(ibdate,ibtime)
     edate=juldate(iedate,ietime)
     ideltas=nint((edate-bdate)*86400.)
-  else if (ldirect.eq.-1) then
+  else if (ldirect .eq. -1) then
     loutaver=-1*loutaver
     loutstep=-1*loutstep
