Commits

Daniel Reynolds committed 923e667

Updated rate table lookup bin_id calculation to handle scenario where a calculated bin_id is outside the temperature bounds. If that occurs, the table lookup will use the temperature interval closest to the desired temperature to generate the rates. This update is purely for robustness, so that an out-of-bounds candidate temperature value will not cause a seg-fault in the table lookup routine.

  • Participants
  • Parent commits 9df37a4

Comments (0)

Files changed (1)

File dengo/templates/rates_and_rate_tables.C.template

     /*fprintf(stderr, "lb = % 0.16g, ub = % 0.16g\n", lb, ub);*/
     for (i = 0; i < nstrip; i++) {
         data->bin_id[i] = bin_id = (int) (data->idbin * (data->logTs[i] - lb));
-        if (data->bin_id[i] == 0) {
+        if (data->bin_id[i] <= 0) {
             data->bin_id[i] = 1;
-        } else if (data->bin_id[i] == data->nbins) {
+        } else if (data->bin_id[i] >= data->nbins) {
             data->bin_id[i] = data->nbins - 1;
         }
         t1 = (lb + (bin_id - 1) * data->dbin);