readcommand.f90 24.9 KB
Newer Older
Matthias Langer's avatar
 
Matthias Langer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
!**********************************************************************
! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010         *
! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa,             *
! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann   *
!                                                                     *
! This file is part of FLEXPART.                                      *
!                                                                     *
! FLEXPART is free software: you can redistribute it and/or modify    *
! it under the terms of the GNU General Public License as published by*
! the Free Software Foundation, either version 3 of the License, or   *
! (at your option) any later version.                                 *
!                                                                     *
! FLEXPART is distributed in the hope that it will be useful,         *
! but WITHOUT ANY WARRANTY; without even the implied warranty of      *
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
! GNU General Public License for more details.                        *
!                                                                     *
! You should have received a copy of the GNU General Public License   *
! along with FLEXPART.  If not, see <http://www.gnu.org/licenses/>.   *
!**********************************************************************

subroutine readcommand

  !*****************************************************************************
  !                                                                            *
  !     This routine reads the user specifications for the current model run.  *
  !                                                                            *
  !     Author: A. Stohl                                                       *
  !                                                                            *
  !     18 May 1996                                                            *
31
32
33
34
  !     Unknown, unknown: various                                              *
  !     HSO, 1 July 2014: Added optional namelist input                        *
  !     Unknown, unknown: various                                              *
  !     Petra Seibert, 2018-06-08: improve error msgs                          *
pesei's avatar
pesei committed
35
  !     PS 6/2015: Minor changes in variable names and layout                  *
Matthias Langer's avatar
 
Matthias Langer committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  !                                                                            *
  !*****************************************************************************
  !                                                                            *
  ! Variables:                                                                 *
  ! bdate                beginning date as Julian date                         *
  ! ctl                  factor by which time step must be smaller than        *
  !                      Lagrangian time scale                                 *
  ! ibdate,ibtime        beginnning date and time (YYYYMMDD, HHMISS)           *
  ! ideltas [s]          modelling period                                      *
  ! iedate,ietime        ending date and time (YYYYMMDD, HHMISS)               *
  ! ifine                reduction factor for vertical wind time step          *
  ! outputforeachrel     for forward runs it is possible either to create      *
  !                      one outputfield or several for each releasepoint      *
  ! iflux                switch to turn on (1)/off (0) flux calculations       *
  ! iout                 1 for conc. (residence time for backward runs) output,*
  !                      2 for mixing ratio output, 3 both, 4 for plume        *
  !                      trajectory output, 5 = options 1 and 4                *
  ! ipin                 1 continue simulation with dumped particle data, 0 no *
  ! ipout                0 no particle dump, 1 every output time, 3 only at end*
  ! itsplit [s]          time constant for particle splitting                  *
  ! loutaver [s]         concentration output is an average over loutaver      *
  !                      seconds                                               *
  ! loutsample [s]       average is computed from samples taken every [s]      *
  !                      seconds                                               *
  ! loutstep [s]         time interval of concentration output                 *
  ! lsynctime [s]        synchronisation time interval for all particles       *
  ! lagespectra          switch to turn on (1)/off (0) calculation of age      *
  !                      spectra                                               *
  ! lconvection          value of either 0 and 1 indicating mixing by          *
  !                      convection                                            *
  !                      = 0 .. no convection                                  *
  !                      + 1 .. parameterisation of mixing by subgrid-scale    *
  !                              convection = on                               *
  ! lsubgrid             switch to turn on (1)/off (0) subgrid topography      *
  !                      parameterization                                      *
  ! method               method used to compute the particle pseudovelocities  *
  ! mdomainfill          1 use domain-filling option, 0 not, 2 use strat. O3   *
  !                                                                            *
  ! Constants:                                                                 *
  ! unitcommand          unit connected to file COMMAND                        *
  !                                                                            *
  !*****************************************************************************

  use par_mod
  use com_mod

  implicit none

  real(kind=dp) :: juldate
  character(len=50) :: line
  logical :: old
