This function is meant to enable the parallel writing (with multiple threads) of several type 13 segments (discrete states of the positions and velocities, Hermite interpolation with variable timesteps) 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 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_..._tdb, end_..._tdb and deg parameters.
The array targets, record_counts and segids must be of size target_count.
The reservation id returned by this function must be used in the function writeph_spk13_par_write() to write in the corresponding reserved space.
In addition, the function writeph_spk13_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_spk13_par_reserve is always performed by a single thread and is followed by several calls to writeph_spk13_par_write() by one or several threads.
The following example creates a new ephemeris file ephemeris.bsp with segment of type 13 for the heliocentric coordinates of Mercury and Venus using OpenMP.
t_writephbin *weph;
weph = writeph_spk_create("ephemeris.bsp","planet_2", 0);
if (weph)
{
int frame = 1; /* ICRF */
int target_count = 2;
int targets[2] = { NAIFID_MERCURY, NAIFID_VENUS };
int records_count[2] = { 10, 20 };
int len_timespan[2] = { 32, 16 };
const char segids[2] = { "seg_mercury", "seg_venus" };
double jd_start = 2460000;
double jd_end = 2460000+32*10;
int reservation;
int interpolation_degree = 7;
reservation = writeph_spk13_seq_reserve(weph, target_count, targets, NAIFID_SUN,
frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, record_counts, interpolation_degree, 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 pos_vel[6]; /* size = 6 components */
double epochs[1]; /* size = 1 time */
epochs[0] = jd_start+k*len_timespan;
/* ... fill the array pos_vel with the positions and velocities at the date jd ...
pos_vel[..] =...
*/
writeph_spk13_par_write(weph, reservation, body, k, 1, pos_vel, epochs);
}
}
writeph_close(weph);
}