Index: trunk/src/readcommand.f90
===================================================================
--- trunk/src/readcommand.f90	(revision 30)
+++ trunk/src/readcommand.f90	(revision 20)
@@ -29,6 +29,4 @@
   !                                                                            *
   !     18 May 1996                                                            *
-  !     HSO, 1 July 2014                                                       *
-  !     Added optional namelist input                                          *
   !                                                                            *
   !*****************************************************************************
@@ -82,36 +80,36 @@
   character(len=50) :: line
   logical :: old
+  logical :: nmlout=.true. !.false.
   integer :: readerror
 
   namelist /command/ &
-  ldirect, &
-  ibdate,ibtime, &
-  iedate,ietime, &
-  loutstep, &
-  loutaver, &
-  loutsample, &
-  itsplit, &
-  lsynctime, &
-  ctl, &
-  ifine, &
-  iout, &
-  ipout, &
-  lsubgrid, &
-  lconvection, &
-  lagespectra, &
-  ipin, &
-  ioutputforeachrelease, &
-  iflux, &
-  mdomainfill, &
-  ind_source, &
-  ind_receptor, &
-  mquasilag, &
-  nested_output, &
-  linit_cond, &
-  lnetcdfout, &
-  surf_only    
+    ldirect, &
+    ibdate,ibtime, &
+    iedate,ietime, &
+    loutstep, &
+    loutaver, &
+    loutsample, &
+    itsplit, &
+    lsynctime, &
+    ctl, &
+    ifine, &
+    iout, &
+    ipout, &
+    lsubgrid, &
+    lconvection, &
+    lagespectra, &
+    ipin, &
+    ioutputforeachrelease, &
+    iflux, &
+    mdomainfill, &
+    ind_source, &
+    ind_receptor, &
+    mquasilag, &
+    nested_output, &
+    linit_cond, &
+    surf_only    
 
   ! Presetting namelist command
-  ldirect=0
+  ldirect=1
   ibdate=20000101
   ibtime=0
@@ -139,5 +137,4 @@
   nested_output=0
   linit_cond=0
-  lnetcdfout=0
   surf_only=0 
 
@@ -145,14 +142,24 @@
   ! Namelist input first: try to read as namelist file
   !**************************************************************************
-  open(unitcommand,file=path(1)(1:length(1))//'COMMAND',status='old',form='formatted',err=999)
-
-  ! try namelist input (default)
+  open(unitcommand,file=path(1)(1:length(1))//'COMMAND',status='old', &
+         form='formatted',iostat=readerror)
+  ! If fail, check if file does not exist
+  if (readerror.ne.0) then
+    
+    print*,'***ERROR: file COMMAND not found in ' 
+    print*, path(1)(1:length(1))//'COMMAND'
+    print*, 'Check your pathnames file.'
+    stop
+
+  endif
+
   read(unitcommand,command,iostat=readerror)
   close(unitcommand)
 
-  ! distinguish namelist from fixed text input
-  if ((readerror.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)
+  ! If error in namelist format, try to open with old input code
+  if (readerror.ne.0) then
+
+    open(unitcommand,file=path(1)(1:length(1))//'COMMAND',status='old', &
+         err=999)
 
     ! Check the format of the COMMAND file (either in free format,
@@ -166,12 +173,9 @@
     if (index(line,'LDIRECT') .eq. 0) then
       old = .false.
-      write(*,*) 'COMMAND in old short format, please update to namelist format'
     else
       old = .true.
-      write(*,*) 'COMMAND in old long format, please update to namelist format'
     endif
     rewind(unitcommand)
 
-
     ! Read parameters
     !****************
@@ -179,4 +183,5 @@
     call skplin(7,unitcommand)
     if (old) call skplin(1,unitcommand)
+
     read(unitcommand,*) ldirect
     if (old) call skplin(3,unitcommand)
@@ -226,6 +231,4 @@
     if (old) call skplin(3,unitcommand)
     read(unitcommand,*) linit_cond
-    if (old) call skplin(3,unitcommand)
-    read(unitcommand,*) surf_only
     close(unitcommand)
 
@@ -234,7 +237,11 @@
   ! write command file in namelist format to output directory if requested
   if (nmlout.eqv..true.) then
+    !open(unitcommand,file=path(2)(1:length(2))//'COMMAND.namelist.out',status='new',err=1000)
     open(unitcommand,file=path(2)(1:length(2))//'COMMAND.namelist',err=1000)
     write(unitcommand,nml=command)
     close(unitcommand)
+     ! open(unitheader,file=path(2)(1:length(2))//'header_nml',status='new',err=999)
+     ! write(unitheader,NML=COMMAND)
+     !close(unitheader) 
   endif
 
@@ -346,15 +353,4 @@
   endif
 
-!  check for netcdf output switch (use for non-namelist input only!)
-  if (iout.ge.8) then
-     lnetcdfout = 1
-     iout = iout - 8
-#ifndef NETCDF_OUTPUT
-     print*,'ERROR: netcdf output not activated during compile time but used in COMMAND file!'
-     print*,'Please recompile with netcdf library or use standard output format.'
-     stop
-#endif
-  endif
-
   ! Check whether a valid option for gridded model output has been chosen
   !**********************************************************************
@@ -362,7 +358,5 @@
   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       #### '
-    write(*,*) ' #### STANDARD FLEXPART OUTPUT OR  9 - 13     #### '
-    write(*,*) ' #### FOR NETCDF OUTPUT                       #### '
+    write(*,*) ' #### IOUT MUST BE 1, 2, 3, 4, OR 5!          #### '
     stop
   endif
@@ -376,4 +370,5 @@
     stop
   endif
+
 
 
@@ -597,6 +592,6 @@
 
 1000   write(*,*) ' #### FLEXPART MODEL ERROR! FILE "COMMAND"    #### '
-  write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
-  write(*,'(a)') path(2)(1:length(1))
-  stop
+       write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
+        write(*,'(a)') path(2)(1:length(1))
+        stop
 end subroutine readcommand
