Changeset 13594
- Timestamp:
- 10/10/12 21:21:25 (13 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Container/Elements.cpp
r13381 r13594 168 168 int i; 169 169 170 extern int my_rank;171 extern int num_procs;170 int my_rank2; 171 int num_procs2; 172 172 173 173 Patch *patch = NULL; … … 184 184 int rank; 185 185 int minrank; 186 187 /*recover my_rank2:*/ 188 my_rank2=IssmComm::GetRank(); 189 num_procs2=IssmComm::GetSize(); 186 190 187 191 /*Recover parameters: */ … … 196 200 /*Get rank of first cpu that has results*/ 197 201 #ifdef _HAVE_MPI_ 198 if(this->Size()) rank=my_rank ;199 else rank=num_procs ;202 if(this->Size()) rank=my_rank2; 203 else rank=num_procs2; 200 204 MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,MPI_COMM_WORLD); 201 205 #else 202 minrank=my_rank ;206 minrank=my_rank2; 203 207 #endif 204 208 205 209 /*see what the first element of this partition has in stock (this is common to all partitions)*/ 206 if(my_rank ==minrank){210 if(my_rank2==minrank){ 207 211 if(this->Size()==0) _error_("Cannot write results because there is no element??"); 208 212 Element* element=(Element*)this->GetObjectByOffset(0); … … 216 220 if(!numberofresults) return; 217 221 #ifdef _HAVE_MPI_ 218 if(my_rank !=minrank){222 if(my_rank2!=minrank){ 219 223 resultsenums=xNew<int>(numberofresults); 220 224 resultssizes=xNew<int>(numberofresults); … … 245 249 /*Serialize and add to results*/ 246 250 vector_serial=vector->ToMPISerial(); 247 if(my_rank ==0){251 if(my_rank2==0){ 248 252 /*No need to add this vector for all cpus*/ 249 253 #ifdef _HAVE_ADOLC_ -
issm/trunk-jpl/src/c/Container/Nodes.cpp
r13413 r13594 56 56 void Nodes::DistributeDofs(int analysis_type,int setenum){ 57 57 58 extern int num_procs;59 extern int my_rank;58 int num_procs2; 59 int my_rank2; 60 60 61 61 int i; … … 66 66 int* alltruedofs=NULL; 67 67 int numnodes=0; 68 69 /*recover my_rank2:*/ 70 my_rank2=IssmComm::GetRank(); 71 num_procs2=IssmComm::GetSize(); 68 72 69 73 /*some check: */ … … 84 88 * cpus by the total last dofs of the previus cpu, starting from 0. 85 89 * First: get number of dofs for each cpu*/ 86 alldofcount=xNew<int>(num_procs );90 alldofcount=xNew<int>(num_procs2); 87 91 #ifdef _HAVE_MPI_ 88 92 MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD); 89 MPI_Bcast(alldofcount,num_procs ,MPI_INT,0,MPI_COMM_WORLD);93 MPI_Bcast(alldofcount,num_procs2,MPI_INT,0,MPI_COMM_WORLD); 90 94 #else 91 95 alldofcount[0]=dofcount; … … 94 98 /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/ 95 99 dofcount=0; 96 if(my_rank !=0){97 for(i=0;i<my_rank ;i++){100 if(my_rank2!=0){ 101 for(i=0;i<my_rank2;i++){ 98 102 dofcount+=alldofcount[i]; 99 103 } … … 328 332 void Nodes::Ranks(int* ranks,int analysis_type){ 329 333 330 extern int my_rank;334 int my_rank2; 331 335 int sid; 336 337 /*recover my_rank2:*/ 338 my_rank2=IssmComm::GetRank(); 332 339 333 340 /*Go through nodes, and for each object, report it cpu: */ … … 340 347 /*Plug rank into ranks, according to sid: */ 341 348 sid=node->Sid(); 342 ranks[sid]=my_rank ;349 ranks[sid]=my_rank2; 343 350 } 344 351 } -
issm/trunk-jpl/src/c/Container/Vertices.cpp
r13413 r13594 41 41 void Vertices::DistributePids(int numberofobjects){ 42 42 43 extern int num_procs;44 extern int my_rank;43 int num_procs2; 44 int my_rank2; 45 45 46 46 int i; … … 49 49 int *truepids = NULL; 50 50 int *alltruepids = NULL; 51 52 /*recover my_rank2:*/ 53 my_rank2=IssmComm::GetRank(); 54 num_procs2=IssmComm::GetSize(); 51 55 52 56 /*Go through objects, and distribute pids locally, from 0 to numberofpidsperobject*/ … … 60 64 * cpus by the total last pids of the previus cpu, starting from 0. 61 65 * First: get number of pids for each cpu*/ 62 allpidcount=xNew<int>(num_procs );66 allpidcount=xNew<int>(num_procs2); 63 67 #ifdef _HAVE_MPI_ 64 68 MPI_Gather(&pidcount,1,MPI_INT,allpidcount,1,MPI_INT,0,MPI_COMM_WORLD); 65 MPI_Bcast(allpidcount,num_procs ,MPI_INT,0,MPI_COMM_WORLD);69 MPI_Bcast(allpidcount,num_procs2,MPI_INT,0,MPI_COMM_WORLD); 66 70 #else 67 71 allpidcount[0]=pidcount; … … 70 74 /* Every cpu should start its own pid count at the end of the pidcount from cpu-1*/ 71 75 pidcount=0; 72 if(my_rank !=0){73 for(i=0;i<my_rank ;i++){76 if(my_rank2!=0){ 77 for(i=0;i<my_rank2;i++){ 74 78 pidcount+=allpidcount[i]; 75 79 } … … 111 115 112 116 int i; 113 extern int num_procs;117 int num_procs2; 114 118 115 119 int* ranks=NULL; 116 120 int* minranks=NULL; 121 122 /*recover num_procs2:*/ 123 num_procs2=IssmComm::GetSize(); 117 124 118 125 /*Allocate ranks: */ … … 120 127 minranks=xNew<int>(numberofobjects); 121 128 122 for(i=0;i<numberofobjects;i++)ranks[i]=num_procs ; //no cpu can have rank num_procs. This is the maximum limit.129 for(i=0;i<numberofobjects;i++)ranks[i]=num_procs2; //no cpu can have rank num_procs. This is the maximum limit. 123 130 124 131 /*Now go through all our objects and ask them to report to who they belong (which rank): */ … … 177 184 void Vertices::Ranks(int* ranks){ 178 185 179 extern int my_rank;186 int my_rank2; 180 187 int sid; 188 189 /*recover my_rank2:*/ 190 my_rank2=IssmComm::GetRank(); 181 191 182 192 /*Go through a dataset, and for each object, report it cpu: */ … … 185 195 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); 186 196 sid=vertex->Sid(); 187 ranks[sid]=my_rank ;188 } 189 } 190 /*}}}*/ 197 ranks[sid]=my_rank2; 198 } 199 } 200 /*}}}*/ -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r13589 r13594 104 104 void IoModel::CheckEnumSync(void){ 105 105 106 extern int my_rank;106 int my_rank2; 107 107 int record_enum = 0; 108 108 109 /*recover my_rank2:*/ 110 my_rank2=IssmComm::GetRank(); 111 109 112 /*Check that some fields have been allocated*/ 110 _assert_(this->fid || my_rank );113 _assert_(this->fid || my_rank2); 111 114 112 115 /*Go find in the binary file, the position of the data we want to fetch: */ 113 if(my_rank ==0){ //cpu 0116 if(my_rank2==0){ //cpu 0 114 117 115 118 /*First set FILE* position to the beginning of the file: */ … … 296 299 void IoModel::FetchConstants(void){ 297 300 298 extern int my_rank; 299 extern int num_procs; 301 int my_rank2; 300 302 301 303 /*record descriptions; */ … … 312 314 int string_size; 313 315 316 /*recover my_rank2:*/ 317 my_rank2=IssmComm::GetRank(); 318 314 319 /*Check that some fields have been allocated*/ 315 _assert_(this->fid || my_rank );320 _assert_(this->fid || my_rank2); 316 321 _assert_(this->constants); 317 322 318 323 /*Go find in the binary file, the position of the data we want to fetch: */ 319 if(my_rank ==0){ //cpu 0{{{324 if(my_rank2==0){ //cpu 0{{{ 320 325 321 326 /*First set FILE* position to the beginning of the file: */ … … 535 540 void IoModel::FetchData(bool* pboolean,int data_enum){ 536 541 537 extern int my_rank; 538 extern int num_procs; 542 int my_rank2; 539 543 540 544 … … 543 547 int code; 544 548 549 /*recover my_rank2:*/ 550 my_rank2=IssmComm::GetRank(); 551 552 545 553 /*Set file pointer to beginning of the data: */ 546 554 fid=this->SetFilePointerToData(&code,NULL,data_enum); … … 549 557 550 558 /*We have to read a boolean from disk. */ 551 if(my_rank ==0){559 if(my_rank2==0){ 552 560 if(fread(&booleanint,sizeof(int),1,fid)!=1) _error_("could not read boolean "); 553 561 } … … 565 573 void IoModel::FetchData(int* pinteger,int data_enum){ 566 574 567 extern int my_rank; 568 extern int num_procs; 575 int my_rank2; 569 576 570 577 /*output: */ … … 572 579 int code; 573 580 581 /*recover my_rank2:*/ 582 my_rank2=IssmComm::GetRank(); 583 574 584 /*Set file pointer to beginning of the data: */ 575 585 fid=this->SetFilePointerToData(&code,NULL,data_enum); … … 578 588 579 589 /*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */ 580 if(my_rank ==0){590 if(my_rank2==0){ 581 591 if(fread(&integer,sizeof(int),1,fid)!=1) _error_("could not read integer "); 582 592 } … … 594 604 595 605 596 extern int my_rank; 597 extern int num_procs; 606 int my_rank2; 598 607 599 608 … … 601 610 IssmPDouble scalar; 602 611 int code; 612 613 /*recover my_rank2:*/ 614 my_rank2=IssmComm::GetRank(); 603 615 604 616 /*Set file pointer to beginning of the data: */ … … 608 620 609 621 /*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */ 610 if(my_rank ==0){622 if(my_rank2==0){ 611 623 if(fread(&scalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar "); 612 624 } … … 623 635 void IoModel::FetchData(char** pstring,int data_enum){ 624 636 625 extern int my_rank; 626 extern int num_procs; 637 int my_rank2; 627 638 628 639 … … 631 642 int string_size; 632 643 int code=0; 644 645 /*recover my_rank2:*/ 646 my_rank2=IssmComm::GetRank(); 633 647 634 648 /*Set file pointer to beginning of the data: */ … … 640 654 641 655 /*We have to read a string from disk. First read the dimensions of the string, then the string: */ 642 if(my_rank ==0){656 if(my_rank2==0){ 643 657 if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string "); 644 658 } … … 654 668 655 669 /*Read string on node 0, then broadcast: */ 656 if(my_rank ==0){670 if(my_rank2==0){ 657 671 if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string "); 658 672 } … … 674 688 void IoModel::FetchData(int** pmatrix,int* pM,int* pN,int data_enum){ 675 689 676 extern int my_rank; 677 extern int num_procs; 690 int my_rank2; 678 691 int i,j; 679 692 … … 684 697 int code=0; 685 698 int vector_type=0; 686 699 700 /*recover my_rank2:*/ 701 my_rank2=IssmComm::GetRank(); 687 702 688 703 /*Set file pointer to beginning of the data: */ … … 695 710 /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */ 696 711 /*numberofelements: */ 697 if(my_rank ==0){712 if(my_rank2==0){ 698 713 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix "); 699 714 } … … 703 718 #endif 704 719 705 if(my_rank ==0){720 if(my_rank2==0){ 706 721 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix "); 707 722 } … … 715 730 716 731 /*Read matrix on node 0, then broadcast: */ 717 if(my_rank ==0){732 if(my_rank2==0){ 718 733 if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 719 734 } … … 749 764 void IoModel::FetchData(IssmDouble** pmatrix,int* pM,int* pN,int data_enum){ 750 765 751 extern int my_rank; 752 extern int num_procs; 766 int my_rank2; 753 767 754 768 /*output: */ … … 757 771 int code=0; 758 772 int vector_type=0; 773 774 /*recover my_rank2:*/ 775 my_rank2=IssmComm::GetRank(); 759 776 760 777 /*Set file pointer to beginning of the data: */ … … 766 783 /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */ 767 784 /*numberofelements: */ 768 if(my_rank ==0){785 if(my_rank2==0){ 769 786 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix "); 770 787 } … … 773 790 #endif 774 791 775 if(my_rank ==0){792 if(my_rank2==0){ 776 793 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix "); 777 794 } … … 785 802 786 803 /*Read matrix on node 0, then broadcast: */ 787 if(my_rank ==0){804 if(my_rank2==0){ 788 805 if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 789 806 } … … 814 831 void IoModel::FetchData(char*** pstrings,int* pnumstrings,int data_enum){ 815 832 816 extern int my_rank; 817 extern int num_procs; 833 int my_rank2; 818 834 819 835 int i; … … 828 844 int code; 829 845 846 /*recover my_rank2:*/ 847 my_rank2=IssmComm::GetRank(); 848 830 849 /*Set file pointer to beginning of the data: */ 831 850 fid=this->SetFilePointerToData(&code,NULL,data_enum); … … 834 853 835 854 /*We have to read a bunch of strings from disk. First read the number of strings, and allocate: */ 836 if(my_rank ==0){855 if(my_rank2==0){ 837 856 if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_("could not read length of string array"); 838 857 } … … 849 868 for(i=0;i<numstrings;i++){ 850 869 851 if(my_rank ==0){870 if(my_rank2==0){ 852 871 if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string "); 853 872 } … … 860 879 861 880 /*Read string on node 0, then broadcast: */ 862 if(my_rank ==0){881 if(my_rank2==0){ 863 882 if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string "); 864 883 } … … 886 905 int i; 887 906 888 extern int my_rank; 889 extern int num_procs; 907 int my_rank2; 890 908 891 909 /*output: */ … … 900 918 int code; 901 919 920 /*recover my_rank2:*/ 921 my_rank2=IssmComm::GetRank(); 922 902 923 /*Set file pointer to beginning of the data: */ 903 924 fid=this->SetFilePointerToData(&code,NULL,data_enum); … … 905 926 906 927 /*Now fetch: */ 907 if(my_rank ==0){928 if(my_rank2==0){ 908 929 if(fread(&numrecords,sizeof(int),1,fid)!=1) _error_("could not read number of records in matrix array "); 909 930 } … … 928 949 for(i=0;i<numrecords;i++){ 929 950 930 if(my_rank ==0){951 if(my_rank2==0){ 931 952 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows in " << i << "th matrix of matrix array"); 932 953 } … … 935 956 #endif 936 957 937 if(my_rank ==0){958 if(my_rank2==0){ 938 959 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns in " << i << "th matrix of matrix array"); 939 960 } … … 947 968 948 969 /*Read matrix on node 0, then broadcast: */ 949 if(my_rank ==0){970 if(my_rank2==0){ 950 971 if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 951 972 } … … 976 997 void IoModel::FetchData(Option** poption,int index){ 977 998 978 extern int my_rank;979 extern int num_procs;980 981 999 /*output: */ 982 1000 int code; 983 1001 char *name = NULL; 984 1002 985 1003 /*First get option name*/ 986 1004 this->FetchData(&name,index); … … 1261 1279 void IoModel::LastIndex(int *pindex){ 1262 1280 1263 extern int my_rank;1281 int my_rank2; 1264 1282 int lastindex,index; 1265 1283 int record_length; 1284 1285 /*recover my_rank2:*/ 1286 my_rank2=IssmComm::GetRank(); 1266 1287 1267 1288 /*Go find in the binary file, the position of the data we want to fetch: */ 1268 if(my_rank ==0){1289 if(my_rank2==0){ 1269 1290 1270 1291 /*First set FILE* position to the beginning of the file: */ … … 1297 1318 FILE* IoModel::SetFilePointerToData(int* pcode,int* pvector_type, int data_enum){ 1298 1319 1299 extern int my_rank; 1300 extern int num_procs; 1320 int my_rank2; 1301 1321 1302 1322 int found = 0; … … 1306 1326 int vector_type = 0; //nodal or elementary 1307 1327 1328 /*recover my_rank2:*/ 1329 my_rank2=IssmComm::GetRank(); 1330 1308 1331 /*Go find in the binary file, the position of the data we want to fetch: */ 1309 if(my_rank ==0){1332 if(my_rank2==0){ 1310 1333 1311 1334 /*First set FILE* position to the beginning of the file: */ -
issm/trunk-jpl/src/c/shared/Exceptions/Exceptions.cpp
r13363 r13594 29 29 30 30 ErrorException::~ErrorException() throw(){ 31 extern int num_procs; 31 32 int num_procs2; 33 34 /*recover num_procs2:*/ 35 num_procs2=IssmComm::GetSize(); 36 32 37 /*We want the report only for matlab modules, otherwise we get twice the report 33 38 * We assume that if num_procs==1, it is a module (FIXME)*/ 34 if(num_procs ==1) this->Report();39 if(num_procs2==1) this->Report(); 35 40 } 36 41 … … 40 45 41 46 void ErrorException::Report() const{ 42 extern int my_rank; 43 extern int num_procs; 47 48 int my_rank2; 49 int num_procs2; 50 51 /*recover my_rank2 and num_procs2:*/ 52 my_rank2=IssmComm::GetRank(); 53 num_procs2=IssmComm::GetSize(); 54 55 44 56 45 57 if (function_name=="" || file_line==0){ //WINDOWS … … 47 59 } 48 60 else{ 49 if(num_procs ==1){61 if(num_procs2==1){ 50 62 _printLine_("\n??? Error using ==> " << file_name.c_str() << ":" << file_line); 51 63 _printLine_(function_name.c_str() << " error message: " << what() << "\n"); 52 64 } 53 65 else{ 54 _printLine_("\n[" << my_rank 55 _printLine_("[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n");66 _printLine_("\n[" << my_rank2<< "] ??? Error using ==> " << file_name.c_str() << ":" << file_line); 67 _printLine_("[" << my_rank2 << "] " << function_name.c_str() << " error message: " << what() << "\n"); 56 68 } 57 69 }
Note:
See TracChangeset
for help on using the changeset viewer.