source: TOOLS/SURPACK_IPSL/find_directory_simul.sh @ 3624

Last change on this file since 3624 was 2136, checked in by acosce, 11 years ago

add new tools allows packing simulation alreaddy pack (so pack with a bigger frequency)

File size: 3.5 KB
Line 
1#!/bin/bash
2# set -vx # gpdebug : a virer ########
3# prend en argument le path et le nom d'un fichier param (argument de la commande
4# ccc_archive avec option ipsl_pack)
5# ex : ./find_directory_simul.job  fichier_param_test1.txt liste_fichier_dmnfs
6# ex : find_directory_simul.job param_SL.txt /cscratch/cont003/labetoul/FROM_CCRT_INFORMATIONS_DMNFS/information_dmnfs_2012-03-21
7
8#-------------------------------
9# A modifier avant utilisation :
10#--------------------------------
11
12LISTE_SIMUL=${1}
13LISTE_DMNFS=${2}
14echo $LISTE_SIMUL $LISTE_DMNFS
15# ----
16export JOB_DIR=${JOB_DIR:-${TMP_MIGR_DATA}}
17export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM}
18export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp}
19mkdir -p ${IGCM_DEM}
20mkdir -p ${IGCM_TMP}
21clean_tmp=${clean_tmp:-yes}
22EXE_DIR=$(dirname ${0})
23SCRIPT_NAME=$(basename ${0} )
24source ${EXE_DIR}/DEM_utilities.sh
25
26echo "apres sources" ${SCRIPT_NAME}
27
28# gpdebug : verif si le present script a ete execute jusqu'au bout #########
29MonitoringInfo="${SCRIPT_NAME}-->OK"
30generalMonitoring "$MonitoringInfo"
31
32DEM_log -0 "Demmarrage de ${SCRIPT_NAME}"
33
34cd ${EXE_DIR}
35# ----
36# gpdebug : Execute la function errorReceive() si reception d'un signal TERM
37trap 'DEM_errorReceive' TERM ########
38
39# gpdebug : on augmente la liste des proc à détruire en cas d'erreur bloquante du présent proc
40export listPID="$$ ${listPID}" #########
41
42LISTE_SIMUL=${1}
43LISTE_DMNFS=${2}
44
45LISTE_SIMUL_NAME=$(basename ${LISTE_SIMUL} )
46
47echo "gpdebug : ${IGCM_TMP}/${$}.liste_Restart.txt" # gpdebug : a virer  #######
48
49# Pour tous les fichiers ou repertoires contenus dans le fichier de parametres
50for DIR in $( awk '{print $0}' ${LISTE_SIMUL} ) ; do
51    eval DIR_FINAL=$DIR
52    DEM_log -1 ${SCRIPT_NAME} - Inspection de ${DIR}"/"
53    # trouve la liste des repertoires restart sous l'arborescence   
54       
55    # gpdebug : s'il n'y a pas de rep Restart, on saute ###############################################################################
56    listRestart=`grep ${DIR_FINAL}"/" ${LISTE_DMNFS} | grep RESTART |grep -v ".tar" | awk '{print $3}' | sed 's%/RESTART.*%%' `
57
58    if [ "x${listRestart}" == "x" ] ;
59    then
60        echo "########## Attention :"
61        echo "${SCRIPT_NAME}:${LINENO}:Pas de Repertoire RESTART ou de fichiers Restart dans ${DIR_FINAL}"
62        continue
63    fi
64    echo "${listRestart}" >> ${IGCM_TMP}/${$}.liste_Restart.txt
65    # gpdebug : fin #########################################################################################################################   
66done
67
68# Pour le cas ou aucune simu n aurait ete detectee
69if [ -e  ${IGCM_TMP}/${$}.liste_Restart.txt ]
70then
71   listRestartNbLines=`cat ${IGCM_TMP}/${$}.liste_Restart.txt | wc -l `
72   if [ "x${listRestartNbLines}" == "x0" ]
73   then
74      DEM_errorSend "${SCRIPT_NAME}:${LINENO}:Il n existe aucune simulation !" # "${$}"
75   fi
76else
77   DEM_errorSend "${SCRIPT_NAME}:${LINENO}:Il n existe aucune simulation !" # "${$}"
78fi
79
80#  il n'y a qu'un seul path par simu dans le fichier (un repertoire RESTART par simul)
81mv ${IGCM_TMP}/${$}.liste_Restart.txt ${IGCM_DEM}/liste_simul_${LISTE_SIMUL_NAME}
82
83# gpdebug : envoi du nombre de simu dans un "nbSimu.txt" du rep de suivi
84echo `cat ${IGCM_DEM}/liste_simul_${LISTE_SIMUL_NAME} | wc -l ` > $nbSimuFile
85
86DEM_log -1 "Fichier cree : liste_simul_${LISTE_SIMUL_NAME}"
87
88
89[[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.path_simul.txt
90[[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.liste_Restart.txt
91
92# gpdebug : le script n'a pas rencontre d'erreur. On l'inscrit dans le fichier de suivi
93echo $MonitoringInfo >> $generalMonitorFile
94
95DEM_log -0 "Fin de ${SCRIPT_NAME}"
Note: See TracBrowser for help on using the repository browser.