Changeset 20943
- Timestamp:
- 07/19/16 13:36:05 (9 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/jenkins/jenkins.sh
r20942 r20943 92 92 ISSM_COMPILATION="no" 93 93 fi 94 ISSM_COMPILATION="yes"95 94 96 95 else -
issm/trunk-jpl/src/c/classes/FemModel.cpp
r20936 r20943 187 187 188 188 /*Intermediary*/ 189 FILE *output_fid;190 char *outbinfilename = NULL;191 189 char *lockfilename = NULL; 192 190 bool waitonlock = false; 193 191 194 /*Close output file: */195 this->parameters->FindParam(&output_fid,OutputFilePointerEnum);196 this->parameters->FindParam(&outbinfilename,OutputFileNameEnum);197 pfclose(output_fid,outbinfilename);198 192 199 193 /*Write lock file if requested: */ … … 225 219 226 220 /*Clean up*/ 227 xDelete<char>(outbinfilename);228 221 xDelete<char>(lockfilename); 229 230 } 231 /*}}}*/ 222 } /*}}}*/ 232 223 FemModel* FemModel::copy(void){/*{{{*/ 233 224 … … 296 287 FILE *IOMODEL = NULL; 297 288 FILE *toolkitsoptionsfid = NULL; 298 FILE *output_fid = NULL;299 289 300 290 /*recover my_rank:*/ … … 314 304 pfclose(toolkitsoptionsfid,toolkitsfilename); 315 305 316 /*Open output file once for all and add output file descriptor to parameters*/317 output_fid=pfopen(outputfilename,"wb");318 this->parameters->SetParam(output_fid,OutputFilePointerEnum);319 320 306 /*Now save all of these file names into parameters, you never know when you might need them: */ 321 307 this->parameters->AddObject(new StringParam(ToolkitsFileNameEnum,toolkitsfilename)); … … 441 427 442 428 FILE* restartfid=NULL; 443 FILE* output_fid=NULL;444 429 char* restartfilename = NULL; 445 430 int femmodel_size=0; … … 471 456 femmodel_buffer_ini=femmodel_buffer; //keep track of the initial position, so as to free later. 472 457 473 this->parameters->FindParam(&output_fid,OutputFilePointerEnum);474 475 458 /*Create new FemModel by demarshalling the buffer: */ 476 459 this->Marshall(&femmodel_buffer,NULL,MARSHALLING_BACKWARD); 477 478 this->parameters->SetParam(output_fid,OutputFilePointerEnum);479 460 480 461 /*Reset position of buffer: */ … … 487 468 xDelete<char>(restartfilename); 488 469 xDelete<char>(femmodel_buffer); 489 490 } 491 /*}}}*/ 470 }/*}}}*/ 492 471 void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){/*{{{*/ 493 472 … … 2448 2427 /*}}}*/ 2449 2428 #endif 2450 2451 2429 void FemModel::HydrologyEPLupdateDomainx(IssmDouble* pEplcount){ /*{{{*/ 2452 2430 … … 2585 2563 } 2586 2564 /*}}}*/ 2587 2588 2565 #ifdef _HAVE_JAVASCRIPT_ 2589 2566 FemModel::FemModel(IssmDouble* buffer, int buffersize, char* toolkits, char* solution, char* modelname,ISSM_MPI_Comm incomm, bool trace){ /*{{{*/ … … 2641 2618 poutputbuffersize=outputbuffersizeparam->GetParameterValue(); 2642 2619 2643 /*Close output file. Watch out, only close the output file after recovering the buffer pointers. Not sure2644 * why, but otherwise, the buffers are garbage: */2645 this->parameters->FindParam(&output_fid,OutputFilePointerEnum);2646 fclose(output_fid);2647 2648 2620 /*Assign output values: */ 2649 2621 *poutput=*poutputbuffer; … … 2660 2632 size_t outputsize; 2661 2633 char *outputbuffer; 2662 const char * rootpath="";//needed for Dakota runs only, which we won't do here.2634 const char *rootpath = ""; //needed for Dakota runs only, which we won't do here. 2663 2635 2664 2636 /*recover my_rank:*/ -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r20940 r20943 733 733 ISSM_MPI_Bcast(&record_length,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 734 734 switch(record_code){ 735 case 1: 736 /*boolean. get it from cpu 0 */ 737 ISSM_MPI_Bcast(&booleanint,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 738 739 /*create BoolParam: */ 740 this->AddConstant(new IoConstant((bool)booleanint,record_name)); //cast to a boolean 741 break; 742 743 case 2: 744 /*integer. get it from cpu 0 */ 745 ISSM_MPI_Bcast(&integer,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 746 747 /*create IntParam: */ 748 this->AddConstant(new IoConstant(integer,record_name)); 749 break; 750 case 3: 751 /*scalar. get it from cpu 0 */ 752 { 753 /*IssmDouble, check whether it is already there (from "declare independents")*/ 754 bool exists = false; 755 vector<IoConstant*>::iterator iter; 756 for(iter=constants.begin();iter<constants.end();iter++){ 757 IoConstant* ioconstant=*iter; 758 if(strcmp(ioconstant->name,record_name)==0){ 759 exists = true; 760 break; 735 case 1: 736 /*boolean. get it from cpu 0 */ 737 ISSM_MPI_Bcast(&booleanint,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 738 739 /*create BoolParam: */ 740 this->AddConstant(new IoConstant((bool)booleanint,record_name)); //cast to a boolean 741 break; 742 743 case 2: 744 /*integer. get it from cpu 0 */ 745 ISSM_MPI_Bcast(&integer,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 746 747 /*create IntParam: */ 748 this->AddConstant(new IoConstant(integer,record_name)); 749 break; 750 case 3: 751 /*scalar. get it from cpu 0 */ 752 { 753 /*IssmDouble, check whether it is already there (from "declare independents")*/ 754 bool exists = false; 755 vector<IoConstant*>::iterator iter; 756 for(iter=constants.begin();iter<constants.end();iter++){ 757 IoConstant* ioconstant=*iter; 758 if(strcmp(ioconstant->name,record_name)==0){ 759 exists = true; 760 break; 761 } 761 762 } 763 if(!exists){ 764 ISSM_MPI_Bcast(&pscalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 765 scalar=pscalar; 766 /*create DoubleParam: */ 767 this->AddConstant(new IoConstant(scalar,record_name)); 768 } 769 } 770 break; 771 case 4: 772 ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 773 if(string_size){ 774 string=xNew<char>((string_size+1)); 775 string[string_size]='\0'; 776 777 /*Read string from cpu 0: */ 778 ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 762 779 } 763 if(!exists){ 764 ISSM_MPI_Bcast(&pscalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 765 scalar=pscalar; 766 /*create DoubleParam: */ 767 this->AddConstant(new IoConstant(scalar,record_name)); 780 else{ 781 string=xNew<char>(1); 782 string[0]='\0'; 768 783 } 769 } 770 break; 771 case 4: 772 ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 773 if(string_size){ 774 string=xNew<char>((string_size+1)); 775 string[string_size]='\0'; 776 777 /*Read string from cpu 0: */ 778 ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 779 } 780 else{ 781 string=xNew<char>(1); 782 string[0]='\0'; 783 } 784 if(strcmp(record_name,"md.flowequation.fe_SSA")==0){ 785 this->AddConstant(new IoConstant(StringToEnumx(string),record_name)); 786 } else if(strcmp(record_name,"md.flowequation.fe_HO")==0){ 787 this->AddConstant(new IoConstant(StringToEnumx(string),record_name)); 788 } else if(strcmp(record_name,"md.flowequation.fe_FS")==0){ 789 this->AddConstant(new IoConstant(StringToEnumx(string),record_name)); 790 } else if(strcmp(record_name,"md.groundingline.migration")==0){ 791 this->AddConstant(new IoConstant(StringToEnumx(string),record_name)); 792 } else if(strcmp(record_name,"md.masstransport.hydrostatic_adjustment")==0){ 793 this->AddConstant(new IoConstant(StringToEnumx(string),record_name)); 794 } else { 795 /*Add string to parameters: */ 796 this->AddConstant(new IoConstant(string,record_name)); 797 } 798 799 /*Free string*/ 800 xDelete<char>(string); 801 802 break; 803 case 5: break; //do nothing. not interested in this type of data, which is memory intensive. 804 case 6: break; //do nothing. not interested in this type of data, which is memory intensive. 805 case 7: break; //do nothing. not interested in this type of data, which is memory intensive. 806 case 8: break; //do nothing. not interested in this type of data, which is memory intensive. 807 case 9: 808 ISSM_MPI_Bcast(&numstrings,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 809 /*Now allocate string array: */ 810 if(numstrings){ 811 strings=xNew<char*>(numstrings); 812 for(int i=0;i<numstrings;i++)strings[i]=NULL; 813 814 /*Go through strings, and read: */ 815 for(int i=0;i<numstrings;i++){ 816 817 ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 818 if(string_size){ 819 string=xNew<char>((string_size+1)); 820 string[string_size]='\0'; 821 ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 822 } 823 else{ 824 string=xNew<char>(1); 825 string[0]='\0'; 826 } 827 strings[i]=string; 784 if(strcmp(record_name,"md.flowequation.fe_SSA")==0){ 785 this->AddConstant(new IoConstant(StringToEnumx(string),record_name)); 786 } else if(strcmp(record_name,"md.flowequation.fe_HO")==0){ 787 this->AddConstant(new IoConstant(StringToEnumx(string),record_name)); 788 } else if(strcmp(record_name,"md.flowequation.fe_FS")==0){ 789 this->AddConstant(new IoConstant(StringToEnumx(string),record_name)); 790 } else if(strcmp(record_name,"md.groundingline.migration")==0){ 791 this->AddConstant(new IoConstant(StringToEnumx(string),record_name)); 792 } else if(strcmp(record_name,"md.masstransport.hydrostatic_adjustment")==0){ 793 this->AddConstant(new IoConstant(StringToEnumx(string),record_name)); 794 } else { 795 /*Add string to parameters: */ 796 this->AddConstant(new IoConstant(string,record_name)); 828 797 } 829 } 830 831 /*Add strings to parameters: */ 832 this->AddConstant(new IoConstant(strings,numstrings,record_name)); 833 834 /*Free string*/ 835 for(int i=0;i<numstrings;i++) xDelete<char>(strings[i]); 836 xDelete<char*>(strings); 837 break; 838 default: 839 _error_("unknown record type:" << record_code); 840 break; 798 799 /*Free string*/ 800 xDelete<char>(string); 801 802 break; 803 case 5: break; //do nothing. not interested in this type of data, which is memory intensive. 804 case 6: break; //do nothing. not interested in this type of data, which is memory intensive. 805 case 7: break; //do nothing. not interested in this type of data, which is memory intensive. 806 case 8: break; //do nothing. not interested in this type of data, which is memory intensive. 807 case 9: 808 ISSM_MPI_Bcast(&numstrings,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 809 /*Now allocate string array: */ 810 if(numstrings){ 811 strings=xNew<char*>(numstrings); 812 for(int i=0;i<numstrings;i++)strings[i]=NULL; 813 814 /*Go through strings, and read: */ 815 for(int i=0;i<numstrings;i++){ 816 817 ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 818 if(string_size){ 819 string=xNew<char>((string_size+1)); 820 string[string_size]='\0'; 821 ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 822 } 823 else{ 824 string=xNew<char>(1); 825 string[0]='\0'; 826 } 827 strings[i]=string; 828 } 829 } 830 831 /*Add strings to parameters: */ 832 this->AddConstant(new IoConstant(strings,numstrings,record_name)); 833 834 /*Free string*/ 835 for(int i=0;i<numstrings;i++) xDelete<char>(strings[i]); 836 xDelete<char*>(strings); 837 break; 838 default: 839 _error_("unknown record type:" << record_code); 840 break; 841 841 } 842 842 xDelete<char>(record_name); 843 843 } 844 844 } -
issm/trunk-jpl/src/c/classes/Params/Parameters.cpp
r20827 r20943 221 221 222 222 /*Object management*/ 223 void Parameters::Delete(int param_enum){/*{{{*/ 224 225 _assert_(param_enum>ParametersSTARTEnum); 226 _assert_(param_enum<ParametersENDEnum); 227 228 int index = param_enum - ParametersSTARTEnum -1; 229 if(this->params[index]){ 230 delete this->params[index]; 231 this->params[index] = NULL; 232 } 233 234 return; 235 } 236 /*}}}*/ 223 237 bool Parameters::Exist(int param_enum){/*{{{*/ 224 238 -
issm/trunk-jpl/src/c/classes/Params/Parameters.h
r20827 r20943 32 32 void DeepEcho(); 33 33 void Echo(); 34 void Delete(int enum_type); 34 35 bool Exist(int enum_type); 35 36 void Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction); -
issm/trunk-jpl/src/c/modules/OutputResultsx/OutputResultsx.cpp
r19709 r20943 46 46 } 47 47 48 /*Now, open file for writing, if not already done: */ 49 if(!femmodel->parameters->Exist(OutputFilePointerEnum)){ 48 /*Now, open file for writing*/ 49 _assert_(!femmodel->parameters->Exist(OutputFilePointerEnum)); 50 femmodel->parameters->FindParam(&outputfilename,OutputFileNameEnum); 51 femmodel->parameters->FindParam(&io_gather,SettingsIoGatherEnum); 50 52 51 /*We don't have a file pointer. Retrieve the output file name and open it for writing:*/ 52 femmodel->parameters->FindParam(&outputfilename,OutputFileNameEnum); 53 #ifdef _HAVE_JAVASCRIPT_ 54 femmodel->parameters->FindParam(&fid,OutputFilePointerEnum); 55 #else 53 56 54 /*What strategy? : */ 55 femmodel->parameters->FindParam(&io_gather,SettingsIoGatherEnum); 57 if(io_gather){ 58 /*Just open the file for output on cpu 0. We are gathering the data on cpu 0 from all other cpus: */ 59 if(my_rank==0) fid=pfopen0(outputfilename ,"ab+"); 60 } 61 else{ 62 /*We are opening different files for output on all cpus. Append the rank to the filename, and open: */ 63 sprintf(cpu_outputfilename,"%s.%i",outputfilename,my_rank); 64 fid=pfopen(cpu_outputfilename ,"ab+"); 65 } 56 66 57 if(io_gather){ 58 /*Just open the file for output on cpu 0. We are gathering the data on cpu 0 from all other cpus: */ 59 if(my_rank==0) fid=pfopen0(outputfilename ,"wb"); 60 } 61 else{ 62 /*We are opening different files for output on all cpus. Append the rank to the filename, and open: */ 63 femmodel->parameters->FindParam(&fid,OutputFilePointerEnum); 64 sprintf(cpu_outputfilename,"%s.%i",outputfilename,my_rank); 65 fid=pfopen(cpu_outputfilename ,"wb"); 66 } 67 xDelete<char>(outputfilename); 68 69 /*Add file pointer in parameters for further calls to OutputResultsx: */ 70 femmodel->parameters->SetParam(fid,OutputFilePointerEnum); 71 } 67 /*Add file pointer in parameters for further calls to OutputResultsx: */ 68 femmodel->parameters->SetParam(fid,OutputFilePointerEnum); 69 #endif 72 70 73 71 /*Write results to disk: */ 74 72 femmodel->results->Write(femmodel->parameters); 75 73 74 femmodel->parameters->Delete(OutputFilePointerEnum); 75 76 76 /*Delete and reinitialize results, in parallel: */ 77 77 femmodel->results->clear(); 78 78 79 #ifndef _HAVE_JAVASCRIPT_ 79 80 /*Close output file? :*/ 80 /*FIXME WARNING: issm.cpp is taking care of it for now (quick fix)81 if((step==1) && (time==0)){82 if(io_gather){83 if(my_rank==0) pfclose(fid,outputfilename);84 } 85 else pfclose(fid,cpu_outputfilename); 86 }87 */81 if(io_gather){ 82 if(my_rank==0) pfclose(fid,outputfilename); 83 } 84 else pfclose(fid,cpu_outputfilename); 85 #endif 86 87 /*Clean up and return*/ 88 xDelete<char>(outputfilename); 88 89 }
Note:
See TracChangeset
for help on using the changeset viewer.