blob: 96122de4fc9a905e319a39194a98a59fca5fb41e [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
8 --initialSeed INITIALSEED]]
9
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.
25END
26}
27
28if (( "$#" < 2 )); then
29 usage
30 exit 1
31fi
32
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020033T="$1"
34L="$2"
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020035defaultOutFilePrefix="L$L-T$T"
36outFilePrefix="${3:-$defaultOutFilePrefix}"
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020037
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020038opts=$(getopt -l "help,skipIfComputed,nSeeds:,mcTot:,mcIni:,mcD:,initialSeed:" -o "hsn:m:i:d:" -n "$progname" -- "${@:4}")
39eval set -- "$opts"
40
41skipIfComputed=false
42nSeeds=150
43mcTot=40000
44mcIni=2000
45mcD=20
46initialSeed=117654
47
48while true; do
49 case "$1" in
50 -h | --help)
51 usage
52 exit
53 ;;
54 -s | --skipIfComputed)
55 skipIfComputed=true
56 shift
57 ;;
58 -n | --nSeeds)
59 nSeeds="$2"
60 shift 2
61 ;;
62 -m | --mcTot)
63 mcTot="$2"
64 shift 2
65 ;;
66 -i | --mcIni)
67 mcIni="$2"
68 shift 2
69 ;;
70 -d | --mcD)
71 mcD="$2"
72 shift 2
73 ;;
74 --initialSeed)
75 initialSeed="$2"
76 shift 2
77 ;;
78 *) break ;;
79 esac
80done
81
82if [ "$skipIfComputed" == "true" ] && [ -f "data_out/${outFilePrefix}.res" ]; then
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020083 echo "Skipping computation for L=$L, T=$T (.res file already exists)"
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020084 exit
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020085fi
86
87echo "Starting computation for L=$L, T=$T"
88
89cat <<EOF | ./out/mc2
90&DADES
91L=$L,
92NOM="$outFilePrefix",
93TEMP=$T,
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020094NSEED=$nSeeds,
95SEED0=$initialSeed,
96MCTOT=$mcTot,
97MCINI=$mcIni,
98MCD=$mcD
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020099&END
100EOF