Changeset 24 for trunk/src/readwind.f90


Ignore:
Timestamp:
May 23, 2014, 11:48:41 AM (10 years ago)
Author:
igpis
Message:

version 9.2 beta. Changes from HH, AST, MC, NIK, IP. Changes in vert transform. New SPECIES input includes scavenging coefficients

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/readwind.f90

    r20 r24  
    7171  integer :: iret
    7272  integer :: igrib
    73   integer :: gribVer,parCat,parNum,typSurf,valSurf,discipl
     73  integer :: gribVer,parCat,parNum,typSurf,valSurf,discipl,parId
    7474  integer :: gotGrid
    7575  !HSO  end
     
    9090  integer :: isec1(56),isec2(22+nxmax+nymax)
    9191  real(kind=4) :: zsec4(jpunp)
    92   real(kind=4) :: xaux,yaux,xaux0,yaux0
     92  real(kind=4) :: xaux,yaux
    9393  real(kind=8) :: xauxin,yauxin
    9494  real,parameter :: eps=1.e-4
    9595  real(kind=4) :: nsss(0:nxmax-1,0:nymax-1),ewss(0:nxmax-1,0:nymax-1)
    96   real :: plev1,pmean,tv,fu,hlev1,ff10m,fflev1
     96  real :: plev1,pmean,tv,fu,hlev1,ff10m,fflev1,conversion_factor
    9797
    9898  logical :: hflswitch,strswitch
     
    101101  character(len=24) :: gribErrorMsg = 'Error reading grib file'
    102102  character(len=20) :: gribFunction = 'readwind'
    103 
    104   !HSO conversion of ECMWF etadot to etadot*dp/deta
    105   logical :: etacon=.false.
    106   real,parameter :: p00=101325.
    107   real :: dak,dbk
    108103
    109104  hflswitch=.false.
     
    155150  endif
    156151
     152  conversion_factor=1.
     153
    157154  else
    158155
     
    168165  call grib_check(iret,gribFunction,gribErrorMsg)
    169166  call grib_get_int(igrib,'level',valSurf,iret)
     167  call grib_check(iret,gribFunction,gribErrorMsg)
     168  call grib_get_int(igrib,'paramId',parId,iret)
    170169  call grib_check(iret,gribFunction,gribErrorMsg)
    171170
     
    177176  isec1(8)=-1
    178177  isec1(8)=valSurf     ! level
     178  conversion_factor=1.
    179179  if ((parCat.eq.0).and.(parNum.eq.0).and.(typSurf.eq.105)) then ! T
    180180    isec1(6)=130         ! indicatorOfParameter
     
    188188    isec1(6)=134         ! indicatorOfParameter
    189189  elseif ((parCat.eq.2).and.(parNum.eq.32)) then ! W, actually eta dot
     190    isec1(6)=135         ! indicatorOfParameter
     191  elseif ((parCat.eq.128).and.(parNum.eq.77)) then ! W, actually eta dot
    190192    isec1(6)=135         ! indicatorOfParameter
    191193  elseif ((parCat.eq.3).and.(parNum.eq.0).and.(typSurf.eq.101)) then !SLP
     
    201203  elseif ((parCat.eq.1).and.(parNum.eq.11).and.(typSurf.eq.1)) then ! SD
    202204    isec1(6)=141         ! indicatorOfParameter
    203   elseif ((parCat.eq.6).and.(parNum.eq.1)) then ! CC
     205    conversion_factor=1000.
     206  elseif ((parCat.eq.6).and.(parNum.eq.1) .or. parId .eq. 164) then ! CC
    204207    isec1(6)=164         ! indicatorOfParameter
    205   elseif ((parCat.eq.1).and.(parNum.eq.9)) then ! LSP
     208  elseif ((parCat.eq.1).and.(parNum.eq.9) .or. parId .eq. 142) then ! LSP
    206209    isec1(6)=142         ! indicatorOfParameter
    207210  elseif ((parCat.eq.1).and.(parNum.eq.10)) then ! CP
    208211    isec1(6)=143         ! indicatorOfParameter
     212    conversion_factor=1000.
    209213  elseif ((parCat.eq.0).and.(parNum.eq.11).and.(typSurf.eq.1)) then ! SHF
    210214    isec1(6)=146         ! indicatorOfParameter
    211215  elseif ((parCat.eq.4).and.(parNum.eq.9).and.(typSurf.eq.1)) then ! SR
    212216    isec1(6)=176         ! indicatorOfParameter
    213   elseif ((parCat.eq.2).and.(parNum.eq.17)) then ! EWSS
     217  elseif ((parCat.eq.2).and.(parNum.eq.17) .or. parId .eq. 180) then ! EWSS
    214218    isec1(6)=180         ! indicatorOfParameter
    215   elseif ((parCat.eq.2).and.(parNum.eq.18)) then ! NSSS
     219  elseif ((parCat.eq.2).and.(parNum.eq.18) .or. parId .eq. 181) then ! NSSS
    216220    isec1(6)=181         ! indicatorOfParameter
    217221  elseif ((parCat.eq.3).and.(parNum.eq.4)) then ! ORO
    218222    isec1(6)=129         ! indicatorOfParameter
    219   elseif ((parCat.eq.3).and.(parNum.eq.7)) then ! SDO
     223  elseif ((parCat.eq.3).and.(parNum.eq.7) .or. parId .eq. 160) then ! SDO
    220224    isec1(6)=160         ! indicatorOfParameter
    221225  elseif ((discipl.eq.2).and.(parCat.eq.0).and.(parNum.eq.0).and. &
     
    223227    isec1(6)=172         ! indicatorOfParameter
    224228  else
    225     print*,'***ERROR: undefined GRiB2 message found!',discipl, &
     229    print*,'***WARNING: undefined GRiB2 message found!',discipl, &
    226230         parCat,parNum,typSurf
     231  endif
     232  if(parId .ne. isec1(6) .and. parId .ne. 77) then
     233    write(*,*) 'parId',parId, 'isec1(6)',isec1(6)
     234!    stop
    227235  endif
    228236
     
    237245  !HSO  get the required fields from section 2 in a gribex compatible manner
    238246  if (ifield.eq.1) then
    239   call grib_get_int(igrib,'numberOfPointsAlongAParallel', &
    240        isec2(2),iret)
    241   call grib_check(iret,gribFunction,gribErrorMsg)
    242   call grib_get_int(igrib,'numberOfPointsAlongAMeridian', &
    243        isec2(3),iret)
    244   call grib_check(iret,gribFunction,gribErrorMsg)
    245   call grib_get_int(igrib,'numberOfVerticalCoordinateValues', &
    246        isec2(12))
     247  call grib_get_int(igrib,'numberOfPointsAlongAParallel',isec2(2),iret)
     248  call grib_check(iret,gribFunction,gribErrorMsg)
     249  call grib_get_int(igrib,'numberOfPointsAlongAMeridian',isec2(3),iret)
     250  call grib_check(iret,gribFunction,gribErrorMsg)
     251  call grib_get_int(igrib,'numberOfVerticalCoordinateValues',isec2(12))
    247252  call grib_check(iret,gribFunction,gribErrorMsg)
    248253  ! CHECK GRID SPECIFICATIONS
     
    250255  if(isec2(3).ne.ny) stop 'READWIND: NY NOT CONSISTENT'
    251256  if(isec2(12)/2-1.ne.nlev_ec) &
    252        stop 'READWIND: VERTICAL DISCRETIZATION NOT CONSISTENT'
     257  stop 'READWIND: VERTICAL DISCRETIZATION NOT CONSISTENT'
    253258  endif ! ifield
    254259
    255260  !HSO  get the second part of the grid dimensions only from GRiB1 messages
    256   if ((gribVer.eq.1).and.(gotGrid.eq.0)) then
     261  if (isec1(6) .eq. 167 .and. (gotGrid.eq.0)) then
    257262    call grib_get_real8(igrib,'longitudeOfFirstGridPointInDegrees', &
    258263         xauxin,iret)
     
    261266         yauxin,iret)
    262267    call grib_check(iret,gribFunction,gribErrorMsg)
     268    if (xauxin.gt.180.) xauxin=xauxin-360.0
     269    if (xauxin.lt.-180.) xauxin=xauxin+360.0
     270
    263271    xaux=xauxin+real(nxshift)*dx
    264272    yaux=yauxin
    265     xaux0=xlon0
    266     yaux0=ylat0
    267     if(xaux.lt.0.) xaux=xaux+360.
    268     if(yaux.lt.0.) yaux=yaux+360.
    269     if(xaux0.lt.0.) xaux0=xaux0+360.
    270     if(yaux0.lt.0.) yaux0=yaux0+360.
    271     if(abs(xaux-xaux0).gt.eps) &
    272          stop 'READWIND: LOWER LEFT LONGITUDE NOT CONSISTENT'
    273     if(abs(yaux-yaux0).gt.eps) &
    274          stop 'READWIND: LOWER LEFT LATITUDE NOT CONSISTENT'
     273    if (xaux.gt.180.) xaux=xaux-360.0
     274    if(abs(xaux-xlon0).gt.eps) &
     275    stop 'READWIND: LOWER LEFT LONGITUDE NOT CONSISTENT'
     276    if(abs(yaux-ylat0).gt.eps) &
     277    stop 'READWIND: LOWER LEFT LATITUDE NOT CONSISTENT'
    275278    gotGrid=1
    276279  endif ! gotGrid
     
    298301           zsec4(nxfield*(ny-j-1)+i+1)
    299302      if(isec1(6).eq.141) sd(i,j,1,n)= &!! SNOW DEPTH
    300            zsec4(nxfield*(ny-j-1)+i+1)
     303           zsec4(nxfield*(ny-j-1)+i+1)/conversion_factor
    301304      if(isec1(6).eq.151) msl(i,j,1,n)= &!! SEA LEVEL PRESS.
    302305           zsec4(nxfield*(ny-j-1)+i+1)
     
    316319      endif
    317320      if(isec1(6).eq.143) then                      !! CONVECTIVE PREC.
    318         convprec(i,j,1,n)=zsec4(nxfield*(ny-j-1)+i+1)
     321        convprec(i,j,1,n)=zsec4(nxfield*(ny-j-1)+i+1)/conversion_factor
    319322        if (convprec(i,j,1,n).lt.0.) convprec(i,j,1,n)=0.
    320323      endif
     
    366369      do j=0,nymin1
    367370        wwh(i,j,nlev_ec+1)=0.
    368       end do
    369     end do
    370   endif
    371 
    372   ! convert from ECMWF etadot to etadot*dp/deta as needed by FLEXPART
    373   if(etacon.eqv..true.) then
    374     do k=1,nwzmax
    375       dak=akm(k+1)-akm(k)
    376       dbk=bkm(k+1)-bkm(k)
    377       do i=0,nxmin1
    378         do j=0,nymin1
    379           wwh(i,j,k)=2*wwh(i,j,k)*ps(i,j,1,n)*(dak/ps(i,j,1,n)+dbk)/(dak/p00+dbk)
    380           if (k.gt.1) then
    381             wwh(i,j,k)=wwh(i,j,k)-wwh(i,j,k-1)
    382           endif
    383         end do
    384371      end do
    385372    end do
     
    479466
    480467end subroutine readwind
     468
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG