blob: 1be282a827b026b6c0b3eca5192bcca6b61c722f [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ínez24d87012022-06-16 00:29:59 +02008 --initialSeed INITIALSEED --saveFinalConf
9 --saveEvolution]]
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020010
Adrià Vilanova Martínez24d87012022-06-16 00:29:59 +020011 the results file will be saved at "data_out/{{outFilePrefix}}.res"
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020012
13 optional arguments:
14 -h, --help show this help message and exit.
15 -s, --skipIfComputed skip if the output file already exists.
16 -n, --nSeeds number of seeds which will be used for the
17 simulation.
18 -m, --mcTot number of iterations which will be performed
19 in the simulation for each seed.
20 -i, --mcIni number of iterations before the program
21 starts measuring physical properties of the
22 system.
23 -d, --mcD the program will measure the physical
24 properties when iteration % MCD == 0.
25 --initialSeed initial seed for the Monte Carlo algorithm.
Adrià Vilanova Martínez1ee4edb2022-06-13 22:37:08 +020026 --saveFinalConf save a file with the configuration which
27 belongs to the last Montecarlo iteration.
Adrià Vilanova Martínez24d87012022-06-16 00:29:59 +020028 It will be saved at
29 "data_out/{{outFilePrefix}}.conf".
30 --saveEvolution save a file with the temporary evolution
31 of the simulation. It will be saved at
32 "data_out/{{outFilePrefix}}.ev"
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020033END
34}
35
36if (( "$#" < 2 )); then
37 usage
38 exit 1
39fi
40
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020041T="$1"
42L="$2"
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020043defaultOutFilePrefix="L$L-T$T"
44outFilePrefix="${3:-$defaultOutFilePrefix}"
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +020045
Adrià Vilanova Martínez24d87012022-06-16 00:29:59 +020046opts=$(getopt -l "help,skipIfComputed,nSeeds:,mcTot:,mcIni:,mcD:,initialSeed:,saveFinalConf,saveEvolution" -o "hsn:m:i:d:" -n "$progname" -- "${@:4}")
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020047eval set -- "$opts"
48
49skipIfComputed=false
50nSeeds=150
51mcTot=40000
52mcIni=2000
53mcD=20
54initialSeed=117654
Adrià Vilanova Martínez1ee4edb2022-06-13 22:37:08 +020055saveFinalConf=F
Adrià Vilanova Martínez24d87012022-06-16 00:29:59 +020056saveEvolution=F
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020057
58while true; do
59 case "$1" in
60 -h | --help)
61 usage
62 exit
63 ;;
64 -s | --skipIfComputed)
65 skipIfComputed=true
66 shift
67 ;;
68 -n | --nSeeds)
69 nSeeds="$2"
70 shift 2
71 ;;
72 -m | --mcTot)
73 mcTot="$2"
74 shift 2
75 ;;
76 -i | --mcIni)
77 mcIni="$2"
78 shift 2
79 ;;
80 -d | --mcD)
81 mcD="$2"
82 shift 2
83 ;;
84 --initialSeed)
85 initialSeed="$2"
86 shift 2
87 ;;
Adrià Vilanova Martínez1ee4edb2022-06-13 22:37:08 +020088 --saveFinalConf)
89 saveFinalConf=T
90 shift
91 ;;
Adrià Vilanova Martínez24d87012022-06-16 00:29:59 +020092 --saveEvolution)
93 saveEvolution=T
94 shift
95 ;;
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +020096 *) break ;;
97 esac
98done
99
100if [ "$skipIfComputed" == "true" ] && [ -f "data_out/${outFilePrefix}.res" ]; then
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +0200101 echo "Skipping computation for L=$L, T=$T (.res file already exists)"
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +0200102 exit
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +0200103fi
104
105echo "Starting computation for L=$L, T=$T"
106
107cat <<EOF | ./out/mc2
108&DADES
109L=$L,
110NOM="$outFilePrefix",
111TEMP=$T,
Adrià Vilanova Martínezd2f8c712022-06-05 22:41:03 +0200112NSEED=$nSeeds,
113SEED0=$initialSeed,
114MCTOT=$mcTot,
115MCINI=$mcIni,
116MCD=$mcD
Adrià Vilanova Martínez1ee4edb2022-06-13 22:37:08 +0200117SAVEFINALCONF=$saveFinalConf
Adrià Vilanova Martínez24d87012022-06-16 00:29:59 +0200118SAVEEVOLUTION=$saveEvolution
Adrià Vilanova Martínezc102e962022-06-04 23:53:44 +0200119&END
120EOF