--- imach/src/imach.c 2002/02/22 17:54:20 1.22 +++ imach/src/imach.c 2002/02/28 17:49:07 1.27 @@ -1,5 +1,5 @@ -/* $Id: imach.c,v 1.22 2002/02/22 17:54:20 brouard Exp $ - Interpolate Markov Chain +/* $Id: imach.c,v 1.27 2002/02/28 17:49:07 lievre Exp $ + Interpolated Markov Chain Short summary of the programme: @@ -94,8 +94,8 @@ int **dh; /* dh[mi][i] is number of step double jmean; /* Mean space between 2 waves */ double **oldm, **newm, **savm; /* Working pointers to matrices */ double **oldms, **newms, **savms; /* Fixed working pointers to matrices */ -FILE *fic,*ficpar, *ficparo,*ficres, *ficrespl, *ficrespij, *ficrest,*ficresf; -FILE *ficgp, *fichtm,*ficresprob,*ficpop; +FILE *fic,*ficpar, *ficparo,*ficres, *ficrespl, *ficrespij, *ficrest,*ficresf,*ficrespop; +FILE *ficgp,*ficresprob,*ficpop; FILE *ficreseij; char filerese[FILENAMELENGTH]; FILE *ficresvij; @@ -123,7 +123,7 @@ FILE *ficreseij; static double maxarg1,maxarg2; #define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1)>(maxarg2)? (maxarg1):(maxarg2)) #define FMIN(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1)<(maxarg2)? (maxarg1):(maxarg2)) - + #define SIGN(a,b) ((b)>0.0 ? fabs(a) : -fabs(a)) #define rint(a) floor(a+0.5) @@ -1176,7 +1176,7 @@ void lubksb(double **a, int n, int *indx } /************ Frequencies ********************/ -void freqsummary(char fileres[], int agemin, int agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2) +void freqsummary(char fileres[], int agemin, int agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2,double jprev1, double mprev1,double anprev1,double jprev2, double mprev2,double anprev2) { /* Some frequencies */ int i, m, jk, k1,i1, j1, bool, z1,z2,j; @@ -1236,6 +1236,9 @@ void freqsummary(char fileres[], int ag } } } + + fprintf(ficresp, "#Count between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2); + if (cptcovn>0) { fprintf(ficresp, "\n#********** Variable "); for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresp, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]); @@ -1620,7 +1623,7 @@ void varevsij(char fileres[], double *** for(i=1; i<=nlstate;i++) prlim[i][i]=probs[(int)age][i][ij]; } - + for(j=1; j<= nlstate; j++){ for(h=0; h<=nhstepm; h++){ for(i=1, gp[h][j]=0.;i<=nlstate;i++) @@ -1632,7 +1635,7 @@ void varevsij(char fileres[], double *** xp[i] = x[i] - (i==theta ?delti[theta]:0); hpxij(p3mat,nhstepm,age,hstepm,xp,nlstate,stepm,oldm,savm, ij); prevalim(prlim,nlstate,xp,age,oldm,savm,ftolpl,ij); - + if (popbased==1) { for(i=1; i<=nlstate;i++) prlim[i][i]=probs[(int)age][i][ij]; @@ -1684,7 +1687,7 @@ void varevsij(char fileres[], double *** free_ma3x(trgradg,0,nhstepm,1,nlstate,1,npar); free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); } /* End age */ - + free_vector(xp,1,npar); free_matrix(doldm,1,nlstate,1,npar); free_matrix(dnewm,1,nlstate,1,nlstate); @@ -1876,138 +1879,655 @@ if (i== 4) fprintf(ficresprob,"%.3e %.3e } free_vector(xp,1,npar); fclose(ficresprob); - exit(0); -} - -/***********************************************/ -/**************** Main Program *****************/ -/***********************************************/ - -int main(int argc, char *argv[]) -{ - int i,j, k, n=MAXN,iter,m,size,cptcode, cptcod; - double agedeb, agefin,hf; - double agemin=1.e20, agemax=-1.e20; +} - double fret; - double **xi,tmp,delta; +/******************* Printing html file ***********/ +void printinghtml(char fileres[], char title[], char datafile[], int firstpass, int lastpass, int stepm, int weightopt, char model[],int imx,int jmin, int jmax, double jmeanint,char optionfile[],char optionfilehtm[] ){ + int jj1, k1, i1, cpt; + FILE *fichtm; + /*char optionfilehtm[FILENAMELENGTH];*/ - double dum; /* Dummy variable */ - double ***p3mat; - int *indx; - char line[MAXLINE], linepar[MAXLINE]; - char title[MAXLINE]; - char optionfile[FILENAMELENGTH], datafile[FILENAMELENGTH], filerespl[FILENAMELENGTH], optionfilehtm[FILENAMELENGTH]; - char optionfilext[10], optionfilefiname[FILENAMELENGTH], optionfilegnuplot[FILENAMELENGTH], plotcmd[FILENAMELENGTH]; - - char fileres[FILENAMELENGTH], filerespij[FILENAMELENGTH], filereso[FILENAMELENGTH], fileresf[FILENAMELENGTH];; + strcpy(optionfilehtm,optionfile); + strcat(optionfilehtm,".htm"); + if((fichtm=fopen(optionfilehtm,"w"))==NULL) { + printf("Problem with %s \n",optionfilehtm), exit(0); + } - char filerest[FILENAMELENGTH]; - char fileregp[FILENAMELENGTH]; - char popfile[FILENAMELENGTH]; - char path[80],pathc[80],pathcd[80],pathtot[80],model[20]; - int firstobs=1, lastobs=10; - int sdeb, sfin; /* Status at beginning and end */ - int c, h , cpt,l; - int ju,jl, mi; - int i1,j1, k1,k2,k3,jk,aa,bb, stepsize, ij; - int jnais,jdc,jint4,jint1,jint2,jint3,**outcome,**adl,*tab; - int mobilav=0,popforecast=0; - int hstepm, nhstepm; - int *popage;/*boolprev=0 if date and zero if wave*/ - double jprev1, mprev1,anprev1,jprev2, mprev2,anprev2; + fprintf(fichtm,"