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 @ 2715

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

commit sette.sh ready to test 3 reference configuration: GYRE_LOBSTER, ORCA2_LIM_PISCES, POMME. (restartability and reproductibility tests), see ticket #752

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 2.8 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
[2675]51#  $ ./set_namelist.sh namelist_ice_lim2 cn_icerst_in  \"00101231_restart_ice\"
[2500]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
[2637]88   if [  ! -f ${SETTE_DIR}/output.sette ] ; then
[2545]89                touch ${SETTE_DIR}/output.sette
90        fi
[2562]91
[2545]92        echo "executing script : set_namelist $@" >> ${SETTE_DIR}/output.sette
93        echo "################" >> ${SETTE_DIR}/output.sette
94     
[2511]95   VAR_NAME=$( supergrep $2 ${INPUT_DIR}/$1 )
[2637]96   if [ ${#VAR_NAME} -eq 0 ] 
97   then
98      echo "doing \"set_namelist $@\". "
99      echo "variable: \"$2\" is empty"
100      echo "control that variable $2 is in \"${INPUT_DIR}/$1\" "
101      echo "exit"
102      echo "error in executing script : set_namelist $@" >> ${SETTE_DIR}/output.sette
103      echo "....." >> ${SETTE_DIR}/output.sette
104      exit 1
105   fi
[2583]106        sed -e "s/${VAR_NAME}.*/${VAR_NAME}/" ${INPUT_DIR}/$1 > ${INPUT_DIR}/$1.tmp
107        mv ${INPUT_DIR}/$1.tmp ${INPUT_DIR}/$1
108        sed -e "s/${VAR_NAME}/$2=$3/"  ${INPUT_DIR}/$1 > ${INPUT_DIR}/$1.tmp
109        mv ${INPUT_DIR}/$1.tmp ${INPUT_DIR}/$1
110
[2545]111        echo "finished script : set_namelist $@" >> ${SETTE_DIR}/output.sette
112        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
113        echo "                " >> ${SETTE_DIR}/output.sette
[2359]114}
Note: See TracBrowser for help on using the repository browser.