!**********************************************************
!
        subroutine tide_admittances(tide_nbharmcp2)
!
!**********************************************************
!
!     objet    : calcul des amplitudes et phases pour les ondes
!                secondaire a l'aide de la methode d amittance
!               (GRS, 18(5), pp 845-848, 1991 Le Provost, Lyard, Molines)
!
!     appelant         : cpharmsimon,cpharmsimon2
!     appeles          :
!     canal d ecriture :
!     canal de lecture :
!     cle cpp          :
!                      :
!     variables in     :
!                      :
!     variables out    :
!     variables inout  : tide_nbharmcp,nu,a0sud,a0ouest,a0nord,ph0sud,ph0ouest,ph0nord
!
!***********************************************************
!
!
USE parameters
use commar
use comaree
implicit none
!
integer                                     :: n,tide_nbharmcp2,i,j
real(kind=rsh),PARAMETER :: alk2=0.1149327_rsh,aln2=0.1758941_rsh,alm2=0.9085024_rsh
real(kind=rsh),PARAMETER :: all2=0.0251_rsh,allda2=0.0066_rsh,alt2=0.0247766_rsh
real(kind=rsh),PARAMETER :: alnu2=0.03303_rsh,almu2=0.02777_rsh,alp1=0.1750754_rsh
real(kind=rsh),PARAMETER :: alq1=0.073017_rsh,alo1=0.3771366_rsh,alk1=0.5300728_rsh
real(kind=rsh) :: frbar1,deno1,ck,sk,cn,sn,aamu2,aanu2,aal2,aat2,aalda2
real(kind=rsh) :: bbmu2,bbnu2,bbl2,bbt2,bblda2,ccmu2,ccnu2,ccl2,cct2,cclda2
real(kind=rsh) :: deno,cnu2,snu2,cmu2,smu2,cl2,sl2,ct2,st2,clda2,slda2,aap1
real(kind=rsh) :: bbp1,ccp1
real(kind=rsh),dimension(nmarmax,imin:imax) :: srealsud,simagsud
real(kind=rsh),dimension(nmarmax,imin:imax) :: srealnord,simagnord
real(kind=rsh),dimension(nmarmax,jmin:jmax) :: srealest,simagest
real(kind=rsh),dimension(nmarmax,jmin:jmax) :: srealouest,simagouest
complex,dimension(nmarmax,imin:imax)        :: c0sud,c0nord
complex,dimension(nmarmax,jmin:jmax)        :: c0ouest,c0est
      
