Changes in trunk/src/readoutgrid.f90 [27:20]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/readoutgrid.f90
r27 r20 29 29 ! * 30 30 ! 4 June 1996 * 31 ! HSO, 1 July 201432 ! Added optional namelist input33 31 ! * 34 32 !***************************************************************************** … … 55 53 real,parameter :: eps=1.e-4 56 54 57 ! namelist variables58 integer, parameter :: maxoutlev=50059 integer :: readerror60 real,allocatable, dimension (:) :: outheights61 55 62 ! declare namelist63 namelist /outgrid/ &64 outlon0,outlat0, &65 numxgrid,numygrid, &66 dxout,dyout, &67 outheights68 69 ! allocate large array for reading input70 allocate(outheights(maxoutlev),stat=stat)71 if (stat.ne.0) write(*,*)'ERROR: could not allocate outheights'72 73 ! helps identifying failed namelist input74 dxout=-1.075 outheights=-1.076 56 77 57 ! Open the OUTGRID file and read output grid specifications 78 58 !********************************************************** 79 59 80 open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID',status='old',form='formatted',err=999) 60 open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID',status='old', & 61 err=999) 81 62 82 ! try namelist input83 read(unitoutgrid,outgrid,iostat=readerror)84 close(unitoutgrid)85 63 86 if ((dxout.le.0).or.(readerror.ne.0)) then64 call skplin(5,unitoutgrid) 87 65 88 readerror=189 66 90 open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID',status='old',err=999) 67 ! 1. Read horizontal grid specifications 68 !**************************************** 91 69 92 call skplin(5,unitoutgrid) 70 call skplin(3,unitoutgrid) 71 read(unitoutgrid,'(4x,f11.4)') outlon0 72 call skplin(3,unitoutgrid) 73 read(unitoutgrid,'(4x,f11.4)') outlat0 74 call skplin(3,unitoutgrid) 75 read(unitoutgrid,'(4x,i5)') numxgrid 76 call skplin(3,unitoutgrid) 77 read(unitoutgrid,'(4x,i5)') numygrid 78 call skplin(3,unitoutgrid) 79 read(unitoutgrid,'(4x,f12.5)') dxout 80 call skplin(3,unitoutgrid) 81 read(unitoutgrid,'(4x,f12.5)') dyout 93 82 94 ! 1. Read horizontal grid specifications95 !****************************************96 97 call skplin(3,unitoutgrid)98 read(unitoutgrid,'(4x,f11.4)') outlon099 call skplin(3,unitoutgrid)100 read(unitoutgrid,'(4x,f11.4)') outlat0101 call skplin(3,unitoutgrid)102 read(unitoutgrid,'(4x,i5)') numxgrid103 call skplin(3,unitoutgrid)104 read(unitoutgrid,'(4x,i5)') numygrid105 call skplin(3,unitoutgrid)106 read(unitoutgrid,'(4x,f12.5)') dxout107 call skplin(3,unitoutgrid)108 read(unitoutgrid,'(4x,f12.5)') dyout109 110 endif111 83 112 84 ! Check validity of output grid (shall be within model domain) … … 119 91 if ((outlon0+eps.lt.xlon0).or.(outlat0+eps.lt.ylat0) & 120 92 .or.(xr.gt.xr1+eps).or.(yr.gt.yr1+eps)) then 93 write(*,*) 'outlon0,outlat0:' 121 94 write(*,*) outlon0,outlat0 95 write(*,*) 'xr1,yr1,xlon0,ylat0,xr,yr,dxout,dyout:' 122 96 write(*,*) xr1,yr1,xlon0,ylat0,xr,yr,dxout,dyout 123 97 write(*,*) ' #### FLEXPART MODEL ERROR! PART OF OUTPUT ####' … … 130 104 ! 2. Count Vertical levels of output grid 131 105 !**************************************** 132 133 if (readerror.ne.0) then 134 j=0 135 100 j=j+1 106 j=0 107 100 j=j+1 136 108 do i=1,3 137 109 read(unitoutgrid,*,end=99) … … 140 112 if (outhelp.eq.0.) goto 99 141 113 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 114 99 numzgrid=j-1 149 115 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' 116 allocate(outheight(numzgrid) & 117 ,stat=stat) 118 if (stat.ne.0) write(*,*)'ERROR: could not allocate outh' 119 allocate(outheighthalf(numzgrid) & 120 ,stat=stat) 121 if (stat.ne.0) write(*,*)'ERROR: could not allocate outh' 122 123 124 rewind(unitoutgrid) 125 call skplin(29,unitoutgrid) 154 126 155 127 ! 2. Vertical levels of output grid 156 128 !********************************** 157 129 158 if (readerror.ne.0) then 130 j=0 131 1000 j=j+1 132 do i=1,3 133 read(unitoutgrid,*,end=990) 134 end do 135 read(unitoutgrid,'(4x,f7.1)',end=990) outhelp 136 if (outhelp.eq.0.) goto 99 137 outheight(j)=outhelp 138 goto 1000 139 990 numzgrid=j-1 159 140 160 rewind(unitoutgrid)161 call skplin(29,unitoutgrid)162 163 do j=1,numzgrid164 do i=1,3165 read(unitoutgrid,*)166 end do167 read(unitoutgrid,'(4x,f7.1)') outhelp168 outheight(j)=outhelp169 outheights(j)=outhelp170 end do171 close(unitoutgrid)172 173 else174 175 do j=1,numzgrid176 outheight(j)=outheights(j)177 end do178 179 endif180 181 ! write outgrid file in namelist format to output directory if requested182 if (nmlout.eqv..true.) then183 ! reallocate outheights with actually required dimension for namelist writing184 deallocate(outheights)185 allocate(outheights(numzgrid),stat=stat)186 if (stat.ne.0) write(*,*)'ERROR: could not allocate outheights'187 188 do j=1,numzgrid189 outheights(j)=outheight(j)190 end do191 192 open(unitoutgrid,file=path(2)(1:length(2))//'OUTGRID.namelist',err=1000)193 write(unitoutgrid,nml=outgrid)194 close(unitoutgrid)195 endif196 141 197 142 ! Check whether vertical levels are specified in ascending order … … 215 160 end do 216 161 162 217 163 xoutshift=xlon0-outlon0 218 164 youtshift=ylat0-outlat0 165 close(unitoutgrid) 219 166 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' 167 allocate(oroout(0:numxgrid-1,0:numygrid-1) & 168 ,stat=stat) 169 if (stat.ne.0) write(*,*)'ERROR: could not allocate outh' 170 allocate(area(0:numxgrid-1,0:numygrid-1) & 171 ,stat=stat) 172 if (stat.ne.0) write(*,*)'ERROR: could not allocate outh' 173 allocate(volume(0:numxgrid-1,0:numygrid-1,numzgrid) & 174 ,stat=stat) 175 if (stat.ne.0) write(*,*)'ERROR: could not allocate outh' 176 allocate(areaeast(0:numxgrid-1,0:numygrid-1,numzgrid) & 177 ,stat=stat) 178 if (stat.ne.0) write(*,*)'ERROR: could not allocate outh' 179 allocate(areanorth(0:numxgrid-1,0:numygrid-1,numzgrid) & 180 ,stat=stat) 181 if (stat.ne.0) write(*,*)'ERROR: could not allocate outh' 230 182 return 231 183 232 184 233 999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID" #### '185 999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID" #### ' 234 186 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 235 write(*,'(a)') path(1)(1:length(1)) 236 stop 237 238 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID" #### ' 239 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 240 write(*,'(a)') path(2)(1:length(2)) 187 write(*,*) ' #### xxx/flexpart/options #### ' 241 188 stop 242 189
Note: See TracChangeset
for help on using the changeset viewer.