writeph_pck_create
- function writeph_pck_create(filename, ifname, flags) BIND(C)
- Parameters:
filename [CHARACTER(len=1,kind=C_CHAR), intent(in)] :: pathname of the file
ifname [CHARACTER(len=1,kind=C_CHAR), intent(in)] :: internal filename (max 60 characters)
flags [INTEGER(C_INT), VALUE, intent(in))] :: reserved for future extensions (must be zero)
This function creates for writing a new PCK file whose pathname is the string pointed to by filename, and returns an ephemeris descriptor associated to it. If a file with the same name already exists, it is overwritten.
The function writeph_close() must be called to free memory allocated by this function.
The function writeph_dump() and writeph_restore() can be called to create a checkpoint restart if the creation of the file is very long.
The following example creates and writes the ephemeris file ephemeris.bpc
USE, INTRINSIC :: ISO_C_BINDING
use calceph
TYPE(C_PTR) :: weph
weph = writeph_pck_create("ephemeris.bpc"//C_NULL_CHAR, "asteroid_1"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(weph)) then
! ... computation ...
call writeph_close(weph)
endif
writeph_pck_open
- function writeph_pck_open(filename) BIND(C)
- Parameters:
filename [CHARACTER(len=1,kind=C_CHAR), intent(in)] :: pathname of the file
This function opens an existing PCK ephemeris file in order to append ephemeris data to it, whose pathname is the string pointed to by filename, and returns an ephemeris descriptor associated to it. If the file doesn't exist, or if it isn't a PCK file, the function fails and returns NULL. This file must be compliant to the format specified by the 'SPICE' PCK ephemeris file.
The function writeph_close() must be called to free memory allocated by this function.
The following example appends data the ephemeris file ephemeris.bpc
USE, INTRINSIC :: ISO_C_BINDING
use calceph
TYPE(C_PTR) :: weph
weph = writeph_pck_open("ephemeris.bpc"//C_NULL_CHAR)
if (C_ASSOCIATED(weph)) then
! ... computation ...
call writeph_close(weph)
endif
The following PCK functions are to be used to write binary PCK files:
writeph_pck2_seq_write
- function writeph_pck2_seq_write(eph, target, frame, start_jd0_tdb, start_frac_tdb, end_jd0_tdb, end_frac_tdb, intlen_jd_tdb, polynomials, record_count, deg, segid) BIND(C)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
target [INTEGER(C_INT), VALUE, intent(in)] :: The body or reference point whose coordinates will be written (see NAIF identification numbers).
frame [INTEGER(C_INT), VALUE, intent(in)] :: reference frame (see Frame numbers).
start_jd0_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date integer part (TDB).
start_frac_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date fraction part (TDB).
end_jd0_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date integer part (TDB).
end_frac_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date fraction part (TDB).
intlen_jd_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: length of the interpolation interval (in days, TDB).
polynomials [REAL(C_DOUBLE), dimension(*), intent(in)] :: array of Chebyshev polynomial coefficients.
record_count [INTEGER(C_INT), VALUE, intent(in)] :: number of records to be written.
deg [INTEGER(C_INT), VALUE, intent(in)] :: degree of the Chebyshev polynomials.
segid [CHARACTER(len=1,kind=C_CHAR), intent(in)] :: segment identifier (must be unique within the file, max 40 characters).
- Return:
writeph_pck2_seq_write [INTEGER(C_INT)] :: 0 if an error occurs, otherwise non-zero value.
This function writes in sequential mode a type 2 segment (Chebyshev polynomials of Chebyshev polynomials of the angles only) in the time scale TDB to the PCK file associated to the ephemeris descriptor eph.
The polynomials array must be of size record_count*(deg+1)*3 and have the following structure :
E1's 1st coef 1st record. |
... |
E1's (deg + 1)th coef 1st record. |
E2's 1st coef 1st record. |
... |
E2's (deg + 1)th coef 1st record. |
E3's 1st coef 1st record. |
... |
E3's (deg + 1)th coef 1st record. |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
The following example creates a new ephemeris file ephemeris.bsp with segment of type 2 for the orientation of one body.
USE, INTRINSIC :: ISO_C_BINDING
use calceph
TYPE(C_PTR) :: weph
INTEGER len_timespan
REAL(8) :: jd_start, jd_end
INTEGER frame, record_count, degree, k, ret
REAL(8), dimension(390) :: coefs ! size = 10*13*3 = record_count * (degree+1) * 3 components
len_timespan = 32 ! days
frame = 1 ! ICRF
record_count = 10
degree = 12
jd_start = 2460000
jd_end = jd_start+record_count*len_timespan
weph = writeph_pck_create("ephemeris.bpc"//C_NULL_CHAR, "planet_2"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(weph)) then
do k=0, record_count-1
! ... fill the array coefs with the coefficients of the Chebychev polynomials ...
! coefs(...) =...
enddo
ret = writeph_pck2_seq_write(weph, 4000099, frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, coefs, record_count, degree+1, "seg_planet"//C_NULL_CHAR)
call writeph_close(weph)
endif
writeph_pck2_par_reserve
- function writeph_pck2_par_reserve(eph, target_count, targets, frame, start_jd0_tdb, start_frac_tdb, end_jd0_tdb, end_frac_tdb, intlens_jd_tdb, record_counts, deg, segids)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
target_count [INTEGER(C_INT), VALUE, intent(in)] :: number of targets the reservation is done for.
targets [INTEGER(C_INT), dimension(*), intent(in)] :: array of bodies or reference points whose coordinates will be written (see NAIF identification numbers).
frame [INTEGER(C_INT), VALUE, intent(in)] :: reference frame (see Frame numbers).
start_jd0_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date integer part (TDB).
start_frac_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date fraction part (TDB).
end_jd0_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date integer part (TDB).
end_frac_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date fraction part (TDB).
intlens_jd_tdb [REAL(C_DOUBLE), dimension(*), intent(in)] :: array containing the interpolation interval length for each target (in days, TDB).
record_counts [INTEGER(C_INT), dimension(*), intent(in)] :: array of number of records for each target.
deg [INTEGER(C_INT), VALUE, intent(in)] :: degree of the Chebyshev polynomials.
segids [CHARACTER(len=1,kind=C_CHAR), dimension(*), intent(in)] :: array of segment identifiers (one per target, each must be unique within the file, max 40 characters).
- Return:
writeph_pck2_par_reserve [INTEGER(C_INT)] :: return a reservation identifier on success, 0 on failure.
This function is meant to enable the parallel writing (with multiple threads) of several type 2 segments (Chebyshev polynomials of the angle only) in the time scale TDB 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 arrays 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_pck2_par_write() to write in the corresponding reserved space.
In addition, the function writeph_pck2_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_pck2_par_reserve() is always performed by a single thread and is followed by several calls to writeph_pck2_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_pck2_par_write().
The following example creates a new ephemeris file ephemeris.bsp with segment of type 2 for the orientation of two bodies 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(39) :: coefs ! size = 13*3 = (degree+1) * 3 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) = 3000099
targets(2) = 4000099
len_timespan(1) = 32
len_timespan(2) = 16
record_counts(1) = 10
record_counts(2) = 20
segids(1) = "seg_body1"//C_NULL_CHAR
segids(2) = "seg_body2"//C_NULL_CHAR
degree = 12
jd_start = 2460000
jd_end = jd_start+32*10
weph = writeph_pck_create("ephemeris.bpc"//C_NULL_CHAR, "planet_2"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(weph)) then
reservation = writeph_pck2_seq_reserve(weph, target_count, targets,
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(...) =...
ret = writeph_pck2_par_write(weph, reservation, body, k, 1, coefs)
enddo
enddo
call writeph_close(weph)
endif
writeph_pck2_par_write
- function writeph_pck2_par_write(eph, reservation, target_index, record_begin_index, record_count, polynomials) BIND(C)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
reservation [INTEGER(C_INT), VALUE, intent(in)] :: reservation identifier.
target_index [INTEGER(C_INT), VALUE, intent(in)] :: index of the target body in the reservation.
record_begin_index [INTEGER(C_INT), VALUE, intent(in)] :: index of the first record to be written in the target's segment.
record_count [INTEGER(C_INT), VALUE, intent(in)] :: number of records to be written.
polynomials [REAL(C_DOUBLE), dimension(*), intent(in)] :: array of Chebyshev polynomial coefficients.
- Return:
writeph_pck2_par_write [INTEGER(C_INT)] :: 0 if an error occurs, otherwise non-zero value.
This function writes in parallel mode records of a type 2 segment (Chebyshev polynomials of the angle only) in the time scale TDB to the PCK file associated to the ephemeris descriptor eph.
The reservation parameter must be the reservation id returned by the function writeph_pck2_par_reserve().
The target_index parameter is the index of the target in the targets array that was passed to the function writeph_pck2_par_reserve().
The record_begin_index parameter is the index of the first record to be written in the target's segment.
The record_count parameter is the number of records to be written starting from the record_begin_index.
The polynomials array must be of size record_count*(deg+1)*3 and have the following structure :
E1's 1st coef 1st record. |
... |
E1's (deg + 1)th coef 1st record. |
E2's 1st coef 1st record. |
... |
E2's (deg + 1)th coef 1st record. |
E3's 1st coef 1st record. |
... |
E3's (deg + 1)th coef 1st record. |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
With the 1st record being the record at index record_begin_index, and the (record_count)th record being the record at index record_begin_index + record_count - 1.
Multiple threads can call this function at the same time, but with different values of target_index and/or record_begin_index. The behavior is undefined if multiple threads overlap the written data : e.g., two threads write to the same target target_index and a common record number.
writeph_pck3_seq_write
- function writeph_pck3_seq_write(eph, target, frame, start_jd0_tdb, start_frac_tdb, end_jd0_tdb, end_frac_tdb, intlen_jd_tdb, polynomials, record_count, deg, segid) BIND(C)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
target [INTEGER(C_INT), VALUE, intent(in)] :: The body or reference point whose coordinates will be written (see NAIF identification numbers).
frame [INTEGER(C_INT), VALUE, intent(in)] :: reference frame (see Frame numbers).
start_jd0_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date integer part (TDB).
start_frac_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date fraction part (TDB).
end_jd0_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date integer part (TDB).
end_frac_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date fraction part (TDB).
intlen_jd_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: length of the interpolation interval (in days, TDB).
polynomials [REAL(C_DOUBLE), dimension(*), intent(in)] :: array of Chebyshev polynomial coefficients.
record_count [INTEGER(C_INT), VALUE, intent(in)] :: number of records to be written.
deg [INTEGER(C_INT), VALUE, intent(in)] :: degree of the Chebyshev polynomials.
segid [CHARACTER(len=1,kind=C_CHAR), intent(in)] :: segment identifier (must be unique within the file, max 40 characters).
- Return:
writeph_pck3_seq_write [INTEGER(C_INT)] :: 0 if an error occurs, otherwise non-zero value.
This function writes in sequential mode a type 3 segment (Chebyshev polynomials of the angles and their derivatives) in the time scale TDB to the PCK file associated to the ephemeris descriptor eph.
The polynomials array must be of size record_count*(deg+1)*6 and have the following structure :
E1's 1st coef 1st record |
... |
E1's (deg + 1)th coef 1st record |
E2's 1st coef 1st record |
... |
E2's (deg + 1)th coef 1st record |
E3's 1st coef 1st record |
... |
E3's (deg + 1)th coef 1st record |
dE1's 1st coef 1st record |
... |
dE1's (deg + 1)th coef 1st record |
dE2's 1st coef 1st record |
... |
dE2's (deg + 1)th coef 1st record |
dE3's 1st coef 1st record |
... |
dE3's (deg + 1)th coef 1st record |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
dE1's 1st coef (record_count)th record |
... |
dE1's (deg + 1)th coef (record_count)th record |
dE2's 1st coef (record_count)th record |
... |
dE2's (deg + 1)th coef (record_count)th record |
dE3's 1st coef (record_count)th record |
... |
dE3's (deg + 1)th coef (record_count)th record |
The following example creates a new ephemeris file ephemeris.bsp with segment of type 3 for the orientation of one body.
USE, INTRINSIC :: ISO_C_BINDING
use calceph
TYPE(C_PTR) :: weph
INTEGER len_timespan
REAL(8) :: jd_start, jd_end
INTEGER frame, record_count, degree, k, ret
REAL(8), dimension(780) :: coefs ! size = 780 = record_count * (degree+1) * 6 components
len_timespan = 32 ! days
frame = 1 ! ICRF
record_count = 10
degree = 12
jd_start = 2460000
jd_end = jd_start+record_count*len_timespan
weph = writeph_pck_create("ephemeris.bpc"//C_NULL_CHAR, "planet_2"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(weph)) then
do k=0, record_count-1
! ... fill the array coefs with the coefficients of the Chebychev polynomials ...
! coefs(...) =...
enddo
ret = writeph_pck3_seq_write(weph, 4000099, frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, coefs, record_count, degree+1, "seg_planet"//C_NULL_CHAR)
call writeph_close(weph)
endif
writeph_pck3_par_reserve
- function writeph_pck3_par_reserve(eph, target_count, targets, frame, start_jd0_tdb, start_frac_tdb, end_jd0_tdb, end_frac_tdb, intlens_jd_tdb, record_counts, deg, segids)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
target_count [INTEGER(C_INT), VALUE, intent(in)] :: number of targets the reservation is done for.
targets [INTEGER(C_INT), dimension(*), intent(in)] :: array of bodies or reference points whose coordinates will be written (see NAIF identification numbers).
frame [INTEGER(C_INT), VALUE, intent(in)] :: reference frame (see Frame numbers).
start_jd0_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date integer part (TDB).
start_frac_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date fraction part (TDB).
end_jd0_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date integer part (TDB).
end_frac_tdb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date fraction part (TDB).
intlens_jd_tdb :: array containing the interpolation interval length for each target (in days, TDB).
record_counts [INTEGER(C_INT), dimension(*), intent(in)] :: array of number of records for each target.
deg [INTEGER(C_INT), VALUE, intent(in)] :: degree of the Chebyshev polynomials.
segids [CHARACTER(len=1,kind=C_CHAR), dimension(*), intent(in)] :: array of segment identifiers (one per target, each must be unique within the file, max 40 characters).
- Return:
writeph_pck3_par_reserve [INTEGER(C_INT)] :: return a reservation identifier on success, 0 on failure.
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.
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) = 3000099
targets(2) = 4000099
len_timespan(1) = 32
len_timespan(2) = 16
record_counts(1) = 10
record_counts(2) = 20
segids(1) = "seg_body1"//C_NULL_CHAR
segids(2) = "seg_body2"//C_NULL_CHAR
degree = 12
jd_start = 2460000
jd_end = jd_start+32*10
weph = writeph_pck_create("ephemeris.bpc"//C_NULL_CHAR, "planet_2"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(weph)) then
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)
!$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(...) =...
ret = writeph_pck3_par_write(weph, reservation, body, k, 1, coefs)
enddo
enddo
call writeph_close(weph)
endif
writeph_pck3_par_write
- function writeph_pck3_par_write(eph, reservation, target_index, record_begin_index, record_count, polynomials) BIND(C)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
reservation [INTEGER(C_INT), VALUE, intent(in)] :: reservation identifier.
target_index [INTEGER(C_INT), VALUE, intent(in)] :: index of the target body in the reservation.
record_begin_index [INTEGER(C_INT), VALUE, intent(in)] :: index of the first record to be written in the target's segment.
record_count [INTEGER(C_INT), VALUE, intent(in)] :: number of records to be written.
polynomials [REAL(C_DOUBLE), dimension(*), intent(in)] :: array of Chebyshev polynomial coefficients.
- Return:
writeph_pck3_par_write [INTEGER(C_INT)] :: 0 if an error occurs, otherwise non-zero value.
This function writes in parallel mode records of a type 3 segment (Chebyshev polynomials of the angles and their derivatives) in the time scale TDB to the PCK file associated to the ephemeris descriptor eph.
The reservation parameter must be the reservation id returned by the function writeph_pck3_par_reserve().
The target_index parameter is the index of the target in the targets array that was passed to the function writeph_pck3_par_reserve(), starting from 0.
The record_begin_index parameter is the index of the first record to be written in the target's segment, starting from 0.
The record_count parameter is the number of records to be written starting from the record_begin_index.
The polynomials array must be of size record_count*(deg+1)*6 and have the following structure :
E1's 1st coef 1st record |
... |
E1's (deg + 1)th coef 1st record |
E2's 1st coef 1st record |
... |
E2's (deg + 1)th coef 1st record |
E3's 1st coef 1st record |
... |
E3's (deg + 1)th coef 1st record |
dE1's 1st coef 1st record |
... |
dE1's (deg + 1)th coef 1st record |
dE2's 1st coef 1st record |
... |
dE2's (deg + 1)th coef 1st record |
dE3's 1st coef 1st record |
... |
dE3's (deg + 1)th coef 1st record |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
dE1's 1st coef (record_count)th record |
... |
dE1's (deg + 1)th coef (record_count)th record |
dE2's 1st coef (record_count)th record |
... |
dE2's (deg + 1)th coef (record_count)th record |
dE3's 1st coef (record_count)th record |
... |
dE3's (deg + 1)th coef (record_count)th record |
With the 1st record being the record at index record_begin_index, and the (record_count)th record being the record at index record_begin_index + record_count - 1.
Multiple threads can call this function at the same time, but with different values of target_index and/or record_begin_index. The behavior is undefined if multiple threads overlap the written data : e.g., two threads write to the same target target_index and a common record number.
writeph_pck102_seq_write
- function writeph_pck102_seq_write(eph, target, frame, start_jd0_tcb, start_frac_tcb, end_jd0_tcb, end_frac_tcb, intlen_jd_tcb, polynomials, record_count, deg, segid) BIND(C)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
target [INTEGER(C_INT), VALUE, intent(in)] :: The body or reference point whose coordinates will be written (see NAIF identification numbers).
frame [INTEGER(C_INT), VALUE, intent(in)] :: reference frame (see Frame numbers).
start_jd0_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date integer part (TCB).
start_frac_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date fraction part (TCB).
end_jd0_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date integer part (TCB).
end_frac_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date fraction part (TCB).
intlen_jd_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: length of the interpolation interval (in days, TCB).
polynomials [REAL(C_DOUBLE), dimension(*), intent(in)] :: array of Chebyshev polynomial coefficients.
record_count [INTEGER(C_INT), VALUE, intent(in)] :: number of records to be written.
deg [INTEGER(C_INT), VALUE, intent(in)] :: degree of the Chebyshev polynomials.
segid [CHARACTER(len=1,kind=C_CHAR), intent(in)] :: segment identifier (must be unique within the file, max 40 characters).
- Return:
writeph_pck102_seq_write [INTEGER(C_INT)] :: 0 if an error occurs, otherwise non-zero value.
This function writes in sequential mode a type 102 segment (Chebyshev polynomials of the angle only) in the time scale TCB to the PCK file associated to the ephemeris descriptor eph.
The polynomials array must be of size record_count*(deg+1)*3 and have the following structure :
E1's 1st coef 1st record. |
... |
E1's (deg + 1)th coef 1st record. |
E2's 1st coef 1st record. |
... |
E2's (deg + 1)th coef 1st record. |
E3's 1st coef 1st record. |
... |
E3's (deg + 1)th coef 1st record. |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
The following example creates a new ephemeris file ephemeris.bsp with segment of type 2 for the orientation of one body, in the timescale TCB.
USE, INTRINSIC :: ISO_C_BINDING
use calceph
TYPE(C_PTR) :: weph
INTEGER len_timespan
REAL(8) :: jd_start, jd_end
INTEGER frame, record_count, degree, k, ret
REAL(8), dimension(390) :: coefs ! size = 10*13*3 = record_count * (degree+1) * 3 components
len_timespan = 32 ! days
frame = 1 ! ICRF
record_count = 10
degree = 12
jd_start = 2460000
jd_end = jd_start+record_count*len_timespan
weph = writeph_pck_create("ephemeris.bpc"//C_NULL_CHAR, "planet_2"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(peph)) then
do k=0, record_count-1
! ... fill the array coefs with the coefficients of the Chebychev polynomials ...
! coefs(...) =...
enddo
ret = writeph_pck102_seq_write(weph, 4000099, frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, coefs, record_count, degree+1, "seg_planet"//C_NULL_CHAR)
call writeph_close(peph)
endif
writeph_pck102_par_reserve
- function writeph_pck102_par_reserve(eph, target_count, targets, frame, start_jd0_tcb, start_frac_tcb, end_jd0_tcb, end_frac_tcb, intlens_jd_tcb, record_counts, deg, segids)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
target_count [INTEGER(C_INT), VALUE, intent(in)] :: number of targets the reservation is done for.
targets [INTEGER(C_INT), dimension(*), intent(in)] :: array of bodies or reference points whose coordinates will be written (see NAIF identification numbers).
frame [INTEGER(C_INT), VALUE, intent(in)] :: reference frame (see Frame numbers).
start_jd0_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date integer part (TCB).
start_frac_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date fraction part (TCB).
end_jd0_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date integer part (TCB).
end_frac_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date fraction part (TCB).
intlens_jd_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: array containing the interpolation interval length for each target (in days, TCB).
record_counts [INTEGER(C_INT), dimension(*), intent(in)] :: array of number of records for each target.
deg [INTEGER(C_INT), VALUE, intent(in)] :: degree of the Chebyshev polynomials.
segids [CHARACTER(len=1,kind=C_CHAR), dimension(*), intent(in)] :: array of segment identifiers (one per target, each must be unique within the file, max 40 characters).
- Return:
writeph_pck102_par_reserve [INTEGER(C_INT)] :: return a reservation identifier on success, 0 on failure.
This function is meant to enable the parallel writing (with multiple threads) of several type 102 segments (Chebyshev polynomials of the angle only ) in the time scale TCB 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 arrays 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_pck102_par_write() to write in the corresponding reserved space.
In addition, the function writeph_pck102_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_pck102_par_reserve() is always performed by a single thread and is followed by several calls to writeph_pck102_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_pck102_par_write().
The following example creates a new ephemeris file ephemeris.bsp with segment of type 102 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(39) :: coefs ! size = 13*3 = (degree+1) * 3 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) = 3000099
targets(2) = 4000099
len_timespan(1) = 32
len_timespan(2) = 16
record_counts(1) = 10
record_counts(2) = 20
segids(1) = "seg_body1"//C_NULL_CHAR
segids(2) = "seg_body2"//C_NULL_CHAR
degree = 12
jd_start = 2460000
jd_end = jd_start+32*10
weph = writeph_pck_create("ephemeris.bpc"//C_NULL_CHAR, "planet_2"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(weph)) then
reservation = writeph_pck102_seq_reserve(weph, target_count, targets,
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_pck102_par_write(weph, reservation, body, k, 1, coefs)
enddo
enddo
call writeph_close(weph)
endif
writeph_pck102_par_write
- function writeph_pck102_par_write(eph, reservation, target_index, record_begin_index, record_count, polynomials) BIND(C)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
reservation [INTEGER(C_INT), VALUE, intent(in)] :: reservation identifier.
target_index [INTEGER(C_INT), VALUE, intent(in)] :: index of the target body in the reservation.
record_begin_index [INTEGER(C_INT), VALUE, intent(in)] :: index of the first record to be written in the target's segment.
record_count [INTEGER(C_INT), VALUE, intent(in)] :: number of records to be written.
polynomials [REAL(C_DOUBLE), dimension(*), intent(in)] :: array of Chebyshev polynomial coefficients.
- Return:
writeph_pck102_par_write [INTEGER(C_INT)] :: 0 if an error occurs, otherwise non-zero value.
This function writes in parallel mode records of a type 102 segment (Chebyshev polynomials of the angle only ) in the time scale TCB to the PCK file associated to the ephemeris descriptor eph.
The reservation parameter must be the reservation id returned by the function writeph_pck102_par_reserve().
The target_index parameter is the index of the target in the targets array that was passed to the function writeph_pck102_par_reserve().
The record_begin_index parameter is the index of the first record to be written in the target's segment.
The record_count parameter is the number of records to be written starting from the record_begin_index.
The polynomials array must have the following structure :
E1's 1st coef 1st record. |
... |
E1's (deg + 1)th coef 1st record. |
E2's 1st coef 1st record. |
... |
E2's (deg + 1)th coef 1st record. |
E3's 1st coef 1st record. |
... |
E3's (deg + 1)th coef 1st record. |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
With the 1st record being the record at index record_begin_index, and the (record_count)th record being the record at index record_begin_index + record_count - 1.
Multiple threads can call this function at the same time, but with different values of target_index and/or record_begin_index. The behavior is undefined if multiple threads overlap the written data : e.g., two threads write to the same target target_index and a common record number.
writeph_pck103_seq_write
- function writeph_pck103_seq_write(eph, target, frame, start_jd0_tcb, start_frac_tcb, end_jd0_tcb, end_frac_tcb, intlen_jd_tcb, polynomials, record_count, deg, segid) BIND(C)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
target [INTEGER(C_INT), VALUE, intent(in)] :: The body or reference point whose coordinates will be written (see NAIF identification numbers).
frame [INTEGER(C_INT), VALUE, intent(in)] :: reference frame (see Frame numbers).
start_jd0_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date integer part (TCB).
start_frac_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date fraction part (TCB).
end_jd0_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date integer part (TCB).
end_frac_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date fraction part (TCB).
intlen_jd_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: length of the interpolation interval (in days, TCB).
polynomials [REAL(C_DOUBLE), dimension(*), intent(in)] :: array of Chebyshev polynomial coefficients.
record_count [INTEGER(C_INT), VALUE, intent(in)] :: number of records to be written.
deg [INTEGER(C_INT), VALUE, intent(in)] :: degree of the Chebyshev polynomials.
segid [CHARACTER(len=1,kind=C_CHAR), intent(in)] :: segment identifier (must be unique within the file, max 40 characters).
- Return:
writeph_pck103_seq_write [INTEGER(C_INT)] :: 0 if an error occurs, otherwise non-zero value.
This function writes in sequential mode a type 103 segment (Chebyshev polynomials of the angles and their derivatives ) in the time scale TCB to the PCK file associated to the ephemeris descriptor eph.
The polynomials array must be of size record_count*(deg+1)*6 and have the following structure :
E1's 1st coef 1st record |
... |
E1's (deg + 1)th coef 1st record |
E2's 1st coef 1st record |
... |
E2's (deg + 1)th coef 1st record |
E3's 1st coef 1st record |
... |
E3's (deg + 1)th coef 1st record |
dE1's 1st coef 1st record |
... |
dE1's (deg + 1)th coef 1st record |
dE2's 1st coef 1st record |
... |
dE2's (deg + 1)th coef 1st record |
dE3's 1st coef 1st record |
... |
dE3's (deg + 1)th coef 1st record |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
dE1's 1st coef (record_count)th record |
... |
dE1's (deg + 1)th coef (record_count)th record |
dE2's 1st coef (record_count)th record |
... |
dE2's (deg + 1)th coef (record_count)th record |
dE3's 1st coef (record_count)th record |
... |
dE3's (deg + 1)th coef (record_count)th record |
The following example creates a new ephemeris file ephemeris.bsp with segment of type 3 for the orientation of one body, in the timescale TCB.
USE, INTRINSIC :: ISO_C_BINDING
use calceph
TYPE(C_PTR) :: weph
INTEGER len_timespan
REAL(8) :: jd_start, jd_end
INTEGER frame, record_count, degree, k, ret
REAL(8), dimension(780) :: coefs ! size = 780 = record_count * (degree+1) * 6 components
len_timespan = 32 ! days
frame = 1 ! ICRF
record_count = 10
degree = 12
jd_start = 2460000
jd_end = jd_start+record_count*len_timespan
weph = writeph_pck_create("ephemeris.bpc"//C_NULL_CHAR, "planet_2"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(peph)) then
do k=0, record_count-1
! ... fill the array coefs with the coefficients of the Chebychev polynomials ...
! coefs(...) =...
enddo
ret = writeph_pck103_seq_write(weph, 4000099, frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, coefs, record_count, degree+1, "seg_planet"//C_NULL_CHAR)
call writeph_close(peph)
endif
writeph_pck103_par_reserve
- function writeph_pck103_par_reserve(eph, target_count, targets, frame, start_jd0_tcb, start_frac_tcb, end_jd0_tcb, end_frac_tcb, intlens_jd_tcb, record_counts, deg, segids)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
target_count [INTEGER(C_INT), VALUE, intent(in)] :: number of targets the reservation is done for.
targets [INTEGER(C_INT), dimension(*), intent(in)] :: array of bodies or reference points whose coordinates will be written (see NAIF identification numbers).
frame [INTEGER(C_INT), VALUE, intent(in)] :: reference frame (see Frame numbers).
start_jd0_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date integer part (TCB).
start_frac_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: starting Julian date fraction part (TCB).
end_jd0_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date integer part (TCB).
end_frac_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: stop Julian date fraction part (TCB).
intlens_jd_tcb [REAL(C_DOUBLE), VALUE, intent(in)] :: array containing the interpolation interval length for each target (in days, TCB).
record_counts [INTEGER(C_INT), dimension(*), intent(in)] :: array of number of records for each target.
deg [INTEGER(C_INT), VALUE, intent(in)] :: degree of the Chebyshev polynomials.
segids [CHARACTER(len=1,kind=C_CHAR), dimension(*), intent(in)] :: array of segment identifiers (one per target, each must be unique within the file, max 40 characters).
- Return:
writeph_pck103_par_reserve [INTEGER(C_INT)] :: return a reservation identifier on success, 0 on failure.
This function is meant to enable the parallel writing (with multiple threads) of several type 103 segments (Chebyshev polynomials of the angles and their derivatives ) in the time scale TCB 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_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 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_pck103_par_write() to write in the corresponding reserved space.
In addition, the function writeph_pck103_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_pck103_par_reserve is always performed by a single thread and is followed by several calls to writeph_pck103_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_pck103_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) = 3000099
targets(2) = 4000099
len_timespan(1) = 32
len_timespan(2) = 16
record_counts(1) = 10
record_counts(2) = 20
segids(1) = "seg_body1"//C_NULL_CHAR
segids(2) = "seg_body2"//C_NULL_CHAR
degree = 12
jd_start = 2460000
jd_end = jd_start+32*10
weph = writeph_pck_create("ephemeris.bpc"//C_NULL_CHAR, "planet_2"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(weph)) then
reservation = writeph_pck103_seq_reserve(weph, target_count, targets,
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_pck103_par_write(weph, reservation, body, k, 1, coefs)
enddo
enddo
call writeph_close(weph)
endif
writeph_pck103_par_write
- function writeph_pck103_par_write(eph, reservation, target_index, record_begin_index, record_count, polynomials)
- Parameters:
eph [TYPE(C_PTR), VALUE, intent(in)] :: ephemeris descriptor
reservation [INTEGER(C_INT), VALUE, intent(in)] :: reservation identifier.
target_index [INTEGER(C_INT), VALUE, intent(in)] :: index of the target body in the reservation.
record_begin_index [INTEGER(C_INT), VALUE, intent(in)] :: index of the first record to be written in the target's segment.
record_count [INTEGER(C_INT), VALUE, intent(in)] :: number of records to be written.
polynomials [REAL(C_DOUBLE), dimension(*), intent(in)] :: array of Chebyshev polynomial coefficients.
- Return:
writeph_pck103_seq_write [INTEGER(C_INT)] :: 0 if an error occurs, otherwise non-zero value.
This function writes in parallel mode records of a type 103 segment (Chebyshev polynomials of the angles and their derivatives ) in the time scale TCB to the PCK file associated to the ephemeris descriptor eph.
The reservation parameter must be the reservation id returned by the function writeph_pck3_par_reserve().
The target_index parameter is the index of the target in the targets array that was passed to the function writeph_pck3_par_reserve(), starting from 0.
The record_begin_index parameter is the index of the first record to be written in the target's segment, starting from 0.
The record_count parameter is the number of records to be written starting from the record_begin_index.
The polynomials array must be of size record_count*(deg+1)*6 and have the following structure :
E1's 1st coef 1st record |
... |
E1's (deg + 1)th coef 1st record |
E2's 1st coef 1st record |
... |
E2's (deg + 1)th coef 1st record |
E3's 1st coef 1st record |
... |
E3's (deg + 1)th coef 1st record |
dE1's 1st coef 1st record |
... |
dE1's (deg + 1)th coef 1st record |
dE2's 1st coef 1st record |
... |
dE2's (deg + 1)th coef 1st record |
dE3's 1st coef 1st record |
... |
dE3's (deg + 1)th coef 1st record |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
dE1's 1st coef (record_count)th record |
... |
dE1's (deg + 1)th coef (record_count)th record |
dE2's 1st coef (record_count)th record |
... |
dE2's (deg + 1)th coef (record_count)th record |
dE3's 1st coef (record_count)th record |
... |
dE3's (deg + 1)th coef (record_count)th record |
With the 1st record being the record at index record_begin_index, and the (record_count)th record being the record at index record_begin_index + record_count - 1.
Multiple threads can call this function at the same time, but with different values of target_index and/or record_begin_index. The behavior is undefined if multiple threads overlap the written data : e.g., two threads write to the same target target_index and a common record number.