Changeset 13612
- Timestamp:
- 10/11/12 00:03:06 (12 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Container/Elements.cpp
r13604 r13612 168 168 int i; 169 169 170 int my_rank 2;171 int num_procs 2;170 int my_rank; 171 int num_procs; 172 172 173 173 Patch *patch = NULL; … … 185 185 int minrank; 186 186 187 /*recover my_rank 2:*/188 my_rank 2=IssmComm::GetRank();189 num_procs 2=IssmComm::GetSize();187 /*recover my_rank:*/ 188 my_rank=IssmComm::GetRank(); 189 num_procs=IssmComm::GetSize(); 190 190 191 191 /*Recover parameters: */ … … 200 200 /*Get rank of first cpu that has results*/ 201 201 #ifdef _HAVE_MPI_ 202 if(this->Size()) rank=my_rank 2;203 else rank=num_procs 2;202 if(this->Size()) rank=my_rank; 203 else rank=num_procs; 204 204 MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,IssmComm::GetComm()); 205 205 #else 206 minrank=my_rank 2;206 minrank=my_rank; 207 207 #endif 208 208 209 209 /*see what the first element of this partition has in stock (this is common to all partitions)*/ 210 if(my_rank 2==minrank){210 if(my_rank==minrank){ 211 211 if(this->Size()==0) _error_("Cannot write results because there is no element??"); 212 212 Element* element=(Element*)this->GetObjectByOffset(0); … … 220 220 if(!numberofresults) return; 221 221 #ifdef _HAVE_MPI_ 222 if(my_rank 2!=minrank){222 if(my_rank!=minrank){ 223 223 resultsenums=xNew<int>(numberofresults); 224 224 resultssizes=xNew<int>(numberofresults); … … 249 249 /*Serialize and add to results*/ 250 250 vector_serial=vector->ToMPISerial(); 251 if(my_rank 2==0){251 if(my_rank==0){ 252 252 /*No need to add this vector for all cpus*/ 253 253 #ifdef _HAVE_ADOLC_ -
issm/trunk-jpl/src/c/Container/Nodes.cpp
r13605 r13612 56 56 void Nodes::DistributeDofs(int analysis_type,int setenum){ 57 57 58 int num_procs 2;59 int my_rank 2;58 int num_procs; 59 int my_rank; 60 60 61 61 int i; … … 67 67 int numnodes=0; 68 68 69 /*recover my_rank 2:*/70 my_rank 2=IssmComm::GetRank();71 num_procs 2=IssmComm::GetSize();69 /*recover my_rank:*/ 70 my_rank=IssmComm::GetRank(); 71 num_procs=IssmComm::GetSize(); 72 72 73 73 /*some check: */ … … 88 88 * cpus by the total last dofs of the previus cpu, starting from 0. 89 89 * First: get number of dofs for each cpu*/ 90 alldofcount=xNew<int>(num_procs 2);90 alldofcount=xNew<int>(num_procs); 91 91 #ifdef _HAVE_MPI_ 92 92 MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,IssmComm::GetComm()); 93 MPI_Bcast(alldofcount,num_procs 2,MPI_INT,0,IssmComm::GetComm());93 MPI_Bcast(alldofcount,num_procs,MPI_INT,0,IssmComm::GetComm()); 94 94 #else 95 95 alldofcount[0]=dofcount; … … 98 98 /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/ 99 99 dofcount=0; 100 if(my_rank 2!=0){101 for(i=0;i<my_rank 2;i++){100 if(my_rank!=0){ 101 for(i=0;i<my_rank;i++){ 102 102 dofcount+=alldofcount[i]; 103 103 } … … 152 152 153 153 int i; 154 int num_procs 2;154 int num_procs; 155 155 156 156 int* ranks=NULL; … … 158 158 int numnodes; 159 159 160 /*recover num_procs 2: */161 num_procs 2=IssmComm::GetSize();160 /*recover num_procs: */ 161 num_procs=IssmComm::GetSize(); 162 162 163 163 /*Figure out number of nodes for this analysis: */ … … 167 167 ranks=xNew<int>(numnodes); 168 168 minranks=xNew<int>(numnodes); 169 for(i=0;i<numnodes;i++)ranks[i]=num_procs 2; //no cpu can have rank num_procs. This is the maximum limit.169 for(i=0;i<numnodes;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit. 170 170 171 171 /*Now go through all our objects and ask them to report to who they belong (which rank): */ … … 335 335 void Nodes::Ranks(int* ranks,int analysis_type){ 336 336 337 int my_rank 2;337 int my_rank; 338 338 int sid; 339 339 340 /*recover my_rank 2:*/341 my_rank 2=IssmComm::GetRank();340 /*recover my_rank:*/ 341 my_rank=IssmComm::GetRank(); 342 342 343 343 /*Go through nodes, and for each object, report it cpu: */ … … 350 350 /*Plug rank into ranks, according to sid: */ 351 351 sid=node->Sid(); 352 ranks[sid]=my_rank 2;352 ranks[sid]=my_rank; 353 353 } 354 354 } -
issm/trunk-jpl/src/c/Container/Vertices.cpp
r13604 r13612 41 41 void Vertices::DistributePids(int numberofobjects){ 42 42 43 int num_procs 2;44 int my_rank 2;43 int num_procs; 44 int my_rank; 45 45 46 46 int i; … … 50 50 int *alltruepids = NULL; 51 51 52 /*recover my_rank 2:*/53 my_rank 2=IssmComm::GetRank();54 num_procs 2=IssmComm::GetSize();52 /*recover my_rank:*/ 53 my_rank=IssmComm::GetRank(); 54 num_procs=IssmComm::GetSize(); 55 55 56 56 /*Go through objects, and distribute pids locally, from 0 to numberofpidsperobject*/ … … 64 64 * cpus by the total last pids of the previus cpu, starting from 0. 65 65 * First: get number of pids for each cpu*/ 66 allpidcount=xNew<int>(num_procs 2);66 allpidcount=xNew<int>(num_procs); 67 67 #ifdef _HAVE_MPI_ 68 68 MPI_Gather(&pidcount,1,MPI_INT,allpidcount,1,MPI_INT,0,IssmComm::GetComm()); 69 MPI_Bcast(allpidcount,num_procs 2,MPI_INT,0,IssmComm::GetComm());69 MPI_Bcast(allpidcount,num_procs,MPI_INT,0,IssmComm::GetComm()); 70 70 #else 71 71 allpidcount[0]=pidcount; … … 74 74 /* Every cpu should start its own pid count at the end of the pidcount from cpu-1*/ 75 75 pidcount=0; 76 if(my_rank 2!=0){77 for(i=0;i<my_rank 2;i++){76 if(my_rank!=0){ 77 for(i=0;i<my_rank;i++){ 78 78 pidcount+=allpidcount[i]; 79 79 } … … 115 115 116 116 int i; 117 int num_procs 2;117 int num_procs; 118 118 119 119 int* ranks=NULL; 120 120 int* minranks=NULL; 121 121 122 /*recover num_procs 2:*/123 num_procs 2=IssmComm::GetSize();122 /*recover num_procs:*/ 123 num_procs=IssmComm::GetSize(); 124 124 125 125 /*Allocate ranks: */ … … 127 127 minranks=xNew<int>(numberofobjects); 128 128 129 for(i=0;i<numberofobjects;i++)ranks[i]=num_procs 2; //no cpu can have rank num_procs. This is the maximum limit.129 for(i=0;i<numberofobjects;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit. 130 130 131 131 /*Now go through all our objects and ask them to report to who they belong (which rank): */ … … 184 184 void Vertices::Ranks(int* ranks){ 185 185 186 int my_rank 2;186 int my_rank; 187 187 int sid; 188 188 189 /*recover my_rank 2:*/190 my_rank 2=IssmComm::GetRank();189 /*recover my_rank:*/ 190 my_rank=IssmComm::GetRank(); 191 191 192 192 /*Go through a dataset, and for each object, report it cpu: */ … … 195 195 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); 196 196 sid=vertex->Sid(); 197 ranks[sid]=my_rank 2;198 } 199 } 200 /*}}}*/ 197 ranks[sid]=my_rank; 198 } 199 } 200 /*}}}*/ -
issm/trunk-jpl/src/c/classes/FemModel.cpp
r13609 r13612 84 84 FILE *petscoptionsfid = NULL; 85 85 FILE *output_fid = NULL; 86 int my_rank 2;87 88 /*recover my_rank 2:*/89 my_rank 2=IssmComm::GetRank();86 int my_rank; 87 88 /*recover my_rank:*/ 89 my_rank=IssmComm::GetRank(); 90 90 91 91 /*Open input file on cpu 0: */ 92 if(my_rank 2==0) IOMODEL = pfopen(inputfilename ,"rb");92 if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb"); 93 93 94 94 /*Initialize internal data: */ … … 130 130 131 131 /*Close input file descriptors: */ 132 if(my_rank 2==0) pfclose(IOMODEL,inputfilename);132 if(my_rank==0) pfclose(IOMODEL,inputfilename); 133 133 134 134 /*Open output file once for all and add output file name and file descriptor to parameters*/ -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r13607 r13612 104 104 void IoModel::CheckEnumSync(void){ 105 105 106 int my_rank 2;106 int my_rank; 107 107 int record_enum = 0; 108 108 109 /*recover my_rank 2:*/110 my_rank 2=IssmComm::GetRank();109 /*recover my_rank:*/ 110 my_rank=IssmComm::GetRank(); 111 111 112 112 /*Check that some fields have been allocated*/ 113 _assert_(this->fid || my_rank 2);113 _assert_(this->fid || my_rank); 114 114 115 115 /*Go find in the binary file, the position of the data we want to fetch: */ 116 if(my_rank 2==0){ //cpu 0116 if(my_rank==0){ //cpu 0 117 117 118 118 /*First set FILE* position to the beginning of the file: */ … … 299 299 void IoModel::FetchConstants(void){ 300 300 301 int my_rank 2;301 int my_rank; 302 302 303 303 /*record descriptions; */ … … 314 314 int string_size; 315 315 316 /*recover my_rank 2:*/317 my_rank 2=IssmComm::GetRank();316 /*recover my_rank:*/ 317 my_rank=IssmComm::GetRank(); 318 318 319 319 /*Check that some fields have been allocated*/ 320 _assert_(this->fid || my_rank 2);320 _assert_(this->fid || my_rank); 321 321 _assert_(this->constants); 322 322 323 323 /*Go find in the binary file, the position of the data we want to fetch: */ 324 if(my_rank 2==0){ //cpu 0{{{324 if(my_rank==0){ //cpu 0{{{ 325 325 326 326 /*First set FILE* position to the beginning of the file: */ … … 540 540 void IoModel::FetchData(bool* pboolean,int data_enum){ 541 541 542 int my_rank 2;542 int my_rank; 543 543 544 544 … … 547 547 int code; 548 548 549 /*recover my_rank 2:*/550 my_rank 2=IssmComm::GetRank();549 /*recover my_rank:*/ 550 my_rank=IssmComm::GetRank(); 551 551 552 552 … … 557 557 558 558 /*We have to read a boolean from disk. */ 559 if(my_rank 2==0){559 if(my_rank==0){ 560 560 if(fread(&booleanint,sizeof(int),1,fid)!=1) _error_("could not read boolean "); 561 561 } … … 573 573 void IoModel::FetchData(int* pinteger,int data_enum){ 574 574 575 int my_rank 2;575 int my_rank; 576 576 577 577 /*output: */ … … 579 579 int code; 580 580 581 /*recover my_rank 2:*/582 my_rank 2=IssmComm::GetRank();581 /*recover my_rank:*/ 582 my_rank=IssmComm::GetRank(); 583 583 584 584 /*Set file pointer to beginning of the data: */ … … 588 588 589 589 /*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */ 590 if(my_rank 2==0){590 if(my_rank==0){ 591 591 if(fread(&integer,sizeof(int),1,fid)!=1) _error_("could not read integer "); 592 592 } … … 604 604 605 605 606 int my_rank 2;606 int my_rank; 607 607 608 608 … … 611 611 int code; 612 612 613 /*recover my_rank 2:*/614 my_rank 2=IssmComm::GetRank();613 /*recover my_rank:*/ 614 my_rank=IssmComm::GetRank(); 615 615 616 616 /*Set file pointer to beginning of the data: */ … … 620 620 621 621 /*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */ 622 if(my_rank 2==0){622 if(my_rank==0){ 623 623 if(fread(&scalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar "); 624 624 } … … 635 635 void IoModel::FetchData(char** pstring,int data_enum){ 636 636 637 int my_rank 2;637 int my_rank; 638 638 639 639 … … 643 643 int code=0; 644 644 645 /*recover my_rank 2:*/646 my_rank 2=IssmComm::GetRank();645 /*recover my_rank:*/ 646 my_rank=IssmComm::GetRank(); 647 647 648 648 /*Set file pointer to beginning of the data: */ … … 654 654 655 655 /*We have to read a string from disk. First read the dimensions of the string, then the string: */ 656 if(my_rank 2==0){656 if(my_rank==0){ 657 657 if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string "); 658 658 } … … 668 668 669 669 /*Read string on node 0, then broadcast: */ 670 if(my_rank 2==0){670 if(my_rank==0){ 671 671 if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string "); 672 672 } … … 688 688 void IoModel::FetchData(int** pmatrix,int* pM,int* pN,int data_enum){ 689 689 690 int my_rank 2;690 int my_rank; 691 691 int i,j; 692 692 … … 698 698 int vector_type=0; 699 699 700 /*recover my_rank 2:*/701 my_rank 2=IssmComm::GetRank();700 /*recover my_rank:*/ 701 my_rank=IssmComm::GetRank(); 702 702 703 703 /*Set file pointer to beginning of the data: */ … … 710 710 /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */ 711 711 /*numberofelements: */ 712 if(my_rank 2==0){712 if(my_rank==0){ 713 713 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix "); 714 714 } … … 718 718 #endif 719 719 720 if(my_rank 2==0){720 if(my_rank==0){ 721 721 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix "); 722 722 } … … 730 730 731 731 /*Read matrix on node 0, then broadcast: */ 732 if(my_rank 2==0){732 if(my_rank==0){ 733 733 if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 734 734 } … … 764 764 void IoModel::FetchData(IssmDouble** pmatrix,int* pM,int* pN,int data_enum){ 765 765 766 int my_rank 2;766 int my_rank; 767 767 768 768 /*output: */ … … 772 772 int vector_type=0; 773 773 774 /*recover my_rank 2:*/775 my_rank 2=IssmComm::GetRank();774 /*recover my_rank:*/ 775 my_rank=IssmComm::GetRank(); 776 776 777 777 /*Set file pointer to beginning of the data: */ … … 783 783 /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */ 784 784 /*numberofelements: */ 785 if(my_rank 2==0){785 if(my_rank==0){ 786 786 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix "); 787 787 } … … 790 790 #endif 791 791 792 if(my_rank 2==0){792 if(my_rank==0){ 793 793 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix "); 794 794 } … … 802 802 803 803 /*Read matrix on node 0, then broadcast: */ 804 if(my_rank 2==0){804 if(my_rank==0){ 805 805 if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 806 806 } … … 831 831 void IoModel::FetchData(char*** pstrings,int* pnumstrings,int data_enum){ 832 832 833 int my_rank 2;833 int my_rank; 834 834 835 835 int i; … … 844 844 int code; 845 845 846 /*recover my_rank 2:*/847 my_rank 2=IssmComm::GetRank();846 /*recover my_rank:*/ 847 my_rank=IssmComm::GetRank(); 848 848 849 849 /*Set file pointer to beginning of the data: */ … … 853 853 854 854 /*We have to read a bunch of strings from disk. First read the number of strings, and allocate: */ 855 if(my_rank 2==0){855 if(my_rank==0){ 856 856 if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_("could not read length of string array"); 857 857 } … … 868 868 for(i=0;i<numstrings;i++){ 869 869 870 if(my_rank 2==0){870 if(my_rank==0){ 871 871 if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string "); 872 872 } … … 879 879 880 880 /*Read string on node 0, then broadcast: */ 881 if(my_rank 2==0){881 if(my_rank==0){ 882 882 if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string "); 883 883 } … … 905 905 int i; 906 906 907 int my_rank 2;907 int my_rank; 908 908 909 909 /*output: */ … … 918 918 int code; 919 919 920 /*recover my_rank 2:*/921 my_rank 2=IssmComm::GetRank();920 /*recover my_rank:*/ 921 my_rank=IssmComm::GetRank(); 922 922 923 923 /*Set file pointer to beginning of the data: */ … … 926 926 927 927 /*Now fetch: */ 928 if(my_rank 2==0){928 if(my_rank==0){ 929 929 if(fread(&numrecords,sizeof(int),1,fid)!=1) _error_("could not read number of records in matrix array "); 930 930 } … … 949 949 for(i=0;i<numrecords;i++){ 950 950 951 if(my_rank 2==0){951 if(my_rank==0){ 952 952 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows in " << i << "th matrix of matrix array"); 953 953 } … … 956 956 #endif 957 957 958 if(my_rank 2==0){958 if(my_rank==0){ 959 959 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns in " << i << "th matrix of matrix array"); 960 960 } … … 968 968 969 969 /*Read matrix on node 0, then broadcast: */ 970 if(my_rank 2==0){970 if(my_rank==0){ 971 971 if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 972 972 } … … 1279 1279 void IoModel::LastIndex(int *pindex){ 1280 1280 1281 int my_rank 2;1281 int my_rank; 1282 1282 int lastindex,index; 1283 1283 int record_length; 1284 1284 1285 /*recover my_rank 2:*/1286 my_rank 2=IssmComm::GetRank();1285 /*recover my_rank:*/ 1286 my_rank=IssmComm::GetRank(); 1287 1287 1288 1288 /*Go find in the binary file, the position of the data we want to fetch: */ 1289 if(my_rank 2==0){1289 if(my_rank==0){ 1290 1290 1291 1291 /*First set FILE* position to the beginning of the file: */ … … 1318 1318 FILE* IoModel::SetFilePointerToData(int* pcode,int* pvector_type, int data_enum){ 1319 1319 1320 int my_rank 2;1320 int my_rank; 1321 1321 1322 1322 int found = 0; … … 1326 1326 int vector_type = 0; //nodal or elementary 1327 1327 1328 /*recover my_rank 2:*/1329 my_rank 2=IssmComm::GetRank();1328 /*recover my_rank:*/ 1329 my_rank=IssmComm::GetRank(); 1330 1330 1331 1331 /*Go find in the binary file, the position of the data we want to fetch: */ 1332 if(my_rank 2==0){1332 if(my_rank==0){ 1333 1333 1334 1334 /*First set FILE* position to the beginning of the file: */ -
issm/trunk-jpl/src/c/classes/IssmComm.cpp
r13610 r13612 18 18 }/*}}}*/ 19 19 int IssmComm::GetRank(){ /*{{{*/ 20 int my_rank 2;20 int my_rank; 21 21 #ifdef _HAVE_MPI_ 22 MPI_Comm_rank(comm,&my_rank 2);22 MPI_Comm_rank(comm,&my_rank); 23 23 #else 24 my_rank 2=0;24 my_rank=0; 25 25 #endif 26 return my_rank 2;26 return my_rank; 27 27 28 28 }/*}}}*/ -
issm/trunk-jpl/src/c/classes/Patch.cpp
r13609 r13612 111 111 int i; 112 112 int count; 113 int my_rank 2;114 int num_procs 2;113 int my_rank; 114 int num_procs; 115 115 int total_numrows; 116 116 int node_numrows; … … 120 120 #endif 121 121 122 /*recover my_rank 2:*/123 my_rank 2=IssmComm::GetRank();124 num_procs 2=IssmComm::GetSize();122 /*recover my_rank:*/ 123 my_rank=IssmComm::GetRank(); 124 num_procs=IssmComm::GetSize(); 125 125 126 126 /*First, figure out total number of rows combining all the cpus: */ … … 136 136 137 137 /*Now, allocate buffer to holds all the values, on node 0: */ 138 if(my_rank 2==0)total_values=xNew<IssmDouble>(this->numcols*total_numrows);138 if(my_rank==0)total_values=xNew<IssmDouble>(this->numcols*total_numrows); 139 139 140 140 /*Start by copying node 0 values onto total_values: */ 141 if(my_rank 2==0){141 if(my_rank==0){ 142 142 count=0; 143 143 xMemCpy<IssmDouble>(total_values+count,this->values,this->numcols*this->numrows); … … 147 147 /*Now, ask other nodes to send their values: */ 148 148 #ifdef _HAVE_MPI_ 149 for (i=1;i<num_procs 2;i++){150 if (my_rank 2==i){149 for (i=1;i<num_procs;i++){ 150 if (my_rank==i){ 151 151 MPI_Send(&this->numrows,1,MPI_INT,0,1,IssmComm::GetComm()); 152 152 if (this->numrows)MPI_Send(this->values,this->numrows*this->numcols,MPI_DOUBLE,0,1,IssmComm::GetComm()); 153 153 } 154 if (my_rank 2==0){154 if (my_rank==0){ 155 155 MPI_Recv(&node_numrows,1,MPI_INT,i,1,IssmComm::GetComm(),&status); 156 156 if (node_numrows)MPI_Recv(total_values+count,node_numrows*this->numcols,MPI_DOUBLE,i,1,IssmComm::GetComm(),&status); … … 162 162 /*Now, node 0 has total_values, of size total_numrows*this->numcols. Update the fields in the patch, to reflect this new 163 163 * reality. For other cpus, no point in keeping their data anymore: */ 164 if(my_rank 2==0){164 if(my_rank==0){ 165 165 this->numrows=total_numrows; 166 166 xDelete<IssmDouble>(this->values); -
issm/trunk-jpl/src/c/classes/objects/ExternalResults/GenericExternalResult.h
r13609 r13612 110 110 void WriteData(FILE* fid,bool io_gather){ /*{{{*/ 111 111 112 int my_rank 2;112 int my_rank; 113 113 int type; 114 114 int size; 115 115 IssmPDouble passiveDouble; 116 116 117 /*recover my_rank 2:*/118 my_rank 2=IssmComm::GetRank();117 /*recover my_rank:*/ 118 my_rank=IssmComm::GetRank(); 119 119 120 120 /*return if now on cpu 0: */ 121 if(my_rank 2)return;121 if(my_rank)return; 122 122 123 123 /*use generic part, same for all ResultTypes: */ … … 205 205 template <> inline void GenericExternalResult<char*>::WriteData(FILE* fid,bool io_gather){ /*{{{*/ 206 206 207 int my_rank 2;207 int my_rank; 208 208 int type; 209 209 int length; 210 210 211 /*recover my_rank 2:*/212 my_rank 2=IssmComm::GetRank();211 /*recover my_rank:*/ 212 my_rank=IssmComm::GetRank(); 213 213 214 214 /*return if now on cpu 0: */ 215 if(my_rank 2)return;215 if(my_rank)return; 216 216 217 217 /*use generic part, same for all ResultTypes: */ … … 287 287 template <> inline void GenericExternalResult<IssmPDouble*>::WriteData(FILE* fid,bool io_gather){ /*{{{*/ 288 288 289 int my_rank 2;289 int my_rank; 290 290 int length; 291 291 int type; … … 294 294 IssmPDouble passiveDouble; 295 295 296 /*recover my_rank 2:*/297 my_rank 2=IssmComm::GetRank();296 /*recover my_rank:*/ 297 my_rank=IssmComm::GetRank(); 298 298 299 299 if(io_gather){ 300 300 /*we are gathering the data on cpu 0, don't write on other cpus: */ 301 if(my_rank 2) return;301 if(my_rank) return; 302 302 } 303 303 -
issm/trunk-jpl/src/c/classes/objects/IndependentObject.cpp
r13608 r13612 82 82 void IndependentObject::FetchIndependent(IoModel* iomodel){ 83 83 84 int my_rank 2;84 int my_rank; 85 85 FILE* fid=NULL; 86 86 87 /*recover my_rank 2:*/88 my_rank 2=IssmComm::GetRank();87 /*recover my_rank:*/ 88 my_rank=IssmComm::GetRank(); 89 89 90 90 #ifdef _HAVE_ADOLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents: … … 105 105 106 106 /*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */ 107 if(my_rank 2==0){107 if(my_rank==0){ 108 108 if(fread(&pscalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar "); 109 109 } … … 143 143 /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */ 144 144 /*numberofelements: */ 145 if(my_rank 2==0){145 if(my_rank==0){ 146 146 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix "); 147 147 } … … 150 150 #endif 151 151 152 if(my_rank 2==0){152 if(my_rank==0){ 153 153 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix "); 154 154 } … … 163 163 164 164 /*Read matrix on node 0, then broadcast: */ 165 if(my_rank 2==0){165 if(my_rank==0){ 166 166 if(fread(buffer,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 167 167 -
issm/trunk-jpl/src/c/classes/objects/Node.cpp
r13608 r13612 979 979 void Node::SetClone(int* minranks){ 980 980 981 int my_rank 2;981 int my_rank; 982 982 983 /*recover my_rank 2:*/984 my_rank 2=IssmComm::GetRank();985 986 if (minranks[sid]==my_rank 2){983 /*recover my_rank:*/ 984 my_rank=IssmComm::GetRank(); 985 986 if (minranks[sid]==my_rank){ 987 987 indexing.clone=false; 988 988 } -
issm/trunk-jpl/src/c/classes/objects/Vertex.cpp
r13608 r13612 178 178 void Vertex::SetClone(int* minranks){ 179 179 180 int my_rank 2;180 int my_rank; 181 181 182 /*recover my_rank 2:*/183 my_rank 2=IssmComm::GetRank();182 /*recover my_rank:*/ 183 my_rank=IssmComm::GetRank(); 184 184 185 if (minranks[this->sid]==my_rank 2){185 if (minranks[this->sid]==my_rank){ 186 186 this->clone=false; 187 187 } -
issm/trunk-jpl/src/c/io/Disk/WriteLockFile.cpp
r13606 r13612 9 9 10 10 int i; 11 int my_rank 2;11 int my_rank; 12 12 13 /*recover my_rank 2:*/14 my_rank 2=IssmComm::GetRank();13 /*recover my_rank:*/ 14 my_rank=IssmComm::GetRank(); 15 15 16 16 /* output: */ … … 18 18 19 19 /* Open lock file and write 1 into it: */ 20 if(my_rank 2==0){20 if(my_rank==0){ 21 21 fid=fopen(filename,"w"); 22 22 if(fid==NULL) _error_("error message: could not open lock file " << filename); -
issm/trunk-jpl/src/c/io/PrintfFunction.cpp
r13609 r13612 16 16 int n,size = 100; 17 17 int string_size; 18 int my_rank 2;18 int my_rank; 19 19 //variable list of arguments 20 20 va_list args; 21 21 22 /*recover my_rank 2:*/23 my_rank 2=IssmComm::GetRank();22 /*recover my_rank:*/ 23 my_rank=IssmComm::GetRank(); 24 24 25 25 while(true){ … … 46 46 47 47 /*Ok, if we are running in parallel, get node 0 to print*/ 48 if(my_rank 2==0)_printString_(buffer);48 if(my_rank==0)_printString_(buffer); 49 49 50 50 /*Clean up and return*/ … … 53 53 } 54 54 int PrintfFunction(const string & message){ 55 int my_rank 2;55 int my_rank; 56 56 57 /*recover my_rank 2:*/58 my_rank 2=IssmComm::GetRank();57 /*recover my_rank:*/ 58 my_rank=IssmComm::GetRank(); 59 59 60 if(my_rank 2==0){60 if(my_rank==0){ 61 61 printf("%s\n",message.c_str()); 62 62 } … … 64 64 } 65 65 int PrintfFunction2(const string & message){ 66 int my_rank 2;66 int my_rank; 67 67 68 /*recover my_rank 2:*/69 my_rank 2=IssmComm::GetRank();68 /*recover my_rank:*/ 69 my_rank=IssmComm::GetRank(); 70 70 71 if(my_rank 2==0){71 if(my_rank==0){ 72 72 printf("%s",message.c_str()); 73 73 } -
issm/trunk-jpl/src/c/matlab/io/PrintfFunction.cpp
r13609 r13612 18 18 int n,size = 100; 19 19 int string_size; 20 int my_rank 2;20 int my_rank; 21 21 22 /*recover my_rank 2:*/23 my_rank 2=IssmComm::GetRank();22 /*recover my_rank:*/ 23 my_rank=IssmComm::GetRank(); 24 24 25 25 //variable list of arguments … … 53 53 54 54 /*Ok, if we are running in parallel, get node 0 to print*/ 55 if(my_rank 2==0)_printString_(buffer);55 if(my_rank==0)_printString_(buffer); 56 56 57 57 /*Clean up and return*/ -
issm/trunk-jpl/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp
r13592 r13612 21 21 22 22 int i,j,k; 23 int my_rank 2;23 int my_rank; 24 24 bool process_units = true; 25 25 … … 36 36 /*retrieve npart: */ 37 37 parameters->FindParam(&npart,QmuNumberofpartitionsEnum); 38 my_rank 2=IssmComm::GetRank();38 my_rank=IssmComm::GetRank(); 39 39 40 40 /*save the d_responses pointer: */ … … 57 57 58 58 /*Copy onto our dakota responses: */ 59 if(my_rank 2==0){59 if(my_rank==0){ 60 60 /*plug response: */ 61 61 for(i=0;i<npart;i++)responses_pointer[i]=qmu_response[i]; … … 78 78 Responsex(&femmodel_response,elements,nodes, vertices,loads,materials, parameters,root,process_units,0);//0 is the index for weights 79 79 80 if(my_rank 2==0){80 if(my_rank==0){ 81 81 /*plug response: */ 82 82 responses_pointer[0]=femmodel_response; … … 97 97 Responsex(&femmodel_response,elements,nodes, vertices,loads,materials, parameters,root,process_units,0);//0 is the weight index 98 98 99 if(my_rank 2==0){99 if(my_rank==0){ 100 100 /*plug response: */ 101 101 responses_pointer[0]=femmodel_response; … … 110 110 111 111 /*Synthesize echo: {{{*/ 112 if(my_rank 2==0){112 if(my_rank==0){ 113 113 _printString_(" responses: " << d_numresponses << ": "); 114 114 for(i=0;i<d_numresponses-1;i++)_printString_(d_responses[i] << "|"); -
issm/trunk-jpl/src/c/modules/ElementResponsex/ElementResponsex.cpp
r13592 r13612 13 13 14 14 15 int my_rank 2;15 int my_rank; 16 16 int i; 17 17 … … 25 25 /*retrieve element we are interested in: */ 26 26 parameters->FindParam(&index,IndexEnum); 27 my_rank 2=IssmComm::GetRank();27 my_rank=IssmComm::GetRank(); 28 28 29 29 /*now, go through our elements, and retrieve the one with this id: index: */ … … 32 32 if (element->Id()==index){ 33 33 found=1; 34 cpu_found=my_rank 2;34 cpu_found=my_rank; 35 35 break; 36 36 } … … 44 44 45 45 /*Ok, we found the element, compute responseocity: */ 46 if(my_rank 2==cpu_found){46 if(my_rank==cpu_found){ 47 47 element->ElementResponse(&response,response_enum,IuToExtEnum); 48 48 } -
issm/trunk-jpl/src/c/modules/Krigingx/pKrigingx.cpp
r13593 r13612 14 14 int pKrigingx(double** ppredictions,double **perror,double* obs_x, double* obs_y, double* obs_list, int obs_length,double* x_interp,double* y_interp,int n_interp,Options* options){ 15 15 16 int num_procs 2;17 int my_rank 2;16 int num_procs; 17 int my_rank; 18 18 19 19 /*output*/ … … 28 28 Observations *observations = NULL; 29 29 30 /*Get my_rank 2: */31 my_rank 2=IssmComm::GetRank();32 num_procs 2=IssmComm::GetSize();30 /*Get my_rank: */ 31 my_rank=IssmComm::GetRank(); 32 num_procs=IssmComm::GetSize(); 33 33 34 34 /*Get some Options*/ … … 59 59 60 60 /*partition loop across threads: */ 61 for(int idx=my_rank 2;idx<n_interp;idx+=num_procs2){61 for(int idx=my_rank;idx<n_interp;idx+=num_procs){ 62 62 _pprintLine_(" interpolation progress: "<<setw(6)<<setprecision(2)<<double(idx)/double(n_interp)*100<<"%"); 63 63 observations->InterpolationKriging(&predictions[idx],&error[idx],x_interp[idx],y_interp[idx],radius,mindata,maxdata,variogram); … … 77 77 78 78 /*partition loop across threads: */ 79 for(int idx=my_rank 2;idx<n_interp;idx+=num_procs2){79 for(int idx=my_rank;idx<n_interp;idx+=num_procs){ 80 80 _pprintLine_(" interpolation progress: "<<setw(6)<<setprecision(2)<<double(idx)/double(n_interp)*100<<"%"); 81 81 observations->InterpolationNearestNeighbor(&predictions[idx],x_interp[idx],y_interp[idx],radius); … … 94 94 95 95 /*partition loop across threads: */ 96 for(int idx=my_rank 2;idx<n_interp;idx+=num_procs2){96 for(int idx=my_rank;idx<n_interp;idx+=num_procs){ 97 97 _pprintLine_(" interpolation progress: "<<setw(6)<<setprecision(2)<<double(idx)/double(n_interp)*100<<"%"); 98 98 observations->InterpolationIDW(&predictions[idx],x_interp[idx],y_interp[idx],radius,mindata,maxdata,power); -
issm/trunk-jpl/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
r13593 r13612 22 22 int i; 23 23 24 int my_rank 2;25 int num_procs 2;24 int my_rank; 25 int num_procs; 26 26 int numberofelements; 27 27 int numberofvertices; … … 47 47 IssmDouble* vertex_pairing=NULL; 48 48 49 /*Get my_rank 2:*/50 my_rank 2=IssmComm::GetRank();51 num_procs 2=IssmComm::GetSize();49 /*Get my_rank:*/ 50 my_rank=IssmComm::GetRank(); 51 num_procs=IssmComm::GetSize(); 52 52 53 53 /*Fetch parameters: */ … … 77 77 } 78 78 79 MeshPartitionx(&epart, &npart,numberofelements,numberofvertices,elements, numberofelements2d,numberofvertices2d,elements2d,numlayers,elements_width, dim,num_procs 2);79 MeshPartitionx(&epart, &npart,numberofelements,numberofvertices,elements, numberofelements2d,numberofvertices2d,elements2d,numlayers,elements_width, dim,num_procs); 80 80 81 81 /*Free elements and elements2d: */ … … 103 103 104 104 /*!All elements have been partitioned above, only deal with elements for this cpu: */ 105 if(my_rank 2==epart[i]){105 if(my_rank==epart[i]){ 106 106 107 107 my_elements[i]=true; -
issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp
r13592 r13612 12 12 void NodalValuex( IssmDouble* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units){ 13 13 14 int my_rank 2;14 int my_rank; 15 15 int i; 16 16 int index; … … 21 21 int cpu_found; 22 22 23 /*Get my_rank 2:*/24 my_rank 2=IssmComm::GetRank();23 /*Get my_rank:*/ 24 my_rank=IssmComm::GetRank(); 25 25 26 26 /*retrieve element we are interested in: */ … … 33 33 found=element->NodalValue(&value,index,natureofdataenum,process_units); 34 34 if (found){ 35 cpu_found=my_rank 2;35 cpu_found=my_rank; 36 36 break; 37 37 } -
issm/trunk-jpl/src/c/modules/OutputResultsx/OutputResultsx.cpp
r13609 r13612 18 18 void OutputResultsx(Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){ 19 19 20 int my_rank 2;20 int my_rank; 21 21 FILE *fid = NULL; 22 22 char *outputfilename = NULL; … … 30 30 parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum); 31 31 32 /*recover my_rank 2:*/33 my_rank 2=IssmComm::GetRank();32 /*recover my_rank:*/ 33 my_rank=IssmComm::GetRank(); 34 34 35 35 if(dakota_analysis){ … … 45 45 /*Results do not include the type of solution being run . In parallel, we output results to a filename, 46 46 *therefore, we need to include the solutiontype into the filename: */ 47 if(my_rank 2==0){47 if(my_rank==0){ 48 48 parameters->FindParam(&solutiontype,SolutionTypeEnum); 49 49 EnumToStringx(&solutiontypestring,solutiontype); … … 63 63 if(io_gather){ 64 64 /*Just open the file for output on cpu 0. We are gathering the data on cpu 0 from all other cpus: */ 65 if(my_rank 2==0) fid=pfopen(outputfilename ,"wb");65 if(my_rank==0) fid=pfopen(outputfilename ,"wb"); 66 66 } 67 67 else{ 68 68 /*We are opening different files for output on all cpus. Append the rank to the filename, and open: */ 69 69 parameters->FindParam(&fid,OutputFilePointerEnum); 70 sprintf(cpu_outputfilename,"%s.%i",outputfilename,my_rank 2);70 sprintf(cpu_outputfilename,"%s.%i",outputfilename,my_rank); 71 71 fid=pfopen(cpu_outputfilename ,"wb"); 72 72 } … … 87 87 if((step==1) && (time==0)){ 88 88 if(io_gather){ 89 if(my_rank 2==0) pfclose(fid,outputfilename);89 if(my_rank==0) pfclose(fid,outputfilename); 90 90 } 91 91 else pfclose(fid,cpu_outputfilename); -
issm/trunk-jpl/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp
r13592 r13612 23 23 24 24 char line [1000]; 25 int my_rank 2;25 int my_rank; 26 26 int i; 27 27 … … 35 35 int stringlength; 36 36 37 /*Get my_rank 2:*/38 my_rank 2=IssmComm::GetRank();37 /*Get my_rank:*/ 38 my_rank=IssmComm::GetRank(); 39 39 40 if(my_rank 2==0){40 if(my_rank==0){ 41 41 42 42 /*Now, go through lines and figure out how many analyses we have: */ … … 100 100 #ifdef _HAVE_MPI_ 101 101 MPI_Bcast(&numanalyses,1,MPI_INT,0,IssmComm::GetComm()); 102 if(my_rank 2!=0){102 if(my_rank!=0){ 103 103 analyses=xNew<IssmPDouble>(numanalyses); 104 104 strings=xNew<char*>(numanalyses); … … 108 108 for(i=0;i<numanalyses;i++){ 109 109 char* string=strings[i]; 110 if(my_rank 2==0){110 if(my_rank==0){ 111 111 if(string==NULL) _error_("PETSc options for analysis " << EnumToStringx(reCast<int>(analyses[i])) << " have been declared but were not found"); 112 112 } 113 if(my_rank 2==0)stringlength=(strlen(string)+1)*sizeof(char);113 if(my_rank==0)stringlength=(strlen(string)+1)*sizeof(char); 114 114 #ifdef _HAVE_MPI_ 115 115 MPI_Bcast(&stringlength,1,MPI_INT,0,IssmComm::GetComm()); 116 if(my_rank 2!=0)string=xNew<char>(stringlength);116 if(my_rank!=0)string=xNew<char>(stringlength); 117 117 MPI_Bcast(string,stringlength,MPI_CHAR,0,IssmComm::GetComm()); 118 if(my_rank 2!=0)strings[i]=string;118 if(my_rank!=0)strings[i]=string; 119 119 #endif 120 120 } -
issm/trunk-jpl/src/c/shared/Exceptions/Exceptions.cpp
r13594 r13612 30 30 ErrorException::~ErrorException() throw(){ 31 31 32 int num_procs 2;32 int num_procs; 33 33 34 /*recover num_procs 2:*/35 num_procs 2=IssmComm::GetSize();34 /*recover num_procs:*/ 35 num_procs=IssmComm::GetSize(); 36 36 37 37 /*We want the report only for matlab modules, otherwise we get twice the report 38 38 * We assume that if num_procs==1, it is a module (FIXME)*/ 39 if(num_procs 2==1) this->Report();39 if(num_procs==1) this->Report(); 40 40 } 41 41 … … 46 46 void ErrorException::Report() const{ 47 47 48 int my_rank 2;49 int num_procs 2;48 int my_rank; 49 int num_procs; 50 50 51 /*recover my_rank 2 and num_procs2:*/52 my_rank 2=IssmComm::GetRank();53 num_procs 2=IssmComm::GetSize();51 /*recover my_rank and num_procs:*/ 52 my_rank=IssmComm::GetRank(); 53 num_procs=IssmComm::GetSize(); 54 54 55 55 … … 59 59 } 60 60 else{ 61 if(num_procs 2==1){61 if(num_procs==1){ 62 62 _printLine_("\n??? Error using ==> " << file_name.c_str() << ":" << file_line); 63 63 _printLine_(function_name.c_str() << " error message: " << what() << "\n"); 64 64 } 65 65 else{ 66 _printLine_("\n[" << my_rank 2<< "] ??? Error using ==> " << file_name.c_str() << ":" << file_line);67 _printLine_("[" << my_rank 2<< "] " << function_name.c_str() << " error message: " << what() << "\n");66 _printLine_("\n[" << my_rank<< "] ??? Error using ==> " << file_name.c_str() << ":" << file_line); 67 _printLine_("[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n"); 68 68 } 69 69 } -
issm/trunk-jpl/src/c/solutions/DakotaSpawnCore.cpp
r13593 r13612 103 103 104 104 int i; 105 int my_rank 2;105 int my_rank; 106 106 107 107 /*inputs and outputs: */ … … 115 115 int string_length; 116 116 117 /*recover my_rank 2:*/118 my_rank 2=IssmComm::GetRank();117 /*recover my_rank:*/ 118 my_rank=IssmComm::GetRank(); 119 119 120 120 /*recover inputs from pointers: */ … … 128 128 129 129 /*variables:*/ 130 if(my_rank 2!=0)variables=xNew<double>(numvariables);130 if(my_rank!=0)variables=xNew<double>(numvariables); 131 131 MPI_Bcast(variables,numvariables,MPI_DOUBLE,0,IssmComm::GetComm()); 132 132 133 133 /*variables_descriptors: */ 134 if(my_rank 2!=0){134 if(my_rank!=0){ 135 135 variables_descriptors=xNew<char*>(numvariables); 136 136 } 137 137 for(i=0;i<numvariables;i++){ 138 if(my_rank 2==0){138 if(my_rank==0){ 139 139 string=variables_descriptors[i]; 140 140 string_length=(strlen(string)+1)*sizeof(char); 141 141 } 142 142 MPI_Bcast(&string_length,1,MPI_INT,0,IssmComm::GetComm()); 143 if(my_rank 2!=0)string=xNew<char>(string_length);143 if(my_rank!=0)string=xNew<char>(string_length); 144 144 MPI_Bcast(string,string_length,MPI_CHAR,0,IssmComm::GetComm()); 145 if(my_rank 2!=0)variables_descriptors[i]=string;145 if(my_rank!=0)variables_descriptors[i]=string; 146 146 } 147 147 … … 160 160 161 161 int i; 162 int my_rank 2;162 int my_rank; 163 163 164 164 double *variables = NULL; … … 172 172 responses_descriptors=*presponses_descriptors; 173 173 174 /*recover my_rank 2:*/175 my_rank 2=IssmComm::GetRank();174 /*recover my_rank:*/ 175 my_rank=IssmComm::GetRank(); 176 176 177 177 /*Free variables and variables_descriptors only on cpu !=0*/ 178 if(my_rank 2!=0){178 if(my_rank!=0){ 179 179 xDelete<double>(variables); 180 180 for(i=0;i<numvariables;i++){ -
issm/trunk-jpl/src/c/solutions/dakota_core.cpp
r13609 r13612 57 57 #ifdef _HAVE_DAKOTA_ //only works if dakota library has been compiled in. 58 58 59 int my_rank 2;59 int my_rank; 60 60 char* dakota_input_file = NULL; 61 61 char* dakota_output_file = NULL; … … 70 70 femmodel->parameters->FindParam(&dakota_error_file,QmuErrNameEnum); 71 71 72 /*recover my_rank 2:*/73 my_rank 2=IssmComm::GetRank();72 /*recover my_rank:*/ 73 my_rank=IssmComm::GetRank(); 74 74 75 if(my_rank 2==0){75 if(my_rank==0){ 76 76 77 77 // Instantiate/initialize the parallel library and problem description -
issm/trunk-jpl/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp
r13602 r13612 19 19 20 20 /*from MPI: */ 21 int num_procs 2;22 int my_rank 2;21 int num_procs; 22 int my_rank; 23 23 24 /*recover my_rank 2*/25 MPI_Comm_rank(comm,&my_rank 2);26 MPI_Comm_size(comm,&num_procs 2);24 /*recover my_rank*/ 25 MPI_Comm_rank(comm,&my_rank); 26 MPI_Comm_size(comm,&num_procs); 27 27 28 28 29 29 /*We are not bound by any library, just use what seems most logical*/ 30 num_local_rows=xNew<int>(num_procs 2);30 num_local_rows=xNew<int>(num_procs); 31 31 32 for (i=0;i<num_procs 2;i++){32 for (i=0;i<num_procs;i++){ 33 33 /*Here, we use floor. We under distribute rows. The rows 34 34 left are then redistributed, therefore resulting in a 35 35 more even distribution.*/ 36 num_local_rows[i]=(int)floor((double)global_size/(double)num_procs 2);36 num_local_rows[i]=(int)floor((double)global_size/(double)num_procs); 37 37 } 38 38 39 39 /*There may be some rows left. Distribute evenly.*/ 40 row_rest=global_size - num_procs 2*(int)floor((double)global_size/(double)num_procs2);40 row_rest=global_size - num_procs*(int)floor((double)global_size/(double)num_procs); 41 41 for (i=0;i<row_rest;i++){ 42 42 num_local_rows[i]++; 43 43 } 44 local_size=num_local_rows[my_rank 2];44 local_size=num_local_rows[my_rank]; 45 45 46 46 /*free ressources: */ -
issm/trunk-jpl/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp
r13601 r13612 17 17 18 18 /*externals :*/ 19 int my_rank 2;20 int num_procs 2;19 int my_rank; 20 int num_procs; 21 21 22 /*recover my_rank 2 and num_procs2:*/23 MPI_Comm_size(comm,&num_procs 2);24 MPI_Comm_rank(comm,&my_rank 2);22 /*recover my_rank and num_procs:*/ 23 MPI_Comm_size(comm,&num_procs); 24 MPI_Comm_rank(comm,&my_rank); 25 25 26 26 /*output: */ … … 32 32 33 33 /*Gather all range values into allranges, for all nodes*/ 34 allranges=xNew<int>(num_procs 2);34 allranges=xNew<int>(num_procs); 35 35 MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,comm); 36 36 … … 38 38 lower_row=0; 39 39 upper_row=lower_row+allranges[0]; 40 for (i=1;i<=my_rank 2;i++){40 for (i=1;i<=my_rank;i++){ 41 41 lower_row=lower_row+allranges[i-1]; 42 42 upper_row=upper_row+allranges[i]; -
issm/trunk-jpl/src/c/toolkits/petsc/patches/MatMultPatch.cpp
r13603 r13612 50 50 int result=1; 51 51 int sumresult; 52 int num_procs 2;52 int num_procs; 53 53 54 /*recover num_procs 2:*/55 MPI_Comm_size(comm,&num_procs 2);54 /*recover num_procs:*/ 55 MPI_Comm_size(comm,&num_procs); 56 56 57 57 MatGetLocalSize(A,&local_m,&local_n);; … … 63 63 MPI_Reduce (&result,&sumresult,1,MPI_INT,MPI_SUM,0,comm ); 64 64 MPI_Bcast(&sumresult,1,MPI_INT,0,comm); 65 if (sumresult!=num_procs 2){65 if (sumresult!=num_procs){ 66 66 result=0; 67 67 } -
issm/trunk-jpl/src/c/toolkits/petsc/patches/MatToSerial.cpp
r13601 r13612 16 16 17 17 int i; 18 int my_rank 2;19 int num_procs 2;18 int my_rank; 19 int num_procs; 20 20 21 21 /*Petsc variables*/ … … 29 29 int buffer[3]; 30 30 31 /*recover my_rank 2 and num_procs2:*/32 MPI_Comm_size(comm,&num_procs 2);33 MPI_Comm_rank(comm,&my_rank 2);31 /*recover my_rank and num_procs:*/ 32 MPI_Comm_size(comm,&num_procs); 33 MPI_Comm_rank(comm,&my_rank); 34 34 35 35 /*Output*/ … … 45 45 46 46 /*Local and global allocation*/ 47 if (my_rank 2==0)outmatrix=xNew<double>(M*N);47 if (my_rank==0)outmatrix=xNew<double>(M*N); 48 48 49 49 if (range){ … … 65 65 * We send these rows to the matrix on node 0*/ 66 66 67 for (i=1;i<num_procs 2;i++){68 if (my_rank 2==i){69 buffer[0]=my_rank 2;67 for (i=1;i<num_procs;i++){ 68 if (my_rank==i){ 69 buffer[0]=my_rank; 70 70 buffer[1]=lower_row; 71 71 buffer[2]=range; … … 73 73 if (range)MPI_Send(local_matrix,N*range,MPI_DOUBLE,0,1,comm); 74 74 } 75 if (my_rank 2==0){75 if (my_rank==0){ 76 76 MPI_Recv(buffer,3,MPI_INT,i,1,comm,&status); 77 77 if (buffer[2])MPI_Recv(outmatrix+(buffer[1]*N),N*buffer[2],MPI_DOUBLE,i,1,comm,&status); 78 78 } 79 79 } 80 if (my_rank 2==0){80 if (my_rank==0){ 81 81 //Still have the local_matrix on node 0 to take care of. 82 82 memcpy(outmatrix,local_matrix,N*range*sizeof(double)); -
issm/trunk-jpl/src/c/toolkits/petsc/patches/VecToMPISerial.cpp
r13601 r13612 16 16 17 17 int i; 18 int num_procs 2;19 int my_rank 2;18 int num_procs; 19 int my_rank; 20 20 21 21 /*Petsc*/ … … 35 35 double* gathered_vector=NULL; //Global vector holding the final assembled vector on all nodes. 36 36 37 /*recover my_rank 2 and num_procs2*/38 MPI_Comm_size(comm,&num_procs 2);39 MPI_Comm_rank(comm,&my_rank 2);37 /*recover my_rank and num_procs*/ 38 MPI_Comm_size(comm,&num_procs); 39 MPI_Comm_rank(comm,&my_rank); 40 40 41 41 VecGetSize(vector,&vector_size); … … 65 65 /*Now each node holds its local_vector containing range rows. 66 66 * We send this local_vector to the gathered_vector on node 0*/ 67 for (i=1;i<num_procs 2;i++){68 if (my_rank 2==i){69 buffer[0]=my_rank 2;67 for (i=1;i<num_procs;i++){ 68 if (my_rank==i){ 69 buffer[0]=my_rank; 70 70 buffer[1]=lower_row; 71 71 buffer[2]=range; … … 73 73 if (range)MPI_Send(local_vector,range,MPI_DOUBLE,0,1,comm); 74 74 } 75 if (my_rank 2==0){75 if (my_rank==0){ 76 76 MPI_Recv(buffer,3,MPI_INT,i,1,comm,&status); 77 77 if (buffer[2])MPI_Recv(gathered_vector+buffer[1],buffer[2],MPI_DOUBLE,i,1,comm,&status); … … 79 79 } 80 80 81 if (my_rank 2==0){81 if (my_rank==0){ 82 82 //Still have the local_vector on node 0 to take care of. 83 83 if (range)memcpy(gathered_vector+lower_row,local_vector,range*sizeof(double));
Note:
See TracChangeset
for help on using the changeset viewer.