Changeset 13601


Ignore:
Timestamp:
10/10/12 22:53:28 (12 years ago)
Author:
Eric.Larour
Message:

CHG: more changes to switch from my_rank and num_procs to IssmComm::GetSize and IssmComm::GetRank

Location:
issm/trunk-jpl/src/c/toolkits/petsc/patches
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp

    r13595 r13601  
    1717
    1818        /*externals :*/
    19         extern int my_rank;
    20         extern int num_procs;
     19        int my_rank2;
     20        int num_procs2;
    2121       
     22        /*recover my_rank2 and num_procs2:*/
     23        MPI_Comm_size(comm,&num_procs2);
     24        MPI_Comm_rank(comm,&my_rank2);
     25
    2226        /*output: */
    2327        int lower_row,upper_row;
     
    2832
    2933        /*Gather all range values into allranges, for all nodes*/
    30         allranges=xNew<int>(num_procs);
     34        allranges=xNew<int>(num_procs2);
    3135        MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,comm);
    3236
     
    3438        lower_row=0;
    3539        upper_row=lower_row+allranges[0];
    36         for (i=1;i<=my_rank;i++){
     40        for (i=1;i<=my_rank2;i++){
    3741                lower_row=lower_row+allranges[i-1];
    3842                upper_row=upper_row+allranges[i];
  • TabularUnified issm/trunk-jpl/src/c/toolkits/petsc/patches/MatToSerial.cpp

    r13595 r13601  
    1616
    1717        int i;
    18         extern int my_rank;
    19         extern int num_procs;
     18        int my_rank2;
     19        int num_procs2;
    2020       
    2121        /*Petsc variables*/
     
    2929        int buffer[3];
    3030       
     31        /*recover my_rank2 and num_procs2:*/
     32        MPI_Comm_size(comm,&num_procs2);
     33        MPI_Comm_rank(comm,&my_rank2);
     34
    3135        /*Output*/
    3236        double* outmatrix=NULL;
     
    4145       
    4246        /*Local and global allocation*/
    43         if (my_rank==0)outmatrix=xNew<double>(M*N);
     47        if (my_rank2==0)outmatrix=xNew<double>(M*N);
    4448       
    4549        if (range){
     
    6165         * We send these rows to the matrix on node 0*/
    6266       
    63         for (i=1;i<num_procs;i++){
    64                 if (my_rank==i){
    65                         buffer[0]=my_rank;
     67        for (i=1;i<num_procs2;i++){
     68                if (my_rank2==i){
     69                        buffer[0]=my_rank2;
    6670                        buffer[1]=lower_row;
    6771                        buffer[2]=range;
     
    6973                        if (range)MPI_Send(local_matrix,N*range,MPI_DOUBLE,0,1,comm);
    7074                }
    71                 if (my_rank==0){
     75                if (my_rank2==0){
    7276                        MPI_Recv(buffer,3,MPI_INT,i,1,comm,&status);
    7377                        if (buffer[2])MPI_Recv(outmatrix+(buffer[1]*N),N*buffer[2],MPI_DOUBLE,i,1,comm,&status);
    7478                }
    7579        }
    76         if (my_rank==0){
     80        if (my_rank2==0){
    7781                //Still have the local_matrix on node 0 to take care of.
    7882                memcpy(outmatrix,local_matrix,N*range*sizeof(double));
  • TabularUnified issm/trunk-jpl/src/c/toolkits/petsc/patches/VecToMPISerial.cpp

    r13595 r13601  
    1616       
    1717        int i;
    18         extern int num_procs;
    19         extern int my_rank;
     18        int num_procs2;
     19        int my_rank2;
    2020
    2121        /*Petsc*/
     
    3434        /*Output*/
    3535        double* gathered_vector=NULL; //Global vector holding the final assembled vector on all nodes.
     36       
     37        /*recover my_rank2 and num_procs2*/
     38        MPI_Comm_size(comm,&num_procs2);
     39        MPI_Comm_rank(comm,&my_rank2);
    3640
    3741        VecGetSize(vector,&vector_size);
     
    6165        /*Now each node holds its local_vector containing range rows.
    6266         * We send this local_vector  to the gathered_vector on node 0*/
    63         for (i=1;i<num_procs;i++){
    64                 if (my_rank==i){
    65                         buffer[0]=my_rank;
     67        for (i=1;i<num_procs2;i++){
     68                if (my_rank2==i){
     69                        buffer[0]=my_rank2;
    6670                        buffer[1]=lower_row;
    6771                        buffer[2]=range;
     
    6973                        if (range)MPI_Send(local_vector,range,MPI_DOUBLE,0,1,comm);
    7074                }
    71                 if (my_rank==0){
     75                if (my_rank2==0){
    7276                        MPI_Recv(buffer,3,MPI_INT,i,1,comm,&status);
    7377                        if (buffer[2])MPI_Recv(gathered_vector+buffer[1],buffer[2],MPI_DOUBLE,i,1,comm,&status);
     
    7579        }
    7680
    77         if (my_rank==0){
     81        if (my_rank2==0){
    7882                //Still have the local_vector on node 0 to take care of.
    7983                if (range)memcpy(gathered_vector+lower_row,local_vector,range*sizeof(double));
Note: See TracChangeset for help on using the changeset viewer.