00001
00002
00003
00004 #include "cddefines.h"
00005 #include "thermal.h"
00006 #include "cooling.h"
00007 #define NCOLSAV 100
00008
00009 void coolpr(
00010 FILE * io,
00011
00012 const char *chLabel,
00013
00014 realnum lambda,
00015
00016 double ratio,
00017
00018 const char *chJOB
00019 )
00020 {
00021 static char chLabsv[NCOLSAV][NCOLNT_LAB_LEN+1];
00022
00023 static char chSig[NCOLSAV];
00024
00025 long int i,
00026 ipAr[NCOLSAV],
00027 j,
00028 limit;
00029
00030 static long int nCoolant = 0;
00031 static realnum sav[NCOLSAV];
00032
00033 realnum SavMax,
00034 scratch[NCOLSAV];
00035
00036 static realnum csav[NCOLSAV];
00037
00038 DEBUG_ENTRY( "coolpr()" );
00039
00040
00041
00042
00043 if( strcmp(chJOB,"ZERO") == 0 )
00044 {
00045
00046
00047 nCoolant = 0;
00048 for( i=0; i<NCOLSAV; ++i )
00049 {
00050 scratch[i] = FLT_MAX;
00051 ipAr[i] = LONG_MAX;
00052 }
00053 }
00054
00055 else if( strcmp(chJOB,"DOIT") == 0 )
00056 {
00057 strcpy( chLabsv[nCoolant], chLabel );
00058
00059 if( lambda < 10000. )
00060 {
00061 sav[nCoolant] = lambda;
00062 }
00063 else
00064 {
00065 sav[nCoolant] = lambda/10000.f;
00066 }
00067
00068 csav[nCoolant] = (realnum)ratio;
00069
00070 if( ratio < 0. )
00071 {
00072 chSig[nCoolant] = 'n';
00073 }
00074 else
00075 {
00076 chSig[nCoolant] = ' ';
00077 }
00078
00079
00080 ++nCoolant;
00081
00082
00083 if( nCoolant >= NCOLSAV )
00084 {
00085 fprintf( ioQQQ, " coolpr ran out of room, increase NCOLSAV.\n" );
00086 ShowMe();
00087 cdEXIT(EXIT_FAILURE);
00088 }
00089 }
00090
00091 else if( strcmp(chJOB,"DONE") == 0 )
00092 {
00093
00094 for( i=0; i < nCoolant; i++ )
00095 {
00096
00097 scratch[i] = (realnum)fabs(csav[i]);
00098 }
00099
00100 for( i=0; i < nCoolant; i++ )
00101 {
00102 SavMax = 0.;
00103
00104 ipAr[i] = -LONG_MAX;
00105
00106
00107 for( j=0; j < nCoolant; j++ )
00108 {
00109 if( scratch[j] > SavMax )
00110 {
00111 SavMax = scratch[j];
00112
00113 ipAr[i] = j;
00114 }
00115 }
00116
00117 ASSERT( i >= 0 && i < NCOLSAV );
00118 ASSERT( ipAr[i] >=0 && ipAr[i] < NCOLSAV );
00119
00120 scratch[ipAr[i]] = 0.;
00121 }
00122
00123
00124 for( j=0; j < nCoolant; j += 7 )
00125 {
00126 limit = MIN2(nCoolant,j+7);
00127 fprintf( io, " " );
00128 for( i=j; i < limit; i++ )
00129 {
00130 ASSERT( i < NCOLSAV );
00131
00132 fprintf( io,
00133 " %s %.2f%c%6.3f",
00134
00135 chLabsv[ipAr[i]],
00136
00137 sav[ipAr[i]],
00138
00139 chSig[ipAr[i]],
00140
00141 csav[ipAr[i]] );
00142 }
00143 fprintf( io, " \n" );
00144 }
00145 }
00146
00147 else
00148 {
00149 fprintf( ioQQQ, " coolpr called with insane job =%s=\n",chJOB );
00150 ShowMe();
00151 cdEXIT(EXIT_FAILURE);
00152 }
00153 return;
00154 }