Changeset 1605


Ignore:
Timestamp:
Jan 2, 2012, 2:48:17 PM (12 years ago)
Author:
Ehouarn Millour
Message:

Fixed problematic if/elif sequence in "makdim" script. Also did some cleanup and added some tests and comments.
EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ5/trunk/libf/grid/dimension/makdim

    r1604 r1605  
     1#!/bin/bash
     2#set -xv
     3
     4# sanity check: do we have the required argument ?
     5if (( $# < 1 )) || (( $# > 3 ))
     6then
     7 echo "Wrong number of parameters in $0 !!!"
     8 echo " Usage:"
     9 echo "  $0 [im] [jm] lm"
     10 echo " where im, jm and lm are the dimensions"
     11 exit
     12fi
     13
     14# build "fichnom", the relevant 'dimensions.im.jm.lm' file name
    115for i in $*
    216  do
     
    721if [ ! -f $fichdim ]
    822    then
    9 # si le fichier de dimensions n'existe pas, on le cree
     23#    echo "$fichdim does not exist"
    1024
     25    # assign values of im, jm and lm
    1126    if [ $# -ge 3 ]
    12         then
    13         im=$1
    14         jm=$2
    15         lm=$3
    16         n2=$1
    17         ndm=1
     27        then
     28        im=$1
     29        jm=$2
     30        lm=$3
     31        ndm=1
     32    elif [ $# -ge 2 ]
     33        then
     34        im=1
     35        jm=$1
     36        lm=$2
     37        ndm=1
     38    elif [ $# -ge 1 ]
     39        then
     40        im=1
     41        jm=1
     42        lm=$1
     43        ndm=1
     44    fi
    1845
    19 # Le test suivant est commente car il est inutile avec le nouveau
    20 # filtre filtrez. Attention avec le "vieux" filtre (F. Forget,11/1994)
    21 #
    22 #     while [ "$n2" -gt 2 ]; do
    23 #       n2=`expr $n2 / 2`
    24 #       ndm=`expr $ndm + 1`
    25 #       echo $n2
    26 #    done
    27 #    if [ "$n2" != 2 ] ; then
    28 #       echo le nombre de longitude doit etre une puissance de 2
    29 #       exit
    30 #    fi
    31 
    32 
    33     else if [ $# -ge 2 ]
    34         then
    35         im=1
    36         jm=$1
    37         lm=$2
    38         ndm=1
    39     else if [ $# -ge 1 ]
    40         then
    41         im=1
    42         jm=1
    43         lm=$1
    44         ndm=1
    45     else
    46         echo il faut au moins une dimension
    47         exit
    48     fi
    49 fi
    50 
     46# since the file doesn't exist, we create it
    5147cat << EOF > $fichdim
    5248!-----------------------------------------------------------------------
     
    6460EOF
    6561
     62fi
     63
     64# remove 'old' dimensions.h file (if any) and replace it with new one
     65if [ -f ../dimensions.h ] ; then
    6666\rm ../dimensions.h
     67fi
    6768tar cf - $fichdim | ( cd .. ; tar xf - ; mv $fichdim dimensions.h )
     69# line above is a trick to preserve time of creation of dimensions.h files
Note: See TracChangeset for help on using the changeset viewer.