Code:
$ git diff
diff --git a/stepfit.c b/stepfit.c
index 6a03f30..fed4762 100644
--- a/stepfit.c
+++ b/stepfit.c
@@ -114,6 +114,21 @@ void step_response(event *current, double risetime, int64_t maxiters, double min
control.patience = maxiters;
lm_status_struct status;
+ if ( event->index == 0 ) { // replace 0 with the magic number of the bad event
+ FILE *dump = fopen("dump.dat","wb");
+ fwrite(&n,sizeof(n),1,dump);
+ fwrite(par,sizeof(par[0]),n,dump);
+ fwrite(&length,sizeof(length),1,dump);
+ fwrite(time,sizeof(time[0]),length,dump);
+ fwrite(current->signal,sizeof(current->signal[0]),length,dump);
+ fwrite(&maxlength,sizeof(maxlength),1,dump);
+ fwrite(&maxstep,sizeof(maxstep),1,dump);
+ fwrite(&maxbaseline,sizeof(maxbaseline),1,dump);
+ fwrite(&risetime,sizeof(risetime),1,dump);
+ fwrite(&sign,sizeof(sign),1,dump);
+ fclose(dump);
+ }
+
lmmin_int64(n, par, length, (const void*) &data, evaluate, &control, &status );
Then a much simplified main() to load dump.dat into appropriate buffers, then call lmmin_int64() would permit much quicker turn around on experiments and analysis.