getrhs.c File Reference

#include <stdlib.h>
#include "intersci-n.h"
#include "getrhs.h"

Include dependency graph for getrhs.c:

Go to the source code of this file.

Functions

void GetMATRIX (FILE *f, var, int flag)
void GetCom (FILE *f, var, int flag)
void GetSTRING (FILE *f, var, int flag)
void GetBMATRIX (FILE *f, var, int flag)
void GetIMATRIX (FILE *f, var, int flag)
void GetSPARSE (FILE *f, var, int flag)
void GetSTRINGMAT (FILE *f, var, int flag)
void GetROW (FILE *f, var, int flag)
void GetCOLUMN (FILE *f, var, int flag)
void GetVECTOR (FILE *f, var, int flag)
void GetPOLYNOM (FILE *f, var, int flag)
void GetSCALAR (FILE *f, var, int flag)
void GetPOINTER (FILE *f, var, int flag)
void GetANY (FILE *f, var, int flag)
void GetLIST (FILE *f, var, int flag)
void GetTLIST (FILE *f, var, int flag)
void GetSEQUENCE (FILE *f, var, int flag)
void GetEMPTY (FILE *f, var, int flag)
void GetWORK (FILE *f, var, int flag)
void GetDIMFOREXT (FILE *f, var, int flag)
void Check (FILE *f, VARPTR var, int nel)
void CheckSquare (FILE *f, VARPTR var, char *str1_, char *str2_)

Variables

GetRhsTab RHSTAB []
int indent
int pass
static char str [MAXNAM]
static char str1 [MAXNAM]
static char str2 [MAXNAM]


Function Documentation

void Check ( FILE *  f,
VARPTR  var,
int  nel 
)

Definition at line 505 of file getrhs.c.

References Check, var::for_name, Fprintf(), indent, var::name, var::nfor_name, str2, var, and variables.

00509 {
00510   VARPTR var1 = variables[var->el[nel]-1];
00511   if ( var1->nfor_name == 0) 
00512     {
00513       fprintf(stderr,"Pb with element number %d [%s] of variable %s\n",
00514               nel+1, var1->name, var->name);
00515       return;
00516     }
00517   if (isdigit(var1->name[0]) != 0) 
00518     {
00519       /* the dimension of the variable is a constant integer */
00520       if ( strcmp(var1->for_name[0],var1->name) != 0) 
00521         {
00522           if (var->list_el ==0 )
00523             {
00524               Fprintf(f,indent,"CheckOneDim(%d,%d,%s,%s);\n",
00525                       var->stack_position,
00526                       nel+1,
00527                       var1->for_name[0],var1->name);
00528             }
00529           else
00530             {
00531               Fprintf(f,indent,"CheckListOneDim(%s,%d,%d,%s,%s);\n",
00532                       str2,
00533                       var->list_el,
00534                       nel+1,
00535                       var1->for_name[0],var1->name);
00536             }
00537         }
00538     }
00539 }

Here is the call graph for this function:

void CheckSquare ( FILE *  f,
VARPTR  var,
char *  str1_,
char *  str2_ 
)

Definition at line 544 of file getrhs.c.

References Fprintf(), indent, and var.

00545 {
00546   if (var->el[0] != var->el[1]) return ;
00547   if (var->list_el ==0 )
00548     {
00549       Fprintf(f,indent,"CheckSquare(%d,m%s,n%s);\n", var->stack_position,str1_,str1_);
00550     }
00551   else 
00552     {
00553       Fprintf(f,indent,"CheckListSquare(%s,%d,m%s,n%s);\n",str2_, var->list_el,str1_,str1_);
00554     }  
00555 }

Here is the call graph for this function:

void GetANY ( FILE *  f,
var  ,
int  flag 
)

Definition at line 460 of file getrhs.c.

00460                                                         {
00461   fprintf(stderr,"Wrong type in Get function \n");
00462   exit(1);
00463 }

void GetBMATRIX ( FILE *  f,
var  ,
int  flag 
)

Definition at line 130 of file getrhs.c.