!
! debut initialisation
!
! Coefficient of the tidal potential (used in spline admittances)
!   spline admittances (see GRL 18(5):845-848,1991)
!------------------------------------------------------------------------
!
!
! compute the coefficient for P1 as a linear admittance with Q1,O1 K1 (linear regression)
!
      frbar1=1/3.*(frequence(iq1)+frequence(io1) + frequence(ik1))
      deno1=frbar1**2 - 1/3.*(frequence(iq1)**2 +frequence(io1)**2 + frequence(ik1)**2)
      aap1 = alp1/3./alq1*(1.- (frequence(ip1)-frbar1)*(frequence(iq1)-frbar1)/deno1)
      bbp1 = alp1/3./alo1*(1.- (frequence(ip1)-frbar1)*(frequence(io1)-frbar1)/deno1)
      ccp1 = alp1/3./alk1*(1.- (frequence(ip1)-frbar1)*(frequence(ik1)-frbar1)/deno1)
      ck=cos(2*pi*2.*(frequence(ik2)-frequence(im2))/15.)
      sk=sin(2*pi*2.*(frequence(ik2)-frequence(im2))/15.)
      cn=cos(2*pi*2.*(frequence(in2)-frequence(im2))/15.)
      sn=sin(2*pi*2.*(frequence(in2)-frequence(im2))/15.)
      deno=sk*(cn-1)-sn*(ck-1)
      cnu2=cos(2*pi*2.*(frequence(inu2)-frequence(im2))/15.)
      snu2=sin(2*pi*2.*(frequence(inu2)-frequence(im2))/15.)
      cmu2=cos(2*pi*2.*(frequence(imu2ms2)-frequence(im2))/15.)
      smu2=sin(2*pi*2.*(frequence(imu2ms2)-frequence(im2))/15.)
      cl2=cos(2*pi*2.*(frequence(il22mn2)-frequence(im2))/15.)
      sl2=sin(2*pi*2.*(frequence(il22mn2)-frequence(im2))/15.)
      ct2=cos(2*pi*2.*(frequence(it2)-frequence(im2))/15.)
      st2=sin(2*pi*2.*(frequence(it2)-frequence(im2))/15.)
      clda2=cos(2*pi*2.*(frequence(ilambda2)-frequence(im2))/15.)
      slda2=sin(2*pi*2.*(frequence(ilambda2)-frequence(im2))/15.)
      aamu2= (-sn*cmu2 +(cn-1)*smu2 +sn)/deno/alk2*almu2
      aanu2= (-sn*cnu2 +(cn-1)*snu2 +sn)/deno/alk2*alnu2
      aal2=  (-sn*cl2  +(cn-1)*sl2  +sn)/deno/alk2*all2
      aat2=  (-sn*ct2  +(cn-1)*st2  +sn)/deno/alk2*alt2
      aalda2=(-sn*clda2+(cn-1)*slda2+sn)/deno/alk2*allda2
      bbmu2=(sk*cmu2-(ck-1)*smu2-sk)/deno/aln2*almu2
      bbnu2=(sk*cnu2-(ck-1)*snu2-sk)/deno/aln2*alnu2
      bbl2=(sk*cl2-(ck-1)*sl2-sk)/deno/aln2*all2
      bbt2=(sk*ct2-(ck-1)*st2-sk)/deno/aln2*alt2
      bblda2=(sk*clda2-(ck-1)*slda2-sk)/deno/aln2*allda2
      ccmu2=(-(sk-sn)*cmu2+(ck-cn)*smu2+sk*cn-sn*ck)/deno/alm2*almu2
      ccnu2=(-(sk-sn)*cnu2+(ck-cn)*snu2+sk*cn-sn*ck)/deno/alm2*alnu2
      ccl2=(-(sk-sn)*cl2+(ck-cn)*sl2+sk*cn-sn*ck)/deno/alm2*all2
      cct2=(-(sk-sn)*ct2+(ck-cn)*st2+sk*cn-sn*ck)/deno/alm2*alt2
      cclda2=(-(sk-sn)*clda2+(ck-cn)*slda2+sk*cn-sn*ck)/deno/alm2*allda2
!
!------------------------------------------------------------------------------
! Passage en complexe pour les 8 ondes principales (M2,S2,K2,N2,O1,P1,Q1,K1)
!
      do n=1,tide_nbharmcp
       c0sud(nu(n),:)=a0sud(nu(n),:)*exp((0.,1.)*ph0sud(nu(n),:)*pi/180)
       srealsud(nu(n),:)=real(c0sud(nu(n),:))
       simagsud(nu(n),:)=aimag(c0sud(nu(n),:))
       c0nord(nu(n),:)=a0nord(nu(n),:)*exp((0.,1.)*ph0nord(nu(n),:)*pi/180)
       srealnord(nu(n),:)=real(c0nord(nu(n),:))
       simagnord(nu(n),:)=aimag(c0nord(nu(n),:))
       c0ouest(nu(n),:)=a0ouest(nu(n),:)*exp((0.,1.)*ph0ouest(nu(n),:)*pi/180)
       srealouest(nu(n),:)=real(c0ouest(nu(n),:))
       simagouest(nu(n),:)=aimag(c0ouest(nu(n),:))
       c0est(nu(n),:)=a0est(nu(n),:)*exp((0.,1.)*ph0est(nu(n),:)*pi/180)
       srealest(nu(n),:)=real(c0est(nu(n),:))
       simagest(nu(n),:)=aimag(c0est(nu(n),:))
      enddo
