source: LMDZ6/trunk/libf/phylmd/ecrad/test/common/change_namelist.sh @ 4773

Last change on this file since 4773 was 4773, checked in by idelkadi, 6 months ago
  • Update of Ecrad in LMDZ The same organization of the Ecrad offline version is retained in order to facilitate the updating of Ecrad in LMDZ and the comparison between online and offline results. version 1.6.1 of Ecrad (https://github.com/lguez/ecrad.git)
  • Implementation of the double call of Ecrad in LMDZ


  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#!/bin/bash
2#
3# (C) Copyright 2014- ECMWF.
4#
5# This software is licensed under the terms of the Apache Licence Version 2.0
6# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
7#
8# In applying this licence, ECMWF does not waive the privileges and immunities
9# granted to it by virtue of its status as an intergovernmental organisation
10# nor does it submit to any jurisdiction.
11
12# Change entries in a Fortran namelist file
13# Usage: change_namelist.sh infile.nam outfile.nam key1=value1 key2=value2 ...
14
15INFILE=$1
16OUTFILE=$2
17shift
18shift
19
20SEDLINE=""
21while [ "$1" ]
22do
23    FOUND=$(echo $1 | grep '=')
24    if [ ! "$FOUND" ]
25    then
26        echo "Error in $0: argument '$1' not of the form key=value"
27        exit 1
28    fi
29    KEY=$(echo $1 | awk -F= '{print $1}')
30    VALUE=$(echo $1 | awk -F= '{print $2}')
31    FOUND=$(grep $KEY $INFILE)
32    if [ ! "$FOUND" ]
33    then
34        echo "Error: $KEY not found in $INFILE"
35        exit 1
36    fi
37
38    SEDLINE="$SEDLINE -e s|^[[:space:]!]*"$KEY".*|"$KEY"="$VALUE",|"
39    shift
40done
41echo sed $SEDLINE $INFILE ">" $OUTFILE
42sed $SEDLINE $INFILE > $OUTFILE
Note: See TracBrowser for help on using the repository browser.