| #!/bin/bash |
| progname=$0 |
| function usage() { |
| cat <<END |
| |
| Usage: $progname T L [outFilePrefix [--help --skipIfComputed |
| --nSeeds NSEEDS --mcTot MCTOT --mcIni MCINI --mcD MCD |
| --initialSeed INITIALSEED --saveFinalConf |
| --saveEvolution]] |
| |
| the results file will be saved at "data_out/{{outFilePrefix}}.res" |
| |
| optional arguments: |
| -h, --help show this help message and exit. |
| -s, --skipIfComputed skip if the output file already exists. |
| -n, --nSeeds number of seeds which will be used for the |
| simulation. |
| -m, --mcTot number of iterations which will be performed |
| in the simulation for each seed. |
| -i, --mcIni number of iterations before the program |
| starts measuring physical properties of the |
| system. |
| -d, --mcD the program will measure the physical |
| properties when iteration % MCD == 0. |
| --initialSeed initial seed for the Monte Carlo algorithm. |
| --saveFinalConf save a file with the configuration which |
| belongs to the last Montecarlo iteration. |
| It will be saved at |
| "data_out/{{outFilePrefix}}.conf". |
| --saveEvolution save a file with the temporary evolution |
| of the simulation. It will be saved at |
| "data_out/{{outFilePrefix}}.ev" |
| END |
| } |
| |
| if (( "$#" < 2 )); then |
| usage |
| exit 1 |
| fi |
| |
| T="$1" |
| L="$2" |
| defaultOutFilePrefix="L$L-T$T" |
| outFilePrefix="${3:-$defaultOutFilePrefix}" |
| |
| opts=$(getopt -l "help,skipIfComputed,nSeeds:,mcTot:,mcIni:,mcD:,initialSeed:,saveFinalConf,saveEvolution" -o "hsn:m:i:d:" -n "$progname" -- "${@:4}") |
| eval set -- "$opts" |
| |
| skipIfComputed=false |
| nSeeds=150 |
| mcTot=40000 |
| mcIni=2000 |
| mcD=20 |
| initialSeed=117654 |
| saveFinalConf=F |
| saveEvolution=F |
| |
| while true; do |
| case "$1" in |
| -h | --help) |
| usage |
| exit |
| ;; |
| -s | --skipIfComputed) |
| skipIfComputed=true |
| shift |
| ;; |
| -n | --nSeeds) |
| nSeeds="$2" |
| shift 2 |
| ;; |
| -m | --mcTot) |
| mcTot="$2" |
| shift 2 |
| ;; |
| -i | --mcIni) |
| mcIni="$2" |
| shift 2 |
| ;; |
| -d | --mcD) |
| mcD="$2" |
| shift 2 |
| ;; |
| --initialSeed) |
| initialSeed="$2" |
| shift 2 |
| ;; |
| --saveFinalConf) |
| saveFinalConf=T |
| shift |
| ;; |
| --saveEvolution) |
| saveEvolution=T |
| shift |
| ;; |
| *) break ;; |
| esac |
| done |
| |
| if [ "$skipIfComputed" == "true" ] && [ -f "data_out/${outFilePrefix}.res" ]; then |
| echo "Skipping computation for L=$L, T=$T (.res file already exists)" |
| exit |
| fi |
| |
| echo "Starting computation for L=$L, T=$T" |
| |
| cat <<EOF | ./out/mc2 |
| &DADES |
| L=$L, |
| NOM="$outFilePrefix", |
| TEMP=$T, |
| NSEED=$nSeeds, |
| SEED0=$initialSeed, |
| MCTOT=$mcTot, |
| MCINI=$mcIni, |
| MCD=$mcD |
| SAVEFINALCONF=$saveFinalConf |
| SAVEEVOLUTION=$saveEvolution |
| &END |
| EOF |