intersci.h

Go to the documentation of this file.
00001 /* VERSION et DATE */
00002 #define VERSION "2.2"
00003 #define DATE "September 2006" 
00004 
00005 /* max dimension for the array: can be modified */
00006 #define MAXARG 50
00007 #define MAXCALL 2000
00008 #define MAXEL 50
00009 #define MAXLINE 1000
00010 #define MAXNAM 128
00011 #define MAXVAR 200
00012 /* flag for generation of type and element dimension checking for lists: 
00013    can be modified */
00014 #define TESTLISTELEMENTS 1
00015 
00016 /******************************************/
00017 /* DO NOT CHANGE ANYTHING BELOW THIS LINE */
00018 /******************************************/
00019 #define MAXFUN 99 /* maximum number of SCILAB functions */
00020 
00021 #include <stdio.h>
00022 #include <string.h>
00023 #include <ctype.h>
00024 #include <stdlib.h>
00025 
00026 /* FORTRAN variable types */ 
00027 #define CHAR 1
00028 #define INT 2
00029 #define DOUBLE 3
00030 #define REAL 4
00031 #define EXTERNAL 5
00032 #define CSTRINGV 6
00033 #define LOGICAL  7
00034 #define MPOINTER 8 /* pointer to Mat */
00035 #define PREDEF  9 /* err,rhs,lhs */
00036 #define SMPOINTER 9 /* pointer to SMat */
00037 #define LPOINTER 10 /* pointer to List */
00038 #define BPOINTER 11 /* pointer to BMat */
00039 #define OPOINTER 12 /* pointer to OBJ */
00040 
00041 /* Fortran Declaration */
00042 
00043 #define DEC_CHAR 1
00044 #define DEC_INT 2
00045 #define DEC_DOUBLE 3
00046 #define DEC_REAL 4
00047 #define DEC_LOGICAL  5
00048 #define DEC_DATA  6
00049 
00050 /* SCILAB variable types */
00051 
00052 #define COLUMN 1
00053 #define LIST 2
00054 #define TLIST 3
00055 #define MATRIX 4
00056 #define POLYNOM 5
00057 #define ROW 6
00058 #define SCALAR 7
00059 #define SEQUENCE 8
00060 #define STRING 9
00061 #define WORK 10
00062 #define EMPTY 11
00063 #define ANY 12
00064 #define VECTOR 13
00065 #define STRINGMAT 14
00066 #define SCIMPOINTER 15
00067 #define IMATRIX 16
00068 #define SCISMPOINTER 17
00069 #define SCILPOINTER 18
00070 #define BMATRIX 19
00071 #define SCIBPOINTER 20
00072 #define SCIOPOINTER 21
00073 #define SPARSE 22
00074 
00075 /* SCILAB optional variable types */
00076 
00077 #define NAME 1 /* {var default-name} */
00078 #define VALUE 2 /* {var default-value} */
00079 
00080 typedef int IVAR; /* variable number */
00081 
00082 /* VAR struct: informations for FORTRAN and/or SCILAB variable */
00083 
00084 typedef struct var {
00085   char *name; /* variable name */
00086   int type; /* SCILAB type */
00087   char Stype[20]; /* Scilab Type as string */
00088   int length; /* number of el */
00089   IVAR el[MAXEL]; /* list of el IVAR (variable associated with,
00090                      typically dimensions) */
00091   int for_type; /* FORTRAN type */
00092   char *fexternal[MAXNAM]; /* name of external function when type is
00093                               external */
00094   IVAR equal; /* ? */
00095   int nfor_name; /* number of for_name */
00096   int kp_state;  /* for pass dealing **/
00097   char *for_name[MAXARG]; /* list of for_name names (FORTRAN name
00098                            in generated FORTRAN code) */
00099   char *list_name; /* name of the list of which the variable is an element */
00100   int list_el; /* element number in the previous list */
00101   int opt_type; /* type of optional variable */
00102   char *opt_name; /* name or value default for optional variable */
00103   int present; /* 1 if the variable is really present in the description file
00104                   0 otherwise
00105                   used for list elements which might be not really present */
00106 } VAR, *VARPTR;
00107 
00108 /* BASFUN struct: informations for SCILAB function */
00109 typedef struct basfun {
00110   char *name; /* function name */
00111   int nin; /* number of arguments */
00112   IVAR in[MAXARG]; /* list of argument IVAR */
00113   IVAR out; /* output IVAR */
00114 } BASFUN, *BASFUNPTR;
00115 
00116 /* FORSUB struct: informations for FORTRAN subroutine */
00117 typedef struct forsub {
00118   char *name; /* subroutine name */
00119   int narg; /* number of arguments */
00120   IVAR arg[MAXARG]; /* list of argument IVAR */
00121 } FORSUB, *FORSUBPTR;
00122 
00123 /* memory allocators */
00124 
00125 VARPTR VarAlloc()
00126 {
00127   return((VARPTR) malloc(sizeof(VAR)));
00128 }
00129 
00130 BASFUNPTR BasfunAlloc()
00131 {
00132   return((BASFUNPTR) malloc(sizeof(BASFUN)));
00133 }
00134 
00135 FORSUBPTR ForsubAlloc()
00136 {
00137   return((FORSUBPTR) malloc(sizeof(FORSUB)));
00138 }
00139 
00140 /* global variables */
00141 
00142 VARPTR variables[MAXVAR]; /* array of VAR structures */
00143 int nVariable; /* number of variables */
00144 BASFUNPTR basfun; /* SCILAB function structure */
00145 FORSUBPTR forsub; /* FORTRAN subroutine structure */
00146 int nFun; /* total number of functions in "desc" file */
00147 int maxOpt; /* maximal number of optional variables */
00148 char *funNames[MAXFUN]; /* array of function names */
00149 
00152 #ifdef __STDC__
00153 #ifndef  __PARAMS
00154 #define  __PARAMS(paramlist)            paramlist
00155 #endif
00156 #else   
00157 #ifndef  __PARAMS
00158 #define  __PARAMS(paramlist)            ()
00159 #endif
00160 #endif
00161 
00162 void WriteInfoCode __PARAMS((FILE *f));
00163 int GetNumberInScilabCall __PARAMS((int ivar));
00164 int GetNumberInFortranCall __PARAMS((int ivar));
00165 char *SGetSciType __PARAMS((int type));
00166 char *SGetForType __PARAMS((int type));
00167 void AddForName __PARAMS((IVAR ivar, char *name));
00168 void ChangeForName __PARAMS((IVAR ivar, char *name));
00169 void Copyright __PARAMS((void));
00170 char *Forname2Int __PARAMS((char *str));
00171 void GenFundef __PARAMS((char *file, int interf));
00172 int GetBasType __PARAMS((char *sname));
00173 int GetForType __PARAMS((char *type));
00174 IVAR GetExistOutVar __PARAMS((void));
00175 IVAR GetExistVar __PARAMS((char *name));
00176 IVAR GetOutVar __PARAMS((char *name));
00177 IVAR GetVar __PARAMS((char *name, int p));
00178 void OptVar __PARAMS(());
00179 int ParseLine __PARAMS((char *s, char **words));
00180 int ParseScilabLine __PARAMS((char *s, char **words));
00181 int ReadListElement __PARAMS((FILE *f, char *varlistname, IVAR iivar, int nel));
00182 void ReadListFile __PARAMS((char *listname, char *varlistname, IVAR ivar));
00183 void ISCIReadFile __PARAMS((char *file));
00184 int ReadFunction __PARAMS((FILE *f));
00185 int TypeToBas __PARAMS(());
00186 void WriteArgCheck __PARAMS((FILE *f, int i));
00187 void WriteCall __PARAMS(());
00188 void WriteCallRest __PARAMS((FILE *f, IVAR ivar, int farg, char *call));
00189 void WriteCallConvertion __PARAMS((FILE *f, IVAR ivar, char *farg, char *barg, char *call));
00190 void WriteCrossCheck __PARAMS((FILE *f));
00191 void WriteEqualCheck __PARAMS((FILE *f));
00192 void WriteExternalVariableOutput __PARAMS((FILE *f, VARPTR var, int farg, int insidelist, int nel));
00193 void WriteFortranCall __PARAMS((FILE *f));
00194 void WriteFunctionCode __PARAMS((FILE *f));
00195 void WriteHeader __PARAMS((FILE *f, char *fname0, char *fname));
00196 void WriteMainHeader __PARAMS((FILE *f, char *fname));
00197 void WriteListAnalysis __PARAMS((FILE *f, int i));
00198 void WriteOutput __PARAMS((FILE *f));
00199 void WriteVariable __PARAMS((FILE *f, VARPTR var, IVAR ivar, int insidelist, int nel));
00200 void WriteVariableOutput __PARAMS((FILE *f, VARPTR var, int barg, int farg, int convert, int insidelist, int nel));
00201 void AddForName1 __PARAMS((IVAR ivar, char *name));
00202 void ForNameClean __PARAMS((void));
00203 void InitDeclare  __PARAMS((void));
00204 void ResetDeclare __PARAMS((void));
00205 void WriteMain  __PARAMS((FILE *f,char *file));
00206 void  FCprintf __PARAMS((FILE*,char *fmt,...));
00207 void  Fprintf __PARAMS((FILE*,int,char *format,...));
00208 void white __PARAMS( (FILE *f, int ind));
00209 void AddDeclare __PARAMS((int type, char *declaration));
00210 void InitDeclare __PARAMS((void));
00211 void ResetDeclare __PARAMS((void));
00212 void WriteDeclaration  __PARAMS((FILE*f));
00213 void WriteCallRestCheck __PARAMS((FILE *f, VARPTR var, int farg, char *name, int iel, int flag));
00214 int CreatePredefVar __PARAMS((char *name));
00215 void Check __PARAMS((FILE *f, char *str, VARPTR var, int i1, int nel));
00216 void OptvarGetSize __PARAMS((char *optvar, char *size, char *data));
00217 void WriteAddInter __PARAMS((char *file));

Generated on Sun Mar 4 15:03:57 2007 for Scilab [trunk] by  doxygen 1.5.1