This function is meant to enable the parallel writing (with multiple threads) of several type 3 segments (Chebyshev polynomials of the angles and their derivatives) to the PCK 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_tdb 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 frame, start_..._tdb, end_..._tdb and deg parameters.

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

The reservation id returned by this function must be used in the function writeph_pck3_par_write() to write in the corresponding reserved space. In addition, the function writeph_pck3_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_pck3_par_reserve is always performed by a single thread and is followed by several calls to writeph_pck3_par_write() by one or several threads.

Warning

The data covers the same timespan from the date start_jd_tdb+start_frac_tdb to end_jd_tdb+end_frac_tdb for all targets, but each target may have a different number of polynomials. The time span record_counts*intlens_jd_tdb must be equal to the timespan defined from the date start_jd_tdb+start_frac_tdb to end_jd_tdb+end_frac_tdb. If the targets doesnot have the timespan, multiple reservations must be performed before the call to writing writeph_pck3_par_write().

The following example creates a new ephemeris file ephemeris.bsp with segment of type 3 for the orientation of two bodiesusing OpenMP.

t_writephbin *weph;

weph = writeph_pck_create("ephemeris.bpc","planet_2", 0);
if (weph)
{
      int frame = 1; /* ICRF */
      int degree = 12;
      int target_count = 2;
      int targets[2] = { 3000099, 4000099 };
      int records_count[2] = { 10, 20 };
      int len_timespan[2] = { 32, 16 };
      const char segids[2] = { "seg_body1",  "seg_body2" };
      double jd_start = 2460000;
      double jd_end = 2460000+32*10;
      int reservation;

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

      #pragma omp parallel for
      for (int body = 0; body<target_count; body++)
      {
           #pragma omp parallel for
           for (int k=0; k<records_count[body]; k++)
           {
               double coefs[78];  /*  size = 13*6  = (degree+1) * 6 components */

               double jd_startk = jd_start+k*len_timespan[body];
               double jd_endk = jd_start+(k+1)*len_timespan[body];


               /* ... fill the array coefs with the coefficients of the Chebychev polynomials ...
                   coefs[..] =...
               */
               writeph_pck3_par_write(weph, reservation, body,  k, 1,  coefs);
           }
      }


      writeph_close(weph);
}