--- ray/src/gen/gendaymtx.c 2014/05/30 00:00:54 2.14 +++ ray/src/gen/gendaymtx.c 2014/06/17 21:01:21 2.16 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: gendaymtx.c,v 2.14 2014/05/30 00:00:54 greg Exp $"; +static const char RCSid[] = "$Id: gendaymtx.c,v 2.16 2014/06/17 21:01:21 greg Exp $"; #endif /* * gendaymtx.c @@ -319,6 +319,7 @@ main(int argc, char *argv[]) int dir_is_horiz; /* direct is meas. on horizontal? */ float *mtx_data = NULL; /* our matrix data */ int ntsteps = 0; /* number of rows in matrix */ + int step_alloc = 0; int last_monthly = 0; /* month of last report */ int mo, da; /* month (1-12) and day (1-31) */ double hr; /* hour (local standard time) */ @@ -460,7 +461,10 @@ main(int argc, char *argv[]) double sda, sta; /* make space for next time step */ mtx_offset = 3*nskypatch*ntsteps++; - mtx_data = resize_dmatrix(mtx_data, ntsteps, nskypatch); + if (ntsteps > step_alloc) { + step_alloc += (step_alloc>>1) + ntsteps + 7; + mtx_data = resize_dmatrix(mtx_data, step_alloc, nskypatch); + } if (dif <= 1e-4) { memset(mtx_data+mtx_offset, 0, sizeof(float)*3*nskypatch); continue;