!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer,
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer
!version 3 or (at your option) any later version that should be found at:
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software;
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec),
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
!

      subroutine mach3(pgd,kni,knj,knk,knip,knjp) 22,1
!
#if defined (DOC)
!
!s/r mach3 : Apply mach on all levels of the XD-Var input 3D field with given structure. 
!
!     Author L. Fillion  - ARMA/MSC - 5 Apr 05
!Revision:
!
#endif
      IMPLICIT NONE
      integer kni,knj,knk,knip,knjp
      real*8 pgd(kni,knk,knj)
!
#include "taglam4d.cdk"
#include "comlun.cdk"
!
      integer ji,jj,jk
      real*8 zwh(kni,knj)
!
!!
      do jk=1,knk
        do ji=1,kni
        do jj=1,knj
          zwh(ji,jj)=pgd(ji,jk,jj)
        enddo
        enddo
!
        call mach2(zwh,kni,knj,knip,knjp) 
!
        do ji=1,kni
        do jj=1,knj
          pgd(ji,jk,jj)=zwh(ji,jj)
        enddo
        enddo
      enddo
!
      return
      end