Index: src/readwind.f90
===================================================================
--- src/readwind.f90	(revision 4fbe7a5609fe43bdc3940768d8f4d949237cc44a)
+++ src/readwind.f90	(revision 8a65cb0801b09eb0ae933a1afabbe10361a9021b)
@@ -22,44 +22,44 @@
 subroutine readwind(indj,n,uuh,vvh,wwh)
 
-  !**********************************************************************
-  !                                                                     *
-  !             TRAJECTORY MODEL SUBROUTINE READWIND                    *
-  !                                                                     *
-  !**********************************************************************
-  !                                                                     *
-  !             AUTHOR:      G. WOTAWA                                  *
-  !             DATE:        1997-08-05                                 *
-  !             LAST UPDATE: 2000-10-17, Andreas Stohl                  *
-  !             CHANGE: 11/01/2008, Harald Sodemann, GRIB1/2 input with *
-  !                                 ECMWF grib_api                      *
-  !             CHANGE: 03/12/2008, Harald Sodemann, update to f90 with *
-  !                                 ECMWF grib_api                      *
-  !                                                                     *
-  !**********************************************************************
-  !  Changes, Bernd C. Krueger, Feb. 2001:
-  !   Variables tth and qvh (on eta coordinates) in common block
-  !**********************************************************************
-  !                                                                     *
-  ! DESCRIPTION:                                                        *
-  !                                                                     *
-  ! READING OF ECMWF METEOROLOGICAL FIELDS FROM INPUT DATA FILES. THE   *
-  ! INPUT DATA FILES ARE EXPECTED TO BE AVAILABLE IN GRIB CODE          *
-  !                                                                     *
-  ! INPUT:                                                              *
-  ! indj               indicates number of the wind field to be read in *
-  ! n                  temporal index for meteorological fields (1 to 3)*
-  !                                                                     *
-  ! IMPORTANT VARIABLES FROM COMMON BLOCK:                              *
-  !                                                                     *
-  ! wfname             File name of data to be read in                  *
-  ! nx,ny,nuvz,nwz     expected field dimensions                        *
-  ! nlev_ec            number of vertical levels ecmwf model            *
-  ! uu,vv,ww           wind fields                                      *
-  ! tt,qv              temperature and specific humidity                *
-  ! ps                 surface pressure                                 *
-  !                                                                     *
-  !**********************************************************************
-
-  use GRIB_API
+!**********************************************************************
+!                                                                     *
+!             TRAJECTORY MODEL SUBROUTINE READWIND                    *
+!                                                                     *
+!**********************************************************************
+!                                                                     *
+!             AUTHOR:      G. WOTAWA                                  *
+!             DATE:        1997-08-05                                 *
+!             LAST UPDATE: 2000-10-17, Andreas Stohl                  *
+!             CHANGE: 11/01/2008, Harald Sodemann, GRIB1/2 input with *
+!                                 ECMWF grib_api                      *
+!             CHANGE: 03/12/2008, Harald Sodemann, update to f90 with *
+!                                 ECMWF grib_api                      *
+!                                                                     *
+!**********************************************************************
+!  Changes, Bernd C. Krueger, Feb. 2001:
+!   Variables tth and qvh (on eta coordinates) in common block
+!**********************************************************************
+!                                                                     *
+! DESCRIPTION:                                                        *
+!                                                                     *
+! READING OF ECMWF METEOROLOGICAL FIELDS FROM INPUT DATA FILES. THE   *
+! INPUT DATA FILES ARE EXPECTED TO BE AVAILABLE IN GRIB CODE          *
+!                                                                     *
+! INPUT:                                                              *
+! indj               indicates number of the wind field to be read in *
+! n                  temporal index for meteorological fields (1 to 3)*
+!                                                                     *
+! IMPORTANT VARIABLES FROM COMMON BLOCK:                              *
+!                                                                     *
+! wfname             File name of data to be read in                  *
+! nx,ny,nuvz,nwz     expected field dimensions                        *
+! nlev_ec            number of vertical levels ecmwf model            *
+! uu,vv,ww           wind fields                                      *
+! tt,qv              temperature and specific humidity                *
+! ps                 surface pressure                                 *
+!                                                                     *
+!**********************************************************************
+
+  use grib_api
   use par_mod
   use com_mod
@@ -67,5 +67,7 @@
   implicit none
 
