//### //***************************************************************************** // * // Function Name: matrix * // * // File Name: matrix.cpp * // * // Purpose: This routine computes the elements of a symetrical matrix * // and stores them in their proper location. Only the upper * // diagonal matix is set up in this routine and reflected to the* // lower part in subroutine gauss. * // * // Author: Robert L. Reese * // * // Date: June 01, 1973 * // * // Language: Borland C++ Compiler, Version 4.5 * // * // Hardware: IBM Compatible PC * // * // Operating System: Microsoft Windows 98 * // * // Update History: * // * // Name Date Revision Changes * // ---- ---- --------- ------- * // * // R.L. Reese 06/01/73 0 Initial Release * // R.L. Reese 11/23/03 A Converted to C++ * // * //----------------------------------------------------------------------------* // * // Usage: * // * // matrix(output_unit) where: * // * // output_unit - FILE pointer to logical output listing unit * // * // * //----------------------------------------------------------------------------* // * // Definitions: * // * // Local Variables: * // ---------------- * // * // f - Double Precision variable used as Gibbs free energy for * // gaseous species * // i - Integer variable used as do loop index * // iq2 - Integer variable used as number of columns in matrix * // j - Integer variable used as do loop index * // k - Integer variable used as do loop index * // kk - Integer variable used as number of condensed species being * // considered in the present matrix * // kmat - Integer variable used to store number of columns in matrix * // loop_end - Logical variable used to go to end of loop * // term - Real variable used to sum mole fraction times stoiciometric* // coefficients of gaseous species * // * // Pointers * // ----------------- * // * // None * // * // Global Variables: * // ----------------- * // * // double.h * // g - Double precision array used as elements of the matrix * // indx.h * // imat - Integer variable used as number of rows in matrix * // iq1 - Integer variable used as number of elements plus the * // number of condensed species included in matrix * // equations plus one * // nlm - Integer variable used as number of elements in the * // system * // npt - Integer variable used as index for data saved for output* // ns - Integer variable used as number of species being * // considered in the system * // misc.h * // bo - Real array used as assigned Kg-atoms of element i per * // Kg of total reactant * // enn - Real variable used as moles of mixture, KG-mole/KG * // gamma - Real array used as fugacity coefficients for gases * // pp - Real variable used as assigned P for current point * // sumn - Real variable used as moles of mixture * // tm - Real variable used as log P/n * // tt - Real variable used as assigned T in kelvin for current * // point * // vol - Real variable used as molar volume of species * // speces.h * // a - Real variable used as stoichiometric coefficient of ith * // element in jth species * // en - Real array used as Kg-mole of jth species/ Kg of mixture* // enln - Real array used as log of en * // ho - Real array used as dimensionless enthalpy for species * // iuse - Integer array used to identify status of ith specie * // s - Real array used as dimensionless entropy calculated from* // coefficients for reaction species * // * // Constants: * // --------- * // * // local * // FALSE - Defines value of logical false = 0 * // r - Real value of universal gas constant * // TRUE - Defines value of logical true = 1 * // * // Include Files: * // -------------- * // * // arrays.h - Contains sizes for include files * // double.h - Contains double precision variables * // indx.h - Contains index variables * // misc.h - Contains miscellaneous variables * // speces.h - Contains species variables * // stdio.h - Contains C++ I/O functions * // * // External Software: * // ----------------- * // * // None * // * // Files: * // ----- * // * // Input Files: * // * // None * // * // Intermediate Files: * // * // None * // * // Output Files: * // * // None * // * //***************************************************************************** //### #include "arrays.h" #include "double.h" #include "indx.h" #include "misc.h" #include "speces.h" #include #define FALSE 0 #define TRUE 1 void matrix(FILE *output_unit) { #include "constant.h" // const float r = 8314.3/4184. ; int loop_end ; double f ; float term ; int i ; int iq2 ; int j ; int k ; int kk ; int kmat ; iq2 = iq1 + 1 ; kmat = iq2 ; imat = iq1 ; // Clear matrix storages to zero for(i=0;i= 0) { // start matrix_3 if(iuse[j] <= 0) { f = (ho[j]-s[j]+enln[j] + tm + gamma[j])*en[j][npt] ; // Calculate the elements g(i,k) // start matrix_4 for(i=0;i 1.0) { g[kk-1][kmat-1] = ho[j]-s[j]+((vol[j]*(pp-1.0))/(r*tt)) ; } // end matrix_9 } // matrix_7 } // end matrix_2 } // end matrix_1 g[iq1-1][iq1-1] = sumn - enn ; // Reflect symmetric portions of the matrix //start matrix_10 for(i=0;i #include #include "misc.h" #include #include #define FALSE 0 #define TRUE 1 // used by molewt and remove_and_add extern double aa[element_max] ; extern float bb[element_max] ; extern float to[element_max] ; extern int ll; extern int removed; int add_all; int call_react ; // used by molewt and increment_add int add_remove ; int loup_exit ; int increment ; int process_loop ; // used by molewt and increment_only float rtest ; float zerot ; void increment_add(void); void increment_only(void); void init(); void react(int *eof_pt, FILE *output_unit, FILE *input_unit); void remove_and_add(); void search(int *eof_pt, FILE *scratch_unit, FILE *therm_unit, FILE *output_unit); void molewt(int *eof_pt, FILE *output_unit, FILE *input_unit, FILE *scratch_unit, FILE *therm_unit) { #include "constant.h" int add_new ; int add_or_increment ; int add_reactant ; int bypass_search ; int i ; int reset_initial ; int store_values ; float tim ; add_all = FALSE ; add_new = FALSE ; add_or_increment = FALSE ; add_remove = FALSE ; call_react = FALSE ; increment = FALSE ; reset_initial = FALSE ; store_values = FALSE ; process_loop = TRUE ; nmin = 0 ; //start outer_loop do { // start finish_up if( ! reset_initial && ! add_all && ! add_remove && ! increment && ! call_react && ! reset_initial) { // Determine which system is being considered. // start molewt_1 if(alter) { increment = TRUE ; } else if(plus && tri != 0.0 && newmol < newmol_test) { store_values = TRUE ; } else if(plus && tri != 0.0 && newmol >= newmol_test) { add_or_increment = TRUE ; } else if(plus) { add_new = TRUE ; } else if(systm && newmol >= newmol_test) { add_or_increment = TRUE ; } else { removed = 1 ; ll = 1 ; store_values = TRUE ; } // end molewt_1 ; } // end finish_up // start process_flags if(add_or_increment) { // Should a new reactant be added or should the constant reactant // be incremented. // fprintf(output_unit," at add_or_increment\n"); add_or_increment = FALSE ; increment_add(); } else if(increment) { // Increment moles between included reactants. // fprintf(output_unit," at increment\n"); increment = FALSE ; increment_only(); react(eof_pt,output_unit,input_unit); // start molewt_21 if(*eof_pt !=0) { // exit outer_loop break; } // end molewt_21 ; increment = FALSE ; reset_initial = TRUE ; } else if(add_remove) { // Add and remove one reactant. // fprintf(output_unit," at add_remove\n"); add_remove = FALSE ; remove_and_add(); // Store base(i), top(i), and add(i) values. } else if(store_values) { // fprintf(output_unit," at store_values\n"); // start molewt_35 for(i = 0;i= newmol_test) { bypass_search = TRUE ; } else { // start molewt_45 if(systm && nmix > 1) { bypass_search = TRUE ; } // end molewt_45 ; } // end molewt_44 ; // Call function search to add or subtract species. // start molewt_46 if( ! bypass_search) { search(eof_pt,scratch_unit,therm_unit,output_unit); // start molewt_47 if(*eof_pt !=0) { // exit outer_loop break; } // end molewt_47 ; } // end molewt_46 ; call_react = FALSE ; reset_initial = TRUE ; } else if(reset_initial) { // Reset the initial estimates. // fprintf(output_unit," at reset_initial\n"); npt = 0 ; // fprintf(output_unit," Alter, Systm, Plus = "); // start alter_conversion // if(alter) // { // fprintf(output_unit,"T "); // } // else // { // fprintf(output_unit,"F "); // } // end alter_conversion // start systm_conversion // if(systm) // { // fprintf(output_unit,"T "); // } // else // { // fprintf(output_unit,"F "); // } // end systm_conversion // start plus_conversion // if(plus) // { // fprintf(output_unit,"T \n"); // } // else // { // fprintf(output_unit,"F \n"); // } // end plus_conversion init() ; reset_initial = FALSE ; process_loop = FALSE ; } // end process_flags } while (process_loop) ; //end outer_loop } // end function molewt //### //***************************************************************************** // * // Function Name: omit_insert * // * // File Name: omit_insert.cpp * // * // Purpose: Function called from search_coeff. It processes the * // omitted and inserted species and selects the species to be * // included in the current system or put into temporary * // storage. * // * // Author: Robert L. Reese * // * // Date: January 07, 2004 * // * // Language: Borland C++ Compiler, Version 4.5 * // * // Hardware: IBM Compatible PC * // * // Operating System: Microsoft Windows 98 * // * // Update History: * // * // Name Date Revision Changes * // ---- ---- --------- ------- * // * // R.L. Reese 01/07/04 0 Initial Release * // * //----------------------------------------------------------------------------* // * // Usage: * // * // omit_insert((break_flag_pt) * // where: * // * // break_flag_pt - Logical pointer to flag indicating if calling * // function needs to exit loop * // * //----------------------------------------------------------------------------* // * // Definitions: * // * // Local Variables: * // ---------------- * // * // exit_loop - Logical variable used to decide when to exit a loop * // i - Integer value used as do loop index * // j - Integer value used as do loop index * // k - Integer value used as do loop index * // kount - Integer value used to compute maxns * // kount1 - Integer value used as index for omits and inserts * // l - Integer value used as do loop index * // ni - Integer value used as first index of array a for * // specie being considered * // nmin_test - Logical variable used to test for minimum n * // * // Pointers * // ----------------- * // * // None * // * // Global Variables: * // ----------------- * // * // Used by search_coeff and omit_insert * // b - Real array containing stoichiometric coefficients of * // ith element read from the coefficient records * // begin_loop - Logical variable used as loop control * // insert_flag - Integer array used to flag legal insert species * // jj - Integer value used as counter for the number of * // elements to be put into temporary storage * // lmt - Character*4 array used as alphanumeric storage for the * // name of elements to be put into temporary storage in * // systm and plus problems * // maxns - Integer value used as maimum number of species allowed * // to be considered in the present system * // mt - Character*4 array used as alphanumeric symbol of the * // elemen read from the coefficient records * // nam - Character*4 array used as alphanumeric symbol of * // species name read from the coefficient records * // nm - Integer value used as number of species put into * // temporary storage * // omit_flag - Integer array used to flag legal omit species * // return_to_top- Logical variable used to test for returning to top of * // loop * // skip_to - Logical variable to test for skipping code * // test - Logical variable used to test if species is to be put * // into temporary storage * // indx.h * // newmol - Integer value used to determine if species should be * // input from the scratch file or the thermo file. * // nlm - Integer value used as number of elements in the system * // nmin - Integer value used as number of elements that are put * // into temporary storage for systm and plus problems * // nomit - Integer value containing number of species to be omitted* // ns - Integer value of number of species being considered in * // the system * // nsert - Integer number of species listed in insert records * // misc.h * // llmt - Character*4 array containing alphameric symbols for the * // elements in the system being studied * // vol - Real array containing molar volume of species * // speces.h * // a - Real array containing stoichiometric coefficients of ith* // element in jth species * // ensert - Character*4 array of ith specie of n species which are * // specified to be considered or input * // juse - Integer array containing variables used to identify * // which phase of a condensed specie should be used or if * // the spcie fits the T range being considered * // omit - Character*4 array containing names of specie to be * // omitted from current system * // * // Constants: * // --------- * // * // local * // FALSE - Defines value of logical false = 0 * // TRUE - Defines value of logical true = 1 * // arrays.h * // b_size - Integer variable used as size of b array * // element_max - Integer value of maximum number of elements allowed * // mt_size - Integer variable used as size of mt array * // size_char - Integer value used as len of char to replace default* // length of 4 characters in one word for FORTRAN 4 and* // FORTRAN 77 conversion * // species_max - Integer value of maximum number of species allowed * // sub_size - Integer variable used as maximum number of * // characters allowed in a name * // constant.h * // iblank - Character*1 containing a blank * // first_start - Integer value of start of first name * // jj_bug_fix - Integer value of fix for bug in temporary storage * // counter * // kount_reset - Integer value used to reset kount variable * // * // Include Files: * // ------------- * // * // arrays.h - Contains sizes for include files * // constant.h - Contains constants and sizes * // indx.h - Contains index variables * // misc.h - Contains miscellaneous variables * // speces.h - Contains species variables * // * // * // External Software: * // ----------------- * // * // None * // * // Files: * // ----- * // * // Input Files: * // * // None * // * // Intermediate Files: * // * // None * // * // Output Files: * // * // None * // * //***************************************************************************** //### #include "arrays.h" #include "indx.h" #include "misc.h" #include "speces.h" #define FALSE 0 #define TRUE 1 extern int begin_loop ; extern int jj; extern int maxns ; extern int nm ; extern int return_to_top ; extern int skip_to ; extern int test ; extern float b[b_size] ; extern int insert_flag[species_max]; extern int omit_flag[species_max]; extern char lmt[size_char][element_max] ; extern char mt[size_char][mt_size] ; extern char nam[size_char][sub_size] ; void omit_insert(int *break_flag_pt) { int exit_loop ; int i; int j; int k; int kount ; int kount1; int l ; int ni ; int nmin_test ; #include "constant.h" *break_flag_pt = FALSE; //start omit_insert_12 for(;;) { // start omit_insert_19 if( ! begin_loop) { *break_flag_pt = TRUE; // exit omit_insert_12 break; } // end omit_insert_19 // set jj to fix bug jj = jj_bug_fix ; // start omit_insert_20 if(newmol < 1) { // start omit_insert_21 if(nomit != 0) { // Is this species to be ommited? return_to_top = FALSE ; // start omit_insert_22 for(i=0;i= 1) { skip_to = FALSE ; // start omit_insert_44 for(l=0;l #include "misc.h" #include "points.h" #include "speces.h" #include #define FALSE 0 #define TRUE 1 void out1_moles(FILE *output_unit); double dltra ; double dtra ; int loop_exit ; int ncond_out ; double td ; double v[npt_out] ; void out1(FILE *output_unit) { #include "constant.h" float fug[npt_out] ; float qfmrel[npt_out] ; float tc[npt_out] ; float xiw ; int i ; int j ; int jj ; int jt ; int k ; int n ; // logical variables int not_empty ; // Zero out fug //start zero_fug for(i=0;i<=npt;i++) { fug[i] = 0.0; } // end zero_fug //start out1_1 if(newest) { fprintf(output_unit,"\t\t THERMODYNAMIC EQUILIBRIUM PROPERTIES AT\n\n"); fprintf(output_unit,"\t\t ASSIGNED TEMPERATURE AND PRESSURE\n\n"); fprintf(output_unit,(" CASE NO. %8d\n"),kase); fprintf(output_unit," INPUT COMPOSITION\t\t\t\t\t\t MOLES \n"); ncond_out = 0 ; // start out1_2 for( n = 0; n= 1.0 && v[n] >= v_limit) { // start out1_33 if(oxfug[n] > oxfug_val) { oxfug[n] = oxfug_val ; } // end out1_33 fug[n] = fug[n]+oxfug[n] ; } // end out1_32 } // end out1_31 fprintf(output_unit,"\n OXYGEN FUGACITY CALCULATIONS:\n"); fprintf(output_unit, " FO2 = XO2*FGO2\t\t "); // start fprintf_14 for(n=0;n<=npt;n++) { fprintf(output_unit,"%7.3f ",fug[n]); } // end fprintf_14 fprintf(output_unit,"\n"); fprintf(output_unit, " FO2 = CO/CO2 \t\t "); // start fprintf_15 for(n=0;n<=npt;n++) { fprintf(output_unit,"%7.3f ",fo2c[n]); } // end fprintf_15 fprintf(output_unit,"\n"); fprintf(output_unit, " FO2 = H2/H2O \t\t "); // start fprintf_16 for(n=0;n<=npt;n++) { fprintf(output_unit,"%7.3f ",fo2h[n]); } // end fprintf_16 fprintf(output_unit,"\n"); fprintf(output_unit, " QFI FO2 \t\t "); // start fprintf_17 for(n=0;n<=npt;n++) { fprintf(output_unit,"%7.3f ",qfmrel[n]); } // end fprintf_17 fprintf(output_unit,"\n"); } // end function out1 //### //***************************************************************************** // * // Function Name: out1_moles * // * // File Name: out1_moles.cpp * // * // Purpose: Used by out1 to output mole fractions and mole fractions for * // gases. * // * // Author: Robert L. Reese * // * // Date: January 29, 2004 * // * // Language: Borland C++ Compiler, Version 4.5 * // * // Hardware: IBM Compatible PC * // * // Operating System: Microsoft Windows 98 * // * // Update History: * // * // Name Date Revision Changes * // ---- ---- --------- ------- * // * // R.L. Reese 01/29/04 0 Initial Release * // * //----------------------------------------------------------------------------* // * // Usage: * // * // out1_moles(output_unit) where: * // * // output_unit - FILE pointer to output listing logical unit * // * //----------------------------------------------------------------------------* // * // Definitions: * // * // Local Variables: * // ---------------- * // * // i - Integer variable used as do loop index * // k - Integer variable used as do loop index * // * // Pointers * // ----------------- * // * // None * // * // Global Variables: * // ----------------- * // local - used by out1 and out1_moles * // dltra - Double precision variable used as dlog10 of dtra * // dtra - Double precision variable used as limit for trace species * // loop_exit - Logical variable used to exit do loop * // ncond_out - Integer variable used as counter for mole fractions of gas * // td - Double precision variable for totn and gtotn calculations * // v - Double precision array used to store mole fraction for * // output * // indx.h * // npt - Integer value of index for data saved for output * // ns - Integer value of number of species being considered in * // the system * // points.h * // gas_input - Logical value of Gas Input flag * // gtotn - Real array of values used in gas mole fractions * // totn - Real value used in calculation of mole fractions * // speces.h * // en - Real value of Kg-moles of jth species/Kg of mixture. * // iuse - Integer value used to identify status of ith species * // sub - Character*4 names of species read from thermo data file.* // * // Constants: * // --------- * // * // local * // FALSE - Defines value of logical false = 0 * // TRUE - Defines value of logical true = 1 * // arrays.h * // npt_out - Integer value of total points output on a page * // constant.h * // trace_limit - Real value of limit of trace * // * // Include Files: * // ------------- * // * // arrays.h - Contains sizes for include files * // constant.h - Contains out1 constants * // indx.h - Contains index variables * // math.h - Contains C++ math routines * // points.h - Contains temperature and pressure variables * // speces.h - Contains species variables * // stdio.h - Contains C++ I/O routines * // * // * // External Software: * // ----------------- * // * // log10 - C++ math library routine to find log value * // * // Files: * // ----- * // * // Input Files: * // * // None * // * // Intermediate Files: * // * // None * // * // Output Files: * // * // output_unit - Integer value of logical unit for output listing * // * //***************************************************************************** //### #include "arrays.h" #include "indx.h" #include #include "points.h" #include "speces.h" #include #define FALSE 0 #define TRUE 1 extern double dltra ; extern double dtra ; extern int loop_exit ; extern int ncond_out ; extern double td ; extern double v[npt_out] ; void out1_moles(FILE *output_unit) { #include "constant.h" int i; int k; // Define limit for trace species dtra = trace_limit ; dltra = log10(dtra) ; // Mole fractions - equilibrium. fprintf(output_unit,"\n MOLE FRACTIONS(TOTAL)\n"); //start out1_7 for( k = 0;k= dtra) { loop_exit = TRUE ; // exit out1_9 break; } // end out1_10 } // end out1_9 // start out1_11 if(loop_exit) { fprintf(output_unit," "); // start fprintf_8 for(i=0;i<8;i++) { fprintf(output_unit,"%c%c%c%c",sub[0][i][k], sub[1][i][k], sub[2][i][k], sub[3][i][k]); } // end fprintf_8 // start fprintf_9 for(i=0;i<=npt;i++) { fprintf(output_unit,"%9.5f",v[i]); } // end fprintf_9 fprintf(output_unit,"\n"); // start out1_12 if(iuse[k] > 0) { ncond_out = ncond_out + 1 ; } // end out1_12 } // end out1_11 } // end out1_7 //start out1_13 if(gas_input && ncond_out != 0) { fprintf(output_unit,"\n MOLE FRACTIONS(GASES)\n"); // start out1_14 for( k = 0;k= dtra) { loop_exit = TRUE ; // exit out1_17 break; } // end out1_18 } // end out1_17 // start out1_19 if(loop_exit) { fprintf(output_unit," "); // start fprintf_10 for(i=0;i<8;i++) { fprintf(output_unit,"%c%c%c%c",sub[0][i][k], sub[1][i][k], sub[2][i][k], sub[3][i][k]); } // end fprintf_10 // start fprintf_11 for(i=0;i<=npt;i++) { fprintf(output_unit,"%9.5f",v[i]); } // end fprintf_11 fprintf(output_unit,"\n"); } // end out1_19 } // end out1_15 } // end out1_14 } // end out1_13 } // end function out1_moles //### //***************************************************************************** // * // Function Name: process_pressure * // * // File Name: process_pressure * // * // Purpose: Reads the pressures from the input file and outputs them to * // the listing file. It checks for valid values. Pressures must * // be greater than zero bars. Temperatures are converted to * // Kelvin and must range from zero degrees to 5000 degrees * // Kelvin. Blanks are not interpreted as zero. If there are * // nine values in a record, there must be a blank record * // following that record. * // * // Author: Robert L. Reese * // * // Date: January 08, 2004 * // * // Language: Borland C++ Compiler, Version 4.5 * // * // Hardware: IBM Compatible PC * // * // Operating System: Microsoft Windows 98 * // * // Update History: * // * // Name Date Revision Changes * // ---- ---- --------- ------- * // * // R.L. Reese 01/07/04 0 Initial Release * // * //----------------------------------------------------------------------------* // * // Usage: * // * // process_pressure(output_unit, * // input_unit, * // break_value_pt, * // read_error_pt) * // where: * // * // output_unit - FILE pointer to logical output listing unit * // input_unit - FILE pointer to logical input unit * // break_flag_pt - Integer logical pointer to value indicating if loop * // needs to be exited upon return * // read_error_pt - Integer logical pointer indicating if error occurred * // on read * // * //----------------------------------------------------------------------------* // * // Definitions: * // * // Local Variables: * // ---------------- * // * // adata - Character buffer containing data returned from * // init_read * // blank - Character buffer containing blanks * // empty_file - Integer value of status returned from init_read * // eof - Integer value of status returned from init_read * // i - Integer for loop index * // input_end - Logical flag for end of temperature or pressure * // values * // j - Integer for loop index * // kount - Integer value of index for temp and pressures * // m - Integer for loop index * // nbytes - Integer value of number of bytes from init_read * // nbytes_count - Integer value used to determine if current p or * // t has been defaulted * // nmove - Integer value of number of digits to move from * // input record for reactant values * // pressure_index - Integer do loop index for processing pressure * // inputs * // real_buf - Real buffer used to contain current number to be * // converted from characters to float * // temp_index - Integer do loop index for processing temperature * // inputs * // tp_index - Integer value of index for outputting pressure * // temperature values * // tp_kount - Integer value for number of temps or pressures * // * // * // Pointers * // ----------------- * // * // adata_pt - Character pointer to data from init_read * // empty_file_pt - Integer pointer to empty file value from * // init_read * // end_ptr - Character pointer to error in strtod * // eof_pt - Integer pointer to eof value from init_read * // nbytes_pt - Integer pointer to number of bytes read from * // init_read * // real_buf_pt - Character pointer to buffer used for conversions * // * // Global Variables: * // ----------------- * // * // points.h * // p - Real values of P in bars that have been input * // pressure_number - Integer number of input pressure values * // t - Real values of T in Kelvin that have been input * // temp_number - Integer number of input temperature values * // * // Constants: * // --------- * // * // local * // FALSE - Defines value of logical false = 0 * // TRUE - Defines value of logical true = 1 * // arrays.h * // adata_len - Integer variable used as length of adata array * // blank_length - Integer variable used as length of blank array * // real_buf_len - Integer variable used as size of real_buf * // constants.h * // blank_index - Integer value pointing to start of blanked field * // count_decrement - Integer value to subtract from nbytes_count for * // pressure default test * // field_width - Integer value of output field width for pressures * // iblank - Character*1 containing a blank * // initial_nbytes - Integer value to ending position of first input * // pressure * // kelvin - Integer value of Kelvin conversion factor * // max_out_values - Integer value to number of output values per line * // max_t_p - Integer value of maximum number of values allowed * // max_temp - Real value of maximum temperature allowed * // round_up - Real value of value used to round up for below zero * // Kelvin test * // string_end - Character containing end of string control character * // t_p_default - Real value of input temperature or pressure input * // t_p_records - Integer value of number of temp or press records * // values_record - Integer value of maximum values per input record * // * // Include Files: * // ------------- * // * // arrays.h - Contains sizes for include files * // constant.h - Contains program constants * // iostream.h - Contains I/O routintes * // points.h - Contains temperature and pressure variables * // stdlib.h - Contains C++ standard library routines * // string.h - Contains C++ string routines * // * // * // External Software: * // ----------------- * // * // init_read - Routine to read input records * // stdio.h - Contains FILE declaration * // strncmp - C++ routine to compare strings * // strncpy - C++ routine to copy strings * // strtod - C++ routine to convert from ascii to float * // * // Files: * // ----- * // * // Input Files: * // * // FILE input_unit - Logical device for input reading * // * // Intermediate Files: * // * // None * // * // Output Files: * // * // FILE output_unit - logical device for output listings * // * //***************************************************************************** //### #include "arrays.h" #include #include "points.h" #include #include #include #define FALSE 0 #define TRUE 1 void init_read(char *idata, int *eof, FILE *opu, FILE *inp_unit, int *empty_file, int *nbytes); void process_pressure(FILE *output_unit, FILE *input_unit, int *break_value_pt, int *read_error_pt) { #include "constant.h" int empty_file; int eof; int i; int input_end; int j; int kount; int m; int nbytes; int nbytes_count; int nmove; int pressure_index ; int temp_index ; int tp_index; int tp_kount; char blank[blank_length]; char adata[adata_len]; char real_buf[real_buf_len]; char *adata_pt; int *empty_file_pt; char *end_ptr = "abcde"; int *eof_pt; int *nbytes_pt; char *real_buf_pt; adata_pt = &adata[0]; empty_file_pt = &empty_file; eof_pt = &eof; nbytes_pt = &nbytes; real_buf_pt = &real_buf[0]; //start initialize blank for(i=0;i (nbytes_count-1)) { nmove = field_width; } else { nmove = *nbytes_pt - (nbytes_count-field_width); } // end compute_pressure_moves strncpy(real_buf_pt,adata_pt+kount,nmove); // start press_all_blanks if(strncmp(real_buf_pt,&blank[0],blank_length)==0) { p[tp_kount] = t_p_default; input_end = TRUE; // exit convert_pressures break; } else { p[tp_kount] = strtod(real_buf_pt,&end_ptr); // start pressure_find_blanks for(m=blank_index;m>=0;m=m-1) { // start pressure_found_nonblank if(*(real_buf_pt+m) != iblank) { // exit pressure_find_blanks break; } // end pressure_found_nonblank } // end pressure_find_blanks // start pressure_error if(end_ptr != (real_buf_pt+(m+1))) { fprintf(output_unit, " Error in PRESSURE Value number %d\n",(tp_kount+1)); cout << " Error in PRESSURE Value number " << (tp_kount+1)<= tp_kount) { // exit pressure_output_others break; } // end pressure_output_others_first // start pressure_output_others_second if(j == i) { fprintf(output_unit,"\n %10.1f",p[j]); } else { // start output_pressure_partial if(j < max_t_p) { fprintf(output_unit,"%10.1f",p[j]); }// end output_pressure_partial } // end pressure_output_others_second } // end pressure_output_others // start pressure_output_others_third if(j >= tp_kount) { // exit pressure_output_rest break; } // end pressure_output_others_third } // end pressure_output_rest // start pressure_check for(pressure_index=0;pressure_index (max_temp - kelvin)) { fprintf(output_unit, "\n Error - Input Temperature %6.1f above %7.1f degrees Kelvin\n", t[temp_index],max_temp); cout << " Error - Input Temperature "< #include "misc.h" #include #include #include #define FALSE 0 #define TRUE 1 void clear_arrays(float *adata); void init_read(char *rdata, int *eof, FILE *opu, FILE *inp_unit, int *empty_file, int *nbytes); void read_react(FILE *output_unit, FILE *input_unit, int *read_status_pt, int *read_error_pt, int *n_pt, int *loop_again_pt, int *break_flag_pt); void system_type(FILE *output_unit, int *read_status_pt); void react(int *read_status_pt, FILE *output_unit, FILE *input_unit) { #include "constant.h" #include "atoms.h" float adata[element_max] ; float rm ; float wp ; int break_flag; int empty_file; int j ; int jj ; int kk ; int kl ; int kt ; int n ; int nbytes; int nj ; int read_error; // pointers float *adata_pt; char *atom_temp_pt; int *break_flag_pt; int *empty_file_pt; char *rdata_pt; int *loop_again_pt; int *n_pt; int *nbytes_pt; int *read_error_pt; // logical variables int exit_loop ; int go_back ; int go_to_rm ; int loop_again ; int loop_end ; int skip_code ; char rdata[rdata_len]; char atom_temp[atom_temp_len]; fpos_t pos; strncpy(atom_temp,ablank,atom_temp_len); // set pointers adata_pt = &adata[0]; break_flag_pt = &break_flag; empty_file_pt = &empty_file; rdata_pt = &rdata[0]; loop_again_pt = &loop_again; n_pt = &n; nbytes_pt = &nbytes; atom_temp_pt = &atom_temp[0]; read_error_pt = &read_error; read_error = FALSE; wp = 0.0 ; // Clear arrays clear_arrays(adata_pt); n = 0 ; nlm = 1 ; // read and write reactant records // start outer_loop for (;;) { skip_code = FALSE ; loop_again = FALSE ; // start react_1 if(newmol != 0) { skip_code = TRUE ; // start blank_test if(name[0][n][0] == iblank) { // exit outer_loop break; } // end blank_test } else { break_flag = FALSE; // read and process each reactant record read_react(output_unit, input_unit, read_status_pt, read_error_pt, n_pt, loop_again_pt, break_flag_pt); // start break_test if(br