Index: src/FLEXPART_MPI.f90
===================================================================
--- src/FLEXPART_MPI.f90	(revision 92fab6545ef2a8e57cadc977df94b6b510318a1d)
+++ src/FLEXPART_MPI.f90	(revision dba422187e10650e160348f0a0271adfac6b8b88)
@@ -44,5 +44,5 @@
   implicit none
 
-  integer :: i,j,ix,jy,inest
+  integer :: i, j, ix, jy, inest, iopt
   integer :: idummy = -320
   character(len=256) :: inline_options  !pathfile, flexversion, arg2
@@ -71,7 +71,8 @@
   call gasdev1(idummy,rannumb(maxrand),rannumb(maxrand-1))
 
+
   ! FLEXPART version string
   flexversion_major = '10' ! Major version number, also used for species file names
-  flexversion='Ver. '//trim(flexversion_major)//'.2beta MPI (2017-08-01)'
+  flexversion='Version '//trim(flexversion_major)//'.4.1 MPI (2022-11-09)'
   verbosity=0
 
@@ -80,12 +81,12 @@
 
   inline_options='none'
-  select case (iargc())
+  select case (command_argument_count())  ! Portable standard Fortran intrinsic procedure
   case (2)
-    call getarg(1,arg1)
+    call get_command_argument(1,arg1)     ! Portable standard Fortran intrinsic procedure
     pathfile=arg1
-    call getarg(2,arg2)
+    call get_command_argument(2,arg2)     ! Portable standard Fortran intrinsic procedure
     inline_options=arg2
   case (1)
-    call getarg(1,arg1)
+    call get_command_argument(1,arg1)     ! Portable standard Fortran intrinsic procedure
     pathfile=arg1
     if (arg1(1:1).eq.'-') then
@@ -97,19 +98,30 @@
   end select
   
-  if (lroot) then
   ! Print the GPL License statement
   !*******************************************************
+  if (lroot) then
     print*,'Welcome to FLEXPART ', trim(flexversion)
     print*,'FLEXPART is free software released under the GNU General Public License.'
   endif
-  
+
+
+  ! Ingest inline options
+  !*******************************************************
   if (inline_options(1:1).eq.'-') then
-    if (trim(inline_options).eq.'-v'.or.trim(inline_options).eq.'-v1') then
-      print*, 'Verbose mode 1: display detailed information during run'
+    print*,'inline_options:',inline_options
+    !verbose mode
+    iopt=index(inline_options,'v') 
+    if (iopt.gt.0) then
       verbosity=1
-    endif
-    if (trim(inline_options).eq.'-v2') then
-      print*, 'Verbose mode 2: display more detailed information during run'
-      verbosity=2
+      !print*, iopt, inline_options(iopt+1:iopt+1)
+      if  (trim(inline_options(iopt+1:iopt+1)).eq.'2') then
+        print*, 'Verbose mode 2: display more detailed information during run'
+        verbosity=2
+      endif
+    endif
+    !debug mode 
+    iopt=index(inline_options,'d')
+    if (iopt.gt.0) then
+      debug_mode=.true.
     endif
     if (trim(inline_options).eq.'-i') then
@@ -125,4 +137,11 @@
   endif
            
+  if (verbosity.gt.0) then
+    print*, 'nxmax=',nxmax
+    print*, 'nymax=',nymax
+    print*, 'nzmax=',nzmax
+    print*,'nxshift=',nxshift 
+  endif
+  
   if (verbosity.gt.0) then
     write(*,*) 'call readpaths'
@@ -133,5 +152,5 @@
      !print*,'length(4)',length(4)
      !count=0,count_rate=1000
-    call system_clock(count_clock0, count_rate, count_max)
+     call system_clock(count_clock0, count_rate, count_max)
      !WRITE(*,*) 'SYSTEM_CLOCK',count, count_rate, count_max
      !WRITE(*,*) 'SYSTEM_CLOCK, count_clock0', count_clock0
@@ -157,12 +176,11 @@
   endif
 
-  ! Initialize arrays in com_mod 
+  ! Initialize arrays in com_mod
   !*****************************
-
   if(.not.(lmpreader.and.lmp_use_reader)) call com_mod_allocate_part(maxpart_mpi)
 
 
-! Read the age classes to be used
-!********************************
+  ! Read the age classes to be used
+  !********************************
   if (verbosity.gt.0 .and. lroot) then
     write(*,*) 'call readageclasses'
@@ -185,4 +203,7 @@
   ! Detect metdata format
   !**********************
+  if (verbosity.gt.0 .and. lroot) then
+    write(*,*) 'call detectformat'
+  endif
 
   metdata_format = detectformat()
@@ -207,7 +228,7 @@
   call com_mod_allocate_nests
 
-! Read the model grid specifications,
-! both for the mother domain and eventual nests
-!**********************************************
+  ! Read the model grid specifications,
+  ! both for the mother domain and eventual nests
+  !**********************************************
 
   if (verbosity.gt.0 .and. lroot) then
@@ -221,5 +242,4 @@
   end if
 
-
   if (verbosity.gt.1 .and. lroot) then   
     call system_clock(count_clock, count_rate, count_max)
@@ -227,5 +247,4 @@
   endif      
 
-
   if (verbosity.gt.0 .and. lroot) then
     write(*,*) 'call gridcheck_nests'
@@ -233,10 +252,9 @@
   call gridcheck_nests
 
-
-! Read the output grid specifications
-!************************************
-
-  if (verbosity.gt.0 .and. lroot) then
-    WRITE(*,*) 'call readoutgrid'
+  ! Read the output grid specifications
+  !************************************
+
+  if (verbosity.gt.0 .and. lroot) then
+    write(*,*) 'call readoutgrid'
   endif
 
@@ -246,5 +264,5 @@
     call readoutgrid_nest
     if (verbosity.gt.0.and.lroot) then
-      WRITE(*,*) '# readoutgrid_nest'
+      write(*,*) '# readoutgrid_nest'
     endif
   endif
@@ -263,5 +281,4 @@
   !call readspecies
 
-
   ! Read the landuse inventory
   !***************************
@@ -272,7 +289,6 @@
   call readlanduse
 
-
-! Assign fractional cover of landuse classes to each ECMWF grid point
-!********************************************************************
+  ! Assign fractional cover of landuse classes to each ECMWF grid point
+  !********************************************************************
 
   if (verbosity.gt.0 .and. lroot) then
@@ -289,7 +305,6 @@
   call readreleases
 
-
-! Read and compute surface resistances to dry deposition of gases
-!****************************************************************
+  ! Read and compute surface resistances to dry deposition of gases
+  !****************************************************************
 
   if (verbosity.gt.0 .and. lroot) then
@@ -305,5 +320,4 @@
     print*,'call coordtrafo'
   endif
-
 
   ! Initialize all particles to non-existent
@@ -337,9 +351,7 @@
   endif
 
-
   ! Calculate volume, surface area, etc., of all output grid cells
   ! Allocate fluxes and OHfield if necessary
   !***************************************************************
-
 
   if (verbosity.gt.0 .and. lroot) then
@@ -387,5 +399,5 @@
 
     call writeheader
-! FLEXPART 9.2 ticket ?? write header in ASCII format 
+    ! FLEXPART 9.2 ticket ?? write header in ASCII format 
     call writeheader_txt
 
@@ -445,6 +457,6 @@
   end if
 
-! Calculate particle trajectories
-!********************************
+  ! Calculate particle trajectories
+  !********************************
 
   if (verbosity.gt.0.and. lroot) then
