Changeset 30620 for trunk/ppStack/src/ppStack.c
- Timestamp:
- Feb 13, 2011, 11:52:31 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/ppStack/src/ppStack.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStack.c
r29552 r30620 1 #ifdef HAVE_CONFIG_H2 #include <config.h>3 #endif4 5 #include <stdio.h>6 #include <pslib.h>7 #include <psmodules.h>8 #include <psphot.h>9 10 1 #include "ppStack.h" 11 #include "ppStackLoop.h"12 13 #define TIMER_NAME "PPSTACK" // Name of timer14 2 15 3 int main(int argc, char *argv[]) 16 4 { 17 5 psLibInit(NULL); 18 psTimerStart( TIMER_NAME);6 psTimerStart("PPSTACK"); 19 7 psTimerStart("PPSTACK_STEPS"); 20 8 … … 23 11 psphotErrorRegister(); 24 12 13 ppStackOptions *options = NULL; // Options for stacking 14 25 15 pmConfig *config = pmConfigRead(&argc, argv, PPSTACK_RECIPE); // Configuration 26 ppStackOptions *options = NULL; // Options for stacking27 16 if (!config) { 28 goto die;17 ppStackCleanup(config, options); 29 18 } 30 19 … … 33 22 if (!pmModelClassInit()) { 34 23 psError(PPSTACK_ERR_PROG, false, "Unable to initialise model classes."); 35 goto die;24 ppStackCleanup(config, options); 36 25 } 37 26 38 27 if (!psphotInit()) { 39 28 psError(PPSTACK_ERR_PROG, false, "Error initialising psphot."); 40 goto die;29 ppStackCleanup(config, options); 41 30 } 42 31 43 (void)psTraceSetLevel("ppStack", 5);44 45 32 if (!ppStackArgumentsSetup(argc, argv, config)) { 46 goto die;33 ppStackCleanup(config, options); 47 34 } 48 35 49 36 if (!ppStackCamera(config)) { 50 goto die;37 ppStackCleanup(config, options); 51 38 } 52 39 53 40 if (!ppStackArgumentsParse(config)) { 54 goto die;41 ppStackCleanup(config, options); 55 42 } 56 43 57 44 options = ppStackOptionsAlloc(); 58 45 if (!ppStackLoop(config, options)) { 59 goto die;46 ppStackCleanup(config, options); 60 47 } 61 48 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); 131 50 } 132 51
Note:
See TracChangeset
for help on using the changeset viewer.
