Ignore:
Timestamp:
Oct 24, 2024, 4:25:39 PM (5 weeks ago)
Author:
abarral
Message:

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

File:
1 edited

Legend:

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

    r4554 r5271  
    11#!/bin/bash
    2 #set -xv
     2set -eu
    33
    44# sanity check: do we have the required argument ?
    5 if (( $# < 1 )) || (( $# > 3 ))
    6 then
     5if (( $# < 1 )) || (( $# > 3 )); then
    76    echo "Wrong number of parameters in $0 !!!"
    87    echo " Usage:"
     
    1211fi
    1312
    14 if ( (( $1 % 8 != 0 )) && (( $# == 3 )) || (( $1 == 1 )) )
    15 then
     13if ( (( $1 % 8 != 0 )) && (( $# == 3 )) || (( $1 == 1 )) ); then
    1614    echo "The number of longitudes must be a multiple of 8."
    1715    echo "See the files dyn3d/groupe.F and dyn3dmem/groupe_loc.F."
     
    2018
    2119# build "fichnom", the relevant 'dimensions.im.jm.lm' file name
    22 for i in $*
    23 do
    24     list=$list.$i
    25 done
     20list=""
     21for i in "$@"; do list=$list.$i; done
    2622fichdim=dimensions${list}
    2723
    28 if [ ! -f $fichdim ]
    29 then
    30 #    echo "$fichdim does not exist"
    31 
     24if [[ ! -f $fichdim ]]; then
    3225    # assign values of im, jm and lm
    33     if [ $# -ge 3 ]
    34     then
     26    if [ $# -ge 3 ]; then
    3527        im=$1
    3628        jm=$2
    3729        lm=$3
    3830        ndm=1
    39     elif [ $# -ge 2 ]
    40     then
     31    elif [ $# -ge 2 ]; then
    4132        im=1
    4233        jm=$1
    4334        lm=$2
    4435        ndm=1
    45     elif [ $# -ge 1 ]
    46     then
     36    elif [ $# -ge 1 ]; then
    4737        im=1
    4838        jm=1
     
    5242
    5343# since the file doesn't exist, we create it
    54     cat << EOF > $fichdim
    55 !-----------------------------------------------------------------------
    56 !   INCLUDE 'dimensions.h'
    57 !
    58 !   dimensions.h contient les dimensions du modele
    59 !   ndm est tel que iim=2**ndm
    60 !-----------------------------------------------------------------------
     44    cat << EOF > "$fichdim"
     45! This module was automatically generated during the installation of LMDZ
     46! It contains the spatial resolution of the model
    6147
    62       INTEGER iim,jjm,llm,ndm
     48MODULE dimensions_mod
     49  IMPLICIT NONE; PRIVATE
     50  PUBLIC iim, jjm, llm, ndm
     51  ! ndm is computed such that iim=2**ndm
    6352
    64       PARAMETER (iim= $im,jjm=$jm,llm=$lm,ndm=$ndm)
    65 
    66 !-----------------------------------------------------------------------
     53  INTEGER, PARAMETER :: iim = $im, jjm = $jm, llm = $lm, ndm = $ndm
     54END MODULE dimensions_mod
    6755EOF
    68 
    6956fi
    7057
    71 # remove 'old' dimensions.h file (if any) and replace it with new one
    72 if [ -f ../dimensions.h ] ; then
    73     \rm ../dimensions.h
     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
    7461fi
    75 tar cf - $fichdim | ( cd .. ; tar xf - ; mv $fichdim dimensions.h )
    76 # line above is a trick to preserve time of creation of dimensions.h files
     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 TracChangeset for help on using the changeset viewer.