Changeset 27517 for branches/eam_branches/20100225/ppSub/src/ppSub.c
- Timestamp:
- Mar 29, 2010, 3:55:49 PM (16 years ago)
- Location:
- branches/eam_branches/20100225
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20100225
- Property svn:mergeinfo changed
-
branches/eam_branches/20100225/ppSub/src
- Property svn:ignore
-
old new 13 13 ppSubErrorCodes.c 14 14 ppSubVersionDefinitions.h 15 ppSubConvolve
-
- Property svn:ignore
-
branches/eam_branches/20100225/ppSub/src/ppSub.c
r27078 r27517 26 26 psLibInit(NULL); 27 27 psTimerStart("ppSub"); 28 29 pmErrorRegister(); 30 ppSubErrorRegister(); 31 psphotErrorRegister(); 28 32 29 33 ppSubData *data = NULL; // Processing data … … 63 67 64 68 die: 65 if (data && data->stats && data->statsFile) { 66 psString stats = psMetadataConfigFormat(data->stats); // Statistics to output 67 if (!stats || strlen(stats) == 0) { 68 psError(PPSUB_ERR_IO, false, "Unable to format statistics file"); 69 } else if (fprintf(data->statsFile, "%s", stats) != strlen(stats)) { 70 psError(PPSUB_ERR_IO, true, "Unable to write statistics file"); 69 { 70 psExit exitValue = ppSubExitCode(PS_EXIT_SUCCESS); // Exit code 71 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); 71 86 } 72 psFree(stats); 73 if (fclose(data->statsFile) == EOF) { 74 psError(PPSUB_ERR_IO, true, "Unable to close statistics file"); 87 88 if (config && !ppSubFilesIterateUp(config, PPSUB_FILES_ALL)) { 89 psError(psErrorCodeLast(), false, "Unable to close files."); 90 exitValue = ppSubExitCode(exitValue); 91 pmFPAfileFreeSetStrict(false); 75 92 } 76 data->statsFile = NULL; 77 pmConfigRunFilenameAddWrite(data->config, "STATS", data->statsName); 93 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); 78 115 } 79 80 if (data) {81 psString dump_file = psMetadataLookupStr(NULL, data->config->arguments, "-dumpconfig");82 if (dump_file) {83 if (!pmConfigDump(data->config, dump_file)) {84 psError(PPSUB_ERR_IO, false, "Unable to dump configuration.");85 }86 }87 psFree(data);88 }89 90 psExit exitValue = PS_EXIT_SUCCESS; // Exit value for program91 psErrorCode errorCode = psErrorCodeLast(); // Error code92 if (errorCode != PS_ERR_NONE) {93 psErrorStackPrint(stderr, "Unable to perform subtraction.");94 switch (errorCode) {95 case PPSUB_ERR_UNKNOWN:96 case PS_ERR_UNKNOWN:97 exitValue = PS_EXIT_UNKNOWN_ERROR;98 break;99 case PS_ERR_IO:100 case PS_ERR_DB_CLIENT:101 case PS_ERR_DB_SERVER:102 case PS_ERR_BAD_FITS:103 case PS_ERR_OS_CALL_FAILED:104 case PPSUB_ERR_IO:105 exitValue = PS_EXIT_SYS_ERROR;106 break;107 case PS_ERR_BAD_PARAMETER_VALUE:108 case PS_ERR_BAD_PARAMETER_TYPE:109 case PS_ERR_BAD_PARAMETER_NULL:110 case PS_ERR_BAD_PARAMETER_SIZE:111 case PPSUB_ERR_ARGUMENTS:112 case PPSUB_ERR_CONFIG:113 exitValue = PS_EXIT_CONFIG_ERROR;114 break;115 case PPSUB_ERR_DATA:116 case PPSUB_ERR_NO_OVERLAP:117 exitValue = PS_EXIT_DATA_ERROR;118 break;119 case PS_ERR_UNEXPECTED_NULL:120 case PS_ERR_PROGRAMMING:121 case PPSUB_ERR_NOT_IMPLEMENTED:122 case PPSUB_ERR_PROG:123 default:124 // It's a programming error if we're not dealing with the error correctly125 exitValue = PS_EXIT_PROG_ERROR;126 break;127 }128 }129 130 if (config && !ppSubFilesIterateUp(config, PPSUB_FILES_ALL)) {131 psErrorStackPrint(stderr, "Unable to close files.");132 }133 134 psTrace("ppSub", 1, "Finished at %f sec\n", psTimerMark("ppSub"));135 psTimerStop();136 137 pmVisualClose(); //close plot windows, if -visual is set138 pmModelClassCleanup();139 pmConfigDone();140 psLibFinalize();141 142 exit(exitValue);143 116 }
Note:
See TracChangeset
for help on using the changeset viewer.
