Changeset 3460


Ignore:
Timestamp:
04/08/10 08:51:55 (15 years ago)
Author:
seroussi
Message:

put all loaded variables in iomodel

Location:
issm/trunk/src/c/ModelProcessorx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/ModelProcessorx/Balancedthickness/CreateParametersBalancedthickness.cpp

    r3436 r3460  
    1 /*!\file: CreateParametersBalancedthickness.cpp
    21 * \brief driver for creating parameters dataset, for prognostic analysis.
    32 */
     
    1615        int      count;
    1716        int      i;
    18         int      dim;
    19 
    20         double* vx=NULL;
    21         double* vy=NULL;
    22         double* vz=NULL;
    2317        double* u_g=NULL;
    24         double* pressure=NULL;
    25         double* temperature=NULL;
    26         double* thickness=NULL;
    27         double* surface=NULL;
    28         double* bed=NULL;
    29         double* accumulation=NULL;
    30         double* melting=NULL;
    3118
    3219        /*recover parameters : */
     
    3623
    3724        /*Get vx and vy: */
    38         IoModelFetchData(&vx,NULL,NULL,iomodel_handle,"vx");
    39         IoModelFetchData(&vy,NULL,NULL,iomodel_handle,"vy");
    40         IoModelFetchData(&vz,NULL,NULL,iomodel_handle,"vz");
     25        IoModelFetchData(&iomodel->vx,NULL,NULL,iomodel_handle,"vx");
     26        IoModelFetchData(&iomodel->vy,NULL,NULL,iomodel_handle,"vy");
     27        IoModelFetchData(&iomodel->vz,NULL,NULL,iomodel_handle,"vz");
    4128
    4229        u_g=(double*)xcalloc(iomodel->numberofvertices*3,sizeof(double));
    4330
    44         if(vx) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+0]=vx[i]/iomodel->yts;
    45         if(vy) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+1]=vy[i]/iomodel->yts;
    46         if(vz) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+2]=vz[i]/iomodel->yts;
     31        if(iomodel->vx) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+0]=iomodel->vx[i]/iomodel->yts;
     32        if(iomodel->vy) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+1]=iomodel->vy[i]/iomodel->yts;
     33        if(iomodel->vz) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+2]=iomodel->vz[i]/iomodel->yts;
    4734
    4835        count++;
     
    5239
    5340
    54         xfree((void**)&vx);
    55         xfree((void**)&vy);
    56         xfree((void**)&vz);
     41        xfree((void**)&iomodel->vx);
     42        xfree((void**)&iomodel->vy);
     43        xfree((void**)&iomodel->vz);
    5744        xfree((void**)&u_g);
    5845
    5946        /*Get melting: */
    60         IoModelFetchData(&melting,NULL,NULL,iomodel_handle,"melting");
    61         if(melting) for(i=0;i<iomodel->numberofvertices;i++)melting[i]=melting[i]/iomodel->yts;
     47        IoModelFetchData(&iomodel->melting,NULL,NULL,iomodel_handle,"melting");
     48        if(iomodel->melting) for(i=0;i<iomodel->numberofvertices;i++)iomodel->melting[i]=iomodel->melting[i]/iomodel->yts;
    6249       
    6350        count++;
    6451        param= new Param(count,"m_g",DOUBLEVEC);
    65         if(melting) param->SetDoubleVec(melting,iomodel->numberofvertices,1);
     52        if(iomodel->melting) param->SetDoubleVec(melting,iomodel->numberofvertices,1);
    6653        else param->SetDoubleVec(melting,0,1);
    6754        parameters->AddObject(param);
    6855
    6956        /*Free melting: */
    70         xfree((void**)&melting);
     57        xfree((void**)&iomodel->melting);
    7158
    7259        /*Get accumulation: */
    73         IoModelFetchData(&accumulation,NULL,NULL,iomodel_handle,"accumulation");
    74         if(accumulation) for(i=0;i<iomodel->numberofvertices;i++)accumulation[i]=accumulation[i]/iomodel->yts;
     60        IoModelFetchData(&iomodel->accumulation,NULL,NULL,iomodel_handle,"accumulation");
     61        if(iomodel->accumulation) for(i=0;i<iomodel->numberofvertices;i++)iomodel->accumulation[i]=iomodel->accumulation[i]/iomodel->yts;
    7562       
    7663        count++;
    7764        param= new Param(count,"a_g",DOUBLEVEC);
    78         if(accumulation) param->SetDoubleVec(accumulation,iomodel->numberofvertices,1);
    79         else param->SetDoubleVec(accumulation,0,0);
     65        if(iomodel->accumulation) param->SetDoubleVec(iomodel->accumulation,iomodel->numberofvertices,1);
     66        else param->SetDoubleVec(iomodel->accumulation,0,0);
    8067        parameters->AddObject(param);
    8168
    8269        /*Free accumulation: */
    83         xfree((void**)&accumulation);
     70        xfree((void**)&iomodel->accumulation);
    8471
    8572        /*Assign output pointer: */
  • issm/trunk/src/c/ModelProcessorx/Balancedvelocities/CreateParametersBalancedvelocities.cpp

    r3436 r3460  
    1616        int      count;
    1717        int      i;
    18         int      dim;
    19 
    20         double* vx=NULL;
    21         double* vy=NULL;
    22         double* vz=NULL;
    2318        double* u_g=NULL;
    24         double* pressure=NULL;
    25         double* temperature=NULL;
    26         double* thickness=NULL;
    27         double* surface=NULL;
    28         double* bed=NULL;
    29         double* accumulation=NULL;
    30         double* melting=NULL;
    3119
    3220        /*recover parameters : */
     
    3624
    3725        /*Get vx and vy: */
    38         IoModelFetchData(&vx,NULL,NULL,iomodel_handle,"vx");
    39         IoModelFetchData(&vy,NULL,NULL,iomodel_handle,"vy");
    40         IoModelFetchData(&vz,NULL,NULL,iomodel_handle,"vz");
     26        IoModelFetchData(&iomodel->vx,NULL,NULL,iomodel_handle,"vx");
     27        IoModelFetchData(&iomodel->vy,NULL,NULL,iomodel_handle,"vy");
     28        IoModelFetchData(&iomodel->vz,NULL,NULL,iomodel_handle,"vz");
    4129
    4230        u_g=(double*)xcalloc(iomodel->numberofvertices*3,sizeof(double));
    4331
    44         if(vx) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+0]=vx[i]/iomodel->yts;
    45         if(vy) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+1]=vy[i]/iomodel->yts;
    46         if(vz) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+2]=vz[i]/iomodel->yts;
     32        if(iomodel->vx) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+0]=iomodel->vx[i]/iomodel->yts;
     33        if(iomodel->vy) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+1]=iomodel->vy[i]/iomodel->yts;
     34        if(iomodel->vz) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+2]=iomodel->vz[i]/iomodel->yts;
    4735
    4836        count++;
     
    5139        parameters->AddObject(param);
    5240
    53 
    54         xfree((void**)&vx);
    55         xfree((void**)&vy);
    56         xfree((void**)&vz);
     41        xfree((void**)&iomodel->vx);
     42        xfree((void**)&iomodel->vy);
     43        xfree((void**)&iomodel->vz);
    5744        xfree((void**)&u_g);
    5845
    5946        /*Get thickness: */
    60         IoModelFetchData(&thickness,NULL,NULL,iomodel_handle,"thickness");
     47        IoModelFetchData(&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness");
    6148       
    6249        count++;
    6350        param= new Param(count,"h_g",DOUBLEVEC);
    64         if(thickness) param->SetDoubleVec(thickness,iomodel->numberofvertices,1);
    65         else param->SetDoubleVec(thickness,0,0);
     51        if(iomodel->thickness) param->SetDoubleVec(iomodel->thickness,iomodel->numberofvertices,1);
     52        else param->SetDoubleVec(iomodel->thickness,0,0);
    6653        parameters->AddObject(param);
    6754
    6855        /*Free thickness: */
    69         xfree((void**)&thickness);
     56        xfree((void**)&iomodel->thickness);
    7057
    7158        /*Get melting: */
    72         IoModelFetchData(&melting,NULL,NULL,iomodel_handle,"melting");
    73         if(melting) for(i=0;i<iomodel->numberofvertices;i++)melting[i]=melting[i]/iomodel->yts;
     59        IoModelFetchData(&iomodel->melting,NULL,NULL,iomodel_handle,"melting");
     60        if(iomodel->melting) for(i=0;i<iomodel->numberofvertices;i++)iomodel->melting[i]=iomodel->melting[i]/iomodel->yts;
    7461       
    7562        count++;
    7663        param= new Param(count,"m_g",DOUBLEVEC);
    77         if(melting) param->SetDoubleVec(melting,iomodel->numberofvertices,1);
    78         else param->SetDoubleVec(melting,0,1);
     64        if(iomodel->melting) param->SetDoubleVec(iomodel->melting,iomodel->numberofvertices,1);
     65        else param->SetDoubleVec(iomodel->melting,0,1);
    7966        parameters->AddObject(param);
    8067
    8168        /*Free melting: */
    82         xfree((void**)&melting);
     69        xfree((void**)&iomodel->melting);
    8370
    8471        /*Get accumulation: */
    85         IoModelFetchData(&accumulation,NULL,NULL,iomodel_handle,"accumulation");
    86         if(accumulation) for(i=0;i<iomodel->numberofvertices;i++)accumulation[i]=accumulation[i]/iomodel->yts;
     72        IoModelFetchData(&iomodel->accumulation,NULL,NULL,iomodel_handle,"accumulation");
     73        if(iomodel->accumulation) for(i=0;i<iomodel->numberofvertices;i++)iomodel->accumulation[i]=iomodel->accumulation[i]/iomodel->yts;
    8774       
    8875        count++;
    8976        param= new Param(count,"a_g",DOUBLEVEC);
    90         if(accumulation) param->SetDoubleVec(accumulation,iomodel->numberofvertices,1);
    91         else param->SetDoubleVec(accumulation,0,0);
     77        if(iomodel->accumulation) param->SetDoubleVec(iomodel->accumulation,iomodel->numberofvertices,1);
     78        else param->SetDoubleVec(iomodel->accumulation,0,0);
    9279        parameters->AddObject(param);
    9380
    9481        /*Free accumulation: */
    95         xfree((void**)&accumulation);
     82        xfree((void**)&iomodel->accumulation);
    9683
    9784
  • issm/trunk/src/c/ModelProcessorx/Melting/CreateParametersMelting.cpp

    r3436 r3460  
    1717        int i;
    1818
    19         double* melting=NULL;
    20 
    2119        /*recover parameters : */
    2220        parameters=*pparameters;
     
    3129
    3230                /*Get melting: */
    33                 IoModelFetchData(&melting,NULL,NULL,iomodel_handle,"melting");
    34                 if(melting) {
    35                         for(i=0;i<iomodel->numberofvertices;i++)melting[i]=melting[i]/iomodel->yts;   //m/s instead of m/yr
     31                IoModelFetchData(&iomodel->melting,NULL,NULL,iomodel_handle,"melting");
     32                if(iomodel->melting) {
     33                        for(i=0;i<iomodel->numberofvertices;i++)iomodel->melting[i]=iomodel->melting[i]/iomodel->yts;   //m/s instead of m/yr
    3634                }
    3735                else{
    38                         for(i=0;i<iomodel->numberofvertices;i++)melting[i]=0;
     36                        for(i=0;i<iomodel->numberofvertices;i++)iomodel->melting[i]=0;
    3937                }
    4038
    4139                count++;
    4240                param= new Param(count,"m_g",DOUBLEVEC);
    43                 if(melting) param->SetDoubleVec(melting,iomodel->numberofvertices);
    44                 else param->SetDoubleVec(melting,0);
     41                if(iomodel->melting) param->SetDoubleVec(iomodel->melting,iomodel->numberofvertices);
     42                else param->SetDoubleVec(iomodel->melting,0);
    4543                parameters->AddObject(param);
    4644
    4745                /*Free melting: */
    48                 xfree((void**)&melting);
     46                xfree((void**)&iomodel->melting);
    4947        }
    5048
  • issm/trunk/src/c/ModelProcessorx/Prognostic/CreateParametersPrognostic.cpp

    r3436 r3460  
    1818        int      i;
    1919        int      dim;
    20 
    21         double* vx=NULL;
    22         double* vy=NULL;
    23         double* vz=NULL;
    2420        double* u_g=NULL;
    25         double* pressure=NULL;
    26         double* temperature=NULL;
    27         double* thickness=NULL;
    28         double* surface=NULL;
    29         double* bed=NULL;
    30         double* accumulation=NULL;
    31         double* melting=NULL;
    3221
    3322        /*recover parameters : */
     
    3726
    3827        /*Get vx and vy: */
    39         IoModelFetchData(&vx,NULL,NULL,iomodel_handle,"vx");
    40         IoModelFetchData(&vy,NULL,NULL,iomodel_handle,"vy");
    41         IoModelFetchData(&vz,NULL,NULL,iomodel_handle,"vz");
     28        IoModelFetchData(&iomodel->vx,NULL,NULL,iomodel_handle,"vx");
     29        IoModelFetchData(&iomodel->vy,NULL,NULL,iomodel_handle,"vy");
     30        IoModelFetchData(&iomodel->vz,NULL,NULL,iomodel_handle,"vz");
    4231
    4332        u_g=(double*)xcalloc(iomodel->numberofvertices*3,sizeof(double));
    4433
    45         if(vx) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+0]=vx[i]/iomodel->yts;
    46         if(vy) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+1]=vy[i]/iomodel->yts;
    47         if(vz) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+2]=vz[i]/iomodel->yts;
     34        if(iomodel->vx) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+0]=iomodel->vx[i]/iomodel->yts;
     35        if(iomodel->vy) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+1]=iomodel->vy[i]/iomodel->yts;
     36        if(iomodel->vz) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+2]=iomodel->vz[i]/iomodel->yts;
    4837
    4938        count++;
     
    5342
    5443
    55         xfree((void**)&vx);
    56         xfree((void**)&vy);
    57         xfree((void**)&vz);
     44        xfree((void**)&iomodel->vx);
     45        xfree((void**)&iomodel->vy);
     46        xfree((void**)&iomodel->vz);
    5847        xfree((void**)&u_g);
    5948
     
    8978
    9079        /*Get thickness: */
    91         IoModelFetchData(&thickness,NULL,NULL,iomodel_handle,"thickness");
     80        IoModelFetchData(&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness");
    9281       
    9382        count++;
    9483        param= new Param(count,"h_g",DOUBLEVEC);
    95         if(thickness) param->SetDoubleVec(thickness,iomodel->numberofvertices,1);
    96         else param->SetDoubleVec(thickness,0,0);
     84        if(iomodel->thickness) param->SetDoubleVec(iomodel->thickness,iomodel->numberofvertices,1);
     85        else param->SetDoubleVec(iomodel->thickness,0,0);
    9786        parameters->AddObject(param);
    9887
    9988        /*Free thickness: */
    100         xfree((void**)&thickness);
     89        xfree((void**)&iomodel->thickness);
    10190
    10291        /*Get surface: */
    103         IoModelFetchData(&surface,NULL,NULL,iomodel_handle,"surface");
     92        IoModelFetchData(&iomodel->surface,NULL,NULL,iomodel_handle,"surface");
    10493       
    10594        count++;
    10695        param= new Param(count,"s_g",DOUBLEVEC);
    107         if(surface) param->SetDoubleVec(surface,iomodel->numberofvertices,1);
    108         else param->SetDoubleVec(surface,0,0);
     96        if(iomodel->surface) param->SetDoubleVec(iomodel->surface,iomodel->numberofvertices,1);
     97        else param->SetDoubleVec(iomodel->surface,0,0);
    10998        parameters->AddObject(param);
    11099
    111100        /*Free surface: */
    112         xfree((void**)&surface);
     101        xfree((void**)&iomodel->surface);
    113102
    114103        /*Get bed: */
    115         IoModelFetchData(&bed,NULL,NULL,iomodel_handle,"bed");
     104        IoModelFetchData(&iomodel->bed,NULL,NULL,iomodel_handle,"bed");
    116105       
    117106        count++;
    118107        param= new Param(count,"b_g",DOUBLEVEC);
    119         if(bed) param->SetDoubleVec(bed,iomodel->numberofvertices,1);
    120         else param->SetDoubleVec(bed,0,0);
     108        if(iomodel->bed) param->SetDoubleVec(iomodel->bed,iomodel->numberofvertices,1);
     109        else param->SetDoubleVec(iomodel->bed,0,0);
    121110        parameters->AddObject(param);
    122111
    123112        /*Free bed: */
    124         xfree((void**)&bed);
     113        xfree((void**)&iomodel->bed);
    125114
    126115        /*Get melting: */
    127         IoModelFetchData(&melting,NULL,NULL,iomodel_handle,"melting");
    128         if(melting) for(i=0;i<iomodel->numberofvertices;i++)melting[i]=melting[i]/iomodel->yts;
     116        IoModelFetchData(&iiomodel->melting,NULL,NULL,iomodel_handle,"melting");
     117        if(iomodel->melting) for(i=0;i<iomodel->numberofvertices;i++)iomodel->melting[i]=iomodel->melting[i]/iomodel->yts;
    129118       
    130119        count++;
    131120        param= new Param(count,"m_g",DOUBLEVEC);
    132         if(melting) param->SetDoubleVec(melting,iomodel->numberofvertices,1);
    133         else param->SetDoubleVec(melting,0,1);
     121        if(iomodel->melting) param->SetDoubleVec(iomodel->melting,iomodel->numberofvertices,1);
     122        else param->SetDoubleVec(iomodel->melting,0,1);
    134123        parameters->AddObject(param);
    135124
    136125        /*Free melting: */
    137         xfree((void**)&melting);
     126        xfree((void**)&iomodel->melting);
    138127
    139128        /*Get accumulation: */
    140         IoModelFetchData(&accumulation,NULL,NULL,iomodel_handle,"accumulation");
    141         if(accumulation) for(i=0;i<iomodel->numberofvertices;i++)accumulation[i]=accumulation[i]/iomodel->yts;
     129        IoModelFetchData(&iomodel->accumulation,NULL,NULL,iomodel_handle,"accumulation");
     130        if(iomodel->accumulation) for(i=0;i<iomodel->numberofvertices;i++)iomodel->accumulation[i]=iomodel->accumulation[i]/iomodel->yts;
    142131       
    143132        count++;
    144133        param= new Param(count,"a_g",DOUBLEVEC);
    145         if(accumulation) param->SetDoubleVec(accumulation,iomodel->numberofvertices,1);
    146         else param->SetDoubleVec(accumulation,0,0);
     134        if(iomodel->accumulation) param->SetDoubleVec(iomodel->accumulation,iomodel->numberofvertices,1);
     135        else param->SetDoubleVec(iomodel->accumulation,0,0);
    147136        parameters->AddObject(param);
    148137
    149138        /*Free accumulation: */
    150         xfree((void**)&accumulation);
    151 
     139        xfree((void**)&iomodel->accumulation);
    152140
    153141        /*Assign output pointer: */
  • issm/trunk/src/c/ModelProcessorx/Thermal/CreateParametersThermal.cpp

    r3436 r3460  
    1717        int      count;
    1818        int i;
    19 
    20         double* vx=NULL;
    21         double* vy=NULL;
    22         double* vz=NULL;
    2319        double* u_g=NULL;
    24         double* pressure=NULL;
    25         double* temperature=NULL;
    2620
    2721        /*recover parameters : */
     
    4034
    4135        /*Get vx vy and vz: */
    42         IoModelFetchData(&vx,NULL,NULL,iomodel_handle,"vx");
    43         IoModelFetchData(&vy,NULL,NULL,iomodel_handle,"vy");
    44         IoModelFetchData(&vz,NULL,NULL,iomodel_handle,"vz");
     36        IoModelFetchData(&iomodel->vx,NULL,NULL,iomodel_handle,"vx");
     37        IoModelFetchData(&iomodel->vy,NULL,NULL,iomodel_handle,"vy");
     38        IoModelFetchData(&iomodel->vz,NULL,NULL,iomodel_handle,"vz");
    4539
    4640        u_g=(double*)xcalloc(iomodel->numberofvertices*3,sizeof(double));
    4741
    48         if(vx) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+0]=vx[i]/iomodel->yts;
    49         if(vy) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+1]=vy[i]/iomodel->yts;
    50         if(vz) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+2]=vz[i]/iomodel->yts;
     42        if(iomodel->vx) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+0]=iomodel->vx[i]/iomodel->yts;
     43        if(iomodel->vy) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+1]=iomodel->vy[i]/iomodel->yts;
     44        if(iomodel->vz) for(i=0;i<iomodel->numberofvertices;i++)u_g[3*i+2]=iomodel->vz[i]/iomodel->yts;
    5145
    5246        count++;
     
    5549        parameters->AddObject(param);
    5650
    57         xfree((void**)&vx);
    58         xfree((void**)&vy);
    59         xfree((void**)&vz);
     51        xfree((void**)&iomodel->vx);
     52        xfree((void**)&iomodel->vy);
     53        xfree((void**)&iomodel->vz);
    6054        xfree((void**)&u_g);
    6155       
    6256        /*Get pressure: */
    63         IoModelFetchData(&pressure,NULL,NULL,iomodel_handle,"pressure");
     57        IoModelFetchData(&iomodel->pressure,NULL,NULL,iomodel_handle,"pressure");
    6458       
    6559        count++;
    6660        param= new Param(count,"p_g",DOUBLEVEC);
    67         if(pressure) param->SetDoubleVec(pressure,iomodel->numberofvertices,1);
    68         else param->SetDoubleVec(pressure,0,0);
     61        if(iomodel->pressure) param->SetDoubleVec(iomodel->pressure,iomodel->numberofvertices,1);
     62        else param->SetDoubleVec(iomodel->pressure,0,0);
    6963        parameters->AddObject(param);
    7064
    7165        /*Free pressure: */
    72         xfree((void**)&pressure);
     66        xfree((void**)&iomodel->pressure);
    7367
    7468        /* get initial temperature and melting if transient*/
     
    7670
    7771                /*Get melting and temperature: */
    78                 IoModelFetchData(&temperature,NULL,NULL,iomodel_handle,"temperature");
     72                IoModelFetchData(&iomodel->temperature,NULL,NULL,iomodel_handle,"temperature");
    7973
    8074                count++;
    8175                param= new Param(count,"t_g",DOUBLEVEC);
    82                 if(temperature) param->SetDoubleVec(temperature,iomodel->numberofvertices,1);
     76                if(iomodel->temperature) param->SetDoubleVec(iomodel->temperature,iomodel->numberofvertices,1);
    8377                else ISSMERROR(exprintf("Missing initial temperature"));
    8478                parameters->AddObject(param);
    8579
    8680                /*Free temperature: */
    87                 xfree((void**)&temperature);
     81                xfree((void**)&iomodel->temperature);
    8882        }
    8983
Note: See TracChangeset for help on using the changeset viewer.