chp15.f 9.86 KB
      subroutine chp15 (year,rre,thetr,phir,br,bt,bp,bb,ier)
c*
c***********************************************************************
c*
c*PRO MAGLIB
c*
c*VER 17.02.23 - V 1.0
c*VER 20.07.07 - V 2.0
c*
c*AUT spec. CNES - JC KOSIK - fevrier 2001
c*AUT port. AKKA
c*
c*ROL Theme : Modeles de champs magnetiques
c*ROL         Calcul des composantes du champ magnetique apres 2015.
c*
c*PAR year  (I) : annee fractionnaire (>= 2015.)
c*
c*PAR rre   (I) : distance radiale geocentrique (rayons terrestres)
c*PAR thetr (I) : colatitude geocentrique (radians)
c*PAR phir  (I) : longitude geocentrique (radians)
c*
c*PAR br    (O) : composante radiale du champ magnetique (gauss)
c*PAR bt    (O) : composante tangentielle du champ magnetique le long
c*PAR           : du meridien positive vers le bas (gauss)
c*PAR bp    (O) : composante azimuthale du champ magnetique, positive
c*PAR           : vers l'est (gauss)
c*
c*PAR bb    (O) : module du champ magnetique (gauss)
c*
c*PAR ier   (O) : code de retour
c*
c*NOT ier       : sans objet
c*
c*NOT common    : util, util2
c*
c*INF utilise   : sans objet
c*
c*HST version 1.0 - 17.02.23 - Coefficients de Schmidt et
c*                             variations seculaires provisoires 2015
c*HST version 2.0 - 20.07.07 - Coefficients de Schmidt définitifs
c*                             variations seculaires interpolées 2015
c*
c***********************************************************************
c*
      implicit none
c
c     ---------------------------------
c*FON Declaration identificateur rcs_id
c     ---------------------------------
c
      character rcs_id*100
c
c     --------------------------
c*FON Declaration des parametres
c     --------------------------
c
      double precision year,rre,thetr,phir,br,bt,bp,bb
      integer ier
c
c     ----------------------------------
c*FON Declaration des variables communes
c     ----------------------------------
c
      double precision pi,dpi,rad,deg,pid,xmu,rayt
c
c*COM pi   : constante pi (obtenue a partir de acos(-1.))
c*COM dpi  : constante 2 * pi
c*COM pid  : constante pi / 2
c*COM rad  : facteur de conversion degres  ----> radians
c*COM deg  : facteur de conversion radians ----> degres
c*COM xmu  : constante de gravitation terrestre (km**3/sec**2)
c*COM rayt : rayon equatorial terrestre (km)
c
      common/util/pi,dpi,rad,deg,pid,xmu,rayt
c
      double precision rgmt
c
c*COM rgmt : rayon geocentrique terrestre (km)
c
      common/util2/rgmt
c
c     ---------------------------------
c*FON Declaration des variables locales
c     ---------------------------------
c
      integer lg(195),lgt(195)
c*LOC lg, lgt : coeeficients apres l'an 2015
c
      integer kmax
c*LOC kmax : nombre de pas de calcul (= 14)
c
      integer l,k,jj,nm,ntot,inc
c*LOC l,k,jj,nm,ntot,inc : indices de boucles et de tableaux
c
      double precision gg(14,14),ggt(14,14),hh(14,14),hht(14,14)
      double precision g(14,14),h(14,14),sh(14,14),fn(14),fm(14)
      double precision cp(14),sp(14),p(14,14),dp(14,14),const(14,14)
      double precision f1, f2, tzero, tmold,t,cph,sph,ct,st
      double precision rrmag,ar,aor,temp,par
c*LOC Variables de travail intermediaires
c
      SAVE
c
c     ---------------------------------
c*FON Affectation identificateur rcs_id
c     ---------------------------------
c
      data rcs_id /"
     >$Id$"/
