Changeset 5530
- Timestamp:
- Jul 18, 2008, 2:04:20 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/urs_ext.c
r5529 r5530 50 50 float *weights; 51 51 int dimensions[2]; 52 longnumSrc;53 longverbose;52 int numSrc; 53 int verbose; 54 54 int nsta0; 55 55 int nt; … … 99 99 } 100 100 101 muxFileNameArray = (char**)malloc( (int)numSrc*sizeof(char*));101 muxFileNameArray = (char**)malloc(numSrc*sizeof(char*)); 102 102 if (muxFileNameArray == NULL) 103 103 { 104 104 printf("ERROR: Memory for muxFileNameArray could not be allocated.\n"); 105 exit(-1);105 return NULL; 106 106 } 107 107 108 108 //printf("Checkpoint 2 for urs2sts_ext.c\n"); 109 //printf("numSrc = %d\n", numSrc); 109 110 for (i = 0; i < numSrc; i++) 110 111 { 111 112 113 //printf("check 2.1, i=%d\n", i); 112 114 fname = PyList_GetItem(filenames, i); 113 if (!PyString_Check(fname)) 114 { 115 //printf("check 2.2\n"); 116 if (!fname) 117 { 118 //printf("error\n"); 115 119 PyErr_SetString(PyExc_ValueError, "filename not a string"); 116 return NULL; 117 } 118 120 return NULL; 121 } 122 //printf("check 2.3\n"); 123 //printf("fname = %s\n", PyString_AsString(fname)); 124 125 126 //printf("check 2.4\n"); 119 127 muxFileNameArray[i] = PyString_AsString(fname); 120 128 if (muxFileNameArray[i] == NULL) … … 135 143 //printf("Checkpoint 4 for urs2sts_ext.c\n"); 136 144 // Create array for weights which are passed to read_mux2 137 weights = (float*) malloc( (int)numSrc*sizeof(float));138 for (i = 0; i < (int)numSrc; i++)145 weights = (float*) malloc(numSrc*sizeof(float)); 146 for (i = 0; i < numSrc; i++) 139 147 { 140 148 weights[i] = (float)(*(double*)(pyweights->data + i*pyweights->strides[0])); … … 143 151 //printf("Checkpoint 5 for urs2sts_ext.c\n"); 144 152 // Read in mux2 data from file 145 cdata = _read_mux2((int)numSrc, muxFileNameArray, weights, (double*)file_params->data, (int)verbose); 153 cdata = _read_mux2(numSrc, 154 muxFileNameArray, 155 weights, 156 (double*)file_params->data, 157 verbose); 146 158 147 159 //printf("Checkpoint 6 for urs2sts_ext.c\n"); … … 237 249 } 238 250 239 float** _read_mux2(int numSrc, char **muxFileNameArray, float *weights, double *params, int verbose) 251 float** _read_mux2(int numSrc, 252 char **muxFileNameArray, 253 float *weights, 254 double *params, 255 int verbose) 240 256 { 241 257 FILE *fp; … … 284 300 285 301 /* loop over remaining sources, check compatibility, and read them into 286 *muxData */ 287 302 *muxData */ 303 for (isrc = 0; isrc < numSrc; isrc++) 288 304 { 289 305 muxFileName = muxFileNameArray[isrc]; 290 306 291 307 /* open the mux file */ 292 308 if((fp = fopen(muxFileName, "r")) == NULL) 293 309 { … … 298 314 if (!isrc) 299 315 { 300 301 302 303 316 fread(&nsta0, sizeof(int), 1, fp); 317 318 fros = (int*)malloc(nsta0*numSrc*sizeof(int)); 319 lros = (int*)malloc(nsta0*numSrc*sizeof(int)); 304 320 305 306 307 308 321 mytgs0 = (struct tgsrwg*)malloc(nsta0*sizeof(struct tgsrwg)); 322 mytgs = (struct tgsrwg*)malloc(nsta0*sizeof(struct tgsrwg)); 323 324 fread(mytgs0, nsta0*sizeof(struct tgsrwg), 1, fp); 309 325 } 310 326 else
Note: See TracChangeset
for help on using the changeset viewer.