!
! infer additional constituents by admittance
!
          tide_nbharmcp2=tide_nbharmcp
!
! DIURNALS (from Richard Ray perth2 program. Thank You, Richard!)
!---------
!  from Q1 and O1 (nu=10-12)
!    2Q1
!
        if(l_presence(iq1).and.l_presence(io1)) then
         tide_nbharmcp2=tide_nbharmcp2+1
         nu(tide_nbharmcp2)=i2q1
         srealsud(i2q1,:)=0.263*srealsud(iq1,:)-0.0252*srealsud(io1,:)
         simagsud(i2q1,:)=0.263*simagsud(iq1,:)-0.0252*simagsud(io1,:)
         srealnord(i2q1,:)=0.263*srealnord(iq1,:)-0.0252*srealnord(io1,:)
         simagnord(i2q1,:)=0.263*simagnord(iq1,:)-0.0252*simagnord(io1,:) 
         srealouest(i2q1,:)=0.263*srealouest(iq1,:)-0.0252*srealouest(io1,:)
         simagouest(i2q1,:)=0.263*simagouest(iq1,:)-0.0252*simagouest(io1,:)
         srealest(i2q1,:)=0.263*srealest(iq1,:)-0.0252*srealest(io1,:)
         simagest(i2q1,:)=0.263*simagest(iq1,:)-0.0252*simagest(io1,:)
!
!    sigma1
!
         tide_nbharmcp2=tide_nbharmcp2+1
         nu(tide_nbharmcp2)=isigma1
         srealsud(isigma1,:)=0.297*srealsud(iq1,:)-0.0264*srealsud(io1,:)
         simagsud(isigma1,:)=0.297*simagsud(iq1,:)-0.0264*simagsud(io1,:)
         srealnord(isigma1,:)=0.297*srealnord(iq1,:)-0.0264*srealnord(io1,:) 
         simagnord(isigma1,:)=0.297*simagnord(iq1,:)-0.0264*simagnord(io1,:)
         srealouest(isigma1,:)=0.297*srealouest(iq1,:)-0.0264*srealouest(io1,:)
         simagouest(isigma1,:)=0.297*simagouest(iq1,:)-0.0264*simagouest(io1,:)
         srealest(isigma1,:)=0.297*srealest(iq1,:)-0.0264*srealest(io1,:)
         simagest(isigma1,:)=0.297*simagest(iq1,:)-0.0264*simagest(io1,:)
!    rho1
         tide_nbharmcp2=tide_nbharmcp2+1
         nu(tide_nbharmcp2)=irho1
         srealsud(irho1,:)=0.164*srealsud(iq1,:)+0.0048*srealsud(io1,:)
         simagsud(irho1,:)=0.164*simagsud(iq1,:)+0.0048*simagsud(io1,:)
         srealnord(irho1,:)=0.164*srealnord(iq1,:)+0.0048*srealnord(io1,:)
         simagnord(irho1,:)=0.164*simagnord(iq1,:)+0.0048*simagnord(io1,:)
         srealouest(irho1,:)=0.164*srealouest(iq1,:)+0.0048*srealouest(io1,:)
         simagouest(irho1,:)=0.164*simagouest(iq1,:)+0.0048*simagouest(io1,:)
         srealest(irho1,:)=0.164*srealest(iq1,:)+0.0048*srealest(io1,:)
         simagest(irho1,:)=0.164*simagest(iq1,:)+0.0048*simagest(io1,:)
        endif
