source: altifloat/src/floater.h @ 98

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

add function run_inc

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