source: issm/oecreview/Archive/16133-16554/ISSM-16498-16499.diff@ 16556

Last change on this file since 16556 was 16556, checked in by Mathieu Morlighem, 11 years ago

NEW: added Archive/16133-16554

File size: 6.8 KB
  • TabularUnified ../trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp

     
    2121               
    2222                definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i));
    2323
    24                 if (strcmp(definition->Name(),output_string)==0){
     24                char* name = definition->Name();
     25                if (strcmp(name,output_string)==0){
    2526                        /*This is the object that we have been chasing for. compute the response and return: */
    2627                        return_value=definition->Response(femmodel);
    2728                        delete output_definitions;
     29                        xDelete<char>(name);
    2830                        return return_value;
    2931                }
     32                xDelete<char>(name);
    3033        }
    3134        /*If we are here, did not find the definition for this response, not good!: */
    3235        _error_("Could not find the response for output definition " << output_string << " because could not find the definition itself!");
  • TabularUnified ../trunk-jpl/src/c/classes/IoModel.cpp

     
    10871087        int* codes=NULL;
    10881088
    10891089        /*output: */
    1090         int   numstrings=0;
    1091         char** strings=NULL;
     1090        int    numstrings = 0;
     1091        char **strings    = NULL;
    10921092
    10931093        /*intermediary: */
    1094         char* string=NULL;
    1095         int   string_size;
    1096         int*   code=NULL;
    1097         fpos_t* file_positions=NULL;
     1094        char   *string         = NULL;
     1095        int     string_size;
     1096        int    *code           = NULL;
     1097        fpos_t *file_positions = NULL;
    10981098
    10991099        /*recover my_rank:*/
    11001100        my_rank=IssmComm::GetRank();
     
    11031103        file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum);
    11041104
    11051105        if(num_instances){
    1106 
    11071106                strings=xNew<char*>(num_instances);
    11081107
    11091108                for(i=0;i<num_instances;i++){
    11101109
    1111 
    11121110                        if(my_rank==0){
    11131111                                /*check we are indeed finding a string, not something else: */
    11141112                                if(codes[i]!=4)_error_("expecting a string for enum " << EnumToStringx(data_enum));
     
    11371135                        }
    11381136                        strings[i]=string;
    11391137                }
    1140 
    11411138        }
    11421139        /*Free ressources:*/
    11431140        xDelete<int>(codes);
     
    11521149
    11531150        int i;
    11541151        int num_instances;
    1155         int my_rank;
    1156        
    11571152        fpos_t* file_positions=NULL;
    11581153
    11591154        /*output: */
    1160         IssmDouble** matrices=NULL;
    1161         int*     mdims=NULL;
    1162         int*     ndims=NULL;
     1155        IssmDouble **matrices = NULL;
     1156        int         *mdims    = NULL;
     1157        int         *ndims    = NULL;
    11631158
    11641159        /*intermediary: */
    1165         int     M, N;
     1160        int          M, N;
    11661161        IssmPDouble *pmatrix = NULL;
    1167         IssmDouble *matrix = NULL;
    1168         int*    codes=NULL;
    1169         int     code;
     1162        IssmDouble  *matrix = NULL;
     1163        int         *codes   = NULL;
     1164        int          code;
    11701165
    11711166        /*recover my_rank:*/
    1172         my_rank=IssmComm::GetRank();
     1167        int my_rank=IssmComm::GetRank();
    11731168       
    11741169        /*Get file pointers to beginning of the data (multiple instances of it): */
    11751170        file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum);
     
    11811176                mdims=xNew<int>(num_instances);
    11821177                ndims=xNew<int>(num_instances);
    11831178
    1184                 for(i=0;i<num_instances;i++){
     1179                for(int i=0;i<num_instances;i++){
    11851180
    11861181                        if(my_rank==0){
    11871182                                code=codes[i];
     
    12121207                                ISSM_MPI_Bcast(pmatrix,M*N,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm());
    12131208
    12141209                                _assert_(this->independents);
    1215                                 if (this->independents[data_enum]){
     1210                                if(this->independents[data_enum]){
    12161211                                        /*this data has already been checked out! So cancel all that we've done here, and return
    12171212                                         * the data[data_enum] directly: */
    12181213                                        matrix=this->data[data_enum];
     
    12391234
    12401235        /*Assign output pointers: */
    12411236        *pmatrices=matrices;
    1242         if(pmdims)*pmdims=mdims;
    1243         if(pndims)*pndims=ndims;
     1237        if(pmdims){
     1238                *pmdims=mdims;
     1239        }
     1240        else{
     1241                xDelete<int>(mdims);
     1242        }
     1243        if(pndims){
     1244                *pndims=ndims;
     1245        }
     1246        else{
     1247                xDelete<int>(ndims);
     1248        }
    12441249        *pnumrecords=num_instances;
    12451250}
    12461251/*}}}*/
     
    14471452/*FUNCTION IoModel::SetFilePointersToData{{{*/
    14481453fpos_t* IoModel::SetFilePointersToData(int** pcodes,int** pvector_types, int* pnum_instances, int data_enum){
    14491454
    1450         int  my_rank;
    1451         int  found         = 0;
    1452         int  record_enum;
    1453         int  record_length;
    1454         int  record_code;       //1 to 7 number
    1455         int  vector_type;       //1 to 7 number
    1456         int* vector_types   = NULL;
    1457         int* codes= NULL;
    1458         int  num_instances  = 0;
    1459         int  counter;
    1460         fpos_t* file_positions=NULL;
     1455        int     found          = 0;
     1456        int     record_enum;
     1457        int     record_length;
     1458        int     record_code;           //1 to 7 number
     1459        int     vector_type;           //1 to 7 number
     1460        int    *vector_types   = NULL;
     1461        int    *codes          = NULL;
     1462        int     num_instances  = 0;
     1463        int     counter;
     1464        fpos_t *file_positions = NULL;
    14611465
    14621466        /*recover my_rank:*/
    1463         my_rank=IssmComm::GetRank();
     1467        int my_rank=IssmComm::GetRank();
    14641468
    14651469        /*Go find in the binary file, the data we want to fetch and count the number of
    14661470         * instances it appears: */
     
    14881492                /*Ok, initialize the number of file handles we are going to return: */
    14891493                if(num_instances){
    14901494                        file_positions = xNew<fpos_t>(num_instances);
    1491                         codes = xNew<int>(num_instances);
    1492                         vector_types = xNew<int>(num_instances);
     1495                        codes          = xNew<int>(num_instances);
     1496                        vector_types   = xNew<int>(num_instances);
    14931497                }
    1494 
    14951498       
    14961499                /*Reset FILE* position to the beginning of the file, and start again, this time saving the data information
    14971500                 * as we find it: */
     
    15151518                                if(5<=record_code && record_code<=7){
    15161519                                        if(fread(&vector_type,sizeof(int),1,fid)!=1) _error_("Could not read vector_type");
    15171520                                }
    1518                                 codes[counter]=record_code;
    1519                                 vector_types[counter]=vector_type;
     1521                                codes[counter]        = record_code;
     1522                                vector_types[counter] = vector_type;
    15201523                                fgetpos(fid,file_positions+counter);
    15211524                               
    15221525                                /*backup and skip over the record, as we have more work to do: */
     
    15391542        ISSM_MPI_Bcast(&num_instances,1,ISSM_MPI_INT,0,IssmComm::GetComm());
    15401543
    15411544        /*Assign output pointers:*/
    1542         *pcodes=codes;
    1543         *pnum_instances=num_instances;
    1544         if(pvector_types)*pvector_types=vector_types;
     1545        *pcodes         = codes;
     1546        *pnum_instances = num_instances;
     1547        if(pvector_types){
     1548                *pvector_types=vector_types;
     1549        }
     1550        else{
     1551                xDelete<int>(vector_types);
     1552        }
    15451553        return file_positions;
    15461554}
    15471555/*}}}*/
  • TabularUnified ../trunk-jpl/src/c/classes/Massfluxatgate.h

     
    126126                /*}}}*/
    127127                /*Definition virtual function resolutoin: */
    128128                /*FUNCTION char* Name() {{{*/
    129                 char*  Name(){
    130                         char* name2=NULL;
     129                char* Name(){
    131130
    132                         name2=xNew<char>(strlen(this->name)+1);
     131                        char* name2=xNew<char>(strlen(this->name)+1);
    133132                        xMemCpy(name2,this->name,strlen(this->name)+1);
    134133
    135134                        return name2;
Note: See TracBrowser for help on using the repository browser.