source: altifloat/src/floater.h @ 107

Last change on this file since 107 was 107, checked in by jbrlod, 11 years ago

normalization after filter

File size: 4.2 KB
Line 
1//constantes
2YREAL rdtflo=2*3600;
3//YREAL rdtflo=1;
4YREAL ur_dx=0;
5YREAL ur_dy=0;
6YREAL vr_dx=0;
7YREAL vr_dy=0;
8
9//FILTER COEFFICIENTS
10#ifdef K_FILTER
11//YREAL c1;
12//YREAL c2,c3,c4,c5;
13YREAL dtfil=1;
14#endif
15
16//Options du run incrŽmental
17int nb_extiter=6;
18short inc_save=1;
19char dirsave[50]="../obs_float/";
20char savename[50]="optim";
21extern double Y3ddf1;
22//Declaration
23
24void appli_start(int argc, char *argv[]){
25#ifdef K_FILTER
26  //c1=0.5;
27  //c2=c3=c4=c5=0.125;
28#endif
29}
30void before_it(int nit){}
31void cost_function(int pdt){}
32void adjust_target(){}
33void after_it(int nit){
34       
35        //printf("u_d(9,16)=%f %f %f %f\n",YS1_u_d(9,16),YS1_u_d(10,16),YS1_u_d(10,17),YS1_u_d(9,17));
36        }
37void forward_before(int ctrp){
38}
39void forward_after(int ctrp){
40}
41
42void backward_before(int ctrp){
43}
44
45void backward_after(int ctrp){
46        }
47
48short select_io(int indic, char *nmod, int sortie, int iaxe,
49                int jaxe, int kaxe, int pdt, YREAL *val){
50        //if(indic==YIO_LOADSTATE && !strcmp(nmod,"u")) {
51        //printf("s=%d t=%d Yi=%d Yj=%d val=%f\n",sortie,pdt,iaxe,jaxe,*val);   
52        //}
53       
54        return(1);
55}
56
57//in case we want to see how it s loading the data we do this above
58
59void update_uv(){
60        int j,k;
61        for (j=0;j<nlon;j++)
62        for (k=0;k<nlat;k++) {
63                YS1_u(j,k)+=YS1_u_d(j,k);
64                YS1_v(j,k)+=YS1_v_d(j,k);
65}
66}
67
68void erase_udvd() {
69  int j,k;
70  for (j=0;j<nlon;j++)
71        for (k=0;k<nlat;k++) {
72#ifdef K_FILTER
73          YS1_uc_d(j,k)=0;
74          YS1_vc_d(j,k)=0;
75#else     
76          YS1_u_d(j,k)=0;
77          YS1_v_d(j,k)=0;
78#endif
79}
80}
81//void load_aviso(int argc, char *argv[]){
82       
83//      }
84
85void run_inc(int argv, char *argc[]) {
86//Run the incremental optimisation
87//1 forward of the complete model
88//2 initialize du et dv to zero
89//3 minimize the incremental cost function
90//4 update u and v
91
92/*
93Options
94nb_extiter : number of extern loop (default=6)
95inc_save : save option
96        0  : no save
97        1 (default): save after each extern loop r_float,u and v
98dirsave : directory in case inc_save>0 (default="../obs_float/")
99savename : basename of save fils (default "optim")
100*/
101char filesave[100];
102int i;
103
104char sactiv[20]="activ";
105char sMD[20]="M";
106char sonly[20]="only";
107char *liste[3];
108liste[0]=sactiv;
109liste[1]=sMD;
110liste[2]=sonly;
111/*Check M1QN3 config*/
112 if (YNbItRun<=0)
113                {        printf("runm(2): number of run iteration not seted; use set_nbiter please\n");
114                         //return(0);
115                }
116        if (Y3ddf1<=0)
117                {       printf("runm(2): expected positive fcost decrease missed; use setm_ddf1\n");
118                         //return(0);
119                }
120        if (YioInsertObsCtr<0)
121                   printf("runm(2): warning : oh oh, run with no obs !!! \n");
122               
123        YTypeAdjust = ADJUST_M1QN3; //d'office avec M1QN3
124       
125//Savestate config
126 YioModulot = OFF; //On sauvegarde tous les pas de temps
127    YioWrite = ON;
128    YioRead= OFF;
129   // Yio_savestate(cdes[1], cdes[3], 0, cdes[7]);
130    YioState=0 ;//Save all states
131    YioBin=OFF; //ascii output
132    YioAscii=ON; //ascii output
133    YioAxes=ON; //save axe numbers
134
135for (i=0;i<nb_extiter;i++) {
136     strcpy(liste[1],"M");
137         Yactraj(3, liste);
138         Yset_modeltime(0);
139         before_it(1);
140         //printf("---forward(i=%d)---\n",i);
141         Yforward(-1, 0);
142         
143         if (inc_save==1 && i>0) {
144          //save rfloat
145          YioTime=ON;
146          sprintf(filesave,"%sr_float_%s_%d.dat",dirsave,savename,i);
147          Yio_savestate("r_float","i",0,filesave);
148         }
149             strcpy(liste[1],"D");
150         Yactraj(3,liste);
151         Yset_modeltime(0);
152         
153       
154        Y3run ('0');
155#ifdef K_FILTER
156        //compute values for u_d and v_d
157        strcpy(liste[1],"Tfil");
158        Yactraj(3,liste);
159        Yset_modeltime(0);
160        before_it(1);
161        Yforward(-1, 0);
162        strcpy(liste[1],"T_euler_d");
163        Yactraj(3,liste);
164        Yset_modeltime(0);
165        before_it(1);
166        Yforward(-1, 0);
167#endif
168
169
170    update_uv();
171    erase_udvd();
172
173    if (inc_save==1) {
174   
175   
176    //save u
177    YioTime=OFF;
178    sprintf(filesave,"%su%s%d.dat",dirsave,savename,i+1);
179    Yio_savestate("u","ij",0,filesave);
180   
181    //save v
182    sprintf(filesave,"%sv%s%d.dat",dirsave,savename,i+1);
183    Yio_savestate("v","ij",0,filesave);
184   
185    }
186    }
187    /*End of the optimization, we run another time the model to compute the final value of r_float
188    */
189     strcpy(liste[1],"M");
190    Yactraj(3, liste);
191         Yset_modeltime(0);
192         before_it(1);
193         Yforward(-1, 0);
194 if (inc_save==1) {
195          //save rfloat
196          YioTime=ON;
197          sprintf(filesave,"%sr_float_%s_%d.dat",dirsave,savename,nb_extiter);
198          Yio_savestate("r_float","i",0,filesave);
199         }
200   
201}
Note: See TracBrowser for help on using the repository browser.