From 642d9b9801b6cb816184d85a8012fbb65a8f8947 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Sun, 28 Jul 2013 13:15:40 -0700 Subject: [PATCH] smurf: Ignore errors if the cache free fails There are reports of CALCQU triggering errors during the cleanup of the cache. I am guessing that CALCQU does not attempt to fix up header metadata so does not initialise an early AST object in the main thread. Later on the WVM data are calculated in threads such that when the object is freed in the main thread at task exit the object is invalid even though the pointer is defined. The error message is: !! AST: Error at line 160 in file smf_calc_wvm.c. ! Invalid Object pointer given (value is 390951). ! This pointer has been annulled, or the associated Object deleted. ! Application exit status AST__OBJIN, Object invalid which hints that my interpretation may not be the whole story. --- applications/smurf/libsmf/smf_calc_wvm.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/applications/smurf/libsmf/smf_calc_wvm.c b/applications/smurf/libsmf/smf_calc_wvm.c index e57409a6f53..d787dd6c64d 100644 --- a/applications/smurf/libsmf/smf_calc_wvm.c +++ b/applications/smurf/libsmf/smf_calc_wvm.c @@ -157,7 +157,13 @@ double smf_calc_wvm( const smfHead *hdr, double approxam, AstKeyMap * extpars, i /* See if we are required to clear any cache */ if (!hdr && approxam != VAL__BADD && approxam < 0.0) { - if (CACHE) CACHE = astAnnul( CACHE ); + if (CACHE) { + CACHE = astAnnul( CACHE ); + /* if we got an error ignore it. An error would indicate that we + somehow instantiated the cache in a different thread to the one we + are using to free it. */ + if (*status == AST__OBJIN) errAnnul( status ); + } return VAL__BADD; } @@ -249,9 +255,14 @@ double smf_calc_wvm( const smfHead *hdr, double approxam, AstKeyMap * extpars, i errAnnul( status ); } + smf_timerinit(&tv1,&tv2,status); + /* Get the pwv for this airmass */ wvmOpt( (float)airmass, (float)tamb, wvm, &pwv, &tau0, &twater, &rms); + printf("Called wvmOpt with %g %g %g %g : %.5f s\n", airmass, wvm[0], wvm[1], wvm[2], + smf_timerupdate(&tv1,&tv2,status)); + /* Convert to zenith pwv */ pwv /= airmass;