Changeset 12450
- Timestamp:
- 06/18/12 15:26:50 (13 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/EnumDefinitions/Synchronize.sh
r12365 r12450 48 48 49 49 len=strlen(EnumToStringx(enum_in)); 50 string= (char*)xmalloc((len+1)*sizeof(char));50 string=xNew<char>(len+1); 51 51 memcpy(string,EnumToStringx(enum_in),(len+1)*sizeof(char)); 52 52 -
issm/trunk-jpl/src/c/modules/AverageFilterx/AverageFilterx.cpp
r3913 r12450 18 18 19 19 /*output: */ 20 double* 20 double* imageout=NULL; 21 21 22 imageout= (double*)xmalloc(samps*lines*sizeof(double));22 imageout=xNew<double>(samps*lines); 23 23 24 24 for ( i = 0; i < lines; i++ ){ -
issm/trunk-jpl/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp
r11695 r12450 65 65 66 66 /*Free ressources:*/ 67 x free((void**)&qmu_part);67 xDelete<int>(qmu_part); 68 68 xdelete(&partition_contributions); 69 69 xdelete(&partition_areas); -
issm/trunk-jpl/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
r12127 r12450 70 70 71 71 /*Free ressources:*/ 72 x free((void**)&in_nod_serial);72 xDelete<double>(in_nod_serial); 73 73 74 74 return noerr; -
issm/trunk-jpl/src/c/modules/ControlInputGetGradientx/ControlInputGetGradientx.cpp
r11695 r12450 33 33 34 34 /*Clean up and return*/ 35 x free((void**)&control_type);35 xDelete<int>(control_type); 36 36 *pgradient=gradient; 37 37 } -
issm/trunk-jpl/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp
r11313 r12450 37 37 38 38 /*Clean up and return*/ 39 x free((void**)&control_type);40 x free((void**)&scalar_list);39 xDelete<int>(control_type); 40 xDelete<double>(scalar_list); 41 41 } -
issm/trunk-jpl/src/c/modules/ControlInputSetGradientx/ControlInputSetGradientx.cpp
r11695 r12450 27 27 28 28 /*Clean up and return*/ 29 x free((void**)&control_type);29 xDelete<int>(control_type); 30 30 31 31 } … … 39 39 40 40 /*Clean up and return*/ 41 x free((void**)&serial_gradient);41 xDelete<double>(serial_gradient); 42 42 } -
issm/trunk-jpl/src/c/modules/CostFunctionx/CostFunctionx.cpp
r11901 r12450 35 35 36 36 /*Assign output pointers: */ 37 x free((void**)&responses);37 xDelete<int>(responses); 38 38 *pJ=J; 39 39 } -
issm/trunk-jpl/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp
r9650 r12450 30 30 double femmodel_response; 31 31 int flag; 32 double* vertex_response=NULL; 33 double* qmu_response=NULL; 34 35 double* responses_pointer=NULL; 32 double *vertex_response = NULL; 33 double *qmu_response = NULL; 34 double *responses_pointer = NULL; 36 35 37 36 /*retrieve npart: */ … … 66 65 67 66 /*Free ressources:*/ 68 x free((void**)&vertex_response);69 x free((void**)&qmu_response);67 xDelete<double>(vertex_response); 68 xDelete<double>(qmu_response); 70 69 71 70 } -
issm/trunk-jpl/src/c/modules/Dakotax/DakotaFree.cpp
r9761 r12450 22 22 extern int my_rank; 23 23 24 double * variables=NULL;25 char ** variables_descriptors=NULL;26 char ** responses_descriptors=NULL;27 char * string=NULL;24 double *variables = NULL; 25 char **variables_descriptors = NULL; 26 char **responses_descriptors = NULL; 27 char *string = NULL; 28 28 29 29 /*recover pointers: */ … … 35 35 /*Free variables and variables_descriptors only on cpu !=0*/ 36 36 if(my_rank!=0){ 37 x free((void**)&variables);37 xDelete<double>(variables); 38 38 for(i=0;i<numvariables;i++){ 39 39 string=variables_descriptors[i]; 40 x free((void**)&string);40 xDelete<char>(string); 41 41 } 42 x free((void**)&variables_descriptors);42 xDelete<char*>(variables_descriptors); 43 43 } 44 44 … … 46 46 for(i=0;i<numresponses;i++){ 47 47 string=responses_descriptors[i]; 48 x free((void**)&string);48 xDelete<char>(string); 49 49 } 50 50 //rest of dynamic allocations. 51 x free((void**)&responses_descriptors);51 xDelete<char*>(responses_descriptors); 52 52 53 53 /*Assign output pointers:*/ … … 56 56 *presponses_descriptors=responses_descriptors; 57 57 } 58 -
issm/trunk-jpl/src/c/modules/Dakotax/DakotaMPI_Bcast.cpp
r9761 r12450 38 38 39 39 /*variables:*/ 40 if(my_rank!=0)variables= (double*)xmalloc(numvariables*sizeof(double));40 if(my_rank!=0)variables=xNew<double>(numvariables); 41 41 MPI_Bcast(variables,numvariables,MPI_DOUBLE,0,MPI_COMM_WORLD); 42 42 43 43 /*variables_descriptors: */ 44 44 if(my_rank!=0){ 45 variables_descriptors= (char**)xmalloc(numvariables*sizeof(char*));45 variables_descriptors=xNew<char*>(numvariables); 46 46 } 47 47 for(i=0;i<numvariables;i++){ … … 51 51 } 52 52 MPI_Bcast(&string_length,1,MPI_INT,0,MPI_COMM_WORLD); 53 if(my_rank!=0)string= (char*)xmalloc(string_length);53 if(my_rank!=0)string=xNew<char>(string_length); 54 54 MPI_Bcast(string,string_length,MPI_CHAR,0,MPI_COMM_WORLD); 55 55 if(my_rank!=0)variables_descriptors[i]=string; -
issm/trunk-jpl/src/c/modules/Dakotax/Dakotax.cpp
r12016 r12450 121 121 122 122 /*Free ressources:*/ 123 x free((void**)&dakota_input_file);124 x free((void**)&dakota_error_file);125 x free((void**)&dakota_output_file);123 xDelete<char>(dakota_input_file); 124 xDelete<char>(dakota_error_file); 125 xDelete<char>(dakota_output_file); 126 126 127 127 #endif //#ifdef _HAVE_DAKOTA_ -
issm/trunk-jpl/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp
r3913 r12450 36 36 maxels=width-1; 37 37 /*Allocate connectivity: */ 38 elementconnectivity= (double*)xcalloc(nel*3,sizeof(double));38 elementconnectivity=xNewZeroInit<double>(nel*3); 39 39 40 40 /*Go through all elements, and for each element, go through its nodes, to get the neighbouring elements. -
issm/trunk-jpl/src/c/modules/EnumToStringx/EnumToStringx.cpp
r12341 r12450 466 466 467 467 len=strlen(EnumToStringx(enum_in)); 468 string= (char*)xmalloc((len+1)*sizeof(char));468 string=xNew<char>(len+1); 469 469 memcpy(string,EnumToStringx(enum_in),(len+1)*sizeof(char)); 470 470 -
issm/trunk-jpl/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
r11695 r12450 32 32 33 33 /*Assign output pointers:*/ 34 x free((void**)&control_type);34 xDelete<int>(control_type); 35 35 *pvector=vector; 36 36 } -
issm/trunk-jpl/src/c/modules/Gradjx/Gradjx.cpp
r11695 r12450 14 14 int i,j,numberofvertices; 15 15 int num_controls; 16 double norm_inf;17 double *norm_list= NULL;18 int *control_type= NULL;19 Vector * gradient= NULL;20 Vector * *gradient_list= NULL;16 double norm_inf; 17 double *norm_list = NULL; 18 int *control_type = NULL; 19 Vector *gradient = NULL; 20 Vector **gradient_list = NULL; 21 21 22 22 /*retrieve some parameters: */ … … 26 26 27 27 /*Allocate gradient_list */ 28 gradient_list = (Vector**)xmalloc(num_controls*sizeof(Vector*));29 norm_list = (double*)xmalloc(num_controls*sizeof(double));28 gradient_list = xNew<Vector*>(num_controls); 29 norm_list = xNew<double>(num_controls); 30 30 for(i=0;i<num_controls;i++){ 31 31 gradient_list[i]=new Vector(num_controls*numberofvertices); … … 62 62 } 63 63 else{ 64 x free((void**)&norm_list);64 xDelete<double>(norm_list); 65 65 } 66 66 if(pgradient) *pgradient=gradient; 67 x free((void**)&gradient_list);68 x free((void**)&control_type);67 xDelete<Vector*>(gradient_list); 68 xDelete<int>(control_type); 69 69 } -
issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
r12365 r12450 49 49 /*free ressouces: */ 50 50 xdelete(&vec_old_floatingice); 51 x free((void**)&vertices_potentially_ungrounding);52 x free((void**)&vertices_ungrounding);53 x free((void**)&old_floatingice);51 xDelete<double>(vertices_potentially_ungrounding); 52 xDelete<double>(vertices_ungrounding); 53 xDelete<double>(old_floatingice); 54 54 } 55 55 … … 164 164 165 165 /*Avoid leaks: */ 166 x free((void**)&elements_neighboring_floatingce);167 x free((void**)&nodes_on_floatingice);166 xDelete<double>(elements_neighboring_floatingce); 167 xDelete<double>(nodes_on_floatingice); 168 168 169 169 /*Assemble and serialize:*/ … … 174 174 /*Free ressources:*/ 175 175 xdelete(&vec_nodes_on_floatingice); 176 x free((void**)&elements_neighboring_floatingce);176 xDelete<double>(elements_neighboring_floatingce); 177 177 178 178 return nodes_on_floatingice; -
issm/trunk-jpl/src/c/modules/HoleFillerx/HoleFillerx.cpp
r9313 r12450 43 43 44 44 /*^^^^^^^^^^^^^ Remove pixels close to the holes ^^^^^^^^^^^^^*/ 45 image2 = (double*) xmalloc( lines*samps*sizeof(double));45 image2 = xNew<double>(lines*samps); 46 46 memcpy(image2,image,lines*samps*sizeof(double)); 47 47 … … 64 64 } 65 65 66 image3 = (double*) xmalloc( lines*samps*sizeof(double));66 image3 = xNew<double>(lines*samps); 67 67 memcpy(image3,image2,lines*samps*sizeof(double)); 68 68 … … 304 304 /************************ SMOOTH THE RESULT ***********************/ 305 305 306 image4 = (double*) xmalloc( lines*samps*sizeof(double));306 image4 = xNew<double>(lines*samps); 307 307 memcpy(image4,image3,lines*samps*sizeof(double)); 308 308 … … 348 348 349 349 /*Allocate output image: */ 350 imageout= (double*)xmalloc(samps*lines*sizeof(double));350 imageout=xNew<double>(samps*lines); 351 351 memcpy(imageout,image3,lines*samps*sizeof(double)); 352 352 … … 363 363 /*Assign output pointers: */ 364 364 *pimageout=imageout; 365 366 365 return 1; 367 368 366 } -
issm/trunk-jpl/src/c/modules/InputConvergencex/InputConvergencex.cpp
r12102 r12450 12 12 13 13 /*intermediary:*/ 14 int 15 bool 16 int num_notconverged=0;17 int 18 double *eps= NULL;19 Element * element=NULL;14 int i; 15 bool converged; 16 int num_notconverged = 0; 17 int total_notconverged; 18 double *eps = NULL; 19 Element *element = NULL; 20 20 21 21 /*allocate dynamic memory: */ 22 eps= (double*)xmalloc(num_criterionenums*sizeof(double));22 eps=xNew<double>(num_criterionenums); 23 23 24 24 /*Go through elements, and ask them to do the job: */ … … 37 37 38 38 /*Free ressources:*/ 39 x free((void**)&eps);39 xDelete<double>(eps); 40 40 41 41 /*return: */ -
issm/trunk-jpl/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp
r10571 r12450 21 21 double *qmu_part = NULL; 22 22 23 double * distributed_values=NULL;24 double * parameter=NULL;25 char * descriptor=NULL;23 double *distributed_values = NULL; 24 double *parameter = NULL; 25 char *descriptor = NULL; 26 26 char root[50]; //root name of variable, ex: DragCoefficent, RhoIce, etc ... 27 27 … … 49 49 50 50 51 distributed_values= (double*)xmalloc(npart*sizeof(double));51 distributed_values=xNew<double>(npart); 52 52 for(j=0;j<npart;j++){ 53 53 distributed_values[j]=variables[i+j]; … … 91 91 92 92 /*Free allocations: */ 93 x free((void**)¶meter);94 x free((void**)&distributed_values);93 xDelete<double>(parameter); 94 xDelete<double>(distributed_values); 95 95 } 96 96 else if (strncmp(descriptor,"indexed_",8)==0){ … … 107 107 108 108 /*Free ressources:*/ 109 xfree((void**)&qmu_part); 110 109 xDelete<double>(qmu_part); 111 110 } -
issm/trunk-jpl/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp
r11679 r12450 20 20 21 21 /*Free ressources:*/ 22 xfree((void**)&serial_solution); 23 22 xDelete<double>(serial_solution); 24 23 } 25 24 … … 36 35 element->InputUpdateFromSolution(solution); 37 36 } 38 39 37 } -
issm/trunk-jpl/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp
r11695 r12450 18 18 19 19 /*Free ressources:*/ 20 x free((void**)&serial_vector);20 xDelete<double>(serial_vector); 21 21 } 22 22 -
issm/trunk-jpl/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp
r11695 r12450 18 18 19 19 /*Free ressources:*/ 20 x free((void**)&serial_vector);20 xDelete<double>(serial_vector); 21 21 } 22 22 -
issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp
r12365 r12450 52 52 53 53 /*The coordinates given in input describe the contour of each pixel. Take the center of each pixel*/ 54 x= (double*)xmalloc(N*sizeof(double));55 y= (double*)xmalloc(M*sizeof(double));54 x=xNew<double>(N); 55 y=xNew<double>(M); 56 56 for (i=0;i<N;i++) x[i]=(x_in[i]+x_in[i+1])/2; 57 57 for (i=0;i<M;i++) y[i]=(y_in[i]+y_in[i+1])/2; … … 62 62 63 63 /*The coordinates given in input describe the center each pixel. Keep them*/ 64 x= (double*)xmalloc(N*sizeof(double));65 y= (double*)xmalloc(M*sizeof(double));64 x=xNew<double>(N); 65 y=xNew<double>(M); 66 66 for (i=0;i<N;i++) x[i]=x_in[i]; 67 67 for (i=0;i<M;i++) y[i]=y_in[i]; -
issm/trunk-jpl/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp
r11918 r12450 45 45 46 46 /*First, allocate pointers: */ 47 griddata= (double*)xcalloc(nlines*ncols,sizeof(double));48 x_grid= (double*)xcalloc(ncols,sizeof(double));49 y_grid= (double*)xcalloc(nlines,sizeof(double));47 griddata=xNewZeroInit<double>(nlines*ncols); 48 x_grid=xNewZeroInit<double>(ncols); 49 y_grid=xNewZeroInit<double>(nlines); 50 50 51 51 /*Set debug to 1 if there are lots of elements*/ -
issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
r12121 r12450 55 55 /*Initialize output*/ 56 56 if (verbose) printf("Initializing output vector\n"); 57 data_interp= (double*)xmalloc(nods_interp*data_cols*sizeof(double));57 data_interp=xNew<double>(nods_interp*data_cols); 58 58 59 59 // read background mesh -
issm/trunk-jpl/src/c/modules/KMLFileReadx/KMLFileReadx.cpp
r11295 r12450 44 44 45 45 // _printf_(true,"%s\n",kstr); 46 x free((void**)&kstr);46 xDelete<char>(kstr); 47 47 } 48 48 -
issm/trunk-jpl/src/c/modules/KMLMeshWritex/KMLMeshWritex.cpp
r12446 r12450 184 184 cmap,mcmap,ncmap)); 185 185 186 if(edfree) x free((void**)&edata);187 if(ncfree) x free((void**)&nodecon);186 if(edfree) xDelete<double>(edata); 187 if(ncfree) xDelete<int>(nodecon); 188 188 clock0a=clock(); 189 189 time0a =time(NULL); -
issm/trunk-jpl/src/c/modules/Krigingx/Krigingx.cpp
r12422 r12450 44 44 45 45 /*Allocate output*/ 46 predictions = (double*)xcalloc(n_interp,sizeof(double));47 error = (double*)xcalloc(n_interp,sizeof(double));46 predictions =xNewZeroInit<double>(n_interp); 47 error =xNewZeroInit<double>(n_interp); 48 48 49 49 /*Get output*/ … … 68 68 printf("Generation Delaunay Triangulation\n"); 69 69 BamgTriangulatex(&index,&nel,x,y,nobs); 70 indexd = (double*)xcalloc(nel*3,sizeof(double));70 indexd =xNewZeroInit<double>(nel*3); 71 71 for(int i=0;i<nel*3;i++) indexd[i]=(double)index[i]; 72 x free((void**)&index);72 xDelete<int>(index); 73 73 74 74 printf("Interpolating\n"); 75 x free((void**)&predictions);75 xDelete<double>(predictions); 76 76 InterpFromMeshToMesh2dx(&predictions,indexd,x,y,nobs,nel,data,nobs,1,x_interp,y_interp,n_interp,NULL,0,new DataSet()); 77 x free((void**)&x);78 x free((void**)&y);79 x free((void**)&index);80 x free((void**)&data);77 xDelete<double>(x); 78 xDelete<double>(y); 79 xDelete<double>(data); 80 xDelete<int>(index); 81 81 } 82 82 else if(strcmp(output,"nearestneighbor")==0){ … … 92 92 gate.predictions = predictions; 93 93 gate.error = error; 94 gate.percent = (double*)xcalloc(num,sizeof(double));94 gate.percent = xNewZeroInit<double>(num); 95 95 96 96 /*launch the thread manager with Krigingxt as a core: */ 97 97 LaunchThread(NearestNeighbort,(void*)&gate,num); 98 98 printf("\r interpolation progress: 100.00%%\n"); 99 x free((void**)&gate.percent);99 xDelete<double>(gate.percent); 100 100 } 101 101 else if(strcmp(output,"idw")==0){ //Inverse distance weighting … … 111 111 gate.predictions = predictions; 112 112 gate.error = error; 113 gate.percent = (double*)xcalloc(num,sizeof(double));113 gate.percent = xNewZeroInit<double>(num); 114 114 115 115 /*launch the thread manager with Krigingxt as a core: */ 116 116 LaunchThread(idwt,(void*)&gate,num); 117 117 printf("\r interpolation progress: 100.00%%\n"); 118 x free((void**)&gate.percent);118 xDelete<double>(gate.percent); 119 119 } 120 120 else if(strcmp(output,"prediction")==0){ … … 131 131 gate.predictions = predictions; 132 132 gate.error = error; 133 gate.percent = (double*)xcalloc(num,sizeof(double));133 gate.percent = xNewZeroInit<double>(num); 134 134 135 135 /*launch the thread manager with Krigingxt as a core: */ 136 136 LaunchThread(Krigingxt,(void*)&gate,num); 137 137 printf("\r interpolation progress: 100.00%%\n"); 138 x free((void**)&gate.percent);138 xDelete<double>(gate.percent); 139 139 } 140 140 else{ … … 145 145 delete variogram; 146 146 delete observations; 147 x free((void**)&output);147 xDelete<char>(output); 148 148 *ppredictions = predictions; 149 149 *perror = error; … … 311 311 312 312 /*Assign output pointer*/ 313 x free((void**)&model);313 xDelete<char>(model); 314 314 *pvariogram = variogram; 315 315 }/*}}}*/ -
issm/trunk-jpl/src/c/modules/MassFluxx/MassFluxx.cpp
r12102 r12450 67 67 for(j=0;j<M;j++){ 68 68 double* matrix=array[j]; 69 x free((void**)&matrix);69 xDelete<double>(matrix); 70 70 } 71 x free((void**)&mdims_array);72 x free((void**)&ndims_array);73 x free((void**)&array);71 xDelete<int>(mdims_array); 72 xDelete<int>(ndims_array); 73 xDelete<double*>(array); 74 74 75 75 /*Assign output pointers: */ -
issm/trunk-jpl/src/c/modules/MeshPartitionx/MeshPartitionx.cpp
r12102 r12450 31 31 32 32 if(dim==2){ 33 epart= (int*)xmalloc(numberofelements*sizeof(int));34 npart= (int*)xmalloc(numberofnodes*sizeof(int));35 index= (int*)xmalloc(elements_width*numberofelements*sizeof(int));33 epart=xNew<int>(numberofelements); 34 npart=xNew<int>(numberofnodes); 35 index=xNew<int>(elements_width*numberofelements); 36 36 for (i=0;i<numberofelements;i++){ 37 37 for (j=0;j<elements_width;j++){ … … 57 57 58 58 /*First build concatenated 2d mesh from 2d_coll and 2d_noncoll: */ 59 epart2d= (int*)xmalloc(numberofelements2d*sizeof(int));60 npart2d= (int*)xmalloc(numberofnodes2d*sizeof(int));61 index2d= (int*)xmalloc(3*numberofelements2d*sizeof(int));59 epart2d=xNew<int>(numberofelements2d); 60 npart2d=xNew<int>(numberofnodes2d); 61 index2d=xNew<int>(3*numberofelements2d); 62 62 63 63 for (i=0;i<numberofelements2d;i++){ … … 81 81 82 82 /*Extrude epart2d to epart, using numlayers: */ 83 epart= (int*)xmalloc(numberofelements*sizeof(int));83 epart=xNew<int>(numberofelements); 84 84 85 85 count=0; … … 92 92 93 93 /*Extrude npart2d to npart, using numlayers: */ 94 npart= (int*)xmalloc(numberofnodes*sizeof(int));94 npart=xNew<int>(numberofnodes); 95 95 96 96 count=0; … … 108 108 109 109 /*Free ressources: */ 110 xfree((void**)&index); 111 xfree((void**)&epart2d); 112 xfree((void**)&npart2d); 113 xfree((void**)&index2d); 114 110 xDelete<int>(index); 111 xDelete<int>(epart2d); 112 xDelete<int>(npart2d); 113 xDelete<int>(index2d); 115 114 return noerr; 116 117 115 } -
issm/trunk-jpl/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp
r8303 r12450 5 5 6 6 void MeshProfileIntersectionx( double** psegments, int* pnumsegs, int* index, double* x, double* y, int nel, int nods, Contour** contours,int numcontours){ 7 8 7 9 8 int i,j,k; … … 28 27 29 28 /*Allocate: */ 30 allsegments= (double**)xmalloc(numcontours*sizeof(double*));31 allnumsegs= (int*)xmalloc(numcontours*sizeof(int));29 allsegments=xNew<double*>(numcontours); 30 allnumsegs=xNew<int>(numcontours); 32 31 33 32 /*Loop through all contours: */ … … 53 52 54 53 /*Out of all segments, create one common array of segments: */ 55 segments= (double*)xmalloc(5*numsegs*sizeof(double));54 segments=xNew<double>(5*numsegs); 56 55 count=0; 57 56 for(i=0;i<numcontours;i++){ -
issm/trunk-jpl/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp
r8303 r12450 32 32 /*Using the segments_dataset dataset, create segments: */ 33 33 numsegs=segments_dataset->Size(); 34 segments= (double*)xmalloc(5*numsegs*sizeof(double));34 segments=xNew<double>(5*numsegs); 35 35 for(i=0;i<numsegs;i++){ 36 36 Segment* segment=(Segment*)segments_dataset->GetObjectByOffset(i); -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
r11447 r12450 63 63 parameters->AddObject(new DoubleVecParam(InversionMaxiterPerStepEnum,maxiter,nsteps)); 64 64 65 x free((void**)&control_type);66 x free((void**)&cm_responses);67 x free((void**)&cm_jump);68 x free((void**)&optscal);69 x free((void**)&maxiter);65 xDelete<int>(control_type); 66 xDelete<double>(cm_responses); 67 xDelete<double>(cm_jump); 68 xDelete<double>(optscal); 69 xDelete<double>(maxiter); 70 70 } 71 71 -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateNumberNodeToElementConnectivity.cpp
r11001 r12450 43 43 44 44 /*Allocate ouput*/ 45 connectivity= (int*)xcalloc(numberofvertices,sizeof(int));45 connectivity=xNewZeroInit<int>(numberofvertices); 46 46 47 47 /*Get element width (3 or 6)*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp
r12326 r12450 105 105 parameters->AddObject(new IntParam(DiagnosticNumRequestedOutputsEnum,numoutputs)); 106 106 if(numoutputs)parameters->AddObject(new IntVecParam(DiagnosticRequestedOutputsEnum,requestedoutputs,numoutputs)); 107 x free((void**)&requestedoutputs);107 xDelete<double>(requestedoutputs); 108 108 iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,TransientRequestedOutputsEnum); 109 109 parameters->AddObject(new IntParam(TransientNumRequestedOutputsEnum,numoutputs)); 110 110 if(numoutputs)parameters->AddObject(new IntVecParam(TransientRequestedOutputsEnum,requestedoutputs,numoutputs)); 111 x free((void**)&requestedoutputs);111 xDelete<double>(requestedoutputs); 112 112 iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,SteadystateRequestedOutputsEnum); 113 113 parameters->AddObject(new IntParam(SteadystateNumRequestedOutputsEnum,numoutputs)); 114 114 if(numoutputs)parameters->AddObject(new IntVecParam(SteadystateRequestedOutputsEnum,requestedoutputs,numoutputs)); 115 x free((void**)&requestedoutputs);115 xDelete<double>(requestedoutputs); 116 116 117 117 /*Before returning, create parameters in case we are running Qmu or control types runs: */ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateSingleNodeToElementConnectivity.cpp
r9733 r12450 44 44 45 45 /*Allocate ouput*/ 46 connectivity= (int*)xcalloc(numberofvertices,sizeof(int));46 connectivity=xNewZeroInit<int>(numberofvertices); 47 47 48 48 /*Get element width (3 or 6)*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp
r12365 r12450 74 74 75 75 /*name of qmu input, error and output files:{{{*/ 76 qmuinname= (char*)xmalloc((strlen(name)+strlen(".qmu.in")+1)*sizeof(char));76 qmuinname=xNew<char>((strlen(name)+strlen(".qmu.in")+1)); 77 77 sprintf(qmuinname,"%s%s",name,".qmu.in"); 78 78 parameters->AddObject(new StringParam(QmuInNameEnum,qmuinname)); 79 79 80 qmuoutname= (char*)xmalloc((strlen(name)+strlen(".qmu.out")+1)*sizeof(char));80 qmuoutname=xNew<char>((strlen(name)+strlen(".qmu.out")+1)); 81 81 sprintf(qmuoutname,"%s%s",name,".qmu.out"); 82 82 parameters->AddObject(new StringParam(QmuOutNameEnum,qmuoutname)); 83 83 84 qmuerrname= (char*)xmalloc((strlen(name)+strlen(".qmu.err")+1)*sizeof(char));84 qmuerrname=xNew<char>((strlen(name)+strlen(".qmu.err")+1)); 85 85 sprintf(qmuerrname,"%s%s",name,".qmu.err"); 86 86 parameters->AddObject(new StringParam(QmuErrNameEnum,qmuerrname)); … … 111 111 ElementsAndVerticesPartitioning(&iomodel->my_elements,&iomodel->my_vertices,iomodel); 112 112 113 dpart= (double*)xmalloc(numberofvertices*sizeof(double));113 dpart=xNew<double>(numberofvertices); 114 114 for(i=0;i<numberofvertices;i++)dpart[i]=iomodel->my_vertices[i]; 115 115 } … … 136 136 137 137 /*Free ressources:*/ 138 x free((void**)&dakota_parameter);138 xDelete<int>(dakota_parameter); 139 139 } 140 140 } … … 166 166 } 167 167 if(m){ 168 matrix= (double*)xcalloc(5*m,sizeof(double));168 matrix=xNewZeroInit<double>(5*m); 169 169 count=0; 170 170 for(j=0;j<temp_m;j++){ … … 185 185 186 186 /*Free temporary matrix: */ 187 x free((void**)&temp_matrix);187 xDelete<double>(temp_matrix); 188 188 } 189 189 … … 194 194 for(i=0;i<qmu_mass_flux_num_profiles;i++){ 195 195 double* matrix=array[i]; 196 x free((void**)&matrix);197 } 198 x free((void**)&mdims_array);199 x free((void**)&ndims_array);200 x free((void**)&array);196 xDelete<double>(matrix); 197 } 198 xDelete<int>(mdims_array); 199 xDelete<int>(ndims_array); 200 xDelete<double*>(array); 201 201 } 202 202 /*}}}*/ … … 204 204 for(i=0;i<numresponsedescriptors;i++){ 205 205 descriptor=responsedescriptors[i]; 206 x free((void**)&descriptor);207 } 208 x free((void**)&responsedescriptors);206 xDelete<char>(descriptor); 207 } 208 xDelete<char*>(responsedescriptors); 209 209 210 210 for(i=0;i<numvariabledescriptors;i++){ 211 211 descriptor=variabledescriptors[i]; 212 x free((void**)&descriptor);213 } 214 x free((void**)&variabledescriptors);215 x free((void**)&part);216 x free((void**)&dpart);217 x free((void**)&qmuinname);218 x free((void**)&qmuerrname);219 x free((void**)&qmuoutname);212 xDelete<char>(descriptor); 213 } 214 xDelete<char*>(variabledescriptors); 215 xDelete<int>(part); 216 xDelete<int>(dpart); 217 xDelete<char>(qmuinname); 218 xDelete<char>(qmuerrname); 219 xDelete<char>(qmuoutname); 220 220 /*}}}*/ 221 221 } //if(dakota_analysis) 222 222 223 223 /*Free data*/ 224 x free((void**)&name);224 xDelete<char>(name); 225 225 226 226 /*Assign output pointer: */ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
r10544 r12450 87 87 88 88 /*figure out times: */ 89 timesx= (double*)xmalloc(Nx*sizeof(double));89 timesx=xNew<double>(Nx); 90 90 for(j=0;j<Nx;j++){ 91 91 timesx[j]=spcvx[(Mx-1)*Nx+j]; … … 94 94 UnitConversion(timesx,Nx,ExtToIuEnum,TimeEnum); 95 95 /*figure out times: */ 96 timesy= (double*)xmalloc(Ny*sizeof(double));96 timesy=xNew<double>(Ny); 97 97 for(j=0;j<Ny;j++){ 98 98 timesy[j]=spcvy[(My-1)*Ny+j]; … … 101 101 UnitConversion(timesy,Ny,ExtToIuEnum,TimeEnum); 102 102 /*figure out times: */ 103 timesz= (double*)xmalloc(Nz*sizeof(double));103 timesz=xNew<double>(Nz); 104 104 for(j=0;j<Nz;j++){ 105 105 timesz[j]=spcvz[(Mz-1)*Nz+j]; … … 107 107 /*unit conversion: */ 108 108 UnitConversion(timesz,Nz,ExtToIuEnum,TimeEnum); 109 110 109 111 110 /*Create spcs from x,y,z, as well as the spc values on those spcs: */ … … 236 235 else if (Mx==numberofvertices+1) { 237 236 /*figure out times and values: */ 238 values= (double*)xmalloc(Nx*sizeof(double));237 values=xNew<double>(Nx); 239 238 spcpresent=false; 240 239 for(j=0;j<Nx;j++){ … … 247 246 count++; 248 247 } 249 x free((void**)&values);248 xDelete<double>(values); 250 249 } 251 250 else if (vertices_type[i]==HutterApproximationEnum){ … … 260 259 else if (My==numberofvertices+1){ 261 260 /*figure out times and values: */ 262 values= (double*)xmalloc(Ny*sizeof(double));261 values=xNew<double>(Ny); 263 262 spcpresent=false; 264 263 for(j=0;j<Ny;j++){ … … 270 269 count++; 271 270 } 272 x free((void**)&values);271 xDelete<double>(values); 273 272 } 274 273 else if (vertices_type[i]==HutterApproximationEnum){ … … 284 283 else if (Mz==numberofvertices+1){ 285 284 /*figure out times and values: */ 286 values= (double*)xmalloc(Nz*sizeof(double));285 values=xNew<double>(Nz); 287 286 spcpresent=false; 288 287 for(j=0;j<Nz;j++){ … … 294 293 count++; 295 294 } 296 x free((void**)&values);295 xDelete<double>(values); 297 296 } 298 297 … … 326 325 327 326 /*Free data: */ 328 x free((void**)&spcvx);329 x free((void**)&spcvy);330 x free((void**)&spcvz);331 x free((void**)&nodeonmacayeal);332 x free((void**)&nodeonpattyn);333 x free((void**)&nodeonstokes);334 x free((void**)&nodeonicesheet);335 x free((void**)&nodeonbed);336 x free((void**)&vertices_type);337 x free((void**)&surface);338 x free((void**)&z);327 xDelete<double>(spcvx); 328 xDelete<double>(spcvy); 329 xDelete<double>(spcvz); 330 xDelete<double>(nodeonmacayeal); 331 xDelete<double>(nodeonpattyn); 332 xDelete<double>(nodeonstokes); 333 xDelete<double>(nodeonicesheet); 334 xDelete<double>(nodeonbed); 335 xDelete<double>(vertices_type); 336 xDelete<double>(surface); 337 xDelete<double>(z); 339 338 340 339 /*Free resources:*/ 341 x free((void**)×x);342 x free((void**)×y);343 x free((void**)×z);344 x free((void**)&values);340 xDelete<double>(timesx); 341 xDelete<double>(timesy); 342 xDelete<double>(timesz); 343 xDelete<double>(values); 345 344 346 345 /*Assign output pointer: */ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp
r10522 r12450 120 120 /*Free data: */ 121 121 iomodel->DeleteData(3,DiagnosticIcefrontEnum,ThicknessEnum,BedEnum); 122 x free((void**)&elements_type);123 x free((void**)&pressureload);122 xDelete<double>(elements_type); 123 xDelete<double>(pressureload); 124 124 125 125 /*Create Penpair for penalties: */ … … 144 144 145 145 /*free ressources: */ 146 x free((void**)&penalties);146 xDelete<double>(penalties); 147 147 148 148 /*Create Riffront loads for rifts: */ … … 157 157 } 158 158 iomodel->DeleteData(5,RiftsRiftstructEnum,ThicknessEnum,BedEnum,SurfaceEnum,MaskVertexonfloatingiceEnum); 159 x free((void**)&riftfront);159 xDelete<Riftfront>(riftfront); 160 160 } 161 161 -
issm/trunk-jpl/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp
r9218 r12450 35 35 else if (vertices_type[0]==MacAyealPattynApproximationEnum){ 36 36 numdofs=4; 37 doftype= (int*)xmalloc(numdofs*sizeof(int));37 doftype=xNew<int>(numdofs); 38 38 doftype[0]=MacAyealApproximationEnum; 39 39 doftype[1]=MacAyealApproximationEnum; … … 43 43 else if (vertices_type[0]==PattynStokesApproximationEnum){ 44 44 numdofs=6; 45 doftype= (int*)xmalloc(numdofs*sizeof(int));45 doftype=xNew<int>(numdofs); 46 46 doftype[0]=PattynApproximationEnum; 47 47 doftype[1]=PattynApproximationEnum; … … 53 53 else if (vertices_type[0]==MacAyealStokesApproximationEnum){ 54 54 numdofs=6; 55 doftype= (int*)xmalloc(numdofs*sizeof(int));55 doftype=xNew<int>(numdofs); 56 56 doftype[0]=MacAyealApproximationEnum; 57 57 doftype[1]=MacAyealApproximationEnum; … … 96 96 97 97 /*Clean up*/ 98 x free((void**)&doftype);98 xDelete<int>(doftype); 99 99 } -
issm/trunk-jpl/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
r12016 r12450 76 76 77 77 /*Free elements and elements2d: */ 78 x free((void**)&elements);79 x free((void**)&elements2d);78 xDelete<double>(elements); 79 xDelete<double>(elements2d); 80 80 81 81 /*Deal with rifts, they have to be included into one partition only, not several: */ … … 87 87 epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices; 88 88 } 89 x free((void**)&riftinfo);89 xDelete<double>(riftinfo); 90 90 } 91 91 92 92 /*Used later on: */ 93 my_vertices= (int*)xcalloc(numberofvertices,sizeof(int));94 my_elements= (bool*)xcalloc(numberofelements,sizeof(bool));93 my_vertices=xNewZeroInit<int>(numberofvertices); 94 my_elements=xNewZeroInit<bool>(numberofelements); 95 95 96 96 /*Start figuring out, out of the partition, which elements belong to this cpu: */ … … 119 119 }//for (i=0;i<numberofelements;i++) 120 120 /*Free data : */ 121 x free((void**)&elements);121 xDelete<double>(elements); 122 122 123 123 /*We might have vertex_pairing in which case, some vertices have to be cloned: … … 130 130 } 131 131 } 132 x free((void**)&vertex_pairing);132 xDelete<double>(vertex_pairing); 133 133 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,PrognosticVertexPairingEnum); 134 134 for(i=0;i<numvertex_pairing;i++){ … … 137 137 } 138 138 } 139 x free((void**)&vertex_pairing);139 xDelete<double>(vertex_pairing); 140 140 141 141 /*Free ressources:*/ 142 x free((void**)&npart);143 x free((void**)&epart);142 xDelete<int>(npart); 143 xDelete<int>(epart); 144 144 145 145 /*Assign output pointers:*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp
r11270 r12450 65 65 66 66 /*Free data: */ 67 x free((void**)&spctemperature);67 xDelete<double>(spctemperature); 68 68 69 69 /*Assign output pointer: */ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/NodesPartitioning.cpp
r9733 r12450 24 24 25 25 /*First thing, this is a new partition for a new analysis_type, therefore, to avoid a leak, erase the nodes partition that might come through pmy_nodes: */ 26 x free((void**)pmy_nodes);26 xDelete<bool>(*pmy_nodes); 27 27 28 28 /*Now, depending on whether we are running galerkin discontinous or continuous elements, carry out a different partition of the nodes: */ … … 44 44 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); 45 45 46 my_nodes= (bool*)xmalloc(numberofvertices*sizeof(bool));47 memcpy(my_nodes,my_vertices,numberofvertices*sizeof(bool));46 my_nodes=xNew<bool>(numberofvertices); 47 for(int i=0;i<numberofvertices;i++) my_nodes[i]=(bool)my_vertices[i]; 48 48 49 49 /*Assign output pointers:*/ … … 90 90 91 91 /*Allocate*/ 92 my_nodes= (bool*)xcalloc(3*numberofelements,sizeof(int));92 my_nodes=xNewZeroInit<bool>(3*numberofelements); 93 93 94 94 /*First: add all the nodes of all the elements belonging to this cpu*/ … … 96 96 for (i=0;i<numberofelements;i++){ 97 97 if (my_elements[i]){ 98 my_nodes[3*i+0]= 1;99 my_nodes[3*i+1]= 1;100 my_nodes[3*i+2]= 1;98 my_nodes[3*i+0]=true; 99 my_nodes[3*i+1]=true; 100 my_nodes[3*i+2]=true; 101 101 } 102 102 } … … 140 140 * we can now create the corresponding nodes:*/ 141 141 if (pos==0){ 142 my_nodes[(int)e2*3+0]= 1;143 my_nodes[(int)e2*3+2]= 1;142 my_nodes[(int)e2*3+0]=true; 143 my_nodes[(int)e2*3+2]=true; 144 144 } 145 145 else if(pos==1){ 146 my_nodes[(int)e2*3+1]= 1;147 my_nodes[(int)e2*3+0]= 1;146 my_nodes[(int)e2*3+1]=true; 147 my_nodes[(int)e2*3+0]=true; 148 148 } 149 149 else if (pos==2){ 150 my_nodes[(int)e2*3+2]= 1;151 my_nodes[(int)e2*3+1]= 1;150 my_nodes[(int)e2*3+2]=true; 151 my_nodes[(int)e2*3+1]=true; 152 152 } 153 153 else{ … … 158 158 159 159 /*Free data: */ 160 x free((void**)&elements);161 x free((void**)&edges);160 xDelete<double>(elements); 161 xDelete<double>(edges); 162 162 163 163 /*Assign output pointers:*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
r10522 r12450 90 90 91 91 /*free ressources: */ 92 xfree((void**)&vertex_pairing); 93 xfree((void**)&nodeonbed); 94 92 xDelete<double>(vertex_pairing); 93 xDelete<double>(nodeonbed); 95 94 96 95 /*Assign output pointer: */ -
issm/trunk-jpl/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp
r6412 r12450 37 37 38 38 /*Allocate connectivity: */ 39 connectivity= (double*)xcalloc(nods*width,sizeof(double));39 connectivity=xNewZeroInit<double>(nods*width); 40 40 41 41 /*Go through all elements, and for each elements, plug into the connectivity, all the nodes. -
issm/trunk-jpl/src/c/modules/OutputResultsx/OutputResultsx.cpp
r12377 r12450 46 46 EnumToStringx(&solutiontypestring,solutiontype); 47 47 results->AddObject(new StringExternalResult(results->Size()+1,SolutionTypeEnum,solutiontypestring,1,0)); 48 x free((void**)&solutiontypestring);48 xDelete<char>(solutiontypestring); 49 49 } 50 50 … … 68 68 fid=pfopen(cpu_outputfilename ,"wb"); 69 69 } 70 x free((void**)&outputfilename);70 xDelete<char>(outputfilename); 71 71 72 72 /*Add file pointer in parameters for further calls to OutputResultsx: */ -
issm/trunk-jpl/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp
r12319 r12450 48 48 49 49 /*Now, allocate analyses and strings: */ 50 analyses= (double*)xmalloc(numanalyses*sizeof(double));51 strings= (char**)xmalloc(numanalyses*sizeof(char*));50 analyses=xNew<double>(numanalyses); 51 strings=xNew<char*>(numanalyses); 52 52 for(i=0;i<numanalyses;i++)strings[i]=NULL; 53 53 … … 70 70 to the already existing options*/ 71 71 if(strings[numanalyses-1]==NULL){ 72 string= (char*)xmalloc((strlen(line)+1)*sizeof(char));72 string=xNew<char>((strlen(line)+1)); 73 73 memcpy(string,line,(strlen(line)+1)*sizeof(char)); 74 74 … … 77 77 else{ 78 78 string=strings[numanalyses-1]; 79 newstring= (char*)xmalloc((strlen(line)+1)*sizeof(char));79 newstring=xNew<char>((strlen(line)+1)); 80 80 memcpy(newstring,line,(strlen(line)+1)*sizeof(char)); 81 81 82 82 /*concatenate:*/ 83 catstring= (char*)xmalloc((strlen(string)+1+strlen(newstring)+1+1)*sizeof(char)); //fit in a space " "83 catstring=xNew<char>(strlen(string)+1+strlen(newstring)+1+1); //fit in a space " " 84 84 memcpy(catstring,string,(strlen(string)+1)*sizeof(char)); 85 85 … … 87 87 strcat(catstring,newstring); 88 88 strings[numanalyses-1]=catstring; 89 x free((void**)&newstring);90 x free((void**)&string);89 xDelete<char>(newstring); 90 xDelete<char>(string); 91 91 } 92 92 } … … 98 98 MPI_Bcast(&numanalyses,1,MPI_INT,0,MPI_COMM_WORLD); 99 99 if(my_rank!=0){ 100 analyses= (double*)xmalloc(numanalyses*sizeof(double));101 strings= (char**)xmalloc(numanalyses*sizeof(char*));100 analyses=xNew<double>(numanalyses); 101 strings=xNew<char*>(numanalyses); 102 102 } 103 103 MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0,MPI_COMM_WORLD); … … 111 111 #ifdef _HAVE_MPI_ 112 112 MPI_Bcast(&stringlength,1,MPI_INT,0,MPI_COMM_WORLD); 113 if(my_rank!=0)string= (char*)xmalloc(stringlength);113 if(my_rank!=0)string=xNew<char>(stringlength); 114 114 MPI_Bcast(string,stringlength,MPI_CHAR,0,MPI_COMM_WORLD); 115 115 if(my_rank!=0)strings[i]=string; … … 122 122 123 123 /*Clean up and return*/ 124 for(i=0;i<numanalyses;i++) x free((void**)&strings[i]);125 x free((void**)&strings);126 x free((void**)&analyses);124 for(i=0;i<numanalyses;i++) xDelete<char>(strings[i]); 125 xDelete<char*>(strings); 126 xDelete<double>(analyses); 127 127 return; 128 128 } 129 -
issm/trunk-jpl/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp
r11695 r12450 39 39 40 40 /*allocate: */ 41 already= (bool*)xcalloc(nods,sizeof(bool));41 already=xNewZeroInit<bool>(nods); 42 42 43 43 /*partition loop across threads: */ … … 73 73 74 74 /*Free ressources:*/ 75 x free((void**)&already);75 xDelete<bool>(already); 76 76 77 77 return NULL; -
issm/trunk-jpl/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp
r12326 r12450 40 40 Element* element = NULL; 41 41 42 pdds= (double*)xmalloc(NPDMAX*sizeof(double)+1);43 pds= (double*)xmalloc(NPDCMAX*sizeof(double)+1);42 pdds=xNew<double>(NPDMAX+1); 43 pds=xNew<double>(NPDCMAX+1); 44 44 45 45 // initialize PDD (creation of a lookup table) … … 106 106 } 107 107 /*free ressouces: */ 108 x free((void**)&pdds);109 x free((void**)&pds);108 xDelete<double>(pdds); 109 xDelete<double>(pds); 110 110 111 111 } -
issm/trunk-jpl/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp
r11679 r12450 51 51 52 52 /*Free ressources:*/ 53 x free((void**)&ug_serial);53 xDelete<double>(ug_serial); 54 54 55 55 /*Assign output pointers:*/ -
issm/trunk-jpl/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp
r11679 r12450 51 51 52 52 /*Free ressources:*/ 53 x free((void**)&yg_serial);53 xDelete<double>(yg_serial); 54 54 55 55 /*Assign output pointers:*/ -
issm/trunk-jpl/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
r11695 r12450 25 25 } 26 26 27 x free((void**)&control_type);27 xDelete<int>(control_type); 28 28 } 29 29 … … 37 37 38 38 /*Free ressources:*/ 39 x free((void**)&serial_vector);39 xDelete<double>(serial_vector); 40 40 } -
issm/trunk-jpl/src/c/modules/Solverx/DofTypesToIndexSet.cpp
r9826 r12450 46 46 47 47 /*Allocate indices: */ 48 if(pressure_num)pressure_indices= (int*)xmalloc(pressure_num*sizeof(int));49 if(velocity_num)velocity_indices= (int*)xmalloc(velocity_num*sizeof(int));48 if(pressure_num)pressure_indices=xNew<int>(pressure_num); 49 if(velocity_num)velocity_indices=xNew<int>(velocity_num); 50 50 51 51 pressure_count=0; … … 74 74 75 75 /*Free ressources:*/ 76 x free((void**)&pressure_indices);77 x free((void**)&velocity_indices);76 xDelete<int>(pressure_indices); 77 xDelete<int>(velocity_indices); 78 78 79 79 /*Assign output pointers:*/ -
issm/trunk-jpl/src/c/modules/Solverx/SolverxGsl.cpp
r12445 r12450 18 18 void SolverxGsl(SeqVec** puf,SeqMat* Kff, SeqVec* pf){/*{{{*/ 19 19 20 /*Intermediaries*/21 SeqMat* KffCopy = NULL;22 SeqVec* uf = NULL;23 24 /*GSL Matrices and vectors: */25 gsl_matrix_view m;26 gsl_vector_view b;27 gsl_vector* x=NULL;28 gsl_permutation* p=NULL;29 30 /*We are going to do an in place LU decomp, so we need to save the matrix with its original structure: */31 KffCopy=Kff->Duplicate();32 33 20 /*Intermediary: */ 34 21 int M,N,N2,s; 22 SeqVec *uf = NULL; 23 double *x = NULL; 35 24 36 25 Kff->GetSize(&M,&N); … … 40 29 if(M!=N)_error_("Stiffness matrix should be square!"); 41 30 42 /*Initialize gsl matrices and vectors: */ 43 m = gsl_matrix_view_array (KffCopy->matrix, M, N); 44 b = gsl_vector_view_array (pf->vector, N); 45 x = gsl_vector_alloc (N); 46 47 /*Run LU and solve: */ 48 p = gsl_permutation_alloc (N); 49 gsl_linalg_LU_decomp (&m.matrix, p, &s); 50 gsl_linalg_LU_solve (&m.matrix, p, &b.vector, x); 51 52 //printf ("x = \n"); 53 //gsl_vector_fprintf (stdout, x, "%g"); 54 55 /*Get uf initialized with the results: */ 56 uf=new SeqVec(gsl_vector_ptr(x,0),M); 57 58 /*Free resources:*/ 59 gsl_permutation_free (p); 60 gsl_vector_free (x); 61 delete KffCopy; 31 SolverxGsl(&x,Kff->matrix,pf->vector,N); 32 uf=new SeqVec(x,N); 62 33 63 34 /*Assign output pointers:*/ … … 74 45 75 46 /*A will be modified by LU decomposition. Use copy*/ 76 double* Acopy = (double*)xmalloc(n*n*sizeof(double));47 double* Acopy = xNew<double>(n*n); 77 48 memcpy(Acopy,A,n*n*sizeof(double)); 78 49 … … 91 62 92 63 /*Copy result*/ 93 double* X = (double*)xmalloc(n*sizeof(double));64 double* X = xNew<double>(n); 94 65 memcpy(X,gsl_vector_ptr(x,0),n*sizeof(double)); 95 66 96 67 /*Clean up and assign output pointer*/ 97 x free((void**)&Acopy);68 xDelete<double>(Acopy); 98 69 gsl_permutation_free(p); 99 70 gsl_vector_free(x); -
issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.cpp
r12442 r12450 98 98 99 99 in.segmentlist = xNew<int>(in.numberofsegments*2); 100 in.segmentmarkerlist = (int*)xcalloc(in.numberofsegments,sizeof(int));100 in.segmentmarkerlist = xNewZeroInit<int>(in.numberofsegments); 101 101 counter=0; 102 102 backcounter=0; -
issm/trunk-jpl/src/c/modules/TriaSearchx/TriaSearchx.cpp
r8303 r12450 19 19 20 20 /*allocate: */ 21 tria= (double*)xmalloc(numberofnodes*sizeof(double));21 tria=xNew<double>(numberofnodes); 22 22 23 23 /*Intermediary*/ … … 52 52 } 53 53 54 55 54 /*Assign output pointers:*/ 56 55 *ptria=tria; -
issm/trunk-jpl/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp
r11679 r12450 34 34 35 35 /*Free ressources:*/ 36 x free((void**)&yg_serial);36 xDelete<double>(yg_serial); 37 37 } -
issm/trunk-jpl/src/c/modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp
r11707 r12450 38 38 39 39 /*Free ressources:*/ 40 x free((void**)&thickness);41 x free((void**)&bed);40 xDelete<double>(thickness); 41 xDelete<double>(bed); 42 42 xdelete(&vz); 43 43 return 1; -
issm/trunk-jpl/src/c/modules/VecMergex/VecMergex.cpp
r11679 r12450 41 41 } 42 42 /*Free ressources:*/ 43 x free((void**)&uf_serial);43 xDelete<double>(uf_serial); 44 44 45 45 /*Assemble vector: */ -
issm/trunk-jpl/src/c/objects/IoModel.cpp
r12418 r12450 205 205 dataenum=va_arg(ap, int); 206 206 _assert_(dataenum<MaximumNumberOfEnums); 207 x free((void**)&this->data[dataenum]);207 xDelete<double>(this->data[dataenum]); 208 208 } 209 209 va_end(ap); … … 691 691 /*Now allocate matrix: */ 692 692 if(M*N){ 693 matrix= (IssmPDouble*)xmalloc(M*N*sizeof(IssmPDouble));693 matrix=xNew<IssmPDouble>(M*N); 694 694 695 695 /*Read matrix on node 0, then broadcast: */
Note:
See TracChangeset
for help on using the changeset viewer.