#!/bin/bash # set -vx # gpdebug : a virer ######## # prend en argument le path et le nom d'un fichier param (argument de la commande # ccc_archive avec option ipsl_pack) # ex : ./find_directory_simul.job fichier_param_test1.txt liste_fichier_dmnfs # ex : find_directory_simul.job param_SL.txt /cscratch/cont003/labetoul/FROM_CCRT_INFORMATIONS_DMNFS/information_dmnfs_2012-03-21 #------------------------------- # A modifier avant utilisation : #-------------------------------- LISTE_SIMUL=${1} LISTE_DMNFS=${2} echo $LISTE_SIMUL $LISTE_DMNFS # ---- export JOB_DIR=${JOB_DIR:-${TMP_MIGR_DATA}} export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM} export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp} mkdir -p ${IGCM_DEM} mkdir -p ${IGCM_TMP} clean_tmp=${clean_tmp:-yes} EXE_DIR=$(dirname ${0}) SCRIPT_NAME=$(basename ${0} ) source ${EXE_DIR}/DEM_utilities.sh echo "apres sources" ${SCRIPT_NAME} # gpdebug : verif si le present script a ete execute jusqu'au bout ######### MonitoringInfo="${SCRIPT_NAME}-->OK" generalMonitoring "$MonitoringInfo" DEM_log -0 "Demmarrage de ${SCRIPT_NAME}" cd ${EXE_DIR} # ---- # gpdebug : Execute la function errorReceive() si reception d'un signal TERM trap 'DEM_errorReceive' TERM ######## # gpdebug : on augmente la liste des proc à détruire en cas d'erreur bloquante du présent proc export listPID="$$ ${listPID}" ######### LISTE_SIMUL=${1} LISTE_DMNFS=${2} LISTE_SIMUL_NAME=$(basename ${LISTE_SIMUL} ) echo "gpdebug : ${IGCM_TMP}/${$}.liste_Restart.txt" # gpdebug : a virer ####### # Pour tous les fichiers ou repertoires contenus dans le fichier de parametres for DIR in $( awk '{print $0}' ${LISTE_SIMUL} ) ; do eval DIR_FINAL=$DIR DEM_log -1 ${SCRIPT_NAME} - Inspection de ${DIR}"/" # trouve la liste des repertoires restart sous l'arborescence # gpdebug : s'il n'y a pas de rep Restart, on saute ############################################################################### listRestart=`grep ${DIR_FINAL}"/" ${LISTE_DMNFS} | grep RESTART |grep -v ".tar" | awk '{print $3}' | sed 's%/RESTART.*%%' ` if [ "x${listRestart}" == "x" ] ; then echo "########## Attention :" echo "${SCRIPT_NAME}:${LINENO}:Pas de Repertoire RESTART ou de fichiers Restart dans ${DIR_FINAL}" continue fi echo "${listRestart}" >> ${IGCM_TMP}/${$}.liste_Restart.txt # gpdebug : fin ######################################################################################################################### done # Pour le cas ou aucune simu n aurait ete detectee if [ -e ${IGCM_TMP}/${$}.liste_Restart.txt ] then listRestartNbLines=`cat ${IGCM_TMP}/${$}.liste_Restart.txt | wc -l ` if [ "x${listRestartNbLines}" == "x0" ] then DEM_errorSend "${SCRIPT_NAME}:${LINENO}:Il n existe aucune simulation !" # "${$}" fi else DEM_errorSend "${SCRIPT_NAME}:${LINENO}:Il n existe aucune simulation !" # "${$}" fi # il n'y a qu'un seul path par simu dans le fichier (un repertoire RESTART par simul) mv ${IGCM_TMP}/${$}.liste_Restart.txt ${IGCM_DEM}/liste_simul_${LISTE_SIMUL_NAME} # gpdebug : envoi du nombre de simu dans un "nbSimu.txt" du rep de suivi echo `cat ${IGCM_DEM}/liste_simul_${LISTE_SIMUL_NAME} | wc -l ` > $nbSimuFile DEM_log -1 "Fichier cree : liste_simul_${LISTE_SIMUL_NAME}" [[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.path_simul.txt [[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.liste_Restart.txt # gpdebug : le script n'a pas rencontre d'erreur. On l'inscrit dans le fichier de suivi echo $MonitoringInfo >> $generalMonitorFile DEM_log -0 "Fin de ${SCRIPT_NAME}"