source: altifloat/src/floater.h @ 108

Last change on this file since 108 was 108, checked in by leila_ocean, 11 years ago

with filter

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