/* test to make sure padding does what it's supposed to do */ static int testPadding( void ) { int keep = lalDebugLevel; XLALClobberDebugLevel(lalDebugLevel | LALMEMDBGBIT | LALMEMPADBIT); XLALClobberDebugLevel(lalDebugLevel & ~LALMEMTRKBIT); /* try to free NULL pointer */ /* changed behaviour: LALFree is a no-op when passed NULL */ // trial( LALFree( NULL ), SIGSEGV, "error: tried to free NULL pointer" ); /* double free */ /* actually, this cannot be done robustly -- system can change values * in unallocated space at will */ //trial( p = LALMalloc( 2 * sizeof( *p ) ), 0, "" ); //trial( LALFree( p ), 0, "" ); //trial( LALFree( p ), SIGSEGV, "error: tried to free a freed pointer" ); //trial( LALCheckMemoryLeaks(), 0, "" ); /* wrong magic */ trial( p = LALMalloc( 2 * sizeof( *p ) ), 0, "" ); p[-1] = 4; trial( LALFree( p ), SIGSEGV, "error: wrong magic" ); p[-1] = 0xABadCafe; trial( LALFree( p ), 0, "" ); trial( LALCheckMemoryLeaks(), 0, "" ); /* corrupt size */ trial( p = LALMalloc( 4 * sizeof( *p ) ), 0, ""); n = p[-2]; p[-2] = -2; trial( LALFree( p ), SIGSEGV, "error: corrupt size descriptor" ); p[-2] = n; trial( LALFree( p ), 0, "" ); trial( LALCheckMemoryLeaks(), 0, "" ); /* overwritten array bounds */ trial( p = LALMalloc( 8 * sizeof( *p ) ), 0, "" ); n = p[8]; p[8] = 0; trial( LALFree( p ), SIGSEGV, "error: array bounds overwritten" ); p[8] = n; trial( LALFree( p ), 0, "" ); trial( LALCheckMemoryLeaks(), 0, "" ); /* free too much memory */ q = malloc( 4 * sizeof( *p ) ); trial( p = LALMalloc( sizeof( *p ) ), 0, "" ); memcpy( q, p - 2, 4 * sizeof( *p ) ); trial( LALFree( p ), 0, "" ); trial( LALFree( q + 2 ), SIGSEGV, "error: lalMallocTotal too small" ); free( q ); trial( LALCheckMemoryLeaks(), 0, "" ); XLALClobberDebugLevel(keep); return 0; }
/*---------- function definitions ---------- */ int main(int argc,char *argv[]) { LALStatus status = blank_status; /* initialize status */ vrbflg = 1; /* verbose error-messages */ /* set LAL error-handler */ lal_errhandler = LAL_ERR_EXIT; /* exit with returned status-code on error */ /* register all user-variables */ LAL_CALL (InitUserVars(&status, &CommandLineArgs), &status); /* read cmdline & cfgfile */ BOOLEAN should_exit = 0; XLAL_CHECK_MAIN (XLALUserVarReadAllInput(&should_exit, argc, argv, lalAppsVCSInfoList) == XLAL_SUCCESS, XLAL_EFUNC); if (should_exit) return EXIT_FAILURE; LAL_CALL ( CheckUserInput (&status, &CommandLineArgs), &status); LAL_CALL ( Initialize (&status, &CommandLineArgs), &status); /*---------- central function: compute F-statistic ---------- */ LAL_CALL ( ComputeF(&status, CommandLineArgs), &status); /* Free remaining memory */ LAL_CALL ( LALSDestroyVector(&status, &(amc.a) ), &status); LAL_CALL ( LALSDestroyVector(&status, &(amc.b) ), &status); XLALDestroyUserVars(); LALCheckMemoryLeaks(); return 0; } /* main() */
int main( int argc, char *argv[] ) { LALFILE *outfile = NULL; LALCache *cache; int arg = 1; XLALSetErrorHandler( XLALExitErrorHandler ); if ( argc > 1 && ! strcmp(argv[1],"-o") ) { outfile = XLALFileOpen( argv[2], "w" ); arg += 2; } cache = XLALCacheGlob( NULL, argc == 1 ? NULL : argv[arg] ); for ( ; arg < argc; ++arg ) { LALCache *tmp = cache; LALCache *add; add = XLALCacheGlob( NULL, argv[arg] ); cache = XLALCacheMerge( tmp, add ); XLALDestroyCache( add ); XLALDestroyCache( tmp ); } XLALCacheFileWrite( outfile ? outfile : LALSTDOUT, cache ); XLALFileClose( outfile ); XLALDestroyCache( cache ); LALCheckMemoryLeaks(); return 0; }
/* ********************************************************/ int main(int UNUSED argc, char **argv) { static LALStatus status; /* status structure */ /* initialize status */ status.statusCode = 0; status.statusPtr = NULL; status.statusDescription = NULL; /* Actual test are performed by this function */ /* RunGeneratePulsarSignalTest(&status,argc,argv); */ /* 02/02/05 gam */ RunGeneratePulsarSignalTest(&status); if (status.statusCode) { fprintf(stderr,"Error: statusCode = %i statusDescription = %s \n", status.statusCode, status.statusDescription); return 1; } LALCheckMemoryLeaks(); if ( lalDebugLevel & LALINFO ) { XLALPrintError( "Info[0]: program %s, file %s, line %d, %s\n" " %s\n", *argv, __FILE__, __LINE__, "$Id$", (GENERATEPULSARSIGNALTESTC_MSGENORM) ); } return GENERATEPULSARSIGNALTESTC_ENORM; }
int main( void ) { #if defined(NDEBUG) /* debugging is turned off */ return 77; /* don't do any testing */ #else XLALGetDebugLevel(); XLALClobberDebugLevel(LALMEMDBG); /* get rid of annoying messages from elsewhere */ setvbuf( mystderr = stdout, NULL, _IONBF, 0 ); FILE *fp = freopen( "/dev/null", "w", stderr ); if (fp == NULL) die ( unable to open /dev/null ); lalRaiseHook = TestRaise; if ( lalNoDebug ) /* library was not compiled with debugging */ return 77; /* don't do any testing */ if ( testOK() ) return 1; if ( testPadding() ) return 1; if ( testAllocList() ) return 1; if ( stressTestRealloc() ) return 1; trial( LALCheckMemoryLeaks(), 0, "" ); return 0; #endif }
int main( void ) { CircularOrbit(); EccentricOrbit(); LALCheckMemoryLeaks(); return 0; }
int main(void) { XLALSetErrorHandler(XLALAbortErrorHandler); test_orf(); LALCheckMemoryLeaks(); return 0; }
int main(int argc, char *argv[]) { char tstr[32]; // string to hold GPS time -- 31 characters is enough const double H0 = 0.72 * LAL_H0FAC_SI; // Hubble's constant in seconds const size_t length = 65536; // number of points in a segment const size_t stride = length / 2; // number of points in a stride size_t i, n; REAL8FrequencySeries *OmegaGW = NULL; REAL8TimeSeries **seg = NULL; LIGOTimeGPS epoch; gsl_rng *rng; XLALSetErrorHandler(XLALAbortErrorHandler); parseargs(argc, argv); XLALGPSSetREAL8(&epoch, tstart); gsl_rng_env_setup(); rng = gsl_rng_alloc(gsl_rng_default); OmegaGW = XLALSimSGWBOmegaGWFlatSpectrum(Omega0, flow, srate/length, length/2 + 1); n = duration * srate; seg = LALCalloc(numDetectors, sizeof(*seg)); printf("# time (s)"); for (i = 0; i < numDetectors; ++i) { char name[LALNameLength]; snprintf(name, sizeof(name), "%s:STRAIN", detectors[i].frDetector.prefix); seg[i] = XLALCreateREAL8TimeSeries(name, &epoch, 0.0, 1.0/srate, &lalStrainUnit, length); printf("\t%s (strain)", name); } printf("\n"); XLALSimSGWB(seg, detectors, numDetectors, 0, OmegaGW, H0, rng); // first time to initilize while (1) { // infinite loop size_t j; for (j = 0; j < stride; ++j, --n) { // output first stride points LIGOTimeGPS t = seg[0]->epoch; if (n == 0) // check if we're done goto end; printf("%s", XLALGPSToStr(tstr, XLALGPSAdd(&t, j * seg[0]->deltaT))); for (i = 0; i < numDetectors; ++i) printf("\t%e", seg[i]->data->data[j]); printf("\n"); } XLALSimSGWB(seg, detectors, numDetectors, stride, OmegaGW, H0, rng); // make more data } end: for (i = 0; i < numDetectors; ++i) XLALDestroyREAL8TimeSeries(seg[i]); XLALFree(seg); XLALDestroyREAL8FrequencySeries(OmegaGW); LALCheckMemoryLeaks(); return 0; }
int main( int argc, char *argv[]) { /* sanity check for input arguments */ if ( argc != 1 ) XLAL_ERROR ( XLAL_EINVAL, "The executable '%s' doesn't support any input arguments right now.\n", argv[0] ); printf ("Starting test...\n"); /* set up single- and multi-IFO F-stat input */ REAL4 TwoF = 7.0; UINT4 numDetectors = 2; REAL4Vector *TwoFX = NULL; if ( (TwoFX = XLALCreateREAL4Vector ( numDetectors )) == NULL ) { XLAL_ERROR ( XLAL_EFUNC, "failed to XLALCreateREAL4Vector( %d )\n", numDetectors ); return XLAL_EFAILED; } TwoFX->data[0] = 4.0; TwoFX->data[1] = 12.0; REAL8 rhomaxline = 0.0; /* prior from LV-stat derivation, 0 means pure line veto, +inf means pure multi-Fstat */ REAL8Vector *lX = NULL; /* per-IFO prior odds ratio for line vs. Gaussian noise, NULL is interpreted as l[X]=1 for all X */ /* maximum allowed difference between recalculated and XLAL result */ REAL4 tolerance_allterms = 2e-04; REAL4 tolerance_leadterm = 2e-02; /* compute and compare the results for one set of rhomaxline, lX values */ printf ("Computing LV-stat for TwoF_multi=%f, TwoFX[0]=%f, TwoFX[1]=%f, rhomaxline=%f, priors lX=NULL...\n", TwoF, TwoFX->data[0], TwoFX->data[1], rhomaxline ); if ( XLALCompareLVComputations( TwoF, TwoFX, rhomaxline, lX, tolerance_allterms, tolerance_leadterm ) != XLAL_SUCCESS ) { XLAL_ERROR ( XLAL_EFUNC, "Test failed.\n" ); return XLAL_EFAILED; } /* change the priors to catch more possible problems */ rhomaxline = 5.0; if ( (lX = XLALCreateREAL8Vector ( numDetectors )) == NULL ) { XLAL_ERROR ( XLAL_EFUNC, "failed to XLALCreateREAL8Vector( %d )\n", numDetectors ); return XLAL_EFAILED; } lX->data[0] = 0.5; lX->data[1] = 0.8; /* compute and compare the results for second set of rhomaxline, lX values */ printf ("Computing LV-stat for TwoF_multi=%f, TwoFX[0]=%f, TwoFX[1]=%f, rhomaxline=%f, priors lX=(%f,%f)...\n", TwoF, TwoFX->data[0], TwoFX->data[1], rhomaxline, lX->data[0], lX->data[1] ); if ( XLALCompareLVComputations( TwoF, TwoFX, rhomaxline, lX, tolerance_allterms, tolerance_leadterm ) != XLAL_SUCCESS ) { XLAL_ERROR ( XLAL_EFUNC, "Test failed.\n" ); return XLAL_EFAILED; } /* free memory */ XLALDestroyREAL4Vector(TwoFX); XLALDestroyREAL8Vector(lX); LALCheckMemoryLeaks(); return XLAL_SUCCESS; } /* main */
/* ----- function definitions ---------- */ int main ( void ) { LALStatus XLAL_INIT_DECL(status); SFTCatalog *catalog = NULL; SFTConstraints XLAL_INIT_DECL(constraints); MultiSFTVector *multiSFTs = NULL; MultiPSDVector *multiPSDs = NULL; MultiNoiseWeights *multiWeightsXLAL = NULL; MultiNoiseWeights *multiWeightsCorrect = NULL; UINT4 rngmedBins = 11; REAL8 tolerance = 2e-6; /* same algorithm, should be basically identical results */ /* Construct the "correct" weights, calculated using the old LAL routines */ UINT4 numIFOsCorrect = 2; XLAL_CHECK ( ( multiWeightsCorrect = XLALCalloc ( 1, sizeof(*multiWeightsCorrect ) ) ) != NULL, XLAL_ENOMEM ); multiWeightsCorrect->length = numIFOsCorrect; multiWeightsCorrect->Sinv_Tsft = 1.980867126449e+52; XLAL_CHECK ( ( multiWeightsCorrect->data = XLALCalloc ( numIFOsCorrect, sizeof(*multiWeightsCorrect->data ) ) ) != NULL, XLAL_ENOMEM ); XLAL_CHECK ( ( multiWeightsCorrect->data[0] = XLALCreateREAL8Vector(4) ) != NULL, XLAL_ENOMEM ); multiWeightsCorrect->data[0]->data[0] = 6.425160659487e-05; multiWeightsCorrect->data[0]->data[1] = 7.259453662367e-06; multiWeightsCorrect->data[0]->data[2] = 9.838893684664e-04; multiWeightsCorrect->data[0]->data[3] = 5.043766789923e-05; XLAL_CHECK ( ( multiWeightsCorrect->data[1] = XLALCreateREAL8Vector(3) ) != NULL, XLAL_ENOMEM ); multiWeightsCorrect->data[1]->data[0] = 1.582309910283e-04; multiWeightsCorrect->data[1]->data[1] = 5.345673753744e-04; multiWeightsCorrect->data[1]->data[2] = 6.998201363537e+00; /* Construct the catalog */ XLAL_CHECK ( ( catalog = XLALSFTdataFind ( TEST_DATA_DIR "MultiNoiseWeightsTest*.sft", &constraints ) ) != NULL, XLAL_EFUNC, " XLALSFTdataFind failed\n" ); /* Load the SFTs */ XLAL_CHECK ( ( multiSFTs = XLALLoadMultiSFTs ( catalog, -1, -1 ) ) != NULL, XLAL_EFUNC, " XLALLoadMultiSFTs failed\n" ); /* calculate the psd and normalize the SFTs */ XLAL_CHECK ( ( multiPSDs = XLALNormalizeMultiSFTVect ( multiSFTs, rngmedBins, NULL ) ) != NULL, XLAL_EFUNC, " XLALNormalizeMultiSFTVect failed\n" ); /* Get weights using XLAL function */ XLAL_CHECK ( ( multiWeightsXLAL = XLALComputeMultiNoiseWeights ( multiPSDs, rngmedBins, 0 ) ) != NULL, XLAL_EFUNC, " XLALComputeMultiNoiseWeights failed\n" ); /* Compare XLAL weights to reference */ XLAL_CHECK ( XLALCompareMultiNoiseWeights ( multiWeightsXLAL, multiWeightsCorrect, tolerance ) == XLAL_SUCCESS, XLAL_EFAILED, "Comparison between XLAL and reference MultiNoiseWeights failed\n" ); /* Clean up memory */ XLALDestroyMultiNoiseWeights ( multiWeightsCorrect ); XLALDestroyMultiNoiseWeights ( multiWeightsXLAL ); XLALDestroyMultiPSDVector ( multiPSDs ); XLALDestroyMultiSFTVector ( multiSFTs ); XLALDestroySFTCatalog ( catalog ); /* check for memory-leaks */ LALCheckMemoryLeaks(); return XLAL_SUCCESS; } /* main() */
int Freemem(void) { LALFree(po); LALFree(p); LALCheckMemoryLeaks(); return 0; }
int main( void ) { /* Create hash table */ LALBitset *bs = XLALBitsetCreate(); XLAL_CHECK_MAIN( bs != NULL, XLAL_EFUNC ); /* Create some random bits */ BOOLEAN XLAL_INIT_DECL( bits, [4096] ); gsl_rng *r = gsl_rng_alloc( gsl_rng_mt19937 ); XLAL_CHECK_MAIN( r != NULL, XLAL_ESYS ); int nbits = 0; for ( size_t n = 0; n < XLAL_NUM_ELEM( bits ); ++n ) { bits[n] = ( gsl_rng_uniform( r ) > 0.44 ); nbits += bits[n] ? 1 : 0; } /* Create random index offset into bitset */ const UINT8 n0 = gsl_rng_get( r ) % 65536; /* Print information */ printf("nbits = %i, n0 = %"LAL_UINT8_FORMAT"\n", nbits, n0); /* Set bits */ for ( size_t n = 0; n < XLAL_NUM_ELEM( bits ); ++n ) { XLAL_CHECK_MAIN( XLALBitsetSet( bs, n0 + n, bits[n] ) == XLAL_SUCCESS, XLAL_EFUNC ); } /* Get bits */ for ( size_t n = 0; n < XLAL_NUM_ELEM( bits ); ++n ) { BOOLEAN is_set = 0; XLAL_CHECK_MAIN( XLALBitsetGet( bs, n0 + n, &is_set ) == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK_MAIN( !is_set == !bits[n], XLAL_EFAILED, "Inconsistent bit at index %"LAL_UINT8_FORMAT": LALBitset=%i, reference=%i", n0 + n, is_set, bits[n] ); } /* Clear bitset */ XLAL_CHECK_MAIN( XLALBitsetClear( bs ) == XLAL_SUCCESS, XLAL_EFUNC ); for ( size_t n = 0; n < XLAL_NUM_ELEM( bits ); ++n ) { BOOLEAN is_set = 0; XLAL_CHECK_MAIN( XLALBitsetGet( bs, n0 + n, &is_set ) == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK_MAIN( !is_set, XLAL_EFAILED, "Bit still set at index %"LAL_UINT8_FORMAT, n0 + n ); } /* Cleanup */ gsl_rng_free( r ); XLALBitsetDestroy( bs ); /* Check for memory leaks */ LALCheckMemoryLeaks(); return EXIT_SUCCESS; }
// ==================== function definitions ==================== int main(void) { // ---------- test angle conversions ---------- XLAL_CHECK_MAIN ( test_HMS_RAD() == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK_MAIN ( test_DMS_RAD() == XLAL_SUCCESS, XLAL_EFUNC ); // check for memory leaks LALCheckMemoryLeaks(); return EXIT_SUCCESS; } // main()
/** * MAIN function */ int main(void) { XLAL_CHECK ( test_XLALSFTVectorToLFT() == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK ( test_XLALSincInterpolateCOMPLEX8TimeSeries() == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK ( test_XLALSincInterpolateSFT() == XLAL_SUCCESS, XLAL_EFUNC ); LALCheckMemoryLeaks(); return XLAL_SUCCESS; } /* main() */
int main(int argc, char *argv[]) { const double H0 = 0.72 * LAL_H0FAC_SI; // Hubble's constant in seconds const double srate = 16384.0; // sampling rate in Hertz const size_t length = 65536; // number of points in a segment const size_t stride = length / 2; // number of points in a stride size_t i, n; REAL8FrequencySeries *OmegaGW = NULL; REAL8TimeSeries **seg = NULL; LIGOTimeGPS epoch; gsl_rng *rng; XLALSetErrorHandler(XLALAbortErrorHandler); parseargs(argc, argv); XLALGPSSetREAL8(&epoch, tstart); gsl_rng_env_setup(); rng = gsl_rng_alloc(gsl_rng_default); OmegaGW = XLALSimSGWBOmegaGWFlatSpectrum(Omega0, flow, srate/length, length/2 + 1); n = duration * srate; seg = LALCalloc(numDetectors, sizeof(*seg)); for (i = 0; i < numDetectors; ++i) seg[i] = XLALCreateREAL8TimeSeries("STRAIN", &epoch, 0.0, 1.0/srate, &lalStrainUnit, length); XLALSimSGWB(seg, detectors, numDetectors, 0, OmegaGW, H0, rng); // first time to initilize while (1) { // infinite loop double t0 = XLALGPSGetREAL8(&seg[0]->epoch); size_t j; for (j = 0; j < stride; ++j, --n) { // output first stride points if (n == 0) // check if we're done goto end; printf("%.9f", t0 + j * seg[0]->deltaT); for (i = 0; i < numDetectors; ++i) printf("\t%e", seg[i]->data->data[j]); printf("\n"); } XLALSimSGWB(seg, detectors, numDetectors, stride, OmegaGW, H0, rng); // make more data } end: for (i = 0; i < numDetectors; ++i) XLALDestroyREAL8TimeSeries(seg[i]); XLALFree(seg); XLALDestroyREAL8FrequencySeries(OmegaGW); LALCheckMemoryLeaks(); return 0; }
/* test to make sure alloc list does what it's supposed to do */ static int testAllocList( void ) { int keep = lalDebugLevel; s = malloc( sizeof( *s ) ); XLALClobberDebugLevel(lalDebugLevel | LALMEMDBGBIT | LALMEMTRKBIT); XLALClobberDebugLevel(lalDebugLevel & ~LALMEMPADBIT); /* empty allocation list */ trial( LALCheckMemoryLeaks(), 0, "" ); trial( LALFree( s ), SIGSEGV, "not found" ); /* can't find allocation in PopAlloc */ trial( p = LALMalloc( 2 * sizeof( *p ) ), 0, "" ); trial( q = LALMalloc( 4 * sizeof( *q ) ), 0, "" ); trial( r = LALMalloc( 8 * sizeof( *r ) ), 0, "" ); trial( LALFree( s ), SIGSEGV, "not found" ); trial( LALFree( p ), 0, "" ); trial( LALFree( r ), 0, "" ); trial( LALCheckMemoryLeaks(), SIGSEGV, "memory leak" ); trial( LALFree( q ), 0, "" ); trial( LALCheckMemoryLeaks(), 0, "" ); /* can't find allocation in ModAlloc */ /* For some reason this next test fails on Snow Leopard... */ /* trial( s = LALRealloc( s, 1024 ), SIGSEGV, "not found" ); */ trial( p = LALRealloc( NULL, 2 * sizeof( *p ) ), 0, "" ); /* trial( s = LALRealloc( s, 1024 ), SIGSEGV, "not found" ); */ trial( LALFree( p ), 0, "" ); trial( LALCheckMemoryLeaks(), 0, "" ); free( s ); XLALClobberDebugLevel(keep); return 0; }
// ==================== function definitions ==================== int main(void) { // ---------- test various string-value parser functions ---------- XLAL_CHECK_MAIN ( test_ParseStringValue() == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK_MAIN ( test_ParseStringVector() == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK_MAIN ( test_ParseREAL8Vector() == XLAL_SUCCESS, XLAL_EFUNC ); // check for memory leaks LALCheckMemoryLeaks(); return EXIT_SUCCESS; } // main()
int main (void) { static REAL4Vector *signal1; static LALStatus status; static InspiralTemplate params; static REAL8 dt; UINT4 n; params.OmegaS = 0.; params.Theta = 0.; params.ieta=1; params.mass1=5.1; params.mass2=5.; params.startTime=0.0; params.startPhase=0.0; params.fLower=40.0; params.fCutoff=2048.00; params.tSampling=8192.0; params.order=6; params.approximant=IMRPhenomB; /* SpinTaylorT3 */ params.signalAmplitude=1.0; params.nStartPad=0; params.nEndPad=0; params.massChoice=m1Andm2; params.distance = 100.; dt = 1./params.tSampling; params.spin1[2]=1.0; params.spin2[2]=0.99; LALInspiralWaveLength(&status, &n, params); LALInspiralParameterCalc(&status, ¶ms); fprintf(stderr, "Testing Inspiral Signal Generation Codes:\n"); fprintf(stderr, "Signal length=%d, m1=%e, m2=%e, fLower=%e, fUpper=%e\n", n, params.mass1, params.mass2, params.fLower, params.fCutoff); LALCreateVector(&status, &signal1, n); LALInspiralWave(&status, signal1, ¶ms); fprintf(stderr,"fFinal = %e\n", params.fFinal); printf_timeseries(signal1->length, signal1->data, dt, params.startTime); REPORTSTATUS(&status); printf("duration is %f \n", params.tC); printf("final frequency is %f \n", params.fFinal); LALDestroyVector(&status, &signal1); LALCheckMemoryLeaks(); return 0; }
int FreeMem(void) { LALFrClose(&status,&framestream); LALDestroyVector(&status,&darm.data); LALDestroyVector(&status,&exc.data); LALDestroyVector(&status,&asq.data); LALDestroyVector(&status,&asqwin); LALDestroyVector(&status,&darmwin); LALDestroyVector(&status,&excwin); LALCheckMemoryLeaks(); return 0; }
int main(void) { XLALSetErrorHandler(XLALAbortErrorHandler); test_CHARVector(); test_INT2Vector(); test_INT4Vector(); test_INT8Vector(); test_UINT2Vector(); test_UINT4Vector(); test_UINT8Vector(); test_REAL4Vector(); test_REAL8Vector(); test_COMPLEX8Vector(); test_COMPLEX16Vector(); test_INT2Array(); test_INT4Array(); test_INT8Array(); test_UINT2Array(); test_UINT4Array(); test_UINT8Array(); test_REAL4Array(); test_REAL8Array(); test_COMPLEX8Array(); test_COMPLEX16Array(); test_INT2TimeSeries(); test_INT4TimeSeries(); test_INT8TimeSeries(); test_UINT2TimeSeries(); test_UINT4TimeSeries(); test_UINT8TimeSeries(); test_REAL4TimeSeries(); test_REAL8TimeSeries(); test_COMPLEX8TimeSeries(); test_COMPLEX16TimeSeries(); test_REAL4FrequencySeries(); test_REAL8FrequencySeries(); test_COMPLEX8FrequencySeries(); test_COMPLEX16FrequencySeries(); LALCheckMemoryLeaks(); return 0; }
/** * MAIN function: calls a number of unit-tests */ int main( void ) { INT4 ret; ret = test_XLALComputeDopplerMetrics(); XLAL_CHECK ( ret == XLAL_SUCCESS, XLAL_EFUNC, "test_XLALComputeDopplerMetrics() failed with status = %d.\n", ret ); ret = test_XLALComputeOrbitalDerivatives(); XLAL_CHECK ( ret == XLAL_SUCCESS, XLAL_EFUNC, "test_XLALComputeOrbitalDerivatives() failed with status = %d.\n", ret ); /* check for memory leaks */ LALCheckMemoryLeaks(); /* all tests passed */ return XLAL_SUCCESS; } /* main() */
int main(void) { /* Test XLALPearsonHash() */ XLAL_CHECK_MAIN(test_XLALPearsonHash(sizeof(UINT2), 1024, 8) == XLAL_SUCCESS, XLAL_EFAILED); XLAL_CHECK_MAIN(test_XLALPearsonHash(sizeof(UINT4), 1024, 0) == XLAL_SUCCESS, XLAL_EFAILED); XLAL_CHECK_MAIN(test_XLALPearsonHash(sizeof(UINT8), 1024, 0) == XLAL_SUCCESS, XLAL_EFAILED); /* Test XLALCityHash() */ XLAL_CHECK_MAIN(test_XLALCityHash(5, 0) == XLAL_SUCCESS, XLAL_EFAILED); XLAL_CHECK_MAIN(test_XLALCityHash(7, 0) == XLAL_SUCCESS, XLAL_EFAILED); /* Check for memory leaks */ LALCheckMemoryLeaks(); return EXIT_SUCCESS; }
int main( int argc, char *argv[]) { /* sanity check for input arguments */ XLAL_CHECK ( argc == 1, XLAL_EINVAL, "The executable '%s' doesn't support any input arguments right now.\n", argv[0] ); printf ("Starting test...\n"); /* set up single- and multi-IFO F-stat input */ REAL4 TwoF = 7.0; UINT4 numDetectors = 2; REAL4Vector *TwoFX = NULL; XLAL_CHECK ( (TwoFX = XLALCreateREAL4Vector ( numDetectors )) != NULL, XLAL_EFUNC ); TwoFX->data[0] = 4.0; TwoFX->data[1] = 12.0; /* maximum allowed difference between recalculated and XLAL result */ REAL4 tolerance = 1e-06; /* compute and compare the results for one set of Fstar0, oLGX values */ REAL4 Fstar0 = -LAL_REAL4_MAX; /* prior from BSGL derivation, -Inf means pure line veto, +Inf means pure multi-Fstat */ REAL4 *oLGX = NULL; /* per-IFO prior odds ratio for line vs. Gaussian noise, NULL is interpreted as oLG[X]=1 for all X */ printf ("Computing BSGL for TwoF_multi=%f, TwoFX=(%f,%f), priors F*0=%f and oLGX=NULL...\n", TwoF, TwoFX->data[0], TwoFX->data[1], Fstar0 ); XLAL_CHECK ( XLALCompareBSGLComputations( TwoF, numDetectors, TwoFX, Fstar0, oLGX, tolerance ) == XLAL_SUCCESS, XLAL_EFUNC ); /* change the priors to catch more possible problems */ Fstar0 = 10.0; REAL4 oLGXarray[numDetectors]; oLGXarray[0] = 0.5; oLGXarray[1] = 0.8; oLGX = oLGXarray; printf ("Computing BSGL for TwoF_multi=%f, TwoFX=(%f,%f), priors F*0=%f and oLGX=(%f,%f)...\n", TwoF, TwoFX->data[0], TwoFX->data[1], Fstar0, oLGX[0], oLGX[1] ); XLAL_CHECK ( XLALCompareBSGLComputations( TwoF, numDetectors, TwoFX, Fstar0, oLGX, tolerance ) == XLAL_SUCCESS, XLAL_EFUNC ); /* free memory */ XLALDestroyREAL4Vector(TwoFX); LALCheckMemoryLeaks(); return XLAL_SUCCESS; } /* main */
int main(void) { LIGOTimeGPS tc = { 888888888, 222222222 }; REAL8 phic = 1.0; REAL8 deltaT = 1.0/16384.0; REAL8 m1 = 1.4*LAL_MSUN_SI; REAL8 m2 = 1.4*LAL_MSUN_SI; REAL8 r = 1e6*LAL_PC_SI; REAL8 i = 0.5*LAL_PI; REAL8 f_min = 100.0; REAL8 fRef = 0.; int O = -1; REAL8TimeSeries *hplus; REAL8TimeSeries *hcross; XLALSimInspiralTaylorT4PN(&hplus, &hcross, &tc, phic, deltaT, m1, m2, f_min, fRef, r, i, lambda1, lambda2, tideO, O); LALDPrintTimeSeries(hplus, "hp.dat"); LALDPrintTimeSeries(hcross, "hc.dat"); XLALDestroyREAL8TimeSeries(hplus); XLALDestroyREAL8TimeSeries(hcross); LALCheckMemoryLeaks(); return 0; }
int main(void) { int fail = 0; char *hosttype = getenv("hosttype"); /* DEC Alpha's FPU is not capable of computing some of these window * functions correctly. This is safe because in the cases where it * fails it raises SIGFPE and the program crashes. I can't be * bothered to code up the work-arounds needed to get the windows * working on that platform. */ if(!strcmp(hosttype ? hosttype : "", "alpha")) { fprintf(stderr, "Window functions not computable on DEC Alpha, tests skipped! Set environment variable \"hosttype\" to something other than \"alpha\" to force tests\n"); exit(77); } /* Numerical tests: assume that if the end-points, mid-points, and * sum-of-squares are all as expected, then the window functions * are correct */ if(test_end_and_midpoints()) fail = 1; if(test_sum_of_squares()) fail = 1; /* Test parameter safety */ if(test_parameter_safety()) fail = 1; /* Verbosity */ display(); LALCheckMemoryLeaks(); return fail; }
int main(int argc, char *argv[]) { LIGOTimeGPS epoch = {0, 0}; REAL8TimeSeries *hplus; REAL8TimeSeries *hcross; size_t j; XLALSetErrorHandler(XLALBacktraceErrorHandler); parseargs(argc, argv); XLALSimBlackHoleRingdown(&hplus, &hcross, &epoch, q, dt, M, a, e, r, i, l, m); fprintf(stdout, "# time (s)\th_plus \th_cross\n"); for (j = 0; j < hplus->data->length; ++j) fprintf(stdout, "%.9f\t%e\t%e\n", j*dt, hplus->data->data[j], hcross->data->data[j]); XLALDestroyREAL8TimeSeries(hcross); XLALDestroyREAL8TimeSeries(hplus); LALCheckMemoryLeaks(); return 0; }
/* stress test the realloc routine */ static int stressTestRealloc( void ) { const size_t nmax = 256; int keep = lalDebugLevel; v = NULL; XLALClobberDebugLevel(lalDebugLevel | LALMEMDBGBIT | LALMEMPADBIT | LALMEMTRKBIT); XLALClobberDebugLevel(lalDebugLevel & ~LALMEMINFOBIT); /* ascending */ for ( n = 1; n <= nmax; ++n ) { size_t *u; trial( v = LALRealloc( v, n * sizeof( *v ) ), 0, "" ); trial( u = v[n - 1] = LALRealloc( NULL, n * sizeof( **v ) ), 0, "" ); for ( i = 0; i < n; ++i ) u[i] = n - 1; for ( i = 0; i < n; ++i ) { trial( u = v[i] = LALRealloc( v[i], n * sizeof( *u ) ), 0, "" ); for ( j = 0; j < n - 1; ++j ) if ( u[j] != n - 1 ) die( wrong contents ); for ( j = 0; j < n; ++j ) u[j] = n; } } for ( n = 0; n < nmax; ++n ) { trial( v[n] = LALRealloc( v[n], 0 ), 0, "" ); } trial( v = LALRealloc( v, 0 ), 0, "" ); trial( LALCheckMemoryLeaks(), 0, "" ); XLALClobberDebugLevel(keep); return 0; }
/* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv------------------------------------ */ int main(int argc, char *argv[]) { static LALStatus status; static HOUGHMapTotal ht; static HoughStats stats; static UINT8Vector hist; const CHAR *fname = NULL; /* The output filename */ INT4 arg; /* Argument counter */ INT4 i; FILE *fp=NULL; /* Output file */ fname = FILEOUT; /********************************************************/ /* Parse argument list. i stores the current position. */ /********************************************************/ arg = 1; while ( arg < argc ) { /* Parse debuglevel option. */ if ( !strcmp( argv[arg], "-d" ) ) { if ( argc > arg + 1 ) { arg++; } else { ERROR( TESTSTATISTICSC_EARG, TESTSTATISTICSC_MSGEARG, 0 ); XLALPrintError( USAGE, *argv ); return TESTSTATISTICSC_EARG; } } /* Parse output file option. */ else if ( !strcmp( argv[arg], "-o" ) ) { if ( argc > arg + 1 ) { arg++; fname = argv[arg++]; } else { ERROR( TESTSTATISTICSC_EARG, TESTSTATISTICSC_MSGEARG, 0 ); XLALPrintError( USAGE, *argv ); return TESTSTATISTICSC_EARG; } } /* Unrecognized option. */ else { ERROR( TESTSTATISTICSC_EARG, TESTSTATISTICSC_MSGEARG, 0 ); XLALPrintError( USAGE, *argv ); return TESTSTATISTICSC_EARG; } } /* End of argument parsing loop. */ /******************************************************************/ /* ------------------------------------------------------- */ /* create a hough map */ ht.mObsCoh = 1000; ht.xSide = 100; ht.ySide = 100; /* allocate memory for hough map */ ht.map = (HoughTT *)LALMalloc(ht.xSide * ht.ySide * sizeof(HoughTT)); /* make up a hough map */ for (i = 0; i < floor(ht.xSide * ht.ySide / 2.0); i++) ht.map[i] = 500; for (i = ceil(ht.xSide * ht.ySide / 2.0); i < ht.xSide * ht.ySide; i++) ht.map[i] = 900; SUB( LALHoughStatistics ( &status, &stats, &ht), &status ); printf(" Maximum number count: %d\n", (int)stats.maxCount); printf(" Location: %d %d\n", stats.maxIndex[0], stats.maxIndex[1]); printf(" Minimum number count: %d\n", (int)stats.minCount); printf(" Location: %d %d\n", stats.minIndex[0], stats.minIndex[1]); printf(" Average number count: %f\n", stats.avgCount); printf(" Standard deviation of number count: %f\n", stats.stdDev); /* allocate memory for histogram */ hist.length = ht.mObsCoh +1; hist.data= NULL; hist.data = (UINT8 *)LALMalloc((hist.length)*sizeof(UINT8)); SUB( LALHoughHistogram ( &status, &hist, &ht), &status); /* write histogram to a file */ fp = fopen(fname, "w"); if ( !fp ) { ERROR( TESTSTATISTICSC_EFILE, TESTSTATISTICSC_MSGEFILE, 0 ); return TESTSTATISTICSC_EFILE; } for (i=0; i < (INT4)hist.length; i++) { fprintf(fp,"%d %" LAL_UINT8_FORMAT "\n", i, hist.data[i]); } fclose(fp); LALFree(ht.map); LALFree(hist.data); LALCheckMemoryLeaks(); INFO(TESTSTATISTICSC_MSGENORM); return TESTSTATISTICSC_ENORM; }
/* ----- function definitions ---------- */ int main ( int argc, char *argv[] ) { LALStatus status; UserInput_t uvar_s; UserInput_t *uvar = &uvar_s; INIT_MEM ( status ); INIT_MEM ( uvar_s ); struct tms buf; uvar->randSeed = times(&buf); // ---------- register all our user-variable ---------- XLALregBOOLUserStruct ( help, 'h', UVAR_HELP , "Print this help/usage message"); XLALregINTUserStruct ( randSeed, 's', UVAR_OPTIONAL, "Specify random-number seed for reproducible noise."); /* read cmdline & cfgfile */ XLAL_CHECK ( XLALUserVarReadAllInput ( argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC ); if ( uvar->help ) { /* if help was requested, we're done */ exit (0); } srand ( uvar->randSeed ); REAL8 startTimeREAL8 = 714180733; REAL8 duration = 180000; /* 50 hours */ REAL8 Tsft = 1800; /* assume 30min SFTs */ char earthEphem[] = TEST_DATA_DIR "earth00-19-DE200.dat.gz"; char sunEphem[] = TEST_DATA_DIR "sun00-19-DE200.dat.gz"; //REAL8 tolerance = 2e-10; /* same algorithm, should be basically identical results */ LIGOTimeGPS startTime, refTime; XLALGPSSetREAL8 ( &startTime, startTimeREAL8 ); refTime = startTime; // pick skyposition at random ----- */ SkyPosition skypos; skypos.longitude = LAL_TWOPI * (1.0 * rand() / ( RAND_MAX + 1.0 ) ); // alpha uniform in [0, 2pi) skypos.latitude = LAL_PI_2 - acos ( 1 - 2.0 * rand()/RAND_MAX ); // sin(delta) uniform in [-1,1] skypos.system = COORDINATESYSTEM_EQUATORIAL; // pick binary orbital parameters: // somewhat inspired by Sco-X1 parameters from S2-paper (PRD76, 082001 (2007), gr-qc/0605028) // but with a more extreme eccentricity, and random argp REAL8 argp = LAL_TWOPI * (1.0 * rand() / ( RAND_MAX + 1.0 ) ); // uniform in [0, 2pi) BinaryOrbitParams orbit; XLALGPSSetREAL8 ( &orbit.tp, 731163327 ); // time of observed periapsis passage (in SSB) orbit.argp = argp; // argument of periapsis (radians) orbit.asini = 1.44; // projected, normalized orbital semi-major axis (s) */ orbit.ecc = 1e-2; // relatively large value, for better testing orbit.period = 68023; // period (s) : about ~18.9h // ----- step 0: prepare test-case input for calling the BinarySSB-functions // setup detectors const char *sites[3] = { "H1", "L1", "V1" }; UINT4 numDetectors = sizeof( sites ) / sizeof ( sites[0] ); MultiLALDetector multiIFO; multiIFO.length = numDetectors; for ( UINT4 X = 0; X < numDetectors; X ++ ) { LALDetector *det = XLALGetSiteInfo ( sites[X] ); XLAL_CHECK ( det != NULL, XLAL_EFUNC, "XLALGetSiteInfo ('%s') failed for detector X=%d\n", sites[X], X ); multiIFO.sites[X] = (*det); // struct copy XLALFree ( det ); } // load ephemeris EphemerisData *edat = XLALInitBarycenter ( earthEphem, sunEphem ); XLAL_CHECK ( edat != NULL, XLAL_EFUNC, "XLALInitBarycenter('%s','%s') failed\n", earthEphem, sunEphem ); // setup multi-timeseries MultiLIGOTimeGPSVector *multiTS; XLAL_CHECK ( (multiTS = XLALCalloc ( 1, sizeof(*multiTS))) != NULL, XLAL_ENOMEM ); XLAL_CHECK ( (multiTS->data = XLALCalloc (numDetectors, sizeof(*multiTS->data))) != NULL, XLAL_ENOMEM ); multiTS->length = numDetectors; for ( UINT4 X = 0; X < numDetectors; X ++ ) { multiTS->data[X] = XLALMakeTimestamps ( startTime, duration, Tsft, 0 ); XLAL_CHECK ( multiTS->data[X] != NULL, XLAL_EFUNC, "XLALMakeTimestamps() failed.\n"); } /* for X < numIFOs */ // generate detector-states MultiDetectorStateSeries *multiDetStates = XLALGetMultiDetectorStates ( multiTS, &multiIFO, edat, 0 ); XLAL_CHECK ( multiDetStates != NULL, XLAL_EFUNC, "XLALGetMultiDetectorStates() failed.\n"); // generate isolated-NS SSB times MultiSSBtimes *multiSSBIn = XLALGetMultiSSBtimes ( multiDetStates, skypos, refTime, SSBPREC_RELATIVISTICOPT ); XLAL_CHECK ( multiSSBIn != NULL, XLAL_EFUNC, "XLALGetMultiSSBtimes() failed.\n"); // ----- step 1: compute reference-result using old LALGetMultiBinarytimes() MultiSSBtimes *multiBinary_ref = NULL; LALGetMultiBinarytimes (&status, &(multiBinary_ref), multiSSBIn, multiDetStates, &orbit, refTime ); XLAL_CHECK ( status.statusCode == 0, XLAL_EFAILED, "LALGetMultiBinarytimes() failed with status = %d : '%s'\n", status.statusCode, status.statusDescription ); // ----- step 2: compute test-result using new XLALAddMultiBinaryTimes() MultiSSBtimes *multiBinary_test = NULL; PulsarDopplerParams doppler; memset(&doppler, 0, sizeof(doppler)); doppler.tp = orbit.tp; doppler.argp = orbit.argp; doppler.asini = orbit.asini; doppler.ecc = orbit.ecc; doppler.period = orbit.period; XLAL_CHECK ( XLALAddMultiBinaryTimes ( &multiBinary_test, multiSSBIn, &doppler ) == XLAL_SUCCESS, XLAL_EFUNC ); // ----- step 3: compare results REAL8 err_DeltaT, err_Tdot; REAL8 tolerance = 1e-10; int ret = XLALCompareMultiSSBtimes ( &err_DeltaT, &err_Tdot, multiBinary_ref, multiBinary_test ); XLAL_CHECK ( ret == XLAL_SUCCESS, XLAL_EFUNC, "XLALCompareMultiSSBtimes() failed.\n"); XLALPrintWarning ( "INFO: err(DeltaT) = %g, err(Tdot) = %g\n", err_DeltaT, err_Tdot ); XLAL_CHECK ( err_DeltaT < tolerance, XLAL_ETOL, "error(DeltaT) = %g exceeds tolerance of %g\n", err_DeltaT, tolerance ); XLAL_CHECK ( err_Tdot < tolerance, XLAL_ETOL, "error(Tdot) = %g exceeds tolerance of %g\n", err_Tdot, tolerance ); // ---- step 4: clean-up memory XLALDestroyUserVars(); XLALDestroyEphemerisData ( edat ); XLALDestroyMultiSSBtimes ( multiBinary_test ); XLALDestroyMultiSSBtimes ( multiBinary_ref ); XLALDestroyMultiSSBtimes ( multiSSBIn ); XLALDestroyMultiTimestamps ( multiTS ); XLALDestroyMultiDetectorStateSeries ( multiDetStates ); // check for memory-leaks LALCheckMemoryLeaks(); return XLAL_SUCCESS; } // main()
int main( int argc, char *argv[] ) { LALStatus status = blank_status; #if 0 const INT4 S2StartTime = 729273613; /* Feb 14 2003 16:00:00 UTC */ const INT4 S2StopTime = 734367613; /* Apr 14 2003 15:00:00 UTC */ #endif /* command line options */ LIGOTimeGPS gpsStartTime = {S2StartTime, 0}; LIGOTimeGPS gpsEndTime = {S2StopTime, 0}; REAL8 meanTimeStep = 2630 / LAL_PI; REAL8 timeInterval = 0; UINT4 randSeed = 1; CHAR *userTag = NULL; REAL4 minMass = 3.0; /* minimum component mass */ REAL4 maxMass = 20.0; /* maximum component mass */ REAL4 sumMaxMass = 0.0; /* maximum total mass sum */ UINT4 sumMaxMassUse=0; /* flag indicating to use the sumMaxMass */ REAL4 dmin = 1.0; /* minimum distance from earth (kpc) */ REAL4 dmax = 20000.0 ; /* maximum distance from earth (kpc) */ REAL4 fLower = 0; /* default value for th lower cut off frequency */ /* REAL4 Rcore = 0.0; */ UINT4 ddistr = 0, mdistr=0; /* program variables */ RandomParams *randParams = NULL; REAL4 u, exponent, d2; REAL4 deltaM, mtotal; /* waveform */ CHAR waveform[LIGOMETA_WAVEFORM_MAX]; #if 0 int i, stat; double d, cosphi, sinphi; #endif /* GalacticInspiralParamStruc galacticPar; */ /* xml output data */ CHAR fname[256]; MetadataTable proctable; MetadataTable procparams; MetadataTable injections; ProcessParamsTable *this_proc_param; SimInspiralTable *this_inj = NULL; LIGOLwXMLStream xmlfp; UINT4 outCompress = 0; /* getopt arguments */ struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"verbose", no_argument, &vrbflg, 1 }, {"write-compress", no_argument, &outCompress, 1 }, {"version", no_argument, 0, 'V'}, {"f-lower", required_argument, 0, 'f'}, {"gps-start-time", required_argument, 0, 'a'}, {"gps-end-time", required_argument, 0, 'b'}, {"time-step", required_argument, 0, 't'}, {"time-interval", required_argument, 0, 'i'}, {"seed", required_argument, 0, 's'}, {"min-mass", required_argument, 0, 'A'}, {"max-mass", required_argument, 0, 'B'}, {"max-total-mass", required_argument, 0, 'x'}, {"min-distance", required_argument, 0, 'p'}, {"max-distance", required_argument, 0, 'r'}, {"d-distr", required_argument, 0, 'd'}, {"m-distr", required_argument, 0, 'm'}, {"waveform", required_argument, 0, 'w'}, {"user-tag", required_argument, 0, 'Z'}, {"userTag", required_argument, 0, 'Z'}, {0, 0, 0, 0} }; int c; /* set up inital debugging values */ lal_errhandler = LAL_ERR_EXIT; /* create the process and process params tables */ proctable.processTable = (ProcessTable *) calloc( 1, sizeof(ProcessTable) ); XLALGPSTimeNow(&(proctable.processTable->start_time)); if (strcmp(CVS_REVISION,"$Revi" "sion$")) { XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, CVS_REVISION, CVS_SOURCE, CVS_DATE, 0); } else { XLALPopulateProcessTable(proctable.processTable, PROGRAM_NAME, lalappsGitCommitID, lalappsGitGitStatus, lalappsGitCommitDate, 0); } snprintf( proctable.processTable->comment, LIGOMETA_COMMENT_MAX, " " ); this_proc_param = procparams.processParamsTable = (ProcessParamsTable *) calloc( 1, sizeof(ProcessParamsTable) ); /* clear the waveform field */ memset( waveform, 0, LIGOMETA_WAVEFORM_MAX * sizeof(CHAR) ); /* * * parse command line arguments * */ while ( 1 ) { /* getopt_long stores long option here */ int option_index = 0; long int gpsinput; size_t optarg_len; c = getopt_long_only( argc, argv, "a:A:b:B:d:f:hi:m:p:q:r:s:t:vZ:w:", long_options, &option_index ); /* detect the end of the options */ if ( c == - 1 ) { break; } switch ( c ) { case 0: /* if this option set a flag, do nothing else now */ if ( long_options[option_index].flag != 0 ) { break; } else { fprintf( stderr, "error parsing option %s with argument %s\n", long_options[option_index].name, optarg ); exit( 1 ); } break; case 'a': gpsinput = atol( optarg ); if ( gpsinput < 441417609 ) { fprintf( stderr, "invalid argument to --%s:\n" "GPS start time is prior to " "Jan 01, 1994 00:00:00 UTC:\n" "(%ld specified)\n", long_options[option_index].name, gpsinput ); exit( 1 ); } gpsStartTime.gpsSeconds = gpsinput; this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "int", "%ld", gpsinput ); break; case 'b': gpsinput = atol( optarg ); if ( gpsinput < 441417609 ) { fprintf( stderr, "invalid argument to --%s:\n" "GPS start time is prior to " "Jan 01, 1994 00:00:00 UTC:\n" "(%ld specified)\n", long_options[option_index].name, gpsinput ); exit( 1 ); } gpsEndTime.gpsSeconds = gpsinput; this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "int", "%ld", gpsinput ); break; case 'f': fLower = atof( optarg ); this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "float", "%f", fLower ); break; case 's': randSeed = atoi( optarg ); this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "int", "%d", randSeed ); break; case 't': meanTimeStep = (REAL8) atof( optarg ); if ( meanTimeStep <= 0 ) { fprintf( stderr, "invalid argument to --%s:\n" "time step must be > 0: (%e seconds specified)\n", long_options[option_index].name, meanTimeStep ); exit( 1 ); } this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "float", "%e", meanTimeStep ); break; case 'i': timeInterval = atof( optarg ); if ( timeInterval < 0 ) { fprintf( stderr, "invalid argument to --%s:\n" "time interval must be >= 0: (%e seconds specified)\n", long_options[option_index].name, meanTimeStep ); exit( 1 ); } this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "float", "%e", timeInterval ); break; case 'A': /* minimum component mass */ minMass = (REAL4) atof( optarg ); if ( minMass <= 0 ) { fprintf( stderr, "invalid argument to --%s:\n" "miniumum component mass must be > 0: " "(%f solar masses specified)\n", long_options[option_index].name, minMass ); exit( 1 ); } this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "float", "%e", minMass ); break; case 'B': /* maximum component mass */ maxMass = (REAL4) atof( optarg ); if ( maxMass <= 0 ) { fprintf( stderr, "invalid argument to --%s:\n" "maxiumum component mass must be > 0: " "(%f solar masses specified)\n", long_options[option_index].name, maxMass ); exit( 1 ); } this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "float", "%e", maxMass ); break; case 'x': /* maximum sum of components */ sumMaxMass = (REAL4) atof( optarg ); if ( sumMaxMass <= 0 ) { fprintf( stderr, "invalid argument to --%s:\n" "sum of two component masses must be > 0: " "(%f solar masses specified)\n", long_options[option_index].name, sumMaxMass ); exit( 1 ); } sumMaxMassUse=1; this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "float", "%e", sumMaxMass ); break; case 'p': /* minimum distance from earth */ dmin = (REAL4) atof( optarg ); if ( dmin <= 0 ) { fprintf( stderr, "invalid argument to --%s:\n" "minimum distance must be > 0: " "(%f kpc specified)\n", long_options[option_index].name, dmin ); exit( 1 ); } this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "float", "%e", dmin ); break; case 'r': /* max distance from earth */ dmax = (REAL4) atof( optarg ); if ( dmax <= 0 ) { fprintf( stderr, "invalid argument to --%s:\n" "maximum distance must be greater than 0: " "(%f kpc specified)\n", long_options[option_index].name, dmax ); exit( 1 ); } this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "float", "%e", dmax ); break; case 'd': ddistr = (UINT4) atoi( optarg ); if ( ddistr != 0 && ddistr != 1 && ddistr != 2) { fprintf( stderr, "invalid argument to --%s:\n" "DDISTR must be either 0 or 1 or 2\n", long_options[option_index].name); exit(1); } this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "int", "%d", ddistr ); break; case 'm': mdistr = (UINT4) atoi( optarg ); if ( mdistr != 0 && mdistr != 1 ) { fprintf( stderr, "invalid argument to --%s:\n" "MDISTR must be either 0 or 1\n", long_options[option_index].name); exit(1); } this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "int", "%d", mdistr ); break; case 'Z': /* create storage for the usertag */ optarg_len = strlen( optarg ) + 1; userTag = (CHAR *) calloc( optarg_len, sizeof(CHAR) ); memcpy( userTag, optarg, optarg_len ); this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "string", "%s", optarg ); break; case 'w': snprintf( waveform, LIGOMETA_WAVEFORM_MAX, "%s", optarg); this_proc_param = this_proc_param->next = next_process_param( long_options[option_index].name, "string", "%s", optarg); break; case 'V': /* print version information and exit */ fprintf( stdout, "Binary Black Hole INJection generation routine\n" "Duncan A Brown and Eirini Messaritaki\n" "CVS Version: " CVS_ID_STRING "\n" "CVS Tag: " CVS_NAME_STRING "\n" ); fprintf( stdout, lalappsGitID ); exit( 0 ); break; case 'h': case '?': fprintf( stderr, USAGE ); exit( 0 ); break; default: fprintf( stderr, "unknown error while parsing options\n" ); fprintf( stderr, USAGE ); exit( 1 ); } } if ( optind < argc ) { fprintf( stderr, "extraneous command line arguments:\n" ); while ( optind < argc ) { fprintf ( stderr, "%s\n", argv[optind++] ); } exit( 1 ); } if ( !*waveform ) { /* use EOBtwoPN as the default waveform */ snprintf( waveform, LIGOMETA_WAVEFORM_MAX, "EOBtwoPN"); } if ( !fLower ) { fprintf( stderr, "--f-lower must be specified and non-zero\n" ); exit( 1 ); } /* * * initialization * */ /* initialize the random number generator */ LAL_CALL( LALCreateRandomParams( &status, &randParams, randSeed ), &status ); /* mass range, per component */ deltaM = maxMass - minMass; /* null out the head of the linked list */ injections.simInspiralTable = NULL; /* create the output file name */ if ( userTag && outCompress ) { snprintf( fname, sizeof(fname), "HL-INJECTIONS_%d_%s-%d-%d.xml.gz", randSeed, userTag, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } else if ( userTag && !outCompress ) { snprintf( fname, sizeof(fname), "HL-INJECTIONS_%d_%s-%d-%d.xml", randSeed, userTag, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } else if ( !userTag && outCompress ) { snprintf( fname, sizeof(fname), "HL-INJECTIONS_%d-%d-%d.xml.gz", randSeed, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } else { snprintf( fname, sizeof(fname), "HL-INJECTIONS_%d-%d-%d.xml", randSeed, gpsStartTime.gpsSeconds, gpsEndTime.gpsSeconds - gpsStartTime.gpsSeconds ); } /* * * loop over duration of desired output times * */ while ( XLALGPSCmp( &gpsStartTime, &gpsEndTime ) < 0 ) { /* rho, z and lGal are the galactocentric galactic axial coordinates */ /* r and phi are the geocentric galactic spherical coordinates */ #if 0 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); galacticPar.lGal = LAL_TWOPI * u; galacticPar.z = r * sinphi ; galacticPar.rho = 0.0 - Rcore * cos(galacticPar.lGal) + sqrt( r * r - galacticPar.z * galacticPar.z - Rcore * Rcore * sin(galacticPar.lGal) * sin(galacticPar.lGal) ); #endif #if 0 if ( vrbflg ) fprintf( stdout, "%e %e %e %e %e\n", galacticPar.m1, galacticPar.m2, galacticPar.rho * cos( galacticPar.lGal ), galacticPar.rho * sin( galacticPar.lGal ), galacticPar.z ); #endif /* create the sim_inspiral table */ if ( injections.simInspiralTable ) { this_inj = this_inj->next = (SimInspiralTable *) LALCalloc( 1, sizeof(SimInspiralTable) ); } else { injections.simInspiralTable = this_inj = (SimInspiralTable *) LALCalloc( 1, sizeof(SimInspiralTable) ); } /* set the geocentric end time of the injection */ /* XXX CHECK XXX */ this_inj->geocent_end_time = gpsStartTime; if ( timeInterval ) { LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); XLALGPSAdd( &(this_inj->geocent_end_time), u * timeInterval ); } /* set gmst */ this_inj->end_time_gmst = fmod(XLALGreenwichMeanSiderealTime( &this_inj->geocent_end_time), LAL_TWOPI) * 24.0 / LAL_TWOPI; /* hours */ if( XLAL_IS_REAL8_FAIL_NAN(this_inj->end_time_gmst) ) { fprintf(stderr, "XLALGreenwichMeanSiderealTime() failed\n"); exit(1); } /* XXX END CHECK XXX */ /* populate the sim_inspiral table */ if (mdistr == 1) /* uniformly distributed mass1 and uniformly distributed mass2 */ { LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); this_inj->mass1 = minMass + u * deltaM; LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); this_inj->mass2 = minMass + u * deltaM; mtotal = this_inj->mass1 + this_inj->mass2 ; this_inj->eta = this_inj->mass1 * this_inj->mass2 / ( mtotal * mtotal ); this_inj->mchirp = (this_inj->mass1 + this_inj->mass2) * pow(this_inj->eta, 0.6); } else if (mdistr == 0) /*uniformly distributed total mass */ { LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status); mtotal = 2.0 * minMass + u * 2.0 *deltaM ; if (sumMaxMassUse==1) { while (mtotal > sumMaxMass) { LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status); mtotal = 2.0 * minMass + u * 2.0 *deltaM ; } } LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); this_inj->mass1 = minMass + u * deltaM; this_inj->mass2 = mtotal - this_inj->mass1; while (this_inj->mass1 >= mtotal || this_inj->mass2 >= maxMass || this_inj->mass2 <= minMass ) { LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); this_inj->mass1 = minMass + u * deltaM; this_inj->mass2 = mtotal - this_inj->mass1; } this_inj->eta = this_inj->mass1 * this_inj->mass2 / ( mtotal * mtotal ); this_inj->mchirp = (this_inj->mass1 + this_inj->mass2) * pow(this_inj->eta, 0.6); } /* spatial distribution */ #if 0 LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); sinphi = 2.0 * u - 1.0; cosphi = sqrt( 1.0 - sinphi*sinphi ); #endif if (ddistr == 0) /* uniform distribution in distance */ { REAL4 deltaD = dmax - dmin ; LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); this_inj->distance = dmin + deltaD * u ; } else if (ddistr == 1) /* uniform distribution in log(distance) */ { REAL4 lmin = log10(dmin); REAL4 lmax = log10(dmax); REAL4 deltaL = lmax - lmin; LAL_CALL( LALUniformDeviate(&status,&u,randParams),&status ); exponent = lmin + deltaL * u; this_inj->distance = pow(10.0,(REAL4) exponent); } else if (ddistr == 2) /* uniform volume distribution */ { REAL4 d2min = pow(dmin,3.0) ; REAL4 d2max = pow(dmax,3.0) ; REAL4 deltad2 = d2max - d2min ; LAL_CALL( LALUniformDeviate(&status,&u,randParams),&status ); d2 = d2min + u * deltad2 ; this_inj->distance = pow(d2,1.0/3.0); } this_inj->distance = this_inj->distance / 1000.0; /*convert to Mpc */ /* compute random longitude and latitude */ LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); this_inj->latitude = asin( 2.0 * u - 1.0 ) ; LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); this_inj->longitude = LAL_TWOPI * u ; #if 0 LAL_CALL( LALGalacticInspiralParamsToSimInspiralTable( &status, this_inj, &galacticPar, randParams ), &status ); if (vrbflg) { fprintf( stdout, "%e\n", sqrt(galacticPar.z*galacticPar.z+galacticPar.rho*galacticPar.rho + Rcore*Rcore + 2.0*Rcore*galacticPar.rho*cos(galacticPar.lGal))- this_inj->distance*1000.0); } #endif /* set the source and waveform fields */ snprintf( this_inj->source, LIGOMETA_SOURCE_MAX, "???" ); memcpy( this_inj->waveform, waveform, LIGOMETA_WAVEFORM_MAX * sizeof(CHAR)); /* XXX CHECK XXX */ /* compute random inclination, polarization and coalescence phase */ LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); this_inj->inclination = acos( 2.0 * u - 1.0 ); LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); this_inj->polarization = LAL_TWOPI * u ; LAL_CALL( LALUniformDeviate( &status, &u, randParams ), &status ); this_inj->coa_phase = LAL_TWOPI * u ; /* populate the site specific information */ LAL_CALL(LALPopulateSimInspiralSiteInfo( &status, this_inj ), &status); /* increment the injection time */ XLALGPSAdd( &gpsStartTime, meanTimeStep ); /* finally populate the flower */ if (fLower > 0) { this_inj->f_lower = fLower; } else { this_inj->f_lower = 0; } /* XXX END CHECK XXX */ } /* end loop over injection times */ /* destroy random parameters */ LAL_CALL( LALDestroyRandomParams( &status, &randParams ), &status ); /* * * write output to LIGO_LW XML file * */ /* open the xml file */ memset( &xmlfp, 0, sizeof(LIGOLwXMLStream) ); LAL_CALL( LALOpenLIGOLwXMLFile( &status, &xmlfp, fname ), &status ); /* write the process table */ snprintf( proctable.processTable->ifos, LIGOMETA_IFOS_MAX, "H1H2L1" ); XLALGPSTimeNow(&(proctable.processTable->end_time)); LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, proctable, process_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlfp ), &status ); free( proctable.processTable ); /* free the unused process param entry */ this_proc_param = procparams.processParamsTable; procparams.processParamsTable = procparams.processParamsTable->next; free( this_proc_param ); /* write the process params table */ if ( procparams.processParamsTable ) { LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, process_params_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, procparams, process_params_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlfp ), &status ); while( procparams.processParamsTable ) { this_proc_param = procparams.processParamsTable; procparams.processParamsTable = this_proc_param->next; free( this_proc_param ); } } /* write the sim_inspiral table */ if ( injections.simInspiralTable ) { LAL_CALL( LALBeginLIGOLwXMLTable( &status, &xmlfp, sim_inspiral_table ), &status ); LAL_CALL( LALWriteLIGOLwXMLTable( &status, &xmlfp, injections, sim_inspiral_table ), &status ); LAL_CALL( LALEndLIGOLwXMLTable ( &status, &xmlfp ), &status ); } while ( injections.simInspiralTable ) { this_inj = injections.simInspiralTable; injections.simInspiralTable = injections.simInspiralTable->next; LALFree( this_inj ); } /* close the injection file */ LAL_CALL( LALCloseLIGOLwXMLFile ( &status, &xmlfp ), &status ); /* check for memory leaks and exit */ LALCheckMemoryLeaks(); return 0; }