Ignore:
Timestamp:
09/28/12 20:44:09 (12 years ago)
Author:
Mathieu Morlighem
Message:

BUG: do not check for segment if isautodiff=false

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp

    r13483 r13485  
    2525        Parameters *parameters       = NULL;
    2626        IssmDouble *requestedoutputs = NULL;
    27         bool        isdelta18o;
     27        bool        isdelta18o,isautodiff;
    2828
    2929        /*parameters for mass flux: {{{*/
     
    156156               
    157157       
    158         /*Deal with mass flux segments: {{{*/
    159         iomodel->FetchData(&mass_flux_present,MassFluxSegmentsPresentEnum);
    160         parameters->AddObject(new BoolParam(MassFluxSegmentsPresentEnum,mass_flux_present));
    161 
    162         if(mass_flux_present){
    163 
    164                 /*Fetch the mass flux segments necessary to compute the mass fluxes.  Build a DoubleMatArrayParam object out of them: */
    165                 iomodel->FetchData(&array,&mdims_array,&ndims_array,&mass_flux_num_profiles,MassFluxSegmentsEnum);
    166                 if(mass_flux_num_profiles==0)_error_("mass_flux_num_profiles is 0, when MassFlux computations were requested!");
    167 
    168                 /*Go through segments, and extract those that belong to this cpu: */
    169                 for(i=0;i<mass_flux_num_profiles;i++){
    170                         temp_matrix=array[i];
    171                         temp_m=mdims_array[i];
    172                         temp_n=ndims_array[i];
    173 
    174                         m=0;
    175                         for(j=0;j<temp_m;j++){
    176                                 if (  iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1] )m++;
    177                         }
    178                         if(m){
    179                                 matrix=xNewZeroInit<IssmDouble>(5*m);
    180                                 count=0;
     158        if(isautodiff){
     159                /*Deal with mass flux segments: {{{*/
     160                iomodel->Constant(&isautodiff,AutodiffIsautodiffEnum);
     161                iomodel->FetchData(&mass_flux_present,MassFluxSegmentsPresentEnum);
     162                parameters->AddObject(new BoolParam(MassFluxSegmentsPresentEnum,mass_flux_present));
     163
     164                if(mass_flux_present){
     165
     166                        /*Fetch the mass flux segments necessary to compute the mass fluxes.  Build a DoubleMatArrayParam object out of them: */
     167                        iomodel->FetchData(&array,&mdims_array,&ndims_array,&mass_flux_num_profiles,MassFluxSegmentsEnum);
     168                        if(mass_flux_num_profiles==0)_error_("mass_flux_num_profiles is 0, when MassFlux computations were requested!");
     169
     170                        /*Go through segments, and extract those that belong to this cpu: */
     171                        for(i=0;i<mass_flux_num_profiles;i++){
     172                                temp_matrix=array[i];
     173                                temp_m=mdims_array[i];
     174                                temp_n=ndims_array[i];
     175
     176                                m=0;
    181177                                for(j=0;j<temp_m;j++){
    182                                         if (iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1]){
    183                                                 for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k);
    184                                                 count++;
     178                                        if (  iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1] )m++;
     179                                }
     180                                if(m){
     181                                        matrix=xNewZeroInit<IssmDouble>(5*m);
     182                                        count=0;
     183                                        for(j=0;j<temp_m;j++){
     184                                                if (iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1]){
     185                                                        for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k);
     186                                                        count++;
     187                                                }
    185188                                        }
    186189                                }
     190                                else{
     191                                        matrix=NULL;
     192                                }
     193
     194                                /*Assign: */
     195                                array[i]=matrix;
     196                                mdims_array[i]=m;
     197                                ndims_array[i]=5;
     198
     199                                /*Free temporary matrix: */
     200                                xDelete<IssmDouble>(temp_matrix);
    187201                        }
    188                         else{
    189                                 matrix=NULL;
     202
     203                        /*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */
     204                        parameters->AddObject(new DoubleMatArrayParam(MassFluxSegmentsEnum,array,mass_flux_num_profiles,mdims_array,ndims_array));
     205
     206                        /*Free data: */
     207                        for(i=0;i<mass_flux_num_profiles;i++){
     208                                IssmDouble* matrix=array[i];
     209                                xDelete<IssmDouble>(matrix);
    190210                        }
    191 
    192                         /*Assign: */
    193                         array[i]=matrix;
    194                         mdims_array[i]=m;
    195                         ndims_array[i]=5;
    196 
    197                         /*Free temporary matrix: */
    198                         xDelete<IssmDouble>(temp_matrix);
     211                        xDelete<int>(mdims_array);
     212                        xDelete<int>(ndims_array);
     213                        xDelete<IssmDouble*>(array);
    199214                }
    200 
    201                 /*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */
    202                 parameters->AddObject(new DoubleMatArrayParam(MassFluxSegmentsEnum,array,mass_flux_num_profiles,mdims_array,ndims_array));
    203 
    204                 /*Free data: */
    205                 for(i=0;i<mass_flux_num_profiles;i++){
    206                         IssmDouble* matrix=array[i];
    207                         xDelete<IssmDouble>(matrix);
    208                 }
    209                 xDelete<int>(mdims_array);
    210                 xDelete<int>(ndims_array);
    211                 xDelete<IssmDouble*>(array);
     215                /*}}}*/
    212216        }
    213         /*}}}*/
    214217
    215218        /*Before returning, create parameters in case we are running Qmu or control types runs: */
Note: See TracChangeset for help on using the changeset viewer.