Changeset d7935de in flexpart.git


Ignore:
Timestamp:
Sep 11, 2018, 6:06:31 PM (6 years ago)
Author:
pesei <petra seibert at univie ac at>
Branches:
univie
Children:
93786a1
Parents:
34f1452
Message:

modify most input read subroutines

changed some variable names (mostly for I-N reasons)
includes two names appearing also in timemanager, com_mod
corrected a few mistakes
simplified some parts of code
changed options/RELEASES which is in nml fmt correspondingly

Files:
13 edited

Legend:

Unmodified
Added
Removed
  • options/RELEASES

    r5b7ec80 rd7935de  
    11&RELEASES_CTRL
    22 NSPEC=          1,
    3  SPECNUM_REL=        24,
     3 NUMSPEC_REL=        24,
    44 /
    55&RELEASE
     
    88 IDATE2=   20170102,
    99 ITIME2=     090000,
    10  LON1=    0.000    ,
    11  LON2=    0.000    ,
    12  LAT1=   0.000    ,
    13  LAT2=   0.000    ,
     10 RLON1=    0.000    ,
     11 RLON2=    0.000    ,
     12 RLAT1=   0.000    ,
     13 RLAT2=   0.000    ,
    1414 Z1=    50.000       ,
    1515 Z2=    50.000       ,
    16  ZKIND=     1,
    17  MASS=  1.0000E8    ,
    18  PARTS=   10000
     16 IKINDZ=     1,
     17 RMASS=  1.0000E8    ,
     18 NPARTS=   10000
    1919 COMMENT="TEST1",
    2020 /
  • src/advance.f90

    r5184a7c rd7935de  
    421421  !*************************************************************
    422422  !************** CBL options added by mc see routine cblf90 ***
    423             if (cblflag.eq.1) then  !modified by mc
     423            if (iflagcbl.eq.1) then  !modified by mc
    424424              if (-h/ol.gt.5) then  !modified by mc
    425425              !if (ol.lt.0.) then   !modified by mc 
     
    515515
    516516      end do
    517       if (cblflag.ne.1) nrand=nrand+i
     517      if (iflagcbl.ne.1) nrand=nrand+i
    518518
    519519  ! Determine time step for next integration
  • src/com_mod.f90

    r1a8fbee rd7935de  
    2626  integer :: length(numpath+2*maxnests)
    2727  character(len=256) :: pathfile, flexversion, flexversion_major, arg1, arg2
    28   character(len=256) :: ohfields_path
     28  character(len=256) :: path_ohfields
    2929 
    3030  ! path                    path names needed for trajectory model
     
    3434  ! flexversion_major       version of flexpart (major version number)
    3535  ! arg                     input arguments from launch at command line
    36   ! ohfields_path           path to binary files for OH fields
     36  ! path_ohfields           path to binary files for OH fields
    3737
    3838  !********************************************************
     
    7373  integer :: ind_rel,ind_samp,ioutputforeachrelease,linit_cond,surf_only
    7474  logical :: turbswitch
    75   integer :: cblflag !added by mc for cbl
     75  integer :: iflagcbl !added by mc for cbl
    7676
    7777  ! ctl      factor, by which time step must be smaller than Lagrangian time scale
     
    104104
    105105  ! ind_rel and ind_samp  are used within the code to change between mass and mass-mix (see readcommand.f)
    106   ! cblflag !: 1 activate cbl skewed pdf routines with bi-gaussina pdf whan OL<0 added by mc
     106  ! iflagcbl !: 1 activate cbl skewed pdf routines with bi-gaussina pdf whan OL<0 added by mc
    107107
    108108
  • src/initialize.f90

    rdb712a8 rd7935de  
    158158    if (.not.turbswitch) then     ! modified by mc
    159159      wp=wp*sigw
    160     else if (cblflag.eq.1) then   ! modified by mc
     160    else if (iflagcbl.eq.1) then   ! modified by mc
    161161      if(-h/ol.gt.5) then
    162162!if (ol.lt.0.) then
  • src/readOHfield.f90

    r3f149cc rd7935de  
    6060
    6161
    62   open(unitOH,file=trim(ohfields_path) &
     62  open(unitOH,file=trim(path_ohfields) &
    6363       //'OH_FIELDS/OH_variables.bin',status='old', &
    6464       form='UNFORMATTED', iostat=ierr, convert='little_endian')
    6565
    6666  if(ierr.ne.0) then
    67     write(*,*) 'Cannot read binary OH fields in ',trim(ohfields_path)//'OH_FIELDS/OH_variables.bin'
     67    write(*,*) 'Cannot read binary OH fields in ',trim(path_ohfields)//'OH_FIELDS/OH_variables.bin'
    6868    stop
    6969  endif
  • src/readageclasses.f90

    r5f9d14a rd7935de  
    2929  !     Author: A. Stohl                                                       *
    3030  !     20 March 2000                                                          *
     31  !
    3132  !     HSO, 1 July 2014                                                       *
    3233  !     Added optional namelist input                                          *
     34  !                                                                            *
     35  !     PS, 6/2015-9/2018 some variable names changed as in readreleases.f90   *
     36  !       catch nageclass>maxage properly                                      *
    3337  !                                                                            *
    3438  !*****************************************************************************
     
    4751  integer :: i
    4852
    49   ! namelist help variables
    50   integer :: readerror
     53  ! namelist aux variables
     54  integer :: ios
    5155
    5256  ! namelist declaration
    53   namelist /ageclass/ &
     57  namelist /nml_ageclass/ &
    5458    nageclass, &
    5559    lage
     
    7175  !************************************************
    7276
    73   open(unitageclasses,file=path(1)(1:length(1))//'AGECLASSES',form='formatted',status='old',err=999)
     77  open(unitageclasses,file=path(1)(1:length(1))//'AGECLASSES', &
     78    form='formatted',status='old',err=999)
    7479
    7580  ! try to read in as a namelist
    76   read(unitageclasses,ageclass,iostat=readerror)
     81  read(unitageclasses, nml_ageclass, iostat=ios)
    7782  close(unitageclasses)
    7883
    79   if ((nageclass.lt.0).or.(readerror.ne.0)) then
    80     open(unitageclasses,file=path(1)(1:length(1))//'AGECLASSES',status='old',err=999)
    81     do i=1,13
    82       read(unitageclasses,*)
    83     end do
    84     read(unitageclasses,*) nageclass
    85     read(unitageclasses,*) lage(1)
    86     do i=2,nageclass
    87       read(unitageclasses,*) lage(i)
     84  if (ios .ne. 0) then ! failed to read nml, assume simple text
     85    open(unitageclasses,file=path(1)(1:length(1))// &
     86      'AGECLASSES',status='old',err=999)
     87    call skplin(13,unitageclasses)
     88    read(unitageclasses,*) nageclass ! number of classes
     89    if (nageclass.gt.maxageclass) goto 1001
     90    do i=1,nageclass
     91      read(unitageclasses,*) lage(i) ! max age per classes
    8892    end do
    8993    close(unitageclasses)
    9094  endif
    9195
     96  if (nageclass.lt.1) goto 1002
     97
    9298  ! write ageclasses file in namelist format to output directory if requested
    9399  if (nmlout.and.lroot) then
    94     open(unitageclasses,file=path(2)(1:length(2))//'AGECLASSES.namelist',err=1000)
    95     write(unitageclasses,nml=ageclass)
     100    open(unitageclasses,file=path(2)(1:length(2))//'AGECLASSES.namelist', &
     101      err=1000)
     102    write(unitageclasses,nml=nml_ageclass)
    96103    close(unitageclasses)
    97   endif
    98 
    99   if (nageclass.gt.maxageclass) then
    100     write(*,*) ' #### FLEXPART MODEL ERROR! NUMBER OF AGE     #### '
    101     write(*,*) ' #### CLASSES GREATER THAN MAXIMUM ALLOWED.   #### '
    102     write(*,*) ' #### CHANGE SETTINGS IN FILE AGECLASSES OR   #### '
    103     write(*,*) ' #### RECOMPILE WITH LARGER MAXAGECLASS IN    #### '
    104     write(*,*) ' #### FILE PAR_MOD.                        #### '
    105     stop
    106104  endif
    107105
     
    126124999   write(*,*) ' #### FLEXPART MODEL ERROR! FILE "AGECLASSES" #### '
    127125  write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
    128   write(*,'(a)') path(1)(1:length(1))
     126  write(*,'(a)') trim(path(1))
    129127  stop
    130128
     
    134132  stop
    135133
     1341001 continue
     135    write(*,*) ' #### FLEXPART MODEL ERROR! NUMBER OF AGE     #### '
     136    write(*,*) ' #### CLASSES GREATER THAN MAXIMUM ALLOWED.   #### '
     137    write(*,*) ' #### CHANGE SETTINGS IN FILE AGECLASSES OR   #### '
     138    write(*,*) ' #### RECOMPILE WITH LARGER MAXAGECLASS IN    #### '
     139    write(*,*) ' #### FILE PAR_MOD.                           #### '
     140    stop
     141
     1421002 continue
     143    write(*,*) ' #### FLEXPART MODEL ERROR! NUMBER OF AGE     #### '
     144    write(*,*) ' #### CLASSES < 1                             #### '
     145    write(*,*) ' #### CHANGE SETTINGS IN FILE AGECLASSES      #### '
     146    stop
    136147
    137148end subroutine readageclasses
  • src/readcommand.f90

    r77778f8 rd7935de  
    3333  !     Unknown, unknown: various                                              *
    3434  !     Petra Seibert, 2018-06-08: improve error msgs                          *
     35  !     PS 6/2015: Minor changes in variable names and layout                  *
    3536  !                                                                            *
    3637  !*****************************************************************************
     
    8485  character(len=50) :: line
    8586  logical :: old
    86   integer :: readerror
    87 
    88   namelist /command/ &
    89   ldirect, &
    90   ibdate,ibtime, &
    91   iedate,ietime, &
    92   loutstep, &
    93   loutaver, &
    94   loutsample, &
    95   itsplit, &
    96   lsynctime, &
    97   ctl, &
    98   ifine, &
    99   iout, &
    100   ipout, &
    101   lsubgrid, &
    102   lconvection, &
    103   lagespectra, &
    104   ipin, &
    105   ioutputforeachrelease, &
    106   iflux, &
    107   mdomainfill, &
    108   ind_source, &
    109   ind_receptor, &
    110   mquasilag, &
    111   nested_output, &
    112   linit_cond, &
    113   lnetcdfout, &
    114   surf_only, &
    115   cblflag, &
    116   ohfields_path
    117 
    118   ! Presetting namelist command
    119   ldirect=0
    120   ibdate=20000101
    121   ibtime=0
    122   iedate=20000102
    123   ietime=0
    124   loutstep=10800
    125   loutaver=10800
    126   loutsample=900
    127   itsplit=999999999
    128   lsynctime=900
    129   ctl=-5.0
    130   ifine=4
    131   iout=3
    132   ipout=0
    133   lsubgrid=1
    134   lconvection=1
    135   lagespectra=0
    136   ipin=1
    137   ioutputforeachrelease=1
    138   iflux=1
    139   mdomainfill=0
    140   ind_source=1
    141   ind_receptor=1
    142   mquasilag=0
    143   nested_output=0
    144   linit_cond=0
    145   lnetcdfout=0
    146   surf_only=0
    147   cblflag=0 ! if using old-style COMMAND file, set to 1 here to use mc cbl routine
    148   ohfields_path="../../flexin/"
     87  integer :: ios, icmdstat
     88
     89  namelist /nml_command/ &
     90    ldirect, &
     91    ibdate,ibtime, &
     92    iedate,ietime, &
     93    loutstep, &
     94    loutaver, &
     95    loutsample, &
     96    itsplit, &
     97    lsynctime, &
     98    ctl, &
     99    ifine, &
     100    iout, &
     101    ipout, &
     102    lsubgrid, &
     103    lconvection, &
     104    lagespectra, &
     105    ipin, &
     106    ioutputforeachrelease, &
     107    iflux, &
     108    mdomainfill, &
     109    ind_source, &
     110    ind_receptor, &
     111    mquasilag, &
     112    nested_output, &
     113    linit_cond, &
     114    lnetcdfout, &
     115    surf_only, &
     116    iflagcbl, &
     117    path_ohfields
     118
     119! Set default values for namelist
     120    ldirect=0
     121    ibdate=20000101
     122    ibtime=0
     123    iedate=20000102
     124    ietime=0
     125    loutstep=10800
     126    loutaver=10800
     127    loutsample=900
     128    itsplit=999999999
     129    lsynctime=900
     130    ctl=-5.0
     131    ifine=4
     132    iout=3
     133    ipout=0
     134    lsubgrid=1
     135    lconvection=1
     136    lagespectra=0
     137    ipin=1
     138    ioutputforeachrelease=1
     139    iflux=1
     140    mdomainfill=0
     141    ind_source=1
     142    ind_receptor=1
     143    mquasilag=0
     144    nested_output=0
     145    linit_cond=0
     146    lnetcdfout=0
     147    surf_only=0
     148    iflagcbl=0 ! if using old-style COMMAND file, set to 1 here to use mc cbl routine
     149    path_ohfields="../../flexin/"
    149150
    150151  !Af set release-switch
    151   WETBKDEP=.false.
    152   DRYBKDEP=.false.
    153 
     152    wetbkdep=.false.
     153    drybkdep=.false.
     154 
    154155  ! Open the command file and read user options
    155156  ! Namelist input first: try to read as namelist file
     
    158159    form='formatted',err=999)
    159160
    160   ! try namelist input (default)
    161   read(unitcommand,command,iostat=readerror)
     161! try namelist input
     162  read(unitcommand, nml_command, iostat=ios)
    162163  close(unitcommand)
    163164
    164165  ! distinguish namelist from fixed text input
    165   if ((readerror.ne.0).or.(ldirect.eq.0)) then ! parse as text file format
     166
     167  if (ios .ne. 0) then ! simple text file format
    166168 
    167169    open(unitcommand,file=path(1)(1:length(1))//'COMMAND',status='old', err=999)
    168170
    169     ! Check the format of the COMMAND file (either in free format,
    170     ! or using formatted mask)
     171    ! Check the format of the COMMAND file
     172    ! (either in free format or using formatted mask)
    171173    ! Use of formatted mask is assumed if line 10 contains the word 'DIRECTION'
    172174    !**************************************************************************
    173175
    174176    call skplin(9,unitcommand)
    175     read (unitcommand,901) line
    176   901   format (a)
     177    read (unitcommand,900) line
    177178    if (index(line,'LDIRECT') .eq. 0) then
    178179      old = .false.
     
    243244    ! Removed for backwards compatibility.
    244245    ! if (old) call skplin(3,unitcommand)  !added by mc
    245     ! read(unitcommand,*) cblflag          !added by mc
     246    ! read(unitcommand,*) iflagcbl          !added by mc
    246247
    247248    close(unitcommand)
     
    252253  if (nmlout.and.lroot) then
    253254    open(unitcommand,file=path(2)(1:length(2))//'COMMAND.namelist',err=998)
    254     write(unitcommand,nml=command)
     255    write(unitcommand,nml=nml_command)
    255256    close(unitcommand)
    256257  endif
     
    260261  ! Determine how Markov chain is formulated (for w or for w/sigw)
    261262  !***************************************************************
    262   if (cblflag.eq.1) then !---- added by mc to properly set parameters for CBL simulations
     263  if (iflagcbl.eq.1) then !added by mc to set parameters for CBL simulations
    263264    turbswitch=.true.
    264     if (lsynctime>maxtl) lsynctime=maxtl  !maxtl defined in com_mod.f90
     265    if (lsynctime.gt.maxtl) lsynctime=maxtl  !maxtl defined in com_mod.f90
    265266    if (ctl.lt.5) then
    266       print *,'WARNING: CBL flag active the ratio of TLu/dt has been set to 5'
     267      print*,'WARNING: CBL flag active; ctl (TLu/dt) has been set to 5'
    267268      ctl=5.
    268     end if
    269     if (ifine*ctl.lt.50) then
     269    endif
     270    if (ifine*ctl.lt.50.) then
    270271      ifine=int(50./ctl)+1
    271 
    272       print *,'WARNING: CBL flag active the ratio of TLW/dt was < 50, ifine has been re-set to',ifine
    273 !pause
     272      print *,'WARNING: CBL flag active; ctl (TLW/dt) was < 50,'// &
     273        ' ifine has been re-set to', ifine
    274274    endif
    275     print *,'WARNING: CBL flag active the ratio of TLW/dt is ',ctl*ifine
    276     print *,'WARNING: CBL flag active lsynctime is ',lsynctime
     275    print*,'WARNING: CBL flag active; reduced ctl is ',ctl*ifine
     276    print*,'WARNING: CBL flag active; lsynctime is ',lsynctime
    277277  else                    !added by mc
     278  ! note PS: shouldn't we print some msg as above also in the ntext case?
    278279    if (ctl.ge.0.1) then
    279280      turbswitch=.true.
     
    286287  ctl=1./ctl
    287288
    288   ! Set the switches required for the various options for input/output units
    289   !*************************************************************************
    290   !AF Set the switches IND_REL and IND_SAMP for the release and sampling
    291   !Af switches for the releasefile:
    292   !Af IND_REL =  1 : xmass * rho
    293   !Af IND_REL =  0 : xmass * 1
    294 
    295   !Af switches for the conccalcfile:
    296   !AF IND_SAMP =  0 : xmass * 1
    297   !Af IND_SAMP = -1 : xmass / rho
    298 
    299   !AF IND_SOURCE switches between different units for concentrations at the source
    300   !Af   NOTE that in backward simulations the release of computational particles
    301   !Af   takes place at the "receptor" and the sampling of p[articles at the "source".
    302   !Af          1 = mass units
    303   !Af          2 = mass mixing ratio units
    304   !Af IND_RECEPTOR switches between different units for concentrations at the receptor
    305   !Af          1 = mass units
    306   !Af          2 = mass mixing ratio units
    307   !            3 = wet deposition in outputfield
    308   !            4 = dry deposition in outputfield
     289! Set the switches required for the various options for input/output units
     290!*************************************************************************
     291!AF Set the switches IND_REL and IND_SAMP for the release and sampling
     292!Af switches for the releasefile:
     293!Af IND_REL =  1 : xmass * rho
     294!Af IND_REL =  0 : xmass * 1
     295
     296!Af switches for the conccalcfile:
     297!AF IND_SAMP =  0 : xmass * 1
     298!Af IND_SAMP = -1 : xmass / rho
     299
     300!AF IND_SOURCE switches between different units for concentrations at the source
     301!Af   NOTE that in backward simulations the release of computational particles
     302!Af   takes place at the "receptor" and the sampling of p[articles at the "source".
     303!Af          1 = mass units
     304!Af          2 = mass mixing ratio units
     305!Af IND_RECEPTOR switches between different units for concentrations at the receptor
     306!Af          1 = mass units
     307!Af          2 = mass mixing ratio units
     308!            3 = wet deposition in outputfield
     309!            4 = dry deposition in outputfield
    309310
    310311  if ( ldirect .eq. 1 ) then  ! FWD-Run
     
    328329        ind_samp = 0
    329330     endif
     331! note PS: why do we suddenly switch to CASE syntax??
     332! not helpful.
    330333     select case (ind_receptor)
    331334     case (1)  !  1 .. concentration at receptor
     
    337340        if (lroot) then
    338341          write(*,*) ' #### FLEXPART WET DEPOSITION BACKWARD MODE    #### '
    339           write(*,*) ' #### Releaseheight is forced to 0 - 20km      #### '
     342          write(*,*) ' #### Release height is forced to 0 - 20 km    #### '
    340343          write(*,*) ' #### Release is performed above ground lev    #### '
    341344        end if
    342          WETBKDEP=.true.
     345         wetbkdep=.true.
    343346         allocate(xscav_frac1(maxpart,maxspec))
    344347     case (4)  ! 4 .. dry deposition in outputfield
     
    349352           write(*,*) ' #### Release is performed above ground lev    #### '
    350353         end if
    351          DRYBKDEP=.true.
     354         drybkdep=.true.
    352355         allocate(xscav_frac1(maxpart,maxspec))
    353356     end select
     
    399402  endif
    400403
    401 ! Check for netcdf output switch
    402 !*******************************
     404!  check for netcdf output switch (use for non-namelist input only!)
    403405  if (iout.ge.8) then
    404406     lnetcdfout = 1
    405407     iout = iout - 8
    406408#ifndef USE_NCF
    407      write(*,*) 'ERROR: netcdf output not activated during compile time but used in COMMAND file!'
    408      write(*,*) 'Please recompile with netcdf library (`make [...] ncf=yes`) or use standard output format.'
     409     write(*,*) 'ERROR: netcdf output not activated during compile '// &
     410       'time but used in COMMAND file!'
     411     write(*,*) 'Please recompile with netcdf library (`make [...] ncf=yes`)'//&
     412       ' or use standard output format.'
    409413     stop
    410414#endif
     
    414418  !**********************************************************************
    415419
    416   if ((iout.lt.1).or.(iout.gt.6)) then
     420  if (iout.lt.1 .or. iout.gt.6) then
    417421    write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND:     #### '
    418422    write(*,*) ' #### IOUT MUST BE 1, 2, 3, 4 OR 5 FOR        #### '
     
    423427
    424428  !AF check consistency between units and volume mixing ratio
    425   if ( ((iout.eq.2).or.(iout.eq.3)).and. &
    426        (ind_source.gt.1 .or.ind_receptor.gt.1) ) then
     429  if ( (iout.eq.2       .or. iout.eq.3) .and. &
     430       (ind_source.gt.1 .or. ind_receptor.gt.1) ) then
    427431    write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND:     #### '
    428432    write(*,*) ' #### VOLUME MIXING RATIO ONLY SUPPORTED      #### '
     
    479483
    480484  ! For domain-filling trajectories, a plume centroid trajectory makes no sense,
    481   ! For backward runs, only residence time output (iout=1) or plume trajectories (iout=4),
    482   ! or both (iout=5) makes sense; other output options are "forbidden"
     485  ! For backward runs, only residence time output (iout=1) or plume trajectories
     486  ! (iout=4), or both (iout=5) makes sense; other output options are "forbidden"
    483487  !*****************************************************************************
    484488
     
    649653    path(2)(1:length(2))//'COMMAND.namelist'
    650654  stop 'stopped in readcommand'
     655
    651656999 write(*,900) ' #### FLEXPART MODEL ERROR! FILE "COMMAND"'
    652657  write(*,900)   ' #### CANNOT OPEN '//path(1)(1:length(1))//'COMMAND'
    653658  stop 'stopped in readcommand'
    654 900 format (a)
     659
     660900 format(a)
     661
    655662end subroutine readcommand
  • src/readoutgrid.f90

    r8a65cb0 rd7935de  
    2929  !                                                                            *
    3030  !     4 June 1996                                                            *
    31   !     HSO, 1 July 2014
    32   !     Added optional namelist input
     31  !     HSO, 1 July 2014: Add optional namelist input                          *
     32  !     PS, 6/2015-9/2018: read regular input with free format                 *
     33  !       simplify code and rename some variables                              *
    3334  !                                                                            *
    3435  !*****************************************************************************
     
    5152  implicit none
    5253
    53   integer :: i,j,stat
    54   real :: outhelp,xr,xr1,yr,yr1
     54  integer :: i,kz,istat
     55  real :: xr,xr1,yr,yr1
    5556  real,parameter :: eps=1.e-4
    5657
    5758  ! namelist variables
    5859  integer, parameter :: maxoutlev=500
    59   integer :: readerror
    60   real,allocatable, dimension (:) :: outheights
     60  integer :: ios
     61  real,allocatable, dimension (:) :: outheights,outaux
     62  logical :: lnml
    6163
    6264  ! declare namelist
    63   namelist /outgrid/ &
     65  namelist /nml_outgrid/ &
    6466    outlon0,outlat0, &
    6567    numxgrid,numygrid, &
    6668    dxout,dyout, &
    67     outheights
    68 
    69   ! allocate large array for reading input
    70   allocate(outheights(maxoutlev),stat=stat)
    71   if (stat.ne.0) write(*,*)'ERROR: could not allocate outheights'
    72 
    73   ! helps identifying failed namelist input
    74   dxout=-1.0
    75   outheights=-1.0
     69    outheight
     70
     71! allocate outheights for nml read with max dimension
     72  allocate(outheights(maxoutlev),outaux(maxoutlev),stat=istat)
     73  if (istat .ne. 0) write(*,*)'ERROR: could not allocate outheights'
    7674
    7775  ! Open the OUTGRID file and read output grid specifications
    7876  !**********************************************************
    7977
    80   open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID',status='old',form='formatted',err=999)
     78  outheight(:) = -999. ! initialise for later finding #valid levels
     79  open(unitoutgrid,file=trim(path(1))//'OUTGRID',status='old',&
     80    form='formatted',err=999)
    8181
    8282  ! try namelist input
    83   read(unitoutgrid,outgrid,iostat=readerror)
     83  read(unitoutgrid,nml_outgrid,iostat=ios)
    8484  close(unitoutgrid)
    8585
    86   if ((dxout.le.0).or.(readerror.ne.0)) then
    87 
    88     readerror=1
    89 
    90     open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID',status='old',err=999)
    91 
     86  if (ios .eq. 0) then ! namelist works
     87
     88    lnml = .true.
     89
     90  else ! read as regular text
     91
     92    lnml = .false.
     93
     94    open(unitoutgrid,file=trim(path(1))//'OUTGRID',status='old',err=999)
    9295    call skplin(5,unitoutgrid)
    9396
    94     ! 1. Read horizontal grid specifications
     97   ! Read horizontal grid specifications
    9598    !****************************************
    9699
    97100    call skplin(3,unitoutgrid)
    98     read(unitoutgrid,'(4x,f11.4)') outlon0
    99     call skplin(3,unitoutgrid)
    100     read(unitoutgrid,'(4x,f11.4)') outlat0
    101     call skplin(3,unitoutgrid)
    102     read(unitoutgrid,'(4x,i5)') numxgrid
    103     call skplin(3,unitoutgrid)
    104     read(unitoutgrid,'(4x,i5)') numygrid
    105     call skplin(3,unitoutgrid)
    106     read(unitoutgrid,'(4x,f12.5)') dxout
    107     call skplin(3,unitoutgrid)
    108     read(unitoutgrid,'(4x,f12.5)') dyout
    109 
    110   endif
     101    read(unitoutgrid,*) outlon0
     102    call skplin(3,unitoutgrid)
     103    read(unitoutgrid,*) outlat0
     104    call skplin(3,unitoutgrid)
     105    read(unitoutgrid,*) numxgrid
     106    call skplin(3,unitoutgrid)
     107    read(unitoutgrid,*) numygrid
     108    call skplin(3,unitoutgrid)
     109    read(unitoutgrid,*) dxout
     110    call skplin(3,unitoutgrid)
     111    read(unitoutgrid,*) dyout
     112
     113  endif ! read OUTGRID file
    111114
    112115  ! Check validity of output grid (shall be within model domain)
     
    124127    write(*,*) ' #### GRID IS OUTSIDE MODEL DOMAIN. CHANGE    ####'
    125128    write(*,*) ' #### FILE OUTGRID IN DIRECTORY               ####'
    126     write(*,'(a)') path(1)(1:length(1))
     129    write(*,'(a)') trim(path(1))
    127130    stop
    128131  endif
    129132
    130   ! 2. Count Vertical levels of output grid
    131   !****************************************
    132 
    133   if (readerror.ne.0) then
    134     j=0
    135 100 j=j+1
    136     do i=1,3
    137       read(unitoutgrid,*,end=99)
    138     end do
    139     read(unitoutgrid,'(4x,f7.1)',end=99) outhelp
    140     if (outhelp.eq.0.) goto 99
    141     goto 100
    142 99  numzgrid=j-1
    143   else
    144     do i=1,maxoutlev
    145       if (outheights(i).lt.0) exit
    146     end do
    147     numzgrid=i-1
    148   end if
    149 
    150   allocate(outheight(numzgrid),stat=stat)
    151   if (stat.ne.0) write(*,*)'ERROR: could not allocate outheight'
    152   allocate(outheighthalf(numzgrid),stat=stat)
    153   if (stat.ne.0) write(*,*)'ERROR: could not allocate outheighthalf'
    154 
    155   ! 2. Vertical levels of output grid
    156   !**********************************
    157 
    158   if (readerror.ne.0) then
    159 
    160     rewind(unitoutgrid)
    161     call skplin(29,unitoutgrid)
    162 
    163     do j=1,numzgrid
    164       do i=1,3
    165         read(unitoutgrid,*)
    166       end do
    167       read(unitoutgrid,'(4x,f7.1)') outhelp
    168       outheight(j)=outhelp
    169       outheights(j)=outhelp
    170     end do
    171     close(unitoutgrid)
    172 
    173   else
    174 
    175     do j=1,numzgrid
    176       outheight(j)=outheights(j)
    177     end do
    178 
     133! Read (if .not. lmnl) and count vertical levels of output grid
     134!**************************************************************
     135
     136  do kz = 1,maxoutlev
     137    if (lnml) then ! we have read them already
     138      if (outheight(kz) .lt. 0.) exit ! 1st nondefined level
     139    else
     140      call skplin(3,unitoutgrid)
     141      read(unitoutgrid,*,end=10) outheight(kz)
     142    endif
     143  end do
     14410 continue 
     145
     146  numzgrid = kz - 1 ! number of outgrid levels
     147
     148! allocate the required length only, shuffle data 
     149  outaux = outheight ! shuffle
     150
     151  deallocate(outheights)
     152  allocate(outheight(numzgrid),outheighthalf(numzgrid),stat=istat)
     153  if (istat .ne. 0) then
     154    write(*,*) 'ERROR: could not allocate outheight and outheighthalf'
     155    stop 'readoutgrid error'
    179156  endif
    180157
    181   ! write outgrid file in namelist format to output directory if requested
    182   if (nmlout.and.lroot) then
    183     ! reallocate outheights with actually required dimension for namelist writing
    184     deallocate(outheights)
    185     allocate(outheights(numzgrid),stat=stat)
    186     if (stat.ne.0) write(*,*)'ERROR: could not allocate outheights'
    187 
    188     do j=1,numzgrid
    189       outheights(j)=outheight(j)
    190     end do
    191 
    192     open(unitoutgrid,file=path(2)(1:length(2))//'OUTGRID.namelist',err=1000)
    193     write(unitoutgrid,nml=outgrid)
     158  outheight=outaux(1:numzgrid) ! shuffle back
     159  deallocate (outaux)
     160
     161! write outgrid file in namelist format to output directory if requested
     162  if (nmlout) then
     163    open(unitoutgrid,file=trim(path(2))//'OUTGRID.namelist',err=1000)
     164    write(unitoutgrid,nml=nml_outgrid)
    194165    close(unitoutgrid)
    195166  endif
     
    198169  !***************************************************************
    199170
    200   do j=2,numzgrid
    201     if (outheight(j).le.outheight(j-1)) then
    202     write(*,*) ' #### FLEXPART MODEL ERROR! YOUR SPECIFICATION#### '
    203     write(*,*) ' #### OF OUTPUT LEVELS IS CORRUPT AT LEVEL    #### '
    204     write(*,*) ' #### ',j,'                              #### '
    205     write(*,*) ' #### PLEASE MAKE CHANGES IN FILE OUTGRID.    #### '
    206     endif
     171  do kz=2,numzgrid
     172    if (outheight(kz) .le. outheight(kz-1)) goto 998
    207173  end do
    208174
     
    210176  !*****************************************************************
    211177
    212   outheighthalf(1)=outheight(1)/2.
    213   do j=2,numzgrid
    214     outheighthalf(j)=(outheight(j-1)+outheight(j))/2.
     178  outheighthalf(1) = 0.5*outheight(1)
     179  do kz = 2,numzgrid
     180    outheighthalf(kz) = 0.5*(outheight(kz-1)+outheight(kz))
    215181  end do
    216182
     
    218184  youtshift=ylat0-outlat0
    219185
    220   allocate(oroout(0:numxgrid-1,0:numygrid-1),stat=stat)
    221   if (stat.ne.0) write(*,*)'ERROR: could not allocate oroout'
    222   allocate(area(0:numxgrid-1,0:numygrid-1),stat=stat)
    223   if (stat.ne.0) write(*,*)'ERROR: could not allocate area'
    224   allocate(volume(0:numxgrid-1,0:numygrid-1,numzgrid),stat=stat)
    225   if (stat.ne.0) write(*,*)'ERROR: could not allocate volume'
    226   allocate(areaeast(0:numxgrid-1,0:numygrid-1,numzgrid),stat=stat)
    227   if (stat.ne.0) write(*,*)'ERROR: could not allocate areaeast'
    228   allocate(areanorth(0:numxgrid-1,0:numygrid-1,numzgrid),stat=stat)
    229   if (stat.ne.0) write(*,*)'ERROR: could not allocate areanorth'
     186  allocate(oroout(0:numxgrid-1,0:numygrid-1),stat=istat)
     187  if (istat .ne. 0) write(*,*)'ERROR: could not allocate oroout'
     188  allocate(area(0:numxgrid-1,0:numygrid-1),stat=istat)
     189  if (istat .ne. 0) write(*,*)'ERROR: could not allocate area'
     190  allocate(volume(0:numxgrid-1,0:numygrid-1,numzgrid),stat=istat)
     191  if (istat .ne. 0) write(*,*)'ERROR: could not allocate volume'
     192  allocate(areaeast(0:numxgrid-1,0:numygrid-1,numzgrid),stat=istat)
     193  if (istat .ne. 0) write(*,*)'ERROR: could not allocate areaeast'
     194  allocate(areanorth(0:numxgrid-1,0:numygrid-1,numzgrid),stat=istat)
     195  if (istat .ne. 0) write(*,*)'ERROR: could not allocate areanorth'
     196 
    230197  return
    231198
     199998 continue
     200  write(*,*) ' #### FLEXPART MODEL ERROR! YOUR SPECIFICATION#### '
     201  write(*,*) ' #### OF OUTPUT LEVELS NOT INCREASING AT LEVEL#### '
     202  write(*,*) ' #### ',kz,'                                  #### '
     203  write(*,*) ' #### PLEASE MAKE CHANGES IN FILE OUTGRID.    #### '
     204  STOP 'readoutgrid error'
    232205
    233206999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID"    #### '
    234207  write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
    235   write(*,'(a)') path(1)(1:length(1))
     208  write(*,'(a)') trim(path(1))
    236209  stop
    237210
    2382111000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID"    #### '
    239212  write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
    240   write(*,'(a)') path(2)(1:length(2))
     213  write(*,'(a)') trim(path(2))
    241214  stop
    242215
  • src/readoutgrid_nest.f90

    r8a65cb0 rd7935de  
    2929  !                                                                            *
    3030  !     4 June 1996                                                            *
     31  !     HSO, 1 July 2014: Add optional namelist input                          *
     32  !     PS, 6/2015-9/2018: read regular input with free format                 *
     33  !       and rename some variables                                            *
    3134  !                                                                            *
    3235  !*****************************************************************************
     
    5356  real,parameter :: eps=1.e-4
    5457
    55   integer :: readerror
     58  integer :: ios
    5659
    57   ! declare namelist
    58   namelist /outgridn/ &
    59     outlon0n,outlat0n, &
    60     numxgridn,numygridn, &
    61     dxoutn,dyoutn
     60! declare namelist
     61  namelist /nml_outgridn/ &
     62    outlon0n,outlat0n,numxgridn,numygridn,dxoutn,dyoutn
    6263
    6364  ! helps identifying failed namelist input
     
    6768  !**********************************************************
    6869
    69   open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID_NEST',form='formatted',status='old',err=999)
     70  open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID_NEST',form='formatted',&
     71    status='old',err=999)
    7072
    7173  ! try namelist input
    72   read(unitoutgrid,outgridn,iostat=readerror)
     74  read(unitoutgrid,nml_outgridn,iostat=ios)
    7375  close(unitoutgrid)
    7476
    75   if ((dxoutn.le.0).or.(readerror.ne.0)) then
     77  if (dxoutn.le.0 .or.ios.ne.0) then
    7678
    77     open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID_NEST',status='old',err=999)
     79    open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID_NEST',status='old',&
     80      err=999)
    7881    call skplin(5,unitoutgrid)
    7982
    80     ! 1. Read horizontal grid specifications
    81     !****************************************
     83  ! Read horizontal grid specifications
     84  ! ***********************************
    8285
    8386    call skplin(3,unitoutgrid)
    84     read(unitoutgrid,'(4x,f11.4)') outlon0n
     87    read(unitoutgrid,*) outlon0n
    8588    call skplin(3,unitoutgrid)
    86     read(unitoutgrid,'(4x,f11.4)') outlat0n
     89    read(unitoutgrid,*) outlat0n
    8790    call skplin(3,unitoutgrid)
    88     read(unitoutgrid,'(4x,i5)') numxgridn
     91    read(unitoutgrid,*) numxgridn
    8992    call skplin(3,unitoutgrid)
    90     read(unitoutgrid,'(4x,i5)') numygridn
     93    read(unitoutgrid,*) numygridn
    9194    call skplin(3,unitoutgrid)
    92     read(unitoutgrid,'(4x,f12.5)') dxoutn
     95    read(unitoutgrid,*) dxoutn
    9396    call skplin(3,unitoutgrid)
    94     read(unitoutgrid,'(4x,f12.5)') dyoutn
     97    read(unitoutgrid,*) dyoutn
    9598
    9699    close(unitoutgrid)
     
    99102  ! write outgrid_nest file in namelist format to output directory if requested
    100103  if (nmlout.and.lroot) then
    101     open(unitoutgrid,file=path(2)(1:length(2))//'OUTGRID_NEST.namelist',err=1000)
    102     write(unitoutgrid,nml=outgridn)
     104    open(unitoutgrid,file=path(2)(1:length(2))//'OUTGRID_NEST.namelist',&
     105      err=1000)
     106    write(unitoutgrid,nml=nml_outgridn)
    103107    close(unitoutgrid)
    104108  endif
    105109
    106   allocate(orooutn(0:numxgridn-1,0:numygridn-1),stat=stat)
    107   if (stat.ne.0) write(*,*)'ERROR: could not allocate orooutn'
    108   allocate(arean(0:numxgridn-1,0:numygridn-1),stat=stat)
    109   if (stat.ne.0) write(*,*)'ERROR: could not allocate arean'
    110   allocate(volumen(0:numxgridn-1,0:numygridn-1,numzgrid),stat=stat)
    111   if (stat.ne.0) write(*,*)'ERROR: could not allocate volumen'
     110  allocate(orooutn(0:numxgridn-1,0:numygridn-1),stat=ios)
     111  if (ios.ne.0) write(*,*)'ERROR: could not allocate orooutn'
     112  allocate(arean(0:numxgridn-1,0:numygridn-1),stat=ios)
     113  if (ios.ne.0) write(*,*)'ERROR: could not allocate arean'
     114  allocate(volumen(0:numxgridn-1,0:numygridn-1,numzgrid),stat=ios)
     115  if (ios.ne.0) write(*,*)'ERROR: could not allocate volumen'
    112116
    113117  ! Check validity of output grid (shall be within model domain)
     
    118122  xr1=xlon0+real(nxmin1)*dx
    119123  yr1=ylat0+real(nymin1)*dy
    120   if ((outlon0n+eps.lt.xlon0).or.(outlat0n+eps.lt.ylat0) &
    121        .or.(xr.gt.xr1+eps).or.(yr.gt.yr1+eps)) then
     124  if (outlon0n+eps.lt.xlon0 .or. outlat0n+eps.lt.ylat0 &
     125    .or. xr.gt.xr1+eps .or. yr.gt.yr1+eps) then
    122126    write(*,*) ' #### FLEXPART MODEL ERROR! PART OF OUTPUT    ####'
    123127    write(*,*) ' #### NEST IS OUTSIDE MODEL DOMAIN. CHANGE    ####'
    124128    write(*,*) ' #### FILE OUTGRID IN DIRECTORY               ####'
    125     write(*,'(a)') path(1)(1:length(1))
     129    write(*,'(a)') trim(path(1))
    126130    stop
    127131  endif
     
    133137999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID"    #### '
    134138  write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
    135   write(*,'(a)') path(1)(1:length(1))
     139  write(*,'(a)') trim(path(1))
    136140  stop
    137141
    1381421000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID"    #### '
    139143  write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
    140   write(*,'(a)') path(2)(1:length(2))
     144  write(*,'(a)') trim(path(2))
    141145  stop
    142146
  • src/readreceptors.f90

    r8a65cb0 rd7935de  
    2727  !                                                                            *
    2828  !     Author: A. Stohl                                                       *
    29   !     1 August 1996                                                          *
    30   !     HSO, 14 August 2013
    31   !     Added optional namelist input
     29  !     1 August 1996       
     30  !                                                  *
     31  !     HSO, 14 August 2013: Added optional namelist input
     32  !     PS, 2/2015: access= -> position=
     33  !     PS, 6/2015: variable names, simplify code
    3234  !                                                                            *
    3335  !*****************************************************************************
     
    5254  character(len=16) :: receptor
    5355
    54   integer :: readerror
    55   real :: lon,lat   ! for namelist input, lon/lat are used instead of x,y
     56  integer :: ios
     57  real :: xlon,ylat   ! for namelist input, lon/lat are used instead of x,y
    5658  integer,parameter :: unitreceptorout=2
    5759
    5860  ! declare namelist
    59   namelist /receptors/ &
    60     receptor, lon, lat
     61  namelist /nml_receptors/ receptor, xlon, ylat
    6162
    62   lon=-999.9
    63 
    64   ! For backward runs, do not allow receptor output. Thus, set number of receptors to zero
     63!CPS I comment this out - why should we not have receptor output in bwd runs?
     64  ! For backward runs, do not allow receptor output. Thus, set number of
     65  ! receptors to zero
    6566  !*****************************************************************************
    6667
    67   if (ldirect.lt.0) then
    68     numreceptor=0
    69     return
    70   endif
     68!  if (ldirect.lt.0) then
     69!    numreceptor=0
     70!    return
     71!  endif
    7172
    7273
     
    7475  !************************************************************
    7576
    76   open(unitreceptor,file=path(1)(1:length(1))//'RECEPTORS',form='formatted',status='old',err=999)
     77  open(unitreceptor,file=path(1)(1:length(1))//'RECEPTORS',form='formatted',&
     78    status='old',err=999)
    7779
    7880  ! try namelist input
    79   read(unitreceptor,receptors,iostat=readerror)
     81  read(unitreceptor,nml_receptors,iostat=ios)
    8082
    8183  ! prepare namelist output if requested
    82   if (nmlout.and.lroot) then
    83     open(unitreceptorout,file=path(2)(1:length(2))//'RECEPTORS.namelist',&
    84          &access='append',status='replace',err=1000)
    85   endif
     84  if (nmlout) open(unitreceptorout,file=path(2)(1:length(2))// &
     85    'RECEPTORS.namelist', position='append',status='new',err=1000)
    8686
    87   if ((lon.lt.-900).or.(readerror.ne.0)) then
     87  if (ios .ne. 0) then ! read as regular text file
    8888
    8989    close(unitreceptor)
    90     open(unitreceptor,file=path(1)(1:length(1))//'RECEPTORS',status='old',err=999)
     90    open(unitreceptor,file=path(1)(1:length(1))// &
     91     'RECEPTORS',status='old',err=999)
     92 
    9193    call skplin(5,unitreceptor)
    9294
     
    101103    read(unitreceptor,'(4x,a16)',end=99) receptor
    102104    call skplin(3,unitreceptor)
    103     read(unitreceptor,'(4x,f11.4)',end=99) x
     105      read(unitreceptor,'(4x,f11.4)',end=99) xlon
    104106    call skplin(3,unitreceptor)
    105     read(unitreceptor,'(4x,f11.4)',end=99) y
    106     if ((x.eq.0.).and.(y.eq.0.).and. &
     107      read(unitreceptor,'(4x,f11.4)',end=99) ylat
     108      if ((xlon.eq.0.).and.(ylat.eq.0.).and. &
    107109         (receptor.eq.'                ')) then
    108110      j=j-1
     
    116118    endif
    117119    receptorname(j)=receptor
    118     xreceptor(j)=(x-xlon0)/dx       ! transform to grid coordinates
    119     yreceptor(j)=(y-ylat0)/dy
    120     xm=r_earth*cos(y*pi/180.)*dx/180.*pi
     120      xreceptor(j)=(xlon-xlon0)/dx       ! transform to grid coordinates
     121      yreceptor(j)=(ylat-ylat0)/dy
     122      xm=r_earth*cos(ylat*pi/180.)*dx/180.*pi
    121123    ym=r_earth*dy/180.*pi
    122124    receptorarea(j)=xm*ym
    123 
    124     ! write receptors file in namelist format to output directory if requested
    125     if (nmlout.and.lroot) then
    126       lon=x
    127       lat=y
    128       write(unitreceptorout,nml=receptors)
    129     endif
     125  ! write receptors file in namelist format to output directory if requested
     126    if (nmlout.and.lroot) write(unitreceptorout,nml=nml_receptors)
    130127
    131128    goto 100
     
    136133
    137134    j=0
    138     do while (readerror.eq.0)
     135    do while (ios .eq. 0)
    139136      j=j+1
    140       lon=-999.9
    141       read(unitreceptor,receptors,iostat=readerror)
    142       if ((lon.lt.-900).or.(readerror.ne.0)) then
    143         readerror=1
    144       else
     137      read(unitreceptor,nml_receptors,iostat=ios)
     138      if (ios .eq. 0) then
    145139        if (j.gt.maxreceptor) then
    146140          write(*,*) ' #### FLEXPART MODEL ERROR! TOO MANY RECEPTOR #### '
     
    150144        endif
    151145        receptorname(j)=receptor
    152         xreceptor(j)=(lon-xlon0)/dx       ! transform to grid coordinates
    153         yreceptor(j)=(lat-ylat0)/dy
    154         xm=r_earth*cos(lat*pi/180.)*dx/180.*pi
     146        xreceptor(j)=(xlon-xlon0)/dx       ! transform to grid coordinates
     147        yreceptor(j)=(ylat-ylat0)/dy
     148        xm=r_earth*cos(ylat*pi/180.)*dx/180.*pi
    155149        ym=r_earth*dy/180.*pi
    156150        receptorarea(j)=xm*ym
    157151      endif
    158152
    159       ! write receptors file in namelist format to output directory if requested
    160       if (nmlout.and.lroot) then
    161         write(unitreceptorout,nml=receptors)
    162       endif
     153    ! write receptors file in namelist format to output directory if requested
     154      if (nmlout.and.lroot) write(unitreceptorout,nml=nml_receptors)
    163155
    164156    end do
     
    166158    close(unitreceptor)
    167159
    168   endif
     160  endif ! end no-nml / nml bloc
    169161
    170   if (nmlout.and.lroot) then
    171     close(unitreceptorout)
    172   endif
     162  if (nmlout .and. lroot) close(unitreceptorout)
    173163
    174164  return
     
    176166
    177167999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RECEPTORS"  #### '
    178   write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
    179   write(*,'(a)') path(1)(1:length(1))
     168  write(*,*)   ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
     169  write(*,'(a)') trim(path(1))
    180170  stop
    181171
    182 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RECEPTORS"    #### '
    183   write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
    184   write(*,'(a)') path(2)(1:length(2))
     1721000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RECEPTORS"  #### '
     173  write(*,*)    ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
     174  write(*,'(a)') trim(path(2))
    185175  stop
    186176
  • src/readreleases.f90

    r5184a7c rd7935de  
    3333  !     Update: 29 January 2001                                                *
    3434  !     Release altitude can be either in magl or masl                         *
    35   !     HSO, 12 August 2013
    36   !     Added optional namelist input
     35  !     HSO, 12 August 2013: Added optional namelist input                     *
     36  !     PS, 2/2015: access= -> position= (ported from 9.2 review)              *
     37  !     PS, 8/2018: check for uninitialised mass (ticket:204),                 *
     38  !          rename int/real variables, a bit of code layout improvement       *
    3739  !                                                                            *
    3840  !*****************************************************************************
     
    7476  implicit none
    7577
    76   integer :: numpartmax,i,j,id1,it1,id2,it2,idum,stat,irel,ispc,nsettle
     78  integer :: numpartmax,i,j,id1,it1,id2,it2,idum,iallocstat,irel,ispc,nsettle
    7779  integer,parameter :: num_min_discrete=100
    7880  real :: vsh(ni),fracth(ni),schmih(ni),releaserate,xdum,cun
    7981  real(kind=dp) :: jul1,jul2,julm,juldate
    80   real,parameter :: eps2=1.e-9
    8182  character(len=50) :: line
    8283  logical :: old
    8384
    8485  ! help variables for namelist reading
    85   integer :: numpoints, parts, readerror
    86   integer*2 :: zkind
     86  integer :: numpoints, nparts, ios
     87  integer*2 :: ikindz
    8788  integer :: idate1, itime1, idate2, itime2
    88   real :: lon1,lon2,lat1,lat2,z1,z2
     89  real :: rlon1,rlon2,rlat1,rlat2,z1,z2
    8990  character*40 :: comment
    9091  integer,parameter :: unitreleasesout=2
    91   real,allocatable, dimension (:) :: mass
    92   integer,allocatable, dimension (:) :: specnum_rel,specnum_rel2
     92  real,allocatable, dimension (:) :: rmass
     93  integer,allocatable, dimension (:) :: numspec_rel,numspec_rel2
    9394
    9495  ! declare namelists
    9596  namelist /releases_ctrl/ &
    9697       nspec, &
    97        specnum_rel
     98       numspec_rel
    9899
    99100  namelist /release/ &
    100101       idate1, itime1, &
    101102       idate2, itime2, &
    102        lon1, lon2, &
    103        lat1, lat2, &
     103       rlon1, rlon2, &
     104       rlat1, rlat2, &
    104105       z1, z2, &
    105        zkind, &
    106        mass, &
    107        parts, &
     106       ikindz, &
     107       rmass, &
     108       nparts, &
    108109       comment
     110! initialiase mass
    109111
    110112  numpoint=0
    111113
    112   ! allocate with maxspec for first input loop
    113   allocate(mass(maxspec),stat=stat)
    114   if (stat.ne.0) write(*,*)'ERROR: could not allocate mass'
    115   allocate(specnum_rel(maxspec),stat=stat)
    116   if (stat.ne.0) write(*,*)'ERROR: could not allocate specnum_rel'
    117 
    118   ! presetting namelist releases_ctrl
     114! allocate with maxspec for first input loop
     115  allocate(rmass(maxspec),stat=iallocstat)
     116  if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate rmass'
     117  allocate(numspec_rel(maxspec),stat=iallocstat)
     118  if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate numspec_rel'
     119
     120! presetting namelist releases_ctrl
    119121  nspec = -1  ! use negative value to determine failed namelist input
    120   specnum_rel = 0
    121 
    122   !sec, read release to find how many releasepoints should be allocated
    123   open(unitreleases,file=path(1)(1:length(1))//'RELEASES',status='old',form='formatted',err=999)
    124 
    125   ! check if namelist input provided
    126   read(unitreleases,releases_ctrl,iostat=readerror)
    127 
    128   ! prepare namelist output if requested
     122  numspec_rel = 0
     123
     124!SEC: read release to find how many releasepoints should be allocated
     125  open(unitreleases,file=path(1)(1:length(1))//'RELEASES',status='old', &
     126    form='formatted',err=999)
     127
     128! prepare namelist output if requested
    129129  if (nmlout.and.lroot) then
    130     open(unitreleasesout,file=path(2)(1:length(2))//'RELEASES.namelist',access='append',status='replace',err=1000)
    131   endif
    132 
    133   if ((readerror.ne.0).or.(nspec.lt.0)) then
    134 
    135   ! no namelist format, close file and allow reopening in old format
     130    open(unitreleasesout,file=path(2)(1:length(2))//'RELEASES.namelist', &
     131      position='append',status='replace',err=1000)
     132  endif
     133
     134! check whether namelist input is available
     135  read(unitreleases,releases_ctrl,iostat=ios)
     136
     137  if (ios .ne. 0 .or. nspec .lt. 0 ) then
     138
     139  ! not in namelist format, close file and reopen as simple text file
     140
    136141    close(unitreleases)
    137     open(unitreleases,file=path(1)(1:length(1))//'RELEASES',status='old',err=999)
    138 
    139     readerror=1 ! indicates old format
    140 
    141   ! Check the format of the RELEASES file (either in free format,
    142   ! or using a formatted mask)
     142    open(unitreleases,file=path(1)(1:length(1))//'RELEASES', status='old', &
     143      err=999)
     144
     145    ios=1 ! indicates old format
     146
     147  ! Check the format of the RELEASES file
     148  ! (either in free format, or using a formatted mask)
    143149  ! Use of formatted mask is assumed if line 10 contains the word 'DIRECTION'
    144150  !**************************************************************************
     151! Note PS: something has changed, now Total is checked. Is this compatible??
    145152
    146153    call skplin(12,unitreleases)
     
    163170    if (old) call skplin(2,unitreleases)
    164171    do i=1,nspec
    165       read(unitreleases,*,err=998) specnum_rel(i)
     172      read(unitreleases,*,err=998) numspec_rel(i)
    166173      if (old) call skplin(2,unitreleases)
    167174    end do
     
    20220925  numpoint=numpoint-1
    203210
    204   else
    205 
    206     readerror=0
    207     do while (readerror.eq.0)
     211  else ! read namelist input
     212
     213    ios=0
     214    do while (ios.eq.0)  ! loop over release points
    208215      idate1=-1
    209       read(unitreleases,release,iostat=readerror)
    210       if ((idate1.lt.0).or.(readerror.ne.0)) then
    211         readerror=1
     216      read(unitreleases,release,iostat=ios)
     217      if (idate1.lt.0 .or. ios.ne.0) then
     218        ios=1
    212219      else
    213220        numpoint=numpoint+1
    214221      endif
    215222    end do
    216     readerror=0
    217   endif ! if namelist input
     223    ios=0
     224
     225  endif
    218226
    219227  rewind(unitreleases)
     
    221229  if (nspec.gt.maxspec) goto 994
    222230
    223   ! allocate arrays of matching size for number of species (namelist output)
    224   deallocate(mass)
    225   allocate(mass(nspec),stat=stat)
    226   if (stat.ne.0) write(*,*)'ERROR: could not allocate mass'
    227   allocate(specnum_rel2(nspec),stat=stat)
    228   if (stat.ne.0) write(*,*)'ERROR: could not allocate specnum_rel2'
    229   specnum_rel2=specnum_rel(1:nspec)
    230   deallocate(specnum_rel)
     231! allocate arrays of matching size for number of species (namelist output)
     232  deallocate(rmass)
     233  allocate(rmass(nspec),stat=iallocstat)
     234  if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate rmass'
     235  allocate(numspec_rel2(nspec),stat=iallocstat)
     236  if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate numspec_rel2'
     237
     238  numspec_rel2 = numspec_rel(1:nspec)
     239
     240  deallocate(numspec_rel)
    231241  ! eso: BUG, crashes here for nspec=12 and maxspec=6,
    232242  ! TODO: catch error and exit
    233   allocate(specnum_rel(nspec),stat=stat)
    234   if (stat.ne.0) write(*,*)'ERROR: could not allocate specnum_rel'
    235   specnum_rel=specnum_rel2
    236   deallocate(specnum_rel2)
    237 
    238   !allocate memory for numpoint releaspoints
    239   allocate(ireleasestart(numpoint),stat=stat)
    240   if (stat.ne.0) write(*,*)'ERROR: could not allocate ireleasestart'
    241   allocate(ireleaseend(numpoint),stat=stat)
    242   if (stat.ne.0) write(*,*)'ERROR: could not allocate ireleaseend'
    243   allocate(xpoint1(numpoint),stat=stat)
    244   if (stat.ne.0) write(*,*)'ERROR: could not allocate xpoint1'
    245   allocate(xpoint2(numpoint),stat=stat)
    246   if (stat.ne.0) write(*,*)'ERROR: could not allocate xpoint2'
    247   allocate(ypoint1(numpoint),stat=stat)
    248   if (stat.ne.0) write(*,*)'ERROR: could not allocate ypoint1'
    249   allocate(ypoint2(numpoint),stat=stat)
    250   if (stat.ne.0) write(*,*)'ERROR: could not allocate ypoint2'
    251   allocate(zpoint1(numpoint),stat=stat)
    252   if (stat.ne.0) write(*,*)'ERROR: could not allocate zpoint1'
    253   allocate(zpoint2(numpoint),stat=stat)
    254   if (stat.ne.0) write(*,*)'ERROR: could not allocate zpoint2'
    255   allocate(kindz(numpoint),stat=stat)
    256   if (stat.ne.0) write(*,*)'ERROR: could not allocate kindz'
    257   allocate(xmass(numpoint,maxspec),stat=stat)
    258   if (stat.ne.0) write(*,*)'ERROR: could not allocate xmass'
    259   allocate(rho_rel(numpoint),stat=stat)
    260   if (stat.ne.0) write(*,*)'ERROR: could not allocate rho_rel'
    261   allocate(npart(numpoint),stat=stat)
    262   if (stat.ne.0) write(*,*)'ERROR: could not allocate npart'
    263   allocate(xmasssave(numpoint),stat=stat)
    264   if (stat.ne.0) write(*,*)'ERROR: could not allocate xmasssave'
    265 
    266   if (lroot) write (*,*) 'Releasepoints : ', numpoint
    267 
    268   do i=1,numpoint
    269     xmasssave(i)=0.
    270   end do
     243  allocate(numspec_rel(nspec),stat=iallocstat)
     244  if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate numspec_rel'
     245
     246  numspec_rel = numspec_rel2
     247
     248  deallocate(numspec_rel2)
     249
     250! allocate memory for numpoint releaspoints
     251  allocate ( &
     252    ireleasestart(numpoint), ireleaseend(numpoint),xpoint1(numpoint), &
     253    xpoint2(numpoint), ypoint1(numpoint), ypoint2(numpoint), &
     254    zpoint1(numpoint), zpoint2(numpoint), kindz(numpoint), &
     255    xmass(numpoint,maxspec), rho_rel(numpoint), npart(numpoint), &
     256    xmasssave(numpoint), &
     257      stat=iallocstat )
     258  if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate variables' // &
     259    ' dimensioned numpoint =', numpoint
     260
     261  if (lroot) write (*,*) 'Release points : ', numpoint
     262
     263  xmasssave(:)=0.
    271264
    272265  !now save the information
    273   DEP=.false.
    274   DRYDEP=.false.
    275   WETDEP=.false.
    276   OHREA=.false.
    277   do i=1,maxspec
    278     DRYDEPSPEC(i)=.false.
    279     WETDEPSPEC(i)=.false.
    280   end do
    281 
    282   if (readerror.ne.0) then
     266  dep   =.false.
     267  drydep=.false.
     268  wetdep=.false.
     269  ohrea =.false.
     270  drydepspec(:)=.false.
     271  wetdepspec(:)=.false.
     272
     273  if (ios.ne.0) then
     274
    283275  ! Skip first 11 lines (file header)
    284276  !**********************************
     
    292284    if (nspec.gt.maxspec) goto 994
    293285    if (old) call skplin(2,unitreleases)
    294   endif
    295 
    296   ! namelist output
    297   if (nmlout.and.lroot) then
    298     write(unitreleasesout,nml=releases_ctrl)
    299   endif
    300 
     286
     287  endif
     288
     289! namelist output
     290  if (nmlout.and.lroot) write(unitreleasesout,nml=releases_ctrl)
     291
     292! species loop
    301293  do i=1,nspec
    302     if (readerror.ne.0) then
    303       read(unitreleases,*,err=998) specnum_rel(i)
     294 
     295    if (ios.ne.0) then
     296      read(unitreleases,*,err=998) numspec_rel(i)
    304297      if (old) call skplin(2,unitreleases)
    305       call readspecies(specnum_rel(i),i)
     298      call readspecies(numspec_rel(i),i)
    306299    else
    307       call readspecies(specnum_rel(i),i)
     300      call readspecies(numspec_rel(i),i)
    308301    endif
    309302
     
    322315  !*****************
    323316
    324     if (((iout.eq.2).or.(iout.eq.3)).and.(weightmolar(i).lt.0.)) then
     317    if ( (iout.eq.2 .or. iout.eq.3) .and. weightmolar(i).lt.0. ) then
    325318      write(*,*) 'For mixing ratio output, valid molar weight'
    326319      write(*,*) 'must be specified for all simulated species.'
     
    334327
    335328    decay(i)=0.693147/decay(i) !conversion half life to decay constant
    336 
     329! Note PS: this should be replace by = alog(2.)/decay(i)
     330! keep it for the moment so that results are not affect in test phase of v10
    337331
    338332  ! Dry deposition of gases
    339333  !************************
    340334
    341     if (reldiff(i).gt.0.) rm(i)=1./(henry(i)/3000.+100.*f0(i))    ! mesophyll resistance
     335    if (reldiff(i).gt.0.) rm(i)=1./( henry(i)/3000. + 100.*f0(i) )! mesophyll resistance
    342336
    343337  ! Dry deposition of particles
    344338  !****************************
    345339
    346     vsetaver(i)=0.
    347     cunningham(i)=0.
    348     dquer(i)=dquer(i)*1000000.        ! Conversion m to um
     340    vsetaver(i) = 0.
     341    cunningham(i) = 0.
     342    dquer(i) = dquer(i)*1.e6 ! Conversion m to um
    349343    if (density(i).gt.0.) then         ! Additional parameters
    350344      call part0(dquer(i),dsigma(i),density(i),fracth,schmih,cun,vsh)
    351345      do j=1,ni
    352         fract(i,j)=fracth(j)
    353         schmi(i,j)=schmih(j)
    354         vset(i,j)=vsh(j)
    355         cunningham(i)=cunningham(i)+cun*fract(i,j)
    356         vsetaver(i)=vsetaver(i)-vset(i,j)*fract(i,j)
     346        fract(i,j) = fracth(j)
     347        schmi(i,j) = schmih(j)
     348        vset(i,j) = vsh(j)
     349        cunningham(i) = cunningham(i) + cun*fract(i,j)
     350        vsetaver(i) = vsetaver(i) - vset(i,j)*fract(i,j)
    357351      end do
    358352      if (lroot) write(*,*) 'Average settling velocity: ',i,vsetaver(i)
     
    368362
    369363  ! ESO 04.2016 check for below-cloud scavenging (gas or aerosol)
    370     if ((dquer(i).le.0..and.(weta_gas(i).gt.0. .or. wetb_gas(i).gt.0.)) .or. &
    371          &(dquer(i).gt.0. .and. (crain_aero(i) .gt. 0. .or. csnow_aero(i).gt.0.)))  then
    372       WETDEP=.true.
    373       WETDEPSPEC(i)=.true.
     364    if ( &
     365      dquer(i).le.0. .and. (weta_gas(i)  .gt.0. .or. wetb_gas(i)  .gt.0.) .or. &
     366      dquer(i).gt.0. .and. (crain_aero(i).gt.0. .or. csnow_aero(i).gt.0.)  &
     367       )  then
     368      wetdep        = .true.
     369      wetdepspec(i) = .true.
    374370      if (lroot) then
    375371        write (*,*) '  Below-cloud scavenging: ON'
     
    381377
    382378  ! NIK 31.01.2013 + 10.12.2013 + 15.02.2015
    383     if (dquer(i).gt.0..and.(ccn_aero(i).gt.0. .or. in_aero(i).gt.0.))  then
    384       WETDEP=.true.
    385       WETDEPSPEC(i)=.true.
     379    if (dquer(i).gt.0. .and. (ccn_aero(i).gt.0. .or. in_aero(i).gt.0.))  then
     380      wetdep        = .true.
     381      wetdepspec(i) = .true.
    386382      if (lroot) then
    387383        write (*,*) '  In-cloud scavenging: ON'
     
    394390
    395391    if (ohcconst(i).gt.0.) then
    396       OHREA=.true.
     392      ohrea = .true.
    397393      if (lroot) write (*,*) '  OHreaction switched on: ',ohcconst(i),i
    398394    endif
    399395
    400     if ((reldiff(i).gt.0.).or.(density(i).gt.0.).or.(dryvel(i).gt.0.)) then
    401       DRYDEP=.true.
    402       DRYDEPSPEC(i)=.true.
     396    if (reldiff(i).gt.0. .or. density(i).gt.0. .or. dryvel(i).gt.0.) then
     397      drydep        = .true.
     398      drydepspec(i) = .true.
    403399    endif
    404400
     
    415411101 numpoint=numpoint+1
    416412
    417   if (readerror.lt.1) then ! reading namelist format
     413  if (ios.lt.1) then ! reading namelist format
    418414
    419415    if (numpoint.gt.numpoints) goto 250
    420     zkind = 1
    421     mass = 0
    422     parts = 0
     416    ikindz = 1
     417    rmass = -1. ! initialise as negative to catch if not given in input
     418    nparts = 0
    423419    comment = ' '
    424     read(unitreleases,release,iostat=readerror)
     420    read(unitreleases,release,iostat=ios)
    425421    id1=idate1
    426422    it1=itime1
    427423    id2=idate2
    428424    it2=itime2
    429     xpoint1(numpoint)=lon1
    430     xpoint2(numpoint)=lon2
    431     ypoint1(numpoint)=lat1
    432     ypoint2(numpoint)=lat2
     425    xpoint1(numpoint)=rlon1
     426    xpoint2(numpoint)=rlon2
     427    ypoint1(numpoint)=rlat1
     428    ypoint2(numpoint)=rlat2
    433429    zpoint1(numpoint)=z1
    434430    zpoint2(numpoint)=z2
    435     kindz(numpoint)=zkind
     431    kindz(numpoint)=ikindz
    436432    do i=1,nspec
    437       xmass(numpoint,i)=mass(i)
     433      if (rmass(i) .lt. 0.) goto 995 ! write error and stop
     434      xmass(numpoint,i)=rmass(i)
    438435    end do
    439     npart(numpoint)=parts
     436    npart(numpoint)=nparts
    440437    compoint(min(1001,numpoint))=comment
    441438
     
    445442    endif
    446443
    447   else
     444  else ! simple text format
    448445
    449446    read(unitreleases,*,end=250)
     
    471468      read(unitreleases,*,err=998) xmass(numpoint,i)
    472469      if (old) call skplin(2,unitreleases)
    473       mass(i)=xmass(numpoint,i)
     470      rmass(i)=xmass(numpoint,i)
    474471    end do
    475472  !save compoint only for the first 1000 release points
     
    489486      idate2=id2
    490487      itime2=it2
    491       lon1=xpoint1(numpoint)
    492       lon2=xpoint2(numpoint)
    493       lat1=ypoint1(numpoint)
    494       lat2=ypoint2(numpoint)
     488      rlon1=xpoint1(numpoint)
     489      rlon2=xpoint2(numpoint)
     490      rlat1=ypoint1(numpoint)
     491      rlat2=ypoint2(numpoint)
    495492      z1=zpoint1(numpoint)
    496493      z2=zpoint2(numpoint)
    497       zkind=kindz(numpoint)
    498       parts=npart(numpoint)
     494      ikindz=kindz(numpoint)
     495      nparts=npart(numpoint)
    499496      write(unitreleasesout,nml=release)
    500497    endif
    501498
    502499    if (numpoint.le.1000) then
    503       if((xpoint1(numpoint).eq.0.).and.(ypoint1(numpoint).eq.0.).and. &
    504            (xpoint2(numpoint).eq.0.).and.(ypoint2(numpoint).eq.0.).and. &
    505            (compoint(numpoint)(1:8).eq.'        ')) goto 250
     500      if (xpoint1(numpoint).eq.0. .and. ypoint1(numpoint).eq.0. .and. &
     501          xpoint2(numpoint).eq.0. .and. ypoint2(numpoint).eq.0. .and. &
     502          compoint(numpoint)(1:8).eq.'        ') goto 250
    506503    else
    507       if((xpoint1(numpoint).eq.0.).and.(ypoint1(numpoint).eq.0.).and. &
    508            (xpoint2(numpoint).eq.0.).and.(ypoint2(numpoint).eq.0.)) goto 250
     504      if (xpoint1(numpoint).eq.0. .and. ypoint1(numpoint).eq.0. .and. &
     505          xpoint2(numpoint).eq.0. .and. ypoint2(numpoint).eq.0.) goto 250
    509506    endif
    510507
     
    539536  !*********************************************************************
    540537
    541   if (xpoint1(numpoint).lt.xlon0) &
    542        xpoint1(numpoint)=xpoint1(numpoint)+360.
    543   if (xpoint1(numpoint).gt.xlon0+(nxmin1)*dx) &
    544        xpoint1(numpoint)=xpoint1(numpoint)-360.
    545   if (xpoint2(numpoint).lt.xlon0) &
    546        xpoint2(numpoint)=xpoint2(numpoint)+360.
    547   if (xpoint2(numpoint).gt.xlon0+(nxmin1)*dx) &
    548        xpoint2(numpoint)=xpoint2(numpoint)-360.
     538  if (xpoint1(numpoint) .lt. xlon0) &
     539      xpoint1(numpoint) = xpoint1(numpoint) + 360.
     540  if (xpoint1(numpoint) .gt. xlon0+nxmin1*dx) &
     541      xpoint1(numpoint) = xpoint1(numpoint) - 360.
     542  if (xpoint2(numpoint) .lt. xlon0) &
     543      xpoint2(numpoint) = xpoint2(numpoint) + 360.
     544  if (xpoint2(numpoint) .gt. xlon0+nxmin1*dx) &
     545      xpoint2(numpoint) = xpoint2(numpoint) - 360.
    549546
    550547  ! Determine relative beginning and ending times of particle release
     
    562559  if (mdomainfill.eq.0) then   ! no domain filling
    563560    if (ldirect.eq.1) then
    564       if ((jul1.lt.bdate).or.(jul2.gt.edate)) then
     561      if (jul1.lt.bdate .or. jul2.gt.edate) then
    565562        write(*,*) 'FLEXPART MODEL ERROR'
    566563        write(*,*) 'Release starts before simulation begins or ends'
     
    577574      endif
    578575    else if (ldirect.eq.-1) then
    579       if ((jul1.lt.edate).or.(jul2.gt.bdate)) then
     576      if (jul1.lt.edate .or. jul2.gt.bdate) then
    580577        write(*,*) 'FLEXPART MODEL ERROR'
    581578        write(*,*) 'Release starts before simulation begins or ends'
     
    586583      if (npart(numpoint).gt.num_min_discrete) then
    587584        ireleasestart(numpoint)=int((jul1-bdate)*86400.)
    588         ireleaseend(numpoint)=int((jul2-bdate)*86400.)
     585        ireleaseend(numpoint) = int((jul2-bdate)*86400.)
    589586      else
    590587        ireleasestart(numpoint)=int((julm-bdate)*86400.)
    591         ireleaseend(numpoint)=int((julm-bdate)*86400.)
     588        ireleaseend(numpoint) = int((julm-bdate)*86400.)
    592589      endif
    593590    endif
     
    600597
    601598  if (ireleasestart(numpoint).ne.ireleaseend(numpoint)) then
    602     releaserate=releaserate+real(npart(numpoint))/ &
    603          real(ireleaseend(numpoint)-ireleasestart(numpoint))
     599    releaserate = releaserate + real( npart(numpoint) ) / &
     600      real( ireleaseend(numpoint) - ireleasestart(numpoint) )
    604601  else
    605602    releaserate=99999999
     
    634631      nsettle=0
    635632      do ispc=1,nspec
    636         if (xmass(irel,ispc).gt.eps2) nsettle=nsettle+1
     633        if (xmass(irel,ispc).gt.tiny(1.)) nsettle=nsettle+1
    637634      end do
    638635      if (nsettle.gt.1) lsettling=.false.
     
    641638
    642639  if (lroot) then
    643     if (.not.lsettling) then
    644       write(*,*) 'WARNING: more than 1 species per release point, settling &
    645            &disabled'
    646     end if
     640    if (.not.lsettling) &
     641     write(*,*) 'WARNING: more than 1 species per release point,' &
     642           // ' settling disabled'
    647643  end if
    648644
     
    651647  !************************************************************************
    652648
    653   if (releaserate.gt. &
    654        0.99*real(maxpart)/real(lage(nageclass))) then
     649  if (releaserate .gt. 0.99*real(maxpart)/real(lage(nageclass))) then
    655650    if (numpartmax.gt.maxpart.and.lroot) then
    656651      write(*,*) '#####################################################'
     
    670665      write(*,*) 'Maximum allowed release rate is: ', &
    671666           real(maxpart)/real(lage(nageclass)),' particles per second'
    672       write(*,*) &
    673            'Total number of particles released during the simulation is: ', &
    674            numpartmax
     667      write(*,*) 'Total number of particles released during the simulation is:'&
     668        ,numpartmax
    675669      write(*,*) 'Maximum allowed number of particles is: ',maxpart
    676670    endif
     
    679673
    680674  if (lroot) then
    681     write(*,FMT='(A,ES14.7)') ' Total mass released:', sum(xmass(1:numpoint,1:nspec))
     675    write(*,FMT='(A,ES14.7)') ' Total mass released:', &
     676      sum(xmass(1:numpoint,1:nspec))
    682677  end if
    683678
    684679  return
    685680
    686 994 write(*,*) '#####################################################'
     681995 write(*,*) '#####################################################'
    687682  write(*,*) '#### FLEXPART MODEL SUBROUTINE READRELEASES:     ####'
    688683  write(*,*) '####                                             ####'
    689   write(*,*) '#### ERROR - MAXIMUM NUMBER OF EMITTED SPECIES IS####'
    690   write(*,*) '#### TOO LARGE. PLEASE REDUCE NUMBER OF SPECIES. ####'
     684  write(*,*) '#### ERROR - mass for species',i,' not given     ####'
    691685  write(*,*) '#####################################################'
     686  stop 'readreleases - undefined mass'
     687
     688994 write(*,*) '######################################################'
     689  write(*,*) '#### FLEXPART MODEL SUBROUTINE READRELEASES:      ####'
     690  write(*,*) '####                                              ####'
     691  write(*,*) '#### ERROR - MAXIMUM NUMBER OF EMITTED SPECIES IS ####'
     692  write(*,*) '#### TOO LARGE. PLEASE REDUCE NUMBER OF SPECIES.  ####'
     693  write(*,*) '######################################################'
    692694  stop
    693695
     
    702704  stop
    703705
    704 
    705706999 write(*,*) '#####################################################'
    706707  write(*,*) '   FLEXPART MODEL SUBROUTINE READRELEASES: '
     
    713714
    7147151000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RELEASES"    #### '
    715   write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
     716  write(*,*)    ' #### CANNOT BE OPENED IN THE DIRECTORY        #### '
    716717  write(*,'(a)') path(2)(1:length(2))
    717718  stop
  • src/timemanager.f90

    rc0884a8 rd7935de  
    719719  ! Output to keep track of the numerical instabilities in CBL simulation and if
    720720  ! they are compromising the final result (or not)
    721     if (cblflag.eq.1) print *,j,itime,'nan_synctime',nan_count,'nan_tl',total_nan_intl 
     721    if (iflagcbl.eq.1) print *,j,itime,'nan_synctime',nan_count,'nan_tl',total_nan_intl 
    722722         
    723723  end do
  • src/timemanager_mpi.f90

    rc0884a8 rd7935de  
    876876! Output to keep track of the numerical instabilities in CBL simulation
    877877! and if they are compromising the final result (or not):
    878     if (cblflag.eq.1) print *,j,itime,'nan_synctime',nan_count,'nan_tl',total_nan_intl 
     878    if (iflagcbl.eq.1) print *,j,itime,'nan_synctime',nan_count,'nan_tl',total_nan_intl 
    879879
    880880
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG