This function opens an existing SPK 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 SPK file, the function fails and returns NULL. This file must be compliant to the format specified by the 'SPICE' SPK ephemeris file.

The function writeph_close() must be called to flush data to the disk and to free memory allocated by this function.

The following example appends data the ephemeris file ephemeris.bsp

USE, INTRINSIC :: ISO_C_BINDING
use calceph
TYPE(C_PTR) :: weph

weph = writeph_spk_open("ephemeris.bsp"//C_NULL_CHAR)
if (C_ASSOCIATED(weph)) then

     ! ... computation ...

     call writeph_close(weph)
endif