00001
00002
00003
00004 #include "cddefines.h"
00005 #include "cddrive.h"
00006 #include "input.h"
00007 #include "punch.h"
00008
00009 #define NPUNLM 100L
00010
00011
00012 void punch_colden(
00013
00014 char chHeader[] ,
00015
00016 FILE * ioPUN,
00017
00018 const char *chDo )
00019 {
00020 char chCAP[INPUT_LINE_LENGTH],
00021 chCard[INPUT_LINE_LENGTH];
00022 char chTemp[INPUT_LINE_LENGTH];
00023
00024 bool lgEOF,
00025 lgEOL;
00026 long int i;
00027 static char chElement[NPUNLM][5];
00028 static long int nColdenEntered;
00029 static long int ionstage[NPUNLM];
00030
00031 DEBUG_ENTRY( "punch_colden()" );
00032
00033 if( strcmp(chDo,"READ") == 0 )
00034 {
00035
00036
00037
00038
00039
00040 nColdenEntered = 0;
00041
00042
00043 input_readarray(chCard,&lgEOF);
00044 if( lgEOF )
00045 {
00046 fprintf( ioQQQ,
00047 " Hit EOF while reading line list; use END to end list.\n" );
00048 puts( "[Stop in punch_colden]" );
00049 cdEXIT(EXIT_FAILURE);
00050 }
00051
00052
00053 strcpy( chCAP, chCard );
00054 caps(chCAP);
00055
00056 while( strncmp(chCAP, "END" ,3 ) != 0 )
00057 {
00058 if( nColdenEntered >= NPUNLM )
00059 {
00060 fprintf( ioQQQ,
00061 " Too many lines have been entered; the %ld limit is. Increase variable NPUNLM in routine punch_colden.\n",
00062 NPUNLM );
00063 puts( "[Stop in punch_colden]" );
00064 cdEXIT(EXIT_FAILURE);
00065 }
00066
00067
00068 strncpy( chElement[nColdenEntered], chCard , 4 );
00069
00070
00071 chElement[nColdenEntered][4] = 0;
00072
00073
00074 i = 5;
00075 ionstage[nColdenEntered] = (long)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00076 if( lgEOL )
00077 NoNumb( chCard );
00078
00079
00080 ++nColdenEntered;
00081
00082
00083 input_readarray(chCard,&lgEOF);
00084 if( lgEOF )
00085 {
00086 fprintf( ioQQQ, " Hit EOF while reading line list; use END to end list.\n" );
00087 puts( "[Stop in punch_colden]" );
00088 cdEXIT(EXIT_FAILURE);
00089 }
00090
00091
00092 strcpy( chCAP, chCard );
00093 caps(chCAP);
00094 }
00095
00096
00097
00098
00099
00100 sprintf( chHeader , "#colden %s %3li", chElement[0] , ionstage[0] );
00101 for( i=1; i < nColdenEntered; i++ )
00102 {
00103 sprintf( chTemp, "\t%s %3li", chElement[i] , ionstage[i] );
00104 strcat( chHeader, chTemp );
00105 }
00106 strcat( chHeader, "\n" );
00107 }
00108
00109 else if( strcmp(chDo,"PUNS") == 0 )
00110 {
00111
00112 double colden;
00113
00114 for( i=0; i < nColdenEntered; i++ )
00115 {
00116 if( i )
00117 fprintf(ioPUN,"\t");
00118
00119 if( cdColm(
00120
00121 chElement[i],
00122
00123 ionstage[i],
00124
00125 &colden) )
00126 {
00127 fprintf( ioQQQ,
00128 " punch_colden: could not find a column density with label %s %li \n",
00129 chElement[i] , ionstage[i] );
00130 colden = 1.;
00131 }
00132 fprintf( ioPUN, "%.4f", log10( MAX2(SMALLFLOAT , colden ) ) );
00133 }
00134 fprintf( ioPUN, "\n" );
00135
00136 }
00137
00138 else
00139 {
00140 fprintf( ioQQQ,
00141 " unrecognized key for punch_colden=%4.4s\n",
00142 chDo );
00143 puts( "[Stop in punch_colden]" );
00144 cdEXIT(EXIT_FAILURE);
00145 }
00146
00147 DEBUG_EXIT( "punch_colden()" );
00148
00149 return;
00150 }
00151