[1605] | 1 | #!/bin/bash |
---|
[5159] | 2 | set -eu |
---|
[1605] | 3 | |
---|
| 4 | # sanity check: do we have the required argument ? |
---|
[5159] | 5 | if (( $# < 1 )) || (( $# > 3 )); then |
---|
[2202] | 6 | echo "Wrong number of parameters in $0 !!!" |
---|
| 7 | echo " Usage:" |
---|
| 8 | echo " $0 [im] [jm] lm" |
---|
| 9 | echo " where im, jm and lm are the dimensions" |
---|
| 10 | exit 1 |
---|
[1605] | 11 | fi |
---|
| 12 | |
---|
[5159] | 13 | if ( (( $1 % 8 != 0 )) && (( $# == 3 )) || (( $1 == 1 )) ); then |
---|
[2202] | 14 | echo "The number of longitudes must be a multiple of 8." |
---|
| 15 | echo "See the files dyn3d/groupe.F and dyn3dmem/groupe_loc.F." |
---|
| 16 | exit 1 |
---|
| 17 | fi |
---|
| 18 | |
---|
[1605] | 19 | # build "fichnom", the relevant 'dimensions.im.jm.lm' file name |
---|
[5159] | 20 | list="" |
---|
| 21 | for i in "$@"; do list=$list.$i; done |
---|
[1146] | 22 | fichdim=dimensions${list} |
---|
[524] | 23 | |
---|
[5159] | 24 | if [[ ! -f $fichdim ]]; then |
---|
[1605] | 25 | # assign values of im, jm and lm |
---|
[5159] | 26 | if [ $# -ge 3 ]; then |
---|
[1605] | 27 | im=$1 |
---|
| 28 | jm=$2 |
---|
| 29 | lm=$3 |
---|
| 30 | ndm=1 |
---|
[5159] | 31 | elif [ $# -ge 2 ]; then |
---|
[1605] | 32 | im=1 |
---|
| 33 | jm=$1 |
---|
| 34 | lm=$2 |
---|
| 35 | ndm=1 |
---|
[5159] | 36 | elif [ $# -ge 1 ]; then |
---|
[1605] | 37 | im=1 |
---|
| 38 | jm=1 |
---|
| 39 | lm=$1 |
---|
| 40 | ndm=1 |
---|
[1604] | 41 | fi |
---|
[524] | 42 | |
---|
[1605] | 43 | # since the file doesn't exist, we create it |
---|
[5159] | 44 | cat << EOF > "$fichdim" |
---|
| 45 | ! This module was automatically generated during the installation of LMDZ |
---|
| 46 | ! It contains the spatial resolution of the model |
---|
[5099] | 47 | |
---|
[5159] | 48 | MODULE lmdz_dimensions |
---|
| 49 | IMPLICIT NONE; PRIVATE |
---|
| 50 | PUBLIC iim, jjm, llm, ndm |
---|
| 51 | ! ndm is computed such that iim=2**ndm |
---|
[764] | 52 | |
---|
[5159] | 53 | INTEGER, PARAMETER :: iim = $im, jjm = $jm, llm = $lm, ndm = $ndm |
---|
| 54 | END MODULE lmdz_dimensions |
---|
[764] | 55 | EOF |
---|
[1605] | 56 | fi |
---|
| 57 | |
---|
[5159] | 58 | # remove 'old' lmdz_dimensions.f90 file (if any) and replace it with new one |
---|
| 59 | if [[ -f ../lmdz_dimensions.f90 ]]; then |
---|
| 60 | rm ../lmdz_dimensions.f90 |
---|
[1605] | 61 | fi |
---|
[5159] | 62 | tar cf - "$fichdim" | ( cd .. ; tar xf - ; mv "$fichdim" lmdz_dimensions.f90 ) |
---|
| 63 | # line above is a trick to preserve time of creation of lmdz_dimensions.f90 files |
---|