This function is meant to enable the parallel writing (with multiple threads) of several type 103 segments (Chebyshev polynomials of the position and velocity ) in the time scale TCB to the SPK file associated to the ephemeris descriptor eph. It reserves space in the file for target_count segments, each segment associated to a target in the targets array. Each target has its own interpolation interval length specified in the intlens_jd_tcb array, its own number of records specified in the record_counts array, and its own segment identifier specified in the segids array. All the targets share the same center, frame, start_..._tcb, end_..._tcb and deg parameters.

The array targets, intlens_jd_tcb, record_counts and segids must be of size target_count.

The reservation id returned by this function must be used in the function writeph_spk103_par_write() to write in the corresponding reserved space. In addition, the function writeph_spk103_par_write() will require a target_index, which is the index of the target in the targets array used in this function.

A call to writeph_spk103_par_reserve is always performed by a single thread and is followed by several calls to writeph_spk103_par_write() by one or several threads.

Warning

The data covers the same timespan from the date start_jd_tcb+start_frac_tcb to end_jd_tcb+end_frac_tcb for all targets, but each target may have a different number of polynomials. The time span record_counts*intlens_jd_tcb must be equal to the timespan defined from the date start_jd_tcb+start_frac_tcb to end_jd_tcb+end_frac_tcb. If the targets doesnot have the timespan, multiple reservations must be performed before the call to writing writeph_spk103_par_write().

The following example creates a new ephemeris file ephemeris.bsp with segment of type 103 for the heliocentric coordinates of Mercury and Venus, in the timescale TCB, using OpenMP.

USE, INTRINSIC :: ISO_C_BINDING
use calceph
TYPE(C_PTR) :: weph
INTEGER len_timespan
REAL(8) :: jd_start, jd_end
INTEGER frame, degree, body, k, ret
REAL(8), dimension(78) :: coefs !  size = 13*6  = (degree+1) * 6 components
INTEGER, dimension(2) :: record_counts, targets
INTEGER target_count, reservation
REAL(8), dimension(2) :: len_timespan
CHARACTER(len=40), dimension (2) :: segids

frame = 1 ! ICRF
target_count = 2
targets(1) = NAIFID_MERCURY
targets(2) = NAIFID_VENUS
len_timespan(1) = 32
len_timespan(2) = 16
record_counts(1) = 10
record_counts(2) = 20
segids(1) = "seg_mercury"//C_NULL_CHAR
segids(2) = "seg_venus"//C_NULL_CHAR
degree = 12
jd_start = 2460000
jd_end = jd_start+32*10

weph = writeph_spk_create("ephemeris.bsp"//C_NULL_CHAR, "planet_2"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(weph)) then

     reservation = writeph_spk103_seq_reserve(weph, target_count, targets, NAIFID_SUN,
                            frame, jd_start, 0.0, jd_end, 0.0,
                            len_timespan, record_counts, degree+1, segids)

     !$omp parallel for private(body)
     do body=0, target_count
          !$omp parallel for private(k, coefs)
          do k=0, record_counts(body)-1
               ! ... fill the array coefs with the coefficients of the Chebychev polynomials ...
               ! coefs(...) =...
               writeph_spk103_par_write(weph, reservation, body,  k, 1,  coefs)
          enddo
     enddo
     call writeph_close(weph)
endif