[e200b7a] | 1 | !********************************************************************** |
---|
| 2 | ! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010 * |
---|
| 3 | ! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa, * |
---|
| 4 | ! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann * |
---|
| 5 | ! * |
---|
| 6 | ! This file is part of FLEXPART. * |
---|
| 7 | ! * |
---|
| 8 | ! FLEXPART is free software: you can redistribute it and/or modify * |
---|
| 9 | ! it under the terms of the GNU General Public License as published by* |
---|
| 10 | ! the Free Software Foundation, either version 3 of the License, or * |
---|
| 11 | ! (at your option) any later version. * |
---|
| 12 | ! * |
---|
| 13 | ! FLEXPART is distributed in the hope that it will be useful, * |
---|
| 14 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
| 15 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
| 16 | ! GNU General Public License for more details. * |
---|
| 17 | ! * |
---|
| 18 | ! You should have received a copy of the GNU General Public License * |
---|
| 19 | ! along with FLEXPART. If not, see <http://www.gnu.org/licenses/>. * |
---|
| 20 | !********************************************************************** |
---|
| 21 | |
---|
| 22 | subroutine readwind_nests(indj,n,uuhn,vvhn,wwhn) |
---|
| 23 | ! i i o o o |
---|
| 24 | !***************************************************************************** |
---|
| 25 | ! * |
---|
| 26 | ! This routine reads the wind fields for the nested model domains. * |
---|
| 27 | ! It is similar to subroutine readwind, which reads the mother domain. * |
---|
| 28 | ! * |
---|
| 29 | ! Authors: A. Stohl, G. Wotawa * |
---|
| 30 | ! * |
---|
| 31 | ! 8 February 1999 * |
---|
| 32 | ! * |
---|
| 33 | ! Last update: 17 October 2000, A. Stohl * |
---|
| 34 | ! * |
---|
| 35 | !***************************************************************************** |
---|
| 36 | ! Changes, Bernd C. Krueger, Feb. 2001: * |
---|
| 37 | ! Variables tthn and qvhn (on eta coordinates) in common block * |
---|
| 38 | ! CHANGE: 11/01/2008, Harald Sodemann, GRIB1/2 input with ECMWF grib_api * |
---|
| 39 | ! CHANGE: 03/12/2008, Harald Sodemann, update to f90 with ECMWF grib_api * |
---|
| 40 | !***************************************************************************** |
---|
| 41 | |
---|
| 42 | use grib_api |
---|
| 43 | use par_mod |
---|
| 44 | use com_mod |
---|
| 45 | |
---|
| 46 | implicit none |
---|
| 47 | |
---|
| 48 | !HSO parameters for grib_api |
---|
| 49 | integer :: ifile |
---|
| 50 | integer :: iret |
---|
| 51 | integer :: igrib |
---|
| 52 | integer :: gribVer,parCat,parNum,typSurf,valSurf,discipl |
---|
[4fbe7a5] | 53 | integer :: parId !!added by mc for making it consistent with new readwind.f90 |
---|
[e200b7a] | 54 | integer :: gotGrid |
---|
| 55 | !HSO end |
---|
| 56 | |
---|
| 57 | real :: uuhn(0:nxmaxn-1,0:nymaxn-1,nuvzmax,maxnests) |
---|
| 58 | real :: vvhn(0:nxmaxn-1,0:nymaxn-1,nuvzmax,maxnests) |
---|
| 59 | real :: wwhn(0:nxmaxn-1,0:nymaxn-1,nwzmax,maxnests) |
---|
| 60 | integer :: indj,i,j,k,n,levdiff2,ifield,iumax,iwmax,l |
---|
| 61 | |
---|
| 62 | ! VARIABLES AND ARRAYS NEEDED FOR GRIB DECODING |
---|
| 63 | |
---|
| 64 | ! dimension of isec2 at least (22+n), where n is the number of parallels or |
---|
| 65 | ! meridians in a quasi-regular (reduced) Gaussian or lat/long grid |
---|
| 66 | |
---|
| 67 | ! dimension of zsec2 at least (10+nn), where nn is the number of vertical |
---|
| 68 | ! coordinate parameters |
---|
| 69 | |
---|
| 70 | integer :: isec1(56),isec2(22+nxmaxn+nymaxn) |
---|
| 71 | real(kind=4) :: zsec4(jpunp) |
---|
[4fbe7a5] | 72 | real(kind=4) :: xaux,yaux |
---|
[e200b7a] | 73 | real(kind=8) :: xauxin,yauxin |
---|
[4fbe7a5] | 74 | real,parameter :: eps=1.e-4 |
---|
[e200b7a] | 75 | real :: ewss(0:nxmaxn-1,0:nymaxn-1),nsss(0:nxmaxn-1,0:nymaxn-1) |
---|
| 76 | real :: plev1,pmean,tv,fu,hlev1,ff10m,fflev1 |
---|
[4fbe7a5] | 77 | real :: conversion_factor !added by mc to make it consistent with new gridchek.f90 |
---|
[e200b7a] | 78 | |
---|
| 79 | logical :: hflswitch,strswitch |
---|
| 80 | |
---|
| 81 | !HSO grib api error messages |
---|
| 82 | character(len=24) :: gribErrorMsg = 'Error reading grib file' |
---|
| 83 | character(len=20) :: gribFunction = 'readwind_nests' |
---|
| 84 | |
---|
| 85 | do l=1,numbnests |
---|
| 86 | hflswitch=.false. |
---|
| 87 | strswitch=.false. |
---|
| 88 | levdiff2=nlev_ec-nwz+1 |
---|
| 89 | iumax=0 |
---|
| 90 | iwmax=0 |
---|
| 91 | |
---|
| 92 | ifile=0 |
---|
| 93 | igrib=0 |
---|
| 94 | iret=0 |
---|
| 95 | |
---|
| 96 | ! |
---|
| 97 | ! OPENING OF DATA FILE (GRIB CODE) |
---|
| 98 | ! |
---|
| 99 | |
---|
| 100 | 5 call grib_open_file(ifile,path(numpath+2*(l-1)+1) & |
---|
| 101 | (1:length(numpath+2*(l-1)+1))//trim(wfnamen(l,indj)),'r') |
---|
| 102 | if (iret.ne.GRIB_SUCCESS) then |
---|
| 103 | goto 888 ! ERROR DETECTED |
---|
| 104 | endif |
---|
| 105 | !turn on support for multi fields messages */ |
---|
| 106 | !call grib_multi_support_on |
---|
| 107 | |
---|
| 108 | gotGrid=0 |
---|
| 109 | ifield=0 |
---|
| 110 | 10 ifield=ifield+1 |
---|
| 111 | ! |
---|
| 112 | ! GET NEXT FIELDS |
---|
| 113 | ! |
---|
| 114 | call grib_new_from_file(ifile,igrib,iret) |
---|
| 115 | if (iret.eq.GRIB_END_OF_FILE) then |
---|
| 116 | goto 50 ! EOF DETECTED |
---|
| 117 | elseif (iret.ne.GRIB_SUCCESS) then |
---|
| 118 | goto 888 ! ERROR DETECTED |
---|
| 119 | endif |
---|
| 120 | |
---|
| 121 | !first see if we read GRIB1 or GRIB2 |
---|
| 122 | call grib_get_int(igrib,'editionNumber',gribVer,iret) |
---|
| 123 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 124 | |
---|
| 125 | if (gribVer.eq.1) then ! GRIB Edition 1 |
---|
| 126 | |
---|
| 127 | !print*,'GRiB Edition 1' |
---|
| 128 | !read the grib2 identifiers |
---|
| 129 | call grib_get_int(igrib,'indicatorOfParameter',isec1(6),iret) |
---|
| 130 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 131 | call grib_get_int(igrib,'level',isec1(8),iret) |
---|
| 132 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 133 | |
---|
| 134 | !change code for etadot to code for omega |
---|
| 135 | if (isec1(6).eq.77) then |
---|
| 136 | isec1(6)=135 |
---|
| 137 | endif |
---|
| 138 | |
---|
[4fbe7a5] | 139 | conversion_factor=1. |
---|
| 140 | |
---|
| 141 | |
---|
[e200b7a] | 142 | else |
---|
| 143 | |
---|
| 144 | !print*,'GRiB Edition 2' |
---|
| 145 | !read the grib2 identifiers |
---|
| 146 | call grib_get_int(igrib,'discipline',discipl,iret) |
---|
| 147 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 148 | call grib_get_int(igrib,'parameterCategory',parCat,iret) |
---|
| 149 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 150 | call grib_get_int(igrib,'parameterNumber',parNum,iret) |
---|
| 151 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 152 | call grib_get_int(igrib,'typeOfFirstFixedSurface',typSurf,iret) |
---|
| 153 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 154 | call grib_get_int(igrib,'level',valSurf,iret) |
---|
| 155 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
[4fbe7a5] | 156 | call grib_get_int(igrib,'paramId',parId,iret) !added by mc to make it consisitent with new readwind.f90 |
---|
| 157 | call grib_check(iret,gribFunction,gribErrorMsg) !added by mc to make it consisitent with new readwind.f90 |
---|
[e200b7a] | 158 | |
---|
| 159 | !print*,discipl,parCat,parNum,typSurf,valSurf |
---|
| 160 | |
---|
| 161 | !convert to grib1 identifiers |
---|
| 162 | isec1(6)=-1 |
---|
| 163 | isec1(7)=-1 |
---|
| 164 | isec1(8)=-1 |
---|
| 165 | isec1(8)=valSurf ! level |
---|
[4fbe7a5] | 166 | conversion_factor=1. |
---|
[e200b7a] | 167 | if ((parCat.eq.0).and.(parNum.eq.0).and.(typSurf.eq.105)) then ! T |
---|
| 168 | isec1(6)=130 ! indicatorOfParameter |
---|
| 169 | elseif ((parCat.eq.2).and.(parNum.eq.2).and.(typSurf.eq.105)) then ! U |
---|
| 170 | isec1(6)=131 ! indicatorOfParameter |
---|
| 171 | elseif ((parCat.eq.2).and.(parNum.eq.3).and.(typSurf.eq.105)) then ! V |
---|
| 172 | isec1(6)=132 ! indicatorOfParameter |
---|
| 173 | elseif ((parCat.eq.1).and.(parNum.eq.0).and.(typSurf.eq.105)) then ! Q |
---|
| 174 | isec1(6)=133 ! indicatorOfParameter |
---|
[b0434e1] | 175 | ! ESO Cloud water is in a) fields CLWC and CIWC, *or* b) field QC |
---|
| 176 | elseif ((parCat.eq.1).and.(parNum.eq.83).and.(typSurf.eq.105)) then ! clwc |
---|
| 177 | isec1(6)=246 ! indicatorOfParameter |
---|
| 178 | elseif ((parCat.eq.1).and.(parNum.eq.84).and.(typSurf.eq.105)) then ! ciwc |
---|
| 179 | isec1(6)=247 ! indicatorOfParameter |
---|
| 180 | ! ESO qc(=clwc+ciwc): |
---|
| 181 | elseif ((parCat.eq.201).and.(parNum.eq.31).and.(typSurf.eq.105)) then ! qc |
---|
| 182 | isec1(6)=201031 ! indicatorOfParameter |
---|
[e200b7a] | 183 | elseif ((parCat.eq.3).and.(parNum.eq.0).and.(typSurf.eq.1)) then !SP |
---|
| 184 | isec1(6)=134 ! indicatorOfParameter |
---|
[4fbe7a5] | 185 | elseif ((parCat.eq.2).and.(parNum.eq.32)) then ! W, actually eta dot ! |
---|
[e200b7a] | 186 | isec1(6)=135 ! indicatorOfParameter |
---|
[4fbe7a5] | 187 | elseif ((parCat.eq.128).and.(parNum.eq.77)) then ! W, actually eta dot !added by mc to make it consisitent with new readwind.f90 |
---|
| 188 | isec1(6)=135 ! indicatorOfParameter !added by mc to make it consisitent with new readwind.f90 |
---|
[e200b7a] | 189 | elseif ((parCat.eq.3).and.(parNum.eq.0).and.(typSurf.eq.101)) then !SLP |
---|
| 190 | isec1(6)=151 ! indicatorOfParameter |
---|
| 191 | elseif ((parCat.eq.2).and.(parNum.eq.2).and.(typSurf.eq.103)) then ! 10U |
---|
| 192 | isec1(6)=165 ! indicatorOfParameter |
---|
| 193 | elseif ((parCat.eq.2).and.(parNum.eq.3).and.(typSurf.eq.103)) then ! 10V |
---|
| 194 | isec1(6)=166 ! indicatorOfParameter |
---|
| 195 | elseif ((parCat.eq.0).and.(parNum.eq.0).and.(typSurf.eq.103)) then ! 2T |
---|
| 196 | isec1(6)=167 ! indicatorOfParameter |
---|
| 197 | elseif ((parCat.eq.0).and.(parNum.eq.6).and.(typSurf.eq.103)) then ! 2D |
---|
| 198 | isec1(6)=168 ! indicatorOfParameter |
---|
| 199 | elseif ((parCat.eq.1).and.(parNum.eq.11).and.(typSurf.eq.1)) then ! SD |
---|
| 200 | isec1(6)=141 ! indicatorOfParameter |
---|
[4fbe7a5] | 201 | conversion_factor=1000. !added by mc to make it consisitent with new readwind.f90 |
---|
| 202 | elseif ((parCat.eq.6).and.(parNum.eq.1) .or. parId .eq. 164) then ! CC !added by mc to make it consisitent with new readwind.f90 |
---|
[e200b7a] | 203 | isec1(6)=164 ! indicatorOfParameter |
---|
[4fbe7a5] | 204 | elseif ((parCat.eq.1).and.(parNum.eq.9) .or. parId .eq. 142) then ! LSP !added by mc to make it consisitent with new readwind.f90 |
---|
[e200b7a] | 205 | isec1(6)=142 ! indicatorOfParameter |
---|
| 206 | elseif ((parCat.eq.1).and.(parNum.eq.10)) then ! CP |
---|
| 207 | isec1(6)=143 ! indicatorOfParameter |
---|
[4fbe7a5] | 208 | conversion_factor=1000. !added by mc to make it consisitent with new readwind.f90 |
---|
[e200b7a] | 209 | elseif ((parCat.eq.0).and.(parNum.eq.11).and.(typSurf.eq.1)) then ! SHF |
---|
| 210 | isec1(6)=146 ! indicatorOfParameter |
---|
| 211 | elseif ((parCat.eq.4).and.(parNum.eq.9).and.(typSurf.eq.1)) then ! SR |
---|
| 212 | isec1(6)=176 ! indicatorOfParameter |
---|
[b0434e1] | 213 | elseif ((parCat.eq.2).and.(parNum.eq.38) .or. parId .eq. 180) then ! EWSS !added by mc to make it consisitent with new readwind.f90 |
---|
[e200b7a] | 214 | isec1(6)=180 ! indicatorOfParameter |
---|
[b0434e1] | 215 | elseif ((parCat.eq.2).and.(parNum.eq.37) .or. parId .eq. 181) then ! NSSS !added by mc to make it consisitent with new readwind.f90 |
---|
[e200b7a] | 216 | isec1(6)=181 ! indicatorOfParameter |
---|
| 217 | elseif ((parCat.eq.3).and.(parNum.eq.4)) then ! ORO |
---|
| 218 | isec1(6)=129 ! indicatorOfParameter |
---|
[4fbe7a5] | 219 | elseif ((parCat.eq.3).and.(parNum.eq.7) .or. parId .eq. 160) then ! SDO !added by mc to make it consisitent with new readwind.f90 |
---|
[e200b7a] | 220 | isec1(6)=160 ! indicatorOfParameter |
---|
| 221 | elseif ((discipl.eq.2).and.(parCat.eq.0).and.(parNum.eq.0).and. & |
---|
| 222 | (typSurf.eq.1)) then ! LSM |
---|
| 223 | isec1(6)=172 ! indicatorOfParameter |
---|
| 224 | else |
---|
[4fbe7a5] | 225 | print*,'***WARNING: undefined GRiB2 message found!',discipl, & |
---|
[e200b7a] | 226 | parCat,parNum,typSurf |
---|
| 227 | endif |
---|
[4fbe7a5] | 228 | if(parId .ne. isec1(6) .and. parId .ne. 77) then !added by mc to make it consisitent with new readwind.f90 |
---|
| 229 | write(*,*) 'parId',parId, 'isec1(6)',isec1(6) ! |
---|
| 230 | ! stop |
---|
| 231 | endif |
---|
[e200b7a] | 232 | |
---|
| 233 | endif |
---|
| 234 | |
---|
| 235 | !HSO get the size and data of the values array |
---|
| 236 | if (isec1(6).ne.-1) then |
---|
| 237 | call grib_get_real4_array(igrib,'values',zsec4,iret) |
---|
| 238 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 239 | endif |
---|
| 240 | |
---|
| 241 | !HSO get the required fields from section 2 in a gribex compatible manner |
---|
| 242 | if(ifield.eq.1) then |
---|
| 243 | call grib_get_int(igrib,'numberOfPointsAlongAParallel', & |
---|
| 244 | isec2(2),iret) |
---|
| 245 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 246 | call grib_get_int(igrib,'numberOfPointsAlongAMeridian', & |
---|
| 247 | isec2(3),iret) |
---|
| 248 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 249 | call grib_get_int(igrib,'numberOfVerticalCoordinateValues', & |
---|
| 250 | isec2(12)) |
---|
| 251 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 252 | ! CHECK GRID SPECIFICATIONS |
---|
| 253 | if(isec2(2).ne.nxn(l)) stop & |
---|
[4fbe7a5] | 254 | 'READWIND: NX NOT CONSISTENT FOR A NESTING LEVEL' |
---|
[e200b7a] | 255 | if(isec2(3).ne.nyn(l)) stop & |
---|
[4fbe7a5] | 256 | 'READWIND: NY NOT CONSISTENT FOR A NESTING LEVEL' |
---|
[e200b7a] | 257 | if(isec2(12)/2-1.ne.nlev_ec) stop 'READWIND: VERTICAL DISCRET& |
---|
[8a65cb0] | 258 | &IZATION NOT CONSISTENT FOR A NESTING LEVEL' |
---|
[e200b7a] | 259 | endif ! ifield |
---|
| 260 | |
---|
| 261 | !HSO get the second part of the grid dimensions only from GRiB1 messages |
---|
[4fbe7a5] | 262 | if (isec1(6) .eq. 167 .and. (gotGrid.eq.0)) then ! !added by mc to make it consisitent with new readwind.f90 |
---|
[e200b7a] | 263 | call grib_get_real8(igrib,'longitudeOfFirstGridPointInDegrees', & |
---|
| 264 | xauxin,iret) |
---|
| 265 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
| 266 | call grib_get_real8(igrib,'latitudeOfLastGridPointInDegrees', & |
---|
| 267 | yauxin,iret) |
---|
| 268 | call grib_check(iret,gribFunction,gribErrorMsg) |
---|
[4fbe7a5] | 269 | if (xauxin.gt.180.) xauxin=xauxin-360.0 |
---|
| 270 | if (xauxin.lt.-180.) xauxin=xauxin+360.0 |
---|
| 271 | |
---|
[e200b7a] | 272 | xaux=xauxin |
---|
| 273 | yaux=yauxin |
---|
[4fbe7a5] | 274 | if (abs(xaux-xlon0n(l)).gt.eps) & |
---|
| 275 | stop 'READWIND: LOWER LEFT LONGITUDE NOT CONSISTENT FOR A NESTING LEVEL' |
---|
| 276 | if (abs(yaux-ylat0n(l)).gt.eps) & |
---|
| 277 | stop 'READWIND: LOWER LEFT LATITUDE NOT CONSISTENT FOR A NESTING LEVEL' |
---|
[e200b7a] | 278 | gotGrid=1 |
---|
| 279 | endif |
---|
| 280 | |
---|
| 281 | do j=0,nyn(l)-1 |
---|
| 282 | do i=0,nxn(l)-1 |
---|
| 283 | k=isec1(8) |
---|
| 284 | if(isec1(6).eq.130) tthn(i,j,nlev_ec-k+2,n,l)= &!! TEMPERATURE |
---|
| 285 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 286 | if(isec1(6).eq.131) uuhn(i,j,nlev_ec-k+2,l)= &!! U VELOCITY |
---|
| 287 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 288 | if(isec1(6).eq.132) vvhn(i,j,nlev_ec-k+2,l)= &!! V VELOCITY |
---|
| 289 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 290 | if(isec1(6).eq.133) then !! SPEC. HUMIDITY |
---|
| 291 | qvhn(i,j,nlev_ec-k+2,n,l)=zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 292 | if (qvhn(i,j,nlev_ec-k+2,n,l) .lt. 0.) & |
---|
| 293 | qvhn(i,j,nlev_ec-k+2,n,l) = 0. |
---|
| 294 | ! this is necessary because the gridded data may contain |
---|
| 295 | ! spurious negative values |
---|
| 296 | endif |
---|
| 297 | if(isec1(6).eq.134) psn(i,j,1,n,l)= &!! SURF. PRESS. |
---|
| 298 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 299 | if(isec1(6).eq.135) wwhn(i,j,nlev_ec-k+1,l)= &!! W VELOCITY |
---|
| 300 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 301 | if(isec1(6).eq.141) sdn(i,j,1,n,l)= &!! SNOW DEPTH |
---|
[4fbe7a5] | 302 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1)/conversion_factor !added by mc to make it consisitent with new readwind.f90! |
---|
[e200b7a] | 303 | if(isec1(6).eq.151) msln(i,j,1,n,l)= &!! SEA LEVEL PRESS. |
---|
| 304 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 305 | if(isec1(6).eq.164) tccn(i,j,1,n,l)= &!! CLOUD COVER |
---|
| 306 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 307 | if(isec1(6).eq.165) u10n(i,j,1,n,l)= &!! 10 M U VELOCITY |
---|
| 308 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 309 | if(isec1(6).eq.166) v10n(i,j,1,n,l)= &!! 10 M V VELOCITY |
---|
| 310 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 311 | if(isec1(6).eq.167) tt2n(i,j,1,n,l)= &!! 2 M TEMPERATURE |
---|
| 312 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 313 | if(isec1(6).eq.168) td2n(i,j,1,n,l)= &!! 2 M DEW POINT |
---|
| 314 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 315 | if(isec1(6).eq.142) then !! LARGE SCALE PREC. |
---|
| 316 | lsprecn(i,j,1,n,l)=zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 317 | if (lsprecn(i,j,1,n,l).lt.0.) lsprecn(i,j,1,n,l)=0. |
---|
| 318 | endif |
---|
| 319 | if(isec1(6).eq.143) then !! CONVECTIVE PREC. |
---|
[4fbe7a5] | 320 | convprecn(i,j,1,n,l)=zsec4(nxn(l)*(nyn(l)-j-1)+i+1)/conversion_factor !added by mc to make it consisitent with new readwind.f90 |
---|
[e200b7a] | 321 | if (convprecn(i,j,1,n,l).lt.0.) convprecn(i,j,1,n,l)=0. |
---|
| 322 | endif |
---|
| 323 | if(isec1(6).eq.146) sshfn(i,j,1,n,l)= &!! SENS. HEAT FLUX |
---|
| 324 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 325 | if((isec1(6).eq.146).and. & |
---|
| 326 | (zsec4(nxn(l)*(nyn(l)-j-1)+i+1).ne.0.)) hflswitch=.true. ! Heat flux available |
---|
| 327 | if(isec1(6).eq.176) then !! SOLAR RADIATION |
---|
| 328 | ssrn(i,j,1,n,l)=zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 329 | if (ssrn(i,j,1,n,l).lt.0.) ssrn(i,j,1,n,l)=0. |
---|
| 330 | endif |
---|
| 331 | if(isec1(6).eq.180) ewss(i,j)= &!! EW SURFACE STRESS |
---|
| 332 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 333 | if(isec1(6).eq.181) nsss(i,j)= &!! NS SURFACE STRESS |
---|
| 334 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 335 | if(((isec1(6).eq.180).or.(isec1(6).eq.181)).and. & |
---|
| 336 | (zsec4(nxn(l)*(nyn(l)-j-1)+i+1).ne.0.)) strswitch=.true. ! stress available |
---|
| 337 | if(isec1(6).eq.129) oron(i,j,l)= &!! ECMWF OROGRAPHY |
---|
| 338 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1)/ga |
---|
| 339 | if(isec1(6).eq.160) excessoron(i,j,l)= &!! STANDARD DEVIATION OF OROGRAPHY |
---|
| 340 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 341 | if(isec1(6).eq.172) lsmn(i,j,l)= &!! ECMWF LAND SEA MASK |
---|
| 342 | zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 343 | if(isec1(6).eq.131) iumax=max(iumax,nlev_ec-k+1) |
---|
| 344 | if(isec1(6).eq.135) iwmax=max(iwmax,nlev_ec-k+1) |
---|
| 345 | |
---|
[b0434e1] | 346 | ! ESO TODO: |
---|
| 347 | ! -add check for if one of clwc/ciwc missing (error), |
---|
| 348 | ! also if all 3 cw fields present, use qc and disregard the others |
---|
| 349 | if(isec1(6).eq.246) then !! CLWC Cloud liquid water content [kg/kg] |
---|
[db712a8] | 350 | clwchn(i,j,nlev_ec-k+2,n,l)=zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 351 | readclouds_nest(l)=.true. |
---|
| 352 | sumclouds_nest(l)=.false. |
---|
[b0434e1] | 353 | endif |
---|
| 354 | if(isec1(6).eq.247) then !! CIWC Cloud ice water content |
---|
[db712a8] | 355 | ciwchn(i,j,nlev_ec-k+2,n,l)=zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
[b0434e1] | 356 | endif |
---|
| 357 | !ZHG end |
---|
| 358 | !ESO read qc (=clwc+ciwc) |
---|
| 359 | if(isec1(6).eq.201031) then !! QC Cloud liquid water content [kg/kg] |
---|
[db712a8] | 360 | clwchn(i,j,nlev_ec-k+2,n,l)=zsec4(nxn(l)*(nyn(l)-j-1)+i+1) |
---|
| 361 | readclouds_nest(l)=.true. |
---|
| 362 | sumclouds_nest(l)=.true. |
---|
[b0434e1] | 363 | endif |
---|
| 364 | |
---|
| 365 | |
---|
[e200b7a] | 366 | end do |
---|
| 367 | end do |
---|
| 368 | |
---|
| 369 | call grib_release(igrib) |
---|
| 370 | goto 10 !! READ NEXT LEVEL OR PARAMETER |
---|
| 371 | ! |
---|
| 372 | ! CLOSING OF INPUT DATA FILE |
---|
| 373 | ! |
---|
| 374 | 50 call grib_close_file(ifile) |
---|
| 375 | |
---|
| 376 | !error message if no fields found with correct first longitude in it |
---|
| 377 | if (gotGrid.eq.0) then |
---|
| 378 | print*,'***ERROR: input file needs to contain GRiB1 formatted'// & |
---|
| 379 | 'messages' |
---|
| 380 | stop |
---|
| 381 | endif |
---|
| 382 | |
---|
| 383 | if(levdiff2.eq.0) then |
---|
| 384 | iwmax=nlev_ec+1 |
---|
| 385 | do i=0,nxn(l)-1 |
---|
| 386 | do j=0,nyn(l)-1 |
---|
| 387 | wwhn(i,j,nlev_ec+1,l)=0. |
---|
| 388 | end do |
---|
| 389 | end do |
---|
| 390 | endif |
---|
| 391 | |
---|
| 392 | do i=0,nxn(l)-1 |
---|
| 393 | do j=0,nyn(l)-1 |
---|
| 394 | surfstrn(i,j,1,n,l)=sqrt(ewss(i,j)**2+nsss(i,j)**2) |
---|
| 395 | end do |
---|
| 396 | end do |
---|
| 397 | |
---|
| 398 | if ((.not.hflswitch).or.(.not.strswitch)) then |
---|
| 399 | write(*,*) 'WARNING: No flux data contained in GRIB file ', & |
---|
| 400 | wfnamen(l,indj) |
---|
| 401 | |
---|
| 402 | ! CALCULATE USTAR AND SSHF USING THE PROFILE METHOD |
---|
| 403 | ! As ECMWF has increased the model resolution, such that now the first model |
---|
| 404 | ! level is at about 10 m (where 10-m wind is given), use the 2nd ECMWF level |
---|
| 405 | ! (3rd model level in FLEXPART) for the profile method |
---|
| 406 | !*************************************************************************** |
---|
| 407 | |
---|
| 408 | do i=0,nxn(l)-1 |
---|
| 409 | do j=0,nyn(l)-1 |
---|
| 410 | plev1=akz(3)+bkz(3)*psn(i,j,1,n,l) |
---|
| 411 | pmean=0.5*(psn(i,j,1,n,l)+plev1) |
---|
| 412 | tv=tthn(i,j,3,n,l)*(1.+0.61*qvhn(i,j,3,n,l)) |
---|
| 413 | fu=-r_air*tv/ga/pmean |
---|
| 414 | hlev1=fu*(plev1-psn(i,j,1,n,l)) ! HEIGTH OF FIRST MODEL LAYER |
---|
| 415 | ff10m= sqrt(u10n(i,j,1,n,l)**2+v10n(i,j,1,n,l)**2) |
---|
| 416 | fflev1=sqrt(uuhn(i,j,3,l)**2+vvhn(i,j,3,l)**2) |
---|
| 417 | call pbl_profile(psn(i,j,1,n,l),td2n(i,j,1,n,l),hlev1, & |
---|
| 418 | tt2n(i,j,1,n,l),tthn(i,j,3,n,l),ff10m,fflev1, & |
---|
| 419 | surfstrn(i,j,1,n,l),sshfn(i,j,1,n,l)) |
---|
| 420 | if(sshfn(i,j,1,n,l).gt.200.) sshfn(i,j,1,n,l)=200. |
---|
| 421 | if(sshfn(i,j,1,n,l).lt.-400.) sshfn(i,j,1,n,l)=-400. |
---|
| 422 | end do |
---|
| 423 | end do |
---|
| 424 | endif |
---|
| 425 | |
---|
| 426 | |
---|
| 427 | ! Assign 10 m wind to model level at eta=1.0 to have one additional model |
---|
| 428 | ! level at the ground |
---|
| 429 | ! Specific humidity is taken the same as at one level above |
---|
| 430 | ! Temperature is taken as 2 m temperature |
---|
| 431 | !************************************************************************** |
---|
| 432 | |
---|
| 433 | do i=0,nxn(l)-1 |
---|
| 434 | do j=0,nyn(l)-1 |
---|
| 435 | uuhn(i,j,1,l)=u10n(i,j,1,n,l) |
---|
| 436 | vvhn(i,j,1,l)=v10n(i,j,1,n,l) |
---|
| 437 | qvhn(i,j,1,n,l)=qvhn(i,j,2,n,l) |
---|
| 438 | tthn(i,j,1,n,l)=tt2n(i,j,1,n,l) |
---|
| 439 | end do |
---|
| 440 | end do |
---|
| 441 | |
---|
| 442 | if(iumax.ne.nuvz-1) stop & |
---|
| 443 | 'READWIND: NUVZ NOT CONSISTENT FOR A NESTING LEVEL' |
---|
| 444 | if(iwmax.ne.nwz) stop & |
---|
| 445 | 'READWIND: NWZ NOT CONSISTENT FOR A NESTING LEVEL' |
---|
| 446 | |
---|
| 447 | end do |
---|
| 448 | |
---|
| 449 | return |
---|
| 450 | 888 write(*,*) ' #### FLEXPART MODEL ERROR! WINDFIELD #### ' |
---|
| 451 | write(*,*) ' #### ',wfnamen(l,indj),' FOR NESTING LEVEL #### ' |
---|
| 452 | write(*,*) ' #### ',l,' IS NOT GRIB FORMAT !!! #### ' |
---|
| 453 | stop 'Execution terminated' |
---|
| 454 | |
---|
| 455 | |
---|
| 456 | 999 write(*,*) ' #### FLEXPART MODEL ERROR! WINDFIELD #### ' |
---|
| 457 | write(*,*) ' #### ',wfnamen(l,indj),' #### ' |
---|
| 458 | write(*,*) ' #### CANNOT BE OPENED FOR NESTING LEVEL ',l,'####' |
---|
| 459 | |
---|
| 460 | end subroutine readwind_nests |
---|