Changeset da4244 for pcp/src/output.c
- Timestamp:
- Apr 21, 2008, 8:27:24 PM (17 years ago)
- Children:
- 0b638d
- Parents:
- 18d065
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pcp/src/output.c
r18d065 rda4244 1350 1350 FILE *SrcIonDoc, *SrcIonData; 1351 1351 char *suffix; 1352 int flag = 0; 1352 1353 // read the doc file and check 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) { 1358 //Error(SomeError, "ReadSrcIons: read error"); 1359 Free(suffix, "ReadSrcIons: suffix"); 1360 return 0; 1361 } 1362 if (Max_Types != I->Max_Types) { 1363 //Error(SomeError, "ReadSrcIons: srcion file does not fit to system, MaxTypes"); 1364 Free(suffix, "ReadSrcIons: suffix"); 1365 return 0; 1366 } 1367 Max_IonsOfType = (int *) Malloc(Max_Types*sizeof(int), "ReadSrcIons: Max_IonsOfType"); 1368 for (is=0; is < Max_Types; is++) { 1369 if (fscanf(SrcIonDoc,"%i", &Max_IonsOfType[is]) != 1) { 1370 //Error(SomeError, "ReadSrcIons: read error"); 1371 Free(suffix, "ReadSrcIons: suffix"); 1372 return 0; 1373 } 1374 if (Max_IonsOfType[is] != I->I[is].Max_IonsOfType) { 1375 //Error(SomeError, "ReadSrcIons: srcion file does not fit to system, Max_IonsOfType"); 1376 Free(suffix, "ReadSrcIons: suffix"); 1377 return 0; 1354 1355 if (!P->Par.me) { // process 0 reads and broadcasts .. 1356 suffix = (char *) 1357 Malloc(strlen(suffixsrciondoc) + 3 + 1,"ReadSrcIons: suffix"); 1358 sprintf(suffix, ".L%i%s", P->Lat.Lev[STANDARTLEVEL].LevelNo, suffixsrciondoc); 1359 if (OpenFile(P, &SrcIonDoc, suffix, "r",P->Call.out[ReadOut])) { 1360 if (fscanf(SrcIonDoc,"%i", &Max_Types) != 1) { 1361 //Error(SomeError, "ReadSrcIons: read error"); 1362 Free(suffix, "ReadSrcIons: suffix"); 1363 if (MPI_Bcast(&flag,1,MPI_INT,0,P->Par.comm) != MPI_SUCCESS) 1364 Error(SomeError,"ReadSrcIons: Bcast of signal failed\n"); 1365 return flag; 1378 1366 } 1379 } 1380 fclose(SrcIonDoc); 1381 // read basis, then positions and speeds of ions 1367 if (Max_Types != I->Max_Types) { 1368 //Error(SomeError, "ReadSrcIons: srcion file does not fit to system, MaxTypes"); 1369 Free(suffix, "ReadSrcIons: suffix"); 1370 if (MPI_Bcast(&flag,1,MPI_INT,0,P->Par.comm) != MPI_SUCCESS) 1371 Error(SomeError,"ReadSrcIons: Bcast of signal failed\n"); 1372 return flag; 1373 } 1374 Max_IonsOfType = (int *) Malloc(Max_Types*sizeof(int), "ReadSrcIons: Max_IonsOfType"); 1375 for (is=0; is < Max_Types; is++) { 1376 if (fscanf(SrcIonDoc,"%i", &Max_IonsOfType[is]) != 1) { 1377 //Error(SomeError, "ReadSrcIons: read error"); 1378 Free(suffix, "ReadSrcIons: suffix"); 1379 Free(Max_IonsOfType, "ReadSrcIons: Max_IonsOfType"); 1380 if (MPI_Bcast(&flag,1,MPI_INT,0,P->Par.comm) != MPI_SUCCESS) 1381 Error(SomeError,"ReadSrcIons: Bcast of signal failed\n"); 1382 return flag; 1383 } 1384 if (Max_IonsOfType[is] != I->I[is].Max_IonsOfType) { 1385 //Error(SomeError, "ReadSrcIons: srcion file does not fit to system, Max_IonsOfType"); 1386 Free(suffix, "ReadSrcIons: suffix"); 1387 Free(Max_IonsOfType, "ReadSrcIons: Max_IonsOfType"); 1388 if (MPI_Bcast(&flag,1,MPI_INT,0,P->Par.comm) != MPI_SUCCESS) 1389 Error(SomeError,"ReadSrcIons: Bcast of signal failed\n"); 1390 return flag; 1391 } 1392 } 1393 Free(Max_IonsOfType, "ReadSrcIons: Max_IonsOfType"); 1394 fclose(SrcIonDoc); 1395 } 1396 // read basis, then positions and speeds of ions 1382 1397 if (OpenFile(P, &SrcIonData, suffixsrciondat, "rb",P->Call.out[ReadOut])) { 1383 1398 if (fread(RealBasis, sizeof(double), (size_t)(NDIM_NDIM), SrcIonData) != NDIM_NDIM) { 1384 1399 //Error(SomeError, "ReadSrcIons: read error"); 1385 1400 Free(suffix, "ReadSrcIons: suffix"); 1386 return 0; 1401 if (MPI_Bcast(&flag,1,MPI_INT,0,P->Par.comm) != MPI_SUCCESS) 1402 Error(SomeError,"ReadSrcIons: Bcast of signal failed\n"); 1403 return flag; 1387 1404 } 1388 1405 for (i=0; i < NDIM_NDIM; i++) 1389 1406 if (RealBasis[i] != P->Lat.RealBasis[i]) { 1390 1407 //Error(SomeError, "ReadSrcIons: srcion file does not fit to system, RealBasis"); 1391 Free(suffix, "ReadSrcIons: suffix"); 1392 return 0; 1408 Free(suffix, "ReadSrcIons: suffix"); 1409 if (MPI_Bcast(&flag,1,MPI_INT,0,P->Par.comm) != MPI_SUCCESS) 1410 Error(SomeError,"ReadSrcIons: Bcast of signal failed\n"); 1411 return flag; 1393 1412 } 1394 1413 for (is=0; is < I->Max_Types; is++) { … … 1396 1415 if (fread(&data, sizeof(double), (size_t)(2*NDIM), SrcIonData) != 2*NDIM) { 1397 1416 //Error(SomeError, "ReadSrcIons: read error"); 1398 Free(suffix, "ReadSrcIons: suffix"); 1399 return 0; 1417 Free(suffix, "ReadSrcIons: suffix"); 1418 if (MPI_Bcast(&flag,1,MPI_INT,0,P->Par.comm) != MPI_SUCCESS) 1419 Error(SomeError,"ReadSrcIons: Bcast of signal failed\n"); 1420 return flag; 1400 1421 } 1401 1422 U = &I->I[is].U[NDIM*ia]; … … 1408 1429 } 1409 1430 fclose(SrcIonData); 1410 } 1411 if (Max_IonsOfType != NULL) Free(Max_IonsOfType, "Max_IonsOfType"); 1412 } 1431 flag = 1; 1432 } 1413 1433 Free(suffix, "ReadSrcIons: suffix"); 1414 return 1; 1434 } 1435 if (MPI_Bcast(&flag,1,MPI_INT,0,P->Par.comm) != MPI_SUCCESS) 1436 Error(SomeError,"ReadSrcIons: Bcast of signal failed\n"); 1437 //fprintf(stderr, "(%i) Flag is %i\n", P->Par.me, flag); 1438 if (flag) { 1439 for (is=0; is < I->Max_Types; is++) { 1440 if (MPI_Bcast(I->I[is].R, I->I[is].Max_IonsOfType*NDIM, MPI_DOUBLE, 0, P->Par.comm) != MPI_SUCCESS) 1441 Error(SomeError,"ReadSrcIons: Bcast of I->I[is].R failed\n"); 1442 if (MPI_Bcast(I->I[is].U, I->I[is].Max_IonsOfType*NDIM, MPI_DOUBLE, 0, P->Par.comm) != MPI_SUCCESS) 1443 Error(SomeError,"ReadSrcIons: Bcast of I->I[is].U failed\n"); 1444 } 1445 } 1446 //fprintf(stderr, "(%i) ReadSrcIons done\n", P->Par.me); 1447 return flag; 1415 1448 } 1416 1449
Note:
See TracChangeset
for help on using the changeset viewer.