Changeset 2079 for branches/newmole/source
- Timestamp:
- 05/17/08 09:51:43 (8 months ago)
- Location:
- branches/newmole/source
- Files:
-
- 34 modified
-
atmdat_chianti.cpp (modified) (4 diffs)
-
atmdat_lamda.cpp (modified) (2 diffs)
-
cddrive.h (modified) (3 diffs)
-
cdspec.cpp (modified) (3 diffs)
-
cont_createmesh.cpp (modified) (1 diff)
-
cpu.cpp (modified) (5 diffs)
-
cpu.h (modified) (2 diffs)
-
date.h (modified) (1 diff)
-
dense_fabden.cpp (modified) (1 diff)
-
grains.cpp (modified) (1 diff)
-
grid.h (modified) (1 diff)
-
grid_xspec.cpp (modified) (8 diffs)
-
init_coreload.cpp (modified) (1 diff)
-
init_defaults_preparse.cpp (modified) (2 diffs)
-
ion_trim.cpp (modified) (2 diffs)
-
iso_collide.cpp (modified) (3 diffs)
-
iso_error.cpp (modified) (1 diff)
-
iso_level.cpp (modified) (1 diff)
-
iso_radiative_recomb.cpp (modified) (1 diff)
-
nemala2.cpp (modified) (3 diffs)
-
parse_caseb.cpp (modified) (2 diffs)
-
parse_commands.cpp (modified) (2 diffs)
-
parse_punch.cpp (modified) (3 diffs)
-
punch_do.cpp (modified) (1 diff)
-
punch_fits.cpp (modified) (4 diffs)
-
punch_line.cpp (modified) (1 diff)
-
radius_increment.cpp (modified) (1 diff)
-
rt_diffuse.cpp (modified) (1 diff)
-
rt_tau_init.cpp (modified) (2 diffs)
-
sanity_check.cpp (modified) (1 diff)
-
service.cpp (modified) (5 diffs)
-
stars.cpp (modified) (15 diffs)
-
version.h (modified) (2 diffs)
-
zero.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/newmole/source/atmdat_chianti.cpp
r1942 r2079 18 18 /* type is set to 0 for non chianti and 1 for chianti*/ 19 19 long int i,j,nMolLevs,intCollTran,intcollindex,ipLo,ipHi; 20 FILE *atmolLevDATA , *atmolTraDATA=NULL,*atmolEleColDATA=NULL ;20 FILE *atmolLevDATA , *atmolTraDATA=NULL,*atmolEleColDATA=NULL,*atmolProColDATA=NULL; 21 21 realnum fstatwt,fenergyK,fenergyWN,fWLAng,fenergy,feinsteina; 22 22 double fScalingParam,fEnergyDiff,fGF,*xs,*spl,*spl2; … … 40 40 long int *intNewIndex=NULL,*intOldIndex=NULL; 41 41 int interror; 42 bool lg EneLevOrder;42 bool lgProtonData=false,lgEneLevOrder; 43 43 44 44 /*This is to identify where the fields start */ … … 99 99 if( trace.lgTrace ) 100 100 fprintf( ioQQQ," moldat_readin opening %s:",chProColFilename); 101 /*We will set a flag here to indicate if the proton collision strengths are available */ 102 if( ( atmolProColDATA = fopen( chProColFilename , "r" ) ) != NULL ) 103 { 104 lgProtonData = true; 105 } 106 else 107 { 108 lgProtonData = false; 109 } 101 110 102 111 nMolLevs = 0; … … 146 155 for( intcollindex = 0; intcollindex<NUM_COLLIDERS; intcollindex++ ) 147 156 { 148 CollRatesArray[intNS][intcollindex] = (double**)MALLOC((nMolLevs)*sizeof(double*)); 157 CollRatesArray[intNS][intcollindex] = NULL; 158 } 159 /*Allocating space just for the electron*/ 160 CollRatesArray[intNS][0] = (double**)MALLOC((nMolLevs)*sizeof(double*)); 161 for( ipHi = 0; ipHi<nMolLevs; ipHi++ ) 162 { 163 CollRatesArray[intNS][0][ipHi] = (double*)MALLOC((unsigned long)(nMolLevs)*sizeof(double)); 164 for( ipLo = 0; ipLo<nMolLevs; ipLo++) 165 { 166 CollRatesArray[intNS][0][ipHi][ipLo] = 0.0; 167 } 168 } 169 /*Allocating space for the proton*/ 170 if(lgProtonData) 171 { 172 CollRatesArray[intNS][1] = (double**)MALLOC((nMolLevs)*sizeof(double*)); 149 173 for( ipHi = 0; ipHi<nMolLevs; ipHi++ ) 150 174 { 151 CollRatesArray[intNS][ intcollindex][ipHi] = (double*)MALLOC((unsigned long)(nMolLevs)*sizeof(double));175 CollRatesArray[intNS][1][ipHi] = (double*)MALLOC((unsigned long)(nMolLevs)*sizeof(double)); 152 176 for( ipLo = 0; ipLo<nMolLevs; ipLo++) 153 177 { 154 CollRatesArray[intNS][intcollindex][ipHi][ipLo] = 0.0; 155 } 156 } 157 } 158 178 CollRatesArray[intNS][1][ipHi][ipLo] = 0.0; 179 } 180 } 181 } 159 182 /*Rewind the energy levels files*/ 160 183 if( fseek( atmolLevDATA , 0 , SEEK_SET ) != 0 ) -
branches/newmole/source/atmdat_lamda.cpp
r1942 r2079 113 113 for( intcollindex = 0; intcollindex <NUM_COLLIDERS; intcollindex++ ) 114 114 { 115 CollRatesArray[intNS][intcollindex] = (double**)MALLOC((unsigned long)(ngMolLevs) * sizeof(double*)); 116 for( ipHi = 0; ipHi<ngMolLevs; ipHi++ ) 117 { 118 CollRatesArray[intNS][intcollindex][ipHi] = (double*)MALLOC((unsigned long)(ngMolLevs) * sizeof(double)); 119 for( ipLo = 0; ipLo<ngMolLevs; ipLo++ ) 120 { 121 CollRatesArray[intNS][intcollindex][ipHi][ipLo] = 0.0; 122 } 123 } 124 } 115 CollRatesArray[intNS][intcollindex] = NULL; 116 } 117 125 118 126 119 if(read_whole_line( chLine , (int)sizeof(chLine) , atmolLevDATA ) == NULL ) … … 342 335 TotalInsanity(); 343 336 } 337 /*This is where we allocate memory if the collider exists*/ 338 /*Needed to take care of the he collisions*/ 339 CollRatesArray[intNS][intCollIndex] = (double**)MALLOC((unsigned long)(ngMolLevs) * sizeof(double*)); 340 for( ipHi = 0; ipHi<ngMolLevs; ipHi++ ) 341 { 342 CollRatesArray[intNS][intCollIndex][ipHi] = (double*)MALLOC((unsigned long)(ngMolLevs) * sizeof(double)); 343 for( ipLo = 0; ipLo<ngMolLevs; ipLo++ ) 344 { 345 CollRatesArray[intNS][intCollIndex][ipHi][ipLo] = 0.0; 346 } 347 } 344 348 if(read_whole_line( chLine , (int)sizeof(chLine) , atmolLevDATA ) == NULL ) 345 349 { -
branches/newmole/source/cddrive.h
r1918 r2079 536 536 3 the reflected continuum, same units 537 537 538 4 diffuse continuousemission outward direction539 5 diffuse continuousemission, reflected538 4 diffuse emission outward direction 539 5 diffuse emission, reflected 540 540 541 541 6 collisional+recombination lines, outward … … 547 547 548 548 \param nEnergy the number of cells + 1 549 \param ipLoEnergy 550 \param ipHiEnergy 549 551 \param ReturnedSpectrum[] the returned spectrum, same size is two energy spectra (see option), returns nEnergy -1 pts 550 552 */ … … 552 554 int Option , 553 555 long int nEnergy , 556 long int ipLoEnergy, 557 long int ipHiEnergy, 554 558 realnum ReturnedSpectrum[] ); 555 559 -
branches/newmole/source/cdspec.cpp
r1780 r2079 318 318 * 3 the reflected continuum, same units 319 319 * 320 * 4 diffuse continuous emission outward direction321 * 5 diffuse continuous emission, reflected322 * 323 * 6 collisional+recombination lines, outward324 * 7 collisional+recombination lines, reflected320 * 4 diffuse emission, lines + continuum, outward 321 * 5 diffuse emission, lines + continuum, reflected 322 * 323 * 6 diffuse continuous emission outward direction 324 * 7 diffuse continuous emission, reflected 325 325 * 326 326 * 8 total transmitted, lines and continuum … … 333 333 int nOption , 334 334 335 /* the number of cells + 1*/ 336 long int nEnergy , 335 /* the number of cells */ 336 long int nEnergy, 337 338 /* the index of the lowest and highest energy bounds to use. */ 339 long ipLoEnergy, 340 long ipHiEnergy, 337 341 338 342 /* the returned spectrum, same size is two energy spectra (see option), returns nEnergy -1 pts */ … … 340 344 341 345 { 342 /* this pointer will bet set to one of the cloudy continuum arrays */ 343 realnum *cont , 344 refac; 345 long int ncell , j; 346 347 /* flag saying whether we will need to free cont at the end */ 348 bool lgFREE; 346 realnum refac; 349 347 350 348 DEBUG_ENTRY( "cdSPEC2()" ); 351 349 350 ASSERT( ipLoEnergy >= 0 ); 351 ASSERT( ipLoEnergy < ipHiEnergy ); 352 ASSERT( ipHiEnergy < rfield.nupper ); 353 ASSERT( nEnergy == (ipHiEnergy-ipLoEnergy+1) ); 354 ASSERT( nEnergy >= 2 ); 355 352 356 ASSERT( nOption <= NUM_OUTPUT_TYPES ); 353 357 354 if( nOption == 1 ) 355 { 356 /* this is the incident continuum, col 2 of punch continuum command */ 357 cont = rfield.flux_total_incident; 358 lgFREE = false; 359 } 360 else if( nOption == 2 ) 361 { 362 /* the attenuated transmitted continuum, no diffuse emission, 363 * col 3 of punch continuum command */ 364 cont = rfield.flux; 365 lgFREE = false; 366 } 367 else if( nOption == 3 ) 368 { 369 /* reflected incident continuum, col 6 of punch continuum command */ 370 lgFREE = false; 371 cont = rfield.ConRefIncid; 372 } 373 else if( nOption == 4 ) 374 { 375 /* diffuse continuous emission outward direction */ 376 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 377 /* need to free the vector once done */ 378 lgFREE = true; 379 refac = (realnum)radius.r1r0sq*geometry.covgeo; 380 for( j=0; j<rfield.nflux; ++j) 381 { 382 cont[j] = rfield.ConEmitOut[j]*refac; 383 } 384 } 385 else if( nOption == 5 ) 386 { 387 /* reflected diffuse continuous emission */ 388 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 389 /* need to free the vector once done */ 390 lgFREE = true; 391 for( j=0; j<rfield.nflux; ++j) 392 { 393 cont[j] = rfield.ConEmitReflec[j]; 394 } 395 } 396 else if( nOption == 6 ) 397 { 398 /* all outward lines, */ 399 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 400 /* need to free the vector once done */ 401 lgFREE = true; 402 /* correct back to inner radius */ 403 refac = (realnum)radius.r1r0sq*geometry.covgeo; 404 for( j=0; j<rfield.nflux; ++j) 405 { 406 cont[j] = rfield.outlin[j]*refac; 407 } 408 } 409 else if( nOption == 7 ) 410 { 411 /* all reflected lines */ 412 if( geometry.lgSphere ) 413 { 414 refac = 0.; 415 } 416 else 417 { 418 refac = 1.; 419 } 420 421 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 422 /* need to free the vector once done */ 423 lgFREE = true; 424 for( j=0; j<rfield.nflux; ++j) 425 { 426 /* units of lines here are to cancel out with tricks applied to continuum cells 427 * when finally extracted below */ 428 cont[j] = rfield.reflin[j]*refac; 429 } 430 } 431 else if( nOption == 8 ) 432 { 433 /* total transmitted continuum */ 434 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 435 /* need to free the vector once done */ 436 lgFREE = true; 437 /* correct back to inner radius */ 438 refac = (realnum)radius.r1r0sq*geometry.covgeo; 439 for( j=0; j<rfield.nflux; ++j) 440 { 441 /* units of lines here are to cancel out with tricks applied to continuum cells 442 * when finally extracted below */ 443 cont[j] = (rfield.ConEmitOut[j]+ rfield.outlin[j])*refac 444 + rfield.flux[j]*(realnum)radius.r1r0sq; 445 } 446 } 447 else if( nOption == 9 ) 448 { 449 /* total reflected continuum */ 450 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 451 /* need to free the vector once done */ 452 lgFREE = true; 453 for( j=0; j<rfield.nflux; ++j) 454 { 455 /* units of lines here are to cancel out with tricks applied to continuum cells 456 * when finally extracted below */ 457 cont[j] = ((rfield.ConRefIncid[j]+rfield.ConEmitReflec[j]) + 358 for( long i = 0; i < nEnergy; i++ ) 359 { 360 long j = ipLoEnergy + i; 361 362 if( j >= rfield.nflux ) 363 { 364 ReturnedSpectrum[i] = SMALLFLOAT; 365 continue; 366 } 367 368 if( nOption == 1 ) 369 { 370 /* this is the incident continuum, col 2 of punch continuum command */ 371 ReturnedSpectrum[i] = rfield.flux_total_incident[j]; 372 } 373 else if( nOption == 2 ) 374 { 375 /* the attenuated transmitted continuum, no diffuse emission, 376 * col 3 of punch continuum command */ 377 ReturnedSpectrum[i] = rfield.flux[j]; 378 } 379 else if( nOption == 3 ) 380 { 381 /* reflected incident continuum, col 6 of punch continuum command */ 382 ReturnedSpectrum[i] = rfield.ConRefIncid[j]; 383 } 384 else if( nOption == 4 ) 385 { 386 /* correct back to inner radius */ 387 refac = (realnum)radius.r1r0sq*geometry.covgeo; 388 ReturnedSpectrum[i] = (rfield.outlin[j]+rfield.ConEmitOut[j])*refac; 389 } 390 else if( nOption == 5 ) 391 { 392 /* all reflected diffuse emission */ 393 if( geometry.lgSphere ) 394 { 395 refac = 0.; 396 } 397 else 398 { 399 refac = 1.; 400 } 401 402 ReturnedSpectrum[i] = (rfield.reflin[j]+rfield.ConEmitReflec[j])*refac; 403 } 404 else if( nOption == 6 ) 405 { 406 /* correct back to inner radius */ 407 refac = (realnum)radius.r1r0sq*geometry.covgeo; 408 ReturnedSpectrum[i] = rfield.outlin[j]*refac; 409 } 410 else if( nOption == 7 ) 411 { 412 /* all reflected line emission */ 413 if( geometry.lgSphere ) 414 { 415 refac = 0.; 416 } 417 else 418 { 419 refac = 1.; 420 } 421 422 ReturnedSpectrum[i] = rfield.reflin[j]*refac; 423 } 424 else if( nOption == 8 ) 425 { 426 /* total transmitted continuum */ 427 /* correct back to inner radius */ 428 refac = (realnum)radius.r1r0sq*geometry.covgeo; 429 ReturnedSpectrum[i] = (rfield.ConEmitOut[j]+ rfield.outlin[j])*refac 430 + rfield.flux[j]*(realnum)radius.r1r0sq; 431 } 432 else if( nOption == 9 ) 433 { 434 /* total reflected continuum */ 435 ReturnedSpectrum[i] = ((rfield.ConRefIncid[j]+rfield.ConEmitReflec[j]) + 458 436 rfield.reflin[j]); 459 437 } 460 } 461 else if( nOption == 10 ) 462 { 463 /* this is exp(-tau) */ 464 cont = (realnum*)MALLOC( sizeof(realnum)*(size_t)rfield.nupper ); 465 /* need to free the vector once done */ 466 lgFREE = true; 467 for( j=0; j<nEnergy; ++j) 468 { 438 else if( nOption == 10 ) 439 { 440 /* this is exp(-tau) */ 469 441 /* This is the TOTAL attenuation in both the continuum and lines. 470 442 * Jon Miller discovered that the line attenuation was missing in 07.02 */ 471 cont[j] = opac.ExpmTau[j]*rfield.trans_coef_total[j]; 472 } 473 } 474 else 475 { 476 fprintf(ioQQQ," cdSPEC called with impossible nOption (%i)\n", nOption); 477 cdEXIT(EXIT_FAILURE); 478 } 479 480 /* now generate the continua */ 481 for( ncell = 0; ncell < nEnergy; ++ncell ) 482 { 483 if( ncell >= rfield.nflux ) 484 { 485 ReturnedSpectrum[ncell] = SMALLFLOAT; 443 ReturnedSpectrum[i] = opac.ExpmTau[j]*rfield.trans_coef_total[j]; 486 444 } 487 445 else 488 446 { 489 ReturnedSpectrum[ncell] = cont[ncell]; 490 } 491 ASSERT( ReturnedSpectrum[ncell] >=0.f ); 492 } 493 494 /* need to free the vector once done if this flag was set */ 495 if( lgFREE ) 496 { 497 free(cont); 498 } 447 fprintf(ioQQQ," cdSPEC called with impossible nOption (%i)\n", nOption); 448 cdEXIT(EXIT_FAILURE); 449 } 450 451 ASSERT( ReturnedSpectrum[i] >=0.f ); 452 } 453 499 454 return; 500 455 } -
branches/newmole/source/cont_createmesh.cpp
r2023 r2079 457 457 * 458 458 * TeLowestFineOpacity of 1e4 K is temperature were line width is 459 * evaluat ioned. Tests were done using the stop temperature in its place459 * evaluated. Tests were done using the stop temperature in its place 460 460 * Te below 1e4 K made fine opacity grid huge 461 461 * do not let temp get higher than 1e4 either - code run with stop temp 10 set 462 462 * stop temp of 1e10K and assert thrown at line 204 of cont_createpointers.c 463 463 * simply use 1e4 K as a characteristic temperature */ 464 /** \todo 1 set temp of 1e4K will be too coarse a line for PDRs where 465 * H2 line overlap is very important */ 464 466 double TeLowestFineOpacity = 1e4; 465 467 rfield.fine_opac_velocity_width = 466 468 (realnum)sqrt(2.*BOLTZMANN/ATOMIC_MASS_UNIT*TeLowestFineOpacity/ 467 /* TurbVel/5 will divide line into 5 cells when turbulence-dominated */ 468 dense.AtomicWeight[rfield.fine_opac_nelem] + POW2(DoppVel.TurbVel/5.)) / 469 dense.AtomicWeight[rfield.fine_opac_nelem] ) / 469 470 /* we want fine_opac_nresolv continuum elements across this line 470 471 * default is 1, changed with SET FINE CONTINUUM command */ -
branches/newmole/source/cpu.cpp
r2023 r2079 359 359 360 360 /* >>chng 01 oct 09, disable gradual underflow on ultrasparc whith g++ 361 * (only needed for versions prior to 3.1, see Note 1).361 * (only needed for versions < 3.1 or >= 4.3.0, see Note 1). 362 362 * 363 363 * compile this module with: 364 * g++ [ other options... ] -I<include-dir> -DHAVE_SUNMATH -c setfpenv.c364 * g++ [ other options... ] -I<include-dir> -DHAVE_SUNMATH -c cpu.cpp 365 365 * link the program with: 366 366 * g++ -L<library-dir> -o cloudy.exe *.o -lsunmath … … 379 379 * g++ [ other options... ] -funsafe-math-optimizations -c *.c 380 380 * g++ [ other options... ] -funsafe-math-optimizations -o cloudy.exe *.o 381 * 382 * Starting with g++ 4.3.0 the -funsafe-math-optimizations option can no longer be 383 * used as it implicitly enables -fno-trapping-math, which is unsafe for Cloudy 384 * because we do trap floating point exceptions. 381 385 * 382 386 * Note 2: Don't use nonstandard_arithmetic() with CC (the SunWorks/Forte compiler); … … 439 443 string FileName( fname ); 440 444 vector<string>::size_type begin, end; 441 bool lgAbort = ( scheme == AS_DATA_ONLY || scheme == AS_DATA_ LOCAL ||445 bool lgAbort = ( scheme == AS_DATA_ONLY || scheme == AS_DATA_OPTIONAL || scheme == AS_DATA_LOCAL || 442 446 scheme == AS_LOCAL_DATA || scheme == AS_LOCAL_ONLY ); 443 447 … … 446 450 case AS_DATA_ONLY: 447 451 case AS_DATA_ONLY_TRY: 452 case AS_DATA_OPTIONAL: 448 453 begin = 1; 449 454 end = cpu.chSearchPath.size()-1; … … 480 485 if( handle == NULL && lgAbort ) 481 486 { 482 // failed on very first open -> probably path is not correct 483 fprintf( ioQQQ, "\nPROBLEM DISASTER I could not open the data file %s\n\n", fname ); 484 fprintf( ioQQQ, "Although there may be other reasons you have received this error,\n"); 485 fprintf( ioQQQ, "the most likely are that the path has not been properly set\n"); 486 fprintf( ioQQQ, "or that the path points to an old version of the data.\n\n"); 487 fprintf( ioQQQ, "Please have a look at the file path.h in the source directory\n"); 488 fprintf( ioQQQ, "to check how the variable CLOUDY_DATA_PATH is set - \n"); 489 fprintf( ioQQQ, "it should give the location of the data files I need.\n"); 490 fprintf( ioQQQ, "These are the files in the data download from the web site.\n\n"); 491 fprintf( ioQQQ, "Recompile the code with the correct data path set in path.h\n"); 492 fprintf( ioQQQ, "or use the shell command \"set CLOUDY_DATA_PATH=path\" to set the\n"); 493 fprintf( ioQQQ, "path from a command prompt.\n\n"); 494 cpu.printDataPath(); 495 496 fprintf( ioQQQ, " These are all the paths I tried:\n" ); 497 for( vector<string>::size_type i=begin; i < end; ++i ) 498 { 499 if( cpu.chSearchPath[i].length() > 0 ) 500 fprintf( ioQQQ, " ==%s==\n", cpu.chSearchPath[i].c_str() ); 501 else 502 fprintf( ioQQQ, " ==<local directory>==\n" ); 487 if( scheme == AS_DATA_OPTIONAL ) 488 // presence is optional -> make warning less scary... 489 fprintf( ioQQQ, "\nI could not open the data file %s\n\n", fname ); 490 else 491 fprintf( ioQQQ, "\nPROBLEM DISASTER I could not open the data file %s\n\n", fname ); 492 if( cpu.nFileDone == 0 || scheme == AS_DATA_ONLY ) 493 { 494 // failed on very first open -> most likely path is not correct 495 // failed on AS_DATA_ONLY -> CLOUDY_DATA_PATH may point to obsolete data dir 496 fprintf( ioQQQ, "Although there may be other reasons you have received this error,\n"); 497 fprintf( ioQQQ, "the most likely are that the path has not been properly set\n"); 498 fprintf( ioQQQ, "or that the path points to an old version of the data.\n\n"); 499 fprintf( ioQQQ, "Please have a look at the file path.h in the source directory\n"); 500 fprintf( ioQQQ, "to check how the variable CLOUDY_DATA_PATH is set - \n"); 501 fprintf( ioQQQ, "it should give the location of the data files I need.\n"); 502 fprintf( ioQQQ, "These are the files in the data download from the web site.\n\n"); 503 fprintf( ioQQQ, "Recompile the code with the correct data path set in path.h\n"); 504 fprintf( ioQQQ, "or use the shell command \"export CLOUDY_DATA_PATH=path\" to set the\n"); 505 fprintf( ioQQQ, "path from a bash command prompt.\n\n"); 506 cpu.printDataPath(); 507 } 508 else 509 { 510 // failed on search including local directory -> most likely the file name 511 // was mistyped on a compile command, or Cloudy is run in the wrong directory 512 // if scheme == AS_DATA_OPTIONAL, this most likely is a stellar grid that is not installed.
