#include <stdlib.h>
#include "intersci-n.h"
#include "crerhs.h"
Include dependency graph for crerhs.c:
Go to the source code of this file.
Functions | |
void | CreMATRIX (FILE *f, VARPTR var) |
void | CreCommon (FILE *f, VARPTR var) |
void | CreSTRING (FILE *f, VARPTR var) |
void | CreBMATRIX (FILE *f, VARPTR var) |
void | CreDIMFOREXT (FILE *f, VARPTR var) |
void | CreVECTOR (FILE *f, VARPTR var) |
void | CreCOLUMN (FILE *f, VARPTR var) |
void | CreSPARSE (FILE *f, VARPTR var) |
void | CreIMATRIX (FILE *f, VARPTR var) |
void | CrePOINTER (FILE *f, VARPTR var) |
void | CreSTRINGMAT (FILE *f, VARPTR var) |
void | CreSCALAR (FILE *f, VARPTR var) |
void | CreANY (FILE *f, VARPTR var) |
void | WriteCallRestCheck (FILE *f, VARPTR var, char *name, int iel, int flag) |
void | GetDim (char *lstr, IVAR ivar) |
Variables | |
CreRhsTab | CRERHSTAB [] |
int | indent |
int | pass |
static char | str [MAXNAM] |
static char | str1 [MAXNAM] |
static char | str2 [MAXNAM] |
static char | str3 [MAXNAM] |
static char | str4 [MAXNAM] |
void CreANY | ( | FILE * | f, | |
VARPTR | var | |||
) |
void CreBMATRIX | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 173 of file crerhs.c.
References BOOLEAN, CreMATRIX(), EXTERNAL, INT, SGetForType(), SGetSciType(), and var.
00176 { 00177 if (var->for_type == INT ) var->for_type = BOOLEAN; 00178 if (var->for_type != BOOLEAN && var->for_type != EXTERNAL ) 00179 { 00180 printf("incompatibility between the type %s and FORTRAN type %s for variable \"%s\"\n", 00181 SGetSciType(var->type),SGetForType(var->for_type),var->name); 00182 exit(1); 00183 } 00184 CreMATRIX(f,var); 00185 }
Here is the call graph for this function:
void CreCOLUMN | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 284 of file crerhs.c.
References AddDeclare1(), CreCommon(), DEC_INT, GetDim(), str1, str2, var, and WriteCallRestCheck().
00287 { 00288 char *lstr1 ; 00289 WriteCallRestCheck(f,var,"nn",0,0) ; 00290 GetDim(str1,var->el[0]); 00291 AddDeclare1(DEC_INT,"un=1"); 00292 AddDeclare1(DEC_INT,"mn%d",var->stack_position); 00293 lstr1 = ( str1[0]== '&' )? str1+1: str1; 00295 if ( strncmp(lstr1,"stk",3) ==0 || strncmp(lstr1,"istk",4)==0 00296 || strncmp(lstr1,"rstk",4)==0 || strncmp(lstr1,"cstk",4)==0 ) 00297 sprintf(str2,"(mn%d=*%s,&mn%d)",var->stack_position, 00298 lstr1,var->stack_position); 00299 else 00300 sprintf(str2,"(mn%d=%s,&mn%d)",var->stack_position, 00301 lstr1,var->stack_position); 00302 strcpy(str1,str2); 00303 strcpy(str2,"(un=1,&un)"); 00304 CreCommon(f,var); 00305 }
Here is the call graph for this function:
void CreCommon | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 98 of file crerhs.c.
References AddDeclare1(), ChangeForName2(), DEC_CPTR, DEC_DPTR, DEC_INT, DEC_IPTR, DEC_RPTR, DEC_UL, EXTERNAL, Fprintf(), indent, SGetForTypeAbrev(), SGetForTypeStack(), str1, str2, and var.
Referenced by CreCOLUMN(), CreMATRIX(), CreSCALAR(), CreSTRING(), and CreVECTOR().
00101 { 00102 if (var->for_type == EXTERNAL ) 00103 { 00104 Fprintf(f,indent,"/* external variable named %s (xxe%d) */\n",var->name,var->stack_position); 00105 AddDeclare1(DEC_INT,"me%d",var->stack_position); 00106 AddDeclare1(DEC_INT,"ne%d",var->stack_position); 00107 if ( strncmp(var->fexternal,"cintf",4)==0 ) 00108 AddDeclare1(DEC_IPTR,"le%d",var->stack_position); 00109 else if ( strncmp(var->fexternal,"cboolf",5)==0 ) 00110 AddDeclare1(DEC_IPTR,"le%d",var->stack_position); 00111 else if ( strncmp(var->fexternal,"cdoublef",7)==0 ) 00112 AddDeclare1(DEC_DPTR,"le%d",var->stack_position); 00113 else if (strncmp(var->fexternal,"ccharf",5)==0) 00114 AddDeclare1(DEC_CPTR,"le%d",var->stack_position); 00115 else if (strncmp(var->fexternal,"cfloatf",6)==0 ) 00116 AddDeclare1(DEC_RPTR,"le%d",var->stack_position); 00117 else 00118 AddDeclare1(DEC_UL,"le%d",var->stack_position); 00119 ChangeForName2(var,"&le%d",var->stack_position); 00121 } 00122 else 00123 { 00124 char *lstr1,*lstr2; 00125 if ( strncmp(str1,"&istk(",6)==0 || strncmp(str1,"&cstk(",6)==0 || strncmp(str1,"&rstk(",6)==0 00126 || strncmp(str1,"&stk(",5)==0 ) lstr1 = str1+1; 00127 else 00128 lstr1=str1; 00129 if ( strncmp(str2,"&istk(",6)==0 || strncmp(str2,"&cstk(",6)==0 || strncmp(str2,"&rstk(",6)==0 00130 || strncmp(str2,"&stk(",5)==0 ) lstr2 = str2+1; 00131 else 00132 lstr2=str2; 00133 00134 Fprintf(f,indent,"CreateVar(%d,\"%s\",%s,%s,&l%d);/* named: %s */\n", 00135 var->stack_position, 00136 SGetForTypeAbrev(var), 00137 lstr1,lstr2,var->stack_position, 00138 var->name); 00139 AddDeclare1(DEC_INT,"l%d",var->stack_position); 00140 ChangeForName2(var,"%s(l%d)",SGetForTypeStack(var), 00141 var->stack_position); 00142 } 00143 }
Here is the call graph for this function:
Here is the caller graph for this function:
void CreDIMFOREXT | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 192 of file crerhs.c.
References AddDeclare(), ChangeForName1(), CHAR, CSTRINGV, DEC_DOUBLE, DEC_INT, DEC_REAL, DOUBLE, Fprintf(), indent, INT, PREDEF, REAL, SGetForType(), str, and var.
00195 { 00196 if (var->nfor_name == 0 && var->for_type != PREDEF) 00197 { 00198 printf("dimension variable \"%s\" is not defined\n",var->name); 00199 exit(1); 00200 } 00201 switch (var->for_type) 00202 { 00203 case PREDEF: 00204 case 'C': 00205 if ( strcmp(var->name,"rhs") == 0) 00206 { 00207 AddDeclare(DEC_INT,"rhs"); 00208 Fprintf(f,indent,"rhs=Rhs;\n"); 00209 sprintf(str,"&rhs"); 00210 } 00211 else 00212 { 00213 sprintf(str,"&%s",var->name); 00214 } 00215 ChangeForName1(var,str); 00216 break; 00217 case 0: 00218 case INT: 00219 sprintf(str,"&%s",var->for_name[0]); 00220 if ( ~isdigit(str[1])) 00221 { 00222 ChangeForName1(var,str); 00223 } 00224 else 00225 { 00226 Fprintf(f,indent,"loc%s= (int) %s;\n", 00227 var->for_name[0],var->for_name[0]); 00228 sprintf(str,"loc%s",var->for_name[0]); 00229 AddDeclare(DEC_INT,str); 00230 sprintf(str,"&loc%s",var->for_name[0]); 00231 ChangeForName1(var,str); 00232 } 00233 break; 00234 case DOUBLE: 00235 Fprintf(f,indent,"loc%s= (double) %s;\n", 00236 var->for_name[0],var->for_name[0]); 00237 sprintf(str,"loc%s",var->for_name[0]); 00238 AddDeclare(DEC_DOUBLE,str); 00239 sprintf(str,"&loc%s",var->for_name[0]); 00240 ChangeForName1(var,str); 00241 break; 00242 case REAL: 00243 Fprintf(f,indent,"loc%s= (float) %s;\n",var->for_name[0],var->for_name[0]); 00244 sprintf(str,"loc%s",var->for_name[0]); 00245 AddDeclare(DEC_REAL,str); 00246 sprintf(str,"&loc%s",var->for_name[0]); 00247 ChangeForName1(var,str); 00248 break; 00249 case CHAR: 00250 case CSTRINGV: 00251 printf("a dimension variable cannot have FORTRAN type \"%s\"\n", 00252 SGetForType(var->for_type)); 00253 exit(1); 00254 break; 00255 } 00256 }
Here is the call graph for this function:
void CreIMATRIX | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 359 of file crerhs.c.
References AddDeclare1(), ChangeForName2(), DEC_INT, DEC_UL, EXTERNAL, Fprintf(), GetDim(), indent, SGetForTypeAbrev(), SGetForTypeStack(), str1, str2, str3, var, and WriteCallRestCheck().
00362 { 00363 WriteCallRestCheck(f,var,"it",2,0) ; 00364 GetDim(str3,var->el[2]); 00365 WriteCallRestCheck(f,var,"mm",1,0) ; 00366 GetDim(str2,var->el[1]); 00367 WriteCallRestCheck(f,var,"nn",0,0) ; 00368 GetDim(str1,var->el[0]); 00369 if (var->for_type == EXTERNAL) 00370 { 00371 AddDeclare1(DEC_UL,"ler%d",var->stack_position); 00372 AddDeclare1(DEC_UL,"lec%d",var->stack_position); 00373 AddDeclare1(DEC_INT,"ite%d",var->stack_position); 00374 ChangeForName2(var,"&ler%d,&lec%d,&ite%d",var->stack_position,var->stack_position,var->stack_position); 00376 } 00377 else 00378 { 00379 Fprintf(f,indent,"CreateCVar(%d,\"%s\",&%s,&%s,&%s,&lr%d,&lc%d);\n", 00380 var->stack_position,SGetForTypeAbrev(var), 00381 str3,str1,str2,var->stack_position,var->stack_position); 00382 AddDeclare1(DEC_INT,"lr%d",var->stack_position); 00383 AddDeclare1(DEC_INT,"lc%d",var->stack_position); 00384 AddDeclare1(DEC_INT,"it%d",var->stack_position); 00385 ChangeForName2(var,"%s(lr%d),%s(lc%d),&it%d", 00386 SGetForTypeStack(var), 00387 var->stack_position, 00388 SGetForTypeStack(var), 00389 var->stack_position,var->stack_position); 00390 } 00391 }
Here is the call graph for this function:
void CreMATRIX | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 79 of file crerhs.c.
References CreCommon(), GetDim(), str1, str2, str3, str4, var, and WriteCallRestCheck().
Referenced by CreBMATRIX().
00082 { 00083 WriteCallRestCheck(f,var,"mm",1,0) ; 00084 GetDim(str3,var->el[1]); 00085 WriteCallRestCheck(f,var,"nn",0,0) ; 00086 GetDim(str4,var->el[0]); 00087 if ( str3[0] == '&' || str3[0] == '(') 00088 sprintf(str2,"%s",str3); 00089 else 00090 sprintf(str2,"&%s",str3); 00091 if ( str4[0] == '&' || str4[0] == '(') 00092 sprintf(str1,"%s",str4); 00093 else 00094 sprintf(str1,"&%s",str4); 00095 CreCommon(f,var); 00096 }
Here is the call graph for this function:
Here is the caller graph for this function:
void CrePOINTER | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 398 of file crerhs.c.
References AddDeclare1(), ChangeForName2(), DEC_INT, DEC_UL, EXTERNAL, Fprintf(), indent, and var.
00401 { 00402 if (var->for_type == EXTERNAL) 00403 { 00404 AddDeclare1(DEC_UL,"le%d",var->stack_position); 00405 ChangeForName2(var,"&le%d",var->stack_position); 00407 } 00408 else 00409 { 00410 Fprintf(f,indent,"CreateOpointer(%d,&lr%d);\n", 00411 var->stack_position,var->stack_position); 00412 AddDeclare1(DEC_INT,"lr%d",var->stack_position); 00413 ChangeForName2(var,"stk(lr%d)", 00414 var->stack_position); 00415 } 00416 }
Here is the call graph for this function:
void CreSCALAR | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 462 of file crerhs.c.
References AddDeclare(), CreCommon(), DEC_INT, str1, str2, and var.
00465 { 00466 strcpy(str1,"&un"); 00467 strcpy(str2,"&un"); 00468 AddDeclare(DEC_INT,"un=1"); 00469 CreCommon(f,var); 00470 }
Here is the call graph for this function:
void CreSPARSE | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 312 of file crerhs.c.
References AddDeclare1(), ChangeForName2(), DEC_SPARSE, DEC_SPARSEPTR, EXTERNAL, Fprintf(), GetDim(), indent, m, n, str1, str2, var, variables, and WriteCallRestCheck().
00315 { 00316 WriteCallRestCheck(f,var,"mm",1,0) ; 00317 GetDim(str2,var->el[1]); 00318 WriteCallRestCheck(f,var,"nn",0,0) ; 00319 GetDim(str1,var->el[0]); 00320 if (var->for_type == EXTERNAL) 00321 { 00322 AddDeclare1(DEC_SPARSEPTR,"S%d",var->stack_position); 00323 ChangeForName2(var,"&S%d",var->stack_position); 00325 } 00326 else 00327 { 00328 VARPTR m,n; 00329 int origm,orign; 00330 m= variables[var->el[0]-1]; 00331 n= variables[var->el[1]-1]; 00332 /* here we must create a sparse variable 00333 * but str1 and str2 is not enough to create the matrix 00334 * we copy the argument which gives the size 00335 */ 00336 origm = ( m->nfor_name == 0)? -1 : m->for_name_orig[0]; 00337 orign = ( n->nfor_name == 0)? -1 : n->for_name_orig[0]; 00338 if ( origm != orign ) 00339 { 00340 fprintf(stderr,"A local sparse matrix can only be built as a copy of a sparse entry\n"); 00341 exit(1); 00342 } 00343 AddDeclare1(DEC_SPARSE,"S%d",var->stack_position); 00344 Fprintf(f,indent,"CreateVarFromPtr(%d,\"s\",&%s,&%s,&S%d);\n", 00345 var->stack_position, 00346 str1,str2,origm); 00347 Fprintf(f,indent,"GetRhsVar(%d,\"s\",&%s,&%s,&S%d);\n", 00348 var->stack_position, 00349 str1,str2,var->stack_position); 00350 ChangeForName2(var,"&S%d",var->stack_position); 00351 } 00352 }
Here is the call graph for this function:
void CreSTRING | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 149 of file crerhs.c.
References AddDeclare1(), CHAR, CreCommon(), DEC_INIT, DEC_INT, EXTERNAL, GetDim(), SGetForType(), SGetSciType(), str1, str2, STRING, var, and WriteCallRestCheck().
00152 { 00153 if (var->for_type != CHAR && var->for_type != EXTERNAL ) 00154 { 00155 printf("incompatibility between the type %s and FORTRAN type %s for variable \"%s\"\n", 00156 SGetSciType(STRING),SGetForType(var->for_type),var->name); 00157 exit(1); 00158 } 00159 AddDeclare1(DEC_INT,"n%d",var->stack_position); 00160 AddDeclare1(DEC_INIT,"n%d=1",var->stack_position); 00161 sprintf(str2,"&n%d",var->stack_position); 00162 WriteCallRestCheck(f,var,"nn",0,0) ; 00163 GetDim(str1,var->el[0]); 00164 CreCommon(f,var); 00165 }
Here is the call graph for this function:
void CreSTRINGMAT | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 423 of file crerhs.c.
References AddDeclare(), AddDeclare1(), AddForName1(), ChangeForName1(), CSTRINGV, DEC_INT, DEC_LOGICAL, DEC_SMAT, EXTERNAL, Fprintf(), indent, NULL, str, var, and WriteCallRestCheck().
00426 { 00427 if (var->for_type == EXTERNAL || var->for_type == CSTRINGV ) 00428 { 00429 /* for external or cstringv parameters, unknown formal dimensions 00430 can be used */ 00431 WriteCallRestCheck(f,var,"nsmm",0,1) ; 00432 WriteCallRestCheck(f,var,"nsnn",1,1) ; 00433 sprintf(str,"nsmm%d",var->stack_position); 00434 AddForName1(var->el[0],str,NULL,var->stack_position); 00435 sprintf(str,"nsnn%d",var->stack_position); 00436 AddForName1(var->el[1],str,NULL,var->stack_position); 00437 AddDeclare1(DEC_SMAT,"Str%d",var->stack_position); 00438 AddDeclare1(DEC_INT,"nsmm%d",var->stack_position); 00439 AddDeclare1(DEC_INT,"nsnn%d",var->stack_position); 00440 sprintf(str,"&Str%d",var->stack_position); 00441 ChangeForName1(var,str); 00442 } 00443 else 00444 { 00446 fprintf(stderr,"WARNING : your code contains a specification \n"); 00447 fprintf(stderr," not fully implemented in intersci \n"); 00448 WriteCallRestCheck(f,var,"mm",0,0) ; 00449 WriteCallRestCheck(f,var,"nn",1,0) ; 00450 AddDeclare(DEC_LOGICAL,"cresmatafaire"); 00451 Fprintf(f,indent,"if(.not.cresmatafaire(fname,top-rhs+%d,lr%d)) return\n",var->stack_position,var->stack_position); 00452 sprintf(str,"stk(lr%d)",var->stack_position); 00453 ChangeForName1(var,str); 00454 } 00455 }
Here is the call graph for this function:
void CreVECTOR | ( | FILE * | f, | |
VARPTR | var | |||
) |
Definition at line 262 of file crerhs.c.
References AddDeclare1(), CreCommon(), DEC_INT, GetDim(), str1, str2, var, and WriteCallRestCheck().
00265 { 00266 char *lstr1 ; 00267 WriteCallRestCheck(f,var,"nn",0,0) ; 00268 GetDim(str1,var->el[0]); 00269 AddDeclare1(DEC_INT,"un=1"); 00270 AddDeclare1(DEC_INT,"mn%d",var->stack_position); 00271 lstr1 = ( str1[0]== '&' )? str1+1: str1; 00273 if ( strncmp(lstr1,"stk",3) ==0 || strncmp(lstr1,"istk",4)==0 00274 || strncmp(lstr1,"rstk",4)==0 || strncmp(lstr1,"cstk",4)==0 ) 00275 sprintf(str2,"(mn%d=*%s,&mn%d)",var->stack_position, 00276 lstr1,var->stack_position); 00277 else 00278 sprintf(str2,"(mn%d=%s,&mn%d)",var->stack_position, 00279 lstr1,var->stack_position); 00280 strcpy(str1,"(un=1,&un)"); 00281 CreCommon(f,var); 00282 }
Here is the call graph for this function:
void GetDim | ( | char * | lstr, | |
IVAR | ivar | |||
) |
to be finished : Forname2Int is not finished fo C
Definition at line 529 of file crerhs.c.
References AddDeclare1(), DEC_INT, Forname2Int(), s, and variables.
Referenced by CreCOLUMN(), CreIMATRIX(), CreMATRIX(), CreSPARSE(), CreSTRING(), and CreVECTOR().
00530 { 00531 char *s; 00532 s=Forname2Int(variables[ivar-1],0); 00533 if ( strncmp(s,"stk",3)==0 || strncmp(s,"istk",4)==0 00534 || strncmp(s,"sstk",4)==0 || strncmp(s,"stk",3)==0 || 00535 strncmp(s,"cstk",4)==0 ) 00536 { 00537 sprintf(lstr,"%s",s); 00538 return ; 00539 } 00540 else 00541 { 00542 AddDeclare1(DEC_INT,s); 00543 sprintf(lstr,"%s",s); 00544 } 00545 }
Here is the call graph for this function:
Here is the caller graph for this function:
Definition at line 494 of file crerhs.c.
References AddForName1(), Fprintf(), indent, var::is_sciarg, lstr, MAXNAM, var::name, var::nfor_name, NULL, var::stack_position, var, and variables.
Referenced by CreCOLUMN(), CreIMATRIX(), CreMATRIX(), CreSPARSE(), CreSTRING(), CreSTRINGMAT(), CreVECTOR(), and WriteCallRest().
00495 { 00496 char sdim[MAXNAM]; 00497 char lstr[MAXNAM]; 00498 if (variables[var->el[iel]-1]->nfor_name == 0) 00499 { 00500 strcpy(lstr,variables[var->el[iel]-1]->name); 00501 if (isdigit(lstr[0]) == 0) 00502 { 00503 if ( variables[var->el[iel]-1]->is_sciarg == 1) 00504 { 00505 /* dimension of FORTRAN argument is a SCILAB argument */ 00506 sprintf(sdim,"%s%d",name,var->stack_position); 00507 Fprintf(f,indent,"%s= (int) *stk(lr%d));\n",sdim, 00508 variables[var->el[iel]-1]->stack_position); 00509 AddForName1(var->el[iel],sdim,NULL,var->stack_position); 00510 } 00511 else if ( flag != 1) 00512 { 00513 printf("dimension variable \"%s\" is not defined\n", 00514 variables[var->el[iel]-1]->name); 00515 exit(1); 00516 } 00517 } 00518 else 00519 { 00520 sprintf(sdim,"%s%d",name,var->stack_position); 00521 Fprintf(f,indent,"%s=%s;\n",sdim,lstr); 00522 AddForName1(var->el[iel],sdim,NULL,var->stack_position); 00523 } 00524 } 00525 }
Here is the call graph for this function:
Here is the caller graph for this function:
Initial value:
{ {DIMFOREXT,CreDIMFOREXT}, {COLUMN,CreCOLUMN}, {LIST,CreANY}, {TLIST,CreANY}, {MATRIX,CreMATRIX}, {POLYNOM,CreVECTOR}, {ROW,CreVECTOR}, {SCALAR,CreSCALAR}, {SEQUENCE,CreANY}, {STRING,CreSTRING}, {WORK,CreVECTOR}, {EMPTY,CreANY}, {ANY,CreANY}, {VECTOR,CreVECTOR}, {STRINGMAT,CreSTRINGMAT}, {SCIMPOINTER,CrePOINTER}, {IMATRIX,CreIMATRIX}, {SCISMPOINTER,CrePOINTER}, {SCILPOINTER,CrePOINTER}, {BMATRIX,CreBMATRIX}, {SCIBPOINTER,CrePOINTER}, {SCIOPOINTER,CrePOINTER}, {SPARSE,CreSPARSE} }
Definition at line 38 of file crerhs.c.
Referenced by WriteFortranCall(), and WriteOptArg().
Definition at line 36 of file niceprintf.c.
Definition at line 17 of file intersci-n.c.
char str3[MAXNAM] [static] |
Definition at line 72 of file crerhs.c.
Referenced by CreIMATRIX(), CreMATRIX(), OutCommon(), OutExtIMATRIX(), OutExtSPARSE(), OutIMATRIX(), WriteCallRest(), WriteExternalVariableOutput(), WriteVariableOutput(), XRotCreateTextItem(), XRotDrawHorizontalString(), and XRotTextExtents().
char str4[MAXNAM] [static] |
Definition at line 73 of file crerhs.c.
Referenced by CreMATRIX(), OutIMATRIX(), WriteCallRest(), WriteExternalVariableOutput(), and WriteVariableOutput().