pesei's avatar
pesei committed
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
  integer :: ios, icmdstat

  namelist /nml_command/ &
    ldirect, &
    ibdate,ibtime, &
    iedate,ietime, &
    loutstep, &
    loutaver, &
    loutsample, &
    itsplit, &
    lsynctime, &
    ctl, &
    ifine, &
    iout, &
    ipout, &
    lsubgrid, &
    lconvection, &
    lagespectra, &
    ipin, &
    ioutputforeachrelease, &
    iflux, &
    mdomainfill, &
    ind_source, &
    ind_receptor, &
    mquasilag, &
    nested_output, &
    linit_cond, &
    lnetcdfout, &
    surf_only, &
    iflagcbl, &
    path_ohfields

! Set default values for namelist
    ldirect=0
    ibdate=20000101
    ibtime=0
    iedate=20000102
    ietime=0
    loutstep=10800
    loutaver=10800
    loutsample=900
    itsplit=999999999
    lsynctime=900
    ctl=-5.0
    ifine=4
    iout=3
    ipout=0
    lsubgrid=1
    lconvection=1
    lagespectra=0
    ipin=1
    ioutputforeachrelease=1
    iflux=1
    mdomainfill=0
    ind_source=1
    ind_receptor=1
    mquasilag=0
    nested_output=0
    linit_cond=0
    lnetcdfout=0
    surf_only=0 
    iflagcbl=0 ! if using old-style COMMAND file, set to 1 here to use mc cbl routine
    path_ohfields="../../flexin/"
Matthias Langer's avatar
 
Matthias Langer committed
150

151
  !Af set release-switch
pesei's avatar
pesei committed
152
153
154
    wetbkdep=.false.
    drybkdep=.false.
 
Matthias Langer's avatar
 
Matthias Langer committed
155
  ! Open the command file and read user options
156
157
  ! Namelist input first: try to read as namelist file
  !**************************************************************************
158
159
  open(unitcommand,file=path(1)(1:length(1))//'COMMAND',status='old', &
    form='formatted',err=999)
Matthias Langer's avatar
 
Matthias Langer committed
160

pesei's avatar
pesei committed
161
162
! try namelist input
  read(unitcommand, nml_command, iostat=ios)
163
  close(unitcommand)
Matthias Langer's avatar
 
Matthias Langer committed
164

165
  ! distinguish namelist from fixed text input
pesei's avatar
pesei committed
166
167

  if (ios .ne. 0) then ! simple text file format
168
169
 
    open(unitcommand,file=path(1)(1:length(1))//'COMMAND',status='old', err=999)
170

pesei's avatar
pesei committed
171
172
    ! Check the format of the COMMAND file 
    ! (either in free format or using formatted mask)
173
174
175
176
    ! Use of formatted mask is assumed if line 10 contains the word 'DIRECTION'
    !**************************************************************************

    call skplin(9,unitcommand)
pesei's avatar
pesei committed
177
    read (unitcommand,900) line
178
179
    if (index(line,'LDIRECT') .eq. 0) then
      old = .false.
180
181
      if (lroot) write(*,*) 'COMMAND in old short format, &
           &please update to namelist format'
182
183
    else
      old = .true.
184
185
      if (lroot) write(*,*) 'COMMAND in old long format, &
           &please update to namelist format'
186
187
188
    endif
    rewind(unitcommand)

189

190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
    ! Read parameters
    !****************

    call skplin(7,unitcommand)
    if (old) call skplin(1,unitcommand)
    read(unitcommand,*) ldirect
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) ibdate,ibtime
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) iedate,ietime
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) loutstep
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) loutaver
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) loutsample
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) itsplit
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) lsynctime
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) ctl
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) ifine
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) iout
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) ipout
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) lsubgrid
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) lconvection
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) lagespectra
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) ipin
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) ioutputforeachrelease
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) iflux
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) mdomainfill
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) ind_source
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) ind_receptor
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) mquasilag
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) nested_output
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) linit_cond
242
243
    if (old) call skplin(3,unitcommand)
    read(unitcommand,*) surf_only
