00001
00002 #define VERSION "2.2"
00003 #define DATE "September 2006"
00004
00005
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
00013
00014 #define TESTLISTELEMENTS 1
00015
00016
00017
00018
00019 #define MAXFUN 99
00020
00021 #include <stdio.h>
00022 #include <string.h>
00023 #include <ctype.h>
00024 #include <stdlib.h>
00025
00026
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
00035 #define PREDEF 9
00036 #define SMPOINTER 9
00037 #define LPOINTER 10
00038 #define BPOINTER 11
00039 #define OPOINTER 12
00040
00041
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
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
00076
00077 #define NAME 1
00078 #define VALUE 2
00079
00080 typedef int IVAR;
00081
00082
00083
00084 typedef struct var {
00085 char *name;
00086 int type;
00087 char Stype[20];
00088 int length;
00089 IVAR el[MAXEL];
00090
00091 int for_type;
00092 char *fexternal[MAXNAM];
00093
00094 IVAR equal;
00095 int nfor_name;
00096 int kp_state;
00097 char *for_name[MAXARG];
00098
00099 char *list_name;
00100 int list_el;
00101 int opt_type;
00102 char *opt_name;
00103 int present;
00104
00105
00106 } VAR, *VARPTR;
00107
00108
00109 typedef struct basfun {
00110 char *name;
00111 int nin;
00112 IVAR in[MAXARG];
00113 IVAR out;
00114 } BASFUN, *BASFUNPTR;
00115
00116
00117 typedef struct forsub {
00118 char *name;
00119 int narg;
00120 IVAR arg[MAXARG];
00121 } FORSUB, *FORSUBPTR;
00122
00123
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
00141
00142 VARPTR variables[MAXVAR];
00143 int nVariable;
00144 BASFUNPTR basfun;
00145 FORSUBPTR forsub;
00146 int nFun;
00147 int maxOpt;
00148 char *funNames[MAXFUN];
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));