-  !HSO  parameters for grib_api
+!  include 'grib_api.h'
+
+!HSO  parameters for grib_api
   integer :: ifile
   integer :: iret
@@ -73,5 +75,5 @@
   integer :: gribVer,parCat,parNum,typSurf,valSurf,discipl,parId
   integer :: gotGrid
-  !HSO  end
+!HSO  end
 
   real(kind=4) :: uuh(0:nxmax-1,0:nymax-1,nuvzmax)
@@ -80,15 +82,15 @@
   integer :: indj,i,j,k,n,levdiff2,ifield,iumax,iwmax
 
-  ! VARIABLES AND ARRAYS NEEDED FOR GRIB DECODING
-
-  ! dimension of isec2 at least (22+n), where n is the number of parallels or
-  ! meridians in a quasi-regular (reduced) Gaussian or lat/long grid
-
-  ! dimension of zsec2 at least (10+nn), where nn is the number of vertical
-  ! coordinate parameters
+! VARIABLES AND ARRAYS NEEDED FOR GRIB DECODING
+
+! dimension of isec2 at least (22+n), where n is the number of parallels or
+! meridians in a quasi-regular (reduced) Gaussian or lat/long grid
+
+! dimension of zsec2 at least (10+nn), where nn is the number of vertical
+! coordinate parameters
 
   integer :: isec1(56),isec2(22+nxmax+nymax)
   real(kind=4) :: zsec4(jpunp)
-  real(kind=4) :: xaux,yaux
+  real(kind=4) :: xaux,yaux,xaux0,yaux0
   real(kind=8) :: xauxin,yauxin
   real,parameter :: eps=1.e-4
@@ -96,7 +98,7 @@
   real :: plev1,pmean,tv,fu,hlev1,ff10m,fflev1,conversion_factor
 
-  logical :: hflswitch,strswitch
-
-  !HSO  grib api error messages
+  logical :: hflswitch,strswitch, readcloud
+
+!HSO  grib api error messages
   character(len=24) :: gribErrorMsg = 'Error reading grib file'
   character(len=20) :: gribFunction = 'readwind'
@@ -104,25 +106,28 @@
   hflswitch=.false.
   strswitch=.false.
+!hg
+  readcloud=.false.
+!hg end
   levdiff2=nlev_ec-nwz+1
   iumax=0
   iwmax=0
 
