Changeset 13701
- Timestamp:
- 10/16/12 14:37:32 (12 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/IssmComm.cpp
r13613 r13701 19 19 }/*}}}*/ 20 20 int IssmComm::GetRank(){ /*{{{*/ 21 int my_rank; 21 int my_rank = 0; 22 23 /*for matlab and python modules, comm == -1*/ 24 if((int)comm==-1) return my_rank; 25 22 26 #ifdef _HAVE_MPI_ 23 27 MPI_Comm_rank(comm,&my_rank); 24 #else25 my_rank=0;26 28 #endif 29 27 30 return my_rank; 28 31 29 32 }/*}}}*/ 30 33 int IssmComm::GetSize(){ /*{{{*/ 31 int size; 34 35 int size = 1; 36 37 /*for matlab and python modules, comm == -1*/ 38 if((int)comm==-1) return size; 39 32 40 #ifdef _HAVE_MPI_ 33 41 MPI_Comm_size(comm,&size); 34 #else35 size=1;36 42 #endif 43 37 44 return size; 38 45 -
issm/trunk-jpl/src/c/include/macros.h
r13531 r13701 23 23 #define _printf_(flag,...) do{if(flag) PrintfFunction(__VA_ARGS__);}while(0) 24 24 /*}}}*/ 25 /* _error 2_ {{{*/25 /* _error_ {{{*/ 26 26 /*new Error exception macro*/ 27 27 #ifdef _INTEL_WIN_ … … 82 82 #define ExceptionTrapEnd(); }\ 83 83 catch(ErrorException &exception){\ 84 exception.Report(); \85 84 return 1;\ 86 85 }\ -
issm/trunk-jpl/src/c/matlab/include/matlab_macros.h
r13231 r13701 20 20 * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions 21 21 * will be trapped*/ 22 #define MODULEBOOT(); try{ 22 #define MODULEBOOT(); try{ \ 23 IssmComm::SetComm(-1); 23 24 24 25 #define MODULEEND(); }\ 25 26 catch(ErrorException &exception){\ 26 mexErrMsgTxt( "ISSM Error"); \27 mexErrMsgTxt(exception.MatlabReport()); \ 27 28 }\ 28 29 catch (exception &e){\ -
issm/trunk-jpl/src/c/python/include/python_macros.h
r13627 r13701 22 22 * will be trapped*/ 23 23 #define MODULEBOOT(); \ 24 PyObject *output = PyTuple_New(NLHS); 24 PyObject *output = PyTuple_New(NLHS); \ 25 25 int nrhs = (int)PyTuple_Size(args); \ 26 26 if(!output) return NULL;\ 27 try{ \ 27 try{ \ 28 IssmComm::SetComm(-1); 28 29 29 30 #define MODULEEND(); }\ 30 31 catch(ErrorException &exception){\ 31 PyErr_SetString(PyExc_TypeError, "ISSM Error"); \32 PyErr_SetString(PyExc_TypeError,exception.PythonReport()); \ 32 33 return NULL;\ 33 34 } \ -
issm/trunk-jpl/src/c/shared/Exceptions/Exceptions.cpp
r13622 r13701 12 12 #include "../../include/include.h" 13 13 14 ErrorException::ErrorException(const string &what_arg){ 14 ErrorException::ErrorException(const string &what_arg){/*{{{*/ 15 15 16 16 what_str=what_arg; … … 18 18 function_name=""; 19 19 file_line=0; 20 } 21 22 ErrorException::ErrorException(const string& what_file, const string& what_function,int what_line, const string& what_arg){ 20 }/*}}}*/ 21 ErrorException::ErrorException(const string& what_file, const string& what_function,int what_line, const string& what_arg){/*{{{*/ 23 22 24 23 what_str=what_arg; … … 26 25 function_name=what_function; 27 26 file_line=what_line; 28 } 29 30 ErrorException::~ErrorException() throw(){ 31 32 int num_procs; 33 34 /*recover num_procs:*/ 35 num_procs=IssmComm::GetSize(); 36 37 /*We want the report only for matlab modules, otherwise we get twice the report 38 * We assume that if num_procs==1, it is a module (FIXME)*/ 39 if(num_procs==1) this->Report(); 40 } 41 42 const char* ErrorException::what() const throw(){ 27 }/*}}}*/ 28 ErrorException::~ErrorException() throw(){/*{{{*/ 29 }/*}}}*/ 30 const char* ErrorException::what() const throw(){/*{{{*/ 43 31 return what_str.c_str(); 44 } 45 46 void ErrorException::Report() const{ 32 }/*}}}*/ 33 void ErrorException::Report() const{/*{{{*/ 47 34 48 35 int my_rank; … … 58 45 else{ 59 46 if(num_procs==1){ 60 _printLine_("\n??? Error using==> " << file_name.c_str() << ":" << file_line);47 _printLine_("\n??? Error in ==> " << file_name.c_str() << ":" << file_line); 61 48 _printLine_(function_name.c_str() << " error message: " << what() << "\n"); 62 49 } 63 50 else{ 64 51 _printLine_("\n[" << my_rank<< "] ??? Error using ==> " << file_name.c_str() << ":" << file_line); 65 _printLine_( "[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n");52 _printLine_( "[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n"); 66 53 } 67 54 } 68 55 return; 69 } 56 }/*}}}*/ 57 const char* ErrorException::MatlabReport() const{/*{{{*/ 58 59 /*Output*/ 60 std::ostringstream buffer; 61 62 if (this->file_line==0){ //WINDOWS 63 buffer << " error message: " << (this->what_str).c_str(); 64 } 65 else{ 66 buffer << "\nError in ==> " << (this->file_name).c_str() << ":" << file_line << "\n"; 67 buffer << (this->function_name).c_str() << " error message: " << (this->what_str).c_str(); 68 } 69 70 return buffer.str().c_str(); 71 }/*}}}*/ 72 const char* ErrorException::PythonReport() const{/*{{{*/ 73 74 /*Output*/ 75 std::ostringstream buffer; 76 77 if (this->file_line==0){ //WINDOWS 78 buffer << " error message: " << (this->what_str).c_str(); 79 } 80 else{ 81 buffer << "\nError in ==> " << (this->file_name).c_str() << ":" << file_line << "\n"; 82 buffer << (this->function_name).c_str() << " error message: " << (this->what_str).c_str(); 83 } 84 85 return buffer.str().c_str(); 86 }/*}}}*/ -
issm/trunk-jpl/src/c/shared/Exceptions/exceptions.h
r13623 r13701 28 28 virtual const char *what() const throw(); 29 29 void Report() const; 30 const char* MatlabReport() const; 31 const char* PythonReport() const; 30 32 31 33 };
Note:
See TracChangeset
for help on using the changeset viewer.