IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 3, 2010, 1:54:33 PM (16 years ago)
Author:
Paul Price
Message:

Reorganise so that statistics file gets written out even when we don't make it to the bottom of ppStackLoop().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStack.c

    r27135 r27160  
    2424
    2525    pmConfig *config = pmConfigRead(&argc, argv, PPSTACK_RECIPE); // Configuration
     26    ppStackOptions *options = NULL;                               // Options for stacking
    2627    if (!config) {
    2728        goto die;
     
    5455    }
    5556
    56     if (!ppStackLoop(config)) {
     57    options = ppStackOptionsAlloc();
     58    if (!ppStackLoop(config, options)) {
    5759        goto die;
    5860    }
     
    7678            }
    7779        }
     80
     81        // Write out summary statistics
     82        if (options && options->stats) {
     83
     84            psMetadataAddS32(options->stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE,
     85                             "Bad data quality flag", options->quality);
     86            psMetadataAddF32(options->stats, PS_LIST_TAIL, "TIME_STACK", 0,
     87                             "Total time", psTimerClear("PPSTACK_TOTAL"));
     88
     89            const char *statsMDC = psMetadataConfigFormat(options->stats);
     90            if (!statsMDC || strlen(statsMDC) == 0) {
     91                psError(PS_ERR_IO, false, "Unable to get statistics MDC file.");
     92                return false;
     93            }
     94            if (fprintf(options->statsFile, "%s", statsMDC) != strlen(statsMDC)) {
     95                psError(PS_ERR_IO, false, "Unable to write statistics MDC file.");
     96                return false;
     97            }
     98            psFree(statsMDC);
     99            if (fclose(options->statsFile) == EOF) {
     100                psError(PS_ERR_IO, false, "Unable to close statistics MDC file.");
     101                return false;
     102            }
     103            options->statsFile = NULL;
     104            pmConfigRunFilenameAddWrite(config, "STATS",
     105                                        psMetadataLookupStr(NULL, config->arguments, "STATS"));
     106        }
     107        psFree(options);
    78108
    79109        // Dump configuration
Note: See TracChangeset for help on using the changeset viewer.