Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 1 | #!/bin/bash |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 2 | progname=$0 |
| 3 | function 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ínez | 24d8701 | 2022-06-16 00:29:59 +0200 | [diff] [blame^] | 8 | --initialSeed INITIALSEED --saveFinalConf |
| 9 | --saveEvolution]] |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 10 | |
Adrià Vilanova Martínez | 24d8701 | 2022-06-16 00:29:59 +0200 | [diff] [blame^] | 11 | the results file will be saved at "data_out/{{outFilePrefix}}.res" |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 12 | |
| 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ínez | 1ee4edb | 2022-06-13 22:37:08 +0200 | [diff] [blame] | 26 | --saveFinalConf save a file with the configuration which |
| 27 | belongs to the last Montecarlo iteration. |
Adrià Vilanova Martínez | 24d8701 | 2022-06-16 00:29:59 +0200 | [diff] [blame^] | 28 | 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ínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 33 | END |
| 34 | } |
| 35 | |
| 36 | if (( "$#" < 2 )); then |
| 37 | usage |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 41 | T="$1" |
| 42 | L="$2" |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 43 | defaultOutFilePrefix="L$L-T$T" |
| 44 | outFilePrefix="${3:-$defaultOutFilePrefix}" |
Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 45 | |
Adrià Vilanova Martínez | 24d8701 | 2022-06-16 00:29:59 +0200 | [diff] [blame^] | 46 | opts=$(getopt -l "help,skipIfComputed,nSeeds:,mcTot:,mcIni:,mcD:,initialSeed:,saveFinalConf,saveEvolution" -o "hsn:m:i:d:" -n "$progname" -- "${@:4}") |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 47 | eval set -- "$opts" |
| 48 | |
| 49 | skipIfComputed=false |
| 50 | nSeeds=150 |
| 51 | mcTot=40000 |
| 52 | mcIni=2000 |
| 53 | mcD=20 |
| 54 | initialSeed=117654 |
Adrià Vilanova Martínez | 1ee4edb | 2022-06-13 22:37:08 +0200 | [diff] [blame] | 55 | saveFinalConf=F |
Adrià Vilanova Martínez | 24d8701 | 2022-06-16 00:29:59 +0200 | [diff] [blame^] | 56 | saveEvolution=F |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 57 | |
| 58 | while 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ínez | 1ee4edb | 2022-06-13 22:37:08 +0200 | [diff] [blame] | 88 | --saveFinalConf) |
| 89 | saveFinalConf=T |
| 90 | shift |
| 91 | ;; |
Adrià Vilanova Martínez | 24d8701 | 2022-06-16 00:29:59 +0200 | [diff] [blame^] | 92 | --saveEvolution) |
| 93 | saveEvolution=T |
| 94 | shift |
| 95 | ;; |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 96 | *) break ;; |
| 97 | esac |
| 98 | done |
| 99 | |
| 100 | if [ "$skipIfComputed" == "true" ] && [ -f "data_out/${outFilePrefix}.res" ]; then |
Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 101 | echo "Skipping computation for L=$L, T=$T (.res file already exists)" |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 102 | exit |
Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 103 | fi |
| 104 | |
| 105 | echo "Starting computation for L=$L, T=$T" |
| 106 | |
| 107 | cat <<EOF | ./out/mc2 |
| 108 | &DADES |
| 109 | L=$L, |
| 110 | NOM="$outFilePrefix", |
| 111 | TEMP=$T, |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 112 | NSEED=$nSeeds, |
| 113 | SEED0=$initialSeed, |
| 114 | MCTOT=$mcTot, |
| 115 | MCINI=$mcIni, |
| 116 | MCD=$mcD |
Adrià Vilanova Martínez | 1ee4edb | 2022-06-13 22:37:08 +0200 | [diff] [blame] | 117 | SAVEFINALCONF=$saveFinalConf |
Adrià Vilanova Martínez | 24d8701 | 2022-06-16 00:29:59 +0200 | [diff] [blame^] | 118 | SAVEEVOLUTION=$saveEvolution |
Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 119 | &END |
| 120 | EOF |