!
!  from O1 and K1 (nu=12-21)
!    M11
        if(l_presence(io1).and.l_presence(ik1)) then
         tide_nbharmcp2=tide_nbharmcp2+1
         nu(tide_nbharmcp2)=im1
         srealsud(im1,:)=0.0140*srealsud(io1,:)+0.0101*srealsud(ik1,:)
         simagsud(im1,:)=0.0140*simagsud(io1,:)+0.0101*simagsud(ik1,:)
         srealnord(im1,:)=0.0140*srealnord(io1,:)+0.0101*srealnord(ik1,:)
         simagnord(im1,:)=0.0140*simagnord(io1,:)+0.0101*simagnord(ik1,:) 
         srealouest(im1,:)=0.0140*srealouest(io1,:)+0.0101*srealouest(ik1,:)
         simagouest(im1,:)=0.0140*simagouest(io1,:)+0.0101*simagouest(ik1,:)
         srealest(im1,:)=0.0140*srealest(io1,:)+0.0101*srealest(ik1,:)
         simagest(im1,:)=0.0140*simagest(io1,:)+0.0101*simagest(ik1,:)
!    M12
!c       tide_nbharmcp2=tide_nbharmcp2+1
!c       nu(tide_nbharmcp2)=im12
!c       srealsud(im12,:)=0.0389*srealsud(io1,:)+0.0282*srealsud(ik1,:)
!c       simagsud(im12,:)=0.0389*simagsud(io1,:)+0.0282*simagsud(ik1,:)
!c       srealnord(im12,:)=0.0389*srealnord(io1,:)+0.0282*srealnord(ik1,:)
!c       simagnord(im12,:)=0.0389*simagnord(io1,:)+0.0282*simagnord(ik1,:)
!c       srealouest(im12,:)=0.0389*srealouest(io1,:)+0.0282*srealouest(ik1,:)
!c       simagouest(im12,:)=0.0389*simagouest(io1,:)+0.0282*simagouest(ik1,:)
!c       srealest(im12,:)=0.0389*srealest(io1,:)+0.0282*srealest(ik1,:)
!c       simagest(im12,:)=0.0389*simagest(io1,:)+0.0282*simagest(ik1,:)
!    khi1
         tide_nbharmcp2=tide_nbharmcp2+1
         nu(tide_nbharmcp2)=ikhi1
         srealsud(ikhi1,:)=0.0064*srealsud(io1,:)+0.006*srealsud(ik1,:)
         simagsud(ikhi1,:)=0.0064*simagsud(io1,:)+0.006*simagsud(ik1,:)
         srealnord(ikhi1,:)=0.0064*srealnord(io1,:)+0.006*srealnord(ik1,:)
         simagnord(ikhi1,:)=0.0064*simagnord(io1,:)+0.006*simagnord(ik1,:)
         srealouest(ikhi1,:)=0.0064*srealouest(io1,:)+0.006*srealouest(ik1,:)
         simagouest(ikhi1,:)=0.0064*simagouest(io1,:)+0.006*simagouest(ik1,:)
         srealest(ikhi1,:)=0.0064*srealest(io1,:)+0.006*srealest(ik1,:)
         simagest(ikhi1,:)=0.0064*simagest(io1,:)+0.006*simagest(ik1,:)
!    pi1
          tide_nbharmcp2=tide_nbharmcp2+1
          nu(tide_nbharmcp2)=ipi1
          srealsud(ipi1,:)=0.003*srealsud(io1,:)+0.0171*srealsud(ik1,:)
          simagsud(ipi1,:)=0.003*simagsud(io1,:)+0.0171*simagsud(ik1,:)
          srealnord(ipi1,:)=0.003*srealnord(io1,:)+0.0171*srealnord(ik1,:)
          simagnord(ipi1,:)=0.003*simagnord(io1,:)+0.0171*simagnord(ik1,:)
          srealouest(ipi1,:)=0.003*srealouest(io1,:)+0.0171*srealouest(ik1,:) 
          simagouest(ipi1,:)=0.003*simagouest(io1,:)+0.0171*simagouest(ik1,:)
          srealest(ipi1,:)=0.003*srealest(io1,:)+0.0171*srealest(ik1,:) 
          simagest(ipi1,:)=0.003*simagest(io1,:)+0.0171*simagest(ik1,:)
!    phi1
          tide_nbharmcp2=tide_nbharmcp2+1
          nu(tide_nbharmcp2)=iphi1
          srealsud(iphi1,:)=-0.0015*srealsud(io1,:)+0.0152*srealsud(ik1,:)
          simagsud(iphi1,:)=-0.0015*simagsud(io1,:)+0.0152*simagsud(ik1,:)
          srealnord(iphi1,:)=-0.0015*srealnord(io1,:)+0.0152*srealnord(ik1,:)
          simagnord(iphi1,:)=-0.0015*simagnord(io1,:)+0.0152*simagnord(ik1,:)
          srealouest(iphi1,:)=-0.0015*srealouest(io1,:)+0.0152*srealouest(ik1,:)
          simagouest(iphi1,:)=-0.0015*simagouest(io1,:)+0.0152*simagouest(ik1,:)
          srealest(iphi1,:)=-0.0015*srealest(io1,:)+0.0152*srealest(ik1,:)
          simagest(iphi1,:)=-0.0015*simagest(io1,:)+0.0152*simagest(ik1,:)
!    theta1
          tide_nbharmcp2=tide_nbharmcp2+1
          nu(tide_nbharmcp2)=itheta1
          srealsud(itheta1,:)=-0.0065*srealsud(io1,:)+0.0155*srealsud(ik1,:)
          simagsud(itheta1,:)=-0.0065*simagsud(io1,:)+0.0155*simagsud(ik1,:)
          srealnord(itheta1,:)=-0.0065*srealnord(io1,:)+0.0155*srealnord(ik1,:)
          simagnord(itheta1,:)=-0.0065*simagnord(io1,:)+0.0155*simagnord(ik1,:)
          srealouest(itheta1,:)=-0.0065*srealouest(io1,:)+0.0155*srealouest(ik1,:)
          simagouest(itheta1,:)=-0.0065*simagouest(io1,:)+0.0155*simagouest(ik1,:)
          srealest(itheta1,:)=-0.0065*srealest(io1,:)+0.0155*srealest(ik1,:)
          simagest(itheta1,:)=-0.0065*simagest(io1,:)+0.0155*simagest(ik1,:)
!   J1
          tide_nbharmcp2=tide_nbharmcp2+1
          nu(tide_nbharmcp2)=ij1
          srealsud(ij1,:)=-0.0389*srealsud(io1,:)+0.0836*srealsud(ik1,:)
          simagsud(ij1,:)=-0.0389*simagsud(io1,:)+0.0836*simagsud(ik1,:)
          srealnord(ij1,:)=-0.0389*srealnord(io1,:)+0.0836*srealnord(ik1,:)
          simagnord(ij1,:)=-0.0389*simagnord(io1,:)+0.0836*simagnord(ik1,:)
          srealouest(ij1,:)=-0.0389*srealouest(io1,:)+0.0836*srealouest(ik1,:)
          simagouest(ij1,:)=-0.0389*simagouest(io1,:)+0.0836*simagouest(ik1,:)
          srealest(ij1,:)=-0.0389*srealest(io1,:)+0.0836*srealest(ik1,:)
          simagest(ij1,:)=-0.0389*simagest(io1,:)+0.0836*simagest(ik1,:)
!   OO1
          tide_nbharmcp2=tide_nbharmcp2+1
          nu(tide_nbharmcp2)=ioo1
          srealsud(ioo1,:)=-0.0431*srealsud(io1,:)+0.0613*srealsud(ik1,:) 
          simagsud(ioo1,:)=-0.0431*simagsud(io1,:)+0.0613*simagsud(ik1,:)
          srealnord(ioo1,:)=-0.0431*srealnord(io1,:)+0.0613*srealnord(ik1,:)
          simagnord(ioo1,:)=-0.0431*simagnord(io1,:)+0.0613*simagnord(ik1,:)
          srealouest(ioo1,:)=-0.0431*srealouest(io1,:)+0.0613*srealouest(ik1,:) 
          simagouest(ioo1,:)=-0.0431*simagouest(io1,:)+0.0613*simagouest(ik1,:)
          srealest(ioo1,:)=-0.0431*srealest(io1,:)+0.0613*srealest(ik1,:) 
          simagest(ioo1,:)=-0.0431*simagest(io1,:)+0.0613*simagest(ik1,:)
         endif
!
!
! SEMI-DIURNAL (from Grenoble to take advantage of 2N2)
! ------------
!  from 2N2 -N2 (4-5)
!    eps2
!c       if(l_presence(i2n2).and.l_presence(in2)) then
!c        tide_nbharmcp2=tide_nbharmcp2+1
!c        nu(tide_nbharmcp2)=ieps2
!c        srealsud(ieps2,:)=0.53285*srealsud(im2,:)-0.03304*srealsud(in2,:)
!c        simagsud(ieps2,:)=0.53285*simagsud(im2,:)-0.03304*simagsud(in2,:)
!c        srealnord(ieps2,:)=0.53285*srealnord(im2,:)-0.03304*srealnord(in2,:)
!c        simagnord(ieps2,:)=0.53285*simagnord(im2,:)-0.03304*simagnord(in2,:)
!c        srealouest(ieps2,:)=0.53285*srealouest(im2,:)-0.03304*srealouest(in2,:)
!c        simagouest(ieps2,:)=0.53285*simagouest(im2,:)-0.03304*simagouest(in2,:)
!c        srealest(ieps2,:)=0.53285*srealest(im2,:)-0.03304*srealest(in2,:)
!c        simagest(ieps2,:)=0.53285*simagest(im2,:)-0.03304*simagest(in2,:)
!c      endif
!  from M2 - K2 (6-7)
!   eta2
!c      if(l_presence(im2).and.l_presence(ik2)) then
!c       tide_nbharmcp2=tide_nbharmcp2+1
!c       nu(tide_nbharmcp2)=ieta2
!c       srealsud(ieta2,:)=-0.0034925*srealsud(im2,:)+0.0831707*srealsud(in2,:)
!c       simagsud(ieta2,:)=-0.0034925*simagsud(im2,:)+0.0831707*simagsud(in2,:)
!c       srealnord(ieta2,:)=-0.0034925*srealnord(im2,:)+0.0831707*srealnord(in2,:)
!c       simagnord(ieta2,:)=-0.0034925*simagnord(im2,:)+0.0831707*simagnord(in2,:)
!c       srealouest(ieta2,:)=-0.0034925*srealouest(im2,:)+0.0831707*srealouest(in2,:)
!c       simagouest(ieta2,:)=-0.0034925*simagouest(im2,:)+0.0831707*simagouest(in2,:)
!c       srealest(ieta2,:)=-0.0034925*srealest(im2,:)+0.0831707*srealest(in2,:)
!c       simagest(ieta2,:)=-0.0034925*simagest(im2,:)+0.0831707*simagest(in2,:)
!c      endif
!
!  from N2 -M2- K2 by spline admittances (see GRL 18(5):845-848,1991)
!   mu2
        if(l_presence(im2).and.l_presence(ik2).and.l_presence(in2)) then
         tide_nbharmcp2=tide_nbharmcp2+1
         nu(tide_nbharmcp2)=imu2ms2
         srealsud(imu2ms2,:)=aamu2*srealsud(ik2,:)+bbmu2*srealsud(in2,:)+ccmu2*srealsud(im2,:)
         simagsud(imu2ms2,:)=aamu2*simagsud(ik2,:)+bbmu2*simagsud(in2,:)+ccmu2*simagsud(im2,:)
         srealnord(imu2ms2,:)=aamu2*srealnord(ik2,:)+bbmu2*srealnord(in2,:)+ccmu2*srealnord(im2,:)
         simagnord(imu2ms2,:)=aamu2*simagnord(ik2,:)+bbmu2*simagnord(in2,:)+ccmu2*simagnord(im2,:)
         srealouest(imu2ms2,:)=aamu2*srealouest(ik2,:)+bbmu2*srealouest(in2,:)+ccmu2*srealouest(im2,:)
         simagouest(imu2ms2,:)=aamu2*simagouest(ik2,:)+bbmu2*simagouest(in2,:)+ccmu2*simagouest(im2,:)
         srealest(imu2ms2,:)=aamu2*srealest(ik2,:)+bbmu2*srealest(in2,:)+ccmu2*srealest(im2,:)
         simagest(imu2ms2,:)=aamu2*simagest(ik2,:)+bbmu2*simagest(in2,:)+ccmu2*simagest(im2,:)
!   nu2
         tide_nbharmcp2=tide_nbharmcp2+1
         nu(tide_nbharmcp2)=inu2
         srealsud(inu2,:)=aanu2*srealsud(ik2,:)+bbnu2*srealsud(in2,:)+ccnu2*srealsud(im2,:)
         simagsud(inu2,:)=aanu2*simagsud(ik2,:)+bbnu2*simagsud(in2,:)+ccnu2*simagsud(im2,:) 
         srealnord(inu2,:)=aanu2*srealnord(ik2,:)+bbnu2*srealnord(in2,:)+ccnu2*srealnord(im2,:)
         simagnord(inu2,:)=aanu2*simagnord(ik2,:)+bbnu2*simagnord(in2,:)+ccnu2*simagnord(im2,:)
         srealouest(inu2,:)=aanu2*srealouest(ik2,:)+bbnu2*srealouest(in2,:)+ccnu2*srealouest(im2,:)
         simagouest(inu2,:)=aanu2*simagouest(ik2,:)+bbnu2*simagouest(in2,:)+ccnu2*simagouest(im2,:)
         srealest(inu2,:)=aanu2*srealest(ik2,:)+bbnu2*srealest(in2,:)+ccnu2*srealest(im2,:)
         simagest(inu2,:)=aanu2*simagest(ik2,:)+bbnu2*simagest(in2,:)+ccnu2*simagest(im2,:)
!   lda2
         tide_nbharmcp2=tide_nbharmcp2+1
         nu(tide_nbharmcp2)=ilambda2
         srealsud(ilambda2,:)=aalda2*srealsud(ik2,:)+bblda2*srealsud(in2,:)+cclda2*srealsud(im2,:)
         simagsud(ilambda2,:)=aalda2*simagsud(ik2,:)+bblda2*simagsud(in2,:)+cclda2*simagsud(im2,:)
         srealnord(ilambda2,:)=aalda2*srealnord(ik2,:)+bblda2*srealnord(in2,:)+cclda2*srealnord(im2,:)
         simagnord(ilambda2,:)=aalda2*simagnord(ik2,:)+bblda2*simagnord(in2,:)+cclda2*simagnord(im2,:)
         srealouest(ilambda2,:)=aalda2*srealouest(ik2,:)+bblda2*srealouest(in2,:)+cclda2*srealouest(im2,:)
         simagouest(ilambda2,:)=aalda2*simagouest(ik2,:)+bblda2*simagouest(in2,:)+cclda2*simagouest(im2,:)
         srealest(ilambda2,:)=aalda2*srealest(ik2,:)+bblda2*srealest(in2,:)+cclda2*srealest(im2,:)
         simagest(ilambda2,:)=aalda2*simagest(ik2,:)+bblda2*simagest(in2,:)+cclda2*simagest(im2,:)
