00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "cddefines.h"
00043 #include "trace.h"
00044 #include "conv.h"
00045 #include "punch.h"
00046 #include "lines.h"
00047 #include "pressure.h"
00048 #include "prt.h"
00049 #include "colden.h"
00050 #include "dense.h"
00051 #include "radius.h"
00052 #include "struc.h"
00053 #include "mole.h"
00054 #include "elementnames.h"
00055 #include "mean.h"
00056 #include "phycon.h"
00057 #include "called.h"
00058 #include "parse.h"
00059 #include "input.h"
00060 #include "taulines.h"
00061 #include "version.h"
00062 #include "thermal.h"
00063 #include "optimize.h"
00064 #include "grid.h"
00065 #include "timesc.h"
00066 #include "cloudy.h"
00067 #include "warnings.h"
00068 #include "lines_service.h"
00069 #include "cddrive.h"
00070
00071
00072
00073
00074
00075
00076
00077 int cdDrive(void )
00078 {
00079 bool lgBAD;
00080
00081 DEBUG_ENTRY( "cdDrive()" );
00082
00083
00084
00085
00086
00087
00088 if( !lgcdInitCalled )
00089 {
00090 printf(" cdInit was not called first - this must be the first call.\n");
00091 puts( "[Stop in cdDrive]" );
00092 cdEXIT(EXIT_FAILURE);
00093 }
00094
00095 if( trace.lgTraceInput )
00096 {
00097 fprintf( ioQQQ,
00098 "cdDrive: lgOptimr=%1i lgVaryOn=%1i lgNoVary=%1i input.nSave:%li\n",
00099 optimize.lgOptimr , optimize.lgVaryOn , optimize.lgNoVary, input.nSave );
00100 }
00101
00102
00103
00104 if( optimize.lgOptimr && optimize.lgVaryOn )
00105 {
00106 optimize.lgVaryOn = true;
00107 }
00108 else
00109 {
00110 optimize.lgVaryOn = false;
00111 }
00112
00113
00114
00115
00116
00117
00118 punch.lgOpenUnits = true;
00119 punch.lgPunHeader = true;
00120 grid.lgGridDone = false;
00121 PunchFilesInit();
00122
00123
00124
00125 if( optimize.lgNoVary )
00126 optimize.lgVaryOn = false;
00127
00128 if( optimize.lgVaryOn )
00129 {
00130 if( trace.lgTraceInput )
00131 fprintf( ioQQQ, "cdDrive: calling lgOptimize_do\n");
00132
00133 lgBAD = grid_do();
00134 }
00135 else
00136 {
00137 if( trace.lgTraceInput )
00138 fprintf( ioQQQ, "cdDrive: calling cloudy\n");
00139
00140 lgBAD = cloudy();
00141 }
00142
00143
00144 lgcdInitCalled = false;
00145
00146 if( lgAbort || lgBAD )
00147 {
00148 if( trace.lgTraceInput )
00149 fprintf( ioQQQ, "cdDrive: returning failure during call. \n");
00150
00151 DEBUG_EXIT( "cdDrive()" );
00152 return(1);
00153 }
00154 else
00155 {
00156
00157 DEBUG_EXIT( "cdDrive()" );
00158 return(0);
00159 }
00160 }
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 void cdPrtWL( FILE *io , float wl )
00172 {
00173
00174 DEBUG_ENTRY( "cdPrtWL()" );
00175
00176 prt_wl( io , wl );
00177
00178 DEBUG_EXIT( "cdPrtWL()" );
00179 return;
00180 }
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 void cdReasonGeo(FILE * ioOUT)
00192 {
00193
00194 DEBUG_ENTRY( "cdReasonGeo()" );
00195
00196
00197 fprintf( ioOUT, "%s", warnings.chRgcln[0] );
00198 fprintf( ioOUT , "\n" );
00199
00200 fprintf( ioOUT, "%s", warnings.chRgcln[1] );
00201 fprintf( ioOUT , "\n" );
00202
00203 DEBUG_EXIT( "cdReasonGeo()" );
00204 return;
00205 }
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 void cdWarnings(FILE *ioPNT )
00217 {
00218 long int i;
00219
00220 DEBUG_ENTRY( "cdWarnings()" );
00221
00222 if( warnings.nwarn > 0 )
00223 {
00224 for( i=0; i < warnings.nwarn; i++ )
00225 {
00226
00227 fprintf( ioPNT, "%s", warnings.chWarnln[i] );
00228 fprintf( ioPNT, "\n" );
00229 }
00230 }
00231
00232
00233 DEBUG_EXIT( "cdWarnings()" );
00234 return;
00235 }
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246 void cdCautions(FILE * ioOUT)
00247 {
00248 long int i;
00249
00250 DEBUG_ENTRY( "cdCautions()" );
00251
00252 if( warnings.ncaun > 0 )
00253 {
00254 for( i=0; i < warnings.ncaun; i++ )
00255 {
00256 fprintf( ioOUT, "%s", warnings.chCaunln[i] );
00257 fprintf( ioOUT, "\n" );
00258 }
00259 }
00260
00261 DEBUG_EXIT( "cdCautions()" );
00262 return;
00263 }
00264
00265
00266
00267
00268
00269
00270
00271 void cdTimescales(
00272
00273 double *TTherm ,
00274
00275 double *THRecom ,
00276
00277 double *TH2 )
00278 {
00279
00280 DEBUG_ENTRY( "cdTimescales()" );
00281
00282
00283
00284
00285 *TTherm = timesc.time_therm_long;
00286
00287
00288 *THRecom = timesc.time_Hrecom_long;
00289
00290
00291 *TH2 = MAX2( timesc.time_H2_Dest_longest , timesc.time_H2_Form_longest );
00292
00293 DEBUG_EXIT( "cdTimescales()" );
00294 return;
00295 }
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 void cdSurprises(FILE * ioOUT)
00307 {
00308 long int i;
00309
00310 DEBUG_ENTRY( "cdSurprises()" );
00311
00312 if( warnings.nbang > 0 )
00313 {
00314 for( i=0; i < warnings.nbang; i++ )
00315 {
00316 fprintf( ioOUT, "%s", warnings.chBangln[i] );
00317 fprintf( ioOUT, "\n" );
00318 }
00319 }
00320
00321
00322 DEBUG_EXIT( "cdSurprises()" );
00323 return;
00324 }
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335 void cdNotes(FILE * ioOUT)
00336 {
00337 long int i;
00338
00339 DEBUG_ENTRY( "cdNotes()" );
00340
00341 if( warnings.nnote > 0 )
00342 {
00343 for( i=0; i < warnings.nnote; i++ )
00344 {
00345 fprintf( ioOUT, "%s", warnings.chNoteln[i] );
00346 fprintf( ioOUT, "\n" );
00347 }
00348 }
00349
00350 DEBUG_EXIT( "cdNotes()" );
00351 return;
00352 }
00353
00354
00355
00356
00357
00358
00359
00360
00361 double cdCooling_last(void)
00362 {
00363 return (thermal.ctot);
00364 }
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374 void cdVersion(char chString[] )
00375 {
00376 if( !lgcdInitCalled )
00377 {
00378 printf(" cdInit was not called first - this must be the first call.\n");
00379 puts( "[Stop in cdVersion]" );
00380 cdEXIT(EXIT_FAILURE);
00381 }
00382
00383
00384 strcpy( chString , version.chVersion );
00385 return;
00386 }
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 void cdDate(char chString[] )
00398 {
00399
00400 strcpy( chString , version.chDate );
00401 return;
00402 }
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413 double cdHeating_last(void)
00414 {
00415 return (thermal.htot);
00416 }
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427 double cdEDEN_last(void)
00428 {
00429 return ( dense.eden );
00430 }
00431
00432
00433
00434
00435
00436
00437
00438
00439 #include "noexec.h"
00440
00441 void cdNoExec(void)
00442 {
00443
00444 DEBUG_ENTRY( "cdNoExec()" );
00445
00446
00447
00448
00449 noexec.lgNoExec = true;
00450
00451
00452 DEBUG_EXIT( "cdNoExec()" );
00453 return;
00454 }
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465 static bool lgCalled=false;
00466
00467
00468 #if defined(_MSC_VER)
00469
00470
00471 struct timeval {
00472 long tv_sec;
00473 long tv_usec;
00474 };
00475 #else
00476 #include <sys/time.h>
00477 #include <sys/resource.h>
00478 #endif
00479
00480
00481 static struct timeval before;
00482
00483
00484 static void cdClock(struct timeval *clock_dat)
00485 {
00486
00487
00488
00489 #if defined(_MSC_VER) || defined(__HP_aCC)
00490 clock_t clock_val;
00491
00492
00493 clock_val = clock();
00494 clock_dat->tv_sec = clock_val/CLOCKS_PER_SEC;
00495 clock_dat->tv_usec = 1000000*(clock_val-(clock_dat->tv_sec*CLOCKS_PER_SEC))/CLOCKS_PER_SEC;
00496
00497
00498 #else
00499 struct rusage rusage;
00500 if(getrusage(RUSAGE_SELF,&rusage) != 0)
00501 {
00502 fprintf( ioQQQ, "DISASTER cdClock called getrusage with invalid arguments.\n" );
00503 fprintf( ioQQQ, "Sorry.\n" );
00504 puts( "[Stop in cdClock]" );
00505 cdEXIT(EXIT_FAILURE);
00506 }
00507 clock_dat->tv_sec = rusage.ru_utime.tv_sec;
00508 clock_dat->tv_usec = rusage.ru_utime.tv_usec;
00509 #endif
00510
00511 }
00512
00513
00514 void cdSetExecTime(void)
00515 {
00516 cdClock(&before);
00517 lgCalled = true;
00518 }
00519
00520 double cdExecTime(void)
00521 {
00522 struct timeval clock_dat;
00523
00524 if( lgCalled)
00525 {
00526 cdClock(&clock_dat);
00527
00528
00529
00530 return (double)(clock_dat.tv_sec-before.tv_sec)+1e-6*(double)(clock_dat.tv_usec-before.tv_usec);
00531 }
00532 else
00533 {
00534
00535
00536 fprintf( ioQQQ, "DISASTER cdExecTime was called before SetExecTime, impossible.\n" );
00537 fprintf( ioQQQ, "Sorry.\n" );
00538 puts( "[Stop in cdExecTime]" );
00539 cdEXIT(EXIT_FAILURE);
00540 }
00541 }
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551 void cdPrintCommands( FILE * ioOUT )
00552 {
00553 long int i;
00554 fprintf( ioOUT, " Input commands follow:\n" );
00555 fprintf( ioOUT, "c ======================\n" );
00556
00557 for( i=0; i <= input.nSave; i++ )
00558 {
00559 fprintf( ioOUT, "%s\n", input.chCardSav[i] );
00560 }
00561 fprintf( ioOUT, "c ======================\n" );
00562 }
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573 long int cdEmis(
00574
00575
00576
00577 char *chLabel,
00578
00579 float wavelength,
00580
00581 double *emiss )
00582 {
00583
00584 char chCARD[INPUT_LINE_LENGTH];
00585 char chCaps[5];
00586 long int j;
00587 float errorwave;
00588
00589 DEBUG_ENTRY( "cdEms()" );
00590
00591
00592
00593
00594 strcpy( chCARD, chLabel );
00595
00596
00597 caps(chCARD);
00598
00599
00600 errorwave = WavlenErrorGet( wavelength );
00601
00602 for( j=0; j < LineSave.nsum; j++ )
00603 {
00604
00605 cap4(chCaps , (char*)LineSv[j].chALab);
00606
00607
00608
00609
00610 if( fabs(LineSv[j].wavelength-wavelength) < errorwave && strcmp(chCaps,chCARD) == 0 )
00611 {
00612
00613 *emiss = LineSv[j].emslin[LineSave.lgLineEmergent];
00614
00615 DEBUG_EXIT( "cdEms()" );
00616
00617 return j;
00618 }
00619 }
00620
00621 DEBUG_EXIT( "cdEms()" );
00622
00623
00624 return -LineSave.nsum;
00625 }
00626
00627
00628
00629
00630
00631
00632
00633
00634 void cdEmis_ip(
00635
00636 long int ipLine,
00637
00638 double *emiss )
00639 {
00640
00641 DEBUG_ENTRY( "cdEmis_ip()" );
00642
00643
00644
00645
00646
00647 ASSERT( ipLine >= 0 && ipLine < LineSave.nsum );
00648 *emiss = LineSv[ipLine].emslin[LineSave.lgLineEmergent];
00649
00650 DEBUG_EXIT( "cdEmis_ip()" );
00651
00652 return;
00653 }
00654
00655
00656
00657
00658
00659
00660
00661 int cdColm(
00662
00663
00664
00665 const char *chLabel,
00666
00667
00668
00669 long int ion,
00670
00671
00672 double *theocl )
00673 {
00674 long int nelem;
00675
00676 char chLABEL_CAPS[20];
00677
00678 DEBUG_ENTRY( "cdColm()" );
00679
00680
00681 if( chLabel[4]!=0 )
00682 {
00683 fprintf( ioQQQ, " cdColm called with insane ion label, =%s, must be 4 character + end of string.\n",
00684 chLabel );
00685 DEBUG_EXIT( "cdColm()" );
00686 return(1);
00687 }
00688
00689 strcpy( chLABEL_CAPS, chLabel );
00690
00691 caps(chLABEL_CAPS);
00692
00693
00694
00695
00696 if( ion < 0 )
00697 {
00698 fprintf( ioQQQ, " cdColm called with insane ion, =%li\n",
00699 ion );
00700 DEBUG_EXIT( "cdColm()" );
00701 return(1);
00702 }
00703
00704 else if( ion == 0 )
00705 {
00706
00707
00708 if( strcmp( chLABEL_CAPS , "H2 " )==0 )
00709 {
00710 *theocl = colden.colden[ipCOL_H2g] + colden.colden[ipCOL_H2s];
00711 }
00712
00713
00714 else if( strcmp( chLABEL_CAPS , "H- " )==0 )
00715 {
00716 *theocl = colden.colden[ipCOL_HMIN];
00717 }
00718
00719
00720 else if( strcmp( chLABEL_CAPS , "H2+ " )==0 )
00721 {
00722 *theocl = colden.colden[ipCOL_H2p];
00723 }
00724
00725
00726 else if( strcmp( chLABEL_CAPS , "H3+ " )==0 )
00727 {
00728 *theocl = colden.colden[ipCOL_H3p];
00729 }
00730
00731
00732 else if( strcmp( chLABEL_CAPS , "H2G " )==0 )
00733 {
00734 *theocl = colden.colden[ipCOL_H2g];
00735 }
00736
00737
00738 else if( strcmp( chLABEL_CAPS , "H2* " )==0 )
00739 {
00740 *theocl = colden.colden[ipCOL_H2s];
00741 }
00742
00743
00744 else if( strcmp( chLABEL_CAPS , "HEH+" )==0 )
00745 {
00746 *theocl = colden.colden[ipCOL_HeHp];
00747 }
00748
00749
00750 else if( strcmp( chLABEL_CAPS , "CO " )==0 )
00751 {
00752 *theocl = findspecies("CO")->hevcol;
00753 }
00754
00755
00756 else if( strcmp( chLABEL_CAPS , "OH " )==0 )
00757 {
00758 *theocl = findspecies("OH")->hevcol;
00759 }
00760
00761
00762 else if( strcmp( chLABEL_CAPS , "H2O " )==0 )
00763 {
00764 *theocl = findspecies("H2O")->hevcol;
00765 }
00766
00767
00768 else if( strcmp( chLABEL_CAPS , "O2 " )==0 )
00769 {
00770 *theocl = findspecies("O2")->hevcol;
00771 }
00772
00773
00774 else if( strcmp( chLABEL_CAPS , "SIO " )==0 )
00775 {
00776 *theocl = findspecies("SiO")->hevcol;
00777 }
00778
00779
00780 else if( strcmp( chLABEL_CAPS , "C2 " )==0 )
00781 {
00782 *theocl = findspecies("C2")->hevcol;
00783 }
00784
00785
00786 else if( strcmp( chLABEL_CAPS , "C3 " )==0 )
00787 {
00788 *theocl = findspecies("C3")->hevcol;
00789 }
00790
00791
00792 else if( strcmp( chLABEL_CAPS , "CN " )==0 )
00793 {
00794 *theocl = findspecies("CN")->hevcol;
00795 }
00796
00797
00798 else if( strcmp( chLABEL_CAPS , "CH " )==0 )
00799 {
00800 *theocl = findspecies("CH")->hevcol;
00801 }
00802
00803
00804 else if( strcmp( chLABEL_CAPS , "CH+ " )==0 )
00805 {
00806 *theocl = findspecies("CH+")->hevcol;
00807 }
00808
00809
00810
00811
00812
00813 else if( strcmp( chLABEL_CAPS , "CII*" )==0 )
00814 {
00815 *theocl = colden.C2Colden[1];
00816 }
00817 else if( strcmp( chLABEL_CAPS , "C11*" )==0 )
00818 {
00819 *theocl = colden.C1Colden[0];
00820 }
00821 else if( strcmp( chLABEL_CAPS , "C12*" )==0 )
00822 {
00823 *theocl = colden.C1Colden[1];
00824 }
00825 else if( strcmp( chLABEL_CAPS , "C13*" )==0 )
00826 {
00827 *theocl = colden.C1Colden[2];
00828 }
00829 else if( strcmp( chLABEL_CAPS , "O11*" )==0 )
00830 {
00831 *theocl = colden.O1Colden[0];
00832 }
00833 else if( strcmp( chLABEL_CAPS , "O12*" )==0 )
00834 {
00835 *theocl = colden.O1Colden[1];
00836 }
00837 else if( strcmp( chLABEL_CAPS , "O13*" )==0 )
00838 {
00839 *theocl = colden.O1Colden[2];
00840 }
00841
00842 else if( strcmp( chLABEL_CAPS , "C30*" )==0 )
00843 {
00844 *theocl = colden.C3Colden[1];
00845 }
00846 else if( strcmp( chLABEL_CAPS , "C31*" )==0 )
00847 {
00848 *theocl = colden.C3Colden[2];
00849 }
00850 else if( strcmp( chLABEL_CAPS , "C32*" )==0 )
00851 {
00852 *theocl = colden.C3Colden[3];
00853 }
00854 else if( strcmp( chLABEL_CAPS , "SI2*" )==0 )
00855 {
00856 *theocl = colden.Si2Colden[1];
00857 }
00858 else if( strcmp( chLABEL_CAPS , "HE1*" )==0 )
00859 {
00860 *theocl = colden.He123S;
00861 }
00862
00863 else if( strncmp(chLABEL_CAPS , "H2" , 2 ) == 0 )
00864 {
00865 long int iVib = chLABEL_CAPS[2] - '0';
00866 long int iRot = chLABEL_CAPS[3] - '0';
00867 if( iVib<0 || iRot < 0 )
00868 {
00869 fprintf( ioQQQ, " cdColm called with insane v,J for H2=\"%4.4s\" caps=\"%4.4s\"\n",
00870 chLabel , chLABEL_CAPS );
00871 DEBUG_EXIT( "cdColm()" );
00872 return( 1 );
00873 }
00874 *theocl = cdH2_colden( iVib , iRot );
00875 }
00876
00877
00878 else
00879 {
00880 fprintf( ioQQQ, " cdColm called with unknown element chLabel, org=\"%4.4s \" 0 caps=\"%4.4s\" 0\n",
00881 chLabel , chLABEL_CAPS );
00882 DEBUG_EXIT( "cdColm()" );
00883 return(1);
00884 }
00885 }
00886 else
00887 {
00888
00889
00890 nelem = 0;
00891 while( nelem < LIMELM &&
00892 strncmp(chLABEL_CAPS,elementnames.chElementNameShort[nelem],4) != 0 )
00893 {
00894 ++nelem;
00895 }
00896
00897
00898
00899 if( nelem < LIMELM )
00900 {
00901
00902
00903
00904 if( ion > MAX2(3,nelem + 2) )
00905 {
00906 fprintf( ioQQQ,
00907 " cdColm asked to return ionization stage %ld for element %s but this is not physical.\n",
00908 ion, chLabel );
00909 DEBUG_EXIT( "cdColm()" );
00910 return(1);
00911 }
00912
00913
00914 *theocl = mean.xIonMeans[0][nelem][ion-1];
00915
00916
00917
00918
00919 if( nelem==ipHYDROGEN && ion==3 )
00920 *theocl /= 2.;
00921 }
00922 else
00923 {
00924 fprintf( ioQQQ,
00925 " cdColm did not understand this combination of ion %4ld and element %4.4s.\n",
00926 ion, chLabel );
00927 DEBUG_EXIT( "cdColm()" );
00928 return(1);
00929 }
00930 }
00931
00932 DEBUG_EXIT( "cdColm()" );
00933 return(0);
00934 }
00935
00936
00937
00938
00939
00940
00941
00942
00943 void cdErrors(FILE *ioOUT)
00944 {
00945 long int nc,
00946 nn,
00947 npe,
00948 ns,
00949 nte,
00950 nw ,
00951 nIone,
00952 nEdene;
00953 bool lgAbort_loc;
00954
00955 DEBUG_ENTRY( "cdErrors()" );
00956
00957
00958 cdNwcns(&lgAbort_loc,&nw,&nc,&nn,&ns,&nte,&npe, &nIone, &nEdene );
00959
00960
00961 if( nw || nc || nte || npe || nIone || nEdene || lgAbort_loc )
00962 {
00963
00964 fprintf( ioOUT, "%75.75s\n", input.chTitle );
00965
00966 if( lgAbort_loc )
00967 fprintf(ioOUT," Calculation ended with abort!\n");
00968
00969
00970 if( nw != 0 )
00971 {
00972 cdWarnings(ioOUT);
00973 }
00974
00975
00976 if( nc != 0 )
00977 {
00978 cdCautions(ioOUT);
00979 }
00980
00981 if( nte != 0 )
00982 {
00983 fprintf( ioOUT , "Te failures=%4ld\n", nte );
00984 }
00985
00986 if( npe != 0 )
00987 {
00988 fprintf( ioOUT , "Pressure failures=%4ld\n", npe );
00989 }
00990
00991 if( nIone != 0 )
00992 {
00993 fprintf( ioOUT , "Ionization failures=%4ld\n", nte );
00994 }
00995
00996 if( nEdene != 0 )
00997 {
00998 fprintf( ioOUT , "Electron density failures=%4ld\n", npe );
00999 }
01000 }
01001
01002 DEBUG_EXIT( "cdErrors()" );
01003 return;
01004 }
01005
01006
01007
01008
01009
01010
01011 void cdDepth_depth( double cdDepth[] )
01012 {
01013 long int nz;
01014
01015 DEBUG_ENTRY( "cdDepth_depth()" );
01016
01017 for( nz = 0; nz<nzone; ++nz )
01018 {
01019 cdDepth[nz] = struc.depth[nz];
01020 }
01021
01022 DEBUG_EXIT( "cdDepth_depth()" );
01023 return;
01024 }
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038 void cdPressure_depth(
01039
01040 double TotalPressure[],
01041
01042 double GasPressure[],
01043
01044 double RadiationPressure[])
01045 {
01046 long int nz;
01047
01048 DEBUG_ENTRY( "cdPressure_depth()" );
01049
01050 for( nz = 0; nz<nzone; ++nz )
01051 {
01052 TotalPressure[nz] = struc.pressure[nz];
01053 GasPressure[nz] = struc.GasPressure[nz];
01054 RadiationPressure[nz] = struc.pres_radiation_lines_curr[nz];
01055 }
01056
01057 DEBUG_EXIT( "cdPressure_depth()" );
01058 return;
01059 }
01060
01061
01062
01063
01064
01065
01066
01067 void cdPressure_last(
01068 double *PresTotal,
01069 double *PresGas,
01070 double *PresRad)
01071 {
01072
01073 DEBUG_ENTRY( "cdPressure_last()" );
01074
01075 *PresGas = pressure.PresGasCurr;
01076 *PresRad = pressure.pres_radiation_lines_curr;
01077 *PresTotal = pressure.PresGasCurr + pressure.pres_radiation_lines_curr;
01078
01079 DEBUG_EXIT( "cdPressure_last()" );
01080 return;
01081 }
01082
01083
01084
01085
01086
01087
01088
01089
01090 long int cdnZone( void )
01091 {
01092 return nzone;
01093 }
01094
01095
01096
01097
01098
01099
01100
01101
01102 double cdTemp_last(void)
01103 {
01104 return phycon.te;
01105 }
01106
01107
01108
01109
01110
01111
01112
01113 int cdIonFrac(
01114
01115 const char *chLabel,
01116
01117
01118 long int IonStage,
01119
01120 double *fracin,
01121
01122 const char *chWeight ,
01123
01124 bool lgDensity )
01125
01126 {
01127
01128 bool lgVol;
01129 long int ip,
01130 ion,
01131 nelem;
01132 float aaa[LIMELM + 1];
01133
01134 char chCARD[INPUT_LINE_LENGTH];
01135
01136 DEBUG_ENTRY( "cdIonFrac()" );
01137
01138 strcpy( chCARD, chWeight );
01139
01140 caps(chCARD);
01141
01142
01143
01144 if( strcmp(chCARD,"RADIUS") == 0 )
01145 {
01146 lgVol = false;
01147 }
01148
01149 else if( strcmp(chCARD,"VOLUME") == 0 )
01150 {
01151 lgVol = true;
01152 }
01153
01154 else
01155 {
01156 fprintf( ioQQQ, " cdIonFrac: chWeight=%6.6s makes no sense to me, valid options are RADIUS and VOLUME\n",
01157 chWeight );
01158 *fracin = 0.;
01159
01160 DEBUG_EXIT( "cdIonFrac()" );
01161 return(1);
01162 }
01163
01164
01165 strcpy( chCARD, chLabel );
01166
01167 caps(chCARD);
01168
01169 if( IonStage==0 )
01170 {
01171
01172 if( strcmp(chCARD,"H2 " ) == 0 )
01173 {
01174
01175 nelem = 0;
01176 IonStage = 3;
01177 }
01178 else
01179 {
01180 fprintf( ioQQQ, " cdIonFrac: ion stage of zero and element %s makes no sense to me\n",
01181 chCARD );
01182 *fracin = 0.;
01183
01184 DEBUG_EXIT( "cdIonFrac()" );
01185 return(1);
01186 }
01187 }
01188
01189 else
01190 {
01191
01192 nelem = 0;
01193 while( nelem < LIMELM &&
01194 strcmp(chCARD,elementnames.chElementNameShort[nelem]) != 0 )
01195 {
01196 ++nelem;
01197 }
01198
01199 }
01200
01201
01202
01203 if( nelem >= LIMELM )
01204 {
01205 fprintf( ioQQQ, " cdIonFrac called with unknown element chLabel, =%4.4s\n",
01206 chLabel );
01207
01208 DEBUG_EXIT( "cdIonFrac()" );
01209 return(1);
01210 }
01211
01212
01213
01214
01215
01216
01217
01218 ion = IonStage - 1;
01219
01220
01221 if( (ion > nelem+1 || ion < 0 ) && !(nelem==ipHYDROGEN&&ion==2))
01222 {
01223 fprintf( ioQQQ, " cdIonFrac asked to return ionization stage%4ld for element %4.4s but this is not physical.\n",
01224 IonStage, chLabel );
01225 *fracin = -1.;
01226 DEBUG_EXIT( "cdIonFrac()" );
01227 return(1);
01228 }
01229
01230
01231 if( lgVol )
01232 {
01233
01234
01235
01236
01237
01238 MeanIonVolume('i', nelem,&ip,aaa,lgDensity);
01239 *fracin = pow(10.f,aaa[ion]);
01240 }
01241 else
01242 {
01243
01244
01245 MeanIonRadius('i', nelem,&ip,aaa,lgDensity);
01246 *fracin = pow(10.f,aaa[ion]);
01247 }
01248
01249 DEBUG_EXIT( "cdIonFrac()" );
01250
01251
01252 return(0);
01253 }
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266 long debugLine( float wavelength )
01267 {
01268 long j, kount;
01269 float errorwave;
01270
01271 kount = 0;
01272
01273
01274 errorwave = WavlenErrorGet( wavelength );
01275
01276 for( j=0; j < LineSave.nsum; j++ )
01277 {
01278
01279
01280 if( fabs(LineSv[j].wavelength-wavelength) < errorwave )
01281 {
01282 printf("%s\n", LineSv[j].chALab);
01283 ++kount;
01284 }
01285 }
01286 printf(" hits = %li\n", kount );
01287 return(kount);
01288 }
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298 long int cdLineListPunch(
01299
01300
01301 FILE* io )
01302 {
01303
01304 long int j;
01305
01306 DEBUG_ENTRY( "cdLineListPunch()" );
01307
01308 for( j=1; j < LineSave.nsum; j++ )
01309 {
01310
01311 fprintf(io, "%li\t%s\t",
01312 j,
01313 LineSv[j].chALab);
01314 prt_wl( io , LineSv[j].wavelength );
01315 fprintf(io, "\n");
01316 }
01317
01318
01319 DEBUG_EXIT( "cdLineListPunch()" );
01320
01321
01322 return LineSave.nsum;
01323 }
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333 long int cdLine(
01334 const char *chLabel,
01335
01336 float wavelength,
01337
01338 double *relint,
01339
01340 double *absint )
01341 {
01342 char chCaps[5],
01343 chFind[5];
01344 long int ipobs,
01345
01346
01347 j, index_of_closest=LONG_MIN,
01348 index_of_closest_w_correct_label=-1;
01349 float errorwave, smallest_error=BIGFLOAT,
01350 smallest_error_w_correct_label=BIGFLOAT;
01351 char chLabelLoc[INPUT_LINE_LENGTH];
01352
01353 DEBUG_ENTRY( "cdLine()" );
01354
01355
01356 if( LineSave.nsum == 0 )
01357 {
01358 *relint = 0.;
01359 *absint = 0.;
01360 DEBUG_EXIT( "cdLine()" );
01361 return 0;
01362 }
01363 ASSERT( LineSave.ipNormWavL >= 0);
01364 ASSERT( LineSave.nsum > 0);
01365
01366
01367 if( chLabel[4]!=0 )
01368 {
01369 fprintf( ioQQQ, " cdLine called with insane line label, =%s, must be 4 character + end of string.\n",
01370 chLabel );
01371 DEBUG_EXIT( "cdLine()" );
01372 return 1;
01373 }
01374
01375
01376 strcpy( chLabelLoc , chLabel );
01377
01378 cap4(chFind,chLabelLoc);
01379
01380
01381
01382 for( j=0; j<=3; j++ )
01383 {
01384 if( chFind[j] == '\t' )
01385 {
01386 chFind[j] = ' ';
01387 }
01388 }
01389
01390
01391 errorwave = WavlenErrorGet( wavelength );
01392
01393 {
01394
01395 enum{DEBUG_LOC=false};
01396
01397 if( DEBUG_LOC && fabs(wavelength-1000.)<0.01 )
01398 {
01399 fprintf(ioQQQ,"cdDrive wl %.4e error %.3e\n",
01400 wavelength, errorwave );
01401 }
01402 }
01403
01404
01405 for( j=1; j < LineSave.nsum; j++ )
01406 {
01407
01408
01409 float current_error;
01410 current_error = (float)fabs(LineSv[j].wavelength-wavelength);
01411
01412
01413 cap4(chCaps , (char*)LineSv[j].chALab);
01414
01415 if( current_error < smallest_error )
01416 {
01417 index_of_closest = j;
01418 smallest_error = current_error;
01419 }
01420
01421 if( current_error < smallest_error_w_correct_label &&
01422 (strcmp(chCaps,chFind) == 0) )
01423 {
01424 index_of_closest_w_correct_label = j;
01425 smallest_error_w_correct_label = current_error;
01426 }
01427
01428
01429
01430
01431 if( current_error < errorwave )
01432 {
01433
01434
01435
01436
01437
01438 if( strcmp(chCaps,chFind) == 0 )
01439 {
01440
01441 ipobs = j;
01442
01443
01444 if( LineSv[LineSave.ipNormWavL].sumlin[LineSave.lgLineEmergent] > 0. )
01445 {
01446 *relint = LineSv[ipobs].sumlin[LineSave.lgLineEmergent]/LineSv[LineSave.ipNormWavL].sumlin[LineSave.lgLineEmergent]*
01447 LineSave.ScaleNormLine;
01448 }
01449 else
01450 {
01451 *relint = 0.;
01452 }
01453
01454
01455 if( LineSv[ipobs].sumlin[LineSave.lgLineEmergent] > 0. )
01456 {
01457 *absint = log10(LineSv[ipobs].sumlin[LineSave.lgLineEmergent]) + radius.Conv2PrtInten;
01458 }
01459 else
01460 {
01461
01462 *absint = -37.;
01463 }
01464
01465 DEBUG_EXIT( "cdLine()" );
01466
01467 return ipobs;
01468 }
01469 }
01470 }
01471
01472
01473
01474 fprintf( ioQQQ," PROBLEM cdLine did not find line with label %4s and wavelength ", chFind );
01475 prt_wl(ioQQQ,wavelength);
01476 if( index_of_closest >= 0 )
01477 {
01478 fprintf( ioQQQ,".\n The closest line (any label) was \t%4s\t", LineSv[index_of_closest].chALab );
01479 prt_wl(ioQQQ,LineSv[index_of_closest].wavelength );
01480
01481 fprintf( ioQQQ,"\n The closest with correct label was\t%4s\t", chFind );
01482 prt_wl(ioQQQ,LineSv[index_of_closest_w_correct_label].wavelength );
01483
01484 fprintf( ioQQQ,"\n" );
01485 }
01486 else
01487 {
01488 fprintf( ioQQQ,".\n PROBLEM No close line was found\n" );
01489 TotalInsanity();
01490 }
01491
01492 *absint = 0.;
01493 *relint = 0.;
01494
01495 DEBUG_EXIT( "cdLine()" );
01496
01497
01498
01499 return -LineSave.nsum;
01500 }
01501
01502
01503 void cdLine_ip(long int ipLine,
01504
01505 double *relint,
01506
01507 double *absint )
01508 {
01509
01510 DEBUG_ENTRY( "cdLine_ip()" );
01511
01512
01513 if( LineSave.nsum == 0 )
01514 {
01515 *relint = 0.;
01516 *absint = 0.;
01517 DEBUG_EXIT( "cdLine_ip()" );
01518 return;
01519 }
01520 ASSERT( LineSave.ipNormWavL >= 0);
01521 ASSERT( LineSave.nsum > 0);
01522
01523
01524 if( LineSv[LineSave.ipNormWavL].sumlin[LineSave.lgLineEmergent] > 0. )
01525 {
01526 *relint = LineSv[ipLine].sumlin[LineSave.lgLineEmergent]/LineSv[LineSave.ipNormWavL].sumlin[LineSave.lgLineEmergent]*
01527 LineSave.ScaleNormLine;
01528 }
01529 else
01530 {
01531 *relint = 0.;
01532 }
01533
01534
01535 if( LineSv[ipLine].sumlin[LineSave.lgLineEmergent] > 0. )
01536 {
01537 *absint = log10(LineSv[ipLine].sumlin[LineSave.lgLineEmergent]) + radius.Conv2PrtInten;
01538 }
01539 else
01540 {
01541
01542 *absint = -37.;
01543 }
01544
01545 DEBUG_EXIT( "cdLine_ip()" );
01546
01547 return;
01548 }
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558 long int cdDLine(char *chLabel,
01559
01560 float wavelength,
01561
01562 double *relint,
01563
01564 double *absint )
01565 {
01566 char chCaps[5],
01567 chFind[5];
01568 long int ipobs,
01569 j;
01570 float errorwave;
01571
01572 DEBUG_ENTRY( "cdDLine()" );
01573
01574
01575 if( LineSave.nsum == 0 )
01576 {
01577 *relint = 0.;
01578 *absint = 0.;
01579 DEBUG_EXIT( "cdDLine()" );
01580 return 0;
01581 }
01582 ASSERT( LineSave.ipNormWavL >= 0);
01583 ASSERT( LineSave.nsum > 0);
01584
01585
01586 cap4(chFind,chLabel);
01587
01588
01589 errorwave = WavlenErrorGet( wavelength );
01590
01591
01592
01593
01594
01595 for( j=1; j < LineSave.nsum; j++ )
01596 {
01597
01598
01599
01600
01601
01602
01603 if( fabs(LineSv[j].wavelength-wavelength) < errorwave )
01604 {
01605
01606
01607 cap4(chCaps , (char*)LineSv[j].chALab);
01608
01609
01610 if( strcmp(chCaps,chFind) == 0 )
01611 {
01612
01613 ipobs = j;
01614
01615
01616 if( LineSv[LineSave.ipNormWavL].sumlin[1] > 0. )
01617 {
01618 *relint = LineSv[ipobs].sumlin[1]/LineSv[LineSave.ipNormWavL].sumlin[1]*
01619 LineSave.ScaleNormLine;
01620 }
01621 else
01622 {
01623 *relint = 0.;
01624 }
01625
01626
01627 if( LineSv[ipobs].sumlin[1] > 0. )
01628 {
01629 *absint = log10(LineSv[ipobs].sumlin[1]) + radius.Conv2PrtInten;
01630 }
01631 else
01632 {
01633
01634 *absint = -37.;
01635 }
01636
01637 DEBUG_EXIT( "cdDLine()" );
01638
01639 return ipobs;
01640 }
01641 }
01642 }
01643
01644 *absint = 0.;
01645 *relint = 0.;
01646
01647 DEBUG_EXIT( "cdDLine()" );
01648
01649
01650
01651 return -LineSave.nsum;
01652 }
01653
01654
01655
01656
01657
01658
01659
01660 void cdNwcns(
01661
01662 bool *lgAbort_ret ,
01663
01664 long int *NumberWarnings,
01665 long int *NumberCautions,
01666 long int *NumberNotes,
01667 long int *NumberSurprises,
01668
01669 long int *NumberTempFailures,
01670
01671 long int *NumberPresFailures,
01672
01673 long int *NumberIonFailures,
01674
01675 long int *NumberNeFailures )
01676 {
01677
01678 DEBUG_ENTRY( "cdNwcns()" );
01679
01680
01681 *lgAbort_ret = lgAbort;
01682
01683 *NumberWarnings = warnings.nwarn;
01684 *NumberCautions = warnings.ncaun;
01685 *NumberNotes = warnings.nnote;
01686 *NumberSurprises = warnings.nbang;
01687
01688
01689 *NumberTempFailures = conv.nTeFail;
01690 *NumberPresFailures = conv.nPreFail;
01691 *NumberIonFailures = conv.nIonFail;
01692 *NumberNeFailures = conv.nNeFail;
01693
01694 DEBUG_EXIT( "cdNwcns()" );
01695 return;
01696 }
01697
01698
01699
01700
01701
01702
01703
01704 void cdOutp( FILE *ioOut)
01705 {
01706
01707 DEBUG_ENTRY( "cdOutp()" );
01708
01709
01710 ioQQQ = ioOut;
01711
01712 DEBUG_EXIT( "cdOutp()" );
01713 return;
01714 }
01715
01716
01717
01718
01719
01720
01721
01722 void cdInp( FILE *ioInp)
01723 {
01724
01725 DEBUG_ENTRY( "cdInp()" );
01726
01727
01728 ioStdin = ioInp;
01729
01730 DEBUG_EXIT( "cdInp()" );
01731 return;
01732 }
01733
01734
01735
01736
01737
01738
01739
01740 void cdTalk(bool lgTOn)
01741 {
01742
01743 DEBUG_ENTRY( "cdTalk()" );
01744
01745 called.lgTalk = lgTOn;
01746
01747 if( lgTOn )
01748 {
01749
01750 called.lgTalkForcedOff = false;
01751 }
01752 else
01753 {
01754
01755 called.lgTalkForcedOff = true;
01756 }
01757
01758 DEBUG_EXIT( "cdTalk()" );
01759 return;
01760 }
01761
01762
01763 double cdB21cm( void )
01764 {
01765 double ret;
01766
01767 DEBUG_ENTRY( "cdB21cm()" );
01768
01769 if( mean.B_HarMeanTempRadius[1] > SMALLFLOAT )
01770 {
01771 ret = mean.B_HarMeanTempRadius[0]/mean.B_HarMeanTempRadius[1];
01772 }
01773 else
01774 {
01775 ret = 0.;
01776 }
01777
01778 DEBUG_EXIT( "cdB21cm()" );
01779 return(ret);
01780 }
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01802
01803
01804 int cdTemp(
01805
01806 const char *chLabel,
01807
01808
01809 long int IonStage,
01810
01811 double *TeMean,
01812
01813 const char *chWeight )
01814 {
01815
01816 bool lgVol;
01817 long int ip,
01818 ion,
01819 nelem;
01820 float aaa[LIMELM + 1];
01821
01822 char chWGHT[INPUT_LINE_LENGTH] , chELEM[INPUT_LINE_LENGTH];
01823
01824 DEBUG_ENTRY( "cdTemp()" );
01825
01826
01827 strcpy( chWGHT, chWeight );
01828 caps(chWGHT);
01829
01830
01831 strcpy( chELEM, chLabel );
01832 caps(chELEM);
01833
01834
01835 if( strcmp(chWGHT,"RADIUS") == 0 )
01836 {
01837 lgVol = false;
01838 }
01839 else if( strcmp(chWGHT,"VOLUME") == 0 )
01840 {
01841 lgVol = true;
01842 }
01843 else
01844 {
01845 fprintf( ioQQQ, " cdTemp: chWeight=%6.6s makes no sense to me, the options are RADIUS and VOLUME.\n",
01846 chWeight );
01847 *TeMean = 0.;
01848
01849 DEBUG_EXIT( "cdTemp()" );
01850 return(1);
01851 }
01852
01853 if( IonStage == 0 )
01854 {
01855
01856 if( strcmp(chELEM,"21CM") == 0 )
01857 {
01858 if( lgVol )
01859 {
01860
01861 if( mean.HarMeanTempVolume[1] > SMALLFLOAT )
01862 {
01863 *TeMean = mean.HarMeanTempVolume[0]/mean.HarMeanTempVolume[1];
01864 }
01865 else
01866 {
01867 *TeMean = 0.;
01868 }
01869 }
01870 else
01871 {
01872
01873 if( mean.HarMeanTempRadius[1] > SMALLFLOAT )
01874 {
01875 *TeMean = mean.HarMeanTempRadius[0]/mean.HarMeanTempRadius[1];
01876 }
01877 else
01878 {
01879 *TeMean = 0.;
01880 }
01881 }
01882 }
01883
01884
01885 else if( strcmp(chELEM,"SPIN") == 0 )
01886 {
01887 *TeMean = mean.H_21cm_spin_mean_radius[0] /
01888 SDIV(mean.H_21cm_spin_mean_radius[1]);
01889 }
01890
01891 else if( strcmp(chELEM,"OPTI") == 0 )
01892 {
01893
01894 *TeMean =
01895 3.84e-7 * EmisLines[ipH_LIKE][ipHYDROGEN][ipH2p][ipH1s].TauCon /
01896 SDIV( HFLines[0].TauCon );
01897 }
01898
01899 else if( strcmp(chELEM,"H2 ") == 0 )
01900 {
01901 if( lgVol )
01902 {
01903
01904 if( mean.H2MeanTempVolume[1] > SMALLFLOAT )
01905 {
01906 *TeMean = mean.H2MeanTempVolume[0] / mean.H2MeanTempVolume[1];
01907 }
01908 else
01909 {
01910 *TeMean = 0.;
01911 }
01912 }
01913 else
01914 {
01915
01916 if( mean.H2MeanTempRadius[1] > SMALLFLOAT )
01917 {
01918 *TeMean = mean.H2MeanTempRadius[0] / mean.H2MeanTempRadius[1];
01919 }
01920 else
01921 {
01922 *TeMean = 0.;
01923 }
01924 }
01925 }
01926
01927 else if( strcmp(chELEM," ") == 0 )
01928 {
01929 if( lgVol )
01930 {
01931
01932 if( mean.TempMeanVolume[1] > SMALLFLOAT )
01933 {
01934 *TeMean = mean.TempMeanVolume[0]/mean.TempMeanVolume[1];
01935 }
01936 else
01937 {
01938 *TeMean = 0.;
01939 }
01940 }
01941 else
01942 {
01943
01944 if( mean.TempMeanRadius[1] > SMALLFLOAT )
01945 {
01946 *TeMean = mean.TempMeanRadius[0]/mean.TempMeanRadius[1];
01947 }
01948 else
01949 {
01950 *TeMean = 0.;
01951 }
01952 }
01953 }
01954 else
01955 {
01956 fprintf( ioQQQ, " cdTemp called with ion=0 and unknown quantity, =%4.4s\n",
01957 chLabel );
01958 fprintf( ioQQQ, " I know about 21CM and H2__ \n");
01959
01960 DEBUG_EXIT( "cdTemp()" );
01961 return(1);
01962 }
01963
01964 DEBUG_EXIT( "cdTemp()" );
01965
01966
01967 return(0);
01968 }
01969
01970
01971 nelem = 0;
01972 while( nelem < LIMELM &&
01973 strcmp(chELEM,elementnames.chElementNameShort[nelem]) != 0 )
01974 {
01975 ++nelem;
01976 }
01977
01978
01979
01980
01981 if( nelem >= LIMELM )
01982 {
01983 fprintf( ioQQQ, " cdTemp called with unknown element chLabel, =%4.4s\n",
01984 chLabel );
01985
01986 DEBUG_EXIT( "cdTemp()" );
01987 return(1);
01988 }
01989
01990
01991
01992
01993
01994
01995 ion = IonStage - 1;
01996
01997
01998 if( ion > nelem+1 || ion < 0 || ion > LIMELM )
01999 {
02000 fprintf( ioQQQ, " cdTemp asked to return ionization stage%4ld for element %4.4s but this is not physical.\n",
02001 IonStage, chLabel );
02002 DEBUG_EXIT( "cdTemp()" );
02003 return(1);
02004 }
02005
02006
02007 if( lgVol )
02008 {
02009
02010
02011 MeanIonVolume('t', nelem,&ip,aaa,false);
02012 *TeMean = pow(10.f,aaa[ion]);
02013 }
02014 else
02015 {
02016 MeanIonRadius('t', nelem,&ip,aaa,false);
02017 *TeMean = pow(10.f,aaa[ion]);
02018 }
02019
02020 DEBUG_EXIT( "cdTemp()" );
02021 return(0);
02022 }
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034 int cdRead(
02035
02036 char *chInputLine )
02037 {
02038 char *chEOL ,
02039 chCARD[INPUT_LINE_LENGTH],
02040 chLocal[INPUT_LINE_LENGTH];
02041
02042 DEBUG_ENTRY( "cdRead()" );
02043
02044
02045
02046 if( !lgcdInitCalled )
02047 {
02048 printf(" cdInit was not called first - this must be the first call.\n");
02049 puts( "[Stop in cdRead]" );
02050 cdEXIT(EXIT_FAILURE);
02051 }
02052
02053
02054
02055
02056 if( (lgInputComment( chInputLine )
02057
02058
02059 ||
02060
02061 (chInputLine[0]=='\n')||
02062 (chInputLine[0]==' ') )
02063
02064 &&
02065 !(chInputLine[0]=='C' || chInputLine[0]=='c' ) )
02066 {
02067
02068 DEBUG_EXIT( "cdRead()" );
02069 return(NKRD - input.nSave);
02070 }
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080 ++input.nSave;
02081
02082 if( input.nSave >= NKRD )
02083 {
02084
02085 fprintf( ioQQQ,
02086 " Too many line images entered to cdRead. The limit is %d\n",
02087 NKRD );
02088 fprintf( ioQQQ,
02089 " The limit to the number of allowed input lines is %d. This limit was exceeded. Sorry.\n",
02090 NKRD );
02091 fprintf( ioQQQ,
02092 " This limit is set by the variable NKRD which appears in input.h \n" );
02093 fprintf( ioQQQ,
02094 " Increase it everywhere it appears.\n" );
02095 puts( "[Stop in cdRead]" );
02096 cdEXIT(EXIT_FAILURE);
02097 }
02098
02099
02100
02101 if( (chEOL = strchr(chInputLine , '\n' ) ) !=NULL )
02102 {
02103 *chEOL = '\0';
02104 }
02105 if( (chEOL = strchr(chInputLine , '%' ) ) !=NULL )
02106 {
02107 *chEOL = '\0';
02108 }
02109
02110 if( (chEOL = strchr(chInputLine , '#' ) ) !=NULL )
02111 {
02112 *chEOL = '\0';
02113 }
02114 if( (chEOL = strchr(chInputLine , ';' ) ) !=NULL )
02115 {
02116 *chEOL = '\0';
02117 }
02118 if( (chEOL = strstr(chInputLine , "//" ) ) !=NULL )
02119 {
02120 *chEOL = '\0';
02121 }
02122
02123
02124
02125 chEOL = strchr(chInputLine , '\0' );
02126
02127
02128
02129 if( (chEOL==NULL) || (chEOL - chInputLine)>INPUT_LINE_LENGTH )
02130 {
02131
02132 chInputLine[INPUT_LINE_LENGTH-1] = '\0';
02133 fprintf(ioQQQ," cdRead, while parsing the following input line:\n %s\n",
02134 chInputLine);
02135 fprintf(ioQQQ," found that the line is longer than %i characters, the longest possible line.\n",
02136 INPUT_LINE_LENGTH);
02137 fprintf(ioQQQ," Please make the command line shorter than this limit.\n");
02138 }
02139
02140
02141
02142 if( (chEOL = strchr(chInputLine , '\0' )) == NULL )
02143 TotalInsanity();
02144
02145
02146
02147 strcpy( chLocal , chInputLine );
02148 if( chEOL-chInputLine <INPUT_LINE_LENGTH-4 )
02149 {
02150 strcat( chLocal , " " );
02151 }
02152
02153
02154 strcpy( input.chCardSav[input.nSave], chLocal );
02155
02156
02157 strcpy( chCARD, chLocal );
02158 caps(chCARD);
02159
02160
02161 if( strncmp(chCARD,"TRACE",5) == 0 )
02162 {
02163 trace.lgTraceInput = true;
02164 }
02165
02166
02167 if( trace.lgTraceInput )
02168 {
02169 fprintf( ioQQQ,"cdRead=%s=\n",input.chCardSav[input.nSave] );
02170 }
02171
02172
02173 if( nMatch("VARY",chCARD) )
02174 {
02175
02176 optimize.lgVaryOn = true;
02177 }
02178
02179
02180 if( strncmp(chCARD,"NO VARY",7) == 0 )
02181 {
02182 optimize.lgNoVary = true;
02183 }
02184
02185
02186 if( strncmp(chCARD,"GRID",4) == 0 )
02187 {
02188 grid.lgGrid = true;
02189 }
02190
02191
02192
02193 if( strncmp(chCARD,"NO BUFF",7) == 0 )
02194 {
02195
02196
02197
02198 FILE *test = stdout;
02199 if( ioQQQ == test )
02200 {
02201 fprintf( ioQQQ, " cdRead found NO BUFFERING command, redirecting output to stderr now.\n" );
02202
02203 fflush( ioQQQ );
02204
02205 ioQQQ = stderr;
02206
02207 input.lgSetNoBuffering = false;
02208 }
02209 }
02210
02211
02212 if( strncmp(chCARD,"OPTI",4) == 0 || strncmp(chCARD,"GRID",4) == 0 )
02213 {
02214
02215 optimize.lgOptimr = true;
02216 }
02217
02218 DEBUG_EXIT( "cdRead()" );
02219 return( NKRD - input.nSave );
02220 }
02221
02222
02223 void cdClosePunchFiles( void )
02224 {
02225
02226 DEBUG_ENTRY( "cdClosePunchFiles()" );
02227
02228 ClosePunchFiles();
02229
02230 DEBUG_EXIT( "cdClosePunchFiles()" );
02231 return;
02232 }
02233
02234 #if 0
02235
02236 double cdTemp21cmLya( void )
02237 {
02238 double t;
02239
02240 DEBUG_ENTRY( "cdTemp21cmLya()" );
02241
02242
02243
02244
02245
02246
02247
02248
02249 t =
02250 3.84e-7 * EmisLines[ipH_LIKE][ipHYDROGEN][ipH2p][ipH1s].TauCon /
02251 SDIV( HFLines[0].TauCon );
02252
02253 DEBUG_EXIT( "cdTemp21cmLya()" );
02254 return t;
02255 }
02256 #endif
02257
02258