integer res
real(8) jd0
real(8) dt1
real(8) P(3)
real(8) PVAJ(12)
TYPE(C_PTR) :: peph

jd0 = 2442457
dt1 = 0.5D0
peph = calceph_open("example1.dat"//C_NULL_CHAR)
if (C_ASSOCIATED(peph)) then

   ! compute only the heliocentric position of Mars in km
   res = calceph_compute_order(peph, jd0, dt1,
&                     NAIFID_MARS_BARYCENTER,
&                     NAIFID_SUN,
&                     CALCEPH_USE_NAIFID+CALCEPH_UNIT_KM+CALCEPH_UNIT_SEC,
&                     0, P);
   write(*,*) P

   ! compute positions, velocities, accelerations and jerks of Mars in km and seconds
   res = calceph_compute_order(peph, jd0, dt1,
&                     NAIFID_MARS_BARYCENTER,
&                     NAIFID_SUN,
&                     CALCEPH_USE_NAIFID+CALCEPH_UNIT_KM+CALCEPH_UNIT_SEC,
&                     3, PVAJ);
   write(*,*) PVAJ

    call calceph_close(peph)
 endif