c
c     --------------------------
c*FON Affectation des constantes
c     --------------------------
c
c     Revision février 2017 - coefficients lg et lgt
c     Revision juillet 2020 - coefficients lg et lgt
c
      data lg/
     > -2944146,-150177,479599,-244588,301220,-284541,167635,-64217,
     >  135033,-235226,-11529,122585,24504,
     >  58169,-53870,90742,81368,28354,12049,-18843,-33485,18095,7038,
     > -32923,-23291,36014,4698,
     >  19235,19698,-14094,-11914,-15740,1598,430,10012,6955,6757,-2061,
     >  7279,3330,-12985,
     >  5874,-2893,-6664,1314,735,-7085,6241,8129,-7599,-5427,-679,
     > -1953,5182,559,
     >  1507,2445,932,327,-288,-2750,661,-232,2398,889,1004,-1678,-1826,
     > -316,
     >  1318,-2056,-1460,1333,1616,1176,569,-1598,-910,-202,226,533,883,
     > -2177,
     >  302,1076,-322,1174,67,-674,-1320,-688,-10,779,868,104,-906,-389,
     > -1054,844,-201,-626,328,17,-40,55,455,-55,440,170,-792,-67,
     > -61,213,-416,233,-285,-180,-112,-359,-872,300,-140,0,-230,211,
     >  208,-60,-79,-105,58,76,-70,-20,14,-212,170,-144,-22,-257,
     >  44,-201,349,-234,-209,-16,-108,46,37,123,175,-89,-219,85,
     >  27,10,72,54,-9,-37,29,-43,23,22,-89,-94,-16,-3,
     >  72,-2,-92,-88,42,49,63,156,-42,-50,96,-124,-19,-10,
     >  81,42,-13,-4,38,48,8,48,46,-30,-35,-43,-36,-71
     > /
c
       data lgt/
     >  7332,10174,-28698,-10744,-6040,-29238,130,-18486,2574,-5788,
     >  6638,2070,-628,
     > -11198,-940,-884,-836,-328,-6838,6006,5090,3750,-4476,-4094,-278,
     >  612,144,
     > -910,2264,48,-412,1240,3264,1840,-244,-710,-414,302,22,-1640,
     >  1670,
     > -1188,-1454,428,72,310,1230,1138,-138,-142,554,-282,526,936,-678,
     >  146,-190,-584,-1094,-864,60,638,104,-56,162,-328,-164,592,532,
     >  -76,-108,580,394,-252,388,-418,-104,440,344,108,-66,-86,-326,
     >  -24,48,344,-388,-354,328,0,116,240,2,24,-128,-48,498,
     >  -272,232,22,12,24,-54,40,230,-190,-70,80,-200,-136,-46,
     >  102,-46,-28,-186,-110,-120,204,-42,-16,0,0,0,-40,78,
     >  44,0,-22,130,-56,-32,0,0,-48,84,-60,-32,-76,-86,
     >  -48,2,-78,-52,18,12,-24,8,26,14,-70,-62,78,-30,
     >  -34,40,16,-8,-22,14,62,-14,-6,-24,-2,-32,32,-54,
     >  -44,24,4,-4,16,22,14,-32,24,20,-32,-12,38,0,
     >  -2,-24,26,-12,4,4,4,4,8,-20,-30,6,-8,22
     > /
c
      data kmax /14/
c
      data f1 /100.d0/, f2 /1000.d0/
c
      data sp(1)   /0.d0/
      data p(1,1)  /1.d0/
      data cp(1)   /1.d0/
      data dp(1,1) /0.d0/
c
      data tzero /2015.d0/
c
      data tmold /0.d0/
c
      data sh(1,1) /0.d0/
c
c     ******************
c     Debut de programme
c     ******************
c
c     ---------------
c*FON Initialisations
c     ---------------
c
      ier  = 0
c
      if (sh(1,1) .ne. -1.d0) then
         sh(1,1) = -1.d0
c
c     ---------------------------------------------------
c*FON Calcul des coefficients de Shmidt et des constantes
c     ---------------------------------------------------
c
         do 20 k = 1, kmax
            fn(k) = k
            do 10 l = 1, k
               fm(l)      = l - 1
               const(k,l) = dble((k - 2)**2 - (l - 1)**2) /
     >                      dble((2 * k - 3) * (2 * k - 5))
10          continue
20       continue
c
         do 40 k = 2, kmax
            sh(k,1) = dble(2 * k - 3) * sh(k-1,1) / dble(k - 1)
            jj      = 2
            do 30 l = 2,k
               sh(k,l) = sh(k,l-1) * dsqrt(dble((k - l + 1) * jj)
     >                   / (k + l - 2))
               jj      = 1
