Changeset d7935de in flexpart.git for src/readreceptors.f90


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG