      PROGRAM RESON
      PARAMETER(N=2,NITT=10000)
CFIN  PARAMETER(N=2,NITT=1000000,NTEST=100)
CPAP     PARAMETER(N=2,NITT=4000000)


      REAL*8       GAMN1,GAMN2,GAMN3,ALPN1,ALPN2,
     *             DELN1,DELN2,EPSN,K01,K02,KN1,KN2,
     *             BETN1,BETN2,H01,H02,HN1,HN2,PSAS


C  PARAMETRE TERRESTRES

      PI=ACOS(-1.)
      REA=6400000.
      RG=3.6
      RH0=1.E+4
      PH0=PI/4.
      F0=1.0284E-4
      RL=REA/4

C VALEUR DU PAPIER CHADEV:
C     RK=0.01
C     OPEN(10,file='../xmgr/reson_n2_db.dat',form='formatted')
C VALEUR POUR AVOIR UN BEAU GRAPHE:
C     RK=0.04 
C     OPEN(10,file='../xmgr/reson_n2_dm.dat',form='formatted')
C VALEUR POUR AVOIR GRAPHE SANS SOLUTIONS TRIPLE:
      RK=0.08 
      OPEN(10,file='../xmgr/reson_n2_df.dat',form='formatted')
C
      PSAS=0.05

C  PARAMETRE DE CONFIGURATION:

      RLAM2=F0*F0/RG/RH0*RL**2
cCD:
      RH=0.2*RH0
cYO:
c     RH=0.1*RH0
cLO:
c     RH=0.5*RH0

C  PARAMETRE NUMERIQUES:

      DT=0.01
      ALPHA=1.    

C CONSTANTES D'INTEGRATION (EQ.17, Charney De Vore 1979):

      GAMN1=5.* 8.*sqrt(2.)/15./pi*float(n)
      GAMN2=4.* 8.*sqrt(2.)/15./pi*float(n)
      GAMN3=8.* 8.*sqrt(2.)/15./pi*float(n)

      ALPN1=GAMN1*N*N/(N*N+1+RLAM2)
      ALPN2=GAMN2*(N*N+3)/(N*N+4+RLAM2)

      DELN1=GAMN3*N*N/(N*N+1+RLAM2)
      DELN2=GAMN3*(N*N-3)/(N*N+4+RLAM2)

      EPSN=3.*GAMN3/(4.+RLAM2)

      K01=RK/(1+RLAM2)
      K02=RK/(4+RLAM2)
      KN1=RK*(N*N+1)/(N*N+1.+RLAM2)
      KN2=RK*(N*N+4)/(N*N+4.+RLAM2)


      BETN1=RL/REA*COS(PH0)/SIN(PH0)*N/(N*N+1.+RLAM2)
      BETN2=RL/REA*COS(PH0)/SIN(PH0)*N/(N*N+4.+RLAM2)

      H01=GAMN1/(1.+RLAM2)*RH/(2.*RH0)
      H02=GAMN3/(4.+RLAM2)*RH/(2.*RH0)
      HN1=GAMN1/(N*N+1.+RLAM2)*RH/(2.*RH0)
      HN2=GAMN3/(N*N+4.+RLAM2)*RH/(2.*RH0)

      DO IT=1,NITT
         PSIA=FLOAT(IT)/25000.
         PSIL=-HN1*KN1/((BETN1-ALPN1*PSIA)**2+KN1**2)*PSIA
         WRITE(10,*)PSIA/BETN1*ALPN1,-PSIL*H01/K01
      ENDDO

      WRITE(10,*)' '
      DO IT=1,NITT
         PSIA=FLOAT(IT)/25000.
         PSIK=-HN1/((BETN1-ALPN1*PSIA)**2+KN1**2)*
     C         (BETN1-ALPN1*PSIA)*PSIA
         WRITE(10,*)PSIA/BETN1*ALPN1,PSIK*H01/K01
      ENDDO


      DO NP=1,5 
      PSAS=+0.10*NP
      WRITE(10,*)' '
      DO IT=1,NITT
         PSIA=FLOAT(IT)/25000.
         WRITE(10,*)PSIA/BETN1*ALPN1,-PSIA+PSAS
      ENDDO
      ENDDO

      STOP
      END
