Changeset 28259


Ignore:
Timestamp:
05/07/24 10:52:50 (12 months ago)
Author:
Mathieu Morlighem
Message:

CHG: implementing sum for IssmMpiVec

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h

    r27102 r28259  
    588588                /*}}}*/
    589589                void Pow(doubletype scale_factor){/*{{{*/
    590 
    591                         int i;
    592                         for(i=0;i<this->M;i++)this->vector[i]=pow(this->vector[i],scale_factor);
    593 
     590                        for(int i=0;i<this->M;i++)this->vector[i]=pow(this->vector[i],scale_factor);
    594591                }
    595592                /*}}}*/
    596593                void Sum(doubletype* pvalue){/*{{{*/
    597                         _error_("not support yet!");
     594
     595                        doubletype local_sum=0;
     596                        doubletype sum;
     597
     598                        for(int i=0;i<this->m;i++) local_value+=this->vector[i];
     599                        ISSM_MPI_Reduce(&local_sum, &sum, 1, ISSM_MPI_DOUBLE, ISSM_MPI_SUM, 0, IssmComm::GetComm());
     600                        ISSM_MPI_Bcast(&sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
     601                        *pvalue=sum;
     602
    598603                }
    599604                /*}}}*/
Note: See TracChangeset for help on using the changeset viewer.