-  !
-  ! OPENING OF DATA FILE (GRIB CODE)
-  !
-5   call grib_open_file(ifile,path(3)(1:length(3)) &
-         //trim(wfname(indj)),'r',iret)
+!
+! OPENING OF DATA FILE (GRIB CODE)
+!
+5 call grib_open_file(ifile,path(3)(1:length(3)) &
+       //trim(wfname(indj)),'r',iret)
   if (iret.ne.GRIB_SUCCESS) then
     goto 888   ! ERROR DETECTED
   endif
-  !turn on support for multi fields messages */
-  !call grib_multi_support_on
+!turn on support for multi fields messages */
+!call grib_multi_support_on
 
   gotGrid=0
   ifield=0
-10   ifield=ifield+1
-  !
-  ! GET NEXT FIELDS
-  !
+10 ifield=ifield+1
+!
+! GET NEXT FIELDS
+!
   call grib_new_from_file(ifile,igrib,iret)
   if (iret.eq.GRIB_END_OF_FILE)  then
@@ -132,5 +137,5 @@
   endif
 
-  !first see if we read GRIB1 or GRIB2
+!first see if we read GRIB1 or GRIB2
   call grib_get_int(igrib,'editionNumber',gribVer,iret)
   call grib_check(iret,gribFunction,gribErrorMsg)
@@ -138,104 +143,110 @@
   if (gribVer.eq.1) then ! GRIB Edition 1
 
-  !print*,'GRiB Edition 1'
-  !read the grib2 identifiers
-  call grib_get_int(igrib,'indicatorOfParameter',isec1(6),iret)
-  call grib_check(iret,gribFunction,gribErrorMsg)
-  call grib_get_int(igrib,'level',isec1(8),iret)
-  call grib_check(iret,gribFunction,gribErrorMsg)
-
-  !change code for etadot to code for omega
-  if (isec1(6).eq.77) then
-    isec1(6)=135
-  endif
-
-  conversion_factor=1.
+!print*,'GRiB Edition 1'
+!read the grib2 identifiers
+    call grib_get_int(igrib,'indicatorOfParameter',isec1(6),iret)
+    call grib_check(iret,gribFunction,gribErrorMsg)
+    call grib_get_int(igrib,'level',isec1(8),iret)
+    call grib_check(iret,gribFunction,gribErrorMsg)
+
+!change code for etadot to code for omega
+    if (isec1(6).eq.77) then
+      isec1(6)=135
+    endif
+
+    conversion_factor=1.
 
   else
 
-  !print*,'GRiB Edition 2'
-  !read the grib2 identifiers
-  call grib_get_int(igrib,'discipline',discipl,iret)
-  call grib_check(iret,gribFunction,gribErrorMsg)
-  call grib_get_int(igrib,'parameterCategory',parCat,iret)
-  call grib_check(iret,gribFunction,gribErrorMsg)
-  call grib_get_int(igrib,'parameterNumber',parNum,iret)
-  call grib_check(iret,gribFunction,gribErrorMsg)
-  call grib_get_int(igrib,'typeOfFirstFixedSurface',typSurf,iret)
-  call grib_check(iret,gribFunction,gribErrorMsg)
-  call grib_get_int(igrib,'level',valSurf,iret)
-  call grib_check(iret,gribFunction,gribErrorMsg)
-  call grib_get_int(igrib,'paramId',parId,iret)
-  call grib_check(iret,gribFunction,gribErrorMsg)
-
-  !print*,discipl,parCat,parNum,typSurf,valSurf
-
-  !convert to grib1 identifiers
-  isec1(6)=-1
-  isec1(7)=-1
-  isec1(8)=-1
-  isec1(8)=valSurf     ! level
-  conversion_factor=1.
-  if ((parCat.eq.0).and.(parNum.eq.0).and.(typSurf.eq.105)) then ! T
-    isec1(6)=130         ! indicatorOfParameter
-  elseif ((parCat.eq.2).and.(parNum.eq.2).and.(typSurf.eq.105)) then ! U
-    isec1(6)=131         ! indicatorOfParameter
-  elseif ((parCat.eq.2).and.(parNum.eq.3).and.(typSurf.eq.105)) then ! V
-    isec1(6)=132         ! indicatorOfParameter
-  elseif ((parCat.eq.1).and.(parNum.eq.0).and.(typSurf.eq.105)) then ! Q
-    isec1(6)=133         ! indicatorOfParameter
-  elseif ((parCat.eq.3).and.(parNum.eq.0).and.(typSurf.eq.1)) then !SP
-    isec1(6)=134         ! indicatorOfParameter
-  elseif ((parCat.eq.2).and.(parNum.eq.32)) then ! W, actually eta dot
-    isec1(6)=135         ! indicatorOfParameter
-  elseif ((parCat.eq.128).and.(parNum.eq.77)) then ! W, actually eta dot
-    isec1(6)=135         ! indicatorOfParameter
-  elseif ((parCat.eq.3).and.(parNum.eq.0).and.(typSurf.eq.101)) then !SLP
-    isec1(6)=151         ! indicatorOfParameter
-  elseif ((parCat.eq.2).and.(parNum.eq.2).and.(typSurf.eq.103)) then ! 10U
-    isec1(6)=165         ! indicatorOfParameter
-  elseif ((parCat.eq.2).and.(parNum.eq.3).and.(typSurf.eq.103)) then ! 10V
-    isec1(6)=166         ! indicatorOfParameter
-  elseif ((parCat.eq.0).and.(parNum.eq.0).and.(typSurf.eq.103)) then ! 2T
-    isec1(6)=167         ! indicatorOfParameter
-  elseif ((parCat.eq.0).and.(parNum.eq.6).and.(typSurf.eq.103)) then ! 2D
-    isec1(6)=168         ! indicatorOfParameter
-  elseif ((parCat.eq.1).and.(parNum.eq.11).and.(typSurf.eq.1)) then ! SD
-    isec1(6)=141         ! indicatorOfParameter
-    conversion_factor=1000.
-  elseif ((parCat.eq.6).and.(parNum.eq.1) .or. parId .eq. 164) then ! CC
-    isec1(6)=164         ! indicatorOfParameter
-  elseif ((parCat.eq.1).and.(parNum.eq.9) .or. parId .eq. 142) then ! LSP
-    isec1(6)=142         ! indicatorOfParameter
-  elseif ((parCat.eq.1).and.(parNum.eq.10)) then ! CP
-    isec1(6)=143         ! indicatorOfParameter
-    conversion_factor=1000.
-  elseif ((parCat.eq.0).and.(parNum.eq.11).and.(typSurf.eq.1)) then ! SHF
-    isec1(6)=146         ! indicatorOfParameter
-  elseif ((parCat.eq.4).and.(parNum.eq.9).and.(typSurf.eq.1)) then ! SR
-    isec1(6)=176         ! indicatorOfParameter
-  elseif ((parCat.eq.2).and.(parNum.eq.17) .or. parId .eq. 180) then ! EWSS
-    isec1(6)=180         ! indicatorOfParameter
-  elseif ((parCat.eq.2).and.(parNum.eq.18) .or. parId .eq. 181) then ! NSSS
-    isec1(6)=181         ! indicatorOfParameter
-  elseif ((parCat.eq.3).and.(parNum.eq.4)) then ! ORO
-    isec1(6)=129         ! indicatorOfParameter
-  elseif ((parCat.eq.3).and.(parNum.eq.7) .or. parId .eq. 160) then ! SDO
-    isec1(6)=160         ! indicatorOfParameter
-  elseif ((discipl.eq.2).and.(parCat.eq.0).and.(parNum.eq.0).and. &
-       (typSurf.eq.1)) then ! LSM
-    isec1(6)=172         ! indicatorOfParameter
-  else
-    print*,'***WARNING: undefined GRiB2 message found!',discipl, &
-         parCat,parNum,typSurf
-  endif
-  if(parId .ne. isec1(6) .and. parId .ne. 77) then
-    write(*,*) 'parId',parId, 'isec1(6)',isec1(6)
+!print*,'GRiB Edition 2'
+!read the grib2 identifiers
+    call grib_get_int(igrib,'discipline',discipl,iret)
+    call grib_check(iret,gribFunction,gribErrorMsg)
+    call grib_get_int(igrib,'parameterCategory',parCat,iret)
+    call grib_check(iret,gribFunction,gribErrorMsg)
+    call grib_get_int(igrib,'parameterNumber',parNum,iret)
+    call grib_check(iret,gribFunction,gribErrorMsg)
+    call grib_get_int(igrib,'typeOfFirstFixedSurface',typSurf,iret)
+    call grib_check(iret,gribFunction,gribErrorMsg)
+    call grib_get_int(igrib,'level',valSurf,iret)
+    call grib_check(iret,gribFunction,gribErrorMsg)
+    call grib_get_int(igrib,'paramId',parId,iret)
+    call grib_check(iret,gribFunction,gribErrorMsg)
+
+!print*,discipl,parCat,parNum,typSurf,valSurf
+
+!convert to grib1 identifiers
+    isec1(6)=-1
+    isec1(7)=-1
+    isec1(8)=-1
+    isec1(8)=valSurf     ! level
+    conversion_factor=1.
+    if ((parCat.eq.0).and.(parNum.eq.0).and.(typSurf.eq.105)) then ! T
+      isec1(6)=130         ! indicatorOfParameter
+    elseif ((parCat.eq.2).and.(parNum.eq.2).and.(typSurf.eq.105)) then ! U
+      isec1(6)=131         ! indicatorOfParameter
+    elseif ((parCat.eq.2).and.(parNum.eq.3).and.(typSurf.eq.105)) then ! V
+      isec1(6)=132         ! indicatorOfParameter
+    elseif ((parCat.eq.1).and.(parNum.eq.0).and.(typSurf.eq.105)) then ! Q
+      isec1(6)=133         ! indicatorOfParameter
+!hg
+    elseif ((parCat.eq.1).and.(parNum.eq.83).and.(typSurf.eq.105)) then ! clwc
+      isec1(6)=246         ! indicatorOfParameter
+    elseif ((parCat.eq.1).and.(parNum.eq.84).and.(typSurf.eq.105)) then ! ciwc
+      isec1(6)=247         ! indicatorOfParameter
+ !hg end
+    elseif ((parCat.eq.3).and.(parNum.eq.0).and.(typSurf.eq.1)) then !SP
+      isec1(6)=134         ! indicatorOfParameter
+    elseif ((parCat.eq.2).and.(parNum.eq.32)) then ! W, actually eta dot
+      isec1(6)=135         ! indicatorOfParameter
+    elseif ((parCat.eq.128).and.(parNum.eq.77)) then ! W, actually eta dot
+      isec1(6)=135         ! indicatorOfParameter
+    elseif ((parCat.eq.3).and.(parNum.eq.0).and.(typSurf.eq.101)) then !SLP
+      isec1(6)=151         ! indicatorOfParameter
+    elseif ((parCat.eq.2).and.(parNum.eq.2).and.(typSurf.eq.103)) then ! 10U
+      isec1(6)=165         ! indicatorOfParameter
+    elseif ((parCat.eq.2).and.(parNum.eq.3).and.(typSurf.eq.103)) then ! 10V
+      isec1(6)=166         ! indicatorOfParameter
+    elseif ((parCat.eq.0).and.(parNum.eq.0).and.(typSurf.eq.103)) then ! 2T
+      isec1(6)=167         ! indicatorOfParameter
+    elseif ((parCat.eq.0).and.(parNum.eq.6).and.(typSurf.eq.103)) then ! 2D
+      isec1(6)=168         ! indicatorOfParameter
+    elseif ((parCat.eq.1).and.(parNum.eq.11).and.(typSurf.eq.1)) then ! SD
+      isec1(6)=141         ! indicatorOfParameter
+      conversion_factor=1000.
+    elseif ((parCat.eq.6).and.(parNum.eq.1) .or. parId .eq. 164) then ! CC
+      isec1(6)=164         ! indicatorOfParameter
+    elseif ((parCat.eq.1).and.(parNum.eq.9) .or. parId .eq. 142) then ! LSP
+      isec1(6)=142         ! indicatorOfParameter
+    elseif ((parCat.eq.1).and.(parNum.eq.10)) then ! CP
+      isec1(6)=143         ! indicatorOfParameter
+      conversion_factor=1000.
+    elseif ((parCat.eq.0).and.(parNum.eq.11).and.(typSurf.eq.1)) then ! SHF
+      isec1(6)=146         ! indicatorOfParameter
+    elseif ((parCat.eq.4).and.(parNum.eq.9).and.(typSurf.eq.1)) then ! SR
+      isec1(6)=176         ! indicatorOfParameter
+    elseif ((parCat.eq.2).and.(parNum.eq.17) .or. parId .eq. 180) then ! EWSS
+      isec1(6)=180         ! indicatorOfParameter
+    elseif ((parCat.eq.2).and.(parNum.eq.18) .or. parId .eq. 181) then ! NSSS
+      isec1(6)=181         ! indicatorOfParameter
+    elseif ((parCat.eq.3).and.(parNum.eq.4)) then ! ORO
+      isec1(6)=129         ! indicatorOfParameter
+    elseif ((parCat.eq.3).and.(parNum.eq.7) .or. parId .eq. 160) then ! SDO
+      isec1(6)=160         ! indicatorOfParameter
+    elseif ((discipl.eq.2).and.(parCat.eq.0).and.(parNum.eq.0).and. &
+         (typSurf.eq.1)) then ! LSM
+      isec1(6)=172         ! indicatorOfParameter
+    else
+      print*,'***WARNING: undefined GRiB2 message found!',discipl, &
+           parCat,parNum,typSurf
+    endif
+    if(parId .ne. isec1(6) .and. parId .ne. 77) then
+      write(*,*) 'parId',parId, 'isec1(6)',isec1(6)
 !    stop
-  endif
-
-  endif
-
-  !HSO  get the size and data of the values array
+    endif
+
+  endif
+
+!HSO  get the size and data of the values array
   if (isec1(6).ne.-1) then
     call grib_get_real4_array(igrib,'values',zsec4,iret)
@@ -243,20 +254,20 @@
   endif
 
-  !HSO  get the required fields from section 2 in a gribex compatible manner
+!HSO  get the required fields from section 2 in a gribex compatible manner
   if (ifield.eq.1) then
-  call grib_get_int(igrib,'numberOfPointsAlongAParallel',isec2(2),iret)
-  call grib_check(iret,gribFunction,gribErrorMsg)
-  call grib_get_int(igrib,'numberOfPointsAlongAMeridian',isec2(3),iret)
-  call grib_check(iret,gribFunction,gribErrorMsg)
-  call grib_get_int(igrib,'numberOfVerticalCoordinateValues',isec2(12))
-  call grib_check(iret,gribFunction,gribErrorMsg)
-  ! CHECK GRID SPECIFICATIONS
-  if(isec2(2).ne.nxfield) stop 'READWIND: NX NOT CONSISTENT'
-  if(isec2(3).ne.ny) stop 'READWIND: NY NOT CONSISTENT'
-  if(isec2(12)/2-1.ne.nlev_ec) &
-  stop 'READWIND: VERTICAL DISCRETIZATION NOT CONSISTENT'
+    call grib_get_int(igrib,'numberOfPointsAlongAParallel',isec2(2),iret)
+    call grib_check(iret,gribFunction,gribErrorMsg)
+    call grib_get_int(igrib,'numberOfPointsAlongAMeridian',isec2(3),iret)
+    call grib_check(iret,gribFunction,gribErrorMsg)
+    call grib_get_int(igrib,'numberOfVerticalCoordinateValues',isec2(12))
+    call grib_check(iret,gribFunction,gribErrorMsg)
+! CHECK GRID SPECIFICATIONS
+    if(isec2(2).ne.nxfield) stop 'READWIND: NX NOT CONSISTENT'
+    if(isec2(3).ne.ny) stop 'READWIND: NY NOT CONSISTENT'
+    if(isec2(12)/2-1.ne.nlev_ec) &
+         stop 'READWIND: VERTICAL DISCRETIZATION NOT CONSISTENT'
   endif ! ifield
 
-  !HSO  get the second part of the grid dimensions only from GRiB1 messages
+!HSO  get the second part of the grid dimensions only from GRiB1 messages
   if (isec1(6) .eq. 167 .and. (gotGrid.eq.0)) then
     call grib_get_real8(igrib,'longitudeOfFirstGridPointInDegrees', &
@@ -273,7 +284,7 @@
     if (xaux.gt.180.) xaux=xaux-360.0
     if(abs(xaux-xlon0).gt.eps) &
-    stop 'READWIND: LOWER LEFT LONGITUDE NOT CONSISTENT'
+         stop 'READWIND: LOWER LEFT LONGITUDE NOT CONSISTENT'
     if(abs(yaux-ylat0).gt.eps) &
-    stop 'READWIND: LOWER LEFT LATITUDE NOT CONSISTENT'
+         stop 'READWIND: LOWER LEFT LATITUDE NOT CONSISTENT'
     gotGrid=1
   endif ! gotGrid
@@ -292,6 +303,6 @@
         if (qvh(i,j,nlev_ec-k+2,n) .lt. 0.) &
              qvh(i,j,nlev_ec-k+2,n) = 0.
-  !        this is necessary because the gridded data may contain
-  !        spurious negative values
+!        this is necessary because the gridded data may contain
+!        spurious negative values
       endif
       if(isec1(6).eq.134) ps(i,j,1,n)= &!! SURF. PRESS.
@@ -336,5 +347,5 @@
       if(((isec1(6).eq.180).or.(isec1(6).eq.181)).and. &
            (zsec4(nxfield*(ny-j-1)+i+1).ne.0.)) strswitch=.true.    ! stress available
-  !sec        strswitch=.true.
+!sec        strswitch=.true.
       if(isec1(6).eq.129) oro(i,j)= &!! ECMWF OROGRAPHY
            zsec4(nxfield*(ny-j-1)+i+1)/ga
@@ -345,4 +356,16 @@
       if(isec1(6).eq.131) iumax=max(iumax,nlev_ec-k+1)
       if(isec1(6).eq.135) iwmax=max(iwmax,nlev_ec-k+1)
+!hg READING CLOUD FIELDS ASWELL
+      if(isec1(6).eq.246) then  !! CLWC  Cloud liquid water content
+        clwch(i,j,nlev_ec-k+2,n)=zsec4(nxfield*(ny-j-1)+i+1)
+        readclouds = .true.
+        !write(*,*) 'found water!'
+      endif
+
+      if(isec1(6).eq.247) then  !! CIWC  Cloud ice water content
+        ciwch(i,j,nlev_ec-k+2,n)=zsec4(nxfield*(ny-j-1)+i+1)
+        !write(*,*) 'found ice!'
+      endif
+!hg end
 
     end do
@@ -351,11 +374,12 @@
   call grib_release(igrib)
   goto 10                      !! READ NEXT LEVEL OR PARAMETER
-  !
-  ! CLOSING OF INPUT DATA FILE
-  !
-
-50   call grib_close_file(ifile)
-
-  !error message if no fields found with correct first longitude in it
+!
+! CLOSING OF INPUT DATA FILE
+!
+
+50 call grib_close_file(ifile)
+
+
+!error message if no fields found with correct first longitude in it
   if (gotGrid.eq.0) then
     print*,'***ERROR: input file needs to contain GRiB1 formatted'// &
@@ -373,7 +397,7 @@
   endif
 
-  ! For global fields, assign the leftmost data column also to the rightmost
-  ! data column; if required, shift whole grid by nxshift grid points
-  !*************************************************************************
+! For global fields, assign the leftmost data column also to the rightmost
+! data column; if required, shift whole grid by nxshift grid points
+!*************************************************************************
 
   if (xglobal) then
@@ -400,4 +424,9 @@
     call shift_field(vvh,nxfield,ny,nuvzmax,nuvz,1,1)
     call shift_field(wwh,nxfield,ny,nwzmax,nwz,1,1)
+!hg
+    call shift_field(clwch,nxfield,ny,nuvzmax,nuvz,2,n)
+    call shift_field(ciwch,nxfield,ny,nuvzmax,nuvz,2,n)
+!hg end
+
   endif
 
@@ -412,9 +441,9 @@
          wfname(indj)
 
-  ! CALCULATE USTAR AND SSHF USING THE PROFILE METHOD
-  ! As ECMWF has increased the model resolution, such that now the first model
-  ! level is at about 10 m (where 10-m wind is given), use the 2nd ECMWF level
-  ! (3rd model level in FLEXPART) for the profile method
-  !***************************************************************************
+! CALCULATE USTAR AND SSHF USING THE PROFILE METHOD
+! As ECMWF has increased the model resolution, such that now the first model
+! level is at about 10 m (where 10-m wind is given), use the 2nd ECMWF level
+! (3rd model level in FLEXPART) for the profile method
+!***************************************************************************
 
     do i=0,nxmin1
@@ -437,18 +466,18 @@
 
 
-  ! Assign 10 m wind to model level at eta=1.0 to have one additional model
-  ! level at the ground
-  ! Specific humidity is taken the same as at one level above
-  ! Temperature is taken as 2 m temperature
-  !**************************************************************************
-
-     do i=0,nxmin1
-        do j=0,nymin1
-           uuh(i,j,1)=u10(i,j,1,n)
-           vvh(i,j,1)=v10(i,j,1,n)
-           qvh(i,j,1,n)=qvh(i,j,2,n)
-           tth(i,j,1,n)=tt2(i,j,1,n)
-        end do
-     end do
+! Assign 10 m wind to model level at eta=1.0 to have one additional model
+! level at the ground
+! Specific humidity is taken the same as at one level above
+! Temperature is taken as 2 m temperature
+!**************************************************************************
+
+  do i=0,nxmin1
+    do j=0,nymin1
+      uuh(i,j,1)=u10(i,j,1,n)
+      vvh(i,j,1)=v10(i,j,1,n)
+      qvh(i,j,1,n)=qvh(i,j,2,n)
+      tth(i,j,1,n)=tt2(i,j,1,n)
+    end do
+  end do
 
   if(iumax.ne.nuvz-1) stop 'READWIND: NUVZ NOT CONSISTENT'
@@ -456,12 +485,9 @@
 
   return
-888   write(*,*) ' #### FLEXPART MODEL ERROR! WINDFIELD         #### '
+
+888 write(*,*) ' #### FLEXPART MODEL ERROR! WINDFIELD         #### '
   write(*,*) ' #### ',wfname(indj),'                    #### '
   write(*,*) ' #### IS NOT GRIB FORMAT !!!                  #### '
   stop 'Execution terminated'
-999   write(*,*) ' #### FLEXPART MODEL ERROR! WINDFIELD         #### '
-  write(*,*) ' #### ',wfname(indj),'                    #### '
-  write(*,*) ' #### CANNOT BE OPENED !!!                    #### '
-  stop 'Execution terminated'
 
 end subroutine readwind
