source: LMDZ6/trunk/libf/grid/dimension/makdim @ 5450

Last change on this file since 5450 was 5271, checked in by abarral, 2 months ago

Move dimensions.h into a module
Nb: doesn't compile yet

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1#!/bin/bash
2set -eu
3
4# sanity check: do we have the required argument ?
5if (( $# < 1 )) || (( $# > 3 )); then
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
11fi
12
13if ( (( $1 % 8 != 0 )) && (( $# == 3 )) || (( $1 == 1 )) ); then
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
17fi
18
19# build "fichnom", the relevant 'dimensions.im.jm.lm' file name
20list=""
21for i in "$@"; do list=$list.$i; done
22fichdim=dimensions${list}
23
24if [[ ! -f $fichdim ]]; then
25    # assign values of im, jm and lm
26    if [ $# -ge 3 ]; then
27        im=$1
28        jm=$2
29        lm=$3
30        ndm=1
31    elif [ $# -ge 2 ]; then
32        im=1
33        jm=$1
34        lm=$2
35        ndm=1
36    elif [ $# -ge 1 ]; then
37        im=1
38        jm=1
39        lm=$1
40        ndm=1
41    fi
42
43# since the file doesn't exist, we create it
44    cat << EOF > "$fichdim"
45! This module was automatically generated during the installation of LMDZ
46! It contains the spatial resolution of the model
47
48MODULE dimensions_mod
49  IMPLICIT NONE; PRIVATE
50  PUBLIC iim, jjm, llm, ndm
51  ! ndm is computed such that iim=2**ndm
52
53  INTEGER, PARAMETER :: iim = $im, jjm = $jm, llm = $lm, ndm = $ndm
54END MODULE dimensions_mod
55EOF
56fi
57
58# remove 'old' dimensions_mod.f90 file (if any) and replace it with new one
59if [[ -f ../dimensions_mod.f90 ]]; then
60    rm ../dimensions_mod.f90
61fi
62tar cf - "$fichdim" | ( cd .. ; tar xf - ; mv "$fichdim" dimensions_mod.f90 )
63# line above is a trick to preserve time of creation of dimensions_mod.f90 files
Note: See TracBrowser for help on using the repository browser.