diff --git a/example/model.c b/example/model.c index d9502ad..30d465b 100644 --- a/example/model.c +++ b/example/model.c @@ -27,6 +27,7 @@ input(inputPars *par, image *img){ par->antialias = 4; par->sampling = 2; // log distr. for radius, directions distr. uniformly on a sphere. par->nSolveIters = 14; + par->resetRNG = 0; par->outputfile = "populations.pop"; par->binoutputfile = "restart.pop"; diff --git a/src/aux.c b/src/aux.c index eff8e9c..848d626 100644 --- a/src/aux.c +++ b/src/aux.c @@ -50,6 +50,7 @@ parseInput(inputPars inpar, configInfo *par, image **img, molData **m){ par->gridInFile = inpar.gridInFile; par->nSolveIters = inpar.nSolveIters; par->traceRayAlgorithm = inpar.traceRayAlgorithm; + par->resetRNG = inpar.resetRNG; par->gridOutFiles = malloc(sizeof(char *)*NUM_GRID_STAGES); for(i=0;inThreads]; nlinetot = 0; for(ispec=0;ispecnSpecies;ispec++) @@ -730,7 +732,8 @@ levelPops(molData *md, configInfo *par, struct grid *gp, int *popsdone, double * for (i=0;inThreads;i++){ threadRans[i] = gsl_rng_alloc(ranNumGenType); - gsl_rng_set(threadRans[i],(int)(gsl_rng_uniform(ran)*1e6)); + if (par->resetRNG==1) RNG_seeds[i] = (int)(gsl_rng_uniform(ran)*1e6); + else gsl_rng_set(threadRans[i],(int)(gsl_rng_uniform(ran)*1e6)); } calcGridCollRates(par,md,gp); @@ -777,12 +780,14 @@ While this is off however, other gsl_* etc calls will not exit if they encounter calcGridMolSpecNumDens(par,md,gp); + nVerticesDone=0; omp_set_dynamic(0); #pragma omp parallel private(id,ispec,threadI,nextMolWithBlend) num_threads(par->nThreads) { threadI = omp_get_thread_num(); + if (par->resetRNG==1) gsl_rng_set(threadRans[threadI],RNG_seeds[threadI]); /* Declare and allocate thread-private variables */ gridPointData *mp; // Could have declared them earlier double *halfFirstDs; // and included them in private() I guess. @@ -795,7 +800,7 @@ While this is off however, other gsl_* etc calls will not exit if they encounter } halfFirstDs = malloc(sizeof(*halfFirstDs)*max_phot); -#pragma omp for +#pragma omp for schedule(dynamic) for(id=0;idpIntensity;id++){ #pragma omp atomic ++nVerticesDone; diff --git a/src/inpars.h b/src/inpars.h index c93e348..790d709 100644 --- a/src/inpars.h +++ b/src/inpars.h @@ -25,6 +25,7 @@ typedef struct { char *gridInFile,**gridOutFiles; int nSolveIters; double (*gridDensMaxLoc)[DIM], *gridDensMaxValues; + _Bool resetRNG; } inputPars; #endif /* INPARS_H */ diff --git a/src/lime.h b/src/lime.h index ea6cd11..715c024 100644 --- a/src/lime.h +++ b/src/lime.h @@ -68,8 +68,7 @@ #define PI 3.14159265358979323846 /* pi */ #define SPI 1.77245385091 /* sqrt(pi) */ #define maxp 0.15 -#define OtoP 3. -#define NITERATIONS 16 +#define NITERATIONS 16 #define max_phot 10000 /* don't set this value higher unless you have enough memory. */ #define ininphot 9 #define minpop 1.e-6 @@ -94,9 +93,9 @@ #define ERF_TABLE_LIMIT 6.0 /* For x>6 erf(x)-1nThreads = NTHREADS; par->nSolveIters=17; par->traceRayAlgorithm=0; + par->resetRNG=0; par->gridOutFiles = malloc(sizeof(char *)*NUM_GRID_STAGES); for(i=0;i exp(30)){ + if(expTau[iline] > exp(30.)){ if(!silent) warning("Maser warning: optical depth has dropped below -30"); - expTau[iline]=exp(30); + expTau[iline]=exp(30.); } - mp[molI].phot[lineI+iphot*md[molI].nline]+=expTau[iline]*remnantSnu; iline++; } /* Next line this molecule. */