From e1da9bc9d76ce837bf8db846f79d4df1574b096d Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Wed, 9 Nov 2016 16:37:57 +0200 Subject: [PATCH] Fix duplicate w_POWER definition Fix duplicate w_POWER definition and some house keeping. Tested the new commit by @AngelaMarchi from #87, all results are the same as version 2.1. --- src/inpfile.c | 16 ++-------------- src/rules.c | 12 ------------ src/text.h | 8 +------- src/types.h | 4 ++-- 4 files changed, 5 insertions(+), 35 deletions(-) diff --git a/src/inpfile.c b/src/inpfile.c index 8f42c14..77ee434 100755 --- a/src/inpfile.c +++ b/src/inpfile.c @@ -421,7 +421,8 @@ int saveinpfile(char *fname) } } - /*moved after control section */ +/* Write [RULES] section */ + fprintf(f, "\n\n[RULES]"); for (i=1; i<=Nrules; i++) { @@ -429,8 +430,6 @@ int saveinpfile(char *fname) errcode = writeRuleinInp(f, i); fprintf(f, "\n"); } - //fprintf(f, "\n\n"); - /* end move after control section */ /* Write [QUALITY] section */ /* (Skip nodes with default quality of 0) */ @@ -635,17 +634,6 @@ int saveinpfile(char *fname) } fprintf(f, "\n\n"); - /*moved after control section - fprintf(f, "\n\n[RULES]"); - for (i=1; i<=Nrules; i++) - { - fprintf(f, "\nRULE %s",Rule[i].label); - errcode = writeRuleinInp(f, i); - fprintf(f, "\n"); - } - fprintf(f, "\n\n"); - end move after control section */ - /* Write [COORDINATES] section */ if (Coordflag == TRUE) diff --git a/src/rules.c b/src/rules.c index bfff91f..2d94533 100755 --- a/src/rules.c +++ b/src/rules.c @@ -527,8 +527,6 @@ int newaction() if (Tlast == NULL) Rule[Nrules].Tchain = a; else Tlast->next = a; Tlast = a; - //a->next = Rule[Nrules].Tchain; - //Rule[Nrules].Tchain = a; } else { @@ -536,8 +534,6 @@ int newaction() if (Flast == NULL) Rule[Nrules].Fchain = a; else Flast->next = a; Flast = a; - //a->next = Rule[Nrules].Fchain; - //Rule[Nrules].Fchain = a; } return(0); } @@ -963,8 +959,6 @@ int writeRuleinInp(FILE *f, int RuleIdx){ fprintf(f, "\nIF "); if ((strncmp(Object[p->object], "NODE", 4)==0) || (strncmp(Object[p->object], "Junc", 4)==0) || (strncmp(Object[p->object], "Reser", 5)==0) || (strncmp(Object[p->object], "Tank", 4)==0) ) { - //if (p->index <= Njuncs) fprintf(f,"JUNC %s %s %s %s", Node[p->index].ID, Varword[p->variable], Operator[p->relop], Value[p->status]); - //else if (Tank[p->index-Njuncs].A == 0.0) fprintf(f,"RESERV %s %s %s %s", Node[p->index].ID, Varword[p->variable], Operator[p->relop], Value[p->status]); if (p->index <= Njuncs) fprintf(f,"JUNCTION %s %s %s %s", Node[p->index].ID, Varword[p->variable], Operator[p->relop], Value[p->status]); else if (Tank[p->index-Njuncs].A == 0.0) fprintf(f,"RESERVOIR %s %s %s %s", Node[p->index].ID, Varword[p->variable], Operator[p->relop], Value[p->status]); else fprintf(f,"TANK %s %s %s %s", Node[p->index].ID, Varword[p->variable], Operator[p->relop], Value[p->status]); @@ -1004,8 +998,6 @@ int writeRuleinInp(FILE *f, int RuleIdx){ fprintf(f, "\nIF "); if ((strncmp(Object[p->object], "NODE", 4)==0) || (strncmp(Object[p->object], "Junc", 4)==0) || (strncmp(Object[p->object], "Reser", 5)==0) || (strncmp(Object[p->object], "Tank", 4)==0)) { - //if (p->index <= Njuncs) fprintf(f,"JUNC %s %s %s %.4lf", Node[p->index].ID, Varword[p->variable], Operator[p->relop], p->value); - //else if (Tank[p->index-Njuncs].A == 0.0) fprintf(f,"RESERV %s %s %s %.4lf", Node[p->index].ID, Varword[p->variable], Operator[p->relop], p->value); if (p->index <= Njuncs) fprintf(f,"JUNCTION %s %s %s %.4lf", Node[p->index].ID, Varword[p->variable], Operator[p->relop], p->value); else if (Tank[p->index-Njuncs].A == 0.0) fprintf(f,"RESERVOIR %s %s %s %.4lf", Node[p->index].ID, Varword[p->variable], Operator[p->relop], p->value); else fprintf(f,"TANK %s %s %s %.4lf", Node[p->index].ID, Varword[p->variable], Operator[p->relop], p->value); @@ -1029,8 +1021,6 @@ int writeRuleinInp(FILE *f, int RuleIdx){ fprintf(f, "\n%s ", Ruleword[p->logop]); if ((strncmp(Object[p->object], "NODE", 4)==0) || (strncmp(Object[p->object], "Junc", 4)==0) || (strncmp(Object[p->object], "Reser", 5)==0) || (strncmp(Object[p->object], "Tank", 4)==0)) { - //if (p->index <= Njuncs) fprintf(f,"JUNC %s %s %s %s", Node[p->index].ID, Varword[p->variable], Operator[p->relop], Value[p->status]); - //else if (Tank[p->index-Njuncs].A == 0.0) fprintf(f,"RESERV %s %s %s %s", Node[p->index].ID, Varword[p->variable], Operator[p->relop], Value[p->status]); if (p->index <= Njuncs) fprintf(f,"JUNCTION %s %s %s %s", Node[p->index].ID, Varword[p->variable], Operator[p->relop], Value[p->status]); else if (Tank[p->index-Njuncs].A == 0.0) fprintf(f,"RESERVOIR %s %s %s %s", Node[p->index].ID, Varword[p->variable], Operator[p->relop], Value[p->status]); else fprintf(f,"TANK %s %s %s %s", Node[p->index].ID, Varword[p->variable], Operator[p->relop], Value[p->status]); @@ -1069,8 +1059,6 @@ int writeRuleinInp(FILE *f, int RuleIdx){ { fprintf(f, "\n%s ", Ruleword[p->logop]); if ((strncmp(Object[p->object], "NODE", 4)==0) || (strncmp(Object[p->object], "Junc", 4)==0) || (strncmp(Object[p->object], "Reser", 5)==0) || (strncmp(Object[p->object], "Tank", 4)==0)) { - //if (p->index <= Njuncs) fprintf(f,"JUNC %s %s %s %.4lf", Node[p->index].ID, Varword[p->variable], Operator[p->relop], p->value); - //else if (Tank[p->index-Njuncs].A == 0.0) fprintf(f,"RESERV %s %s %s %.4lf", Node[p->index].ID, Varword[p->variable], Operator[p->relop], p->value); if (p->index <= Njuncs) fprintf(f,"JUNCTION %s %s %s %.4lf", Node[p->index].ID, Varword[p->variable], Operator[p->relop], p->value); else if (Tank[p->index-Njuncs].A == 0.0) fprintf(f,"RESERVOIR %s %s %s %.4lf", Node[p->index].ID, Varword[p->variable], Operator[p->relop], p->value); else fprintf(f,"TANK %s %s %s %.4lf", Node[p->index].ID, Varword[p->variable], Operator[p->relop], p->value); diff --git a/src/text.h b/src/text.h index 9a64798..caaf552 100755 --- a/src/text.h +++ b/src/text.h @@ -95,10 +95,8 @@ AUTHOR: L. Rossman #define w_METERS "METERS" #define w_ELEV "ELEV" -//#define w_DEMAND "DEMA" #define w_DEMAND "DEMAND" #define w_HEAD "HEAD" -//#define w_PRESSURE "PRES" #define w_PRESSURE "PRESSURE" #define w_QUALITY "QUAL" @@ -107,15 +105,11 @@ AUTHOR: L. Rossman #define w_ROUGHNESS "ROUG" #define w_VELOCITY "VELO" #define w_HEADLOSS "HEADL" -//#define w_SETTING "SETT" #define w_SETTING "SETTING" -//#define w_POWER "POWE" #define w_POWER "POWER" #define w_VOLUME "VOLU" #define w_CLOCKTIME "CLOCKTIME" -//#define w_FILLTIME "FILL" #define w_FILLTIME "FILLTIME" -//#define w_DRAINTIME "DRAI" #define w_DRAINTIME "DRAINTIME" #define w_GRADE "GRADE" #define w_LEVEL "LEVEL" @@ -166,7 +160,7 @@ AUTHOR: L. Rossman #define w_EFFIC "EFFI" #define w_HEAD "HEAD" -#define w_POWER "POWE" +#define w_POWER "POWER" #define w_SPEED "SPEE" #define w_MIXED "MIXED" diff --git a/src/types.h b/src/types.h index 36732e1..1fbc839 100755 --- a/src/types.h +++ b/src/types.h @@ -506,7 +506,7 @@ struct ActItem *ActList; /* Linked list of action items */ int RuleState; /* State of rule interpreter */ long Time1; /* Start of rule evaluation time interval (sec) */ struct Premise *Plast; /* Previous premise clause */ -struct Action *Tlast; /*Previous true action */ -struct Action *Flast; /*Previous false action */ +struct Action *Tlast; /* Previous true action */ +struct Action *Flast; /* Previous false action */ #endif