/* rocot_example.f -- translated by f2c (version 20100827).
   You must link the resulting object file with libf2c:
	on Microsoft Windows system, link with libf2c.lib;
	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
	or, if you install libf2c.a in a standard place, with -lf2c -lm
	-- in that order, at the end of the command line, as in
		cc *.o -lf2c -lm
	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,

		http://www.netlib.org/f2c/libf2c.zip
*/

#include "f2c.h"

/* Table of constant values */

static integer c__1 = 1;
static real c_b66 = -5.5f;
static real c_b68 = -12.5f;
static real c_b70 = -7.1f;

/* Main program */ int MAIN__(void)
{
    /* Format strings */
    static char fmt_100[] = "(a,3i6)";
    static char fmt_200[] = "(a,3f14.6)";
    static char fmt_300[] = "(a,3f14.4)";

    /* Builtin functions */
    integer s_wsfe(cilist *), e_wsfe(void), do_fio(integer *, char *, ftnlen);
    /* Subroutine */ int s_stop(char *, ftnlen);

    /* Local variables */
    extern /* Subroutine */ int g_gei_geo_sun_dir__(real *, real *, real *, 
	    real *, real *, real *);
    static integer ih, im, is;
    extern /* Subroutine */ int t_gei_to_sm__(real *, real *, real *, real *, 
	    real *, real *);
    static integer iday, idoy;
    static real xgse, ygse, zgse;
    extern /* Subroutine */ int t_gei_to_mag__(real *, real *, real *, real *,
	     real *, real *);
    static real xgsm, ygsm, zgsm;
    extern /* Subroutine */ int g_gei_geo_dipole_dir__(real *, real *, real *,
	     real *, real *, real *), t_geo_to_gse__(real *, real *, real *, 
	    real *, real *, real *), t_gei_to_gsm__(real *, real *, real *, 
	    real *, real *, real *), t_geo_to_gsm__(real *, real *, real *, 
	    real *, real *, real *);
    static real dxgei, dygei, dzgei, dxmag, dymag, dzmag, dxgeo, dygeo, dzgeo;
    static integer iyear;
    static real dxsma, dysma, dzsma, sxgei, sygei, szgei, dxgsm, dygsm, dzgsm,
	     sxgeo, sygeo, szgeo;
    extern /* Subroutine */ int cp_time_param__(integer *, integer *, integer 
	    *, integer *, integer *, integer *);
    static real sxgsm, sygsm, szgsm;
    extern /* Subroutine */ int r_date__(integer *, integer *, integer *), 
	    r_time__(integer *, integer *, integer *);
    static integer imonth;
    extern /* Subroutine */ int cv_date_to_doty__(integer *, integer *, 
	    integer *, integer *);

    /* Fortran I/O blocks */
    static cilist io___1 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___2 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___3 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___4 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___5 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___13 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___14 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___15 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___16 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___26 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___27 = { 0, 6, 0, fmt_200, 0 };
    static cilist io___28 = { 0, 6, 0, fmt_200, 0 };
    static cilist io___29 = { 0, 6, 0, fmt_200, 0 };
    static cilist io___45 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___46 = { 0, 6, 0, fmt_200, 0 };
    static cilist io___47 = { 0, 6, 0, fmt_200, 0 };
    static cilist io___48 = { 0, 6, 0, fmt_200, 0 };
    static cilist io___49 = { 0, 6, 0, fmt_200, 0 };
    static cilist io___50 = { 0, 6, 0, fmt_200, 0 };
    static cilist io___51 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___52 = { 0, 6, 0, fmt_300, 0 };
    static cilist io___59 = { 0, 6, 0, fmt_300, 0 };
    static cilist io___60 = { 0, 6, 0, fmt_300, 0 };
    static cilist io___61 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___62 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___63 = { 0, 6, 0, fmt_100, 0 };



/*     ***************************************************************0** */
/* *   Rocot_Example: show example of Rocotlib use. */
/*     P. Robert, July 2000 */
/*     ***************************************************************0** */


    s_wsfe(&io___1);
    e_wsfe();
    s_wsfe(&io___2);
    do_fio(&c__1, "*****************************************************", (
	    ftnlen)53);
    e_wsfe();
    s_wsfe(&io___3);
    e_wsfe();
    s_wsfe(&io___4);
    do_fio(&c__1, "ROCOTEXP:", (ftnlen)9);
    e_wsfe();
    s_wsfe(&io___5);
    e_wsfe();

    r_date__(&iyear, &imonth, &iday);
    r_time__(&ih, &im, &is);
    cv_date_to_doty__(&iyear, &imonth, &iday, &idoy);

    s_wsfe(&io___13);
    e_wsfe();
    s_wsfe(&io___14);
    do_fio(&c__1, "date: MM/JJ/YY =", (ftnlen)16);
    do_fio(&c__1, (char *)&imonth, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&iday, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&iyear, (ftnlen)sizeof(integer));
    e_wsfe();
    s_wsfe(&io___15);
    do_fio(&c__1, "time: HH/MM/SS =", (ftnlen)16);
    do_fio(&c__1, (char *)&ih, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&im, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&is, (ftnlen)sizeof(integer));
    e_wsfe();
    s_wsfe(&io___16);
    do_fio(&c__1, "day of the year=", (ftnlen)16);
    do_fio(&c__1, (char *)&idoy, (ftnlen)sizeof(integer));
    e_wsfe();

    cp_time_param__(&iyear, &imonth, &iday, &ih, &im, &is);
    g_gei_geo_sun_dir__(&sxgei, &sygei, &szgei, &sxgeo, &sygeo, &szgeo);
    t_gei_to_gsm__(&sxgei, &sygei, &szgei, &sxgsm, &sygsm, &szgsm);

    s_wsfe(&io___26);
    e_wsfe();
    s_wsfe(&io___27);
    do_fio(&c__1, "Sun in GEI:", (ftnlen)11);
    do_fio(&c__1, (char *)&sxgei, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&sygei, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&szgei, (ftnlen)sizeof(real));
    e_wsfe();
    s_wsfe(&io___28);
    do_fio(&c__1, "Sun in GEO:", (ftnlen)11);
    do_fio(&c__1, (char *)&sxgeo, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&sygeo, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&szgeo, (ftnlen)sizeof(real));
    e_wsfe();
    s_wsfe(&io___29);
    do_fio(&c__1, "Sun in GSM:", (ftnlen)11);
    do_fio(&c__1, (char *)&sxgsm, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&sygsm, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&szgsm, (ftnlen)sizeof(real));
    e_wsfe();

    g_gei_geo_dipole_dir__(&dxgei, &dygei, &dzgei, &dxgeo, &dygeo, &dzgeo);
    t_gei_to_gsm__(&dxgei, &dygei, &dzgei, &dxgsm, &dygsm, &dzgsm);
    t_gei_to_mag__(&dxgei, &dygei, &dzgei, &dxmag, &dymag, &dzmag);
    t_gei_to_sm__(&dxgei, &dygei, &dzgei, &dxsma, &dysma, &dzsma);

    s_wsfe(&io___45);
    e_wsfe();
    s_wsfe(&io___46);
    do_fio(&c__1, "Dip in GEI:", (ftnlen)11);
    do_fio(&c__1, (char *)&dxgei, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&dygei, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&dzgei, (ftnlen)sizeof(real));
    e_wsfe();
    s_wsfe(&io___47);
    do_fio(&c__1, "Dip in GEO:", (ftnlen)11);
    do_fio(&c__1, (char *)&dxgeo, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&dygeo, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&dzgeo, (ftnlen)sizeof(real));
    e_wsfe();
    s_wsfe(&io___48);
    do_fio(&c__1, "Dip in GSM:", (ftnlen)11);
    do_fio(&c__1, (char *)&dxgsm, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&dygsm, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&dzgsm, (ftnlen)sizeof(real));
    e_wsfe();
    s_wsfe(&io___49);
    do_fio(&c__1, "Dip in MAG:", (ftnlen)11);
    do_fio(&c__1, (char *)&dxmag, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&dymag, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&dzmag, (ftnlen)sizeof(real));
    e_wsfe();
    s_wsfe(&io___50);
    do_fio(&c__1, "Dip in SM :", (ftnlen)11);
    do_fio(&c__1, (char *)&dxsma, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&dysma, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&dzsma, (ftnlen)sizeof(real));
    e_wsfe();

    s_wsfe(&io___51);
    e_wsfe();
    s_wsfe(&io___52);
    do_fio(&c__1, "xyz in GEO=", (ftnlen)11);
    do_fio(&c__1, (char *)&c_b66, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&c_b68, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&c_b70, (ftnlen)sizeof(real));
    e_wsfe();

    t_geo_to_gsm__(&c_b66, &c_b68, &c_b70, &xgsm, &ygsm, &zgsm);
    t_geo_to_gse__(&c_b66, &c_b68, &c_b70, &xgse, &ygse, &zgse);

    s_wsfe(&io___59);
    do_fio(&c__1, "xyz in GSM:", (ftnlen)11);
    do_fio(&c__1, (char *)&xgsm, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&ygsm, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&zgsm, (ftnlen)sizeof(real));
    e_wsfe();
    s_wsfe(&io___60);
    do_fio(&c__1, "xyz in GSE:", (ftnlen)11);
    do_fio(&c__1, (char *)&xgse, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&ygse, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&zgse, (ftnlen)sizeof(real));
    e_wsfe();

    s_wsfe(&io___61);
    e_wsfe();
    s_wsfe(&io___62);
    do_fio(&c__1, "*****************************************************", (
	    ftnlen)53);
    e_wsfe();
    s_wsfe(&io___63);
    e_wsfe();

    s_stop("rocot_example.exe: normal termination", (ftnlen)37);
    return 0;
} /* MAIN__ */

/* Main program alias */ int rocot_example__ () { MAIN__ (); return 0; }
