source: flexpart.git/src/FLEXPART_MPI.f90 @ 5f9d14a

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

Updated wet depo scheme

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