Changeset 12015
- Timestamp:
- 04/16/12 19:08:00 (13 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Container/DataSet.cpp
r11874 r12015 84 84 /*}}}*/ 85 85 86 /*I/O*/87 #ifdef _SERIAL_88 /*FUNCTION DataSet::Marshall{{{1*/89 char* DataSet::Marshall(){90 91 vector<Object*>::iterator object;92 int object_size;93 int marshalled_dataset_size=0;94 char* marshalled_dataset=NULL;95 char* old_marshalled_dataset=NULL;96 97 /*First get size of marshalled dataset: */98 object_size=(int)objects.size();99 100 marshalled_dataset_size=MarshallSize();101 102 /*Allocate marshalled dataset: */103 marshalled_dataset=(char*)xmalloc(marshalled_dataset_size*sizeof(char));104 105 /*Keep track of old_marshalled_dataset: */106 old_marshalled_dataset=marshalled_dataset;107 108 /*Store internals of dataset first: */109 memcpy(marshalled_dataset,&object_size,sizeof(int)); marshalled_dataset+=sizeof(int);110 memcpy(marshalled_dataset,&sorted,sizeof(int)); marshalled_dataset+=sizeof(int);111 if(sorted){112 if(object_size)memcpy(marshalled_dataset,sorted_ids,object_size*sizeof(int)); marshalled_dataset+=object_size*sizeof(int);113 if(object_size)memcpy(marshalled_dataset,id_offsets,object_size*sizeof(int)); marshalled_dataset+=object_size*sizeof(int);114 }115 116 for ( object=objects.begin() ; object < objects.end(); object++ ){117 (*object)->Marshall(&marshalled_dataset);118 }119 120 /* Ok, marshalled_dataset now points to the end of the original marshalled_dataset pointer121 * before we started the loop on objects. Get object to point right again: */122 marshalled_dataset-=marshalled_dataset_size;123 124 /*We should be back to old_marshalled_dataset: check and abort if that's not the case,125 * because this is a nasty error: */126 if (marshalled_dataset!=old_marshalled_dataset){127 _error_("final marshalled dataset \"%s\" is different from initial one!",EnumToStringx(enum_type));128 abort();129 }130 131 /*Return: */132 return marshalled_dataset;133 }134 /*}}}*/135 /*FUNCTION DataSet::MarshallSize{{{1*/136 int DataSet::MarshallSize(){137 138 vector<Object*>::iterator object;139 int marshalled_dataset_size=0;140 141 142 for ( object=objects.begin() ; object < objects.end(); object++ ){143 marshalled_dataset_size+= (*object)->MarshallSize();144 }145 146 marshalled_dataset_size+=sizeof(int); //objects size147 marshalled_dataset_size+=sizeof(int); //sorted size148 if(sorted){149 marshalled_dataset_size+=(int)objects.size()*sizeof(int); //sorted ids150 marshalled_dataset_size+=(int)objects.size()*sizeof(int); //id offsets151 }152 153 return marshalled_dataset_size;154 }155 /*}}}*/156 /*FUNCTION DataSet::Demarshall{{{1*/157 DataSet* DataSetDemarshall(char* marshalled_dataset){158 159 return DataSetDemarshallRaw(&marshalled_dataset);160 161 }162 /*}}}*/163 /*FUNCTION DataSet::DemarshallRaw{{{1*/164 DataSet* DataSetDemarshallRaw(char** pmarshalled_dataset){165 166 int i;167 168 DataSet* dataset=NULL;169 int numobjects=0;170 int enum_type;171 Object* object=NULL;172 int sorted;173 int* sorted_ids=NULL;174 int* id_offsets=NULL;175 char* marshalled_dataset=NULL;176 177 /*recover marshalled_dataset pointer: */178 marshalled_dataset=*pmarshalled_dataset;179 180 /*initialize dataset: */181 dataset=new DataSet();182 183 /*Get internals first: */184 memcpy(&numobjects,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);185 memcpy(&sorted,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);186 if(sorted){187 if(numobjects){188 sorted_ids=(int*)xmalloc(numobjects*sizeof(int));189 id_offsets=(int*)xmalloc(numobjects*sizeof(int));190 memcpy(sorted_ids,marshalled_dataset,numobjects*sizeof(int)); marshalled_dataset+=numobjects*sizeof(int);191 memcpy(id_offsets,marshalled_dataset,numobjects*sizeof(int)); marshalled_dataset+=numobjects*sizeof(int);192 }193 dataset->SetSorting(sorted_ids,id_offsets);194 }195 196 for(i=0;i<numobjects;i++){197 198 /*get enum type of object: */199 memcpy(&enum_type,marshalled_dataset,sizeof(int)); marshalled_dataset+=sizeof(int);200 201 switch(enum_type){202 case NodeEnum:{203 Node* node=NULL;204 node=new Node();205 node->Demarshall(&marshalled_dataset);206 dataset->AddObject(node);}207 break;208 case VertexEnum:{209 Vertex* vertex=NULL;210 vertex=new Vertex();211 vertex->Demarshall(&marshalled_dataset);212 dataset->AddObject(vertex);}213 break;214 case DoubleParamEnum:{215 DoubleParam* doubleparam=NULL;216 doubleparam=new DoubleParam();217 doubleparam->Demarshall(&marshalled_dataset);218 dataset->AddObject(doubleparam);}219 break;220 case TriaEnum:{221 Tria* tria=NULL;222 tria=new Tria();223 tria->Demarshall(&marshalled_dataset);224 dataset->AddObject(tria);}225 break;226 case TriaP1InputEnum:{227 TriaP1Input* triavertexinput=NULL;228 triavertexinput=new TriaP1Input();229 triavertexinput->Demarshall(&marshalled_dataset);230 dataset->AddObject(triavertexinput);}231 break;232 #ifdef _HAVE_3D_233 case PentaP1InputEnum:{234 PentaP1Input* pentavertexinput=NULL;235 pentavertexinput=new PentaP1Input();236 pentavertexinput->Demarshall(&marshalled_dataset);237 dataset->AddObject(pentavertexinput);}238 break;239 #endif240 case TransientInputEnum:{241 TransientInput* transientinput=NULL;242 transientinput=new TransientInput();243 transientinput->Demarshall(&marshalled_dataset);244 dataset->AddObject(transientinput);}245 break;246 #ifdef _HAVE_CONTROL_247 case ControlInputEnum:{248 ControlInput* controlinputinput=NULL;249 controlinputinput=new ControlInput();250 controlinputinput->Demarshall(&marshalled_dataset);251 dataset->AddObject(controlinputinput);}252 break;253 #endif254 case DatasetInputEnum:{255 DatasetInput* datasetinputinput=NULL;256 datasetinputinput=new DatasetInput();257 datasetinputinput->Demarshall(&marshalled_dataset);258 dataset->AddObject(datasetinputinput);}259 break;260 case TriaP1ElementResultEnum:{261 TriaP1ElementResult* triavertexelementresult=NULL;262 triavertexelementresult=new TriaP1ElementResult();263 triavertexelementresult->Demarshall(&marshalled_dataset);264 dataset->AddObject(triavertexelementresult);}265 break;266 #ifdef _HAVE_3D_267 case PentaP1ElementResultEnum:{268 PentaP1ElementResult* pentavertexelementresult=NULL;269 pentavertexelementresult=new PentaP1ElementResult();270 pentavertexelementresult->Demarshall(&marshalled_dataset);271 dataset->AddObject(pentavertexelementresult);}272 break;273 case PentaEnum:{274 Penta* penta=NULL;275 penta=new Penta();276 penta->Demarshall(&marshalled_dataset);277 dataset->AddObject(penta);}278 break;279 #endif280 case MaticeEnum:{281 Matice* matice=NULL;282 matice=new Matice();283 matice->Demarshall(&marshalled_dataset);284 dataset->AddObject(matice);}285 break;286 case MatparEnum:{287 Matpar* matpar=NULL;288 matpar=new Matpar();289 matpar->Demarshall(&marshalled_dataset);290 dataset->AddObject(matpar);}291 break;292 case SpcStaticEnum:{293 SpcStatic* spcstatic=NULL;294 spcstatic=new SpcStatic();295 spcstatic->Demarshall(&marshalled_dataset);296 dataset->AddObject(spcstatic);}297 break;298 case SpcDynamicEnum:{299 SpcDynamic* spcdynamic=NULL;300 spcdynamic=new SpcDynamic();301 spcdynamic->Demarshall(&marshalled_dataset);302 dataset->AddObject(spcdynamic);}303 break;304 case SpcTransientEnum:{305 SpcTransient* spctransient=NULL;306 spctransient=new SpcTransient();307 spctransient->Demarshall(&marshalled_dataset);308 dataset->AddObject(spctransient);}309 break;310 case PengridEnum:{311 Pengrid* pengrid=NULL;312 pengrid=new Pengrid();313 pengrid->Demarshall(&marshalled_dataset);314 dataset->AddObject(pengrid);}315 break;316 case PenpairEnum:{317 Penpair* penpair=NULL;318 penpair=new Penpair();319 penpair->Demarshall(&marshalled_dataset);320 dataset->AddObject(penpair);}321 break;322 case IcefrontEnum:{323 Icefront* icefront=NULL;324 icefront=new Icefront();325 icefront->Demarshall(&marshalled_dataset);326 dataset->AddObject(icefront);}327 break;328 case NumericalfluxEnum:{329 Numericalflux* numericalflux=NULL;330 numericalflux=new Numericalflux();331 numericalflux->Demarshall(&marshalled_dataset);332 dataset->AddObject(numericalflux);}333 break;334 #ifdef _HAVE_RIFTS_335 case RiftfrontEnum:{336 Riftfront* riftfront=NULL;337 riftfront=new Riftfront();338 riftfront->Demarshall(&marshalled_dataset);339 dataset->AddObject(riftfront);}340 break;341 #endif342 case DoubleInputEnum:{343 DoubleInput* doubleinput=NULL;344 doubleinput=new DoubleInput();345 doubleinput->Demarshall(&marshalled_dataset);346 dataset->AddObject(doubleinput);}347 break;348 case IntInputEnum:{349 IntInput* intinput=NULL;350 intinput=new IntInput();351 intinput->Demarshall(&marshalled_dataset);352 dataset->AddObject(intinput);}353 break;354 case BoolInputEnum:{355 BoolInput* boolinput=NULL;356 boolinput=new BoolInput();357 boolinput->Demarshall(&marshalled_dataset);358 dataset->AddObject(boolinput);}359 break;360 case IntParamEnum:{361 IntParam* intparam=NULL;362 intparam=new IntParam();363 intparam->Demarshall(&marshalled_dataset);364 dataset->AddObject(intparam);}365 break;366 case BoolParamEnum:{367 BoolParam* boolparam=NULL;368 boolparam=new BoolParam();369 boolparam->Demarshall(&marshalled_dataset);370 dataset->AddObject(boolparam);}371 break;372 case StringParamEnum:{373 StringParam* stringparam=NULL;374 stringparam=new StringParam();375 stringparam->Demarshall(&marshalled_dataset);376 dataset->AddObject(stringparam);}377 break;378 case DoubleVecExternalResultEnum:{379 DoubleVecExternalResult* doublevecexternalresult=NULL;380 doublevecexternalresult=new DoubleVecExternalResult();381 doublevecexternalresult->Demarshall(&marshalled_dataset);382 dataset->AddObject(doublevecexternalresult);}383 break;384 case DoubleExternalResultEnum:{385 DoubleExternalResult* doubleexternalresult=NULL;386 doubleexternalresult=new DoubleExternalResult();387 doubleexternalresult->Demarshall(&marshalled_dataset);388 dataset->AddObject(doubleexternalresult);}389 break;390 #ifdef _HAVE_GROUNDINGLINE_391 case BoolElementResultEnum:{392 BoolElementResult* boolelementresult=NULL;393 boolelementresult=new BoolElementResult();394 boolelementresult->Demarshall(&marshalled_dataset);395 dataset->AddObject(boolelementresult);}396 break;397 #endif398 default:399 _error_("could not recognize enum type: %s",EnumToStringx(enum_type));400 }401 }402 403 /*Assign output pointers:*/404 *pmarshalled_dataset=marshalled_dataset;405 406 return dataset;407 }408 /*}}}*/409 #endif410 411 86 /*Specific methods*/ 412 87 /*FUNCTION DataSet::AddObject{{{1*/ -
issm/trunk-jpl/src/c/Container/DataSet.h
r9777 r12015 49 49 void Echo(); 50 50 void DeepEcho(); 51 #ifdef _SERIAL_52 char* Marshall();53 int MarshallSize();54 #endif55 51 int AddObject(Object* object); 56 52 int DeleteObject(int id); … … 69 65 }; 70 66 71 /*This routine cannot be object oriented, but need for demarshalling: */72 #ifdef _SERIAL_73 DataSet* DataSetDemarshall(char* marshalled_dataset);74 DataSet* DataSetDemarshallRaw(char** pmarshalled_dataset);75 67 #endif 76 77 78 79 #endif -
issm/trunk-jpl/src/c/Container/Options.cpp
r11944 r12015 20 20 #include "../shared/shared.h" 21 21 #include "../EnumDefinitions/EnumDefinitions.h" 22 #if _SERIAL_23 22 #include "../io/io.h" 24 #endif25 23 /*}}}*/ 26 24 … … 31 29 } 32 30 /*}}}*/ 33 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)34 /*FUNCTION Options::Options(int istart, int nrhs, const mxArray* prhs[]){{{1*/35 Options::Options(int istart, int nrhs, const mxArray* prhs[]){36 37 int i;38 char *name = NULL;39 Option *option = NULL;40 41 /*loop over each name and value*/42 for (i=istart; i<nrhs; i=i+2){43 if (!mxIsClass(prhs[i],"char")) _error_("Argument %d must be name of option.",i+1);44 45 FetchData(&name,prhs[i]);46 if (i+1 == nrhs) _error_("Argument %d must exist and be value of option \"%s\".",i+2,name);47 48 //_printf_(true," Processing option \"%s\" of class \"%s\".\n",name,mxGetClassName(prhs[i+1]));49 option=(Option*)OptionParse(name,&prhs[i+1]);50 this->AddOption(option);51 option=NULL;52 }53 54 /*echo the dataset */55 //if (this->Size()) for(i=0;i<this->Size();i++) ((Option*)this->GetObjectByOffset(i))->Echo();56 }57 /*}}}*/58 #endif59 31 /*FUNCTION Options::~Options(){{{1*/ 60 32 Options::~Options(){ -
issm/trunk-jpl/src/c/Makefile.am
r12013 r12015 727 727 #Python sources {{{1 728 728 python_sources= ./python/io/pythonio.h\ 729 ./python/python-binding.h\ 729 730 ./python/io/WritePythonData.cpp\ 730 731 ./python/io/CheckNumPythonArguments.cpp\ … … 740 741 #Matlab sources {{{1 741 742 matlab_sources= ./toolkits/matlab/matlabincludes.h\ 743 ./matlab/matlab-binding.h\ 742 744 ./matlab/io/matlabio.h\ 743 745 ./matlab/io/MatlabNArrayToNArray.cpp\ -
issm/trunk-jpl/src/c/include/macros.h
r12011 r12015 40 40 #endif 41 41 /*}}}*/ 42 43 42 /* MODULEBOOT/MODULEEND {{{1*/ 44 43 … … 47 46 * will be trapped. Really nifty!*/ 48 47 49 #ifdef _SERIAL_50 #ifdef _HAVE_PYTHON_ //{{{251 #define MODULEBOOT(); ModuleBoot(); \52 PyObject* output = PyTuple_New(NLHS); if (!output) return NULL;53 54 #define MODULEEND(); ModuleEnd(); \55 return output;56 #endif //}}}57 #else58 //{{{259 48 #define MODULEBOOT(); \ 60 49 try{ … … 69 58 return 1;\ 70 59 } 71 //}}}72 #endif73 /*}}}*/74 /* WRAPPER {{{1*/75 #ifdef _HAVE_PYTHON_76 #define WRAPPER(modulename,...) \77 \78 static PyObject* modulename(PyObject* self,PyObject* args);\79 static PyMethodDef modulename##_funcs[] = {\80 {#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\81 {NULL,NULL,0,NULL}\82 };\83 \84 static struct PyModuleDef modulename##module= {\85 PyModuleDef_HEAD_INIT,\86 #modulename, /* name of module */\87 NULL, /* module documentation, may be NULL */\88 -1, /* size of per-interpreter state of the module,\89 or -1 if the module keeps state in global variables. */\90 modulename##_funcs\91 };\92 \93 PyMODINIT_FUNC PyInit_##modulename(void){\94 \95 import_array();\96 return PyModule_Create(&modulename##module);\97 }\98 \99 static PyObject* modulename(PyObject* self,PyObject* args)100 101 #endif102 103 /*}}}*/104 /* CHECKARGUMENTS {{{1*/105 #ifdef _HAVE_PYTHON_106 #define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumPythonArguments(args, NRHS,functionpointer)107 #endif108 60 /*}}}*/ 109 61 -
issm/trunk-jpl/src/c/matlab/include/matlab_macros.h
r12013 r12015 1 /* \file ma cros.h2 * \brief: global macros used in the whole code1 /* \file matlab macros.h 2 * \brief: macros used for the matlab bindings 3 3 */ 4 4 -
issm/trunk-jpl/src/c/shared/shared.h
r11973 r12015 8 8 9 9 #include "Alloc/alloc.h" 10 #include "Alloc/alloc_module.h" 10 11 #include "Exceptions/exceptions.h" 11 12 #include "Exp/exp.h" -
issm/trunk-jpl/src/mex/TriMesh/TriMesh.cpp
r11969 r12015 50 50 /*free ressources: */ 51 51 delete domain; 52 xdelete (&index);53 xdelete (&x);54 xdelete (&y);55 xdelete (&segments);56 xdelete (&segmentmarkerlist);52 xdelete_module(&index); 53 xdelete_module(&x); 54 xdelete_module(&y); 55 xdelete_module(&segments); 56 xdelete_module(&segmentmarkerlist); 57 57 58 58 /*end module: */
Note:
See TracChangeset
for help on using the changeset viewer.