source: flexpart.git/src/FLEXPART.f90 @ 02095e3

10.4.1_peseiGFS_025bugfixes+enhancementsdevrelease-10release-10.4.1scaling-bugunivie
Last change on this file since 02095e3 was fe32dca, checked in by Espen Sollum ATMOS <eso@…>, 7 years ago

Renamed lnokernel, corrected default setting.

  • Property mode set to 100644
File size: 14.6 KB
RevLine 
[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
22program 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  !*****************************************************************************
[6ecb30a]35  ! Changes:                                                                   *
36  !   Unified ECMWF and GFS builds                                             *
37  !   Marian Harustak, 12.5.2017                                               *
38  !     - Added detection of metdata format using gributils routines           *
39  !     - Distinguished calls to ecmwf/gfs gridcheck versions based on         *
40  !       detected metdata format                                              *
41  !     - Passed metdata format down to timemanager                            *
42  !*****************************************************************************
[e200b7a]43  !                                                                            *
44  ! Variables:                                                                 *
45  !                                                                            *
46  ! Constants:                                                                 *
47  !                                                                            *
48  !*****************************************************************************
49
50  use point_mod
51  use par_mod
52  use com_mod
53  use conv_mod
[8a65cb0]54  use netcdf_output_mod, only: writeheader_netcdf
55  use random_mod, only: gasdev1
[6ecb30a]56  use class_gribfile
[e200b7a]57
58  implicit none
59
60  integer :: i,j,ix,jy,inest
61  integer :: idummy = -320
[f13406c]62  character(len=256) :: inline_options  !pathfile, flexversion, arg2
[6ecb30a]63  integer :: metdata_format = GRIBFILE_CENTRE_UNKNOWN
64  integer :: detectformat
65
[8a65cb0]66
67
68  ! Initialize arrays in com_mod
69  !*****************************
[b0434e1]70  call com_mod_allocate_part(maxpart)
71 
[8a65cb0]72
[e200b7a]73  ! Generate a large number of random numbers
74  !******************************************
75
76  do i=1,maxrand-1,2
77    call gasdev1(idummy,rannumb(i),rannumb(i+1))
78  end do
79  call gasdev1(idummy,rannumb(maxrand),rannumb(maxrand-1))
80
[4c64400]81
[b4d29ce]82  ! FLEXPART version string
[fddc6ec]83  flexversion_major = '10' ! Major version number, also used for species file names
[d8eed02]84  flexversion='Version '//trim(flexversion_major)//'.2beta (2017-08-01)'
[8a65cb0]85  verbosity=0
86
[f13406c]87  ! Read the pathnames where input/output files are stored
88  !*******************************************************
89
[8a65cb0]90  inline_options='none'
[f13406c]91  select case (iargc())
[8a65cb0]92  case (2)
[f13406c]93    call getarg(1,arg1)
94    pathfile=arg1
95    call getarg(2,arg2)
96    inline_options=arg2
[8a65cb0]97  case (1)
[f13406c]98    call getarg(1,arg1)
99    pathfile=arg1
100    if (arg1(1:1).eq.'-') then
[b4d29ce]101      write(pathfile,'(a11)') './pathnames'
102      inline_options=arg1
[f13406c]103    endif
[8a65cb0]104  case (0)
[f13406c]105    write(pathfile,'(a11)') './pathnames'
106  end select
107 
[e200b7a]108  ! Print the GPL License statement
109  !*******************************************************
[4fbe7a5]110  print*,'Welcome to FLEXPART ', trim(flexversion)
[b4d29ce]111  print*,'FLEXPART is free software released under the GNU General Public License.'
[414a5e5]112 
[8a65cb0]113  if (inline_options(1:1).eq.'-') then
114    if (trim(inline_options).eq.'-v'.or.trim(inline_options).eq.'-v1') then
115       print*, 'Verbose mode 1: display detailed information during run'
[b4d29ce]116       verbosity=1
[8a65cb0]117    endif
118    if (trim(inline_options).eq.'-v2') then
119       print*, 'Verbose mode 2: display more detailed information during run'
[b4d29ce]120       verbosity=2
121    endif
[8a65cb0]122    if (trim(inline_options).eq.'-i') then
123       print*, 'Info mode: provide detailed run specific information and stop'
[b4d29ce]124       verbosity=1
125       info_flag=1
126    endif
[8a65cb0]127    if (trim(inline_options).eq.'-i2') then
128       print*, 'Info mode: provide more detailed run specific information and stop'
129       verbosity=2
130       info_flag=1
[b4d29ce]131    endif
132  endif
133           
[f13406c]134  if (verbosity.gt.0) then
[b4d29ce]135    write(*,*) 'call readpaths'
[f13406c]136  endif
137  call readpaths(pathfile)
138 
[8a65cb0]139  if (verbosity.gt.1) then !show clock info
140     !print*,'length(4)',length(4)
[f13406c]141     !count=0,count_rate=1000
[8a65cb0]142     CALL SYSTEM_CLOCK(count_clock0, count_rate, count_max)
[f13406c]143     !WRITE(*,*) 'SYSTEM_CLOCK',count, count_rate, count_max
144     !WRITE(*,*) 'SYSTEM_CLOCK, count_clock0', count_clock0
145     !WRITE(*,*) 'SYSTEM_CLOCK, count_rate', count_rate
146     !WRITE(*,*) 'SYSTEM_CLOCK, count_max', count_max
[8a65cb0]147  endif
[e200b7a]148
149  ! Read the user specifications for the current model run
150  !*******************************************************
151
[f13406c]152  if (verbosity.gt.0) then
[8a65cb0]153    write(*,*) 'call readcommand'
[f13406c]154  endif
[e200b7a]155  call readcommand
[f13406c]156  if (verbosity.gt.0) then
[8a65cb0]157    write(*,*) '    ldirect=', ldirect
158    write(*,*) '    ibdate,ibtime=',ibdate,ibtime
[b4d29ce]159    write(*,*) '    iedate,ietime=', iedate,ietime
[8a65cb0]160    if (verbosity.gt.1) then   
[b4d29ce]161      CALL SYSTEM_CLOCK(count_clock, count_rate, count_max)
162      write(*,*) 'SYSTEM_CLOCK',(count_clock - count_clock0)/real(count_rate) !, count_rate, count_max
163    endif     
[8a65cb0]164  endif
[e200b7a]165
166  ! Read the age classes to be used
167  !********************************
[f13406c]168  if (verbosity.gt.0) then
[8a65cb0]169    write(*,*) 'call readageclasses'
[f13406c]170  endif
[e200b7a]171  call readageclasses
172
[8a65cb0]173  if (verbosity.gt.1) then   
[b4d29ce]174    CALL SYSTEM_CLOCK(count_clock, count_rate, count_max)
175    write(*,*) 'SYSTEM_CLOCK',(count_clock - count_clock0)/real(count_rate) !, count_rate, count_max
[f13406c]176  endif     
[e200b7a]177
178  ! Read, which wind fields are available within the modelling period
179  !******************************************************************
180
[f13406c]181  if (verbosity.gt.0) then
[8a65cb0]182    write(*,*) 'call readavailable'
[f13406c]183  endif 
[e200b7a]184  call readavailable
185
[6ecb30a]186  ! Detect metdata format
187  !**********************
188
189  metdata_format = detectformat()
190
191  if (metdata_format.eq.GRIBFILE_CENTRE_ECMWF) then
192    print *,'ECMWF metdata detected'
193  elseif (metdata_format.eq.GRIBFILE_CENTRE_NCEP) then
194    print *,'NCEP metdata detected'
195  else
196    print *,'Unknown metdata format'
197    return
198  endif
199
200
201
[b0434e1]202  ! If nested wind fields are used, allocate arrays
203  !************************************************
204
205  if (verbosity.gt.0) then
206    write(*,*) 'call com_mod_allocate_nests'
207  endif
208  call com_mod_allocate_nests
209
[e200b7a]210  ! Read the model grid specifications,
211  ! both for the mother domain and eventual nests
212  !**********************************************
[f13406c]213 
214  if (verbosity.gt.0) then
[8a65cb0]215     write(*,*) 'call gridcheck'
[f13406c]216  endif
[8a65cb0]217
[6ecb30a]218  if (metdata_format.eq.GRIBFILE_CENTRE_ECMWF) then
219    call gridcheck_ecmwf
220  else
221    call gridcheck_gfs
222  end if
[f13406c]223
[8a65cb0]224  if (verbosity.gt.1) then   
[b4d29ce]225    CALL SYSTEM_CLOCK(count_clock, count_rate, count_max)
226    write(*,*) 'SYSTEM_CLOCK',(count_clock - count_clock0)/real(count_rate) !, count_rate, count_max
[f13406c]227  endif     
228
229  if (verbosity.gt.0) then
[8a65cb0]230    write(*,*) 'call gridcheck_nests'
[f13406c]231  endif 
[e200b7a]232  call gridcheck_nests
233
234  ! Read the output grid specifications
235  !************************************
236
[f13406c]237  if (verbosity.gt.0) then
[8a65cb0]238    write(*,*) 'call readoutgrid'
[f13406c]239  endif
240
[e200b7a]241  call readoutgrid
242
[f13406c]243  if (nested_output.eq.1) then
[b4d29ce]244    call readoutgrid_nest
[f13406c]245    if (verbosity.gt.0) then
[8a65cb0]246      write(*,*) '# readoutgrid_nest'
[f13406c]247    endif
248  endif
[e200b7a]249
250  ! Read the receptor points for which extra concentrations are to be calculated
251  !*****************************************************************************
252
[f13406c]253  if (verbosity.eq.1) then
[8a65cb0]254     print*,'call readreceptors'
[f13406c]255  endif
[e200b7a]256  call readreceptors
257
258  ! Read the physico-chemical species property table
259  !*************************************************
260  !SEC: now only needed SPECIES are read in readreleases.f
261  !call readspecies
262
263
264  ! Read the landuse inventory
265  !***************************
266
[f13406c]267  if (verbosity.gt.0) then
[8a65cb0]268    print*,'call readlanduse'
[f13406c]269  endif
[e200b7a]270  call readlanduse
271
272  ! Assign fractional cover of landuse classes to each ECMWF grid point
273  !********************************************************************
274
[f13406c]275  if (verbosity.gt.0) then
[8a65cb0]276    print*,'call assignland'
[f13406c]277  endif
[e200b7a]278  call assignland
279
280  ! Read the coordinates of the release locations
281  !**********************************************
282
[f13406c]283  if (verbosity.gt.0) then
[8a65cb0]284    print*,'call readreleases'
[f13406c]285  endif
[e200b7a]286  call readreleases
287
288  ! Read and compute surface resistances to dry deposition of gases
289  !****************************************************************
290
[f13406c]291  if (verbosity.gt.0) then
[8a65cb0]292    print*,'call readdepo'
[f13406c]293  endif
[e200b7a]294  call readdepo
295
296  ! Convert the release point coordinates from geografical to grid coordinates
297  !***************************************************************************
298
[f13406c]299  call coordtrafo 
300  if (verbosity.gt.0) then
[8a65cb0]301    print*,'call coordtrafo'
[f13406c]302  endif
[e200b7a]303
304  ! Initialize all particles to non-existent
305  !*****************************************
306
[f13406c]307  if (verbosity.gt.0) then
[8a65cb0]308    print*,'Initialize all particles to non-existent'
[f13406c]309  endif
[e200b7a]310  do j=1,maxpart
311    itra1(j)=-999999999
312  end do
313
314  ! For continuation of previous run, read in particle positions
315  !*************************************************************
316
317  if (ipin.eq.1) then
[f13406c]318    if (verbosity.gt.0) then
[8a65cb0]319      print*,'call readpartpositions'
[f13406c]320    endif
[e200b7a]321    call readpartpositions
322  else
[f13406c]323    if (verbosity.gt.0) then
[8a65cb0]324      print*,'numpart=0, numparticlecount=0'
[f13406c]325    endif   
[e200b7a]326    numpart=0
327    numparticlecount=0
328  endif
329
330  ! Calculate volume, surface area, etc., of all output grid cells
331  ! Allocate fluxes and OHfield if necessary
332  !***************************************************************
333
[f13406c]334  if (verbosity.gt.0) then
[8a65cb0]335    print*,'call outgrid_init'
[f13406c]336  endif
[e200b7a]337  call outgrid_init
338  if (nested_output.eq.1) call outgrid_init_nest
339
340  ! Read the OH field
341  !******************
342
[f13406c]343  if (OHREA.eqv..TRUE.) then
344    if (verbosity.gt.0) then
[8a65cb0]345      print*,'call readOHfield'
[f13406c]346    endif
[b4d29ce]347    call readOHfield
[f13406c]348  endif
[e200b7a]349
350  ! Write basic information on the simulation to a file "header"
351  ! and open files that are to be kept open throughout the simulation
352  !******************************************************************
353
[8a65cb0]354  if (lnetcdfout.eq.1) then
355    call writeheader_netcdf(lnest=.false.)
356  else
357    call writeheader
358  end if
359
360  if (nested_output.eq.1) then
361    if (lnetcdfout.eq.1) then
362      call writeheader_netcdf(lnest=.true.)
363    else
364      call writeheader_nest
365    endif
366  endif
367
[f13406c]368  if (verbosity.gt.0) then
[8a65cb0]369    print*,'call writeheader'
[f13406c]370  endif
371
[e200b7a]372  call writeheader
[8a65cb0]373  ! FLEXPART 9.2 ticket ?? write header in ASCII format
[f13406c]374  call writeheader_txt
375  !if (nested_output.eq.1) call writeheader_nest
376  if (nested_output.eq.1.and.surf_only.ne.1) call writeheader_nest
377  if (nested_output.eq.1.and.surf_only.eq.1) call writeheader_nest_surf
378  if (nested_output.ne.1.and.surf_only.eq.1) call writeheader_surf
379
380  !open(unitdates,file=path(2)(1:length(2))//'dates')
381
382  if (verbosity.gt.0) then
[8a65cb0]383    print*,'call openreceptors'
[f13406c]384  endif
[e200b7a]385  call openreceptors
386  if ((iout.eq.4).or.(iout.eq.5)) call openouttraj
387
388  ! Releases can only start and end at discrete times (multiples of lsynctime)
389  !***************************************************************************
390
[f13406c]391  if (verbosity.gt.0) then
[8a65cb0]392    print*,'discretize release times'
[f13406c]393  endif
[e200b7a]394  do i=1,numpoint
[b4d29ce]395    ireleasestart(i)=nint(real(ireleasestart(i))/real(lsynctime))*lsynctime
396    ireleaseend(i)=nint(real(ireleaseend(i))/real(lsynctime))*lsynctime
[e200b7a]397  end do
398
399  ! Initialize cloud-base mass fluxes for the convection scheme
400  !************************************************************
401
[f13406c]402  if (verbosity.gt.0) then
[8a65cb0]403    print*,'Initialize cloud-base mass fluxes for the convection scheme'
[f13406c]404  endif
405
[e200b7a]406  do jy=0,nymin1
407    do ix=0,nxmin1
408      cbaseflux(ix,jy)=0.
409    end do
410  end do
411  do inest=1,numbnests
412    do jy=0,nyn(inest)-1
413      do ix=0,nxn(inest)-1
414        cbasefluxn(ix,jy,inest)=0.
415      end do
416    end do
417  end do
418
[4c64400]419  ! Inform whether output kernel is used or not
420  !*********************************************
421  if (lroot) then
[fe32dca]422    if (.not.lusekerneloutput) then
[4c64400]423      write(*,*) "Concentrations are calculated without using kernel"
424    else
425      write(*,*) "Concentrations are calculated using kernel"
426    end if
427  end if
428
429
[e200b7a]430  ! Calculate particle trajectories
431  !********************************
432
[f13406c]433  if (verbosity.gt.0) then
[8a65cb0]434     if (verbosity.gt.1) then   
435       CALL SYSTEM_CLOCK(count_clock, count_rate, count_max)
436       write(*,*) 'SYSTEM_CLOCK',(count_clock - count_clock0)/real(count_rate) !, count_rate, count_max
437     endif
438     if (info_flag.eq.1) then
439       print*, 'info only mode (stop)'   
440       stop
441     endif
442     print*,'call timemanager'
[f13406c]443  endif
444
[6ecb30a]445  call timemanager(metdata_format)
[e200b7a]446
[8a65cb0]447! NIK 16.02.2005
[c8fc724]448  do i=1,nspec
449    write(*,*) '**********************************************'
450    write(*,*) 'Scavenging statistics for species ', species(i), ':'
451    write(*,*) 'Total number of occurences of below-cloud scavenging', &
452         & tot_blc_count(i)
453    write(*,*) 'Total number of occurences of in-cloud    scavenging', &
454         & tot_inc_count(i)
455    write(*,*) '**********************************************'
456  end do
457 
[8a65cb0]458  write(*,*) 'CONGRATULATIONS: YOU HAVE SUCCESSFULLY COMPLETED A FLE&
459       &XPART MODEL RUN!'
[e200b7a]460
461end program flexpart
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG