Ignore:
Timestamp:
Nov 22, 2006, 2:53:31 PM (19 years ago)
Author:
cmv
Message:

mise en conformite xephem 3.7.2 cmv 22/11/2006

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/XephemAstroLib/marsmoon.c

    r2818 r3111  
    44#include <stdlib.h>
    55#include <string.h>
     6#include <errno.h>
    67#include <math.h>
    78
     
    2425};
    2526static double sizemjd;
    26 
    27 /* file containing BDL coefficients */
    28 static char mbdlfn[] = "mars.9910";
    2927
    3028/* These values are from the Explanatory Supplement.
     
    8785
    8886        /* get moon x,y,z from BDL if possible */
    89         if (dir && use_bdl (JD, dir, md) < 0) {
     87        if (!dir || use_bdl (JD, dir, md) < 0) {
    9088            int i;
    9189            for (i = 1; i < M_NMOONS; i++)
     
    122120        char buf[1024];
    123121        FILE *fp;
    124         int i;
    125 
    126         /* only valid 1999 through 2010 */
    127         if (JD < 2451179.50000 || JD >= 2455562.5)
     122        char *fn;
     123        int i;
     124
     125        /* check ranges and appropriate data file */
     126        if (JD < 2451179.50000)         /* Jan 1 1999 UTC */
     127            return (-1);
     128        if (JD < 2455562.5)             /* Jan 1 2011 UTC */
     129            fn = "mars.9910";
     130        else if (JD < 2459215.5)        /* Jan 1 2021 UTC */
     131            fn = "mars.1020";
     132        else
    128133            return (-1);
    129134
    130135        /* open */
    131         (void) sprintf (buf, "%s/%s", dir, mbdlfn);
     136        (void) sprintf (buf, "%s/%s", dir, fn);
    132137        fp = fopen (buf, "r");
    133         if (!fp)
    134             return (-1);
     138        if (!fp) {
     139            fprintf (stderr, "%s: %s\n", fn, strerror(errno));
     140            return (-1);
     141        }
    135142
    136143        /* use it */
    137144        if ((i = read_bdl (fp, JD, x, y, z, buf)) < 0) {
    138             fprintf (stderr, "%s: %s\n", mbdlfn, buf);
     145            fprintf (stderr, "%s: %s\n", fn, buf);
    139146            fclose (fp);
    140147            return (-1);
    141148        }
    142149        if (i != M_NMOONS-1) {
    143             fprintf (stderr, "%s: BDL says %d moons, code expects %d", mbdlfn,
     150            fprintf (stderr, "%s: BDL says %d moons, code expects %d", fn,
    144151                                                                i, M_NMOONS-1);
    145152            fclose (fp);
     
    256263
    257264/* For RCS Only -- Do Not Edit */
    258 static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: marsmoon.c,v $ $Date: 2005-08-21 10:02:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
     265static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: marsmoon.c,v $ $Date: 2006-11-22 13:53:29 $ $Revision: 1.4 $ $Name: not supported by cvs2svn $"};
Note: See TracChangeset for help on using the changeset viewer.