Index: src/readwind.f90
===================================================================
--- src/readwind.f90	(revision 31674b5436c9f947856a157411d362718a307aa9)
+++ src/readwind.f90	(revision 3c1da523f53497adfac8379a95ba9e93216ad2c3)
@@ -40,4 +40,6 @@
   !   Variables tth and qvh (on eta coordinates) in common block
   ! 2/2015, PS: add missing paramter iret in call to grib subr
+  ! 3/2015, PS: add some verbosity messages
+  ! 3/2015, PS: add GRIB2 coding for deta/dt dp/deta used by ZAMG
   !
   !**********************************************************************
@@ -113,5 +115,9 @@
   ! OPENING OF DATA FILE (GRIB CODE)
   !
-5   call grib_open_file(ifile,path(3)(1:length(3)) &
+  
+5 continue
+  call verboutput(verbosity,1,'      call grib_open_file '//path(3)(1:length(3))&
+         //trim(wfname(indj)))
+  call grib_open_file(ifile,path(3)(1:length(3)) &
          //trim(wfname(indj)),'r',iret)
   if (iret.ne.GRIB_SUCCESS) then
@@ -127,4 +133,5 @@
   ! GET NEXT FIELDS
   !
+  call verboutput(verbosity,2,'      call grib_new_from_file')
   call grib_new_from_file(ifile,igrib,iret)
   if (iret.eq.GRIB_END_OF_FILE)  then
@@ -135,107 +142,116 @@
 
   !first see if we read GRIB1 or GRIB2
+  call verboutput(verbosity,2,'      call grib_get_int')
   call grib_get_int(igrib,'editionNumber',gribVer,iret)
+  call verboutput(verbosity,2,'      call grib_check')
   call grib_check(iret,gribFunction,gribErrorMsg)
 
   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.
-
-  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)
-!    stop
-  endif
-
-  endif
+    !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 ! GRIB 2
+
+    !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 detadtdpdeta
+      isec1(6)=135         ! indicatorOfParameter
+    elseif ((parCat.eq.128).and.(parNum.eq.77)) then ! W, actually detadtdpdeta
+      isec1(6)=135         ! indicatorOfParameter
+    elseif ((parCat.eq.2).and.(parNum.eq.8)) then ! Omega, actually detadtdpdeta
+      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 ! end GRIB 1 / GRIB 2 cases
 
   !HSO  get the size and data of the values array
@@ -351,4 +367,5 @@
   end do
 
+  call verboutput(verbosity,2,'      call grib_release')
   call grib_release(igrib)
   goto 10                      !! READ NEXT LEVEL OR PARAMETER
@@ -380,4 +397,5 @@
 
   if (xglobal) then
+    call verboutput(verbosity,2,'      call shift_field_0')
     call shift_field_0(ewss,nxfield,ny)
     call shift_field_0(nsss,nxfield,ny)
@@ -429,4 +447,5 @@
         ff10m= sqrt(u10(i,j,1,n)**2+v10(i,j,1,n)**2)
         fflev1=sqrt(uuh(i,j,3)**2+vvh(i,j,3)**2)
+        call verboutput(verbosity,2,'      call pbl_profile')
         call pbl_profile(ps(i,j,1,n),td2(i,j,1,n),hlev1, &
              tt2(i,j,1,n),tth(i,j,3,n),ff10m,fflev1, &
@@ -457,5 +476,7 @@
   if(iwmax.ne.nwz)    stop 'READWIND: NWZ NOT CONSISTENT'
 
+  call verboutput(verbosity,1,'      leaving readwind')
   return
+
 888   write(*,*) ' #### FLEXPART MODEL ERROR! WINDFIELD         #### '
   write(*,*) ' #### ',wfname(indj),'                    #### '
