IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35351


Ignore:
Timestamp:
Apr 3, 2013, 12:32:10 PM (13 years ago)
Author:
eugene
Message:

exit status now reflects success / failure; fix double/float types

Location:
branches/eam_branches/ipp-20130307/Ohana/src/dvopsps/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130307/Ohana/src/dvopsps/src/insert_detections_dvopsps.c

    r35221 r35351  
    5757  }
    5858
     59  int status = TRUE;
    5960  // select measurements for each populated catalog
    6061  for (i = 0; i < skylist[0].Nregions; i++) {
     
    8687    // NOTE: this is where the real action happens
    8788    if (SAVE_REMOTE && HOST_ID) {
    88       append_detections_dvopsps_catalog (&catalog);
     89      if (!append_detections_dvopsps_catalog (&catalog)) {
     90        fprintf (stderr, "ERROR: failure to append detections to output catalog\n");
     91        status = FALSE;
     92      }
    8993    } else {
    90       insert_detections_dvopsps_catalog (&catalog, mysqlReal);
     94      if (!insert_detections_dvopsps_catalog (&catalog, mysqlReal)) {
     95        fprintf (stderr, "ERROR: failure to insert detections into mysql database\n");
     96        status = FALSE;
     97      }
    9198    }
    9299
     
    97104
    98105  if (SAVE_REMOTE && HOST_ID) {
    99     save_detections_dvopsps ();
    100   }
    101 
    102   return (TRUE);
     106    if (!save_detections_dvopsps ()) {
     107      fprintf (stderr, "ERROR: failure to save output file with detections\n");
     108      status = FALSE;
     109    }
     110  }
     111
     112  return (status);
    103113}     
    104114
  • branches/eam_branches/ipp-20130307/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c

    r35221 r35351  
    7474int save_detections_dvopsps () {
    7575
     76  int status = TRUE;
     77
    7678  if (!DetectionsSave (RESULT_FILE, detections, Ndetections)) {
    7779    fprintf (stderr, "failed to save detection file %s\n", RESULT_FILE);
     80    status = FALSE;
    7881  }
    7982
    8083  free (detections);
    8184  Ndetections = 0;
    82   return (TRUE);
     85  return (status);
    8386}
    8487
     
    101104  int Ninsert = 0;
    102105
     106  int status = TRUE;
     107
    103108  // NOTE for testing, just do a few objects
    104109  if (!mysql) {
     
    115120
    116121      // XXX check return status
    117       insert_detections_mysql_value (&buffer, &average[i], &measure[m+j]);
     122      if (!insert_detections_mysql_value (&buffer, &average[i], &measure[m+j])) {
     123        fprintf (stderr, "failure to insert detections in mysql\n");
     124        status = FALSE;
     125      }
    118126
    119127      if (buffer.Nbuffer > MAX_BUFFER) {
    120         insert_detections_mysql_commit (&buffer, mysql);
     128        if (!insert_detections_mysql_commit (&buffer, mysql)) {
     129          fprintf (stderr, "failure to insert detections in mysql (commit)\n");
     130          status = FALSE;
     131        }
    121132        if (DEBUG) fprintf (stderr, "inserted %d rows\n", Ninsert);
    122133        Ninsert = 0;
     
    134145    }
    135146  }
    136   insert_detections_mysql_commit (&buffer, mysql);
     147  if (!insert_detections_mysql_commit (&buffer, mysql)) {
     148    fprintf (stderr, "failure to insert detections in mysql (commit)\n");
     149    status = FALSE;
     150  }
     151 
    137152  if (VERBOSE) fprintf (stderr, "inserted %d rows\n", Ninsert);
    138153  FreeIOBuffer (&buffer);
     154
     155  if (!status) {
     156    MARKTIME("-- failed to insert "OFF_T_FMT" rows in %f sec\n", found, dtime);
     157    return (FALSE);
     158  }
    139159
    140160  MARKTIME("-- inserted "OFF_T_FMT" rows in %f sec, skipped %d without IDs\n", found, dtime, missingID);
     
    188208  PrintIOBuffer (buffer, "%lu, ", average->extID);        // objID
    189209  PrintIOBuffer (buffer, "%u, ", measure->dbFlags);       // flags
     210
    190211  float zp = code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal;
    191212  float exptime = pow(10.0, 0.4 * measure->dt);
     
    211232  MYSQL_RES *result;
    212233
     234  int status = TRUE;
     235
    213236  // check that the last two chars are ,\n and replace with ;\n
    214237  if (!strcmp(&buffer->buffer[buffer->Nbuffer-2], ",\n")) {
     
    222245  if (mysql) {
    223246    if (DEBUG) fprintf (stderr, "%s\n", buffer->buffer);
    224     int status = mysql_query(mysql, buffer->buffer);
    225     if (status) {
     247    int mysqlStatus = mysql_query(mysql, buffer->buffer);
     248    if (mysqlStatus) {
    226249      fprintf (stderr, "error with insert:\n");
    227250      fprintf (stderr, "%s\n", mysql_error(mysql));
    228251      fprintf (stderr, "Nbuffer: %d\n", buffer->Nbuffer);
     252      status = FALSE;
    229253    }
    230254    result = mysql_store_result (mysql);
     
    234258  }
    235259
    236   return TRUE;
    237 }
     260  return status;
     261}
  • branches/eam_branches/ipp-20130307/Ohana/src/dvopsps/src/insert_objects_dvopsps_catalog.c

    r35221 r35351  
    9696
    9797  PrintIOBuffer (&buffer, "CREATE TABLE %s_cpt ("
    98                  "RA FLOAT,  "         
    99                  "DEC_ FLOAT,  "         
    100                  "RA_ERR REAL,  "     
    101                  "DEC_ERR REAL,  "     
    102                  "U_RA REAL,  "       
    103                  "U_DEC REAL,  "       
    104                  "V_RA_ERR REAL,  "   
    105                  "V_DEC_ERR REAL,  "   
    106                  "PAR REAL,  "         
    107                  "PAR_ERR REAL,  "     
    108                  "CHISQ_POS REAL,  "   
    109                  "CHISQ_PM REAL,  "   
    110                  "CHISQ_PAP REAL,  "   
     98                 "RA DOUBLE,  "         
     99                 "DEC_ DOUBLE,  "         
     100                 "RA_ERR FLOAT,  "     
     101                 "DEC_ERR FLOAT,  "     
     102                 "U_RA FLOAT,  "       
     103                 "U_DEC FLOAT,  "       
     104                 "V_RA_ERR FLOAT,  "   
     105                 "V_DEC_ERR FLOAT,  "   
     106                 "PAR FLOAT,  "         
     107                 "PAR_ERR FLOAT,  "     
     108                 "CHISQ_POS FLOAT,  "   
     109                 "CHISQ_PM FLOAT,  "   
     110                 "CHISQ_PAP FLOAT,  "   
    111111                 "MEAN_EPOCH INT,  " 
    112112                 "TIME_RANGE INT,  " 
    113                  "PSF_QF REAL, "     
    114                  "PSF_QF_PERF REAL,  "
    115                  "STARGAL_SEP REAL,  "
     113                 "PSF_QF FLOAT, "     
     114                 "PSF_QF_PERF FLOAT,  "
     115                 "STARGAL_SEP FLOAT,  "
    116116                 "NUMBER_POS SMALLINT,  " 
    117117                 "NMEASURE SMALLINT,  "   
     
    152152
    153153  PrintIOBuffer (&buffer, "CREATE TABLE %s_cps ("
    154                  "MAG REAL,  "             
    155                  "MAG_AP REAL,  "             
    156                  "MAG_KRON REAL,  "       
    157                  "MAG_KRON_ERR REAL,  "   
    158                  "MAG_ERR REAL,  "         
    159                  "MAG_CHI REAL,  "         
    160                  "FLUX_PSF REAL,  "       
    161                  "FLUX_PSF_ERR REAL,  "   
    162                  "FLUX_KRON REAL,  "       
    163                  "FLUX_KRON_ERR REAL,  "   
     154                 "MAG FLOAT,  "             
     155                 "MAG_AP FLOAT,  "             
     156                 "MAG_KRON FLOAT,  "       
     157                 "MAG_KRON_ERR FLOAT,  "   
     158                 "MAG_ERR FLOAT,  "         
     159                 "MAG_CHI FLOAT,  "         
     160                 "FLUX_PSF FLOAT,  "       
     161                 "FLUX_PSF_ERR FLOAT,  "   
     162                 "FLUX_KRON FLOAT,  "       
     163                 "FLUX_KRON_ERR FLOAT,  "   
    164164                 "FLAGS INT,  "           
    165165                 "NCODE SMALLINT,  "           
  • branches/eam_branches/ipp-20130307/Ohana/src/dvopsps/src/mysql_dvopsps.c

    r35098 r35351  
    5858  // dump_result (connection);
    5959   
    60   sprintf (query, "show variables like 'max_allowed_packet';");
    61   if (mysql_query (connection, query)) {
    62     fprintf (stderr, "failed to set max_allowed_packet\n");
    63     fprintf (stderr, "%s\n", mysql_error (connection));
    64     return NULL;
    65   }
    66   dump_result (connection);
     60  // sprintf (query, "show variables like 'max_allowed_packet';");
     61  // if (mysql_query (connection, query)) {
     62  //   fprintf (stderr, "failed to set max_allowed_packet\n");
     63  //   fprintf (stderr, "%s\n", mysql_error (connection));
     64  //   return NULL;
     65  // }
     66  // dump_result (connection);
    6767   
    6868  if (0) {
Note: See TracChangeset for help on using the changeset viewer.