!   L2
          tide_nbharmcp2=tide_nbharmcp2+1
          nu(tide_nbharmcp2)=il22mn2
          srealsud(il22mn2,:)=aal2*srealsud(ik2,:)+bbl2*srealsud(in2,:)+ccl2*srealsud(im2,:)
          simagsud(il22mn2,:)=aal2*simagsud(ik2,:)+bbl2*simagsud(in2,:)+ccl2*simagsud(im2,:)
          srealnord(il22mn2,:)=aal2*srealnord(ik2,:)+bbl2*srealnord(in2,:)+ccl2*srealnord(im2,:)
          simagnord(il22mn2,:)=aal2*simagnord(ik2,:)+bbl2*simagnord(in2,:)+ccl2*simagnord(im2,:)
          srealouest(il22mn2,:)=aal2*srealouest(ik2,:)+bbl2*srealouest(in2,:)+ccl2*srealouest(im2,:)
          simagouest(il22mn2,:)=aal2*simagouest(ik2,:)+bbl2*simagouest(in2,:)+ccl2*simagouest(im2,:)
          srealest(il22mn2,:)=aal2*srealest(ik2,:)+bbl2*srealest(in2,:)+ccl2*srealest(im2,:)
          simagest(il22mn2,:)=aal2*simagest(ik2,:)+bbl2*simagest(in2,:)+ccl2*simagest(im2,:)
!   T2
          tide_nbharmcp2=tide_nbharmcp2+1
          nu(tide_nbharmcp2)=it2
          srealsud(it2,:)=aat2*srealsud(ik2,:)+bbt2*srealsud(in2,:)+cct2*srealsud(im2,:)
          simagsud(it2,:)=aat2*simagsud(ik2,:)+bbt2*simagsud(in2,:)+cct2*simagsud(im2,:)
          srealnord(it2,:)=aat2*srealnord(ik2,:)+bbt2*srealnord(in2,:)+cct2*srealnord(im2,:)
          simagnord(it2,:)=aat2*simagnord(ik2,:)+bbt2*simagnord(in2,:)+cct2*simagnord(im2,:)
          srealouest(it2,:)=aat2*srealouest(ik2,:)+bbt2*srealouest(in2,:)+cct2*srealouest(im2,:)
          simagouest(it2,:)=aat2*simagouest(ik2,:)+bbt2*simagouest(in2,:)+cct2*simagouest(im2,:)
          srealest(it2,:)=aat2*srealest(ik2,:)+bbt2*srealest(in2,:)+cct2*srealest(im2,:)
          simagest(it2,:)=aat2*simagest(ik2,:)+bbt2*simagest(in2,:)+cct2*simagest(im2,:)
         endif
!
!
!-- Passage en reel
!
        do n=tide_nbharmcp+1,tide_nbharmcp2
          a0sud(nu(n),:)=sqrt(srealsud(nu(n),:)*srealsud(nu(n),:)+simagsud(nu(n),:)*simagsud(nu(n),:))
          ph0sud(nu(n),:)=atan2(simagsud(nu(n),:),srealsud(nu(n),:))*180/pi
          a0nord(nu(n),:)=sqrt(srealnord(nu(n),:)*srealnord(nu(n),:)+simagnord(nu(n),:)*simagnord(nu(n),:))
          ph0nord(nu(n),:)=atan2(simagnord(nu(n),:),srealnord(nu(n),:))*180/pi
          do i=imin,imax
          if(ph0nord(nu(n),i) < 0.0) ph0nord(nu(n),i)=ph0nord(nu(n),i)+360.0
          if(ph0sud(nu(n),i) < 0.0) ph0sud(nu(n),i)=ph0sud(nu(n),i)+360.0
          end do 
          a0ouest(nu(n),:)=sqrt(srealouest(nu(n),:)*srealouest(nu(n),:)+simagouest(nu(n),:)*simagouest(nu(n),:))
          ph0ouest(nu(n),:)=atan2(simagouest(nu(n),:),srealouest(nu(n),:))*180/pi
          a0est(nu(n),:)=sqrt(srealest(nu(n),:)*srealest(nu(n),:)+simagest(nu(n),:)*simagest(nu(n),:))
          ph0est(nu(n),:)=atan2(simagest(nu(n),:),srealest(nu(n),:))*180/pi
          do j=jmin,jmax
          if(ph0est(nu(n),j) < 0.0) ph0est(nu(n),j)=ph0est(nu(n),j)+360.0
          if(ph0ouest(nu(n),j) < 0.0) ph0ouest(nu(n),j)=ph0ouest(nu(n),j)+360.0
          end do 
        enddo
!
        end subroutine tide_admittances
