From 87ab224ab9c08eb099e03cdca8950da483d60a91 Mon Sep 17 00:00:00 2001
From: lucieb92 <lucie.bakels@univie.ac.at>
Date: Mon, 3 Jun 2024 14:19:30 +0200
Subject: [PATCH] move ndia to par_mod, since it is a numerical value and not a
 particle property

Former-commit-id: f41c000158d3ed69446ee50666a6bdd3bd4161c7
---
 src/com_mod.f90         |  4 ++--
 src/initialise_mod.f90  |  4 +---
 src/par_mod.f90         |  1 +
 src/readoptions_mod.f90 | 37 ++++++++++++++++++++++---------------
 4 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/src/com_mod.f90 b/src/com_mod.f90
index 8e1b38f7..45eb2156 100644
--- a/src/com_mod.f90
+++ b/src/com_mod.f90
@@ -15,7 +15,7 @@
 
 module com_mod
 
-  use par_mod, only: dp, numpath, maxnests, &
+  use par_mod, only: dp, numpath, maxnests, maxndia, &
        numclass, maxcolumn, maxrand, numwfmem, numpf, &
        maxreagent, maxrecsample
 
@@ -451,7 +451,7 @@ module com_mod
   integer :: numpart=0
   integer :: numparticlecount
   integer :: maxspec ! Number of chemical species per release
-  integer :: maxndia ! Number of diameter bins
+  !integer :: maxndia ! Number of diameter bins (now set in par_mod.f90)
   !real, allocatable, dimension(:,:) :: xscav_frac1
 
   !****************************************************************
diff --git a/src/initialise_mod.f90 b/src/initialise_mod.f90
index 5f98e205..9a1cd6d4 100644
--- a/src/initialise_mod.f90
+++ b/src/initialise_mod.f90
@@ -1075,9 +1075,7 @@ subroutine init_domainfill
   ! information, which is stored as a 3-d field
   !*****************************************************************************
 
-      do kz=1,nz
-        pp(kz)=prs(lix,ljy,kz,1)!rho(lix,ljy,kz,1)*r_air*tt(lix,ljy,kz,1)
-      end do
+      pp(:)=prs(lix,ljy,:,1)!rho(lix,ljy,kz,1)*r_air*tt(lix,ljy,kz,1)
 
 
       deltacol=(pp(1)-pp(nz))/real(ncolumn)
