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 |
| 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. |
| 25 | END |
| 26 | } |
| 27 | |
| 28 | if (( "$#" < 2 )); then |
| 29 | usage |
| 30 | exit 1 |
| 31 | fi |
| 32 | |
Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 33 | T="$1" |
| 34 | L="$2" |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 35 | defaultOutFilePrefix="L$L-T$T" |
| 36 | outFilePrefix="${3:-$defaultOutFilePrefix}" |
Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 37 | |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 38 | opts=$(getopt -l "help,skipIfComputed,nSeeds:,mcTot:,mcIni:,mcD:,initialSeed:" -o "hsn:m:i:d:" -n "$progname" -- "${@:4}") |
| 39 | eval set -- "$opts" |
| 40 | |
| 41 | skipIfComputed=false |
| 42 | nSeeds=150 |
| 43 | mcTot=40000 |
| 44 | mcIni=2000 |
| 45 | mcD=20 |
| 46 | initialSeed=117654 |
| 47 | |
| 48 | while 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 |
| 80 | done |
| 81 | |
| 82 | if [ "$skipIfComputed" == "true" ] && [ -f "data_out/${outFilePrefix}.res" ]; then |
Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 83 | 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] | 84 | exit |
Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 85 | fi |
| 86 | |
| 87 | echo "Starting computation for L=$L, T=$T" |
| 88 | |
| 89 | cat <<EOF | ./out/mc2 |
| 90 | &DADES |
| 91 | L=$L, |
| 92 | NOM="$outFilePrefix", |
| 93 | TEMP=$T, |
Adrià Vilanova Martínez | d2f8c71 | 2022-06-05 22:41:03 +0200 | [diff] [blame] | 94 | NSEED=$nSeeds, |
| 95 | SEED0=$initialSeed, |
| 96 | MCTOT=$mcTot, |
| 97 | MCINI=$mcIni, |
| 98 | MCD=$mcD |
Adrià Vilanova Martínez | c102e96 | 2022-06-04 23:53:44 +0200 | [diff] [blame] | 99 | &END |
| 100 | EOF |