Blame view

php/src/ceftimeinfo.c 1.47 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 /************************************************************/
 /*        
/***********************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <CEF.h>
#include <string.h>
#include <time.h>
#include <math.h>
 
#define MAX_FILE_NAME_LEN  250        // Max. file name length
#define DAYS_1958_1970  4383
#define MILLI_PER_DAY  86400000


/**************************
   Function prototypes
**************************/
 
 
/*--------------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
    
    t_err  err;
    int i, RecCount, VarCount;
    t_variable *cef_time, *var;
    double ddTime0, ddTimeN, step, SHIFT;
    
    
    SHIFT = (double)DAYS_1958_1970 * (double)MILLI_PER_DAY;
/*********************** Open CEF file *****************************/
   
       err = Read_CEF_file(argv[1]);
       RecCount = Records_count();
       VarCount = Variables_count();
     
       for (i = 0; i < VarCount; i++) {
           var  = Get_variable_number(i);
           if (var->type == CEF_ISO_TIME ) break; 
       } 
       cef_time = Get_variable(var->name);
       
        ddTime0 = ((T1D(cef_time, 0, 0) - SHIFT) / 1000.0); 
        ddTimeN = ((T1D(cef_time, RecCount-1, 0) - SHIFT) / 1000.0); 
        step = ((T1D(cef_time, 1, 0) - SHIFT) / 1000.0) - ddTime0; 
        printf("%lf %lf %f", ddTime0, ddTimeN, step);

       
       err = Close_CEF_file();
    
}