Commit 60aa47075183502be40373a0eb5da50c6a326e1c

Authored by Benjamin Renard
1 parent a601c793
Exists in master and in 3 other branches WIP, epntap, ubuntu

Return granules names & modification times

Showing 1 changed file with 23 additions and 5 deletions   Show diff stats
src/DATA/TOOLS/GetGranules.c
... ... @@ -3,7 +3,8 @@
3 3 * @brief Stand-alone executable <br> Returns granules for given VI in DDBase <br>
4 4 *
5 5 * @details GetGranules(string *) <br>
6   -* @arg \c argv[1] Full name of *_times.nc
  6 +* @arg \c argv[1] Path to VI
  7 +* @arg \c argv[2] Prefix
7 8 *
8 9 */
9 10  
... ... @@ -13,6 +14,7 @@
13 14 #include <string.h>
14 15 #include <time.h>
15 16 #include <math.h>
  17 +#include <sys/stat.h>
16 18 #include <netcdf.h>
17 19 #include <DD.h>
18 20  
... ... @@ -29,14 +31,21 @@ int main(int argc, char *argv[])
29 31 {
30 32 int status;
31 33  
32   - if (argc < 2){
33   - fprintf(stderr,"Usage: GetGranules *_times.nc\n");
  34 + if (argc < 3){
  35 + fprintf(stderr,"Usage: GetGranules path_to_vi prefix\n");
34 36 exit(1);
35 37 }
36 38  
  39 + char timesPath[512];
  40 + memset(timesPath, 0, 512*sizeof(char));
  41 + strcat(timesPath, argv[1]);
  42 + strcat(timesPath, "/");
  43 + strcat(timesPath, argv[2]);
  44 + strcat(timesPath, "_times.nc");
  45 +
37 46 // Open VI_times.nc
38 47 int DataID;
39   - if ((status = nc_open(argv[1], NC_NOWRITE, &DataID)) != NC_NOERR)
  48 + if ((status = nc_open(timesPath, NC_NOWRITE, &DataID)) != NC_NOERR)
40 49 nc_handle_error(status);
41 50  
42 51 int StartID;
... ... @@ -81,6 +90,8 @@ int main(int argc, char *argv[])
81 90 double StopTimestamp;
82 91 size_t count[2] = {1L,TIMELENGTH};
83 92 size_t start[2] = {0L,0L};
  93 + char filePath[512];
  94 + struct stat attrib;
84 95  
85 96 for (i = 0; i < nb_records; ++i) {
86 97 count[1] = TIMELENGTH;
... ... @@ -94,7 +105,14 @@ int main(int argc, char *argv[])
94 105 count[1] = 32;
95 106 if ((status = nc_get_vara_text(DataID, FileID, start, count, FileName)) != NC_NOERR)
96 107 nc_handle_error(status);
97   - printf("%f %f\n", StartTimestamp, StopTimestamp);
  108 + memset(filePath, 0, 512*sizeof(char));
  109 + strcat(filePath, argv[1]);
  110 + strcat(filePath, "/");
  111 + strcat(filePath, FileName);
  112 + strcat(filePath, ".gz");
  113 + stat(filePath, &attrib);
  114 +
  115 + printf("%f %f %s %d\n", StartTimestamp, StopTimestamp, FileName, attrib.st_mtime);
98 116 }
99 117  
100 118 if ((status = nc_close(DataID)) != NC_NOERR) nc_handle_error(status);
... ...