project(o815)
-find_package(MPI REQUIRED)
-set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
-set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
-include_directories(${MPI_INCLUDE_PATH})
+if(NOT DEFINED ENV{MPI_DISABLED})
+ find_package(MPI REQUIRED)
+ set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
+ set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
+ include_directories(${MPI_INCLUDE_PATH})
+else()
+ message("MPI support is disabled!")
+endif()
SET(CMAKE_BUILD_TYPE Release)
add_library(o815 o815.cpp obs.cpp sim.cpp)
target_link_libraries(o815 ${MPI_LIBRARIES} lat_paraq lat_writeout lat_hypercache lat_progress)
+if(DEFINED ENV{MPI_DISABLED})
+ set_target_properties(o815 PROPERTIES COMPILE_DEFINITIONS "MPI_DISABLED")
+endif()
#include <sstream>
#include <iomanip>
+#include <cstring>
+#ifndef MPI_DISABLED
#include <mpi.h>
+#endif
#include "latlib/progress.h"
comargs.idonly = false;
comargs.showjobnum = false;
+#ifndef MPI_DISABLED
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+#else
+ numprocs = 1;
+ rank = 0;
+#endif
addComOption("lsize", required_argument, NULL, 'L', "define lattice size", "xsize:tsize");
addComOption("nmeas", required_argument, NULL, 'N', "set number of measurements", "nmeas");
if(rank==0) {
timestamp = time(NULL);
+#ifndef MPI_DISABLED
for(int idest=1; idest<numprocs; idest++)
MPI_Send(×tamp, 1, MPI_LONG, idest, 123, MPI_COMM_WORLD);
+#endif
}
+#ifndef MPI_DISABLED
else if(rank>0)
MPI_Recv(×tamp, 1, MPI_LONG, 0, 123, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
-
+#endif
+
out = new writeout(comargs.outdir, programid+headMaster(), rank, numprocs, timestamp);
}
o815::~o815() {
if(comargs.outdir=="") {
+#ifndef MPI_DISABLED
MPI_Barrier(MPI_COMM_WORLD);
+#endif
if(rank==0)
cout << "#end" << endl << flush;
}
hypercache::finalize();
delete out;
+#ifndef MPI_DISABLED
MPI_Finalize();
+#endif
}
int o815::nextParas()
#include "latlib/hypercache.h"
+#ifndef MPI_DISABLED
#include <mpi.h>
+#endif
void o815::obs::finish() {
_finish();
*out << "#" << O815->programid << "-" << obsid << obsidpostfix << O815->headMaster() << "-" << datadesc << endl << flush;
}
+#ifndef MPI_DISABLED
if (O815->comargs.outdir=="")
MPI_Barrier(MPI_COMM_WORLD);
-
+#endif
+
_start();
}