#!/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:-${PWD}} 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 ${JOB_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 DEM_log -1 ${SCRIPT_NAME} - Inspection de ${DIR}"/" # trouve la liste des repertoires restart sous l'arborescence # grep ${DIR}"/" ${LISTE_DMNFS} | grep Restart | awk '{print $3}' | sed 's%/Restart.*%%' >> ${IGCM_TMP}/${$}.liste_Restart.txt # gpdebug : suppr # gpdebug : s'il n'y a pas de rep Restart, on saute ############################################################################### listRestart=`grep ${DIR}"/" ${LISTE_DMNFS} | grep Restart/ | awk '{print $3}' | sed 's%/Restart.*%%' ` if [ "x${listRestart}" == "x" ] ; then # DEM_errorSend "${SCRIPT_NAME}:${LINENO}:Pas de Repertoire Restart dans ${DIR}" "${$}" # gpdebug : a virer ######## echo "########## Attention :" echo "${SCRIPT_NAME}:${LINENO}:Pas de Repertoire Restart ou de fichiers Restart dans ${DIR}" continue fi echo "${listRestart}" >> ${IGCM_TMP}/${$}.liste_Restart.txt # gpdebug : fin ######################################################################################################################### done # DEM_errorSend "${SCRIPT_NAME}:${LINENO}:On arrete expres !" $$ # gpdebug : a virer ######## # 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 # On cherche le path (deux crans au dessus des repertoires Restart) DEM_log -1 "Recherche du path" for DIR in $( awk '{print $0}' ${IGCM_TMP}/${$}.liste_Restart.txt ) ; do DEM_log -3 ${SCRIPT_NAME} - Recherche path : ${DIR} #gestion des cas particulier tels que la creation de l'etat initial avec lmdz (JobName/ATM/Output/Restart/ au lieu de JobName/ATM/Restart/) PATH_SIM=$( dirname ${DIR} ) lastdir=$( echo $PATH_SIM | sed -e "s%.*/%%") if [ $lastdir != "ATM" ]; then dirname ${DIR} >> ${IGCM_TMP}/${$}.path_simul.txt else dirname ${PATH_SIM} >> ${IGCM_TMP}/${$}.path_simul.txt fi done # On retire les doublons pour avoir la liste des simulations a tester DEM_log -1 "Suppression des doublons" awk '{if (x[$0] != "") next ; print $0 ; x[$0]=$0}' <${IGCM_TMP}/${$}.path_simul.txt >> liste_simul_${LISTE_SIMUL_NAME} awk '{if (x[$0] != "") next ; print $0 ; x[$0]=$0}' > liste_simul_${LISTE_SIMUL_NAME}.tmp${$} mv liste_simul_${LISTE_SIMUL_NAME}.tmp${$} ${IGCM_DEM}/liste_simul_${LISTE_SIMUL_NAME} rm -f 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}"