pro magfld, jd, p, b ; ; Given a double-precision Julian date and fraction (UT) and a geocentric ; position vector (direction, distance) in the Earth-centered inertial ; (ECI) frame, this procedure returns the Earth's magnetic field vector ; (direction, magnitude) in the ECI frame. ; ; B. Knapp, 1998-11-19, 1999-06-25, 2001-04-20 (WMM2000), ; 2006-03-27 (WMM2005) ; ; The present implementation uses the "World Magnetic Model 2005" (WMM2005) ; which includes a secular variation which is valid from 2005 to 2010. ; ; The output argument STATUS is returned non-zero if an error ; occurred. ; ; Print usage? if n_params() lt 3 or n_elements( p ) ne 4 then begin print, " " print, " MagFld is a procedure which given a UT date/time (as a Julian" print, " Day Number and fraction) and a geocentric position vector in" print, " the Earth-centered inertial (ECI) frame, returns the Earth's" print, " magnetic field (main field) vector in the same ECI frame. The" print, " input position vector p must be a 4-vector with the first 3" print, " elements being a unit vector giving the direction, and the 4th" print, " element the distance from the center of the Earth in km. The" print, " output vector b is also a 4-vector, with the first 3 elements" print, " a unit vector giving the field direction, and the 4th element" print, " the field magnitude in nTesla. The input Julian Day Number" print, " and fraction must be sufficiently precise to specify the UT" print, " time-of-day, since the Earth's magnetic field depends on the" print, " geographic longitude. The World Magnetic Model 2005 is used," print, " which specifies a secular variation valid from 2005 to 2010." print, " " print, " Usage:" print, " magfld, jd, p, b" print, " " return endif ; ; Use 32-bit or 64-bit shareable object library? mbits = ((!version.release ge 5.4) ? !version.memory_bits : 32) dll = getenv('bgkroot')+string(mbits,"('/lib/astron',i2,'.so')") ; ; Cast inputs and define outputs for the external call jd_loc = double( jd ) p_loc = double( p ) b = dblarr( 4 ) result = call_external( dll, 'magfld_arg_', jd_loc, p_loc, b ) ; return end