cloudy
trunk
|
00001 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and 00002 * others. For conditions of distribution and use see copyright notice in license.txt */ 00003 /*prt_LineLabels punch all labels and wavelengths for emission line array */ 00004 /*sprt_wl write wavelength to string - must be kept parallel with prt_wl */ 00005 /*prt_wl - print floating wavelength in Angstroms, in output format */ 00006 #include "cddefines.h" 00007 #include "lines.h" 00008 #include "prt.h" 00009 00010 /*prt_wl print floating wavelength in Angstroms, in output format */ 00011 void prt_wl( FILE *ioOUT , realnum wl ) 00012 { 00013 char chString[100]; 00014 DEBUG_ENTRY( "prt_wl()" ); 00015 00016 sprt_wl( chString , wl ); 00017 00018 fprintf(ioOUT, "%s", chString ); 00019 return; 00020 } 00021 00022 /* write wavelength to string */ 00023 void sprt_wl( char *chString , realnum wl ) 00024 { 00025 char chUnits[10]; 00026 00027 DEBUG_ENTRY( "sprt_wl()" ); 00028 00029 /* print in A unless > 1e4, then use microns */ 00030 if( wl > 1e8 ) 00031 { 00032 /* centimeters */ 00033 strcpy( chUnits , "c" ); 00034 wl /= 1e8; 00035 } 00036 else if( wl > 1e4 ) 00037 { 00038 /* microns */ 00039 strcpy( chUnits , "m" ); 00040 wl /= 1e4; 00041 } 00042 else if( wl == 0. ) 00043 { 00044 strcpy( chUnits , " " ); 00045 } 00046 else 00047 { 00048 /* Angstroms units */ 00049 strcpy( chUnits , "A" ); 00050 } 00051 00052 /* want total of four sig figs */ 00053 if( LineSave.sig_figs == 4 ) 00054 { 00055 if( wl==0. ) 00056 { 00057 sprintf(chString, "%5i", 0 ); 00058 } 00059 else if( wl<10. ) 00060 { 00061 sprintf(chString, "%5.3f", wl ); 00062 } 00063 else if( wl<100. ) 00064 { 00065 sprintf(chString, "%5.2f", wl ); 00066 } 00067 else if( wl < 1e3 ) 00068 { 00069 sprintf(chString, "%5.1f", wl ); 00070 } 00071 else if( wl < 1e4 ) 00072 { 00073 sprintf(chString, "%5.0f", wl ); 00074 } 00075 else if( wl < 1e5 ) 00076 { 00077 sprintf(chString, "%5i", (int)wl ); 00078 } 00079 else 00080 { 00081 TotalInsanity(); 00082 } 00083 } 00084 else if( LineSave.sig_figs == 5 ) 00085 { 00086 /* this branch five sig figs */ 00087 if( wl==0. ) 00088 { 00089 sprintf(chString, "%5i", 0 ); 00090 } 00091 else if( wl<10. ) 00092 { 00093 sprintf(chString, "%5.4f", wl ); 00094 } 00095 else if( wl<100. ) 00096 { 00097 sprintf(chString, "%5.3f", wl ); 00098 } 00099 else if( wl < 1e3 ) 00100 { 00101 sprintf(chString, "%5.2f", wl ); 00102 } 00103 else if( wl < 1e4 ) 00104 { 00105 sprintf(chString, "%5.1f", wl ); 00106 } 00107 else if( wl < 1e5 ) 00108 { 00109 sprintf(chString, "%5.0f", wl ); 00110 } 00111 else if( wl < 1e6 ) 00112 { 00113 sprintf(chString, "%5i", (int)wl ); 00114 } 00115 else 00116 { 00117 TotalInsanity(); 00118 } 00119 } 00120 else 00121 { 00122 ASSERT( LineSave.sig_figs == 6 ); 00123 /* this branch five sig figs */ 00124 if( wl==0. ) 00125 { 00126 sprintf(chString, "%6i", 0 ); 00127 } 00128 else if( wl<10. ) 00129 { 00130 sprintf(chString, "%6.5f", wl ); 00131 } 00132 else if( wl<100. ) 00133 { 00134 sprintf(chString, "%6.4f", wl ); 00135 } 00136 else if( wl < 1e3 ) 00137 { 00138 sprintf(chString, "%6.3f", wl ); 00139 } 00140 else if( wl < 1e4 ) 00141 { 00142 sprintf(chString, "%6.2f", wl ); 00143 } 00144 else if( wl < 1e5 ) 00145 { 00146 sprintf(chString, "%6.1f", wl ); 00147 } 00148 else if( wl < 1e6 ) 00149 { 00150 sprintf(chString, "%6.0f", wl ); 00151 } 00152 else if( wl < 1e7 ) 00153 { 00154 sprintf(chString, "%6i", (int)wl ); 00155 } 00156 else 00157 { 00158 TotalInsanity(); 00159 } 00160 } 00161 strcat( chString , chUnits ); 00162 return; 00163 } 00164 00165 /*prt_LineLabels punch all labels and wavelengths for emission line array */ 00166 void prt_LineLabels( 00167 /* io file handle */ 00168 FILE * ioOUT , 00169 /* print all if true, if false then do not print parts of 00170 * transferred lines */ 00171 bool lgPrintAll ) 00172 { 00173 long int i; 00174 00175 DEBUG_ENTRY( "prt_LineLabels()" ); 00176 00177 for( i=0; i < LineSave.nsum; i++ ) 00178 { 00179 if( strcmp( LineSv[i].chALab , "####" )==0 ) 00180 { 00181 /*fprintf( ioOUT, "%s ", LineSv[i].chALab );*/ 00182 fprintf( ioOUT, "####\t%s",LineSave.chHoldComments[(int)LineSv[i].wavelength] ); 00183 } 00184 else 00185 { 00186 if( !lgPrintAll && 00187 (strcmp( LineSv[i].chALab , "Inwd" )==0 || 00188 strcmp( LineSv[i].chALab , "Coll" )==0 || 00189 strcmp( LineSv[i].chALab , "Pump" )==0 || 00190 strcmp( LineSv[i].chALab , "Heat" )==0) 00191 ) 00192 /* option to do not print lots of redundant labels 00193 * lgPrintAll is false by default set true with LONG option 00194 * on punch line labels command */ 00195 continue; 00196 /* this format chosen to be identical to that used by final */ 00197 fprintf( ioOUT, "%li\t%s\t", 00198 i, 00199 LineSv[i].chALab ); 00200 /* wavelength as given in printout */ 00201 prt_wl( ioOUT, LineSv[i].wavelength ); 00202 /* skip over leading spaces - a formatting problem */ 00203 long int j = 0; 00204 while( LineSv[i].chComment[j]!='\0' && LineSv[i].chComment[j]==' ') 00205 ++j; 00206 /* comment entered when line intensity generated */ 00207 fprintf( ioOUT , "\t%s" , &LineSv[i].chComment[j] ); 00208 } 00209 fprintf( ioOUT, "\n" ); 00210 } 00211 return; 00212 }