Changeset 18d065
- Timestamp:
- Apr 21, 2008, 7:47:06 PM (17 years ago)
- Children:
- da4244
- Parents:
- 4d4fc1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pcp/src/output.c
r4d4fc1 r18d065 1301 1301 int is,ia,i; 1302 1302 FILE *SrcIonDoc, *SrcIonData; 1303 char suffix[255]; 1303 1304 1304 1305 if (!(P->Par.me == 0)) return; 1305 1306 1306 1307 // output of ion types and numbers per type 1307 OpenFile(P, &SrcIonDoc, suffixsrciondoc, "w",P->Call.out[ReadOut]); 1308 sprintf(suffix, ".L%i%s", P->Lat.Lev[STANDARTLEVEL].LevelNo, suffixsrciondoc); 1309 OpenFile(P, &SrcIonDoc, suffix, "w",P->Call.out[ReadOut]); 1308 1310 fprintf(SrcIonDoc,"%i\n", I->Max_Types); 1309 1311 for (is=0; is < I->Max_Types; is++) … … 1311 1313 fclose(SrcIonDoc); 1312 1314 1313 OpenFile(P, &SrcIonData, suffixsrciondat, "wb",P->Call.out[ReadOut]); 1315 sprintf(suffix, ".L%i%s", P->Lat.Lev[STANDARTLEVEL].LevelNo, suffixsrciondat); 1316 OpenFile(P, &SrcIonData, suffix, "wb",P->Call.out[ReadOut]); 1314 1317 (void)fwrite(P->Lat.RealBasis, sizeof(double), (size_t)(NDIM_NDIM), SrcIonData); 1315 1318 for (is=0; is < I->Max_Types; is++) { … … 1346 1349 double RealBasis[NDIM_NDIM]; 1347 1350 FILE *SrcIonDoc, *SrcIonData; 1351 char *suffix; 1348 1352 // read the doc file and check 1349 if (OpenFile(P, &SrcIonDoc, suffixsrciondoc, "r",P->Call.out[ReadOut])) { 1350 if (fscanf(SrcIonDoc,"%i", &Max_Types) != 1) 1353 suffix = (char *) 1354 Malloc(strlen(suffixsrciondoc) + 3 + 1,"ReadSrcIons: suffix"); 1355 sprintf(suffix, ".L%i%s", P->Lat.Lev[STANDARTLEVEL].LevelNo, suffixsrciondoc); 1356 if (OpenFile(P, &SrcIonDoc, suffix, "r",P->Call.out[ReadOut])) { 1357 if (fscanf(SrcIonDoc,"%i", &Max_Types) != 1) { 1351 1358 //Error(SomeError, "ReadSrcIons: read error"); 1359 Free(suffix, "ReadSrcIons: suffix"); 1352 1360 return 0; 1353 if (Max_Types != I->Max_Types) 1361 } 1362 if (Max_Types != I->Max_Types) { 1354 1363 //Error(SomeError, "ReadSrcIons: srcion file does not fit to system, MaxTypes"); 1364 Free(suffix, "ReadSrcIons: suffix"); 1355 1365 return 0; 1366 } 1356 1367 Max_IonsOfType = (int *) Malloc(Max_Types*sizeof(int), "ReadSrcIons: Max_IonsOfType"); 1357 1368 for (is=0; is < Max_Types; is++) { 1358 if (fscanf(SrcIonDoc,"%i", &Max_IonsOfType[is]) != 1) 1369 if (fscanf(SrcIonDoc,"%i", &Max_IonsOfType[is]) != 1) { 1359 1370 //Error(SomeError, "ReadSrcIons: read error"); 1360 return 0; 1361 if (Max_IonsOfType[is] != I->I[is].Max_IonsOfType) 1371 Free(suffix, "ReadSrcIons: suffix"); 1372 return 0; 1373 } 1374 if (Max_IonsOfType[is] != I->I[is].Max_IonsOfType) { 1362 1375 //Error(SomeError, "ReadSrcIons: srcion file does not fit to system, Max_IonsOfType"); 1363 return 0; 1376 Free(suffix, "ReadSrcIons: suffix"); 1377 return 0; 1378 } 1364 1379 } 1365 1380 fclose(SrcIonDoc); 1366 1381 // read basis, then positions and speeds of ions 1367 1382 if (OpenFile(P, &SrcIonData, suffixsrciondat, "rb",P->Call.out[ReadOut])) { 1368 if (fread(RealBasis, sizeof(double), (size_t)(NDIM_NDIM), SrcIonData) != NDIM_NDIM) 1383 if (fread(RealBasis, sizeof(double), (size_t)(NDIM_NDIM), SrcIonData) != NDIM_NDIM) { 1369 1384 //Error(SomeError, "ReadSrcIons: read error"); 1385 Free(suffix, "ReadSrcIons: suffix"); 1370 1386 return 0; 1387 } 1371 1388 for (i=0; i < NDIM_NDIM; i++) 1372 if (RealBasis[i] != P->Lat.RealBasis[i]) 1389 if (RealBasis[i] != P->Lat.RealBasis[i]) { 1373 1390 //Error(SomeError, "ReadSrcIons: srcion file does not fit to system, RealBasis"); 1391 Free(suffix, "ReadSrcIons: suffix"); 1374 1392 return 0; 1393 } 1375 1394 for (is=0; is < I->Max_Types; is++) { 1376 1395 for (ia=0; ia < I->I[is].Max_IonsOfType; ia++) { 1377 if (fread(&data, sizeof(double), (size_t)(2*NDIM), SrcIonData) != 2*NDIM) 1396 if (fread(&data, sizeof(double), (size_t)(2*NDIM), SrcIonData) != 2*NDIM) { 1378 1397 //Error(SomeError, "ReadSrcIons: read error"); 1398 Free(suffix, "ReadSrcIons: suffix"); 1379 1399 return 0; 1400 } 1380 1401 U = &I->I[is].U[NDIM*ia]; 1381 1402 pos = &I->I[is].R[NDIM*ia]; … … 1390 1411 if (Max_IonsOfType != NULL) Free(Max_IonsOfType, "Max_IonsOfType"); 1391 1412 } 1413 Free(suffix, "ReadSrcIons: suffix"); 1392 1414 return 1; 1393 1415 }
Note:
See TracChangeset
for help on using the changeset viewer.