Ejemplo n.º 1
0
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 );
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
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);
}
Ejemplo n.º 4
0
void CommentFunctionEnd( int f )
{
  WriteComment("End of %s function", varTable[ f ]->name );   
  WriteDelim();
  NewLines(2);
}