source: flexpart.git/src/FLEXPART.f90 @ 8057778

10.4.1_peseiGFS_025bugfixes+enhancementsdevrelease-10release-10.4.1scaling-bug
Last change on this file since 8057778 was 8057778, checked in by Ignacio Pisso <ip@…>, 5 years ago

update flexversion to 10.3

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