source:
branches/nemo_v3_3_beta/NEMOGCM/SETTE/all_functions.sh
@
2500
Last change on this file since 2500 was 2500, checked in by flavoni, 13 years ago | |
---|---|
|
|
File size: 1.5 KB |
Rev | Line | |
---|---|---|
[2359] | 1 | #!/bin/bash |
2 | ###################################################### | |
3 | # Author : Simona Flavoni for NEMO | |
4 | # Contact : sflod@locean-ipsl.upmc.fr | |
5 | # | |
6 | # Some scripts called by sette.sh | |
7 | # all_functions.sh : all functions used by sette.sh | |
8 | ###################################################### | |
9 | #set -x | |
10 | set -o posix | |
11 | #set -u | |
12 | #set -e | |
13 | #+ | |
14 | # | |
15 | # ================ | |
16 | # all_functions.sh | |
17 | # ================ | |
18 | # | |
19 | # ---------------------------------------------- | |
20 | # Set of functions used by sette.sh (NEMO tests) | |
21 | # ---------------------------------------------- | |
22 | # | |
23 | # SYNOPSIS | |
24 | # ======== | |
25 | # | |
26 | # :: | |
27 | # | |
[2494] | 28 | # $ ./set_namelist.sh INPUT_NAMELIST VARIABLE VALUE |
[2359] | 29 | # |
30 | # | |
31 | # DESCRIPTION | |
32 | # =========== | |
33 | # | |
[2494] | 34 | # function superegrep |
35 | # input variable value | |
[2500] | 36 | # |
[2359] | 37 | # function set_namelist |
[2494] | 38 | # input namelist_name variable value |
[2359] | 39 | # output namelist |
[2500] | 40 | # |
41 | # EXAMPLES | |
42 | # ======== | |
43 | # | |
44 | # :: | |
45 | # | |
46 | # $ ./set_namelist.sh namelist nn_itend 75 | |
47 | # $ ./set_namelist.sh namelist_ice_lim2 cn_icerst_in \"00101231_restart_icemod\" | |
48 | # | |
49 | # | |
50 | # TODO | |
51 | # ==== | |
52 | # | |
53 | # option debug | |
54 | # | |
55 | # | |
56 | # EVOLUTIONS | |
57 | # ========== | |
58 | # | |
59 | # $Id$ | |
60 | # | |
61 | # * creation | |
[2359] | 62 | |
[2500] | 63 | |
[2359] | 64 | # function to find namelists parameters |
65 | supergrep () { | |
66 | grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%" | |
67 | } | |
68 | ||
[2494] | 69 | usage=" Usage : set_namelist input_namelist variable_name value" |
70 | usage=" if value is a string ths is neede syntax : ./set_namelist namelist_name var_name \"new_value\" | |
71 | ||
[2359] | 72 | # function to set namelists parameters |
73 | set_namelist () { | |
[2500] | 74 | VAR_NAME=$( supergrep $2 ${INPUT_DIR}/$1 ) |
75 | sed -e "s/${VAR_NAME}/$2=$3/" ${INPUT_DIR}/$1 > ${INPUT_DIR}/$1.tmp | |
76 | mv ${INPUT_DIR}/$1.tmp ${INPUT_DIR}/$1 | |
[2359] | 77 | } |
Note: See TracBrowser
for help on using the repository browser.