244
245
    ! Removed for backwards compatibility.
    ! if (old) call skplin(3,unitcommand)  !added by mc
pesei's avatar
pesei committed
246
    ! read(unitcommand,*) iflagcbl          !added by mc
247

248
249
250
251
252
    close(unitcommand)

  endif ! input format

  ! write command file in namelist format to output directory if requested
253
  if (nmlout.and.lroot) then
254
    open(unitcommand,file=path(2)(1:length(2))//'COMMAND.namelist',err=998)
pesei's avatar
pesei committed
255
    write(unitcommand,nml=nml_command)
256
    close(unitcommand)
Matthias Langer's avatar
 
Matthias Langer committed
257
258
259
260
261
262
  endif

  ifine=max(ifine,1)

  ! Determine how Markov chain is formulated (for w or for w/sigw)
  !***************************************************************
pesei's avatar
pesei committed
263
  if (iflagcbl.eq.1) then !added by mc to set parameters for CBL simulations 
Matthias Langer's avatar
 
Matthias Langer committed
264
    turbswitch=.true.
pesei's avatar
pesei committed
265
    if (lsynctime.gt.maxtl) lsynctime=maxtl  !maxtl defined in com_mod.f90
266
    if (ctl.lt.5) then
pesei's avatar
pesei committed
267
      print*,'WARNING: CBL flag active; ctl (TLu/dt) has been set to 5'
268
      ctl=5.
pesei's avatar
pesei committed
269
270
    endif
    if (ifine*ctl.lt.50.) then
271
      ifine=int(50./ctl)+1
pesei's avatar
pesei committed
272
273
      print *,'WARNING: CBL flag active; ctl (TLW/dt) was < 50,'// &
        ' ifine has been re-set to', ifine
274
    endif
pesei's avatar
pesei committed
275
276
    print*,'WARNING: CBL flag active; reduced ctl is ',ctl*ifine
    print*,'WARNING: CBL flag active; lsynctime is ',lsynctime
277
  else                    !added by mc
pesei's avatar
pesei committed
278
  ! note PS: shouldn't we print some msg as above also in the ntext case?
279
280
281
282
283
284
285
    if (ctl.ge.0.1) then
      turbswitch=.true.
    else
      turbswitch=.false.
      ifine=1
    endif
  endif                   !added by mc
Matthias Langer's avatar
 
Matthias Langer committed
286
287
288
  fine=1./real(ifine)
  ctl=1./ctl

pesei's avatar
pesei committed
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
! Set the switches required for the various options for input/output units
!*************************************************************************
!AF Set the switches IND_REL and IND_SAMP for the release and sampling
!Af switches for the releasefile:
!Af IND_REL =  1 : xmass * rho
!Af IND_REL =  0 : xmass * 1

!Af switches for the conccalcfile:
!AF IND_SAMP =  0 : xmass * 1
!Af IND_SAMP = -1 : xmass / rho

!AF IND_SOURCE switches between different units for concentrations at the source
!Af   NOTE that in backward simulations the release of computational particles
!Af   takes place at the "receptor" and the sampling of p[articles at the "source".
!Af          1 = mass units
!Af          2 = mass mixing ratio units
!Af IND_RECEPTOR switches between different units for concentrations at the receptor
!Af          1 = mass units
!Af          2 = mass mixing ratio units
!            3 = wet deposition in outputfield
!            4 = dry deposition in outputfield
Matthias Langer's avatar
 
Matthias Langer committed
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330

  if ( ldirect .eq. 1 ) then  ! FWD-Run
  !Af set release-switch
     if (ind_source .eq. 1 ) then !mass
        ind_rel = 0
     else ! mass mix
        ind_rel = 1
     endif
  !Af set sampling switch
     if (ind_receptor .eq. 1) then !mass
        ind_samp = 0
     else ! mass mix
        ind_samp = -1
     endif
  elseif (ldirect .eq. -1 ) then !BWD-Run
  !Af set sampling switch
     if (ind_source .eq. 1 ) then !mass
        ind_samp = -1
     else ! mass mix
        ind_samp = 0
     endif
pesei's avatar
pesei committed
331
332
! note PS: why do we suddenly switch to CASE syntax??
! not helpful.
333
334
     select case (ind_receptor)
     case (1)  !  1 .. concentration at receptor
Matthias Langer's avatar
 
Matthias Langer committed
335
        ind_rel = 1
336
     case (2)  !  2 .. mixing ratio at receptor
Matthias Langer's avatar
 
Matthias Langer committed
337
        ind_rel = 0
338
339
     case (3)  ! 3 .. wet deposition in outputfield 
        ind_rel = 3
340
341
        if (lroot) then
          write(*,*) ' #### FLEXPART WET DEPOSITION BACKWARD MODE    #### '
pesei's avatar
pesei committed
342
          write(*,*) ' #### Release height is forced to 0 - 20 km    #### '
343
344
          write(*,*) ' #### Release is performed above ground lev    #### '
        end if
pesei's avatar
pesei committed
345
         wetbkdep=.true.
346
347
348
         allocate(xscav_frac1(maxpart,maxspec))
     case (4)  ! 4 .. dry deposition in outputfield
         ind_rel = 4
349
350
351
352
353
         if (lroot) then
           write(*,*) ' #### FLEXPART DRY DEPOSITION BACKWARD MODE    #### '
           write(*,*) ' #### Releaseheight is forced to 0 - 2*href    #### '
           write(*,*) ' #### Release is performed above ground lev    #### '
         end if
pesei's avatar
pesei committed
354
         drybkdep=.true.
355
356
         allocate(xscav_frac1(maxpart,maxspec))
     end select
Matthias Langer's avatar
 
Matthias Langer committed
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
  endif

  !*************************************************************
  ! Check whether valid options have been chosen in file COMMAND
  !*************************************************************

  ! Check options for initial condition output: Switch off for forward runs
  !************************************************************************

  if (ldirect.eq.1) linit_cond=0
  if ((linit_cond.lt.0).or.(linit_cond.gt.2)) then
    write(*,*) ' #### FLEXPART MODEL ERROR! INVALID OPTION    #### '
    write(*,*) ' #### FOR LINIT_COND IN FILE "COMMAND".       #### '
    stop
  endif

  ! Check input dates
  !******************

  if (iedate.lt.ibdate) then
    write(*,*) ' #### FLEXPART MODEL ERROR! BEGINNING DATE    #### '
    write(*,*) ' #### IS LARGER THAN ENDING DATE. CHANGE      #### '
    write(*,*) ' #### EITHER POINT 2 OR POINT 3 IN FILE       #### '
    write(*,*) ' #### "COMMAND".                              #### '
    stop
  else if (iedate.eq.ibdate) then
    if (ietime.lt.ibtime) then
    write(*,*) ' #### FLEXPART MODEL ERROR! BEGINNING TIME    #### '
    write(*,*) ' #### IS LARGER THAN ENDING TIME. CHANGE      #### '
    write(*,*) ' #### EITHER POINT 2 OR POINT 3 IN FILE       #### '
    write(*,*) ' #### "COMMAND".                              #### '
    stop
    endif
  endif


  ! Determine kind of dispersion method
  !************************************

  if (ctl.gt.0.) then
    method=1
    mintime=minstep
  else
    method=0
    mintime=lsynctime
  endif

pesei's avatar
pesei committed
404
!  check for netcdf output switch (use for non-namelist input only!)
405
406
407
  if (iout.ge.8) then
     lnetcdfout = 1
     iout = iout - 8
408
#ifndef USE_NCF
pesei's avatar
pesei committed
409
410
411
412
     write(*,*) 'ERROR: netcdf output not activated during compile '// &
       'time but used in COMMAND file!'
     write(*,*) 'Please recompile with netcdf library (`make [...] ncf=yes`)'//&
       ' or use standard output format.'
413
414
     stop
#endif
415
416
  endif

Matthias Langer's avatar
 
Matthias Langer committed
417
418
419
  ! Check whether a valid option for gridded model output has been chosen
  !**********************************************************************

pesei's avatar
pesei committed
420
  if (iout.lt.1 .or. iout.gt.6) then
Matthias Langer's avatar
 
Matthias Langer committed
421
    write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND:     #### '
422
    write(*,*) ' #### IOUT MUST BE 1, 2, 3, 4 OR 5 FOR        #### '
423
424
    write(*,*) ' #### STANDARD FLEXPART OUTPUT OR  9 - 13     #### '
    write(*,*) ' #### FOR NETCDF OUTPUT                       #### '
Matthias Langer's avatar
 
Matthias Langer committed
425
426
427
428
    stop
  endif

  !AF check consistency between units and volume mixing ratio
pesei's avatar
pesei committed
429
430
  if ( (iout.eq.2       .or. iout.eq.3) .and. &
       (ind_source.gt.1 .or. ind_receptor.gt.1) ) then
Matthias Langer's avatar
 
Matthias Langer committed
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
    write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND:     #### '
    write(*,*) ' #### VOLUME MIXING RATIO ONLY SUPPORTED      #### '
    write(*,*) ' #### FOR MASS UNITS (at the moment)          #### '
    stop
  endif


  ! For quasilag output for each release is forbidden
  !*****************************************************************************

  if ((ioutputforeachrelease.eq.1).and.(mquasilag.eq.1)) then
      write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
      write(*,*) '#### OUTPUTFOREACHRELEASE AND QUASILAGRANGIAN####'
      write(*,*) '#### MODE IS NOT POSSIBLE   !                ####'
      stop
  endif


  ! For quasilag backward is forbidden
  !*****************************************************************************

  if ((ldirect.lt.0).and.(mquasilag.eq.1)) then
      write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
      write(*,*) '#### FOR BACKWARD RUNS, QUASILAGRANGIAN MODE ####'
      write(*,*) '#### IS NOT POSSIBLE   !                     ####'
      stop
  endif


  ! For backward runs one releasefield for all releases makes no sense,
  ! For quasilag and domainfill ioutputforechrelease is forbidden
  !*****************************************************************************

  if ((ldirect.lt.0).and.(ioutputforeachrelease.eq.0)) then
      write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
      write(*,*) '#### FOR BACKWARD RUNS, IOUTPUTFOREACHRLEASE ####'
      write(*,*) '#### MUST BE SET TO ONE!                     ####'
      stop
  endif


  ! For backward runs one releasefield for all releases makes no sense,
  ! and is "forbidden"
  !*****************************************************************************

  if ((mdomainfill.eq.1).and.(ioutputforeachrelease.eq.1)) then
      write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
      write(*,*) '#### FOR DOMAIN FILLING RUNS OUTPUT FOR      ####'
      write(*,*) '#### EACH RELEASE IS FORBIDDEN !             ####'
      stop
  endif


  ! For domain-filling trajectories, a plume centroid trajectory makes no sense,
pesei's avatar
pesei committed
485
486
  ! For backward runs, only residence time output (iout=1) or plume trajectories
  ! (iout=4), or both (iout=5) makes sense; other output options are "forbidden"
Matthias Langer's avatar
 
Matthias Langer committed
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
  !*****************************************************************************

  if (ldirect.lt.0) then
    if ((iout.eq.2).or.(iout.eq.3)) then
      write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
      write(*,*) '#### FOR BACKWARD RUNS, IOUT MUST BE 1,4,OR 5####'
      stop
    endif
  endif


  ! For domain-filling trajectories, a plume centroid trajectory makes no sense,
  ! and is "forbidden"
  !*****************************************************************************

  if (mdomainfill.ge.1) then
    if ((iout.eq.4).or.(iout.eq.5)) then
      write(*,*) '#### FLEXPART MODEL ERROR! FILE COMMAND:     ####'
      write(*,*) '#### FOR DOMAIN-FILLING TRAJECTORY OPTION,   ####'
      write(*,*) '#### IOUT MUST NOT BE SET TO 4 OR 5.         ####'
      stop
    endif
  endif



  ! Check whether a valid options for particle dump has been chosen
  !****************************************************************

  if ((ipout.ne.0).and.(ipout.ne.1).and.(ipout.ne.2)) then
    write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND:     #### '
518
    write(*,*) ' #### IPOUT MUST BE 1, 2 OR 3!                #### '
Matthias Langer's avatar
 
Matthias Langer committed
519
520
521
    stop
  endif

522
  if(lsubgrid.ne.1.and.verbosity.eq.0) then
Matthias Langer's avatar
 
Matthias Langer committed
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
    write(*,*) '             ----------------               '
    write(*,*) ' INFORMATION: SUBGRIDSCALE TERRAIN EFFECT IS'
    write(*,*) ' NOT PARAMETERIZED DURING THIS SIMULATION.  '
    write(*,*) '             ----------------               '
  endif


  ! Check whether convection scheme is either turned on or off
  !***********************************************************

  if ((lconvection.ne.0).and.(lconvection.ne.1)) then
    write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND:     #### '
    write(*,*) ' #### LCONVECTION MUST BE SET TO EITHER 1 OR 0#### '
    stop
  endif


  ! Check whether synchronisation interval is sufficiently short
  !*************************************************************

  if (lsynctime.gt.(idiffnorm/2)) then
    write(*,*) ' #### FLEXPART MODEL ERROR! SYNCHRONISATION   #### '
    write(*,*) ' #### TIME IS TOO LONG. MAKE IT SHORTER.      #### '
    write(*,*) ' #### MINIMUM HAS TO BE: ', idiffnorm/2
    stop
  endif


  ! Check consistency of the intervals, sampling periods, etc., for model output
  !*****************************************************************************

  if (loutaver.eq.0) then
    write(*,*) ' #### FLEXPART MODEL ERROR! TIME AVERAGE OF   #### '
    write(*,*) ' #### CONCENTRATION FIELD OUTPUT MUST NOT BE  #### '
    write(*,*) ' #### ZERO.                                   #### '
    write(*,*) ' #### CHANGE INPUT IN FILE COMMAND.           #### '
    stop
  endif

  if (loutaver.gt.loutstep) then
    write(*,*) ' #### FLEXPART MODEL ERROR! TIME AVERAGE OF   #### '
    write(*,*) ' #### CONCENTRATION FIELD OUTPUT MUST NOT BE  #### '
    write(*,*) ' #### GREATER THAN INTERVAL OF OUTPUT.        #### '
    write(*,*) ' #### CHANGE INPUT IN FILE COMMAND.           #### '
    stop
  endif

  if (loutsample.gt.loutaver) then
    write(*,*) ' #### FLEXPART MODEL ERROR! SAMPLING TIME OF  #### '
    write(*,*) ' #### CONCENTRATION FIELD OUTPUT MUST NOT BE  #### '
    write(*,*) ' #### GREATER THAN TIME AVERAGE OF OUTPUT.    #### '
    write(*,*) ' #### CHANGE INPUT IN FILE COMMAND.           #### '
    stop
  endif

  if (mod(loutaver,lsynctime).ne.0) then
    write(*,*) ' #### FLEXPART MODEL ERROR! AVERAGING TIME OF #### '
    write(*,*) ' #### CONCENTRATION FIELD MUST BE A MULTIPLE  #### '
    write(*,*) ' #### OF THE SYNCHRONISATION INTERVAL         #### '
    stop
  endif

  if ((loutaver/lsynctime).lt.2) then
    write(*,*) ' #### FLEXPART MODEL ERROR! AVERAGING TIME OF #### '
    write(*,*) ' #### CONCENTRATION FIELD MUST BE AT LEAST    #### '
    write(*,*) ' #### TWICE THE SYNCHRONISATION INTERVAL      #### '
    stop
  endif

  if (mod(loutstep,lsynctime).ne.0) then
    write(*,*) ' #### FLEXPART MODEL ERROR! INTERVAL BETWEEN  #### '
    write(*,*) ' #### CONCENTRATION FIELDS MUST BE A MULTIPLE #### '
    write(*,*) ' #### OF THE SYNCHRONISATION INTERVAL         #### '
    stop
  endif

  if ((loutstep/lsynctime).lt.2) then
    write(*,*) ' #### FLEXPART MODEL ERROR! INTERVAL BETWEEN  #### '
    write(*,*) ' #### CONCENTRATION FIELDS MUST BE AT LEAST   #### '
    write(*,*) ' #### TWICE THE SYNCHRONISATION INTERVAL      #### '
    stop
  endif

  if (mod(loutsample,lsynctime).ne.0) then
    write(*,*) ' #### FLEXPART MODEL ERROR! SAMPLING TIME OF  #### '
    write(*,*) ' #### CONCENTRATION FIELD MUST BE A MULTIPLE  #### '
    write(*,*) ' #### OF THE SYNCHRONISATION INTERVAL         #### '
    stop
  endif

  if (itsplit.lt.loutaver) then
    write(*,*) ' #### FLEXPART MODEL ERROR! SPLITTING TIME FOR#### '
    write(*,*) ' #### PARTICLES IS TOO SHORT. PLEASE INCREASE #### '
    write(*,*) ' #### SPLITTING TIME CONSTANT.                #### '
    stop
  endif

  if ((mquasilag.eq.1).and.(iout.ge.4)) then
    write(*,*) ' #### FLEXPART MODEL ERROR! CONFLICTING       #### '
    write(*,*) ' #### OPTIONS: IF MQUASILAG=1, PLUME          #### '
    write(*,*) ' #### TRAJECTORY OUTPUT IS IMPOSSIBLE.        #### '
    stop
  endif

  ! Compute modeling time in seconds and beginning date in Julian date
  !*******************************************************************

  outstep=real(abs(loutstep))
  if (ldirect.eq.1) then
    bdate=juldate(ibdate,ibtime)
    edate=juldate(iedate,ietime)
    ideltas=nint((edate-bdate)*86400.)
  else if (ldirect.eq.-1) then
    loutaver=-1*loutaver
    loutstep=-1*loutstep
    loutsample=-1*loutsample
    lsynctime=-1*lsynctime
    bdate=juldate(iedate,ietime)
    edate=juldate(ibdate,ibtime)
    ideltas=nint((edate-bdate)*86400.)
  else
644
645
    write(*,*) ' #### FLEXPART MODEL ERROR! DIRECTION IN'
    write(*,*) ' #### FILE "COMMAND" MUST BE EITHER -1 OR 1.'
Matthias Langer's avatar
 
Matthias Langer committed
646
647
648
649
650
    stop
  endif

  return

651
652
653
654
998 write(*,900) ' #### FLEXPART MODEL ERROR! FILE "COMMAND.namelist"'
  write(*,900)   ' #### CANNOT WRITE TO '// &
    path(2)(1:length(2))//'COMMAND.namelist'
  stop 'stopped in readcommand'
pesei's avatar
pesei committed
655

656
657
658
999 write(*,900) ' #### FLEXPART MODEL ERROR! FILE "COMMAND"'
  write(*,900)   ' #### CANNOT OPEN '//path(1)(1:length(1))//'COMMAND'
  stop 'stopped in readcommand'
pesei's avatar
pesei committed
659
660
661

900 format(a)

Matthias Langer's avatar
 
Matthias Langer committed
662
end subroutine readcommand