References BOOLEAN, Check, CheckSquare, GetCom(), INT, SGetForType(), SGetSciType(), str1, str2, and var.

00132 {
00133   if (var->for_type != INT && var->for_type != BOOLEAN)
00134     {
00135       printf("incompatibility between the type %s and FORTRAN type %s for variable \"%s\"\n",
00136              SGetSciType(var->type),SGetForType(var->for_type),var->name);
00137       exit(1);
00138     }
00139   var->for_type = BOOLEAN;
00140   GetCom(f,var,flag);
00142   CheckSquare(f,var,str1,str2); 
00143   Check(f,var,0);
00144   Check(f,var,1);
00145 }

Here is the call graph for this function:

void GetCOLUMN ( FILE *  f,
var  ,
int  flag 
)

Definition at line 315 of file getrhs.c.

References AddDeclare1(), Check, DEC_INT, Fprintf(), GetCom(), i1, indent, str1, and var.

00316 {
00317   int i1= var->stack_position;
00318   GetCom(f,var,flag);
00319   Check(f,var,0);
00320   if (var->list_el ==0 )
00321     {
00322       Fprintf(f,indent,"CheckColumn(%d,m%d,n%d);\n",i1,i1,i1);
00323       Fprintf(f,indent,"mn%d=m%d*n%d;\n",i1,i1,i1);
00324       AddDeclare1(DEC_INT,"mn%d",i1);
00325     }
00326   else 
00327     {
00328       sprintf(str1,"%de%d",i1,var->list_el);
00329       Fprintf(f,indent,"CheckListColumn(%d,%d,m%s,n%s);\n",i1,var->list_el,str1,str1);
00330       Fprintf(f,indent,"l%dmn%d=m%s*n%s;\n",i1,var->list_el,str1,str1);
00331       AddDeclare1(DEC_INT,"l%dmn%d",i1,var->list_el);
00332     }
00333 }

Here is the call graph for this function:

void GetCom ( FILE *  f,
var  ,
int  flag 
)

common function for different data types

A scilab matrix argument

A scilab matrix argument inside a list

Definition at line 75 of file getrhs.c.

References AddDeclare1(), C, ChangeForName2(), DEC_INT, Fprintf(), i1, indent, SGetForTypeAbrev(), SGetForTypeStack(), str1, str2, and var.

Referenced by GetBMATRIX(), GetCOLUMN(), GetMATRIX(), GetROW(), GetSCALAR(), GetSTRING(), and GetVECTOR().

00077 {
00078   static char C[]="GetRhsVar(%s,\"%s\",&m%d,&n%d,&l%d);\n";
00079   static char LC[]="GetListRhsVar(%s,%d,\"%s\",&m%s,&n%s,&l%s);\n";
00080   int i1= var->stack_position;
00081   if ( flag == 1 ) 
00082     sprintf(str2,"k");
00083   else
00084     sprintf(str2,"%d",i1);
00085   if (var->list_el ==0 )
00086     {
00088       sprintf(str1,"%d",i1);
00089       Fprintf(f,indent,C,str2,SGetForTypeAbrev(var),i1,i1,i1);
00090       /* Adding the calling sequence in the for_names  */ 
00091       ChangeForName2(var,"%s(l%s)",SGetForTypeStack(var),str1);
00092     }
00093   else
00094     {
00096       sprintf(str1,"%de%d",i1,var->list_el);
00097       Fprintf(f,indent,LC,str2,var->list_el,SGetForTypeAbrev(var),str1,str1,str1,str1);
00098       /* Adding the calling sequence in the for_names  */ 
00099       ChangeForName2(var,"%s(l%s)",SGetForTypeStack(var),str1);
00100     }
00101   AddDeclare1(DEC_INT,"m%s",str1);
00102   AddDeclare1(DEC_INT,"n%s",str1);
00103   AddDeclare1(DEC_INT,"l%s",str1);
00104 }

Here is the call graph for this function:

Here is the caller graph for this function:

void GetDIMFOREXT ( FILE *  f,
var  ,
int  flag 
)

Definition at line 494 of file getrhs.c.

