ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/proj/globalhs/apps/undistortmdi.c
(Generate patch)

Comparing proj/globalhs/apps/undistortmdi.c (file contents):
Revision 1.2 by tplarson, Thu Dec 1 21:20:38 2011 UTC vs.
Revision 1.3 by tplarson, Fri May 3 20:43:25 2013 UTC

# Line 12 | Line 12
12   #include <sys/resource.h>
13   #include <mkl_lapack.h>  //needed for dsecnd()
14   #include "jsoc_main.h"
15 //#include "astro.h"
15   #include "fstats.h"
16   #include "drms_dsdsapi.h"
17 + #include "projection.h"
18  
19   #define ARRLENGTH(ARR)  (sizeof(ARR)/sizeof(ARR[0]))
20   #define QUAL_NODATA     (0x80000000)
# Line 52 | Line 52 | typedef enum
52   } V2HStatus_t;
53  
54   char *module_name = "undistortmdi";
55 + char *cvsinfo_undistortmdi = "cvsinfo: $Header$";
56  
57   ModuleArgs_t module_args[] =
58   {
# Line 85 | Line 86 | ModuleArgs_t module_args[] =
86     {ARG_END}
87   };
88  
88 #include "saveparm.c"
89   #include "imageinterp.c"
90 <
91 < double getwalltime(void)
92 < {
93 <  struct timeval tv;
94 <  gettimeofday(&tv, NULL);
95 <  return tv.tv_sec * 1000.0 + tv.tv_usec/1000.0;
96 < }
97 <
98 < double getcputime(double *utime, double *stime)
99 < {
100 <
101 <  struct rusage ru;
102 <  getrusage(RUSAGE_SELF, &ru);
103 <  *utime = ru.ru_utime.tv_sec * 1000.0 + ru.ru_utime.tv_usec/1000.0;
104 <  *stime = ru.ru_stime.tv_sec * 1000.0 + ru.ru_stime.tv_usec/1000.0;
105 <  return *utime + *stime;
106 < }
90 > #include "saveparm.c"
91 > #include "timing.c"
92 > #include "set_history.c"
93  
94   static inline void ParameterDef(int status,
95                                  char *pname,
# Line 198 | Line 184 | int DoIt(void)
184     TIME trec, tnow, UNIX_epoch = -220924792.000; /* 1970.01.01_00:00:00_UTC */
185     char trecstr[100];
186  
187 <   LIBASTRO_Dist_t distP;
187 >   LIBPROJECTION_Dist_t distP;
188     DRMS_Segment_t *segin = NULL;
189     DRMS_Segment_t *segout = NULL;
190     DRMS_Array_t *inarr = NULL;
# Line 274 | Line 260 | int DoIt(void)
260     char *histlinkname = (char *)cmdparams_save_str(&cmdparams, "histlink", &newstat);
261     char *srclinkname = (char *)cmdparams_save_str(&cmdparams, "srclink", &newstat);
262  
263 +   if (newstat)
264 +   {
265 +     fprintf(stderr, "ERROR: problem with input arguments, status = %d, diagnosis follows\n", newstat);
266 +     cpsave_decode_error(newstat);
267 +     return 1;
268 +   }  
269 +   else if (savestrlen != strlen(savestr))
270 +   {
271 +     fprintf(stderr, "ERROR: problem with savestr, savestrlen = %d, strlen(savestr) = %d\n", savestrlen, (int)strlen(savestr));
272 +     return 1;
273 +   }
274 +
275     // set up ancillary dataseries for processing metadata
276     DRMS_Record_t *tempoutrec = drms_create_record(drms_env,
277                                                 outSeries,
# Line 291 | Line 289 | int DoIt(void)
289  
290     if (histlink != NULL)
291     {
292 <      DRMS_Record_t *histrec = drms_create_record(drms_env,
293 <                                                  histlink->info->target_series,
294 <                                                  DRMS_PERMANENT,
295 <                                                  &status);
296 <      if (status != DRMS_SUCCESS)
297 <      {
300 <         fprintf(stderr,"ERROR: could not open a record in history dataseries %s, status = %d\n", histlink->info->target_series, status);
301 <         return 1;
302 <      }
303 <
304 <      histrecnum = histrec->recnum;
305 <      tnow = (double)time(NULL);
306 <      tnow += UNIX_epoch;
307 <      status = drms_setkey_time(histrec, "DATE", tnow);
308 <      if (status != DRMS_SUCCESS)
309 <      {
310 <         fprintf(stderr,"ERROR: problem writing keyword DATE in history dataseries, status = %d\n", status);
311 <         drms_close_record(histrec, DRMS_FREE_RECORD);
312 <         return 1;
313 <      }
314 <      status = drms_setkey_string(histrec, "MODNAME", cmdparams.argv[0]);
315 <      if (status != DRMS_SUCCESS)
316 <      {
317 <         fprintf(stderr,"ERROR: problem writing keyword MODNAME in history dataseries, status = %d\n", status);
318 <         drms_close_record(histrec, DRMS_FREE_RECORD);
319 <         return 1;
320 <      }
321 <      status = drms_setkey_string(histrec, "ARGSUSED", savestr);
322 <      if (status != DRMS_SUCCESS)
323 <      {
324 <         fprintf(stderr,"ERROR: problem writing keyword DATE in history dataseries, status = %d\n", status);
325 <         drms_close_record(histrec, DRMS_FREE_RECORD);
326 <         return 1;
327 <      }
328 <      drms_close_record(histrec, DRMS_INSERT_RECORD);
329 <
292 >     histrecnum=set_history(histlink);
293 >     if (histrecnum < 0)
294 >     {
295 >       drms_close_record(tempoutrec, DRMS_FREE_RECORD);
296 >       return 1;
297 >     }
298     }
299     else
300     {
301 <      fprintf(stderr,"WARNING: could not find history link in output dataseries\n");
301 >     fprintf(stderr,"WARNING: could not find history link in output dataseries\n");
302     }
303  
336   if (newstat)
337   {
338     fprintf(stderr, "ERROR: problem with input arguments, status = %d, diagnosis follows\n", newstat);
339     cpsave_decode_error(newstat);
340     return 1;
341   }  
342   else if (savestrlen != strlen(savestr))
343   {
344     fprintf(stderr, "ERROR: problem with savestr, savestrlen = %d, strlen(savestr) = %d\n", savestrlen, (int)strlen(savestr));
345     return 1;
346   }
347
348
304    int itest;
305   // these must be present in the output dataseries and variable, not links or constants
306   /*
# Line 407 | Line 362 | int DoIt(void)
362     {
363        if (verbflag > 1)
364        {
365 <   wt1=getwalltime();
366 <   getcputime(&ut1, &st1);
365 >         wt1=getwalltime();
366 >         getcputime(&ut1, &st1);
367           gettimeofday(&tv1, NULL);
368           ct1=dsecnd(); //((double)clock())/CLOCKS_PER_SEC;
369 <   tt1=1000*((double)clock())/CLOCKS_PER_SEC;
369 >         tt1=1000*((double)clock())/CLOCKS_PER_SEC;
370           printf("processing record %d\n", iRec);
371        }
372        inrec = inRecSet->records[iRec];
# Line 649 | Line 604 | int DoIt(void)
604           continue; // go to next image
605        }
606  
607 <
653 <      // it would be nice to calculate image statistics at this point and write keywords
654 <      //  DATAMIN, DATAMAX, DATARMS, DATAMEAN, DATAMEDN, DATASKEW, DATAKURT
607 >      drms_setkey_int(outrec, "TOTVALS", maprows*mapcols)
608        set_statistics(segout, outarr, 1);
609  
610        // Write to the output record
# Line 706 | Line 659 | int DoIt(void)
659  
660        if (verbflag > 1)
661        {
662 <   wt=getwalltime();
663 <   getcputime(&ut, &st);
664 <   gettimeofday(&tv, NULL);
665 <   ct=dsecnd(); //((double)clock())/CLOCKS_PER_SEC;
666 <   tt=1000*((double)clock())/CLOCKS_PER_SEC;
667 <        fprintf(stdout,
662 >         wt=getwalltime();
663 >         getcputime(&ut, &st);
664 >         gettimeofday(&tv, NULL);
665 >         ct=dsecnd(); //((double)clock())/CLOCKS_PER_SEC;
666 >         tt=1000*((double)clock())/CLOCKS_PER_SEC;
667 >         fprintf(stdout,
668                  "record %d done, %f ms wall time, %f ms cpu time\n",
669                  iRec,
670                  (float)((tv.tv_sec * 1000000.0 + tv.tv_usec -

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines