  SUBROUTINE tool_interp2d_wave(i1,j1,xdp,ydp,tabin,tabout)
#ifdef key_wave
   !&E---------------------------------------------------------------------
   !&E                 ***  ROUTINE tool_interp2d_wave  ***
   !&E
   !&E ** Purpose : spatial interpolation of wave data
   !&E
   !&E ** Description :
   !&E
   !&E ** Called by : wave.F90
   !&E
   !&E ** External calls : 
   !&E
   !&E ** Used ij-arrays : tabin, i1, j1, xdp, ydp
   !&E
   !&E ** Modified variables : tabout
   !&E
   !&E ** Reference :
   !&E
   !&E ** History :
   !&E       !  2010-06-01 (R. Verney) original code
   !&E
   !&E---------------------------------------------------------------------
   !! * Modules used
   USE parameters
   !USE parameters ,only:rsh,riosh,imin,imax,jmin,jmax
   USE comvars2d,ONLY : jb,jh,ig,id
   USE wave,     ONLY   : iwavemin,iwavemax,jwavemin,jwavemax
   IMPLICIT NONE

   !! * Arguments
   INTEGER         ,DIMENSION(limin:limax,ljmin:ljmax)        ,INTENT(in)  :: i1,j1
   REAL(kind=rsh)  ,DIMENSION(limin:limax,ljmin:ljmax)        ,INTENT(in)  :: xdp,ydp
   REAL(kind=riosh),DIMENSION(iwavemin:iwavemax,jwavemin:jwavemax),INTENT(in)  :: tabin
   REAL(kind=rsh)  ,DIMENSION(limin:limax,ljmin:ljmax)        ,INTENT(out) :: tabout

   !! * Local declarations
   INTEGER        :: i,j,ii1,ii2,jj1,jj2
   REAL(kind=rsh) :: var1,var2

   !!----------------------------------------------------------------------
   !! * Executable part

   !do j = jmin+1,jmax
!$OMP do schedule(runtime),private(i,j,ii1,ii2,jj1,jj2,var1,var2)
   DO j = ljminp1,ljmax
     DO i=MAX0(limin,ig(j)),MIN0(limax,id(j))
       ii1=MAX(i1(i,j),iwavemin)
       ii2=MIN(i1(i,j)+1,iwavemax)
       jj1=MAX(j1(i,j),jwavemin)
       jj2=MIN(j1(i,j)+1,jwavemax)
       var1=xdp(i,j)*tabin(ii2,jj1)+(1.0_rsh-xdp(i,j))*tabin(ii1,jj1)
       var2=xdp(i,j)*tabin(ii2,jj2)+(1.0_rsh-xdp(i,j))*tabin(ii1,jj2)
       tabout(i,j)=(ydp(i,j)*var2+(1.0_rsh-ydp(i,j))*var1)
     END DO
   END DO
!$OMP end do

   ! fill borders

!$OMP do private(i,j,ii1,ii2,jj1,jj2,var1,var2)
   DO i = liminp1,limax

     ! bottom
     j=jb(i)
     IF ((j.LE.ljmax).AND.(j.GE.ljmin))THEN
       ii1=MAX(i1(i,j),iwavemin)
       ii2=MIN(i1(i,j)+1,iwavemax)
       jj1=MAX(j1(i,j),jwavemin)
       jj2=MIN(j1(i,j)+1,jwavemax)
       var1=xdp(i,j)*tabin(ii2,jj1)+(1.0_rsh-xdp(i,j))*tabin(ii1,jj1)
       var2=xdp(i,j)*tabin(ii2,jj2)+(1.0_rsh-xdp(i,j))*tabin(ii1,jj2)
       tabout(i,j)=(ydp(i,j)*var2+(1.0_rsh-ydp(i,j))*var1)
     ENDIF

     ! top
     j=jh(i)
     IF ((j.LE.ljmax).AND.(j.GE.ljmin))THEN
       ii1=MAX(i1(i,j),iwavemin)
       ii2=MIN(i1(i,j)+1,iwavemax)
       jj1=MAX(j1(i,j),jwavemin)
       jj2=MIN(j1(i,j)+1,jwavemax)
       var1=xdp(i,j)*tabin(ii2,jj1)+(1.0_rsh-xdp(i,j))*tabin(ii1,jj1)
       var2=xdp(i,j)*tabin(ii2,jj2)+(1.0_rsh-xdp(i,j))*tabin(ii1,jj2)
       tabout(i,j)=(ydp(i,j)*var2+(1.0_rsh-ydp(i,j))*var1)
     ENDIF
   END DO
!$OMP end do

#else

   USE parameters, ONLY : rsh,riosh,limin,limax,ljmin,ljmax
   INTEGER         ,DIMENSION(limin:limax,ljmin:ljmax),INTENT(in)  :: i1,j1
   REAL(kind=rsh)  ,DIMENSION(limin:limax,ljmin:ljmax),INTENT(in)  :: xdp,ydp
   REAL(kind=riosh),DIMENSION(limin:limax,ljmin:ljmax),INTENT(in) :: tabin
   REAL(kind=rsh)  ,DIMENSION(limin:limax,ljmin:ljmax),INTENT(in) :: tabout

#endif
  END SUBROUTINE tool_interp2d_wave
