IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 10, 2020, 9:40:15 AM (6 years ago)
Author:
eugene
Message:

gDiff now runs and does not crash on forced photometry

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/gDiff.20200202/src/gDiff.c

    r41260 r41413  
    1818    psphotErrorRegister();
    1919
     20    psExit exitValue = PS_EXIT_SUCCESS; // default value
     21
    2022    gDiffData *data = NULL; // Processing data
    2123    pmConfig *config = pmConfigRead(&argc, argv, GDIFF_RECIPE); // Configuration
     
    2628    psphotInit(); // cannot return false
    2729
     30    // the 'data' container carries pointers to all data structures used by gDiff
    2831    data = gDiffDataAlloc(config);
    2932
     33    // parse the command-line options
    3034    if (!gDiffArguments(argc, argv, data)) {
    3135        psError(psErrorCodeLast(), false, "Error reading arguments.");
     
    3337    }
    3438
    35     // determine the camera and setup the I/O file handles
     39    // determine the camera and setup the (many) I/O file handles
    3640    if (!gDiffCamera(data)) goto die;
    3741
     
    4044
    4145 die:
    42     {
    43         psExit exitValue = gDiffExitCode(PS_EXIT_SUCCESS); // Exit code
     46    exitValue = gDiffExitCode(exitValue); // Exit code
    4447
    45         if (data && data->stats && data->statsFile) {
    46             psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_DIFF", 0, "Total time (sec)", psTimerMark("gDiff"));
    47             psString stats = psMetadataConfigFormat(data->stats); // Statistics to output
    48             if (!stats || strlen(stats) == 0) {
    49                 psError(GDIFF_ERR_IO, false, "Unable to format statistics file");
    50             } else if (fprintf(data->statsFile, "%s", stats) != strlen(stats)) {
    51                 psError(GDIFF_ERR_IO, true, "Unable to write statistics file");
    52             }
    53             psFree(stats);
    54             if (fclose(data->statsFile) == EOF) {
    55                 psError(GDIFF_ERR_IO, true, "Unable to close statistics file");
    56             }
    57             data->statsFile = NULL;
    58             pmConfigRunFilenameAddWrite(data->config, "STATS", data->statsName);
    59             exitValue = gDiffExitCode(exitValue);
    60         }
     48    if (data && data->stats && data->statsFile) {
     49      psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_DIFF", 0, "Total time (sec)", psTimerMark("gDiff"));
     50      psString stats = psMetadataConfigFormat(data->stats); // Statistics to output
     51      if (!stats || strlen(stats) == 0) {
     52        psError(GDIFF_ERR_IO, false, "Unable to format statistics file");
     53      } else if (fprintf(data->statsFile, "%s", stats) != strlen(stats)) {
     54        psError(GDIFF_ERR_IO, true, "Unable to write statistics file");
     55      }
     56      psFree(stats);
     57      if (fclose(data->statsFile) == EOF) {
     58        psError(GDIFF_ERR_IO, true, "Unable to close statistics file");
     59      }
     60      data->statsFile = NULL;
     61      pmConfigRunFilenameAddWrite(data->config, "STATS", data->statsName);
     62      exitValue = gDiffExitCode(exitValue);
     63    }
    6164
    62         if (config && !gDiffFilesIterateUp(config, GDIFF_FILES_ALL)) {
    63             psError(psErrorCodeLast(), false, "Unable to close files.");
    64             exitValue = gDiffExitCode(exitValue);
    65             pmFPAfileFreeSetStrict(false);
    66         }
     65    if (config && !gDiffFilesIterateUp(config, GDIFF_FILES_ALL)) {
     66      psError(psErrorCodeLast(), false, "Unable to close files.");
     67      exitValue = gDiffExitCode(exitValue);
     68      pmFPAfileFreeSetStrict(false);
     69    }
    6770
    68         if (data) {
    69             psString dump_file = psMetadataLookupStr(NULL, data->config->arguments, "DUMP_CONFIG");
    70             if (dump_file) {
    71                 if (!pmConfigDump(data->config, dump_file)) {
    72                     psError(GDIFF_ERR_IO, false, "Unable to dump configuration.");
    73                     exitValue = gDiffExitCode(exitValue);
    74                 }
    75             }
    76             psFree(data);
    77         }
     71    if (data) {
     72      psString dump_file = psMetadataLookupStr(NULL, data->config->arguments, "DUMP_CONFIG");
     73      if (dump_file) {
     74        if (!pmConfigDump(data->config, dump_file)) {
     75          psError(GDIFF_ERR_IO, false, "Unable to dump configuration.");
     76          exitValue = gDiffExitCode(exitValue);
     77        }
     78      }
     79      psFree(data);
     80    }
    7881
    79         psTrace("gDiff", 1, "Finished at %f sec\n", psTimerMark("gDiff"));
    80         psLogMsg("gDiff", PS_LOG_INFO, "Complete gDiff run: %f sec\n", psTimerMark("gDiff"));
    81         psTimerStop();
     82    psTrace("gDiff", 1, "Finished at %f sec\n", psTimerMark("gDiff"));
     83    psLogMsg("gDiff", PS_LOG_INFO, "Complete gDiff run: %f sec\n", psTimerMark("gDiff"));
     84    psTimerStop();
    8285
    83         pmVisualClose(); // close plot windows, if -visual is set
    84         pmModelClassCleanup();
    85         pmConfigDone();
    86         pmVisualCleanup ();
    87         psLibFinalize();
     86    pmVisualClose(); // close plot windows, if -visual is set
     87    pmModelClassCleanup();
     88    pmConfigDone();
     89    pmVisualCleanup ();
     90    psLibFinalize();
    8891
    89         fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "gDiff");
    90         exitValue = gDiffExitCode(exitValue);
    91         exit(exitValue);
    92     }
     92    fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "gDiff");
     93    exitValue = gDiffExitCode(exitValue);
     94    exit(exitValue);
    9395}
Note: See TracChangeset for help on using the changeset viewer.