/*punlin parse punch lines command, or actually do the punch output */ #include #include "cddefines.h" #include "cddrive.h" #include "radius.h" #include "ffmtread.h" #include "readar.h" #include "caps.h" #include "punlin.h" /* this is the limit to the number of lines we can store */ #define NPUNLM 100L void punlin(FILE * ip, /* the file we will write to */ char *chDo, int lgLog3) { char chCap[81], chCard[81]; static char chPLab[NPUNLM][5]; int lgEOF, lgEOL, lgOK; static int lgRelhld; long int i; static long int LineWavelength[NPUNLM], nLinesEntered; double a[32], absint, emiss, relint; double dlum[NPUNLM]; # ifdef DEBUG_FUN fputs( "<+>punlin()\n", debug_fp ); # endif if( strcmp(chDo,"READ") == 0 ) { /* very first time this routine is called, chDo is "READ" and we read * in lines from the input stream. The line labels and wavelengths * are store locally, and output in later calls to this routine */ lgRelhld = lgLog3; /* number of lines we will save */ nLinesEntered = 0; /* get the next line, and check for eof */ readar(chCard,&lgEOF); if( lgEOF ) { fprintf( ioQQQ, " Hit EOF while reading line list; use END to end list.\n" ); puts( "[Stop in punlin]" ); exit(1); } /* convert line to caps */ strcpy( chCap, chCard ); caps(chCap); while( strncmp(chCap, "END" ,3 ) != 0 ) { if( nLinesEntered >= NPUNLM ) { fprintf( ioQQQ, " Too many lines have been entered; the %ld limit is. Increase variable NPUNLM in routine punlin.\n", NPUNLM ); puts( "[Stop in punlin]" ); exit(1); } /* order on line is label (col 1-4), wavelength */ strncpy( chPLab[nLinesEntered], chCard , 4 ); /* null terminate the string*/ chPLab[nLinesEntered][4] = 0; /* now get wavelength */ i = 5; LineWavelength[nLinesEntered] = (long int)FFmtRead(chCard,&i,76,&lgEOL); /* this is total number stored so far */ ++nLinesEntered; /* get next line and check for eof */ readar(chCard,&lgEOF); if( lgEOF ) { fprintf( ioQQQ, " Hit EOF while reading line list; use END to end list.\n" ); puts( "[Stop in punlin]" ); exit(1); } /* convert it to caps */ strcpy( chCap, chCard ); caps(chCap); } fprintf( ip, "%li lines were entered, they were;\n", nLinesEntered ); for( i=0; i < nLinesEntered; i++ ) { fprintf( ip, "%s %ld\n", chPLab[i], LineWavelength[i] ); } } else if( strcmp(chDo,"PUNS") == 0 ) { /* punch lines structure command */ for( i=0; i < nLinesEntered; i++ ) { if( cdEms((char*)chPLab[i],LineWavelength[i],&emiss) ) { dlum[i] = emiss; } else { fprintf( ioQQQ, " PUNLIN could not fine line: %4.4s%5ld\n", chPLab[i], LineWavelength[i] ); puts( "[Stop in punlin]" ); exit(1); } } fprintf( ip, "%12.4e", radius.depth - radius.drad/2. ); for( i=0; i < nLinesEntered; i++ ) { fprintf( ip, "%12.4e", dlum[i] ); } fprintf( ip, "\n" ); } else if( strcmp(chDo,"PUNC") == 0 ) { /* punch lines cumulative command */ for( i=0; i < nLinesEntered; i++ ) { if( lgRelhld ) { lgOK = cdLine((char*)chPLab[i],LineWavelength[i],&a[i],&absint); } else { lgOK = cdLine((char*)chPLab[i],LineWavelength[i],&relint,&a[i]); } if( !lgOK ) { fprintf( ioQQQ, " PUNLIN could not fine line: %4.4s%5ld\n", chPLab[i], LineWavelength[i] ); puts( "[Stop in punlin]" ); exit(1); } } fprintf( ip, "%12.4e", radius.depth - radius.drad/2. ); for( i=0; i < nLinesEntered; i++ ) { fprintf( ip, "%12.4e", a[i] ); } fprintf( ip, "\n" ); } else { fprintf( ioQQQ, " unrecognized key for PUNLIN=%4.4s\n", chDo ); puts( "[Stop in punlin]" ); exit(1); } # ifdef DEBUG_FUN fputs( " <->punlin()\n", debug_fp ); # endif return; }