#!/bin/bash
# function set_namelist
# input variable value
# output namelist

# function to find namelists parameters
supergrep () {
            grep "^ *$1 *=" $2 | sed -e "s% *\!.*%%"
    }

# USAGE : if you want to add a string with " : ./test var_name \"new_value\"
# function to set namelists parameters
set_namelist () {
     VAR_NAME=$( supergrep $1 ${INPUT_DIR}/namelist )
     sed -e "s/${VAR_NAME}/$1=$2/"  ${INPUT_DIR}/namelist > ${INPUT_DIR}/namelist.tmp
     mv ${INPUT_DIR}/namelist.tmp ${INPUT_DIR}/namelist
}