30          continue
40       continue
c
         ntot = 0
         do 60 k = 2, kmax
c
            gg(k,1)  = dble(lg(ntot+1))
            ggt(k,1) = dble(lgt(ntot+1))
c
            nm = 2 * k - 1
            do 50 l = 2, k
               inc      = 2 * l - 2
               gg(k,l)  = dble(lg(ntot+inc))
               ggt(k,l) = dble(lgt(ntot+inc))
               hh(k,l)  = dble(lg(ntot+inc+1))
               hht(k,l) = dble(lgt(ntot+inc+1))
50          continue
c
            ntot = ntot + nm
60       continue
c
         do 80 k = 2, kmax
            gg(k,1)  = gg(k,1) * sh(k,1) / f1
            ggt(k,1) = ggt(k,1) * sh(k,1) / f2
            do 70 l = 2, k
               gg(k,l)  = gg(k,l)  * sh(k,l) / f1
               ggt(k,l) = ggt(k,l) * sh(k,l) / f2
               hh(k,l)  = hh(k,l)  * sh(k,l) / f1
               hht(k,l) = hht(k,l) * sh(k,l) / f2
70          continue
80       continue
      endif
c
      if (year .ne. tmold) then
         tmold = year
         t     = year - tzero
         do 100 k = 2, kmax
            g(k,1) = gg(k,1) + t * ggt(k,1)
            do 90 l = 2,k
               g(k,l) = gg(k,l) + t * ggt(k,l)
               h(k,l) = hh(k,l) + t * hht(k,l)
90          continue
c
100      continue
c
      endif
c
      cph = dcos(phir)
      sph = dsin(phir)
c
      if (thetr .ne. 0.d0) then
         ct = dcos(thetr)
         st = dsin(thetr)
      else
         ct = 1.0d0
         st = 1.d-15
      endif
      sp(2) = sph
      cp(2) = cph
c
      do 110 k = 3, kmax
c
         sp(k) = sp(2) * cp(k-1) + cp(2) * sp(k-1)
         cp(k) = cp(2) * cp(k-1) - sp(2) * sp(k-1)
c
110   continue
      rrmag   = rre * rayt / rgmt
      aor     = 1.d0 / rrmag
      ar      = aor * aor * aor
      p(2,1)  = ct
      dp(2,1) = -st
      p(2,2)  = st
      dp(2,2) = ct
c
      br = -(2.d0 * ar) * (g(2,1) * p(2,1) + p(2,2)
     >     * (g(2,2) * cp(2) + h(2,2) * sp(2)))
      bt = ar * (g(2,1) * dp(2,1) + dp(2,2) * (g(2,2)
     >     * cp(2) + h(2,2) * sp(2)))
      bp = ar * (h(2,2) * cp(2) - g(2,2) * sp(2)) * p(2,2)
c
      do 130 k = 3, kmax
c
         ar = aor * ar
c
         do 120 l = 1, k
c
            if (k .eq. l) then
               p(k,k)  = st * p(k-1,k-1)
               dp(k,k) = st * dp(k-1,k-1) + ct * p(k-1,k-1)
            else
               p(k,l)  = ct * p(k-1,l) - const(k,l) * p(k-2,l)
               dp(k,l) = ct * dp(k-1,l) - st * p(k-1,l) - const(k,l)
     >                * dp(k-2,l)
            endif
c
            par = p(k,l) * ar
c
            if (l .eq. 1) then
               temp = g(k,l)
            else
               temp = g(k,l) * cp(l) + h(k,l) * sp(l)
               bp   = bp - (g(k,l) * sp(l) - h(k,l) *
     >                cp(l)) * fm(l) * par
            endif
            br = br - temp * fn(k) * par
            bt = bt + temp * dp(k,l) * ar
c
120      continue
c
130   continue
c
      bp = bp / st
c
c     ---------------------------------------
c*FON Expression du champ magnetique en gauss
c     ---------------------------------------
c
      br = br / 100000.d0
      bt = bt / 100000.d0
      bp = bp / 100000.d0
c
      bb = dsqrt(br * br + bt * bt + bp * bp)
c
c     ****************
c     Fin de programme
c     ****************
c
      return
      end