subroutine grad15 (year,rre,thet,phi,br,bt,bp,bb,gradb,ier) c* c*********************************************************************** c* c*PRO MAGLIB c* c*VER 2017.02.24 - V 1.0 c* c*AUT spec. CNES - JC KOSIK - mars 2001 c*AUT port. CS-SI c*AUT adapt. AKKA c* c*ROL Theme : Modeles de champs magnetiques c*ROL Calcul du champ magnetique d'origine interne avec les c*ROL coefficients du modele IGRF 2015. c* c*PAR year (I) : annee fractionnaire (>= 2015.) c* c*PAR rre (I) : distance radiale geocentrique (rayons terrestres) c*PAR thet (I) : colatitude geocentrique (radians) c*PAR phi (I) : longitude geocentrique (radians) c* c*PAR br (O) : composante radiale du champ magnetique le long du c* : meridien positive vers l'exterieur (gauss) c*PAR bt (O) : composante tangentielle du champ magnetique le long c*PAR : du meridien positive vers le sud (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 gradb (O) : gradients du champ magnetique c*PAR : les quantites sont evaluees en unite de rayon terrestre c* c*PAR ier (O) : code de retour c* c*NOT ier : sans objet c* c*NOT Dans le cas ou l'angle thet est nul , son sinus est c*NOT remplacee par 1.d-15 afin d'eviter des divisions par 0 et c*NOT son cosinus est remplace par 1.0d0. c*NOT Dans le cas ou l'angle thet est egal a pi, son sinus est c*NOT remplacee par 1.d-15 afin d'eviter des divisions par 0 et c*NOT son cosinus est remplace par -1.0d0. c* c*NOT common : util, util2 c* c*HST version 2.0 - 2017.02.23 - utilisation du modele IGRF 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,thet,phi double precision br,bt,bp,bb double precision gradb(3,3) 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(14,14),lgt(14,14) c*LOC lg, lgt : coefficients du modele igrf2015 c integer n,m,jj c*LOC n,m,jj : indices de boucles et de tableaux c integer kmax c*LOC kmax : nombre de pas de calcul (= 14) c double precision dbrdr,dbrdt,dbrdp,dbtdr,dbtdt,dbtdp double precision dbpdr,dbpdt,dbpdp c*LOC dbrdr,dbrdt,dbrdp : derivees partielles des composantes radiale, c*LOC dbtdr,dbtdt,dbtdp : tangentielle et azimuthale du champ total c*LOC dbpdr,dbpdt,dbpdp : c double precision gg(14,14),ggt(14,14),shmit(14,14),g(14,14) double precision const(14,14),fn(14),fm(14) double precision p(14,14),dp(14,14),sp(14),cp(14) double precision d2p(14,14) double precision tmold,tzero,sphi,st,t,f2 double precision cphi,ct,f1,aor,aor3,aorn,daorn,rmag,rkm double precision temp1,dtemp1,d2temp1 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 data lg/10, > -294420,-24451,13507,9076,-2326,700,816,242,54,-19,31,-19,0, > 47971,-15010,30129,-23523,8137,3601,677,-761,88,88,-63,-15,-2, > -9, > -28456,-6419,16767,12256,1204,1924,727,-68,-169,31,1,-23,4,4, > -1153,2449,-5384,5820,-3349,-1409,-1299,518,-32,-33,5,20,12,5, > 2833,-1887,1809,-3295,704,-1575,-289,150,-206,7,-5,-8,-8,-5, > 473,1970,-1193,160,1002,41,132,94,134,-133,18,6,9,10, > -208,332,589,-667,73,626,-709,-28,117,-1,-7,-7,1,-2, > -541,-195,57,244,34,-274,-22,68,-159,87,21,2,5,8, > 101,-183,133,-146,162,57,-91,21,-20,-91,24,17,-3,-1, > -216,108,118,-68,-69,78,10,-40,84,-105,-18,-2,-4,3, > 32,-4,46,44,-79,-6,-42,-28,-12,-87,-36,4,2,1, > -1,20,-7,-11,8,-2,-22,-14,-25,-20,-24,35,-9,5, > -11,4,19,-22,3,7,-1,3,2,-9,-1,7,0,-4, > -9,4,16,-5,-12,-1,4,-1,4,5,-3,-4,-8,-3 > / c data lgt/10, > 103,-87,34,-7,-2,-3,3,2,0,0,0,0,0, > -266,181,-33,-55,2,5,-1,-2,0,0,0,0,0,0, > -274,-141,21,-7,-91,-13,-7,-5,-6,0,0,0,0,0, > 82,-4,18,-101,41,-1,21,13,5,0,0,0,0,0, > -13,53,29,-52,-43,14,-12,1,-2,0,0,0,0,0, > 6,17,-12,34,0,39,3,-6,4,0,0,0,0,0, > 0,-21,-7,2,9,10,16,-8,1,0,0,0,0,0, > 8,4,-2,-3,-6,1,-2,2,-4,0,0,0,0,0, > -3,3,1,5,-2,-3,3,0,3,0,0,0,0,0, > 0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,0,0,0,0,0,0,0,0,0,0,0,0,0 > / c data kmax /14/ c data p(1,1) /1.d0/ data cp(1) /1.d0/ data dp(1,1) /0.d0/ data sp(1) /0.d0/ c data shmit(1,1)/0.d0/ c data tmold/0.d0/ c data tzero/2015.d0/ c c ****************** c Debut de programme c ****************** c ier = 0 c c -------------------------------------------- c*FON Initialisation a 0. des composantes du champ c*FON ainsi que du module c -------------------------------------------- c br = 0.0d0 bt = 0.0d0 bp = 0.0d0 bb = 0.0d0 c c ------------------------------------------------- c*FON Initialisations faites au premier appel du module c ------------------------------------------------- c if (shmit(1,1) .ne. -1.d0) then c c mise a zero des constantes avant la premiere initialisation c do 8 n = 1, 14 fn(n) = 0.d0 do 9 m = 1, 14 fm(m) = 0.d0 const(n,m) = 0.d0 shmit(n,m) = 0.d0 dp(n,m) = 0.d0 d2p(n,m) = 0.d0 9 continue 8 continue c c ---------------------------------- c*FON Calcul des tableaux fn,fm et const c ---------------------------------- c shmit(1,1) = -1.d0 do 10 n = 1, 14 fn(n) = n do 20 m = 1, 14 fm(m) = m - 1 const(n,m) = dble((n - 2)**2 - (m - 1)**2) / > dble((2 * n - 3) * (2 * n - 5)) 20 continue 10 continue c c ---------------------------- c*FON Calcul du tableau shmit(n,m) c ---------------------------- c do 30 n = 2, 14 shmit(n,1) = dble(2 * n - 3) * shmit(n-1,1) / dble(n - 1) jj = 2 do 40 m = 2, n shmit(n,m) = shmit(n,m-1) * > sqrt(dble((n - m + 1) * jj) / (n + m - 2)) shmit(m-1,n) = shmit(n,m) jj = 1 40 continue 30 continue c c --------------------------------------- c*FON Calcul des tableaux gg(n,m) et ggt(n,m) c --------------------------------------- c f1 = dble(lg(1,1)) f2 = dble(lgt(1,1)) do 50 n = 1, kmax do 60 m = 1, kmax gg(n,m) = dble(lg(n,m)) * shmit(n,m) / f1 ggt(n,m) = dble(lgt(n,m)) * shmit(n,m) / f2 60 continue 50 continue c c -------------------------------------------------- c*FON Traitements effectues si ce n'est pas le 1er appel c -------------------------------------------------- c endif c c ------------------------ c*FON Calcul du tableau g(n,m) c ------------------------ c if (year .ne. tmold) then c tmold = year t = year - tzero c do 70 n = 1, kmax do 80 m = 1, kmax g(n,m) = gg(n,m) + t * ggt(n,m) 80 continue 70 continue c endif c c ---------------------------------------------------- c*FON Calcul des cosinus directeurs de la colatitude et de c*FON la longitude geocentriques c ---------------------------------------------------- c cphi = cos(phi) sphi = sin(phi) c if (thet .ne. 0.0d0 .and. thet .ne. acos(-1.0d0)) then c ct = cos(thet) st = sin(thet) c else c if (thet .ne. acos(-1.0d0)) then ct = 1.0d0 st = 1.d-15 elseif (thet .ne. 0.0d0) then ct = -1.0d0 st = 1.d-15 endif c endif c sp(2) = sphi cp(2) = cphi c c ---------------------------- c*FON Calcul des tableaux cp et sp c ---------------------------- c do 90 m = 3, kmax sp(m) = sp(2) * cp(m-1) + cp(2) * sp(m-1) cp(m) = cp(2) * cp(m-1) - sp(2) * sp(m-1) 90 continue c c --------------------------------------------------- c*FON Premiers termes des composantes du champ magnetique c --------------------------------------------------- c rkm = rre * rayt rmag = rkm / rgmt c aor = rgmt / rkm aor3 = aor * aor * aor c p(2,1) = ct dp(2,1) = -st d2p(2,1) = -ct p(2,2) = st dp(2,2) = ct d2p(2,2) = -st c br = -2.d0 * aor3 * > (g(2,1) * ct + (g(2,2) * cphi + g(1,2) * sphi) * st) c bt = aor3 * > (-g(2,1) * st + (g(2,2) * cphi + g(1,2) * sphi) * ct) c bp = aor3 * (g(1,2) * cphi - g(2,2) * sphi) c c ------------------------------------------ c*FON Calcul des 9 derivees partielles de depart c ------------------------------------------ c dbrdr = 6.d0 * aor3 * > (g(2,1) * ct + (g(2,2) * cphi + g(1,2) * sphi) * st) / rre c dbrdt = -2.d0 * aor3 * > (-g(2,1) * st + (g(2,2) * cphi + g(1,2) * sphi) * ct) c dbrdp = -2.d0 * aor3 * > (g(1,2) * cphi - g(2,2) * sphi) * st c dbtdr = -3.d0 * aor3 * > (-g(2,1) * st + (g(2,2) * cphi + g(1,2) * sphi) * ct) / rre c dbtdt = aor3 * > (-g(2,1) * ct - (g(2,2) * cphi + g(1,2) * sphi) * st) c dbtdp = aor3 * > (-g(2,2) * sphi + g(1,2) * cphi) * ct c dbpdr = -3.d0 * aor3 * > (g(1,2) * cphi - g(2,2) * sphi) / rre c dbpdt = 0.d0 c dbpdp = aor3 * (-g(2,2) * cphi - g(1,2) * sphi) c aorn = aor3 c c ----------------------------------------------------- c*FON Evaluation finale des composantes du champ magnetique c ----------------------------------------------------- c do 100 n = 3, kmax c aorn = aor * aorn daorn = -dble(n + 1) * aorn / rre c do 110 m = 1, n c if (m .eq. n) then c p(n,n) = st * p(n-1,n-1) dp(n,n) = st * dp(n-1,n-1) + ct * p(n-1,n-1) d2p(n,n) = ct * dp(n-1,n-1) + st * d2p(n-1,n-1) > - st * p(n-1,n-1) + ct * dp(n-1,n-1) c else c p(n,m) = ct * p(n-1,m) - const(n,m) * p(n-2,m) dp(n,m) = ct * dp(n-1,m) - st * p(n-1,m) - const(n,m) > * dp(n-2,m) d2p(n,m) = - st * dp(n-1,m) + ct * d2p(n-1,m) > - ct * p(n-1,m) - st * dp(n-1,m) > - const(n,m) * d2p(n-2,m) c endif c if (m .eq. 1) then c temp1 = g(n,m) dtemp1 = 0.d0 d2temp1 = 0.d0 c else c temp1 = g(n,m) * cp(m) + g(m-1,n) * sp(m) dtemp1 = fm(m) * (-g(n,m) * sp(m) + g(m-1,n) * cp(m)) d2temp1 = -fm(m) * fm(m) * temp1 c endif c br = br - temp1 * p(n,m) * aorn * fn(n) bt = bt + temp1 * dp(n,m) * aorn bp = bp + dtemp1 * p(n,m) * aorn / st c dbrdr = dbrdr - temp1 * p(n,m) * daorn * fn(n) dbrdt = dbrdt - temp1 * dp(n,m) * aorn * fn(n) dbrdp = dbrdp - dtemp1 * p(n,m) * aorn * fn(n) c dbtdr = dbtdr + temp1 * dp(n,m) * daorn dbtdt = dbtdt + temp1 * d2p(n,m) * aorn dbtdp = dbtdp + dtemp1 * dp(n,m) * aorn c dbpdr = dbpdr + dtemp1 * p(n,m) * daorn / st dbpdt = dbpdt + dtemp1 * aorn * > (dp(n,m) - ct * p(n,m) / st) / st dbpdp = dbpdp + d2temp1 * p(n,m) * aorn / st c 110 continue c 100 continue c c mise en memoire des gradients de champ c gradb(1,1) = dbrdr gradb(1,2) = dbrdt gradb(1,3) = dbrdp gradb(2,1) = dbtdr gradb(2,2) = dbtdt gradb(2,3) = dbtdp gradb(3,1) = dbpdr gradb(3,2) = dbpdt gradb(3,3) = dbpdp c bb = sqrt(bp * bp + bt * bt + br * br) c c **************** c Fin de programme c **************** c return end