diff --git a/src/par_mod.f90 b/src/par_mod.f90
index 5b815f85..deb503b9 100644
--- a/src/par_mod.f90
+++ b/src/par_mod.f90
@@ -189,6 +189,7 @@ module par_mod
   integer,parameter :: maxtable=1000, numclass=13
   integer,parameter :: numpf=1 ! number of precip fields original =1, new=3(AT and PS, #295)
   integer,parameter :: numwfmem=2 ! Serial version/MPI with 2 fields
+  integer,parameter :: maxndia=1
   !integer,parameter :: numwfmem=3 ! MPI with 3 fields
 
   ! maxtable     Maximum number of chemical species that can be tabulated 
diff --git a/src/readoptions_mod.f90 b/src/readoptions_mod.f90
index 491789bf..5e92c357 100644
--- a/src/readoptions_mod.f90
+++ b/src/readoptions_mod.f90
@@ -2696,7 +2696,7 @@ subroutine readspecies(id_spec,pos_spec)
   real :: pcrain_aero, pcsnow_aero, pccn_aero, pin_aero
   real :: pohcconst,pohdconst,pohnconst ! deprecated
   real :: parea_dow(7), parea_hour(24), ppoint_dow(7), ppoint_hour(24)
-  integer :: pndia
+  !integer :: pndia
   integer :: ios
   integer :: pshape,porient
   ! Daria Tatsii: species shape properties
@@ -2706,12 +2706,12 @@ subroutine readspecies(id_spec,pos_spec)
   namelist /species_params/ &
        pspecies, pdecay, pweta_gas, pwetb_gas, &
        pcrain_aero, pcsnow_aero, pccn_aero, pin_aero, &
-       preldiff, phenry, pf0, pdensity, pdquer, &
-       pdsigma, pndia, pdryvel, pweightmolar, pohnconst, &
+       preldiff, phenry, pf0, pdensity, pdquer, pdia, &
+       pdsigma, pdryvel, pweightmolar, pohnconst, &
        preactions, pcconst, pdconst, pnconst, pohcconst, pohdconst, &
        pemis_path, pemis_file, pemis_name, pemis_unit, pemis_coeff, &
        parea_dow, parea_hour, ppoint_dow, ppoint_hour, &
-       pshape, paspectratio, pla, pia, psa, porient
+       pshape, paspectratio, pla, pia, psa, porient !pndia, 
 
   ! allocate reaction variables
   allocate(preactions(maxreagent))
@@ -2741,13 +2741,13 @@ subroutine readspecies(id_spec,pos_spec)
   pccn_aero=-9.9E-09
   pin_aero=-9.9E-09
   preldiff=-9.9
-  phenry=0.0
+  phenry=-9.9
   pf0=0.0
   pdensity=-9.9E09
   pdquer=0.0
-  pdia=0.0
+  pdia=-9.9
   pdsigma=0.0
-  pndia=1
+  !pndia=1
   pdryvel=-9.99
   preactions(:)=""
   pcconst(:)=-9.99e-9
@@ -2815,7 +2815,8 @@ subroutine readspecies(id_spec,pos_spec)
   endif
 
   if ((pohcconst.ne.-9.99).or.(pohdconst.ne.-9.99).or.(pohnconst.ne.-9.99)) then
-    write(*,*) "WARNING: POHCCONST,POHDCONST, and POHNCONST in SPECIES file are deprecated."
+    write(*,*) "ERROR: POHCCONST,POHDCONST, and POHNCONST in SPECIES file are deprecated."
+    error stop
   endif
   species(pos_spec)=pspecies
   decay(pos_spec)=pdecay
@@ -2829,9 +2830,16 @@ subroutine readspecies(id_spec,pos_spec)
   henry(pos_spec)=phenry
   f0(pos_spec)=pf0
   density(pos_spec)=pdensity
-  dquer(pos_spec)=pdquer
+  if (pdia.ne.0.0) then
+    dquer(pos_spec)=pdia
+  else if (pdquer.ne.0.0) then
+    write(*,*) 'WARNING: PDQUER will be depricated, please use PDIA instead.'
+    dquer(pos_spec)=pdquer ! For backwards compatibility
+  else
+    dquer(pos_spec)=0.0
+  endif
   dsigma(pos_spec)=pdsigma
-  ndia(pos_spec)=pndia
+  ! ndia(pos_spec)=pndia
   dryvel(pos_spec)=pdryvel
   weightmolar(pos_spec)=pweightmolar
   emis_path(pos_spec)=pemis_path
@@ -3074,11 +3082,10 @@ subroutine readspecies(id_spec,pos_spec)
     end if
   end if
 
-  if (ndia(pos_spec).gt.maxndia) then
-    maxndia=ndia(pos_spec)
-    ! write(*,*) 'NDIA in SPECIES file', pos_spec, 'set to', ndia(pos_spec), 'larger than maxndia', &
-    !   maxndia, 'set in par_mod.f90'
-  endif
+  !if (ndia(pos_spec).gt.maxndia) then
+  !  maxndia=ndia(pos_spec)
+  !endif
+  ndia(pos_spec)=maxndia ! Setting all ndia to maxndia (par_mod.f90)
   !  if (dsigma(i).eq.0.) dsigma(i)=1.0001   ! avoid floating exception
   if (dquer(i).gt.0 .and. dsigma(i).le.1.) then !dsigma(i)=1.0001   ! avoid floating exception
     !write(*,*) '#### FLEXPART MODEL ERROR!                      ####'
-- 
GitLab