New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
all_functions.sh in trunk/NEMOGCM/SETTE – NEMO

source: trunk/NEMOGCM/SETTE/all_functions.sh @ 2546

Last change on this file since 2546 was 2546, checked in by flavoni, 13 years ago

change test in fcm_job.sh, see ticket #752

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 2.7 KB
RevLine 
[2359]1######################################################
2# Author : Simona Flavoni for NEMO
3# Contact : sflod@locean-ipsl.upmc.fr
4#
[2546]5# ----------------------------------------------------------------------
6# NEMO/SETTE , NEMO Consortium (2010)
7# Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
8# ----------------------------------------------------------------------
9#
[2359]10# Some scripts called by sette.sh
11# all_functions.sh   : all functions used by sette.sh 
12######################################################
13#set -x
14set -o posix
15#set -u
16#set -e
17#+
18#
19# ================
20# all_functions.sh
21# ================
22#
23# ----------------------------------------------
24# Set of functions used by sette.sh (NEMO tests)
25# ----------------------------------------------
26#
27# SYNOPSIS
28# ========
29#
30# ::
31#
[2494]32#  $ ./set_namelist.sh INPUT_NAMELIST VARIABLE VALUE
[2359]33#
34#
35# DESCRIPTION
36# ===========
37#
[2494]38# function superegrep
[2545]39#   input variable value
[2500]40#
[2359]41# function set_namelist
[2545]42#   input namelist_name variable value
43#   output namelist
[2500]44#
45# EXAMPLES
46# ========
47#
48# ::
49#
50#  $ ./set_namelist.sh namelist          nn_itend        75
51#  $ ./set_namelist.sh namelist_ice_lim2 cn_icerst_in  \"00101231_restart_icemod\"
52#
53#
54# TODO
55# ====
56#
57# option debug
58#
59#
60# EVOLUTIONS
61# ==========
62#
63# $Id$
64#
65#   * creation
[2507]66#-
67#
[2359]68
[2500]69
[2359]70# function to find namelists parameters
71supergrep () {
72            grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
73    }
74
[2494]75usage=" Usage : set_namelist input_namelist variable_name value"
[2510]76usage=" if value is a string ths is neede syntax : ./set_namelist namelist_name var_name \"new_value\" "
[2494]77
[2359]78# function to set namelists parameters
79set_namelist () {
[2511]80   minargcount=3
[2545]81   if [ ${#} -lt ${minargcount} ]
82   then
83      echo "not enought arguments for set_namelist"
[2511]84      echo "${usage}"
85      exit 1
[2545]86   fi
[2511]87   unset minargcount
[2545]88   if [  -f ${SETTE_DIR}/output.sette ] ; then
89         echo "file output already present. Append comments"
90                echo "`ls ${SETTE_DIR}/output.sette`"
91        else
92                echo "file output not present"
93                touch ${SETTE_DIR}/output.sette
94                echo "`ls ${SETTE_DIR}/output.sette`"
95        fi
96        echo "executing script : set_namelist $@" >> ${SETTE_DIR}/output.sette
97        echo "################" >> ${SETTE_DIR}/output.sette
98     
[2511]99   VAR_NAME=$( supergrep $2 ${INPUT_DIR}/$1 )
100      sed -e "s/${VAR_NAME}/$2=$3/"  ${INPUT_DIR}/$1 > ${INPUT_DIR}/$1.tmp
101      mv ${INPUT_DIR}/$1.tmp ${INPUT_DIR}/$1
[2545]102   
103   if [  -f ${INPUT_DIR}/$1 ] ; then
104         echo "namelist not empty: ok"
105        else
106      echo "some problems in sed namelist: exit"
107      exit 1
108        fi
109        echo "finished script : set_namelist $@" >> ${SETTE_DIR}/output.sette
110        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
111        echo "                " >> ${SETTE_DIR}/output.sette
[2359]112}
Note: See TracBrowser for help on using the repository browser.