00495 {  
00496   fprintf(stderr,"Wrong type in Get function \n");
00497   exit(1);
00498 }

void GetEMPTY ( FILE *  f,
var  ,
int  flag 
)

Definition at line 481 of file getrhs.c.

00482 {  
00483   fprintf(stderr,"Wrong type in Get function \n");
00484   exit(1);
00485 }

void GetIMATRIX ( FILE *  f,
var  ,
int  flag 
)

Definition at line 151 of file getrhs.c.

References AddDeclare1(), C, ChangeForName2(), Check, CheckSquare, DEC_INT, Fprintf(), i1, indent, SGetForTypeAbrev(), SGetForTypeStack(), str1, str2, and var.

00153 {
00154   static char C[]="GetRhsCVar(%s,\"%s\",&it%d,&m%d,&n%d,&lr%d,&lc%d);\n";
00155   static char LC[]="GetListRhsCVar(%s,%d,\"%s\",&it%s,&m%s,&n%s,&lr%s,&lc%s,&lar%s,&lac%s);\n";
00156   int i1= var->stack_position;
00157   if ( flag == 1 ) 
00158     sprintf(str2,"k");
00159   else
00160     sprintf(str2,"%d",i1);
00161   if (var->list_el ==0 )
00162     {
00164       sprintf(str1,"%d",i1);
00165       Fprintf(f,indent,C,str2,SGetForTypeAbrev(var),
00166               i1,i1,i1,i1,i1);
00167       /* Adding the calling sequence in the for_names  */ 
00168       ChangeForName2(var,"%s(lr%s),%s(lc%s),&it%s",
00169                      SGetForTypeStack(var),str1,
00170                      SGetForTypeStack(var),str1,str1);
00171     }
00172   else
00173     {
00175       sprintf(str1,"%de%d",i1,var->list_el);
00176       AddDeclare1(DEC_INT,"lar%s",str1);
00177       AddDeclare1(DEC_INT,"lac%s",str1);
00178       Fprintf(f,indent,LC,str2,var->list_el,SGetForTypeAbrev(var),
00179               str1,str1,str1,str1,str1,str1,str1);
00180       /* Adding the calling sequence in the for_names  */ 
00181       ChangeForName2(var,"%s(lr%s),%s(lc%s),&it%s",
00182                      SGetForTypeStack(var),str1,
00183                      SGetForTypeStack(var),str1,str1);
00184     }
00185   
00186   AddDeclare1(DEC_INT,"m%s",str1);
00187   AddDeclare1(DEC_INT,"n%s",str1);
00188   AddDeclare1(DEC_INT,"lr%s",str1);
00189   AddDeclare1(DEC_INT,"lc%s",str1);
00190   AddDeclare1(DEC_INT,"it%s",str1);
00191 
00193   CheckSquare(f,var,str1,str2); 
00194   Check(f,var,0);
00195   Check(f,var,1);
00196 }

Here is the call graph for this function:

void GetLIST ( FILE *  f,
var  ,
int  flag 
)

Definition at line 465 of file getrhs.c.

00465                                                          {
00466   fprintf(stderr,"Wrong type in Get function \n");
00467   exit(1);
00468 }

void GetMATRIX ( FILE *  f,
var  ,
int  flag 
)

Definition at line 63 of file getrhs.c.

References Check, CheckSquare, GetCom(), str1, str2, and var.

00065 {
00066   GetCom(f,var,flag);
00068   CheckSquare(f,var,str1,str2); 
00069   Check(f,var,0);
00070   Check(f,var,1);
00071 }

Here is the call graph for this function:

void GetPOINTER ( FILE *  f,
var  ,
int  flag 
)

Definition at line 432 of file getrhs.c.

References AddDeclare1(), C, ChangeForName2(), DEC_INT, Fprintf(), i1, indent, str1, str2, and var.

