# 2 Dimensional Ising Model: src/mcmc_progression.cpp Source File

Loading...
Searching...
No Matches
mcmc_progression.cpp
Go to the documentation of this file.
/** @file mcmc_progression.cpp
*
* @author Cory Alexander Balaton (coryab)
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
*
* @version 1.0
*
* @brief Execute the mcmc algorithm and write data to file after each
* Monte Carlo cycle.
*
* @bug No known bugs
* */
#include "data_type.hpp"
#include "monte_carlo.hpp"
#include "utils.hpp"
#include <getopt.h>
#include <omp.h>
#include <string>
/** @brief A function that displays how to use the program and quits.*/
void usage(std::string filename)
{
std::cout << "Usage: " << filename
<< " <temperature> <lattice size> "
"<cycles> <burn-in-time> <output file>\n\n"
<< "\t[ -h | --help ]\n";
exit(-1);
}
/** @brief The main function.*/
int main(int argc, char **argv)
{
// Command options
struct option long_options[] = {{"help", 0, 0, 0}, {NULL, 0, NULL, 0}};
int option_index = -1;
int c;
while (true) {
c = getopt_long(argc, argv, "h", long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 0:
switch (option_index) {
case 0: // Not a mistake. This just goes to the default.
default:
usage(argv[0]);
}
break;
case 'h':
default:
usage(argv[0]);
}
}
// Check that the number of arguments is at least 8.
if (argc < 6) {
usage(argv[0]);
}
// Timing variables
double t0, t1;
t0 = omp_get_wtime();
// Define/initialize variables
double temp = atoi(argv[1]);
int L = atoi(argv[2]), cycles = atoi(argv[3]), burn_in_time = atoi(argv[4]);
std::string outfile = argv[5];
montecarlo::progression(temp, L, cycles, outfile, burn_in_time);
t1 = omp_get_wtime();
std::cout << "Time: " << t1 - t0 << " seconds\n";
}
main
int main(int argc, char **argv)
The main function.
Definition: main.cpp:125
usage
void usage(std::string filename)
A function that displays how to use the program and quits.
Definition: main.cpp:110