00001
00002
00003
00004 #include "cddefines.h"
00005 #include "cddrive.h"
00006 #include "input.h"
00007 #include "save.h"
00008 #include "parser.h"
00009
00010 #define NPUNLM 100L
00011
00012 static char chElement[NPUNLM][5];
00013 static long int nColdenEntered;
00014 static long int ionstage[NPUNLM];
00015
00016
00017 void parse_save_colden(
00018 Parser &p,
00019
00020 char chHeader[] )
00021 {
00022 char chTemp[INPUT_LINE_LENGTH];
00023
00024 long int i;
00025
00026 DEBUG_ENTRY( "parse_save_colden()" );
00027
00028
00029
00030
00031
00032
00033 nColdenEntered = 0;
00034
00035
00036 p.getline();
00037 if( p.m_lgEOF )
00038 {
00039 fprintf( ioQQQ,
00040 " Hit EOF while reading line list; use END to end list.\n" );
00041 cdEXIT(EXIT_FAILURE);
00042 }
00043
00044 while( p.strcmp( "END" ) != 0 )
00045 {
00046 if( nColdenEntered >= NPUNLM )
00047 {
00048 fprintf( ioQQQ,
00049 " Too many lines have been entered; the %ld limit is. Increase variable NPUNLM in routine save_colden.\n",
00050 NPUNLM );
00051 cdEXIT(EXIT_FAILURE);
00052 }
00053
00054
00055 strncpy( chElement[nColdenEntered], p.getCommand(4).c_str() , 4 );
00056
00057
00058 chElement[nColdenEntered][4] = 0;
00059
00060
00061 ionstage[nColdenEntered] = (long)p.FFmtRead();
00062 if( p.lgEOL() )
00063 p.NoNumb("ion stage");
00064
00065
00066 ++nColdenEntered;
00067
00068
00069 p.getline();
00070 if( p.m_lgEOF )
00071 {
00072 fprintf( ioQQQ, " Hit EOF while reading line list; use END to end list.\n" );
00073 cdEXIT(EXIT_FAILURE);
00074 }
00075
00076 }
00077
00078
00079
00080
00081
00082 sprintf( chHeader , "#colden %s %3li", chElement[0] , ionstage[0] );
00083 for( i=1; i < nColdenEntered; i++ )
00084 {
00085 sprintf( chTemp, "\t%s %3li", chElement[i] , ionstage[i] );
00086 strcat( chHeader, chTemp );
00087 }
00088 strcat( chHeader, "\n" );
00089 }
00090
00091
00092 void save_colden(
00093
00094 FILE * ioPUN )
00095 {
00096 long int i;
00097
00098 DEBUG_ENTRY( "save_colden()" );
00099
00100
00101 double colden;
00102
00103 for( i=0; i < nColdenEntered; i++ )
00104 {
00105 if( i )
00106 fprintf(ioPUN,"\t");
00107
00108 if( cdColm(
00109
00110 chElement[i],
00111
00112 ionstage[i],
00113
00114 &colden) )
00115 {
00116 fprintf( ioQQQ,
00117 "\n PROBLEM save_colden could not find a column density for "
00118 "the species with label %s %li \n\n",
00119 chElement[i] , ionstage[i] );
00120 colden = 1.;
00121 }
00122 fprintf( ioPUN, "%.4f", log10( MAX2(SMALLFLOAT , colden ) ) );
00123 }
00124 fprintf( ioPUN, "\n" );
00125 }
00126