[1709] | 1 | #!/bin/bash |
---|
| 2 | ###################### |
---|
| 3 | ## TITANE CEA ## |
---|
| 4 | ###################### |
---|
| 5 | #MSUB -r ipsl_pack # Nom du job |
---|
| 6 | #MSUB -eo |
---|
| 7 | #MSUB -n 1 # Reservation du processus |
---|
| 8 | #MSUB -T 86400 # Limite de temps elapsed du job |
---|
| 9 | #MSUB -p gen2211 |
---|
| 10 | #MSUB -q mono |
---|
| 11 | |
---|
[1727] | 12 | # ex : ./launch_ipsl_pack.sh fichier_param_test1.txt |
---|
| 13 | # ex : ./launch_ipsl_pack.sh param_SL.txt |
---|
| 14 | # ex : ./launch_ipsl_pack.sh param_OM.txt |
---|
[1709] | 15 | |
---|
| 16 | export JOB_DIR=${LS_SUBCWD:-${PWD}} |
---|
| 17 | export EXE_DIR=${JOB_DIR} |
---|
| 18 | |
---|
[1822] | 19 | ##### gpdebug : addition ################################## |
---|
| 20 | # Boucle qui gere les parametres du script (permet l'introduction d'une option -f |
---|
| 21 | # qui force l'execution de toute les etapes du script de listes) |
---|
| 22 | execEveryStep=0 |
---|
| 23 | LISTE_SIMUL= |
---|
| 24 | while [ $# -gt 0 ] |
---|
| 25 | do |
---|
| 26 | echo "boucle sur les arguments du script ..." |
---|
| 27 | echo "@=$@" |
---|
| 28 | case $1 in |
---|
| 29 | -f) execEveryStep=1 |
---|
| 30 | echo "force..." |
---|
| 31 | ;; |
---|
| 32 | *) LISTE_SIMUL=${1} |
---|
| 33 | echo "autres..." |
---|
| 34 | ;; |
---|
| 35 | |
---|
| 36 | esac |
---|
| 37 | shift |
---|
| 38 | done |
---|
| 39 | echo "Fin boucle sur arguments" |
---|
| 40 | export execEveryStep=${execEveryStep} |
---|
[1864] | 41 | if [ "x${LISTE_SIMUL}" == "x" ] |
---|
| 42 | then |
---|
| 43 | echo "Vous devez passer un fichier en parametre" |
---|
| 44 | exit 1 |
---|
| 45 | fi |
---|
[1709] | 46 | |
---|
[1822] | 47 | # fichier de progression d'execution |
---|
[1849] | 48 | ficParam=$( basename ${LISTE_SIMUL} ) # gpdebug : modif ici et ligne d'apres |
---|
| 49 | extSuiviListes=`echo ${ficParam} | sed 's;\.[[:alnum:]]*$;;' ` |
---|
[1822] | 50 | # echo "extSuiviListes=$extSuiviListes" # gpdebug : a virer |
---|
| 51 | export MonitoringDir="${PWD}/SuiviListes_${extSuiviListes}" |
---|
| 52 | # echo "MonitoringDir=$MonitoringDir" # gpdebug : a virer |
---|
| 53 | # exit 0 # gpdebug : a virer |
---|
| 54 | |
---|
| 55 | export generalMonitorFile=${MonitoringDir}/general.txt |
---|
| 56 | export nbSimuFile=${MonitoringDir}/nbSimu.txt |
---|
| 57 | |
---|
| 58 | ##### gpdebug : fin ##################################### |
---|
| 59 | |
---|
| 60 | # LISTE_SIMUL=${1} # gpdebug : suppr --> cette affectation est maintenant faite dans la boucle while des arg du script ################ |
---|
| 61 | |
---|
[1709] | 62 | #LISTE_SIMUL=${JOB_DIR}/param_SL.txt |
---|
| 63 | #LISTE_DMNFS=${JOB_DIR}/SL_information_dmnfs_2012-03-21 |
---|
| 64 | |
---|
| 65 | # LISTE_SIMUL=${JOB_DIR}/param_OM.txt |
---|
| 66 | # LISTE_DMNFS=${JOB_DIR}/OM_information_dmnfs_2012-03-21 |
---|
| 67 | |
---|
| 68 | LISTE_SIMUL_NAME=$(basename ${LISTE_SIMUL} ) |
---|
| 69 | SCRIPT_NAME=$(basename ${0} ) |
---|
| 70 | |
---|
[1859] | 71 | # On renseigne les variables d'environnement |
---|
| 72 | export scriptCallingLoad=$SCRIPT_NAME # sert a renseigner "load_ipslPack_env.sh" sur le script l'appelant |
---|
[1853] | 73 | . load_ipslPack_env.sh |
---|
| 74 | |
---|
[1863] | 75 | if [ "x${IGCM_DEM}" == "x" ] |
---|
| 76 | then |
---|
| 77 | echo "variable IGCM_DEM non renseignee. STOP." |
---|
| 78 | exit 1 |
---|
| 79 | fi |
---|
| 80 | # rm -f ${IGCM_DEM}/Listing.txt # gpdebug : en cas de reprise, on ne peut pas laisser ca en l'etat --> suppr |
---|
| 81 | # gpdebug : Donc on rajoute le if qui suit |
---|
| 82 | if [ "x${execEveryStep}" == "x1" ] |
---|
| 83 | then |
---|
| 84 | echo "Destruction du repertoire :" |
---|
| 85 | echo "${IGCM_DEM}" |
---|
| 86 | rm -rf ${IGCM_DEM} |
---|
| 87 | fi |
---|
| 88 | |
---|
[1853] | 89 | export IGCM_TMP="${IGCM_DEM}/tmp" # gpdebug : added |
---|
| 90 | # INPUT_DMF_DATA, positionnee par le load_ipslPack_env.sh, sert pour pour PATH_SIMUL_SHORT dans create_config_card.sh |
---|
| 91 | |
---|
[1709] | 92 | export clean_tmp=${clean_tmp:-yes} |
---|
| 93 | export DEM_LOG=${JOB_DIR}/dem_${LSB_JOBID:-${$}}.log |
---|
| 94 | export LOG_LEV=2 |
---|
[1822] | 95 | export FileParam=${LISTE_SIMUL} # gpdebug : pour appel (dans DEM_utilities.sh) a showListsProgress.sh |
---|
| 96 | export FatherPID=$$ # gpdebug : pour appel (dans DEM_utilities.sh) a showListsProgress.sh |
---|
[1709] | 97 | |
---|
| 98 | source ${EXE_DIR}/DEM_utilities.sh |
---|
| 99 | |
---|
[1822] | 100 | # gpdebug : prepare le fichier de suivi de la progression |
---|
| 101 | prepareMonitoringDir |
---|
| 102 | # exit 0 # gpdebug : a virer ############## |
---|
| 103 | |
---|
| 104 | # gpdebug : Execute la function errorReceive() si reception d'un signal TERM |
---|
| 105 | trap 'DEM_errorReceive' TERM ######## |
---|
| 106 | |
---|
| 107 | # gpdebug : liste des processus à détruire en cas d'erreur bloquante |
---|
| 108 | export listPID=$$ ######## |
---|
| 109 | |
---|
| 110 | # gpdebug : fichier pour la transmission des messages d'erreur d'un fils au prog principal |
---|
| 111 | export errorMsgFile="${PWD}/errorMsg.txt" ######## |
---|
| 112 | |
---|
[1709] | 113 | DEM_log -0 "Demarrage de ${SCRIPT_NAME}" |
---|
| 114 | |
---|
| 115 | mkdir -p ${IGCM_DEM} |
---|
| 116 | mkdir -p ${IGCM_TMP} |
---|
| 117 | |
---|
| 118 | rm -rf ${IGCM_TMP}/tmp/* |
---|
| 119 | rm -f ${DEM_LOG} |
---|
| 120 | |
---|
[1713] | 121 | # 0- on cree le listing correspondant au fichier param |
---|
| 122 | # on efface les tests precedents |
---|
[1822] | 123 | |
---|
[1713] | 124 | for DIR in $( awk '{print $0}' ${LISTE_SIMUL} ) ; do |
---|
| 125 | ./create_listing.sh $DIR |
---|
| 126 | done |
---|
| 127 | |
---|
| 128 | LISTE_DMNFS=${IGCM_DEM}/Listing.txt |
---|
| 129 | |
---|
[1709] | 130 | # 1- A partir de param_list - on recherche l'ensemble des simulations a packer |
---|
| 131 | # la liste creee (liste_simul_$1) est stockee dans $SCRATCHDIR/IGCM_DEM |
---|
| 132 | |
---|
| 133 | ${EXE_DIR}/find_directory_simul.sh ${LISTE_SIMUL} ${LISTE_DMNFS} |
---|
| 134 | |
---|
[1822] | 135 | # sleep 2 # gpdebug : a virer |
---|
| 136 | # echo "Le script principal continue..." # gpdebug : a virer |
---|
| 137 | # exit 0 # gpdebug : a virer |
---|
| 138 | |
---|
| 139 | #################################################################### |
---|
| 140 | # gpdebug : partie vidée pour simplifier. Voir le fichier original. |
---|
| 141 | |
---|
[1709] | 142 | # 2- Pour chacune des simulations listees on cree un fichier config.card correspondant |
---|
| 143 | # ces fichiers seront stockes dans ${IGCM_DEM}/arborescence/ |
---|
| 144 | # un fichier recapitulatif des fichiers config.card (config_card.liste) crees sera stocke dans ${IGCM_DEM} |
---|
| 145 | |
---|
[1717] | 146 | ${EXE_DIR}/create_config_card.sh ${IGCM_DEM}/liste_simul_${LISTE_SIMUL_NAME} ${LISTE_DMNFS} |
---|
[1709] | 147 | |
---|
[1822] | 148 | # exit 0 # gpdebug : a virer ######### |
---|
| 149 | |
---|
[1709] | 150 | #3- recherche de la taille ideale de pack pour chacune des simulations - puis creation des listes |
---|
| 151 | |
---|
| 152 | for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do |
---|
| 153 | |
---|
[1714] | 154 | DEM_log -2 ${CONFIG} |
---|
[1709] | 155 | |
---|
| 156 | eval $(grep IGCM_DEM_SIMU ${CONFIG}) |
---|
| 157 | ${EXE_DIR}/calcul_size_simul.sh ${CONFIG} ${LISTE_DMNFS} |
---|
[1822] | 158 | # exit 0 # gpdebug : a virer ######### |
---|
[1714] | 159 | DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${CONFIG} ) |
---|
| 160 | if [[ "${DEM_state}" != "WriteListTarDone" ]] ; then |
---|
| 161 | |
---|
| 162 | DEM_log -3 "la simulation est superieur a 1Go alors on pack" |
---|
[1709] | 163 | ${EXE_DIR}/find_size_pack.sh ${CONFIG} ${LISTE_DMNFS} |
---|
| 164 | ${EXE_DIR}/write_liste_pack.sh ${CONFIG} ${LISTE_DMNFS} |
---|
[1728] | 165 | ${EXE_DIR}/archive_restart.sh ${CONFIG} ${LISTE_DMNFS} |
---|
[1822] | 166 | # DEM_errorSend "${SCRIPT_NAME}:${LINENO}:On arrete expres !" # gpdebug : a virer ######## |
---|
[1728] | 167 | ${EXE_DIR}/archive_debug.sh ${CONFIG} ${LISTE_DMNFS} |
---|
[1714] | 168 | |
---|
[1709] | 169 | fi |
---|
| 170 | done |
---|
[1822] | 171 | #################################################################### |
---|
[1709] | 172 | |
---|
| 173 | DEM_log -0 "Fin de ${SCRIPT_NAME}" |
---|