00434 {
00435   static char C[]="GetRhsOPointer(%s,&lr%d);\n";
00436   int i1= var->stack_position;
00437   if ( flag == 1 ) 
00438     sprintf(str2,"k");
00439   else
00440     sprintf(str2,"%d",i1);
00441   sprintf(str1,"%d",i1);
00442   if (var->list_el ==0 )
00443     {
00445       sprintf(str1,"%d",i1);
00446       Fprintf(f,indent,C,str2,i1);
00447       /* Adding the calling sequence in the for_names  */ 
00448       ChangeForName2(var,"stk(lr%s)",str1);
00449     }
00450   else
00451     {
00452       fprintf(stderr,"Wrong type opointer inside a list \n");
00453       exit(1);
00454     }
00455   AddDeclare1(DEC_INT,"lr%s",str1);
00456   
00457 }

Here is the call graph for this function:

void GetPOLYNOM ( FILE *  f,
var  ,
int  flag 
)

Definition at line 363 of file getrhs.c.

References AddDeclare(), ChangeForName1(), Check, DEC_CHAR, DEC_LOGICAL, DOUBLE, Fprintf(), i1, indent, INT, REAL, str, str1, and var.

00364 {
00365   int i1= var->stack_position;
00366   if (var->list_el ==0 )
00367     {
00368       sprintf(str1,"%d",i1);
00369       AddDeclare(DEC_LOGICAL,"getonepoly");
00370       AddDeclare(DEC_CHAR,str);
00371       Fprintf(f,indent,"if(.not.getonepoly(fname,top,top-rhs+%d,it%d,m%d,namelr%d,namellr%d,lr%d,lc%d)\n",i1,i1,i1,i1,i1,i1,i1);
00372     }
00373   else
00374     {
00375       sprintf(str1,"%de%d",i1,var->list_el);
00376       AddDeclare(DEC_LOGICAL,"getlistpoly");
00377       Fprintf(f,indent,"if(.not.getlistpoly(fname,topk,top-rhs+%d,%d,it%s,m%s,n%s,name%s,\n",
00378               i1,var->list_el,str1,str1,str1,str1);
00379       Fprintf(f,indent,"$     namel%s,ilp%s,lr%s,lc%s)\n",str1,str1,str1,str1);
00380     }
00381   Check(f,var,0);
00382   /* Convertion */ 
00383   switch (var->for_type) 
00384     {
00385     case INT:
00386       Fprintf(f,indent,"call entier(n%s,stk(lr%s),istk(iadr(lr%s)))\n",
00387               str1,str1,str1);
00388       sprintf(str,"istk(iadr(lr%s))",str1);
00389       ChangeForName1(var,str);
00390       break;
00391     case REAL:
00392       Fprintf(f,indent,"call simple(n%s,stk(lr%s),stk(lr%s))\n",
00393               str1,str1,str1);
00394       sprintf(str,"stk(lr%s)",str1);
00395       ChangeForName1(var,str);
00396       break;
00397     case DOUBLE:
00398       sprintf(str,"stk(lr%s)",str1);
00399       ChangeForName1(var,str);
00400       break;
00401     default: 
00402       printf("incompatibility between Scilab and Fortran type for variable \"%s\"\n",
00403              var->name);
00404       exit(1);
00405     }
00406 }

Here is the call graph for this function:

void GetROW ( FILE *  f,
var  ,
int  flag 
)

Definition at line 290 of file getrhs.c.

References AddDeclare1(), Check, DEC_INT, Fprintf(), GetCom(), i1, indent, str1, and var.

00291 {
00292   int i1= var->stack_position;
00293   GetCom(f,var,flag);
00294   Check(f,var,0);
00295   if (var->list_el ==0 )
00296     {
00297       Fprintf(f,indent,"CheckRow(%d,m%d,n%d);\n",i1,i1,i1);
00298       Fprintf(f,indent,"mn%d=m%d*n%d;\n",i1,i1,i1);
00299       AddDeclare1(DEC_INT,"mn%d",i1);
00300     }
00301   else 
00302     {
00303       sprintf(str1,"%de%d",i1,var->list_el);
00304       Fprintf(f,indent,"CheckListRow(%d,%d,m%s,n%s);\n",i1,var->list_el,str1,str1);
00305       Fprintf(f,indent,"l%dmn%d=m%s*n%s;\n",i1,var->list_el,str1,str1);
00306       AddDeclare1(DEC_INT,"l%dmn%d",i1,var->list_el);
00307     }
00308 }

