void MATLAB_FunctionBegin( int f, ... ) { Va_list args; int i; int v; int vars[20]; char * name; int narg; FILE *oldf; char buf[200], bufname[200]; time_t t; name = varTable[ f ]->name; narg = varTable[ f ]->maxi; /*Adi - each Matlab functin requires a separate file*/ sprintf( buf, "%s_%s.m", rootFileName, varTable[ f ]->name ); mex_funFile = fopen(buf, "w"); if( mex_funFile == 0 ) { FatalError(3,"%s: Can't create file", buf ); } UseFile( mex_funFile ); /*Adi*/ Va_start( args, f ); for( i = 0; i < narg; i++ ) vars[ i ] = va_arg( args, int ); va_end( args ); CommentFncBegin( f, vars ); WriteDelim(); WriteComment(""); WriteComment("Generated by KPP - symbolic chemistry Kinetics PreProcessor" ); WriteComment(" KPP is developed at CGRER labs University of Iowa by" ); WriteComment(" Valeriu Damian & Adrian Sandu" ); WriteComment(""); WriteComment("%-20s : %s", "File", buf ); strcpy( buf, (char*)ctime( &t ) ); buf[ (int)strlen(buf) - 1 ] = 0; WriteComment("%-20s : %s", "Time", buf ); WriteComment("%-20s : %s", "Working directory", getcwd(buf, 200) ); WriteComment("%-20s : %s", "Equation file", eqFileName ); WriteComment("%-20s : %s", "Output root filename", rootFileName ); WriteComment(""); WriteDelim(); NewLines(1); MATLAB_FunctionStart( f, vars ); NewLines(1); FlushBuf(); MapFunctionComment( f, vars ); }
void OpenFile( FILE **fpp, char *name, char * ext, char * identity ) { char bufname[200]; char buf[200]; time_t t; int blength; time( &t ); sprintf( bufname, "%s%s", name, ext ); if( *fpp ) fclose( *fpp ); *fpp = fopen( bufname, "w" ); if ( *fpp == 0 ) FatalError(3,"%s: Can't create file", bufname ); UseFile( *fpp ); WriteDelim(); WriteComment(""); WriteComment("%s",identity); WriteComment(""); WriteComment("Generated by KPP-%s symbolic chemistry Kinetics PreProcessor", KPP_VERSION ); WriteComment(" (http://www.cs.vt.edu/~asandu/Software/KPP)"); WriteComment("KPP is distributed under GPL, the general public licence"); WriteComment(" (http://www.gnu.org/copyleft/gpl.html)"); WriteComment("(C) 1995-1997, V. Damian & A. Sandu, CGRER, Univ. Iowa" ); WriteComment("(C) 1997-2005, A. Sandu, Michigan Tech, Virginia Tech" ); WriteComment(" With important contributions from:" ); WriteComment(" M. Damian, Villanova University, USA"); WriteComment(" R. Sander, Max-Planck Institute for Chemistry, Mainz, Germany"); WriteComment(""); WriteComment("%-20s : %s", "File", bufname ); strcpy( buf, ctime( &t ) ); buf[ (int)strlen(buf) - 1 ] = 0; WriteComment("%-20s : %s", "Time", buf ); WriteComment("%-20s : %s", "Working directory", getcwd(buf, 200) ); WriteComment("%-20s : %s", "Equation file", eqFileName ); WriteComment("%-20s : %s", "Output root filename", rootFileName ); WriteComment(""); WriteDelim(); NewLines(1); /* Include Headers in .c Files, except Makefile */ blength = strlen(bufname); if ( (bufname[blength-2]=='.')&&(bufname[blength-1]=='c') ) { C_Inline("#include <stdio.h>"); C_Inline("#include <stdlib.h>"); C_Inline("#include <math.h>"); C_Inline("#include <string.h>"); C_Inline("#include \"%s_Parameters.h\"", rootFileName); C_Inline("#include \"%s_Global.h\"", rootFileName); if( useJacSparse ) C_Inline("#include \"%s_Sparse.h\"", rootFileName); } NewLines(2); }
void F90_FunctionBegin( int f, ... ) { Va_list args; int i; int v; int vars[20]; char * name; int narg; FILE *oldf; name = varTable[ f ]->name; narg = varTable[ f ]->maxi; Va_start( args, f ); for( i = 0; i < narg; i++ ) vars[ i ] = va_arg( args, int ); va_end( args ); CommentFncBegin( f, vars ); F90_FunctionStart( f, vars ); NewLines(1); /* bprintf(" USE %s_Precision\n", rootFileName ); bprintf(" USE %s_Parameters\n\n", rootFileName ); */ /* bprintf(" IMPLICIT NONE\n" ); */ FlushBuf(); for( i = 0; i < narg; i++ ) F90_Declare( vars[ i ] ); bprintf("\n"); FlushBuf(); MapFunctionComment( f, vars ); }
void F90_InitDeclare( int v, int n, void * values ) { int i; VARIABLE * var; var = varTable[ v ]; var->maxi = max( n, 1 ); NewLines(1); F90_DeclareData( v, values, n ); }
/** * Calls Add on all the skipped items */ void AlignStack::ReAddSkipped() { if (!m_skipped.Empty()) { /* Make a copy of the ChunkStack and clear m_skipped */ m_scratch.Set(m_skipped); m_skipped.Reset(); const ChunkStack::Entry *ce; /* Need to add them in order so that m_nl_seqnum is correct */ for (int idx = 0; idx < m_scratch.Len(); idx++) { ce = m_scratch.Get(idx); LOG_FMT(LAS, "ReAddSkipped [%d] - ", ce->m_seqnum); Add(ce->m_pc, ce->m_seqnum); } /* Check to see if we need to flush right away */ NewLines(0); } }
void CommentFncBegin( int f, int *vars ) { VARIABLE *var; char * name; int narg; int i; name = varTable[ f ]->name; narg = varTable[ f ]->maxi; var = varTable[ f ]; WriteDelim(); WriteComment(""); WriteComment("%s - %s", var->name, var->comment ); WriteComment(" Arguments :"); for( i = 0; i < narg; i++ ) { var = varTable[vars[i]]; WriteComment(" %-10s- %s", var->name, var->comment ); } WriteComment(""); WriteDelim(); NewLines(1); }
void CommentFunctionEnd( int f ) { WriteComment("End of %s function", varTable[ f ]->name ); WriteDelim(); NewLines(2); }