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