/*ParseDriveCmnd parse the drive command - drive calls to various subs */ #include "cddefines.h" #include "trace.h" #include "moldrv.h" #include "taulines.h" #include "solar.h" #include "strbst.h" #include "ffmtread.h" #include "lgmatch.h" #include "drvhyas.h" #include "drvcasebhs.h" #include "dgaunt.h" #include "rtescprob.h" #include "conpmp.h" #include "parse.h" /* drive escape probability routines */ void DrvEscP( void ); void ParseDriveCmnd(char *chCard ) { int lgEOL; long int n, i; double fac, zed; # ifdef DEBUG_FUN fputs( "<+>ParseDriveCmnd()\n", debug_fp ); # endif /* NB evolve all following names to style DrvSomething */ /* option to drive cloudy, which one? */ if( lgMatch("FFMT",chCard) ) { fprintf( ioQQQ, " FFmtRead ParseDriveCmnd entered. Enter number.\n" ); lgEOL = FALSE; while( !lgEOL ) { if( fgets( chCard , sizeof(chCard) , stdin ) == NULL ) { fprintf( ioQQQ, " ParseDriveCmnd.dat error getting magic number\n" ); puts( "[Stop in ParseDriveCmnd]" ); exit(1); } i = 1; fac = FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { fprintf( ioQQQ, " FFmtRead hit the EOL with no value, return=%10.2e\n", fac ); break ; } else if( fac == 0. ) { break; } else { fprintf( ioQQQ, " FFmtRead returned with value%11.4e\n", fac ); } fprintf( ioQQQ, " Enter 0 to stop, or another value.\n" ); } fprintf( ioQQQ, " FFmtRead ParseDriveCmnd exits.\n" ); } else if( lgMatch("CASE",chCard) ) { /* option to interpolate on Hummer and Storey case b hydrogenic emission routines */ DrvCaseBHS( ); } else if( lgMatch("ESCA",chCard) ) { /* option to drive escape probability routines */ DrvEscP( ); } else if( lgMatch("HYAS",chCard) ) { /* option to drive Jason's hydrogen transition probabilities */ DrvHyas(); } else if( lgMatch("GAUN",chCard) ) { /* drive gaunt factor routine */ dgaunt(); } else if( lgMatch("POIN",chCard) ) { /* later on, check cell pointers, centers, widths */ fprintf( ioQQQ, " Define entire model first, later I will ask for energies.\n" ); trace.lgPtrace = TRUE; } else if( lgMatch("MOLE",chCard) ) { /* option to test molecule subroutine */ fprintf( ioQQQ, " Define entire model first, later I will ask for molecule abundances.\n" ); moldrv.lgDriveMole = TRUE; } else if( lgMatch("PUMP",chCard) ) { lgEOL = FALSE; fprintf( ioQQQ, " Continuum pump ParseDriveCmnd entered - Enter log tau\n" ); while( !lgEOL ) { if( fgets( chCard , sizeof(chCard) , stdin ) == NULL ) { fprintf( ioQQQ, " ParseDriveCmnd.dat error getting magic number\n" ); puts( "[Stop in ParseDriveCmnd]" ); exit(1); } /* get tau */ i = 1; fac = FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) break; fac = pow(10.,fac); fprintf( ioQQQ, " Tau =%11.4e\n", fac ); TauDummy.TauIn = (float)fac; fac = conpmp(&TauDummy); fprintf( ioQQQ, " conpmp =%11.4e\n", fac ); fprintf( ioQQQ, " Enter null to stop, or another value.\n" ); } fprintf( ioQQQ, " conpmp ParseDriveCmnd exits.\n" ); } else if( lgMatch("STAR",chCard) ) { /* get starburst abundances */ for( i=0; i < 40; i++ ) { zed = (float)(i+1)/4. + 0.01; sprintf( chCard, "starburst, zed=%10.4f", zed ); strbst(chCard); fprintf( ioQQQ, "%8.1e", zed ); for(n=0; n < LIMELM; n++) fprintf( ioQQQ, "%8.1e", solarCom.solar[n] ); fprintf( ioQQQ, "\n" ); } } else { fprintf( ioQQQ, " Unrecognized key; keys are FFmtRead, CASE, GAUNT, HYAS, POINT, MOLE, STAR, " "PUMP, and ESCApe. Sorry.\n" ); puts( "[Stop in ParseDriveCmnd]" ); exit(1); } # ifdef DEBUG_FUN fputs( " <->ParseDriveCmnd()\n", debug_fp ); # endif return; } /*DrvEscP user queries escape probability routines, which return values */ void DrvEscP( void ) { char chCard[135]; int lgEOL ; long i; double tau; # ifdef DEBUG_FUN fputs( "<+>DrvEscP()\n", debug_fp ); # endif /* this routine is enterd with the command escape probability, and * drives the escape probability routine to compare answers */ fprintf( ioQQQ, " Enter the log of the one-sided optical depth; line with no number to stop.\n" ); lgEOL = FALSE; while( !lgEOL ) { if( fgets( chCard , sizeof(chCard) , stdin ) == NULL ) { break; } i = 1; tau = FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { break; } tau = pow(10.,tau); fprintf( ioQQQ, "tau was %e\n", tau ); fprintf( ioQQQ, " ESCINC=%11.3e\n", escinc(tau,1e-4) ); fprintf( ioQQQ, " ESCCOM=%11.3e\n", esccom(tau,1e-4) ); fprintf( ioQQQ, " ESCA0K2=%11.3e\n", esca0k2(tau) ); } # ifdef DEBUG_FUN fputs( " <->DrvEscP()\n", debug_fp ); # endif return; }