Here is the call graph for this function:

void GetSCALAR ( FILE *  f,
var  ,
int  flag 
)

Definition at line 412 of file getrhs.c.

References Fprintf(), GetCom(), i1, indent, str1, and var.

00413 {
00414   int i1= var->stack_position;
00415   GetCom(f,var,flag);
00416   /* Check(f,var,0); */
00417   if (var->list_el ==0 )
00418     {
00419       Fprintf(f,indent,"CheckScalar(%d,m%d,n%d);\n",i1,i1,i1);
00420     }
00421   else 
00422     {
00423       sprintf(str1,"%de%d",i1,var->list_el);
00424       Fprintf(f,indent,"CheckListScalar(%d,%d,m%s,n%s);\n",i1,var->list_el,str1,str1);
00425     }
00426 }

Here is the call graph for this function:

void GetSEQUENCE ( FILE *  f,
var  ,
int  flag 
)

Definition at line 475 of file getrhs.c.

00476 {  
00477   fprintf(stderr,"Wrong type in Get function \n");
00478   exit(1);
00479 }

void GetSPARSE ( FILE *  f,
var  ,
int  flag 
)

Definition at line 203 of file getrhs.c.

References AddDeclare1(), C, ChangeForName2(), Check, CheckSquare, DEC_INT, DEC_SPARSE, Fprintf(), i1, indent, str1, str2, and var.

00205 {
00206   static char C[]="GetRhsVar(%s,\"s\",&m%d,&n%d,&S%d);\n";
00207   static char LC[]="GetListRhsVar(%s,%d,\"s\",&m%s,&n%s,&S%s);\n";
00208   int i1= var->stack_position;
00209   if ( flag == 1 ) 
00210     sprintf(str2,"k");
00211   else
00212     sprintf(str2,"%d",i1);
00213   if (var->list_el ==0 )
00214     {
00216       sprintf(str1,"%d",i1);
00217       Fprintf(f,indent,C,str2, i1,i1,i1);
00218       /* Adding the calling sequence in the for_names  */ 
00219       ChangeForName2(var,"&S%d",i1);
00220     }
00221   else
00222     {
00224       sprintf(str1,"%de%d",i1,var->list_el);
00225       Fprintf(f,indent,LC,str2,var->list_el, str1,str1,str1);
00226       /* Adding the calling sequence in the for_names  */ 
00227       ChangeForName2(var,"&S%s",str1);
00228     }
00229 
00230   AddDeclare1(DEC_INT,"m%s",str1);
00231   AddDeclare1(DEC_INT,"n%s",str1);
00232   AddDeclare1(DEC_SPARSE,"S%s",str1);
00233 
00235   CheckSquare(f,var,str1,str2); 
00236   Check(f,var,0);
00237   Check(f,var,1);
00238 }

Here is the call graph for this function:

void GetSTRING ( FILE *  f,
var  ,
int  flag 
)

Definition at line 113 of file getrhs.c.

References CHAR, Check, GetCom(), SGetForType(), SGetSciType(), STRING, and var.

00114 {
00115   if (var->for_type != CHAR) 
00116     {
00117       printf("incompatibility between the type %s and FORTRAN type %s for variable \"%s\"\n",
00118              SGetSciType(STRING),SGetForType(var->for_type),var->name);
00119       exit(1);
00120     }
00121   GetCom(f,var,flag);
00122   Check(f,var,0);
00123 }

Here is the call graph for this function:

void GetSTRINGMAT ( FILE *  f,
var  ,
int  flag 
)

Definition at line 247 of file getrhs.c.

References AddDeclare1(), ChangeForName1(), Check, CheckSquare, CSTRINGV, DEC_INT, DEC_SMAT, Fprintf(), i1, indent, SGetForType(), SGetSciType(), str, str1, str2, STRINGMAT, and var.

