Ignore:
Timestamp:
2013-11-04T12:51:55+01:00 (8 years ago)
Author:
cetlod
Message:

merge in dev_LOCEAN_2013, the 1st development branch dev_r3853_CNRS9_Confsetting, from its starting point ( r3853 ) on the trunk: see ticket #1169

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2013/dev_LOCEAN_2013/NEMOGCM/SETTE/all_functions.sh

    r3294 r4147  
    111111   if [ ${#VAR_NAME} -eq 0 ]  
    112112   then 
    113       echo "doing \"set_namelist $@\". " 
    114       echo "variable: \"$2\" is empty" 
    115       echo "control that variable $2 is in \"${EXE_DIR}/$1\" " 
    116       echo "exit" 
    117       echo "error in executing script : set_namelist $@" >> ${SETTE_DIR}/output.sette 
    118       echo "....." >> ${SETTE_DIR}/output.sette 
    119       exit 1 
     113      echo "doing \"set_namelist $@\". "  >> ${SETTE_DIR}/output.sette 
     114      echo "variable: \"$2\" not found in \"${EXE_DIR}/$1\" "  >> ${SETTE_DIR}/output.sette 
     115                NAMREF=$( basename $1 _cfg )_ref 
     116      echo "doing more : search in ${EXE_DIR}/$NAMREF " >> ${SETTE_DIR}/output.sette 
     117                VAR_NAME=$( supergrep $2 ${EXE_DIR}/$NAMREF ) 
     118           if [ ${#VAR_NAME} -eq 0 ]  
     119           then 
     120                    echo " variable $VAR_NAME not found in ${EXE_DIR}/$1 nor in ${EXE_DIR}/$NAMREF " 
     121                    echo " check your variable name " 
     122            echo "exit" 
     123            echo "error in executing script : set_namelist $@" >> ${SETTE_DIR}/output.sette 
     124            echo "....." >> ${SETTE_DIR}/output.sette 
     125            exit 1 
     126                fi 
     127                LINEVAR=$( grep -s -n "$VAR_NAME" ${EXE_DIR}/$NAMREF | awk -F: '{ { print $1} }' ) 
     128                echo " $VAR_NAME found in ${EXE_DIR}/$NAMREF at line $LINEVAR " >> ${SETTE_DIR}/output.sette 
     129#   search for namelist group name 
     130                NAMGRP=$( head -n$LINEVAR ${EXE_DIR}/$NAMREF | grep --line-buffered "^&nam" | tail -1 | awk -F" " '{ { print $1} }' )  
     131                echo " variable $VAR_NAME will be added in $NAMGRP namelist-group of namelist file ${EXE_DIR}/$1 " >> ${SETTE_DIR}/output.sette 
     132# Add $VARNAME in namelist file ${EXE_DIR}/$1 in namelist group $NAMGRP 
     133# on mac osx, replace sed --posix by gsed (available with mac port) 
     134set -vx  
     135                sed --posix "/${NAMGRP} /a\ ${VAR_NAME} " ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp || gsed --posix "/${NAMGRP} /a\ ${VAR_NAME} " ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp 
     136set +vx 
     137# if file not empty replace ${EXE_DIR}/$1 
     138                if [ -s ${EXE_DIR}/$1.tmp ] ; then 
     139                   mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1  
     140                else 
     141                echo "file ${EXE_DIR}/$1.tmp is empty. sed command went wrong "; exit 200 
     142                fi 
    120143   fi 
     144 
    121145        sed -e "s:${VAR_NAME}.*:${VAR_NAME}:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp 
    122146        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1 
     
    151175################################################################ 
    152176# SMALL DEBUG 
     177    if [ ! -r ${EXE_DIR}/ocean.output ] 
     178        then 
     179        grep "E R R O R" ${EXE_DIR}/ocean.output && echo "Some ERRORS at execution time, see ${EXE_DIR}/ocean.output" 
     180        exit 2 
     181    fi 
     182 
    153183    if [ ! -r ${EXE_DIR}/time.step ] 
    154184        then 
     
    158188    else 
    159189        echo "file time.step exists"  >> ${SETTE_DIR}/output.sette 
    160         echo "ok model run"   >> ${SETTE_DIR}/output.sette 
    161     fi 
     190        echo "execution of model time step loop started"   >> ${SETTE_DIR}/output.sette 
     191    fi 
     192 
    162193################################################################ 
    163194 
     
    191222    echo "saving ocean & ice output, solver.stat, tracer.stat files ...." >> ${SETTE_DIR}/output.sette 
    192223    echo "            " >> ${SETTE_DIR}/output.sette 
    193     [ -f ${EXE_DIR}/*ocean.output ] && cp ${EXE_DIR}/*ocean.output ${NEMO_VALID}/. 
    194     [ -f ${EXE_DIR}/*solver.stat ] && cp ${EXE_DIR}/*solver.stat ${NEMO_VALID}/. 
    195     [ -f ${EXE_DIR}/*tracer.stat ] && cp ${EXE_DIR}/*tracer.stat ${NEMO_VALID}/. 
     224    [ -f ${EXE_DIR}/ocean.output ] && cp ${EXE_DIR}/*ocean.output ${NEMO_VALID}/. 
     225    [ -f ${EXE_DIR}/solver.stat ] && cp ${EXE_DIR}/*solver.stat ${NEMO_VALID}/. 
     226    [ -f ${EXE_DIR}/output.namelist.dyn ] && cp ${EXE_DIR}/*output.nam* ${NEMO_VALID}/. 
     227    [ -f ${EXE_DIR}/tracer.stat ] && cp ${EXE_DIR}/*tracer.stat ${NEMO_VALID}/. 
     228 
    196229    if [ -n "$(ls ${NEMO_VALID}/*solver*)" ] ; then 
    197230   echo "moved solver.stat in ${NEMO_VALID} directory"  >> ${SETTE_DIR}/output.sette 
Note: See TracChangeset for help on using the changeset viewer.