/*ParsePunch parse the punch command */ #include #include "cddefines.h" #include "elementnames.h" #include "pnunit.h" #include "input.h" #include "ipdr.h" #include "iph2.h" #include "levery.h" #include "zonecnt.h" #include "ioreco.h" #include "optype.h" #include "mappar.h" #include "pop371.h" #include "date.h" #include "punconv.h" #include "punpoint.h" #include "punrlttype.h" #include "getelem.h" #include "getquote.h" #include "ffmtread.h" #include "lgmatch.h" #include "punlin.h" #include "physconst.h" #include "parse.h" void ParsePunch(char *chCard ) { char chLabel[81]; int lgEOL , lgHit ; /* pointer to column across line image for free format number reader*/ long int ipFFmt, i, j, nelem; static int lgFIRST=TRUE; # ifdef DEBUG_FUN fputs( "<+>ParsePunch()\n", debug_fp ); # endif /* on first call to this routine in this coreload, initialized array * to false to say that these files are not yet opened */ if( lgFIRST ) { for( j=0; j LIMPUN ) { fprintf( ioQQQ, "(The limit to the number of PUNCH options is%3ld. Increase LIMPUN in pnunit.h if more are needed.\n", LIMPUN ); puts( "[Stop in getpunch in getpunch]" ); exit(1); } /* LAST keyword is an option to only punch only on last iteration */ if( lgMatch("LAST",chCard) ) { pnunit.lgPunLstIter[pnunit.npunch] = TRUE; } else { pnunit.lgPunLstIter[pnunit.npunch] = FALSE; } /* NOCLOSE keyword is an option to keep punching into the same file */ if( lgMatch("NOCL",chCard) ) { pnunit.lgPunContinue[pnunit.npunch] = TRUE; } else { pnunit.lgPunContinue[pnunit.npunch] = FALSE; } /* * get file name for this punch output. * GetQuote does the following - * first copy original version of file name into chLabel, * string does include null termination. * set filename in OrgCard and second parameter to spaces so * that not picked up below as keyword */ GetQuote( chLabel , chCard ); /* only open the file if continue option is used and * it has not already been opened during a previous call */ if( !pnunit.lgUnitOpen[pnunit.npunch] ) { /* pnunit.npunch is set to 0 in ZERO, * this increment prevents overwriting punch files * pnunit.ipPnunit is the file pointer */ /* we now have the file name, let's open it */ /* open the file with the name generated above */ pnunit.ipPnunit[pnunit.npunch] = fopen( chLabel,"w" ); if( NULL == pnunit.ipPnunit[pnunit.npunch] ) { fprintf( ioQQQ, " ParsePunch could not open punch file %s for writing.\n", chLabel); puts( "[Stop in getpunch]" ); exit(1); } pnunit.lgUnitOpen[pnunit.npunch] = TRUE; } /* put version number and title of model on output file */ fprintf( pnunit.ipPnunit[pnunit.npunch], "%s %s\n", date.chVersion, input.chTitle ); /* this must come first since elements appear as sub-keywords */ if( lgMatch("OPAC",chCard) ) { strcpy( pnunit.chPunch[pnunit.npunch], "OPAC" ); if( lgMatch("TOTA",chCard) ) { /* DoPunch will call popac to parse the subcommands * punch total opacity */ strcpy( optype.chOpcTyp, "TOTL" ); fprintf( pnunit.ipPnunit[pnunit.npunch], " nu Tot opac Abs opac Scat opac Albedo\n" ); } else if( lgMatch("FIGU",chCard) ) { /* do figure for hazy */ strcpy( optype.chOpcTyp, "FIGU" ); fprintf( pnunit.ipPnunit[pnunit.npunch], " nu, H, He, tot opac\n" ); } else if( lgMatch("GRAI",chCard) ) { /* punch grain command, give optical properties of gains in calculation */ strcpy( pnunit.chPunch[pnunit.npunch], "DUSO" ); /* punch grain opacity command in twice, here and above in opacity * chDst = 'OPAC' */ fprintf( pnunit.ipPnunit[pnunit.npunch], " grain nu, total, absorpt, scat\n" ); } else if( lgMatch("SHEL",chCard) ) { /* punch shells, a form of the punch opacity command for showing subshell crossections*/ strcpy( pnunit.chPunch[pnunit.npunch], "OPAC" ); /* punch subshell cross sections */ strcpy( optype.chOpcTyp, "SHEL" ); /* this is element */ ipFFmt = 3; pnunit.punarg[0][pnunit.npunch] = (float)FFmtRead(chCard,&ipFFmt, 76,&lgEOL); /* this is ion */ pnunit.punarg[1][pnunit.npunch] = (float)FFmtRead(chCard,&ipFFmt, 76,&lgEOL); /* this is shell */ pnunit.punarg[2][pnunit.npunch] = (float)FFmtRead(chCard,&ipFFmt, 76,&lgEOL); if( lgEOL ) { fprintf( ioQQQ, " there must be io unit, atom wght, ion, shell\n" ); puts( "[Stop in getpunch]" ); exit(1); } fprintf( pnunit.ipPnunit[pnunit.npunch], " sub shell cross section\n" ); } else { /* punch elenent opacity, produces n name.n files, one for each stage of * ionization. the name is the 4-char version of the element's name, and * n is the stage of ionization. the file nameon the card is ignored. * The code Stop in getpunchs after these files are produced. */ /* this will be used as check that we did find an element on the command lines */ lgHit = FALSE; for( nelem=0; nelemParsePunch()\n", debug_fp ); # endif return; }