IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2011, 1:05:28 PM (15 years ago)
Author:
watersc1
Message:

Merge of trunk back into branch.

Location:
branches/czw_branch/20101203
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20101203

  • branches/czw_branch/20101203/ppStack/src/ppStack.c

    r29552 r30631  
    1 #ifdef HAVE_CONFIG_H
    2 #include <config.h>
    3 #endif
    4 
    5 #include <stdio.h>
    6 #include <pslib.h>
    7 #include <psmodules.h>
    8 #include <psphot.h>
    9 
    101#include "ppStack.h"
    11 #include "ppStackLoop.h"
    12 
    13 #define TIMER_NAME "PPSTACK"            // Name of timer
    142
    153int main(int argc, char *argv[])
    164{
    175    psLibInit(NULL);
    18     psTimerStart(TIMER_NAME);
     6    psTimerStart("PPSTACK");
    197    psTimerStart("PPSTACK_STEPS");
    208
     
    2311    psphotErrorRegister();
    2412
     13    ppStackOptions *options = NULL;                               // Options for stacking
     14
    2515    pmConfig *config = pmConfigRead(&argc, argv, PPSTACK_RECIPE); // Configuration
    26     ppStackOptions *options = NULL;                               // Options for stacking
    2716    if (!config) {
    28         goto die;
     17        ppStackCleanup(config, options);
    2918    }
    3019
     
    3322    if (!pmModelClassInit()) {
    3423        psError(PPSTACK_ERR_PROG, false, "Unable to initialise model classes.");
    35         goto die;
     24        ppStackCleanup(config, options);
    3625    }
    3726
    3827    if (!psphotInit()) {
    3928        psError(PPSTACK_ERR_PROG, false, "Error initialising psphot.");
    40         goto die;
     29        ppStackCleanup(config, options);
    4130    }
    4231
    43     (void)psTraceSetLevel("ppStack", 5);
    44 
    4532    if (!ppStackArgumentsSetup(argc, argv, config)) {
    46         goto die;
     33        ppStackCleanup(config, options);
    4734    }
    4835
    4936    if (!ppStackCamera(config)) {
    50         goto die;
     37        ppStackCleanup(config, options);
    5138    }
    5239
    5340    if (!ppStackArgumentsParse(config)) {
    54         goto die;
     41        ppStackCleanup(config, options);
    5542    }
    5643
    5744    options = ppStackOptionsAlloc();
    5845    if (!ppStackLoop(config, options)) {
    59         goto die;
     46        ppStackCleanup(config, options);
    6047    }
    6148
    62 
    63  die:
    64     // Common code for the death.
    65     {
    66         psExit exitValue = ppStackExitCode(PS_EXIT_SUCCESS); // Exit code
    67 
    68         // Ensure everything closes
    69         if (config) {
    70             ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true);
    71             ppStackFileActivation(config, PPSTACK_FILES_CONVOLVE, true);
    72             ppStackFileActivation(config, PPSTACK_FILES_STACK, true);
    73             ppStackFileActivation(config, PPSTACK_FILES_UNCONV, true);
    74             ppStackFileActivation(config, PPSTACK_FILES_PHOT, true);
    75             if (!ppStackFilesIterateUp(config)) {
    76                 psError(psErrorCodeLast(), false, "Unable to close files.");
    77                 exitValue = ppStackExitCode(exitValue);
    78                 pmFPAfileFreeSetStrict(false);
    79             }
    80         }
    81 
    82         // Write out summary statistics
    83         if (options && options->stats) {
    84 
    85             psMetadataAddS32(options->stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE,
    86                              "Bad data quality flag", options->quality);
    87             psMetadataAddF32(options->stats, PS_LIST_TAIL, "TIME_STACK", 0,
    88                              "Total time", psTimerClear("PPSTACK_TOTAL"));
    89 
    90             const char *statsMDC = psMetadataConfigFormat(options->stats);
    91             if (!statsMDC || strlen(statsMDC) == 0) {
    92                 psError(PS_ERR_IO, false, "Unable to get statistics MDC file.");
    93                 return false;
    94             }
    95             if (fprintf(options->statsFile, "%s", statsMDC) != strlen(statsMDC)) {
    96                 psError(PS_ERR_IO, false, "Unable to write statistics MDC file.");
    97                 return false;
    98             }
    99             psFree(statsMDC);
    100             if (fclose(options->statsFile) == EOF) {
    101                 psError(PS_ERR_IO, false, "Unable to close statistics MDC file.");
    102                 return false;
    103             }
    104             options->statsFile = NULL;
    105             pmConfigRunFilenameAddWrite(config, "STATS",
    106                                         psMetadataLookupStr(NULL, config->arguments, "STATS"));
    107         }
    108         psFree(options);
    109 
    110         // Dump configuration
    111         bool mdok;                                                                    // Status of MD lookup
    112         psString dump = psMetadataLookupStr(&mdok, config->arguments, "DUMP_CONFIG"); // File for config
    113         if (dump && !pmConfigDump(config, dump)) {
    114             psError(psErrorCodeLast(), false, "Unable to dump configuration.");
    115             exitValue = ppStackExitCode(exitValue);
    116         }
    117 
    118         psTrace("ppStack", 1, "Finished at %f sec\n", psTimerMark(TIMER_NAME));
    119         psTimerStop();
    120 
    121         psFree(config);
    122         pmModelClassCleanup();
    123         pmConfigDone();
    124         psLibFinalize();
    125         pmVisualClose();
    126         pmVisualCleanup ();
    127 
    128         exitValue = ppStackExitCode(exitValue);
    129         exit(exitValue);
    130     }
     49    ppStackCleanup(config, options);
    13150}
    13251
Note: See TracChangeset for help on using the changeset viewer.