Library interface

A simple example program

The following example program shows the typical usage of the Fortran 77/90/95 interface.

Other examples using the Fortran 77/90/95 interface can be found in the directory examples of the library sources.

program F90example
    implicit none
    include 'f90calceph.h'
    integer res
    double precision AU
    integer*8 :: peph

    res = f90calceph_open(peph, "example1.dat")
    if (res.eq.1) then
      write (*,*) "The ephemeris is already opened"
      if (f90calceph_getconstant(peph, "AU", AU).eq.1) then
            write (*,*) "AU=", AU
      endif
      call f90calceph_close(peph)
      write (*,*) "The ephemeris is already closed"
    endif
stop
end

Constants

The following constants are defined in the file f90calceph.h.

CALCEPH_MAX_CONSTANTNAME [integer]

This integer defines the maximum number of characters, including the trailing '\0', that the name of a constant, available from the ephemeris file, could contain.

CALCEPH_MAX_CONSTANTVALUE [integer]

This integer defines the maximum number of characters, including the trailing '\0', that the value of a constant, available from the ephemeris file, could contain if the value is stored as a string of characters.

CALCEPH_VERSION_MAJOR [integer]

This integer constant defines the major revision of this library. It can be used to distinguish different releases of this library.

CALCEPH_VERSION_MINOR [integer]

This integer constant defines the minor revision of this library. It can be used to distinguish different releases of this library.

CALCEPH_VERSION_PATCH [integer]

This integer constant defines the patch level revision of this library. It can be used to distinguish different releases of this library.

CALCEPH_VERSION_STRING [character(len=*)]

This string is the version of the library, which can be compared to the result of calceph_getversion to check at run time if the header file and library used match:

Note: Obtaining different strings is not necessarily an error, as in general, a program compiled with some old CALCEPH version can be dynamically linked with a newer CALCEPH library version (if allowed by the operating system).

CALCEPH_ASTEROID [integer]

This integer defines the offset value for the asteroids that must be used as target or center for the computation functions, such as f90calceph_compute().

The following constants specify in which units are expressed the output of the computation functions, such as f90calceph_compute_unit() :

CALCEPH_UNIT_AU [integer]

This integer defines that the unit of the positions and velocities is expressed in astronomical unit.

CALCEPH_UNIT_KM [integer]

This integer defines that the unit of the positions and velocities is expressed in kilometer.

CALCEPH_UNIT_DAY [integer]

This integer defines that the unit of the velocities or the quantity TT-TDB or TCG-TCB is expressed in day (one day=86400 seconds).

CALCEPH_UNIT_SEC [integer]

This integer defines that the unit of the velocities or the quantity TT-TDB or TCG-TCB is expressed in second.

CALCEPH_UNIT_RAD [integer]

This integer defines that the unit of the angles is expressed in radian.

CALCEPH_OUTPUT_EULERANGLES [integer]

This integer defines that the output array contains the euler angles.

CALCEPH_OUTPUT_NUTATIONANGLES [integer]

This integer defines that the output array contains the nutation angles.

CALCEPH_USE_NAIFID [integer]

This integer defines that the NAIF identification numbers are used as target or center for the computation functions, such as f90calceph_compute_unit().

The following constants specify the type of segments for the functions, such as f90calceph_getmaxsupportedorder() :

CALCEPH_SEGTYPE_ORIG_0 [integer]

This integer defines the type of segment for the original INPOP/JPL DE file format.

CALCEPH_SEGTYPE_SPK_1 [integer]
CALCEPH_SEGTYPE_SPK_2 [integer]
CALCEPH_SEGTYPE_SPK_3 [integer]
CALCEPH_SEGTYPE_SPK_5 [integer]
CALCEPH_SEGTYPE_SPK_8 [integer]
CALCEPH_SEGTYPE_SPK_9 [integer]
CALCEPH_SEGTYPE_SPK_12 [integer]
CALCEPH_SEGTYPE_SPK_13 [integer]
CALCEPH_SEGTYPE_SPK_14 [integer]
CALCEPH_SEGTYPE_SPK_17 [integer]
CALCEPH_SEGTYPE_SPK_18 [integer]
CALCEPH_SEGTYPE_SPK_19 [integer]
CALCEPH_SEGTYPE_SPK_20 [integer]
CALCEPH_SEGTYPE_SPK_21 [integer]
CALCEPH_SEGTYPE_SPK_102 [integer]
CALCEPH_SEGTYPE_SPK_103 [integer]
CALCEPH_SEGTYPE_SPK_120 [integer]

This integer defines the type of segments (1, 2, 3, 5, 8, 9, 12, 13, 14, 17, 18, 20, 21, 102, 103 and 120) for the SPICE Kernel files.