# Example 3 - evaluation of the third invariant

## Description

Evaluation of the third invariant of a magnetic drift shell labeled by a pair of (Bm, Lm) parameters. The magnetic field is described with the help of the DGRF/IGRF 1995 geomagnetic model.

The program contains three parts: the initialisation of the library and the magnetic model (UT990, UM510 and UM520), the tracing of the magnetic drift shell (UD310) and the evaluation of the third invariant (UD330). Note that subroutine UD317 can be used instead of subroutine UD310 (see note).

In this example the drift shell parameters are set to Bm = 0.19 Gauss and Lm = 2. The foot points of the magnetic drift shell in the Northern hemisphere are shown on the lefthand panel of the figure below. The crosses indicate the points used to evaluate the magnetic flux. In this case, the third invariant is equal to 3.8 10+7 Gauss km2 which corresponds to L* = 2.07. The righthand panel of the figure shows the foot points in the Southern hemisphere.

Note that the foot points of the drift shell are stored in the common block UC120 [arguments ``` mfl().footpn``` and ``` mfl().footps ```]. ## Source

```      PROGRAM example3
C
INCLUDE 'structure.h'
C
INTEGER*4    kunit, kinit, ifail, kint, kext
CHARACTER*32 lbint, lbext
REAL*8       year, param(10), amjd
INTEGER*4    knfl, ktyplus
REAL*8       fbm0, flm0, falt, phi, star
C
C     initialize variables
C
DATA kunit, kinit/ 6, 1/
DATA kint, kext/ 0, 0/
DATA year, param, amjd/ 1995.d0, 10*0.0d0, 0.0d0/
C
C     initialize the library
C
CALL UT990 (kunit, kinit, ifail)
IF( ifail .LT. 0 )STOP
C
C     set the geomagnetic field model
C     (kint=0, DGRF/IGRF)
C
CALL UM510 (kint, year, lbint, kunit, ifail)
IF( ifail .LT. 0 )STOP
C
C     set no external magnetic field model
C
C
CALL UM520 (kext, amjd, param,
:           lbext, kunit, ifail)
IF( ifail .LT. 0 )STOP
C
C     trace the drift shell
C
fbm0          =    0.19d0
flm0          =    2.0d0
falt          =    0.0d0
knfl          =   60
ktyplus       =    3
C
CALL UD310 (fbm0, flm0, falt, knfl,
:           ktyplus, ifail)
IF( ifail .LT. 0 )STOP
C
C     evaluate the third invariant
C
CALL UD330 (phi, star, ifail)
IF( ifail .LT. 0 )STOP
C
C     write the result
C
WRITE(*,*) phi,star
C
END
```

## Results

```
UNILIB Library
Version  2.01
Developed by BIRA/IASB for ESA

0500-020000-0500

--- Main control parameters ---

UC160 (general constants):
Geoid major axis = 6378.16     km
Geoid minor axis = 6356.77     km
Mean Earth radius (Re) = 6371.20     km
Ecliptic inclination =   23.441512 deg
McIlwain Earth dipole =    0.311653 G/Re^3

UC190 (field line tracing):
Maximum step size =  477.8      km at one Re
Maximum "last" step size =   15.0      km
Minimum step size =    2.0      km
Altitude precision =  200.       m
Magnetic field precision =    0.0006   %

UC192 (magnetic field evaluation):
Max. geomagnetic latitude =   85.0      deg
(drift shell tracing):
Precision on L =    0.10000  %
Precision on the longitude =    0.05     deg

--- Geomagnetic field model ---

Model ( 0): IGRF 1995                          Epoch 1995.
Order + 1 =   11
Calculation epoch = 1995.0      year
Colatitude of the dipole pole =   10.70     deg
Longitude of the dipole pole =  -71.41     deg
Earth dipole moment =    0.302077 G/Re^3
Correction for the SAA drift =    0.00     deg

--- External magnetic field model ---

Model (0): None
Planetary activity index Kp =    0.0      (magnetopause check)
Universal Time =    0.00     hrs
Greenwich angle of equinox =  100.08     deg
GEO direction of the Sun, X =   -0.9200
Y =   -0.0131
Z =   -0.3918
dipole tilt angle =  -25.92     deg
-38317592.4315653        2.07441404002132
```