/*rdsum parse print line sum command to enter set of lines into sum */ #include #include "cddefines.h" #include "cddrive.h" #define NRDSUM 30L #include "fourpi.h" #include "linesave.h" #include "ffmtread.h" #include "readar.h" #include "rdsum.h" #include "caps.h" void rdsum(double *sum, char *chDo) { char chCCap[81], chCard[81]; static char chSMLab[NRDSUM][5]; int lgEND, lgEOF, lgEOL; long int i; static long int lamsm[NRDSUM], nlsum; double absint, relint; # ifdef DEBUG_FUN fputs( "<+>rdsum()\n", debug_fp ); # endif if( strncmp(chDo,"READ",4) == 0 ) { /* this call, read in lines */ nlsum = 0; lgEND = FALSE; while( !lgEND ) { readar(chCard,&lgEOF); if( lgEOF ) { fprintf( ioQQQ, " Hit EOF while reading line list; use END to end list.\n" ); puts( "[Stop in rdsum]" ); exit(1); } strcpy( chCCap, chCard ); caps(chCCap); if( strncmp(chCCap , "END" , 3) != 0 ) { nlsum += 1; if( nlsum > NRDSUM ) { fprintf( ioQQQ, " Too many lines have been entered; the %4ldlimit is. Increase variable NRDSUM.\n", NRDSUM ); puts( "[Stop in rdsum]" ); exit(1); } /* order on line is label (col 1-4), wavelength */ strncpy( chSMLab[nlsum-1], chCCap , 4 ); chSMLab[nlsum-1][4] = 0; i = 5; lamsm[nlsum-1] = (long int)FFmtRead(chCard,&i,76,&lgEOL); } else { lgEND = TRUE; } } } else if( strncmp(chDo," SUM" , 4) == 0 ) { *sum = 0.; /* this can be called during setup mode, in which case we do nothing */ if( LineSave.ipass <= 0 ) { # ifdef DEBUG_FUN fputs( " <->rdsum()\n", debug_fp ); # endif return; } for( i=0; i < nlsum; i++ ) { if( cdLine((char*)chSMLab[i],lamsm[i],&relint,&absint) ) { absint = pow(10.,absint - fourpi.pirsq); *sum += absint; } else { fprintf( ioQQQ, " RDSUM could not fine line %4.4s%5ld\n", chSMLab[i], lamsm[i] ); puts( "[Stop in rdsum]" ); exit(1); } } } else { fprintf( ioQQQ, " unrecognized key for RDSUM=%4.4s\n", chDo ); puts( "[Stop in rdsum]" ); exit(1); } # ifdef DEBUG_FUN fputs( " <->rdsum()\n", debug_fp ); # endif return; }