source: flexpart.git/src/FLEXPART.f90 @ 8a65cb0

10.4.1_peseiGFS_025bugfixes+enhancementsdevrelease-10release-10.4.1scaling-bugunivie
Last change on this file since 8a65cb0 was 8a65cb0, checked in by Espen Sollum ATMOS <espen@…>, 9 years ago

Added code, makefile for dev branch

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