Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: synchonisation iode-dos 6.70 api -> iode 7.0 api #373

Merged
merged 20 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions api/iode.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define MAXFLOAT FLT_MAX
#define MINFLOAT FLT_MIN
#endif


//#include "o_objs.h" // JMP 8/12/2011

Expand Down Expand Up @@ -119,7 +119,6 @@
#define KMAGIC(kdb) ((kdb)->k_magic)
#define KTYPE(kdb) ((kdb)->k_type)
#define KMODE(kdb) ((kdb)->k_mode)
//#define KNAME(kdb) ((kdb)->k_name) Supprim� pour �viter les oublis
#define KNAMEPTR(kdb)((kdb)->k_nameptr) // 6.44
#define KDESC(kdb) ((kdb)->k_desc)
#define KDATA(kdb) ((kdb)->k_data)
Expand Down Expand Up @@ -844,14 +843,14 @@ typedef struct _sample {
} SAMPLE;

typedef struct _lname_ {
ONAME name; // scalar or variable name
ONAME name; // scalar or variable name
char pad[3];
long pos; /* SWHDL */ /* IODE64K */
long pos; // SWHDL
} LNAME;

typedef struct _clec_ {
long tot_lg, /* JMP 20-05-00 */ /* IODE64K */
exec_lg; /* JMP 20-05-00 */ /* IODE64K */
long tot_lg,
exec_lg;
short nb_names; // number of scalar and variables names
char dupendo;
char pad;
Expand Down Expand Up @@ -973,15 +972,15 @@ typedef struct _col_ {

/* {{v00, v01},{v10,v11}}

| |
| file1 | file2
| |
| file1 | file2
--------|-------------|------------
period1 | v00 | v01
| cl_val[0,0] | cl_val[0,1] v.. = valeur
| cl_val[0,0] | cl_val[0,1] v.. = valeur
--------|-------------|------------
period2 | v10 | v11
| cl_val[1,0] | cl_val[1,1]
| |
| cl_val[1,0] | cl_val[1,1]
| |
*/
IODE_REAL cl_res; // computed value (v00 opp v10) opf (v01 opp v11)
} COL;
Expand Down Expand Up @@ -1077,10 +1076,10 @@ typedef struct _token {
char tk_name[L_MAX_NAME + 1];
} TOKEN;

typedef struct _lstack { /* stack of operators used by L_analyse */
unsigned ls_op : 8; /* operator */
//unsigned ls_nb_args : 8; /* nb of arguments */
unsigned ls_nb_args; /* nb of arguments */ // 16 bits pour permettre de v�rifier si plus de 255 arguments
typedef struct _lstack { // stack of operators used by L_analyse
unsigned ls_op : 8; // operator
//unsigned ls_nb_args : 8; // nb of arguments
unsigned ls_nb_args; // nb of arguments : 16 bits instead of 8 to allow checking max 255 args
} LSTACK;


Expand All @@ -1091,7 +1090,7 @@ typedef struct _lstack { /* stack of operators used by L_analyse */
// REPFILE contains a report to be interpreted and the current line during interpretation
typedef struct _repfile_ {
char *filename; // Source file for report file (*.rep) or
// Proc name and position for procedures (PROCDEF)
// Proc name and position for procedures (PROCDEF)
unsigned char **tbl; // Lines of the report
int curline, // Current line (during execution)
nblines; // Total number of lines in the report
Expand Down Expand Up @@ -1188,6 +1187,9 @@ extern int KSIM_MAXIT, // Simulation: max number of iterati
KSIM_NEWTON_MAXIT, // Newton-Raphson: max number of iterations of the Newton-Raphson sub algorithm.
KSIM_SORT, // Simulation: reordering option : SORT_NONE, SORT_CONNEX or SORT_BOTH
KSIM_START; // Simulation: endogenous initial values



extern char **KSIM_EXO;

/*-------------- MESSAGES -----------------------*/
Expand Down Expand Up @@ -1323,18 +1325,23 @@ extern MAT *E_RHS,
*E_DEV;

/************************* SIMULATION *************************************/
extern int KSIM_MAXIT;
extern int *KSIM_NITERS;
extern IODE_REAL *KSIM_NORMS;
extern int KSIM_MAXIT; // Maximum number of iteration to reach a solution
extern int *KSIM_NITERS; // Numbers of iterations needed for each simulation period
extern long *KSIM_CPUS; // Elapsed time for each simulation period
extern IODE_REAL *KSIM_NORMS; // Convergence threshold reached at the end of each simulation period

extern int KSIM_CPU_SCC; // Elapsed time to compute SCC
extern int KSIM_CPU_SORT; // Elapsed time to sort interdep block

// EQUATION ORDERING
extern int KSIM_PRE;
extern int KSIM_INTER;
extern int KSIM_POST;
extern int KSIM_PRE; // number of equations in the "prolog" block
extern int KSIM_INTER; // number of equations in the "interdep" block
extern int KSIM_POST; // number of equations in the "epilog"
//extern int *KSIM_ORDER;
//extern char *KSIM_ORDERED;
extern int KSIM_MAXDEPTH;
extern int *KSIM_POSXK;
extern int KSIM_MAXDEPTH; // Number of equations in the model
extern int *KSIM_POSXK; // Position in KSIM_DBV of the endo variable of equation "KSIM_DBE[i]"
extern int *KSIM_POSXK_REV; // Position in KSIM_DBE of the equation whose endo is "KSIM_DBV[i]" (reverse of KSIM_POSXK)

/*********************** FUNCTIONS DECLARATIONS ***************************/
// NEW FOR IODECOM (JMP 1/23/2018)
Expand Down
11 changes: 10 additions & 1 deletion api/iodeapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,16 @@ extern int IodeSetVector(char *la_name, double *la_values, int la_pos, int ws_po
extern int IodeEstimate(char* veqs, char* afrom, char* ato);

extern int IodeModelSimulate(char *per_from, char *per_to, char *eqs_list, char *endo_exo_list, double eps, double relax, int maxit, int init_values, int sort_algo, int nb_passes, int debug, double newton_eps, int newton_maxit, int newton_debug);

extern int IodeModelCalcSCC(int nbtris, char* pre_listname, char* inter_listname, char* post_listname, char *eqs_list);
alixdamman marked this conversation as resolved.
Show resolved Hide resolved
extern int IodeModelSimulateSCC(char *per_from, char *per_to,
char *pre_eqlist, char *inter_eqlist, char* post_eqlist,
double eps, double relax, int maxit,
int init_values, int debug,
double newton_eps, int newton_maxit, int newton_debug);
extern double IodeModelSimNorm(char* period);
extern int IodeModelSimNIter(char* period);
extern int IodeModelSimCpu(char* period);

extern int IodeExecArgs(char *filename, char **args);
extern int IodeExec(char *filename);

Expand Down
31 changes: 25 additions & 6 deletions api/iodebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,8 @@ extern int RP_goto_label(char *command, char *parm);
extern int RP_goto(char* arg);
extern int RP_message(char* arg);
extern int RP_warning(char* arg);
extern int RP_beep();
extern int RP_silent(char* arg);
extern int RP_beep(char* arg);
extern int RP_ask(char* arg);
extern int B_ReportPrompt(char* arg);
extern int RP_setdebug(char* arg);
Expand All @@ -949,6 +950,7 @@ extern int B_Sleep(char* arg);
extern int B_GraphDefault(char* type);

/* b_rep_fns.c */
extern U_ch *RPF_IodeVersion();
extern U_ch *RPF_take(U_ch** args);
extern U_ch *RPF_drop(U_ch** args);
extern U_ch *RPF_replace(U_ch** args);
Expand Down Expand Up @@ -994,12 +996,27 @@ extern U_ch *RPF_lexpand(U_ch **args);
extern U_ch *RPF_sexpand(U_ch **args);
extern U_ch *RPF_texpand(U_ch **args);
extern U_ch *RPF_vexpand(U_ch **args);

extern int RPF_CalcPeriod(U_ch** args);
extern U_ch *RPF_SimNorm(U_ch** args);
extern U_ch *RPF_SimNIter(U_ch** args);
extern U_ch *RPF_SimMaxit();
extern U_ch *RPF_SimEps();
extern U_ch *RPF_SimRelax();
extern U_ch* RPF_SimSortNbPasses();
extern U_ch* RPF_SimSortAlgo();
extern U_ch* RPF_SimInitValues();

extern IODE_REAL RPF_SimNormReal(U_ch** args);
extern U_ch *RPF_SimNorm(U_ch** args);

extern int RPF_SimNIterInt(U_ch** args);
extern U_ch *RPF_SimNIter(U_ch** args);

extern int RPF_SimCpuInt(U_ch** args);
extern U_ch* RPF_SimCpu(U_ch** args);

extern U_ch* RPF_SimCpuSCC();
extern U_ch* RPF_SimCpuSort();

extern U_ch *RPF_vtake(U_ch** args);
extern U_ch *RPF_vdrop(U_ch** args);
extern U_ch *RPF_vcount(U_ch** args);
Expand Down Expand Up @@ -1087,7 +1104,8 @@ extern int (*B_ScrollVTW0_super)(char *arg);
extern int (*B_ScrollVTN_super )(char *arg);

extern int (*ODE_scroll_super) (KDB *kdb, char **lst);
extern int (*T_view_tbl_super) (char* name, char *smpl, char** vars_names);
extern int (*T_view_tbl_super) (TBL *tbl, char *smpl, char* name);
// extern int (*T_view_tbl_super) (char* name, char *smpl, char** vars_names); // TEMP version for IODE-QT

/* b_rep_super.c - function declarations */
extern int SB_FileDelete ();
Expand Down Expand Up @@ -1152,7 +1170,8 @@ extern int B_ScrollVTW0(char* arg);
extern int B_ScrollVTN (char* arg);

extern int ODE_scroll(KDB *kdb, char **lst);
extern int T_view_tbl(char* name, char *smpl, char** vars_names);
extern int T_view_tbl(TBL *tbl, char *smpl, char* name);
// extern int T_view_tbl(char* name, char *smpl, char** vars_names); // Temp version for IODE-QT


/* b_data.c */
Expand Down Expand Up @@ -1784,7 +1803,6 @@ extern int T_alloc_val(TBL *,char *);
extern int T_free_val(TBL *);
extern int T_name_inline(TCELL *,int ,char *);
extern int T_calc_val(TBL *,char *);
extern int T_view_tbl(char *,char *, char **);
extern int T_calc_line(TBL *,int ,COLS *,int *);
extern int VT_files(void);

Expand Down Expand Up @@ -1918,6 +1936,7 @@ extern int W_EndDisplay(char *title,int x,int y,int w,int h);
extern int W_printf(char *fmt,...);
extern int W_printfDbl(char* fmt, ...);
extern int W_printfRepl(char* fmt, ...);
extern int W_printfReplEsc(char* fmt, ...);
extern int W_printfEx(int dup, int ch1, int ch2, char *fmt, va_list args);

// interface
Expand Down
6 changes: 3 additions & 3 deletions api/lec/l_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ static void L_link1_endos(KDB* dbe, CLEC* cl)

for (i = 0; i < cl->nb_names; i++) {
if (L_ISCOEF(cl->lnames[i].name))
cl->lnames[i].pos = 0; // On s'en tape pour le calcul des SCC
cl->lnames[i].pos = 0; // For the SCC construction, we do not need the coefficients (scalars)
alixdamman marked this conversation as resolved.
Show resolved Hide resolved
else
cl->lnames[i].pos = K_find(dbe, cl->lnames[i].name);

if (cl->lnames[i].pos < 0) // Non trouv� -> exo
cl->lnames[i].pos = KNB(dbe); // exo : on s'en tape aussi
if (cl->lnames[i].pos < 0) // Not found => exogenous var
cl->lnames[i].pos = -1; // For the SCC construction, we do not need the exogenous vars positions
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/objs/k_tbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ char* T_div_cont_tbl(TBL* tbl, int col, int mode)
* @param [in, out] tbl TBL* TBL where a new line must be inserted
* @param [in] nbr int reference position of the new line in TBL (see param where below)
* @param [in] type int TLINE type (KT_CELL, KT_TITLE...)
* @param [in] where int 1 to insert before line nbr, 0 to insert after line nbr
* @param [in] where int 0 to insert before line nbr, 1 to insert after line nbr
* @return int position of the new line in TBL
* **TODO: Check where definition
*/
Expand Down
5 changes: 4 additions & 1 deletion api/report/commands/b_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,10 @@ static int B_CreateVarFromVecOfInts(char *name, int *vec)
// Create var and get Ptr
B_CreateEmptyVar(name);
x = B_GetVarPtr(name);
if(x == 0) return(-1);
if(x == 0) {
B_seterror("B_CreateVarFromVecOfInts %s failed", name);
return(-1);
}

// Copy values
if(vec) {
Expand Down
12 changes: 7 additions & 5 deletions api/report/commands/b_xode.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
int B_FileImportCmt(char* arg)
{
int rc = 0, nb_args, format, lang;
char **args = NULL, *trace, *rule, *infile, *oufile;
char **args = NULL, *trace, *rule, *infile, *oufile, empty_buf[1];

empty_buf[0] = 0;
args = B_ainit_chk(arg, NULL, 0);
nb_args = SCR_tbl_size(args);
if(nb_args < 5) {
Expand All @@ -46,10 +47,10 @@ int B_FileImportCmt(char* arg)
lang = B_argpos("EFD", args[4][0]);

if(nb_args == 6) trace = args[5];
else trace = "";
else trace = empty_buf;

rc = IMP_RuleImport(K_CMT, trace, rule, oufile, infile,
"", "", format, lang);
empty_buf, empty_buf, format, lang);

fin:
A_free(args);
Expand All @@ -74,8 +75,9 @@ int B_FileImportCmt(char* arg)
int B_FileImportVar(char* arg)
{
int rc = 0, nb_args, format;
char **args = NULL, *trace, *rule, *from, *to,*infile, *oufile;
char **args = NULL, *trace, *rule, *from, *to,*infile, *oufile, empty_buf[1];

empty_buf[0] = 0;
args = B_ainit_chk(arg, NULL, 0);
nb_args = SCR_tbl_size(args); /* JMP 16-12-93 */
if(nb_args < 6) {
Expand All @@ -92,7 +94,7 @@ int B_FileImportVar(char* arg)
to = args[5];

if(nb_args == 7) trace = args[6];
else trace = "";
else trace = empty_buf;

rc = IMP_RuleImport(K_VAR, trace, rule, oufile, infile,
from, to, format, 0);
Expand Down
26 changes: 24 additions & 2 deletions api/report/engine/b_rep_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* int RP_goto(char* arg) $goto label [value]
* int RP_message(char* arg) $show message
* int RP_warning(char* arg) $msg text
* int RP_silent(char* arg) $silent {0|1|N|n|Y|y]
* int RP_beep() $beep
* int RP_ask(char* arg) $ask <label> <question>
* int B_ReportPrompt(char* arg) #prompt <macro_name> <question>
Expand Down Expand Up @@ -316,18 +317,39 @@ int RP_message(char* arg)
return(0);
}


// $msg text
int RP_warning(char* arg)
{
if(arg == NULL || arg[0] == 0) return(0); /* JMP 11-07-96 */

if(strlen(arg) > 512) arg[512] = 0;
kwarning("%s", arg);
kwarning("%s", arg);
return(0);
}

// $silent {0|1|n|N|Y|y}
int RP_silent(char* arg)
{
int ch;

ch = SCR_upper_char(arg[0]);
switch(ch) {
case '0' :
case 'n':
case 'N':
kmsg_toggle(1);
break;

default :
kmsg_toggle(0);
break;
}
return(0);
}

// $beep
int RP_beep()
int RP_beep(char* arg)
{
kbeep();
return(0);
Expand Down
Loading