Changeset d7935de in flexpart.git for src/readreceptors.f90
- Timestamp:
- Sep 11, 2018, 6:06:31 PM (6 years ago)
- Branches:
- univie
- Children:
- 93786a1
- Parents:
- 34f1452
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/readreceptors.f90
r8a65cb0 rd7935de 27 27 ! * 28 28 ! 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 32 34 ! * 33 35 !***************************************************************************** … … 52 54 character(len=16) :: receptor 53 55 54 integer :: readerror55 real :: lon,lat ! for namelist input, lon/lat are used instead of x,y56 integer :: ios 57 real :: xlon,ylat ! for namelist input, lon/lat are used instead of x,y 56 58 integer,parameter :: unitreceptorout=2 57 59 58 60 ! declare namelist 59 namelist /receptors/ & 60 receptor, lon, lat 61 namelist /nml_receptors/ receptor, xlon, ylat 61 62 62 lon=-999.9 63 64 ! For backward runs, do not allow receptor output. Thus, set number ofreceptors to zero63 !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 65 66 !***************************************************************************** 66 67 67 if (ldirect.lt.0) then68 numreceptor=069 return70 endif68 ! if (ldirect.lt.0) then 69 ! numreceptor=0 70 ! return 71 ! endif 71 72 72 73 … … 74 75 !************************************************************ 75 76 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) 77 79 78 80 ! try namelist input 79 read(unitreceptor, receptors,iostat=readerror)81 read(unitreceptor,nml_receptors,iostat=ios) 80 82 81 83 ! 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) 86 86 87 if ( (lon.lt.-900).or.(readerror.ne.0)) then87 if (ios .ne. 0) then ! read as regular text file 88 88 89 89 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 91 93 call skplin(5,unitreceptor) 92 94 … … 101 103 read(unitreceptor,'(4x,a16)',end=99) receptor 102 104 call skplin(3,unitreceptor) 103 read(unitreceptor,'(4x,f11.4)',end=99) x105 read(unitreceptor,'(4x,f11.4)',end=99) xlon 104 106 call skplin(3,unitreceptor) 105 read(unitreceptor,'(4x,f11.4)',end=99) y106 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. & 107 109 (receptor.eq.' ')) then 108 110 j=j-1 … … 116 118 endif 117 119 receptorname(j)=receptor 118 xreceptor(j)=(x-xlon0)/dx ! transform to grid coordinates119 yreceptor(j)=(y-ylat0)/dy120 xm=r_earth*cos(y*pi/180.)*dx/180.*pi120 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 121 123 ym=r_earth*dy/180.*pi 122 124 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) 130 127 131 128 goto 100 … … 136 133 137 134 j=0 138 do while ( readerror.eq.0)135 do while (ios .eq. 0) 139 136 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 145 139 if (j.gt.maxreceptor) then 146 140 write(*,*) ' #### FLEXPART MODEL ERROR! TOO MANY RECEPTOR #### ' … … 150 144 endif 151 145 receptorname(j)=receptor 152 xreceptor(j)=( lon-xlon0)/dx ! transform to grid coordinates153 yreceptor(j)=( lat-ylat0)/dy154 xm=r_earth*cos( lat*pi/180.)*dx/180.*pi146 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 155 149 ym=r_earth*dy/180.*pi 156 150 receptorarea(j)=xm*ym 157 151 endif 158 152 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) 163 155 164 156 end do … … 166 158 close(unitreceptor) 167 159 168 endif 160 endif ! end no-nml / nml bloc 169 161 170 if (nmlout.and.lroot) then 171 close(unitreceptorout) 172 endif 162 if (nmlout .and. lroot) close(unitreceptorout) 173 163 174 164 return … … 176 166 177 167 999 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)) 180 170 stop 181 171 182 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RECEPTORS" 183 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### '184 write(*,'(a)') path(2)(1:length(2))172 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RECEPTORS" #### ' 173 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 174 write(*,'(a)') trim(path(2)) 185 175 stop 186 176
Note: See TracChangeset
for help on using the changeset viewer.