00248 {
00249   int i1= var->stack_position;
00250   if ( flag == 1 ) 
00251     sprintf(str2,"k");
00252   else
00253     sprintf(str2,"%d",i1);
00254   if (var->list_el ==0 )
00255     {
00256       AddDeclare1(DEC_SMAT,"Str%d",i1);
00257       AddDeclare1(DEC_INT,"m%d",i1);
00258       AddDeclare1(DEC_INT,"n%d",i1);
00259       Fprintf(f,indent,"GetRhsVar(%s,\"S\",&m%d,&n%d,&Str%d);\n",str2,i1,i1,i1);
00260       sprintf(str,"&Str%d",i1);
00261       ChangeForName1(var,str);
00262     }
00263   else
00264     {
00265       sprintf(str1,"%de%d",i1,var->list_el);
00266       AddDeclare1(DEC_SMAT,"Str%s",str1);
00267       AddDeclare1(DEC_INT,"m%s",str1);
00268       AddDeclare1(DEC_INT,"n%s",str1);
00269       Fprintf(f,indent,"GetListRhsVar(%s,%d,\"S\",&m%s,&n%s,&Str%s);\n",str2,var->list_el,
00270               str1,str1,str1);
00271       sprintf(str,"&Str%s",str1);
00272       ChangeForName1(var,str);
00273     }
00274   /* square matrix */
00275   CheckSquare(f,var,str1,str2); 
00276   Check(f,var,0);
00277   Check(f,var,1);
00278   if (var->for_type != CSTRINGV) 
00279     {
00280       printf("incompatibility between the type %s and FORTRAN type %s for variable \"%s\"\n",
00281              SGetSciType(STRINGMAT),SGetForType(var->for_type),var->name);
00282       exit(1);
00283     }
00284 }

Here is the call graph for this function:

void GetTLIST ( FILE *  f,
var  ,
int  flag 
)

Definition at line 470 of file getrhs.c.

00470                                                           {
00471   fprintf(stderr,"Wrong type in Get function \n");
00472   exit(1);
00473 }

void GetVECTOR ( FILE *  f,
var  ,
int  flag 
)

Definition at line 339 of file getrhs.c.

References AddDeclare1(), Check, DEC_INT, Fprintf(), GetCom(), i1, indent, str1, and var.

00340 {
00341   int i1= var->stack_position;
00342   GetCom(f,var,flag);
00343   Check(f,var,0);
00344   if (var->list_el ==0 )
00345     {
00346       Fprintf(f,indent,"CheckVector(%d,m%d,n%d);\n",i1,i1,i1);
00347       Fprintf(f,indent,"mn%d=m%d*n%d;\n",i1,i1,i1);
00348       AddDeclare1(DEC_INT,"mn%d",i1);
00349     }
00350   else 
00351     {
00352       sprintf(str1,"%de%d",i1,var->list_el);
00353       Fprintf(f,indent,"CheckListVector(%d,%d,m%s,n%s);\n",i1,var->list_el,str1,str1);
00354       Fprintf(f,indent,"l%dmn%d=m%s*n%s;\n",i1,var->list_el,str1,str1);
00355       AddDeclare1(DEC_INT,"l%dmn%d",i1,var->list_el);
00356     }
00357 }

Here is the call graph for this function:

void GetWORK ( FILE *  f,
var  ,
int  flag 
)

Definition at line 487 of file getrhs.c.

00488 {  
00489   fprintf(stderr,"Wrong type in Get function \n");
00490   exit(1);
00491 }


Variable Documentation

int indent

Definition at line 36 of file niceprintf.c.

int pass

Definition at line 17 of file intersci-n.c.

GetRhsTab RHSTAB[]

Initial value:

Definition at line 24 of file getrhs.c.

Referenced by WriteArgCheck(), WriteListAnalysis(), and WriteOptArg().

char str[MAXNAM] [static]

Definition at line 53 of file getrhs.c.

char str1[MAXNAM] [static]

Definition at line 54 of file getrhs.c.

char str2[MAXNAM] [static]

Definition at line 55 of file getrhs.c.


Generated on Sun Mar 4 16:08:25 2007 for Scilab [trunk] by  doxygen 1.5.1