blob: 2c95bdd2d1f50159606afe3a33648ef12588424c [file] [log] [blame]
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +02001#!/bin/bash
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +02002progname=$0
3function usage() {
4 cat <<END
5
6 Usage: $progname T L [outFilePrefix [--help --skipIfComputed
7 --nSeeds NSEEDS --mcTot MCTOT --mcIni MCINI --mcD MCD
Adrià Vilanova Martínez1ee4edb2022-06-13 22:37:08 +02008 --initialSeed INITIALSEED --saveFinalConf]]
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +02009
10 the output file will be saved at "data_out/{{outFilePrefix}}"
11
12 optional arguments:
13 -h, --help show this help message and exit.
14 -s, --skipIfComputed skip if the output file already exists.
15 -n, --nSeeds number of seeds which will be used for the
16 simulation.
17 -m, --mcTot number of iterations which will be performed
18 in the simulation for each seed.
19 -i, --mcIni number of iterations before the program
20 starts measuring physical properties of the
21 system.
22 -d, --mcD the program will measure the physical
23 properties when iteration % MCD == 0.
24 --initialSeed initial seed for the Monte Carlo algorithm.
Adrià Vilanova Martínez1ee4edb2022-06-13 22:37:08 +020025 --saveFinalConf save a file with the configuration which
26 belongs to the last Montecarlo iteration.
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020027END
28}
29
30if (( "$#" < 2 )); then
31 usage
32 exit 1
33fi
34
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020035T="$1"
36L="$2"
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020037defaultOutFilePrefix="L$L-T$T"
38outFilePrefix="${3:-$defaultOutFilePrefix}"
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020039
Adrià Vilanova Martínez1ee4edb2022-06-13 22:37:08 +020040opts=$(getopt -l "help,skipIfComputed,nSeeds:,mcTot:,mcIni:,mcD:,initialSeed:,saveFinalConf" -o "hsn:m:i:d:" -n "$progname" -- "${@:4}")
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020041eval set -- "$opts"
42
43skipIfComputed=false
44nSeeds=150
45mcTot=40000
46mcIni=2000
47mcD=20
48initialSeed=117654
Adrià Vilanova Martínez1ee4edb2022-06-13 22:37:08 +020049saveFinalConf=F
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020050
51while true; do
52 case "$1" in
53 -h | --help)
54 usage
55 exit
56 ;;
57 -s | --skipIfComputed)
58 skipIfComputed=true
59 shift
60 ;;
61 -n | --nSeeds)
62 nSeeds="$2"
63 shift 2
64 ;;
65 -m | --mcTot)
66 mcTot="$2"
67 shift 2
68 ;;
69 -i | --mcIni)
70 mcIni="$2"
71 shift 2
72 ;;
73 -d | --mcD)
74 mcD="$2"
75 shift 2
76 ;;
77 --initialSeed)
78 initialSeed="$2"
79 shift 2
80 ;;
Adrià Vilanova Martínez1ee4edb2022-06-13 22:37:08 +020081 --saveFinalConf)
82 saveFinalConf=T
83 shift
84 ;;
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020085 *) break ;;
86 esac
87done
88
89if [ "$skipIfComputed" == "true" ] && [ -f "data_out/${outFilePrefix}.res" ]; then
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020090 echo "Skipping computation for L=$L, T=$T (.res file already exists)"
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020091 exit
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020092fi
93
94echo "Starting computation for L=$L, T=$T"
95
96cat <<EOF | ./out/mc2
97&DADES
98L=$L,
99NOM="$outFilePrefix",
100TEMP=$T,
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +0200101NSEED=$nSeeds,
102SEED0=$initialSeed,
103MCTOT=$mcTot,
104MCINI=$mcIni,
105MCD=$mcD
Adrià Vilanova Martínez1ee4edb2022-06-13 22:37:08 +0200106SAVEFINALCONF=$saveFinalConf
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +0200107&END
108EOF