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 cdEXIT(EXIT_FAILURE);
00049 }
00050
00051
00052 strcpy( chCAP, chCard );
00053 caps(chCAP);
00054
00055 while( strncmp(chCAP, "END" ,3 ) != 0 )
00056 {
00057 if( nColdenEntered >= NPUNLM )
00058 {
00059 fprintf( ioQQQ,
00060 " Too many lines have been entered; the %ld limit is. Increase variable NPUNLM in routine punch_colden.\n",
00061 NPUNLM );
00062 cdEXIT(EXIT_FAILURE);
00063 }
00064
00065
00066 strncpy( chElement[nColdenEntered], chCard , 4 );
00067
00068
00069 chElement[nColdenEntered][4] = 0;
00070
00071
00072 i = 5;
00073 ionstage[nColdenEntered] = (long)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00074 if( lgEOL )
00075 NoNumb( chCard );
00076
00077
00078 ++nColdenEntered;
00079
00080
00081 input_readarray(chCard,&lgEOF);
00082 if( lgEOF )
00083 {
00084 fprintf( ioQQQ, " Hit EOF while reading line list; use END to end list.\n" );
00085 cdEXIT(EXIT_FAILURE);
00086 }
00087
00088
00089 strcpy( chCAP, chCard );
00090 caps(chCAP);
00091 }
00092
00093
00094
00095
00096
00097 sprintf( chHeader , "#colden %s %3li", chElement[0] , ionstage[0] );
00098 for( i=1; i < nColdenEntered; i++ )
00099 {
00100 sprintf( chTemp, "\t%s %3li", chElement[i] , ionstage[i] );
00101 strcat( chHeader, chTemp );
00102 }
00103 strcat( chHeader, "\n" );
00104 }
00105
00106 else if( strcmp(chDo,"PUNS") == 0 )
00107 {
00108
00109 double colden;
00110
00111 for( i=0; i < nColdenEntered; i++ )
00112 {
00113 if( i )
00114 fprintf(ioPUN,"\t");
00115
00116 if( cdColm(
00117
00118 chElement[i],
00119
00120 ionstage[i],
00121
00122 &colden) )
00123 {
00124 fprintf( ioQQQ,
00125 "\n PROBLEM punch_colden could not find a column density for "
00126 "the species with label %s %li \n\n",
00127 chElement[i] , ionstage[i] );
00128 colden = 1.;
00129 }
00130 fprintf( ioPUN, "%.4f", log10( MAX2(SMALLFLOAT , colden ) ) );
00131 }
00132 fprintf( ioPUN, "\n" );
00133 }
00134
00135 else
00136 {
00137 fprintf( ioQQQ,
00138 " unrecognized key for punch_colden=%4.4s\n",
00139 chDo );
00140 cdEXIT(EXIT_FAILURE);
00141 }
00142
00143 return;
00144 }