[92fab65] | 1 | ! SPDX-FileCopyrightText: FLEXPART 1998-2019, see flexpart_license.txt |
---|
| 2 | ! SPDX-License-Identifier: GPL-3.0-or-later |
---|
[332fbbd] | 3 | |
---|
[e200b7a] | 4 | subroutine readreleases |
---|
| 5 | |
---|
| 6 | !***************************************************************************** |
---|
| 7 | ! * |
---|
| 8 | ! This routine reads the release point specifications for the current * |
---|
| 9 | ! model run. Several release points can be used at the same time. * |
---|
| 10 | ! * |
---|
| 11 | ! Author: A. Stohl * |
---|
| 12 | ! * |
---|
| 13 | ! 18 May 1996 * |
---|
| 14 | ! * |
---|
| 15 | ! Update: 29 January 2001 * |
---|
| 16 | ! Release altitude can be either in magl or masl * |
---|
[b4d29ce] | 17 | ! HSO, 12 August 2013 |
---|
| 18 | ! Added optional namelist input |
---|
[e200b7a] | 19 | ! * |
---|
| 20 | !***************************************************************************** |
---|
| 21 | ! * |
---|
| 22 | ! Variables: * |
---|
| 23 | ! decay decay constant of species * |
---|
| 24 | ! dquer [um] mean particle diameters * |
---|
| 25 | ! dsigma e.g. dsigma=10 or dsigma=0.1 means that 68% of the mass* |
---|
| 26 | ! are between 0.1*dquer and 10*dquer * |
---|
| 27 | ! ireleasestart, ireleaseend [s] starting time and ending time of each * |
---|
| 28 | ! release * |
---|
| 29 | ! kindz 1: zpoint is in m agl, 2: zpoint is in m asl, 3: zpoint* |
---|
| 30 | ! is in hPa * |
---|
| 31 | ! npart number of particles to be released * |
---|
| 32 | ! nspec number of species to be released * |
---|
| 33 | ! density [kg/m3] density of the particles * |
---|
| 34 | ! rm [s/m] Mesophyll resistance * |
---|
| 35 | ! species name of species * |
---|
| 36 | ! xmass total mass of each species * |
---|
| 37 | ! xpoint1,ypoint1 geograf. coordinates of lower left corner of release * |
---|
| 38 | ! area * |
---|
| 39 | ! xpoint2,ypoint2 geograf. coordinates of upper right corner of release * |
---|
| 40 | ! area * |
---|
[341f4b7] | 41 | ! weta_gas, wetb_gas parameters for below-cloud scavenging (gas) * |
---|
| 42 | ! crain_aero, csnow_aero parameters for below-cloud scavenging (aerosol) * |
---|
| 43 | ! ccn_aero, in_aero parameters for in-cloud scavenging (aerosol) * |
---|
[e200b7a] | 44 | ! zpoint1,zpoint2 height range, over which release takes place * |
---|
[f13406c] | 45 | ! num_min_discrete if less, release cannot be randomized and happens at * |
---|
| 46 | ! time mid-point of release interval * |
---|
[8a65cb0] | 47 | ! lroot true if serial version, or if MPI and root process * |
---|
[e200b7a] | 48 | ! * |
---|
| 49 | !***************************************************************************** |
---|
| 50 | |
---|
| 51 | use point_mod |
---|
| 52 | use xmass_mod |
---|
| 53 | use par_mod |
---|
| 54 | use com_mod |
---|
| 55 | |
---|
| 56 | implicit none |
---|
| 57 | |
---|
[5184a7c] | 58 | integer :: numpartmax,i,j,id1,it1,id2,it2,idum,stat,irel,ispc,nsettle |
---|
[f13406c] | 59 | integer,parameter :: num_min_discrete=100 |
---|
[e200b7a] | 60 | real :: vsh(ni),fracth(ni),schmih(ni),releaserate,xdum,cun |
---|
[f13406c] | 61 | real(kind=dp) :: jul1,jul2,julm,juldate |
---|
[5184a7c] | 62 | real,parameter :: eps2=1.e-9 |
---|
[e200b7a] | 63 | character(len=50) :: line |
---|
| 64 | logical :: old |
---|
| 65 | |
---|
[b4d29ce] | 66 | ! help variables for namelist reading |
---|
| 67 | integer :: numpoints, parts, readerror |
---|
| 68 | integer*2 :: zkind |
---|
| 69 | integer :: idate1, itime1, idate2, itime2 |
---|
| 70 | real :: lon1,lon2,lat1,lat2,z1,z2 |
---|
| 71 | character*40 :: comment |
---|
| 72 | integer,parameter :: unitreleasesout=2 |
---|
| 73 | real,allocatable, dimension (:) :: mass |
---|
| 74 | integer,allocatable, dimension (:) :: specnum_rel,specnum_rel2 |
---|
| 75 | |
---|
| 76 | ! declare namelists |
---|
| 77 | namelist /releases_ctrl/ & |
---|
[5184a7c] | 78 | nspec, & |
---|
| 79 | specnum_rel |
---|
[b4d29ce] | 80 | |
---|
| 81 | namelist /release/ & |
---|
[5184a7c] | 82 | idate1, itime1, & |
---|
| 83 | idate2, itime2, & |
---|
| 84 | lon1, lon2, & |
---|
| 85 | lat1, lat2, & |
---|
| 86 | z1, z2, & |
---|
| 87 | zkind, & |
---|
| 88 | mass, & |
---|
| 89 | parts, & |
---|
| 90 | comment |
---|
[e200b7a] | 91 | |
---|
[b4d29ce] | 92 | numpoint=0 |
---|
[e200b7a] | 93 | |
---|
[b4d29ce] | 94 | ! allocate with maxspec for first input loop |
---|
| 95 | allocate(mass(maxspec),stat=stat) |
---|
| 96 | if (stat.ne.0) write(*,*)'ERROR: could not allocate mass' |
---|
| 97 | allocate(specnum_rel(maxspec),stat=stat) |
---|
| 98 | if (stat.ne.0) write(*,*)'ERROR: could not allocate specnum_rel' |
---|
[e200b7a] | 99 | |
---|
[b4d29ce] | 100 | ! presetting namelist releases_ctrl |
---|
| 101 | nspec = -1 ! use negative value to determine failed namelist input |
---|
| 102 | specnum_rel = 0 |
---|
| 103 | |
---|
| 104 | !sec, read release to find how many releasepoints should be allocated |
---|
| 105 | open(unitreleases,file=path(1)(1:length(1))//'RELEASES',status='old',form='formatted',err=999) |
---|
| 106 | |
---|
| 107 | ! check if namelist input provided |
---|
| 108 | read(unitreleases,releases_ctrl,iostat=readerror) |
---|
| 109 | |
---|
| 110 | ! prepare namelist output if requested |
---|
[8a65cb0] | 111 | if (nmlout.and.lroot) then |
---|
| 112 | open(unitreleasesout,file=path(2)(1:length(2))//'RELEASES.namelist',access='append',status='replace',err=1000) |
---|
[e200b7a] | 113 | endif |
---|
| 114 | |
---|
[b4d29ce] | 115 | if ((readerror.ne.0).or.(nspec.lt.0)) then |
---|
[e200b7a] | 116 | |
---|
[5184a7c] | 117 | ! no namelist format, close file and allow reopening in old format |
---|
[b4d29ce] | 118 | close(unitreleases) |
---|
| 119 | open(unitreleases,file=path(1)(1:length(1))//'RELEASES',status='old',err=999) |
---|
[e200b7a] | 120 | |
---|
[b4d29ce] | 121 | readerror=1 ! indicates old format |
---|
[e200b7a] | 122 | |
---|
[5184a7c] | 123 | ! Check the format of the RELEASES file (either in free format, |
---|
| 124 | ! or using a formatted mask) |
---|
| 125 | ! Use of formatted mask is assumed if line 10 contains the word 'DIRECTION' |
---|
| 126 | !************************************************************************** |
---|
[e200b7a] | 127 | |
---|
[b4d29ce] | 128 | call skplin(12,unitreleases) |
---|
| 129 | read (unitreleases,901) line |
---|
| 130 | 901 format (a) |
---|
| 131 | if (index(line,'Total') .eq. 0) then |
---|
| 132 | old = .false. |
---|
| 133 | else |
---|
| 134 | old = .true. |
---|
| 135 | endif |
---|
| 136 | rewind(unitreleases) |
---|
[e200b7a] | 137 | |
---|
[b4d29ce] | 138 | |
---|
[5184a7c] | 139 | ! Skip first 11 lines (file header) |
---|
| 140 | !********************************** |
---|
[b4d29ce] | 141 | |
---|
| 142 | call skplin(11,unitreleases) |
---|
| 143 | |
---|
| 144 | read(unitreleases,*,err=998) nspec |
---|
| 145 | if (old) call skplin(2,unitreleases) |
---|
| 146 | do i=1,nspec |
---|
| 147 | read(unitreleases,*,err=998) specnum_rel(i) |
---|
| 148 | if (old) call skplin(2,unitreleases) |
---|
| 149 | end do |
---|
| 150 | |
---|
| 151 | numpoint=0 |
---|
| 152 | 100 numpoint=numpoint+1 |
---|
| 153 | read(unitreleases,*,end=25) |
---|
| 154 | read(unitreleases,*,err=998,end=25) idum,idum |
---|
| 155 | if (old) call skplin(2,unitreleases) |
---|
| 156 | read(unitreleases,*,err=998) idum,idum |
---|
| 157 | if (old) call skplin(2,unitreleases) |
---|
| 158 | read(unitreleases,*,err=998) xdum |
---|
| 159 | if (old) call skplin(2,unitreleases) |
---|
| 160 | read(unitreleases,*,err=998) xdum |
---|
| 161 | if (old) call skplin(2,unitreleases) |
---|
[e200b7a] | 162 | read(unitreleases,*,err=998) xdum |
---|
| 163 | if (old) call skplin(2,unitreleases) |
---|
[b4d29ce] | 164 | read(unitreleases,*,err=998) xdum |
---|
| 165 | if (old) call skplin(2,unitreleases) |
---|
| 166 | read(unitreleases,*,err=998) idum |
---|
| 167 | if (old) call skplin(2,unitreleases) |
---|
| 168 | read(unitreleases,*,err=998) xdum |
---|
| 169 | if (old) call skplin(2,unitreleases) |
---|
| 170 | read(unitreleases,*,err=998) xdum |
---|
| 171 | if (old) call skplin(2,unitreleases) |
---|
| 172 | read(unitreleases,*,err=998) idum |
---|
| 173 | if (old) call skplin(2,unitreleases) |
---|
| 174 | do i=1,nspec |
---|
| 175 | read(unitreleases,*,err=998) xdum |
---|
| 176 | if (old) call skplin(2,unitreleases) |
---|
| 177 | end do |
---|
[5184a7c] | 178 | !save compoint only for the first 1000 release points |
---|
[b4d29ce] | 179 | read(unitreleases,'(a40)',err=998) compoint(1)(1:40) |
---|
| 180 | if (old) call skplin(1,unitreleases) |
---|
| 181 | |
---|
| 182 | goto 100 |
---|
| 183 | |
---|
| 184 | 25 numpoint=numpoint-1 |
---|
| 185 | |
---|
| 186 | else |
---|
| 187 | |
---|
| 188 | readerror=0 |
---|
| 189 | do while (readerror.eq.0) |
---|
| 190 | idate1=-1 |
---|
| 191 | read(unitreleases,release,iostat=readerror) |
---|
| 192 | if ((idate1.lt.0).or.(readerror.ne.0)) then |
---|
| 193 | readerror=1 |
---|
| 194 | else |
---|
| 195 | numpoint=numpoint+1 |
---|
| 196 | endif |
---|
| 197 | end do |
---|
| 198 | readerror=0 |
---|
| 199 | endif ! if namelist input |
---|
| 200 | |
---|
| 201 | rewind(unitreleases) |
---|
| 202 | |
---|
[4c64400] | 203 | if (nspec.gt.maxspec) goto 994 |
---|
| 204 | |
---|
[b4d29ce] | 205 | ! allocate arrays of matching size for number of species (namelist output) |
---|
| 206 | deallocate(mass) |
---|
| 207 | allocate(mass(nspec),stat=stat) |
---|
| 208 | if (stat.ne.0) write(*,*)'ERROR: could not allocate mass' |
---|
| 209 | allocate(specnum_rel2(nspec),stat=stat) |
---|
| 210 | if (stat.ne.0) write(*,*)'ERROR: could not allocate specnum_rel2' |
---|
| 211 | specnum_rel2=specnum_rel(1:nspec) |
---|
[b0434e1] | 212 | deallocate(specnum_rel) |
---|
[5184a7c] | 213 | ! eso: BUG, crashes here for nspec=12 and maxspec=6, |
---|
| 214 | ! TODO: catch error and exit |
---|
[b4d29ce] | 215 | allocate(specnum_rel(nspec),stat=stat) |
---|
| 216 | if (stat.ne.0) write(*,*)'ERROR: could not allocate specnum_rel' |
---|
| 217 | specnum_rel=specnum_rel2 |
---|
| 218 | deallocate(specnum_rel2) |
---|
| 219 | |
---|
| 220 | !allocate memory for numpoint releaspoints |
---|
| 221 | allocate(ireleasestart(numpoint),stat=stat) |
---|
| 222 | if (stat.ne.0) write(*,*)'ERROR: could not allocate ireleasestart' |
---|
| 223 | allocate(ireleaseend(numpoint),stat=stat) |
---|
| 224 | if (stat.ne.0) write(*,*)'ERROR: could not allocate ireleaseend' |
---|
| 225 | allocate(xpoint1(numpoint),stat=stat) |
---|
| 226 | if (stat.ne.0) write(*,*)'ERROR: could not allocate xpoint1' |
---|
| 227 | allocate(xpoint2(numpoint),stat=stat) |
---|
| 228 | if (stat.ne.0) write(*,*)'ERROR: could not allocate xpoint2' |
---|
| 229 | allocate(ypoint1(numpoint),stat=stat) |
---|
| 230 | if (stat.ne.0) write(*,*)'ERROR: could not allocate ypoint1' |
---|
| 231 | allocate(ypoint2(numpoint),stat=stat) |
---|
| 232 | if (stat.ne.0) write(*,*)'ERROR: could not allocate ypoint2' |
---|
| 233 | allocate(zpoint1(numpoint),stat=stat) |
---|
| 234 | if (stat.ne.0) write(*,*)'ERROR: could not allocate zpoint1' |
---|
| 235 | allocate(zpoint2(numpoint),stat=stat) |
---|
| 236 | if (stat.ne.0) write(*,*)'ERROR: could not allocate zpoint2' |
---|
| 237 | allocate(kindz(numpoint),stat=stat) |
---|
| 238 | if (stat.ne.0) write(*,*)'ERROR: could not allocate kindz' |
---|
| 239 | allocate(xmass(numpoint,maxspec),stat=stat) |
---|
| 240 | if (stat.ne.0) write(*,*)'ERROR: could not allocate xmass' |
---|
| 241 | allocate(rho_rel(numpoint),stat=stat) |
---|
| 242 | if (stat.ne.0) write(*,*)'ERROR: could not allocate rho_rel' |
---|
| 243 | allocate(npart(numpoint),stat=stat) |
---|
| 244 | if (stat.ne.0) write(*,*)'ERROR: could not allocate npart' |
---|
| 245 | allocate(xmasssave(numpoint),stat=stat) |
---|
| 246 | if (stat.ne.0) write(*,*)'ERROR: could not allocate xmasssave' |
---|
| 247 | |
---|
[8a65cb0] | 248 | if (lroot) write (*,*) 'Releasepoints : ', numpoint |
---|
[b4d29ce] | 249 | |
---|
| 250 | do i=1,numpoint |
---|
| 251 | xmasssave(i)=0. |
---|
[e200b7a] | 252 | end do |
---|
| 253 | |
---|
| 254 | !now save the information |
---|
| 255 | DEP=.false. |
---|
| 256 | DRYDEP=.false. |
---|
| 257 | WETDEP=.false. |
---|
| 258 | OHREA=.false. |
---|
| 259 | do i=1,maxspec |
---|
| 260 | DRYDEPSPEC(i)=.false. |
---|
[c8fc724] | 261 | WETDEPSPEC(i)=.false. |
---|
[e200b7a] | 262 | end do |
---|
| 263 | |
---|
[b4d29ce] | 264 | if (readerror.ne.0) then |
---|
[5184a7c] | 265 | ! Skip first 11 lines (file header) |
---|
| 266 | !********************************** |
---|
[e200b7a] | 267 | |
---|
[b4d29ce] | 268 | call skplin(11,unitreleases) |
---|
[e200b7a] | 269 | |
---|
[5184a7c] | 270 | ! Assign species-specific parameters needed for physical processes |
---|
| 271 | !************************************************************************* |
---|
[e200b7a] | 272 | |
---|
[b4d29ce] | 273 | read(unitreleases,*,err=998) nspec |
---|
| 274 | if (nspec.gt.maxspec) goto 994 |
---|
| 275 | if (old) call skplin(2,unitreleases) |
---|
| 276 | endif |
---|
[e200b7a] | 277 | |
---|
[b4d29ce] | 278 | ! namelist output |
---|
[8a65cb0] | 279 | if (nmlout.and.lroot) then |
---|
[b4d29ce] | 280 | write(unitreleasesout,nml=releases_ctrl) |
---|
| 281 | endif |
---|
[e200b7a] | 282 | |
---|
| 283 | do i=1,nspec |
---|
[b4d29ce] | 284 | if (readerror.ne.0) then |
---|
| 285 | read(unitreleases,*,err=998) specnum_rel(i) |
---|
| 286 | if (old) call skplin(2,unitreleases) |
---|
| 287 | call readspecies(specnum_rel(i),i) |
---|
| 288 | else |
---|
| 289 | call readspecies(specnum_rel(i),i) |
---|
| 290 | endif |
---|
[e200b7a] | 291 | |
---|
[5184a7c] | 292 | ! For backward runs, only 1 species is allowed |
---|
| 293 | !********************************************* |
---|
[e200b7a] | 294 | |
---|
[5184a7c] | 295 | !if ((ldirect.lt.0).and.(nspec.gt.1)) then |
---|
| 296 | !write(*,*) '#####################################################' |
---|
| 297 | !write(*,*) '#### FLEXPART MODEL SUBROUTINE READRELEASES: ####' |
---|
| 298 | !write(*,*) '#### FOR BACKWARD RUNS, ONLY 1 SPECIES IS ALLOWED####' |
---|
| 299 | !write(*,*) '#####################################################' |
---|
| 300 | ! stop |
---|
| 301 | !endif |
---|
[e200b7a] | 302 | |
---|
[5184a7c] | 303 | ! Molecular weight |
---|
| 304 | !***************** |
---|
[e200b7a] | 305 | |
---|
[b4d29ce] | 306 | if (((iout.eq.2).or.(iout.eq.3)).and.(weightmolar(i).lt.0.)) then |
---|
[e200b7a] | 307 | write(*,*) 'For mixing ratio output, valid molar weight' |
---|
| 308 | write(*,*) 'must be specified for all simulated species.' |
---|
| 309 | write(*,*) 'Check table SPECIES or choose concentration' |
---|
| 310 | write(*,*) 'output instead if molar weight is not known.' |
---|
| 311 | stop |
---|
| 312 | endif |
---|
| 313 | |
---|
[5184a7c] | 314 | ! Radioactive decay |
---|
| 315 | !****************** |
---|
[e200b7a] | 316 | |
---|
| 317 | decay(i)=0.693147/decay(i) !conversion half life to decay constant |
---|
| 318 | |
---|
| 319 | |
---|
[5184a7c] | 320 | ! Dry deposition of gases |
---|
| 321 | !************************ |
---|
[e200b7a] | 322 | |
---|
[b4d29ce] | 323 | if (reldiff(i).gt.0.) rm(i)=1./(henry(i)/3000.+100.*f0(i)) ! mesophyll resistance |
---|
[e200b7a] | 324 | |
---|
[5184a7c] | 325 | ! Dry deposition of particles |
---|
| 326 | !**************************** |
---|
[e200b7a] | 327 | |
---|
| 328 | vsetaver(i)=0. |
---|
| 329 | cunningham(i)=0. |
---|
| 330 | dquer(i)=dquer(i)*1000000. ! Conversion m to um |
---|
[b4d29ce] | 331 | if (density(i).gt.0.) then ! Additional parameters |
---|
| 332 | call part0(dquer(i),dsigma(i),density(i),fracth,schmih,cun,vsh) |
---|
[e200b7a] | 333 | do j=1,ni |
---|
| 334 | fract(i,j)=fracth(j) |
---|
| 335 | schmi(i,j)=schmih(j) |
---|
| 336 | vset(i,j)=vsh(j) |
---|
| 337 | cunningham(i)=cunningham(i)+cun*fract(i,j) |
---|
| 338 | vsetaver(i)=vsetaver(i)-vset(i,j)*fract(i,j) |
---|
| 339 | end do |
---|
[8a65cb0] | 340 | if (lroot) write(*,*) 'Average settling velocity: ',i,vsetaver(i) |
---|
[e200b7a] | 341 | endif |
---|
| 342 | |
---|
[5184a7c] | 343 | ! Dry deposition for constant deposition velocity |
---|
| 344 | !************************************************ |
---|
[e200b7a] | 345 | |
---|
| 346 | dryvel(i)=dryvel(i)*0.01 ! conversion to m/s |
---|
| 347 | |
---|
[8a65cb0] | 348 | ! Check if wet deposition or OH reaction shall be calculated |
---|
| 349 | !*********************************************************** |
---|
[05cf28d] | 350 | |
---|
| 351 | ! ESO 04.2016 check for below-cloud scavenging (gas or aerosol) |
---|
| 352 | if ((dquer(i).le.0..and.(weta_gas(i).gt.0. .or. wetb_gas(i).gt.0.)) .or. & |
---|
| 353 | &(dquer(i).gt.0. .and. (crain_aero(i) .gt. 0. .or. csnow_aero(i).gt.0.))) then |
---|
[e200b7a] | 354 | WETDEP=.true. |
---|
[c8fc724] | 355 | WETDEPSPEC(i)=.true. |
---|
[8a65cb0] | 356 | if (lroot) then |
---|
[05cf28d] | 357 | write (*,*) ' Below-cloud scavenging: ON' |
---|
[5184a7c] | 358 | ! write (*,*) 'Below-cloud scavenging coefficients: ',weta(i),i |
---|
[8a65cb0] | 359 | end if |
---|
[4fbe7a5] | 360 | else |
---|
[05cf28d] | 361 | if (lroot) write (*,*) ' Below-cloud scavenging: OFF' |
---|
[e200b7a] | 362 | endif |
---|
[5184a7c] | 363 | |
---|
| 364 | ! NIK 31.01.2013 + 10.12.2013 + 15.02.2015 |
---|
[05cf28d] | 365 | if (dquer(i).gt.0..and.(ccn_aero(i).gt.0. .or. in_aero(i).gt.0.)) then |
---|
[4fbe7a5] | 366 | WETDEP=.true. |
---|
[c8fc724] | 367 | WETDEPSPEC(i)=.true. |
---|
[8a65cb0] | 368 | if (lroot) then |
---|
[05cf28d] | 369 | write (*,*) ' In-cloud scavenging: ON' |
---|
[5184a7c] | 370 | ! write (*,*) 'In-cloud scavenging coefficients: ',& |
---|
| 371 | ! &ccn_aero(i),in_aero(i),i !,wetc_in(i), wetd_in(i),i |
---|
[8a65cb0] | 372 | end if |
---|
| 373 | else |
---|
[05cf28d] | 374 | if (lroot) write (*,*) ' In-cloud scavenging: OFF' |
---|
[4fbe7a5] | 375 | endif |
---|
| 376 | |
---|
[8a65cb0] | 377 | if (ohcconst(i).gt.0.) then |
---|
[e200b7a] | 378 | OHREA=.true. |
---|
[05cf28d] | 379 | if (lroot) write (*,*) ' OHreaction switched on: ',ohcconst(i),i |
---|
[e200b7a] | 380 | endif |
---|
| 381 | |
---|
[b4d29ce] | 382 | if ((reldiff(i).gt.0.).or.(density(i).gt.0.).or.(dryvel(i).gt.0.)) then |
---|
[e200b7a] | 383 | DRYDEP=.true. |
---|
| 384 | DRYDEPSPEC(i)=.true. |
---|
| 385 | endif |
---|
| 386 | |
---|
[c8fc724] | 387 | end do ! end loop over species |
---|
[e200b7a] | 388 | |
---|
[b4d29ce] | 389 | if (WETDEP.or.DRYDEP) DEP=.true. |
---|
[e200b7a] | 390 | |
---|
| 391 | ! Read specifications for each release point |
---|
| 392 | !******************************************* |
---|
[b4d29ce] | 393 | numpoints=numpoint |
---|
[e200b7a] | 394 | numpoint=0 |
---|
| 395 | numpartmax=0 |
---|
| 396 | releaserate=0. |
---|
[5184a7c] | 397 | 101 numpoint=numpoint+1 |
---|
[b4d29ce] | 398 | |
---|
| 399 | if (readerror.lt.1) then ! reading namelist format |
---|
| 400 | |
---|
| 401 | if (numpoint.gt.numpoints) goto 250 |
---|
| 402 | zkind = 1 |
---|
| 403 | mass = 0 |
---|
| 404 | parts = 0 |
---|
| 405 | comment = ' ' |
---|
| 406 | read(unitreleases,release,iostat=readerror) |
---|
| 407 | id1=idate1 |
---|
| 408 | it1=itime1 |
---|
| 409 | id2=idate2 |
---|
| 410 | it2=itime2 |
---|
| 411 | xpoint1(numpoint)=lon1 |
---|
| 412 | xpoint2(numpoint)=lon2 |
---|
| 413 | ypoint1(numpoint)=lat1 |
---|
| 414 | ypoint2(numpoint)=lat2 |
---|
| 415 | zpoint1(numpoint)=z1 |
---|
| 416 | zpoint2(numpoint)=z2 |
---|
| 417 | kindz(numpoint)=zkind |
---|
| 418 | do i=1,nspec |
---|
| 419 | xmass(numpoint,i)=mass(i) |
---|
| 420 | end do |
---|
| 421 | npart(numpoint)=parts |
---|
| 422 | compoint(min(1001,numpoint))=comment |
---|
| 423 | |
---|
[5184a7c] | 424 | ! namelist output |
---|
[8a65cb0] | 425 | if (nmlout.and.lroot) then |
---|
[b4d29ce] | 426 | write(unitreleasesout,nml=release) |
---|
| 427 | endif |
---|
| 428 | |
---|
[e200b7a] | 429 | else |
---|
| 430 | |
---|
[b4d29ce] | 431 | read(unitreleases,*,end=250) |
---|
| 432 | read(unitreleases,*,err=998,end=250) id1,it1 |
---|
| 433 | if (old) call skplin(2,unitreleases) |
---|
| 434 | read(unitreleases,*,err=998) id2,it2 |
---|
| 435 | if (old) call skplin(2,unitreleases) |
---|
| 436 | read(unitreleases,*,err=998) xpoint1(numpoint) |
---|
| 437 | if (old) call skplin(2,unitreleases) |
---|
| 438 | read(unitreleases,*,err=998) ypoint1(numpoint) |
---|
| 439 | if (old) call skplin(2,unitreleases) |
---|
| 440 | read(unitreleases,*,err=998) xpoint2(numpoint) |
---|
| 441 | if (old) call skplin(2,unitreleases) |
---|
| 442 | read(unitreleases,*,err=998) ypoint2(numpoint) |
---|
| 443 | if (old) call skplin(2,unitreleases) |
---|
| 444 | read(unitreleases,*,err=998) kindz(numpoint) |
---|
| 445 | if (old) call skplin(2,unitreleases) |
---|
| 446 | read(unitreleases,*,err=998) zpoint1(numpoint) |
---|
| 447 | if (old) call skplin(2,unitreleases) |
---|
| 448 | read(unitreleases,*,err=998) zpoint2(numpoint) |
---|
| 449 | if (old) call skplin(2,unitreleases) |
---|
| 450 | read(unitreleases,*,err=998) npart(numpoint) |
---|
| 451 | if (old) call skplin(2,unitreleases) |
---|
| 452 | do i=1,nspec |
---|
| 453 | read(unitreleases,*,err=998) xmass(numpoint,i) |
---|
| 454 | if (old) call skplin(2,unitreleases) |
---|
| 455 | mass(i)=xmass(numpoint,i) |
---|
| 456 | end do |
---|
[5184a7c] | 457 | !save compoint only for the first 1000 release points |
---|
[b4d29ce] | 458 | if (numpoint.le.1000) then |
---|
| 459 | read(unitreleases,'(a40)',err=998) compoint(numpoint)(1:40) |
---|
| 460 | comment=compoint(numpoint)(1:40) |
---|
| 461 | else |
---|
| 462 | read(unitreleases,'(a40)',err=998) compoint(1001)(1:40) |
---|
| 463 | comment=compoint(1001)(1:40) |
---|
| 464 | endif |
---|
| 465 | if (old) call skplin(1,unitreleases) |
---|
| 466 | |
---|
[5184a7c] | 467 | ! namelist output |
---|
[8a65cb0] | 468 | if (nmlout.and.lroot) then |
---|
[b4d29ce] | 469 | idate1=id1 |
---|
| 470 | itime1=it1 |
---|
| 471 | idate2=id2 |
---|
| 472 | itime2=it2 |
---|
| 473 | lon1=xpoint1(numpoint) |
---|
| 474 | lon2=xpoint2(numpoint) |
---|
| 475 | lat1=ypoint1(numpoint) |
---|
| 476 | lat2=ypoint2(numpoint) |
---|
| 477 | z1=zpoint1(numpoint) |
---|
| 478 | z2=zpoint2(numpoint) |
---|
| 479 | zkind=kindz(numpoint) |
---|
| 480 | parts=npart(numpoint) |
---|
| 481 | write(unitreleasesout,nml=release) |
---|
| 482 | endif |
---|
| 483 | |
---|
| 484 | if (numpoint.le.1000) then |
---|
| 485 | if((xpoint1(numpoint).eq.0.).and.(ypoint1(numpoint).eq.0.).and. & |
---|
| 486 | (xpoint2(numpoint).eq.0.).and.(ypoint2(numpoint).eq.0.).and. & |
---|
| 487 | (compoint(numpoint)(1:8).eq.' ')) goto 250 |
---|
| 488 | else |
---|
| 489 | if((xpoint1(numpoint).eq.0.).and.(ypoint1(numpoint).eq.0.).and. & |
---|
| 490 | (xpoint2(numpoint).eq.0.).and.(ypoint2(numpoint).eq.0.)) goto 250 |
---|
| 491 | endif |
---|
| 492 | |
---|
| 493 | endif ! if namelist format |
---|
[e200b7a] | 494 | |
---|
| 495 | ! If a release point contains no particles, stop and issue error message |
---|
| 496 | !*********************************************************************** |
---|
| 497 | |
---|
| 498 | if (npart(numpoint).eq.0) then |
---|
| 499 | write(*,*) 'FLEXPART MODEL ERROR' |
---|
| 500 | write(*,*) 'RELEASES file is corrupt.' |
---|
| 501 | write(*,*) 'At least for one release point, there are zero' |
---|
| 502 | write(*,*) 'particles released. Make changes to RELEASES.' |
---|
| 503 | stop |
---|
| 504 | endif |
---|
| 505 | |
---|
[8ee24a5] | 506 | ! If FLEXPART is run for backward deposition force zpoint |
---|
| 507 | !********************************************************************* |
---|
| 508 | if (WETBKDEP) then |
---|
[5184a7c] | 509 | zpoint1(numpoint)=0. |
---|
| 510 | zpoint2(numpoint)=20000. |
---|
| 511 | kindz(numpoint)=1 |
---|
[8ee24a5] | 512 | endif |
---|
| 513 | if (DRYBKDEP) then |
---|
[5184a7c] | 514 | zpoint1(numpoint)=0. |
---|
| 515 | zpoint2(numpoint)=2.*href |
---|
| 516 | kindz(numpoint)=1 |
---|
[8ee24a5] | 517 | endif |
---|
| 518 | |
---|
| 519 | |
---|
[e200b7a] | 520 | ! Check whether x coordinates of release point are within model domain |
---|
| 521 | !********************************************************************* |
---|
| 522 | |
---|
[5184a7c] | 523 | if (xpoint1(numpoint).lt.xlon0) & |
---|
| 524 | xpoint1(numpoint)=xpoint1(numpoint)+360. |
---|
| 525 | if (xpoint1(numpoint).gt.xlon0+(nxmin1)*dx) & |
---|
| 526 | xpoint1(numpoint)=xpoint1(numpoint)-360. |
---|
| 527 | if (xpoint2(numpoint).lt.xlon0) & |
---|
| 528 | xpoint2(numpoint)=xpoint2(numpoint)+360. |
---|
| 529 | if (xpoint2(numpoint).gt.xlon0+(nxmin1)*dx) & |
---|
| 530 | xpoint2(numpoint)=xpoint2(numpoint)-360. |
---|
[e200b7a] | 531 | |
---|
| 532 | ! Determine relative beginning and ending times of particle release |
---|
| 533 | !****************************************************************** |
---|
| 534 | |
---|
| 535 | jul1=juldate(id1,it1) |
---|
| 536 | jul2=juldate(id2,it2) |
---|
[f13406c] | 537 | julm=(jul1+jul2)/2. |
---|
[e200b7a] | 538 | if (jul1.gt.jul2) then |
---|
| 539 | write(*,*) 'FLEXPART MODEL ERROR' |
---|
| 540 | write(*,*) 'Release stops before it begins.' |
---|
| 541 | write(*,*) 'Make changes to file RELEASES.' |
---|
| 542 | stop |
---|
| 543 | endif |
---|
| 544 | if (mdomainfill.eq.0) then ! no domain filling |
---|
| 545 | if (ldirect.eq.1) then |
---|
| 546 | if ((jul1.lt.bdate).or.(jul2.gt.edate)) then |
---|
| 547 | write(*,*) 'FLEXPART MODEL ERROR' |
---|
| 548 | write(*,*) 'Release starts before simulation begins or ends' |
---|
| 549 | write(*,*) 'after simulation stops.' |
---|
| 550 | write(*,*) 'Make files COMMAND and RELEASES consistent.' |
---|
| 551 | stop |
---|
| 552 | endif |
---|
[f13406c] | 553 | if (npart(numpoint).gt.num_min_discrete) then |
---|
| 554 | ireleasestart(numpoint)=int((jul1-bdate)*86400.) |
---|
| 555 | ireleaseend(numpoint)=int((jul2-bdate)*86400.) |
---|
| 556 | else |
---|
| 557 | ireleasestart(numpoint)=int((julm-bdate)*86400.) |
---|
| 558 | ireleaseend(numpoint)=int((julm-bdate)*86400.) |
---|
| 559 | endif |
---|
[e200b7a] | 560 | else if (ldirect.eq.-1) then |
---|
| 561 | if ((jul1.lt.edate).or.(jul2.gt.bdate)) then |
---|
| 562 | write(*,*) 'FLEXPART MODEL ERROR' |
---|
| 563 | write(*,*) 'Release starts before simulation begins or ends' |
---|
| 564 | write(*,*) 'after simulation stops.' |
---|
| 565 | write(*,*) 'Make files COMMAND and RELEASES consistent.' |
---|
| 566 | stop |
---|
| 567 | endif |
---|
[f13406c] | 568 | if (npart(numpoint).gt.num_min_discrete) then |
---|
| 569 | ireleasestart(numpoint)=int((jul1-bdate)*86400.) |
---|
| 570 | ireleaseend(numpoint)=int((jul2-bdate)*86400.) |
---|
| 571 | else |
---|
| 572 | ireleasestart(numpoint)=int((julm-bdate)*86400.) |
---|
| 573 | ireleaseend(numpoint)=int((julm-bdate)*86400.) |
---|
| 574 | endif |
---|
[e200b7a] | 575 | endif |
---|
| 576 | endif |
---|
| 577 | |
---|
[4c64400] | 578 | |
---|
[e200b7a] | 579 | ! Determine the release rate (particles per second) and total number |
---|
| 580 | ! of particles released during the simulation |
---|
| 581 | !******************************************************************* |
---|
| 582 | |
---|
| 583 | if (ireleasestart(numpoint).ne.ireleaseend(numpoint)) then |
---|
| 584 | releaserate=releaserate+real(npart(numpoint))/ & |
---|
| 585 | real(ireleaseend(numpoint)-ireleasestart(numpoint)) |
---|
| 586 | else |
---|
| 587 | releaserate=99999999 |
---|
| 588 | endif |
---|
| 589 | numpartmax=numpartmax+npart(numpoint) |
---|
[b4d29ce] | 590 | goto 101 |
---|
[e200b7a] | 591 | |
---|
[5184a7c] | 592 | 250 close(unitreleases) |
---|
[e200b7a] | 593 | |
---|
[8a65cb0] | 594 | if (nmlout.and.lroot) then |
---|
[b4d29ce] | 595 | close(unitreleasesout) |
---|
| 596 | endif |
---|
| 597 | |
---|
[8a65cb0] | 598 | if (lroot) write (*,*) 'Particles allocated (maxpart) : ',maxpart |
---|
| 599 | if (lroot) write (*,*) 'Particles released (numpartmax): ',numpartmax |
---|
[e200b7a] | 600 | numpoint=numpoint-1 |
---|
| 601 | |
---|
| 602 | if (ioutputforeachrelease.eq.1) then |
---|
| 603 | maxpointspec_act=numpoint |
---|
| 604 | else |
---|
| 605 | maxpointspec_act=1 |
---|
| 606 | endif |
---|
| 607 | |
---|
[5184a7c] | 608 | ! Disable settling if more than 1 species at any release point |
---|
| 609 | ! or if MQUASILAG and more than one species |
---|
| 610 | !************************************************************* |
---|
| 611 | |
---|
| 612 | if (mquasilag.ne.0) then |
---|
| 613 | if (nspec.gt.1) lsettling=.false. |
---|
| 614 | else |
---|
| 615 | do irel=1,numpoint |
---|
| 616 | nsettle=0 |
---|
| 617 | do ispc=1,nspec |
---|
| 618 | if (xmass(irel,ispc).gt.eps2) nsettle=nsettle+1 |
---|
| 619 | end do |
---|
| 620 | if (nsettle.gt.1) lsettling=.false. |
---|
| 621 | end do |
---|
| 622 | end if |
---|
| 623 | |
---|
| 624 | if (lroot) then |
---|
| 625 | if (.not.lsettling) then |
---|
| 626 | write(*,*) 'WARNING: more than 1 species per release point, settling & |
---|
| 627 | &disabled' |
---|
| 628 | end if |
---|
| 629 | end if |
---|
| 630 | |
---|
[b4d29ce] | 631 | ! Check, whether the total number of particles may exceed totally allowed |
---|
| 632 | ! number of particles at some time during the simulation |
---|
| 633 | !************************************************************************ |
---|
| 634 | |
---|
[e200b7a] | 635 | if (releaserate.gt. & |
---|
| 636 | 0.99*real(maxpart)/real(lage(nageclass))) then |
---|
[8a65cb0] | 637 | if (numpartmax.gt.maxpart.and.lroot) then |
---|
[5184a7c] | 638 | write(*,*) '#####################################################' |
---|
| 639 | write(*,*) '#### FLEXPART MODEL SUBROUTINE READRELEASES: ####' |
---|
| 640 | write(*,*) '#### ####' |
---|
| 641 | write(*,*) '####WARNING - TOTAL NUMBER OF PARTICLES SPECIFIED####' |
---|
| 642 | write(*,*) '#### IN FILE "RELEASES" MAY AT SOME POINT DURING ####' |
---|
| 643 | write(*,*) '#### THE SIMULATION EXCEED THE MAXIMUM ALLOWED ####' |
---|
| 644 | write(*,*) '#### NUMBER (MAXPART).IF RELEASES DO NOT OVERLAP,####' |
---|
| 645 | write(*,*) '#### FLEXPART CAN POSSIBLY COMPLETE SUCCESSFULLY.####' |
---|
| 646 | write(*,*) '#### HOWEVER, FLEXPART MAY HAVE TO STOP ####' |
---|
| 647 | write(*,*) '#### AT SOME TIME DURING THE SIMULATION. PLEASE ####' |
---|
| 648 | write(*,*) '#### MAKE SURE THAT YOUR SETTINGS ARE CORRECT. ####' |
---|
| 649 | write(*,*) '#####################################################' |
---|
[e200b7a] | 650 | write(*,*) 'Maximum release rate may be: ',releaserate, & |
---|
| 651 | ' particles per second' |
---|
| 652 | write(*,*) 'Maximum allowed release rate is: ', & |
---|
| 653 | real(maxpart)/real(lage(nageclass)),' particles per second' |
---|
| 654 | write(*,*) & |
---|
| 655 | 'Total number of particles released during the simulation is: ', & |
---|
| 656 | numpartmax |
---|
| 657 | write(*,*) 'Maximum allowed number of particles is: ',maxpart |
---|
| 658 | endif |
---|
| 659 | endif |
---|
| 660 | |
---|
[5184a7c] | 661 | |
---|
[4c64400] | 662 | if (lroot) then |
---|
| 663 | write(*,FMT='(A,ES14.7)') ' Total mass released:', sum(xmass(1:numpoint,1:nspec)) |
---|
| 664 | end if |
---|
| 665 | |
---|
[e200b7a] | 666 | return |
---|
| 667 | |
---|
[5184a7c] | 668 | 994 write(*,*) '#####################################################' |
---|
[e200b7a] | 669 | write(*,*) '#### FLEXPART MODEL SUBROUTINE READRELEASES: ####' |
---|
| 670 | write(*,*) '#### ####' |
---|
| 671 | write(*,*) '#### ERROR - MAXIMUM NUMBER OF EMITTED SPECIES IS####' |
---|
| 672 | write(*,*) '#### TOO LARGE. PLEASE REDUCE NUMBER OF SPECIES. ####' |
---|
| 673 | write(*,*) '#####################################################' |
---|
| 674 | stop |
---|
| 675 | |
---|
[5184a7c] | 676 | 998 write(*,*) '#####################################################' |
---|
[e200b7a] | 677 | write(*,*) '#### FLEXPART MODEL SUBROUTINE READRELEASES: ####' |
---|
| 678 | write(*,*) '#### ####' |
---|
| 679 | write(*,*) '#### FATAL ERROR - FILE "RELEASES" IS ####' |
---|
| 680 | write(*,*) '#### CORRUPT. PLEASE CHECK YOUR INPUTS FOR ####' |
---|
| 681 | write(*,*) '#### MISTAKES OR GET A NEW "RELEASES"- ####' |
---|
| 682 | write(*,*) '#### FILE ... ####' |
---|
| 683 | write(*,*) '#####################################################' |
---|
| 684 | stop |
---|
| 685 | |
---|
| 686 | |
---|
[5184a7c] | 687 | 999 write(*,*) '#####################################################' |
---|
[e200b7a] | 688 | write(*,*) ' FLEXPART MODEL SUBROUTINE READRELEASES: ' |
---|
| 689 | write(*,*) |
---|
| 690 | write(*,*) 'FATAL ERROR - FILE CONTAINING PARTICLE RELEASE POINTS' |
---|
| 691 | write(*,*) 'POINTS IS NOT AVAILABLE OR YOU ARE NOT' |
---|
| 692 | write(*,*) 'PERMITTED FOR ANY ACCESS' |
---|
| 693 | write(*,*) '#####################################################' |
---|
| 694 | stop |
---|
| 695 | |
---|
[b4d29ce] | 696 | 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RELEASES" #### ' |
---|
| 697 | write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' |
---|
| 698 | write(*,'(a)') path(2)(1:length(2)) |
---|
| 699 | stop |
---|
| 700 | |
---|
[e200b7a] | 701 | end subroutine readreleases |
---|