Skip to content

Commit

Permalink
Fixes #262
Browse files Browse the repository at this point in the history
Two changes have been made.
  - In run.c:parseInput(), a warning is generated if (!par->lte_only && par->nSolveIters<=par->nSolveItersDone && !allBitsSet(par->dataFlags, DS_mask_populations)). I.e. if the user has neither set pops values via a submitted grid file, nor requested any solver iterations.
  - In run.c:run(), gp[gi].mol[si].pops is malloc'd and filled with zeros whether par->doSolveRTE is set or not.

Upshot of the changes are that, where previous the code would seg fault if the user left par->nSolveIters at default, now it will proceed, with a warning message. Any output images will contain zero contribution from line emission.

An additional change: in run.c:run(), formerly the decision to set par->doSolveRTE depended on (par->nSolveIters>0 || par->lte_only), now it depends on (par->nSolveIters>par->nSolveItersDone || par->lte_only).

In master track, similar changes need to be made to run_new.c.
  • Loading branch information
imckstewart committed Apr 25, 2018
1 parent b148230 commit 5d49da8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
15 changes: 12 additions & 3 deletions src/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,14 @@ exit(1);

par->edgeVelsAvailable=0; /* default value, this is set within getEdgeVelocities(). */

if(!silent && par->nSolveIters>0 && par->lte_only)
warning("Requesting par.nSolveIters>0 will have no effect if LTE calculation is also requested.");
if(!silent){
if(par->lte_only){
if(par->nSolveIters>0)
warning("Requesting par->nSolveIters>0 will have no effect if LTE calculation is also requested.");
}else if(par->nSolveIters<=par->nSolveItersDone && !allBitsSet(par->dataFlags, DS_mask_populations)){
warning("No supplied pops values, and par->nSolveIters <= par->nSolveItersDone.");
}
}

/* Allocate moldata array.
*/
Expand Down Expand Up @@ -855,7 +861,8 @@ exit(1);
par.doMolCalcs = (par.nLineImages>0);

}else{
if(par.nSolveIters>0 || par.lte_only) /* To save the user having to set par.doSolveRTE as well as par.nSolveIters>0 or par.lte_only. */
// if(par.nSolveIters>0 || par.lte_only) /* To save the user having to set par.doSolveRTE as well as par.nSolveIters>0 or par.lte_only. */
if(par.nSolveIters>par.nSolveItersDone || par.lte_only) /* To save the user having to set par->doSolveRTE as well as par->nSolveIters>0 or par->lte_only. */
par.doSolveRTE = TRUE;

par.doMolCalcs = par.doSolveRTE || par.nLineImages>0;
Expand Down Expand Up @@ -913,8 +920,10 @@ exit(1);
for(gi=0;gi<par.ncell;gi++){
for(si=0;si<par.nSpecies;si++){
gp[gi].mol[si].specNumDens = malloc(sizeof(double)*md[si].nlev);
gp[gi].mol[si].pops = malloc(sizeof(double)*md[si].nlev);
for(ei=0;ei<md[si].nlev;ei++){
gp[gi].mol[si].specNumDens[ei] = 0.0;
gp[gi].mol[si].pops[ei] = 0.0;
}
}
}
Expand Down
19 changes: 14 additions & 5 deletions src/run_new.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,17 +804,24 @@ exit(1);

par->edgeVelsAvailable=0; /* default value, this is set within getEdgeVelocities(). */

if(!silent && par->nSolveIters>0 && par->lte_only)
warning("Requesting par->nSolveIters>0 will have no effect if LTE calculation is also requested.");
if(!silent){
if(par->lte_only){
if(par->nSolveIters>0)
warning("Requesting par->nSolveIters>0 will have no effect if LTE calculation is also requested.");
}else if(par->nSolveIters<=par->nSolveItersDone && !allBitsSet(par->dataFlags, DS_mask_populations)){
warning("No supplied pops values, and par->nSolveIters <= par->nSolveItersDone.");
}
}

// if(par->nSolveIters>0 || par->lte_only) /* To save the user having to set par->doSolveRTE as well as par->nSolveIters>0 or par->lte_only. */
if(par->nSolveIters>par->nSolveItersDone || par->lte_only) /* To save the user having to set par->doSolveRTE as well as par->nSolveIters>0 or par->lte_only. */
par->doSolveRTE = TRUE;

if(par->samplingAlgorithm==0)
defaultDensyPower = DENSITY_POWER;
else
defaultDensyPower = TREE_POWER;

if(par->nSolveIters>0 || par->lte_only) /* To save the user having to set par->doSolveRTE as well as par->nSolveIters>0 or par->lte_only. */
par->doSolveRTE = TRUE;

par->doMolCalcs = par->doSolveRTE || par->nLineImages>0;
if(par->doMolCalcs && par->moldatfile==NULL){
if(!silent) bail_out("You must point par->moldatfile to a data file.");
Expand Down Expand Up @@ -934,8 +941,10 @@ exit(1);
for(gi=0;gi<par.ncell;gi++){
for(si=0;si<par.nSpecies;si++){
gp[gi].mol[si].specNumDens = malloc(sizeof(double)*md[si].nlev);
gp[gi].mol[si].pops = malloc(sizeof(double)*md[si].nlev);
for(ei=0;ei<md[si].nlev;ei++){
gp[gi].mol[si].specNumDens[ei] = 0.0;
gp[gi].mol[si].pops[ei] = 0.0;
}
}
}
Expand Down

0 comments on commit 5d49da8

Please sign in to comment.