source: flexpart.git/src/readspecies.f90 @ 6a713e8

10.4.1_peseiGFS_025bugfixes+enhancementsdevrelease-10release-10.4.1scaling-bug
Last change on this file since 6a713e8 was 6a713e8, checked in by Sabine <sabine.eckhardt@…>, 5 years ago

bugfix in readspecies, DOW* were unitialized

  • Property mode set to 100644
File size: 16.1 KB
Line 
1!**********************************************************************
2! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010         *
3! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa,             *
4! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann   *
5!                                                                     *
6! This file is part of FLEXPART.                                      *
7!                                                                     *
8! FLEXPART is free software: you can redistribute it and/or modify    *
9! it under the terms of the GNU General Public License as published by*
10! the Free Software Foundation, either version 3 of the License, or   *
11! (at your option) any later version.                                 *
12!                                                                     *
13! FLEXPART is distributed in the hope that it will be useful,         *
14! but WITHOUT ANY WARRANTY; without even the implied warranty of      *
15! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
16! GNU General Public License for more details.                        *
17!                                                                     *
18! You should have received a copy of the GNU General Public License   *
19! along with FLEXPART.  If not, see <http://www.gnu.org/licenses/>.   *
20!**********************************************************************
21
22subroutine readspecies(id_spec,pos_spec)
23
24  !*****************************************************************************
25  !                                                                            *
26  !     This routine reads names and physical constants of chemical species/   *
27  !     radionuclides given in the parameter pos_spec                          *
28  !                                                                            *
29  !   Author: A. Stohl                                                         *
30  !                                                                            *
31  !   11 July 1996                                                             *
32  !                                                                            *
33  !   Changes:                                                                 *
34  !   N. Kristiansen, 31.01.2013: Including parameters for in-cloud scavenging *
35  !                                                                            *
36  !   HSO, 13 August 2013
37  !   added optional namelist input
38  !                                                                            *
39  !*****************************************************************************
40  !                                                                            *
41  ! Variables:                                                                 *
42  ! decaytime(maxtable)   half time for radiological decay                     *
43  ! specname(maxtable)    names of chemical species, radionuclides             *
44  ! weta_gas, wetb_gas    Parameters for below-cloud scavenging of gasses      *
45  ! crain_aero,csnow_aero Parameters for below-cloud scavenging of aerosols    *
46  ! ccn_aero,in_aero      Parameters for in-cloud scavenging of aerosols       *
47  ! ohcconst              OH reaction rate constant C                          *
48  ! ohdconst              OH reaction rate constant D                          *
49  ! ohnconst              OH reaction rate constant n                          *
50  ! id_spec               SPECIES number as referenced in RELEASE file         *
51  ! id_pos                position where SPECIES data shall be stored          *
52  !                                                                            *
53  ! Constants:                                                                 *
54  !                                                                            *
55  !*****************************************************************************
56
57  use par_mod
58  use com_mod
59
60  implicit none
61
62  integer :: i, pos_spec,j
63  integer :: idow,ihour,id_spec
64  character(len=3) :: aspecnumb
65  logical :: spec_found
66
67  character(len=16) :: pspecies
68  real :: pdecay, pweta_gas, pwetb_gas, preldiff, phenry, pf0, pdensity, pdquer
69  real :: pdsigma, pdryvel, pweightmolar, pohcconst, pohdconst, pohnconst
70  real :: pcrain_aero, pcsnow_aero, pccn_aero, pin_aero
71  real :: parea_dow(7), parea_hour(24), ppoint_dow(7), ppoint_hour(24)
72  integer :: readerror
73
74! declare namelist
75  namelist /species_params/ &
76       pspecies, pdecay, pweta_gas, pwetb_gas, &
77       pcrain_aero, pcsnow_aero, pccn_aero, pin_aero, &
78       preldiff, phenry, pf0, pdensity, pdquer, &
79       pdsigma, pdryvel, pweightmolar, pohcconst, pohdconst, pohnconst, &
80       parea_dow, parea_hour, ppoint_dow, ppoint_hour
81
82  pspecies="" ! read failure indicator value
83  pdecay=-999.9
84  pweta_gas=-9.9E-09
85  pwetb_gas=0.0
86  pcrain_aero=-9.9E-09
87  pcsnow_aero=-9.9E-09
88  pccn_aero=-9.9E-09
89  pin_aero=-9.9E-09
90  preldiff=-9.9
91  phenry=0.0
92  pf0=0.0
93  pdensity=-9.9E09
94  pdquer=0.0
95  pdsigma=0.0
96  pdryvel=-9.99
97  pohcconst=-9.99
98  pohdconst=-9.9E-09
99  pohnconst=2.0
100  pweightmolar=-999.9
101
102  do j=1,24           ! initialize everything to no variation
103    parea_hour(j)=1.
104    ppoint_hour(j)=1.
105    area_hour(pos_spec,j)=1.
106    point_hour(pos_spec,j)=1.
107  end do
108  do j=1,7
109    parea_dow(j)=1.
110    ppoint_dow(j)=1.
111    area_dow(pos_spec,j)=1.
112    point_dow(pos_spec,j)=1.
113  end do
114
115  if (readerror.ne.0) then ! text format input
116! Open the SPECIES file and read species names and properties
117!************************************************************
118  specnum(pos_spec)=id_spec
119  write(aspecnumb,'(i3.3)') specnum(pos_spec)
120  open(unitspecies,file=path(1)(1:length(1))//'SPECIES/SPECIES_'//aspecnumb,status='old',form='formatted',err=998)
121!write(*,*) 'reading SPECIES',specnum(pos_spec)
122
123  ASSSPEC=.FALSE.
124
125! try namelist input
126  read(unitspecies,species_params,iostat=readerror)
127  close(unitspecies)
128
129  if ((len(trim(pspecies)).eq.0).or.(readerror.ne.0)) then ! no namelist found
130    if (lroot) write(*,*) "SPECIES file not in NAMELIST format, attempting to &
131         &read as fixed format"
132
133    readerror=1
134
135    open(unitspecies,file=path(1)(1:length(1))//'SPECIES/SPECIES_'//aspecnumb,status='old',err=998)
136
137    do i=1,6
138      read(unitspecies,*)
139    end do
140
141    read(unitspecies,'(a10)',end=22) species(pos_spec)
142!  write(*,*) species(pos_spec)
143    read(unitspecies,'(f18.1)',end=22) decay(pos_spec)
144!  write(*,*) decay(pos_spec)
145    read(unitspecies,'(e18.1)',end=22) weta_gas(pos_spec)
146!  write(*,*) weta_gas(pos_spec)
147    read(unitspecies,'(f18.2)',end=22) wetb_gas(pos_spec)
148!  write(*,*) wetb_gas(pos_spec)
149    read(unitspecies,'(e18.1)',end=22) crain_aero(pos_spec)
150!  write(*,*) crain_aero(pos_spec)
151    read(unitspecies,'(f18.2)',end=22) csnow_aero(pos_spec)
152!  write(*,*) csnow_aero(pos_spec)
153!*** NIK 31.01.2013: including in-cloud scavening parameters
154    read(unitspecies,'(e18.1)',end=22) ccn_aero(pos_spec)
155!  write(*,*) ccn_aero(pos_spec)
156    read(unitspecies,'(f18.2)',end=22) in_aero(pos_spec)
157!  write(*,*) in_aero(pos_spec)
158    read(unitspecies,'(f18.1)',end=22) reldiff(pos_spec)
159!  write(*,*) reldiff(pos_spec)
160    read(unitspecies,'(e18.1)',end=22) henry(pos_spec)
161!  write(*,*) henry(pos_spec)
162    read(unitspecies,'(f18.1)',end=22) f0(pos_spec)
163!  write(*,*) f0(pos_spec)
164    read(unitspecies,'(e18.1)',end=22) density(pos_spec)
165!  write(*,*) density(pos_spec)
166    read(unitspecies,'(e18.1)',end=22) dquer(pos_spec)
167!  write(*,*) 'dquer(pos_spec):', dquer(pos_spec)
168    read(unitspecies,'(e18.1)',end=22) dsigma(pos_spec)
169!  write(*,*) dsigma(pos_spec)
170    read(unitspecies,'(f18.2)',end=22) dryvel(pos_spec)
171!  write(*,*) dryvel(pos_spec)
172    read(unitspecies,'(f18.2)',end=22) weightmolar(pos_spec)
173!  write(*,*) weightmolar(pos_spec)
174    read(unitspecies,'(e18.2)',end=22) ohcconst(pos_spec)
175!  write(*,*) ohcconst(pos_spec)
176    read(unitspecies,'(f8.2)',end=22) ohdconst(pos_spec)
177!  write(*,*) ohdconst(pos_spec)
178    read(unitspecies,'(f8.2)',end=22) ohnconst(pos_spec)
179!  write(*,*) ohnconst(pos_spec)
180
181! Read in daily and day-of-week variation of emissions, if available
182!*******************************************************************
183
184    read(unitspecies,*,end=22)
185    do j=1,24     ! 24 hours, starting with 0-1 local time
186      read(unitspecies,*) ihour,area_hour(pos_spec,j),point_hour(pos_spec,j)
187    end do
188    read(unitspecies,*)
189    do j=1,7      ! 7 days of the week, starting with Monday
190      read(unitspecies,*) idow,area_dow(pos_spec,j),point_dow(pos_spec,j)
191    end do
192
193    pspecies=species(pos_spec)
194    pdecay=decay(pos_spec)
195    pweta_gas=weta_gas(pos_spec)
196    pwetb_gas=wetb_gas(pos_spec)
197    pcrain_aero=crain_aero(pos_spec)
198    pcsnow_aero=csnow_aero(pos_spec)
199    pccn_aero=ccn_aero(pos_spec)
200    pin_aero=in_aero(pos_spec)
201    preldiff=reldiff(pos_spec)
202    phenry=henry(pos_spec)
203    pf0=f0(pos_spec)
204    pdensity=density(pos_spec)
205    pdquer=dquer(pos_spec)
206    pdsigma=dsigma(pos_spec)
207    pdryvel=dryvel(pos_spec)
208    pweightmolar=weightmolar(pos_spec)
209    pohcconst=ohcconst(pos_spec)
210    pohdconst=ohdconst(pos_spec)
211    pohnconst=ohnconst(pos_spec)
212
213
214    do j=1,24     ! 24 hours, starting with 0-1 local time
215      parea_hour(j)=area_hour(pos_spec,j)
216      ppoint_hour(j)=point_hour(pos_spec,j)
217    end do
218    do j=1,7      ! 7 days of the week, starting with Monday
219      parea_dow(j)=area_dow(pos_spec,j)
220      ppoint_dow(j)=point_dow(pos_spec,j)
221    end do
222
223  else ! namelist available
224
225    species(pos_spec)=pspecies
226    decay(pos_spec)=pdecay
227    weta_gas(pos_spec)=pweta_gas
228    wetb_gas(pos_spec)=pwetb_gas
229    crain_aero(pos_spec)=pcrain_aero
230    csnow_aero(pos_spec)=pcsnow_aero
231    ccn_aero(pos_spec)=pccn_aero
232    in_aero(pos_spec)=pin_aero
233    reldiff(pos_spec)=preldiff
234    henry(pos_spec)=phenry
235    f0(pos_spec)=pf0
236    density(pos_spec)=pdensity
237    dquer(pos_spec)=pdquer
238    dsigma(pos_spec)=pdsigma
239    dryvel(pos_spec)=pdryvel
240    weightmolar(pos_spec)=pweightmolar
241    ohcconst(pos_spec)=pohcconst
242    ohdconst(pos_spec)=pohdconst
243    ohnconst(pos_spec)=pohnconst
244
245    do j=1,24     ! 24 hours, starting with 0-1 local time
246      area_hour(pos_spec,j)=parea_hour(j)
247      point_hour(pos_spec,j)=ppoint_hour(j)
248    end do
249    do j=1,7      ! 7 days of the week, starting with Monday
250      area_dow(pos_spec,j)=parea_dow(j)
251      point_dow(pos_spec,j)=ppoint_dow(j)
252    end do
253
254  endif
255
256  i=pos_spec
257
258!NIK 16.02.2015
259! Check scavenging parameters given in SPECIES file
260
261  if (lroot) then
262! ZHG 2016.04.07 Start of changes
263    write(*,*) ' '
264    if (dquer(pos_spec) .gt.0)  write(*,'(a,i3,a,a,a)')       ' SPECIES: ', &
265         &id_spec,'  ', species(pos_spec),'  (AEROSOL) '
266    if (dquer(pos_spec) .le.0)  write(*,'(a,i3,a,a,a)')       ' SPECIES: ', &
267         &id_spec,'  ', species(pos_spec),'  (GAS) '
268
269! Particles
270!**********
271    if (dquer(pos_spec).gt.0) then
272      if (ccn_aero(pos_spec) .gt. 0) then
273        write(*,'(a,f5.2)') '  Particle CCN  efficiency (CCNeff):', ccn_aero(pos_spec)
274      else
275        write(*,'(a)')      '  Particle CCN  efficiency (CCNeff):   OFF'
276      endif
277      if (in_aero(pos_spec) .gt. 0) then
278        write(*,'(a,f5.2)') '  Particle  IN  efficiency (INeff) :', in_aero(pos_spec)
279      else
280        write(*,'(a)')      '  Particle  IN  efficiency (INeff) :   OFF'
281      endif
282      if (crain_aero(pos_spec) .gt. 0) then
283        write(*,'(a,f5.2)') '  Particle Rain efficiency (Crain) :', crain_aero(pos_spec)
284      else
285        write(*,'(a)')      '  Particle Rain efficiency (Crain) :   OFF'
286      endif
287      if (csnow_aero(pos_spec) .gt. 0) then
288        write(*,'(a,f5.2)') '  Particle Snow efficiency (Csnow) :', csnow_aero(pos_spec)
289      else
290        write(*,'(a)')      '  Particle Snow efficiency (Csnow) :   OFF'
291      end if
292      if (density(pos_spec) .gt. 0) then
293        write(*,'(a)') '  Dry deposition is turned         :   ON'
294      else
295        write(*,'(a)') '  Dry deposition is (density<0)    :   OFF'
296      end if
297      if (crain_aero(pos_spec).gt.10.0 .or. csnow_aero(pos_spec).gt.10.0 .or. &
298           &ccn_aero(pos_spec).gt.1.0 .or. in_aero(pos_spec).gt.1.0) then
299        write(*,*) '*******************************************'
300        write(*,*) ' WARNING: Particle Scavenging parameter likely out of range '
301        write(*,*) '       Likely   range for Crain    0.0-10'
302        write(*,*) '       Likely   range for Csnow    0.0-10'
303        write(*,*) '       Physical range for CCNeff   0.0-1'
304        write(*,*) '       Physical range for INeff    0.0-1'
305        write(*,*) '*******************************************'
306      end if
307    else
308! Gas
309!****
310      if (weta_gas(pos_spec) .gt. 0 .and. wetb_gas(pos_spec).gt.0) then
311        write(*,*)          '  Wet removal for gases      is turned: ON'
312        write(*,*)          '  Gas below-cloud scavenging parameter A  ', &
313             &weta_gas(pos_spec)
314        write(*,'(a,f5.2)') '  Gas below-cloud scavenging parameter B  ', &
315             &wetb_gas(pos_spec)
316      else
317        write(*,*)          '  Wet removal for gases      is turned: OFF '
318      end if
319      if (reldiff(i).gt.0.) then
320        write(*,*)          '  Dry deposition for gases   is turned: ON '
321      else
322        write(*,*)          '  Dry deposition for gases   is turned: OFF '
323      end if
324      if (weta_gas(pos_spec).gt.0.) then !if wet deposition is turned on
325        if (weta_gas(pos_spec).gt.1E-04 .or. weta_gas(pos_spec).lt.1E-09 .or. &
326             &wetb_gas(pos_spec).gt.0.8 .or. wetb_gas(pos_spec).lt.0.4) then
327          write(*,*) '*******************************************'
328          write(*,*) ' WARNING: Gas below-cloud scavengig is out of likely range'
329          write(*,*) '          Likely range for A is 1E-04 to 1E-08'
330          write(*,*) '          Likely range for B is 0.60  to 0.80 '
331          write(*,*) '*******************************************'
332        end if
333      endif
334
335      if (((weta_gas(pos_spec).gt.0).or.(wetb_gas(pos_spec).gt.0)).and.&
336           &(henry(pos_spec).le.0)) then
337        if (dquer(pos_spec).le.0) goto 996 ! no particle, no henry set
338      endif
339    end if
340  end if
341
342  if (dsigma(i).eq.0.) dsigma(i)=1.0001   ! avoid floating exception
343
344  if ((reldiff(i).gt.0.).and.(density(i).gt.0.)) then
345    write(*,*) '#### FLEXPART MODEL ERROR! FILE "SPECIES"    ####'
346    write(*,*) '#### IS CORRUPT. SPECIES CANNOT BE BOTH      ####'
347    write(*,*) '#### PARTICLE AND GAS.                       ####'
348    write(*,*) '#### SPECIES NUMBER',aspecnumb
349    stop
350  endif
35120 continue
352
353
354  endif
355
35622 close(unitspecies)
357
358! namelist output if requested
359  if (nmlout.and.lroot) then
360    open(unitspecies,file=path(2)(1:length(2))//'SPECIES_'//aspecnumb//'.namelist',access='append',status='replace',err=1000)
361    write(unitspecies,nml=species_params)
362    close(unitspecies)
363  endif
364
365  return
366
367996 write(*,*) '#####################################################'
368  write(*,*) '#### FLEXPART MODEL ERROR!                      #### '
369  write(*,*) '#### WET DEPOSITION SWITCHED ON, BUT NO HENRYS  #### '
370  write(*,*) '#### CONSTANT IS SET                            ####'
371  write(*,*) '#### PLEASE MODIFY SPECIES DESCR. FILE!        #### '
372  write(*,*) '#####################################################'
373  stop
374
375
376997 write(*,*) '#####################################################'
377  write(*,*) '#### FLEXPART MODEL ERROR!                      #### '
378  write(*,*) '#### THE ASSSOCIATED SPECIES HAS TO BE DEFINED  #### '
379  write(*,*) '#### BEFORE THE ONE WHICH POINTS AT IT          #### '
380  write(*,*) '#### PLEASE CHANGE ORDER IN RELEASES OR ADD     #### '
381  write(*,*) '#### THE ASSOCIATED SPECIES IN RELEASES         #### '
382  write(*,*) '#####################################################'
383  stop
384
385
386998 write(*,*) '#####################################################'
387  write(*,*) '#### FLEXPART MODEL ERROR!                      #### '
388  write(*,*) '#### THE SPECIES FILE FOR SPECIES ', id_spec
389  write(*,*) '#### CANNOT BE FOUND: CREATE FILE'
390  write(*,*) '#### ',path(1)(1:length(1)),'SPECIES/SPECIES_',aspecnumb
391  write(*,*) '#####################################################'
392  stop
393
3941000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "SPECIES_',aspecnumb,'.namelist'
395  write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
396  write(*,'(a)') path(2)(1:length(2))
397  stop
398
399end subroutine readspecies
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG