!-------------------------------------- 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 --------------------------------------
!
!
! X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
!
subroutine symmetrize(pout,pin,kni,knj,knk) 10,1
!
!**s/r symmetrize - Extend symmetrically outside 2 grid point all around
! LAM-boundary ready for finite differences up to 2nd order.
! N.B.: The fields are periodic on ni+1 points for instance;
! but the LAM-fields only contain "ni" points without explicit periodicity.
!
!Author : Luc Fillion - MSC/CAN - 12 Oct 04.
!Revision: Luc Fillion - EC/CAN - 19 Sept 08. Add documentation lines above on periodicity.
!
! -------------------
!
!Arguments
!
IMPLICIT NONE
#include "taglam4d.cdk"
#include "comdim.cdk"
#include "comcst.cdk"
#include "comct0.cdk"
#include "comsim.cdk"
!
integer kni,knj,knk
real*8 pout(-1:kni+2,knk,-1:knj+2)
real*8 pin(kni,knk,knj)
!
integer ji,jj,jk,idum1,idum2,idum3,idum4
INTEGER myid,numthd,omp_get_thread_num,omp_get_num_threads
real*8 zmin,zmax
!
!!
call zero
((kni+4)*(knj+4)*knk,pout)
!
do jk=1,knk
do jj=1,knj
do ji=1,kni
pout(ji,jk,jj)=pin(ji,jk,jj)
enddo
enddo
enddo
!
! symmetrize
!
!$OMP PARALLEL PRIVATE(ji,jj,jk,myid,numthd)
myid=omp_get_thread_num()+1
numthd=omp_get_num_threads()
do jk = myid,nflev,numthd
do ji=1,kni
pout(ji,jk,0)=pout(ji,jk,knj) ! South Boundary
pout(ji,jk,-1)=pout(ji,jk,knj-1) ! South Boundary
enddo
!
do jj=-1,knj
pout(0,jk,jj)=pout(kni,jk,jj) ! West Boundary
pout(-1,jk,jj)=pout(kni-1,jk,jj) ! West Boundary
enddo
!
do jj=-1,knj
pout(kni+1,jk,jj)=pout(1,jk,jj) ! East Boundary
pout(kni+2,jk,jj)=pout(2,jk,jj) ! East Boundary
enddo
!
do ji=-1,kni+2
pout(ji,jk,knj+1)=pout(ji,jk,1) ! North Boundary
pout(ji,jk,knj+2)=pout(ji,jk,2) ! North Boundary
enddo
enddo
!$OMP END PARALLEL
!
return
end