Changeset 27840 for branches/simtest_nebulous_branches/ppSub/src/ppSub.c
- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/ppSub/src
- Property svn:ignore
-
old new 13 13 ppSubErrorCodes.c 14 14 ppSubVersionDefinitions.h 15 ppSubConvolve
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/ppSub/src/ppSub.c
r23753 r27840 24 24 int main(int argc, char *argv[]) 25 25 { 26 ps Exit exitValue = PS_EXIT_SUCCESS; // Exit value26 psLibInit(NULL); 27 27 psTimerStart("ppSub"); 28 psLibInit(NULL); 28 29 pmErrorRegister(); 30 ppSubErrorRegister(); 31 psphotErrorRegister(); 29 32 30 33 ppSubData *data = NULL; // Processing data 31 34 pmConfig *config = pmConfigRead(&argc, argv, PPSUB_RECIPE); // Configuration 32 35 if (!config) { 33 psErrorStackPrint(stderr, "Error reading configuration.");34 exitValue = PS_EXIT_CONFIG_ERROR;35 36 goto die; 36 37 } … … 39 40 40 41 if (!pmModelClassInit()) { 41 psErrorStackPrint(stderr, "Error initialising model classes.\n"); 42 exitValue = PS_EXIT_PROG_ERROR; 42 psError(PPSUB_ERR_PROG, false, "Unable to initialise model classes."); 43 43 psFree(config); 44 44 goto die; … … 46 46 47 47 if (!psphotInit()) { 48 psErrorStackPrint(stderr, "Error initialising psphot.\n"); 49 exitValue = PS_EXIT_PROG_ERROR; 48 psError(PPSUB_ERR_PROG, false, "Error initialising psphot."); 50 49 psFree(config); 51 50 goto die; … … 55 54 56 55 if (!ppSubArguments(argc, argv, data)) { 57 psErrorStackPrint(stderr, "Error reading arguments.\n"); 58 exitValue = PS_EXIT_CONFIG_ERROR; 56 psError(psErrorCodeLast(), false, "Error reading arguments."); 59 57 goto die; 60 58 } 61 59 62 60 if (!ppSubCamera(data)) { 63 psErrorStackPrint(stderr, "Error setting up camera.\n");64 exitValue = PS_EXIT_CONFIG_ERROR;65 61 goto die; 66 62 } 67 63 68 64 if (!ppSubLoop(data)) { 69 psErrorStackPrint(stderr, "Error performing subtraction.\n");70 exitValue = PS_EXIT_SYS_ERROR;71 65 goto die; 72 66 } 73 67 74 68 die: 75 psTrace("ppSub", 1, "Finished at %f sec\n", psTimerMark("ppSub"));76 psTimerStop();69 { 70 psExit exitValue = ppSubExitCode(PS_EXIT_SUCCESS); // Exit code 77 71 78 psFree(data); 72 if (data && data->stats && data->statsFile) { 73 psString stats = psMetadataConfigFormat(data->stats); // Statistics to output 74 if (!stats || strlen(stats) == 0) { 75 psError(PPSUB_ERR_IO, false, "Unable to format statistics file"); 76 } else if (fprintf(data->statsFile, "%s", stats) != strlen(stats)) { 77 psError(PPSUB_ERR_IO, true, "Unable to write statistics file"); 78 } 79 psFree(stats); 80 if (fclose(data->statsFile) == EOF) { 81 psError(PPSUB_ERR_IO, true, "Unable to close statistics file"); 82 } 83 data->statsFile = NULL; 84 pmConfigRunFilenameAddWrite(data->config, "STATS", data->statsName); 85 exitValue = ppSubExitCode(exitValue); 86 } 79 87 80 pmVisualClose(); //close plot windows, if -visual is set 81 pmModelClassCleanup(); 82 pmConfigDone(); 83 psLibFinalize(); 88 if (config && !ppSubFilesIterateUp(config, PPSUB_FILES_ALL)) { 89 psError(psErrorCodeLast(), false, "Unable to close files."); 90 exitValue = ppSubExitCode(exitValue); 91 pmFPAfileFreeSetStrict(false); 92 } 84 93 85 exit(exitValue); 94 if (data) { 95 psString dump_file = psMetadataLookupStr(NULL, data->config->arguments, "-dumpconfig"); 96 if (dump_file) { 97 if (!pmConfigDump(data->config, dump_file)) { 98 psError(PPSUB_ERR_IO, false, "Unable to dump configuration."); 99 exitValue = ppSubExitCode(exitValue); 100 } 101 } 102 psFree(data); 103 } 104 105 psTrace("ppSub", 1, "Finished at %f sec\n", psTimerMark("ppSub")); 106 psTimerStop(); 107 108 pmVisualClose(); //close plot windows, if -visual is set 109 pmModelClassCleanup(); 110 pmConfigDone(); 111 psLibFinalize(); 112 113 exitValue = ppSubExitCode(exitValue); 114 exit(exitValue); 115 } 86 116 }
Note:
See TracChangeset
for help on using the changeset viewer.
