You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LiebLin_DSF_par.cc 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: LiebLin_DSF_par.cc
  6. Purpose: Parallel version of ABACUS using MPICH.
  7. ***********************************************************/
  8. #include "ABACUS.h"
  9. #include "mpi.h"
  10. using namespace ABACUS;
  11. int main(int argc, char *argv[])
  12. {
  13. char whichDSF;
  14. DP c_int, L, kBT;
  15. int N, iKmin, iKmax, Max_Secs, supercycle_time;
  16. DP target_sumrule = 1.0e+6; // effectively deactivated here
  17. bool refine = true; // always true for parallel mode
  18. if (argc != 10) { // provide some info
  19. cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
  20. cout << endl << "Usage of LiebLin_DSF_par executable: " << endl;
  21. cout << endl << "This function runs ABACUS in parallel mode, starting from a preexisting serial run (obtained using the LiebLin_DSF executable) using the same model parameters." << endl;
  22. cout << endl << "Provide the following arguments:" << endl << endl;
  23. cout << "char whichDSF \t\t Which structure factor should be calculated ? Options are: d for rho rho, g for psi psi{dagger}, o for psi{dagger} psi" << endl;
  24. cout << "DP c_int \t\t Value of the interaction parameter: use positive real values only" << endl;
  25. cout << "DP L \t\t\t Length of the system: use positive real values only" << endl;
  26. cout << "int N \t\t\t Number of particles: use positive integer values only" << endl;
  27. cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers to scan over: recommended values: -2*N and 2*N" << endl;
  28. cout << "DP kBT \t\t Temperature (positive only of course)" << endl;
  29. cout << "int Max_Secs \t\t Allowed computational time: (in seconds)" << endl;
  30. cout << "int supercycle_time \t\t time for one supercycle (in seconds)" << endl;
  31. cout << endl << "EXAMPLE: " << endl << endl;
  32. cout << "mpiexec -np 8 LiebLin_DSF_MosesState_par d 1.0 100.0 100 -400 400 0.0 3600 600" << endl << endl;
  33. return(0);
  34. }
  35. else { // (argc == 9) correct nr of arguments
  36. whichDSF = *argv[1];
  37. c_int = atof(argv[2]);
  38. L = atof(argv[3]);
  39. N = atoi(argv[4]);
  40. iKmin = atoi(argv[5]);
  41. iKmax = atoi(argv[6]);
  42. kBT = atof(argv[7]);
  43. Max_Secs = atoi(argv[8]);
  44. supercycle_time = atoi(argv[9]);
  45. }
  46. //DP supercycle_time = 600.0; // allotted time per supercycle
  47. if (Max_Secs <= supercycle_time) ABACUSerror("Please allow more time in LiebLin_DSF_par.");
  48. MPI::Init(argc, argv);
  49. DP tstart = MPI::Wtime();
  50. int rank = MPI::COMM_WORLD.Get_rank();
  51. int nr_processors = MPI::COMM_WORLD.Get_size();
  52. if (nr_processors < 2) ABACUSerror("Give at least 2 processors to ABACUS parallel !");
  53. refine = true;
  54. // ASSUMPTION: preexisting files (raw, thr, ...) exist for the run.
  55. DP tnow = MPI::Wtime();
  56. string defaultScanStatename = "";
  57. while (tnow - tstart < Max_Secs - supercycle_time - 120) { // space for one more supercycle, + 2 minutes safety
  58. if (rank == 0)
  59. // Split up thread list into chunks, one per processor
  60. //Prepare_Parallel_Scan_LiebLin (whichDSF, c_int, L, N, iK_UL, fixed_iK, iKneeded, nr_processors);
  61. Prepare_Parallel_Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT, defaultScanStatename, nr_processors);
  62. // Barrier synchronization, to make sure other processes wait for process of rank 0
  63. // to have finished splitting up the thr file into pieces before starting:
  64. MPI_Barrier (MPI::COMM_WORLD);
  65. // then everybody gets going on their own chunk !
  66. //Scan_LiebLin (whichDSF, c_int, L, N, iK_UL, fixed_iK, iKneeded,
  67. Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT,
  68. supercycle_time, target_sumrule, refine, rank, nr_processors);
  69. // Another barrier synchronization
  70. MPI_Barrier (MPI::COMM_WORLD);
  71. // Now that everybody is done, digest data into unique files
  72. if (rank == 0)
  73. //Wrapup_Parallel_Scan_LiebLin (whichDSF, c_int, L, N, iK_UL, fixed_iK, iKneeded, nr_processors);
  74. Wrapup_Parallel_Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT, defaultScanStatename, nr_processors);
  75. // Another barrier synchronization
  76. MPI_Barrier (MPI::COMM_WORLD);
  77. tnow = MPI::Wtime();
  78. } // while (tnow - tstart...
  79. MPI::Finalize();
  80. return(0);
  81. }