Changeset 25537


Ignore:
Timestamp:
09/05/20 19:00:40 (5 years ago)
Author:
Eric.Larour
Message:

CHG: fixed issue with long int for length of large files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/branches/trunk-larour-SLPS2020/src/c/main/issm_post.cpp

    r25496 r25537  
    6060        /*Retrieve fields:*/
    6161        nfields=atoi(argv[5]);
     62        fields=xNew<char*>(nfields);
    6263        for(int i=0;i<nfields;i++){
    63                 fields=xNew<char*>(nfields);
    6464                string= argv[6+i];
    6565                field=xNew<char>(strlen(string)+1);
     
    6969        parameters->AddObject(new StringArrayParam(FieldsEnum,fields,nfields));
    7070        offset=6+nfields;
     71
     72        /*free some memory: */
     73        for(int i=0;i<nfields;i++){
     74                char* field=fields[i];
     75                xDelete<char>(field);
     76        }
     77        xDelete<char*>(fields);
    7178
    7279        /*Retrieve time steps:*/
     
    8693        for (int i=step1;i<=step2;i++)steps[i-step1]=i;
    8794        parameters->AddObject(new IntVecParam(StepsEnum,steps,nsteps));
    88 
    8995        offset++;
     96
     97        /*free some memory:*/
     98        xDelete<int>(steps);
     99
    90100        /*}}}*/
    91101       
     
    113123                }
    114124                parameters->AddObject(new IntVecParam(IndicesEnum,indices,nindices));
     125
     126                /*free some memory:*/
     127                xDelete<int>(indices);
    115128               
    116129                ComputeSampleSeries(parameters,results);
    117130        }
    118 
    119 
    120131
    121132        else _error_("unknown method: " << method << "\n");
     
    124135        ISSM_MPI_Barrier(ISSM_MPI_COMM_WORLD); _printf0_("Output file.\n");
    125136        OutputStatistics(parameters,results);
     137
     138        /*Delete ressources:*/
     139        delete parameters;
     140        delete results;
    126141
    127142        /*Finalize ISSM:*/
     
    190205                _printf0_("reading file #: " << i << "\n");
    191206                char file[1000];
    192                 int  length;
     207                long int  length;
    193208                char* buffer=NULL;
    194209
     
    197212
    198213                /*open file: */
    199                 _printf0_("    opening file:\n");
     214                _printf0_("    opening file: " << file << "\n");
    200215                FILE* fid=fopen(file,"rb");
     216                if(fid==NULL) _error_("    could not open file: " << file << "\n");
    201217
    202218                /*figure out size of file, and read the whole thing:*/
     
    505521                _printf0_("reading file #: " << i << "\n");
    506522                char file[1000];
    507                 int  length;
     523                long int  length;
    508524                char* buffer=NULL;
    509525
     
    668684                _printf0_("reading file #: " << i << "\n");
    669685                char file[1000];
    670                 int  length;
     686                long int  length;
    671687                char* buffer=NULL;
    672688
     
    675691
    676692                /*open file: */
    677                 _printf0_("    opening file:\n");
     693                _printf0_("    opening file: " << file < "\n");
    678694                FILE* fid=fopen(file,"rb");
    679695                if(fid==NULL)_error_("cound not open file: " << file << "\n");
     
    715731                                                xMemCpy<IssmDouble>(minxs[counter],doublemat,doublematsize);
    716732                                                xsize[counter]=doublematsize;
     733                                                xDelete<IssmDouble>(doublemat);
    717734                                        }
    718735                                        else _error_("cannot carry out statistics on type " << xtype[counter]);
     
    730747                                                        if(doublemat[k]<newmin[k])newmin[k]=doublemat[k];
    731748                                                }
     749                                                xDelete<IssmDouble>(doublemat);
    732750                                        }
    733751                                        else _error_("cannot carry out statistics on type " << xtype[counter]);
     
    773791                                                timemean[k]+=doublemat[k]/nsteps;
    774792                                        }
     793                                        xDelete<IssmDouble>(doublemat);
    775794                                }
    776795
     
    899918                _printf0_("reading file #: " << i << "\n");
    900919                char file[1000];
    901                 int  length;
     920                long int  length;
    902921                char* buffer=NULL;
    903922
     
    952971                                                }
    953972                                                histogram[counter]=localhistogram;
     973                                                xDelete<IssmDouble>(doublemat);
    954974                                        }
    955975                                        else _error_("cannot carry out statistics on type " << xtype[counter]);
     
    972992                                                        localhistogram[k*nbins+index]++;
    973993                                                }
     994                                                xDelete<IssmDouble>(doublemat);
    974995                                        }
    975996                                        else _error_("cannot carry out statistics on type " << xtype[counter]);
     
    10181039                                                timemean[k]+=doublemat[k]/nsteps;
    10191040                                        }
     1041                                        xDelete<IssmDouble>(doublemat);
    10201042                                }
    10211043
     
    10511073                xDelete<char>(buffer);
    10521074        }
     1075        _printf0_("Start aggregating histogram:\n");
    10531076
    10541077        /*We have agregated histograms across the cluster, now gather them across  the cluster onto
     
    10881111                                /*we are broadcasting double arrays:*/
    10891112                                IssmDouble* histo=histogram[counter];
    1090                                 IssmDouble*  allhisto=xNew<IssmDouble>(size*nbins);
     1113                                IssmDouble* allhisto=xNew<IssmDouble>(size*nbins);
    10911114                               
    10921115                                ISSM_MPI_Allreduce(histo,allhisto,size*nbins,ISSM_MPI_PDOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
     1116                                xDelete<IssmDouble>(histo);
    10931117
    10941118                                /*add to results:*/
     
    11071131                } /*}}}*/
    11081132        }
     1133        _printf0_("Start aggregating time mean histogram:\n");
    11091134       
    11101135        /*Now do the same for the time mean fields:*/
     
    11401165
    11411166                        ISSM_MPI_Allreduce(histo,allhisto,size*nbins,ISSM_MPI_PDOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
     1167                        xDelete<IssmDouble>(histo);
    11421168                        /*add to results at step 1:*/
    11431169                        if(my_rank==0){
Note: See TracChangeset for help on using the changeset viewer.