[e200b7a] | 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 | |
---|
| 22 | program flexpart |
---|
| 23 | |
---|
| 24 | !***************************************************************************** |
---|
| 25 | ! * |
---|
| 26 | ! This is the Lagrangian Particle Dispersion Model FLEXPART. * |
---|
| 27 | ! The main program manages the reading of model run specifications, etc. * |
---|
| 28 | ! All actual computing is done within subroutine timemanager. * |
---|
| 29 | ! * |
---|
| 30 | ! Author: A. Stohl * |
---|
| 31 | ! * |
---|
| 32 | ! 18 May 1996 * |
---|
| 33 | ! * |
---|
| 34 | !***************************************************************************** |
---|
| 35 | ! * |
---|
| 36 | ! Variables: * |
---|
| 37 | ! * |
---|
| 38 | ! Constants: * |
---|
| 39 | ! * |
---|
| 40 | !***************************************************************************** |
---|
| 41 | |
---|
| 42 | use point_mod |
---|
| 43 | use par_mod |
---|
| 44 | use com_mod |
---|
| 45 | use conv_mod |
---|
| 46 | |
---|
| 47 | implicit none |
---|
| 48 | |
---|
| 49 | integer :: i,j,ix,jy,inest |
---|
| 50 | integer :: idummy = -320 |
---|
[f13406c] | 51 | character(len=256) :: inline_options !pathfile, flexversion, arg2 |
---|
| 52 | |
---|
[e200b7a] | 53 | |
---|
| 54 | ! Generate a large number of random numbers |
---|
| 55 | !****************************************** |
---|
| 56 | |
---|
| 57 | do i=1,maxrand-1,2 |
---|
| 58 | call gasdev1(idummy,rannumb(i),rannumb(i+1)) |
---|
| 59 | end do |
---|
| 60 | call gasdev1(idummy,rannumb(maxrand),rannumb(maxrand-1)) |
---|
| 61 | |
---|
[b4d29ce] | 62 | ! FLEXPART version string |
---|
| 63 | flexversion='Version 9.2 beta (2014-07-01)' |
---|
| 64 | verbosity=0 |
---|
| 65 | |
---|
[f13406c] | 66 | ! Read the pathnames where input/output files are stored |
---|
| 67 | !******************************************************* |
---|
| 68 | |
---|
| 69 | inline_options='none' |
---|
| 70 | select case (iargc()) |
---|
| 71 | case (2) |
---|
| 72 | call getarg(1,arg1) |
---|
| 73 | pathfile=arg1 |
---|
| 74 | call getarg(2,arg2) |
---|
| 75 | inline_options=arg2 |
---|
| 76 | case (1) |
---|
| 77 | call getarg(1,arg1) |
---|
| 78 | pathfile=arg1 |
---|
| 79 | if (arg1(1:1).eq.'-') then |
---|
[b4d29ce] | 80 | write(pathfile,'(a11)') './pathnames' |
---|
| 81 | inline_options=arg1 |
---|
[f13406c] | 82 | endif |
---|
| 83 | case (0) |
---|
| 84 | write(pathfile,'(a11)') './pathnames' |
---|
| 85 | end select |
---|
| 86 | |
---|
[e200b7a] | 87 | ! Print the GPL License statement |
---|
| 88 | !******************************************************* |
---|
[4fbe7a5] | 89 | print*,'Welcome to FLEXPART ', trim(flexversion) |
---|
[b4d29ce] | 90 | print*,'FLEXPART is free software released under the GNU General Public License.' |
---|
| 91 | |
---|
| 92 | if (inline_options(1:1).eq.'-') then |
---|
| 93 | if (trim(inline_options).eq.'-v'.or.trim(inline_options).eq.'-v1') then |
---|
| 94 | print*, 'Verbose mode 1: display detailed information during run' |
---|
| 95 | verbosity=1 |
---|
| 96 | endif |
---|
| 97 | if (trim(inline_options).eq.'-v2') then |
---|
| 98 | print*, 'Verbose mode 2: display more detailed information during run' |
---|
| 99 | verbosity=2 |
---|
| 100 | endif |
---|
| 101 | if (trim(inline_options).eq.'-i') then |
---|
| 102 | print*, 'Info mode: provide detailed run specific information and stop' |
---|
| 103 | verbosity=1 |
---|
| 104 | info_flag=1 |
---|
| 105 | endif |
---|
| 106 | if (trim(inline_options).eq.'-i2') then |
---|
| 107 | print*, 'Info mode: provide more detailed run specific information and stop' |
---|
| 108 | verbosity=2 |
---|
| 109 | info_flag=1 |
---|
| 110 | endif |
---|
| 111 | endif |
---|
| 112 | |
---|
[f13406c] | 113 | if (verbosity.gt.0) then |
---|
[b4d29ce] | 114 | write(*,*) 'call readpaths' |
---|
[f13406c] | 115 | endif |
---|
| 116 | call readpaths(pathfile) |
---|
| 117 | |
---|
| 118 | if (verbosity.gt.1) then !show clock info |
---|
| 119 | !print*,'length(4)',length(4) |
---|
| 120 | !count=0,count_rate=1000 |
---|
| 121 | CALL SYSTEM_CLOCK(count_clock0, count_rate, count_max) |
---|
| 122 | !WRITE(*,*) 'SYSTEM_CLOCK',count, count_rate, count_max |
---|
| 123 | !WRITE(*,*) 'SYSTEM_CLOCK, count_clock0', count_clock0 |
---|
| 124 | !WRITE(*,*) 'SYSTEM_CLOCK, count_rate', count_rate |
---|
| 125 | !WRITE(*,*) 'SYSTEM_CLOCK, count_max', count_max |
---|
| 126 | endif |
---|
[e200b7a] | 127 | |
---|
| 128 | ! Read the user specifications for the current model run |
---|
| 129 | !******************************************************* |
---|
| 130 | |
---|
[f13406c] | 131 | if (verbosity.gt.0) then |
---|
[b4d29ce] | 132 | write(*,*) 'call readcommand' |
---|
[f13406c] | 133 | endif |
---|
[e200b7a] | 134 | call readcommand |
---|
[f13406c] | 135 | if (verbosity.gt.0) then |
---|
[b4d29ce] | 136 | write(*,*) ' ldirect=', ldirect |
---|
| 137 | write(*,*) ' ibdate,ibtime=',ibdate,ibtime |
---|
| 138 | write(*,*) ' iedate,ietime=', iedate,ietime |
---|
| 139 | if (verbosity.gt.1) then |
---|
| 140 | CALL SYSTEM_CLOCK(count_clock, count_rate, count_max) |
---|
| 141 | write(*,*) 'SYSTEM_CLOCK',(count_clock - count_clock0)/real(count_rate) !, count_rate, count_max |
---|
| 142 | endif |
---|
[f13406c] | 143 | endif |
---|
[e200b7a] | 144 | |
---|
| 145 | ! Read the age classes to be used |
---|
| 146 | !******************************** |
---|
[f13406c] | 147 | if (verbosity.gt.0) then |
---|
[b4d29ce] | 148 | write(*,*) 'call readageclasses' |
---|
[f13406c] | 149 | endif |
---|
[e200b7a] | 150 | call readageclasses |
---|
| 151 | |
---|
[f13406c] | 152 | if (verbosity.gt.1) then |
---|
[b4d29ce] | 153 | CALL SYSTEM_CLOCK(count_clock, count_rate, count_max) |
---|
| 154 | write(*,*) 'SYSTEM_CLOCK',(count_clock - count_clock0)/real(count_rate) !, count_rate, count_max |
---|
[f13406c] | 155 | endif |
---|
[e200b7a] | 156 | |
---|
| 157 | ! Read, which wind fields are available within the modelling period |
---|
| 158 | !****************************************************************** |
---|
| 159 | |
---|
[f13406c] | 160 | if (verbosity.gt.0) then |
---|
[b4d29ce] | 161 | write(*,*) 'call readavailable' |
---|
[f13406c] | 162 | endif |
---|
[e200b7a] | 163 | call readavailable |
---|
| 164 | |
---|
| 165 | ! Read the model grid specifications, |
---|
| 166 | ! both for the mother domain and eventual nests |
---|
| 167 | !********************************************** |
---|
[f13406c] | 168 | |
---|
| 169 | if (verbosity.gt.0) then |
---|
[b4d29ce] | 170 | write(*,*) 'call gridcheck' |
---|
[f13406c] | 171 | endif |
---|
[e200b7a] | 172 | |
---|
| 173 | call gridcheck |
---|
[f13406c] | 174 | |
---|
| 175 | if (verbosity.gt.1) then |
---|
[b4d29ce] | 176 | CALL SYSTEM_CLOCK(count_clock, count_rate, count_max) |
---|
| 177 | write(*,*) 'SYSTEM_CLOCK',(count_clock - count_clock0)/real(count_rate) !, count_rate, count_max |
---|
[f13406c] | 178 | endif |
---|
| 179 | |
---|
| 180 | if (verbosity.gt.0) then |
---|
[b4d29ce] | 181 | write(*,*) 'call gridcheck_nests' |
---|
[f13406c] | 182 | endif |
---|
[e200b7a] | 183 | call gridcheck_nests |
---|
| 184 | |
---|
| 185 | ! Read the output grid specifications |
---|
| 186 | !************************************ |
---|
| 187 | |
---|
[f13406c] | 188 | if (verbosity.gt.0) then |
---|
[b4d29ce] | 189 | write(*,*) 'call readoutgrid' |
---|
[f13406c] | 190 | endif |
---|
| 191 | |
---|
[e200b7a] | 192 | call readoutgrid |
---|
| 193 | |
---|
[f13406c] | 194 | if (nested_output.eq.1) then |
---|
[b4d29ce] | 195 | call readoutgrid_nest |
---|
[f13406c] | 196 | if (verbosity.gt.0) then |
---|
[b4d29ce] | 197 | write(*,*) '# readoutgrid_nest' |
---|
[f13406c] | 198 | endif |
---|
| 199 | endif |
---|
[e200b7a] | 200 | |
---|
| 201 | ! Read the receptor points for which extra concentrations are to be calculated |
---|
| 202 | !***************************************************************************** |
---|
| 203 | |
---|
[f13406c] | 204 | if (verbosity.eq.1) then |
---|
| 205 | print*,'call readreceptors' |
---|
| 206 | endif |
---|
[e200b7a] | 207 | call readreceptors |
---|
| 208 | |
---|
| 209 | ! Read the physico-chemical species property table |
---|
| 210 | !************************************************* |
---|
| 211 | !SEC: now only needed SPECIES are read in readreleases.f |
---|
| 212 | !call readspecies |
---|
| 213 | |
---|
| 214 | |
---|
| 215 | ! Read the landuse inventory |
---|
| 216 | !*************************** |
---|
| 217 | |
---|
[f13406c] | 218 | if (verbosity.gt.0) then |
---|
| 219 | print*,'call readlanduse' |
---|
| 220 | endif |
---|
[e200b7a] | 221 | call readlanduse |
---|
| 222 | |
---|
| 223 | ! Assign fractional cover of landuse classes to each ECMWF grid point |
---|
| 224 | !******************************************************************** |
---|
| 225 | |
---|
[f13406c] | 226 | if (verbosity.gt.0) then |
---|
| 227 | print*,'call assignland' |
---|
| 228 | endif |
---|
[e200b7a] | 229 | call assignland |
---|
| 230 | |
---|
| 231 | ! Read the coordinates of the release locations |
---|
| 232 | !********************************************** |
---|
| 233 | |
---|
[f13406c] | 234 | if (verbosity.gt.0) then |
---|
| 235 | print*,'call readreleases' |
---|
| 236 | endif |
---|
[e200b7a] | 237 | call readreleases |
---|
| 238 | |
---|
| 239 | ! Read and compute surface resistances to dry deposition of gases |
---|
| 240 | !**************************************************************** |
---|
| 241 | |
---|
[f13406c] | 242 | if (verbosity.gt.0) then |
---|
| 243 | print*,'call readdepo' |
---|
| 244 | endif |
---|
[e200b7a] | 245 | call readdepo |
---|
| 246 | |
---|
| 247 | ! Convert the release point coordinates from geografical to grid coordinates |
---|
| 248 | !*************************************************************************** |
---|
| 249 | |
---|
[f13406c] | 250 | call coordtrafo |
---|
| 251 | if (verbosity.gt.0) then |
---|
| 252 | print*,'call coordtrafo' |
---|
| 253 | endif |
---|
[e200b7a] | 254 | |
---|
| 255 | ! Initialize all particles to non-existent |
---|
| 256 | !***************************************** |
---|
| 257 | |
---|
[f13406c] | 258 | if (verbosity.gt.0) then |
---|
| 259 | print*,'Initialize all particles to non-existent' |
---|
| 260 | endif |
---|
[e200b7a] | 261 | do j=1,maxpart |
---|
| 262 | itra1(j)=-999999999 |
---|
| 263 | end do |
---|
| 264 | |
---|
| 265 | ! For continuation of previous run, read in particle positions |
---|
| 266 | !************************************************************* |
---|
| 267 | |
---|
| 268 | if (ipin.eq.1) then |
---|
[f13406c] | 269 | if (verbosity.gt.0) then |
---|
| 270 | print*,'call readpartpositions' |
---|
| 271 | endif |
---|
[e200b7a] | 272 | call readpartpositions |
---|
| 273 | else |
---|
[f13406c] | 274 | if (verbosity.gt.0) then |
---|
| 275 | print*,'numpart=0, numparticlecount=0' |
---|
| 276 | endif |
---|
[e200b7a] | 277 | numpart=0 |
---|
| 278 | numparticlecount=0 |
---|
| 279 | endif |
---|
| 280 | |
---|
| 281 | ! Calculate volume, surface area, etc., of all output grid cells |
---|
| 282 | ! Allocate fluxes and OHfield if necessary |
---|
| 283 | !*************************************************************** |
---|
| 284 | |
---|
[f13406c] | 285 | if (verbosity.gt.0) then |
---|
| 286 | print*,'call outgrid_init' |
---|
| 287 | endif |
---|
[e200b7a] | 288 | call outgrid_init |
---|
| 289 | if (nested_output.eq.1) call outgrid_init_nest |
---|
| 290 | |
---|
| 291 | ! Read the OH field |
---|
| 292 | !****************** |
---|
| 293 | |
---|
[f13406c] | 294 | if (OHREA.eqv..TRUE.) then |
---|
| 295 | if (verbosity.gt.0) then |
---|
[b4d29ce] | 296 | print*,'call readOHfield' |
---|
[f13406c] | 297 | endif |
---|
[b4d29ce] | 298 | call readOHfield |
---|
[f13406c] | 299 | endif |
---|
[e200b7a] | 300 | |
---|
| 301 | ! Write basic information on the simulation to a file "header" |
---|
| 302 | ! and open files that are to be kept open throughout the simulation |
---|
| 303 | !****************************************************************** |
---|
| 304 | |
---|
[f13406c] | 305 | if (verbosity.gt.0) then |
---|
| 306 | print*,'call writeheader' |
---|
| 307 | endif |
---|
| 308 | |
---|
[e200b7a] | 309 | call writeheader |
---|
[f13406c] | 310 | ! FLEXPART 9.2 ticket ?? write header in ASCII format |
---|
| 311 | call writeheader_txt |
---|
| 312 | !if (nested_output.eq.1) call writeheader_nest |
---|
| 313 | if (nested_output.eq.1.and.surf_only.ne.1) call writeheader_nest |
---|
| 314 | if (nested_output.eq.1.and.surf_only.eq.1) call writeheader_nest_surf |
---|
| 315 | if (nested_output.ne.1.and.surf_only.eq.1) call writeheader_surf |
---|
| 316 | |
---|
| 317 | !open(unitdates,file=path(2)(1:length(2))//'dates') |
---|
| 318 | |
---|
| 319 | if (verbosity.gt.0) then |
---|
| 320 | print*,'call openreceptors' |
---|
| 321 | endif |
---|
[e200b7a] | 322 | call openreceptors |
---|
| 323 | if ((iout.eq.4).or.(iout.eq.5)) call openouttraj |
---|
| 324 | |
---|
| 325 | ! Releases can only start and end at discrete times (multiples of lsynctime) |
---|
| 326 | !*************************************************************************** |
---|
| 327 | |
---|
[f13406c] | 328 | if (verbosity.gt.0) then |
---|
| 329 | print*,'discretize release times' |
---|
| 330 | endif |
---|
[e200b7a] | 331 | do i=1,numpoint |
---|
[b4d29ce] | 332 | ireleasestart(i)=nint(real(ireleasestart(i))/real(lsynctime))*lsynctime |
---|
| 333 | ireleaseend(i)=nint(real(ireleaseend(i))/real(lsynctime))*lsynctime |
---|
[e200b7a] | 334 | end do |
---|
| 335 | |
---|
| 336 | ! Initialize cloud-base mass fluxes for the convection scheme |
---|
| 337 | !************************************************************ |
---|
| 338 | |
---|
[f13406c] | 339 | if (verbosity.gt.0) then |
---|
| 340 | print*,'Initialize cloud-base mass fluxes for the convection scheme' |
---|
| 341 | endif |
---|
| 342 | |
---|
[e200b7a] | 343 | do jy=0,nymin1 |
---|
| 344 | do ix=0,nxmin1 |
---|
| 345 | cbaseflux(ix,jy)=0. |
---|
| 346 | end do |
---|
| 347 | end do |
---|
| 348 | do inest=1,numbnests |
---|
| 349 | do jy=0,nyn(inest)-1 |
---|
| 350 | do ix=0,nxn(inest)-1 |
---|
| 351 | cbasefluxn(ix,jy,inest)=0. |
---|
| 352 | end do |
---|
| 353 | end do |
---|
| 354 | end do |
---|
| 355 | |
---|
| 356 | ! Calculate particle trajectories |
---|
| 357 | !******************************** |
---|
| 358 | |
---|
[f13406c] | 359 | if (verbosity.gt.0) then |
---|
| 360 | if (verbosity.gt.1) then |
---|
| 361 | CALL SYSTEM_CLOCK(count_clock, count_rate, count_max) |
---|
[b4d29ce] | 362 | write(*,*) 'SYSTEM_CLOCK',(count_clock - count_clock0)/real(count_rate) !, count_rate, count_max |
---|
[f13406c] | 363 | endif |
---|
| 364 | if (info_flag.eq.1) then |
---|
[b4d29ce] | 365 | print*, 'info only mode (stop)' |
---|
| 366 | stop |
---|
[f13406c] | 367 | endif |
---|
| 368 | print*,'call timemanager' |
---|
| 369 | endif |
---|
| 370 | |
---|
[e200b7a] | 371 | call timemanager |
---|
| 372 | |
---|
[b4d29ce] | 373 | write(*,*) 'CONGRATULATIONS: YOU HAVE SUCCESSFULLY COMPLETED A FLEXPART MODEL RUN!' |
---|
[e200b7a] | 374 | |
---|
| 375 | end program flexpart |
---|