source: TOOLS/SURPACK_IPSL/SaveNewSimuPack.sh @ 3624

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

Correct a bug and add a new list (files that we will not pack)

  • Property svn:executable set to *
File size: 4.4 KB
Line 
1#!/bin/bash
2
3
4# 1- faire un mv de la simu d'origine en JobName.BF (BF = Before Pack)
5# 2- copier sur le store la simu repackee sur Pseudo_dmnfs_store
6# 3- effacer dans JobName_BF les fichiers contenus dans les listes correctement traitees
7
8#----------------------------------------------------------------
9#----------------------------------------------------------------
10# On renseigne les variables d'environnement
11. load_ipslPack_env.sh
12
13export JOB_DIR=${TMP_MIGR_DATA}
14export EXE_DIR=${LS_SUBCWD:-${PWD}}
15
16SCRIPT_NAME=$(basename ${0} )
17
18export IGCM_TMP="${IGCM_DEM}/tmp"  # gpdebug : added
19
20export config_card=${IGCM_DEM}/config_card.liste
21
22source ${EXE_DIR}/DEM_utilities.sh
23#----------------------------------------------------------------
24#----------------------------------------------------------------
25
26# Gestion de l'option de lancement
27# si -R --> alors on active le stockage sur le store et le remove des anciennes donnees
28
29execRmv=0
30forceDirect2Rmv=0
31while [ $# -gt 0 ]
32do
33    case $1 in
34        -h)  cat <<fin
35script permettant de finaliser l'operation de surpack
361- creer la liste des fichiers a effacer sur le store (tous les fichiers repackes)
372- copie l'ancienne simulation en $SIMU.BP (for before Pack) 
383- copie sur le store la simulation repackee
394- efface dans $SIMU.BP les fichiers repackes
40
41Usage :
42-h : mode d'emploi
43-rmv : lance automatiquement la phase de copie sur le store et de remove des anciennes donnees.
44       sinon le script s'arrete a la creation de la liste de fichiers a effacer.
45fin
46            exit;;
47        -rmv) execRmv=1
48            ;;
49        *) echo "option non reconnue"
50            exit
51            ;;
52    esac
53    shift
54done
55
56
57
58# liste des simus
59
60for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste )
61do
62    PATH_SIMU=$( dirname $CONFIG )
63
64# liste des tar RESTART et DEBUG a effacer
65    config_card=$PATH_SIMU/config_card_*
66    eval $(grep PATH_SIMUL_FULL ${config_card}) 
67    eval $(grep IGCM_DEM_SIMU ${config_card})
68    eval $(grep JobName ${config_card}) 
69   
70    SIMU=${PATH_SIMUL_FULL}
71    SIMU_BP=${SIMU}.BP
72   
73    LITTLE_PATH=`echo $PATH_SIMUL_FULL | sed  "s%${INPUT_DMF_DATA}%%"`
74
75
76    cd ${USER_OUTPUT_PROGRESS}
77    find . -name "removedFiles*" > liste_files.txt
78
79    rmv_file_bis=${USER_OUTPUT_PROGRESS}/rmv_afterSurPack.txt
80    rm -f ${rmv_file_bis}
81
82    for removedfile in `awk '{print $0}' liste_files.txt`; do
83        rmv_file=${removedfile}
84           
85       
86        if [[ -f  ${rmv_file_bis} ]] ; then
87            cp ${rmv_file} ${rmv_file_bis}
88        else
89            cat  ${rmv_file} >> ${rmv_file_bis}
90        fi
91       
92        mkdir -p ${IGCM_DEM_SIMU}/restart_rmv
93        rm -rf ${IGCM_DEM_SIMU}/restart_rmv/*
94        for archive in  `awk '{print $2}' ${IGCM_DEM_SIMU}/liste_restart_files_config.txt`; do
95            not_rmv=0
96            ccc_hsm get $archive
97            tar tf $archive > ${IGCM_DEM_SIMU}/restart_rmv/archive.rmv
98            for fichier in  `awk '{print $0}' ${IGCM_DEM_SIMU}/restart_rmv/archive.rmv`; do
99                FindFile=`grep $fichier $rmv_file`
100                if [ "X$FindFile" == "X" ]; then
101                    echo "$archive tar to be conserved"
102                    not_rmv=1
103                fi
104            done
105            if [ $not_rmv == 0 ] ; then
106                echo "rm -f $archive" >> ${rmv_file_bis}
107            fi
108            rm -f ${IGCM_DEM_SIMU}/restart_rmv/archive.rmv
109        done
110       
111        mkdir -p ${IGCM_DEM_SIMU}/debug_rmv
112        rm -rf ${IGCM_DEM_SIMU}/debug_rmv/*
113        for archive in  `awk '{print $0}' ${IGCM_DEM_SIMU}/liste_debug_files_config.txt`; do
114            not_rmv=0
115            ccc_hsm get $archive
116            tar tf $archive > ${IGCM_DEM_SIMU}/debug_rmv/archive.rmv
117            for fichier in  `awk '{print $0}' ${IGCM_DEM_SIMU}/debug_rmv/archive.rmv`; do
118                FindFile=`grep $fichier $rmv_file`
119                    if [ "X$FindFile" == "X" ]; then
120                        echo "$archive tar to be conserved"
121                        not_rmv=1
122                    fi
123            done
124            if [ $not_rmv == 0 ] ; then
125                echo "rm -f $archive" >> ${rmv_file_bis}
126            fi
127            rm -f ${IGCM_DEM_SIMU}/debug_rmv/archive.rmv
128        done
129    done
130    sed -i -e "s%${SIMU}\/%${SIMU_BP}\/%g" ${rmv_file_bis}
131    echo "grep ${JobName} ${rmv_file_bis} > ${rmv_file_bis}.tmp"
132    grep ${JobName} ${rmv_file_bis} > ${rmv_file_bis}.tmp; mv  ${rmv_file_bis}.tmp  ${rmv_file_bis}
133    chmod 755 ${rmv_file_bis}
134       
135
136
137    if [[ $execRmv == 1 ]] ; then 
138# sauver l'ancienne version
139        mv ${SIMU} ${SIMU_BP}
140#copier sur le store la nouvelle
141        mv ${OUTPUT_STORE}${LITTLE_PATH}  ${SIMU}
142#copie du repertoire Exe qui ne change pas
143        mv ${SIMU_BP}/Exe ${SIMU}/.
144# effacer dans l'ancienne version les fichiers de rmv_file_bis
145        ${rmv_file_bis}
146#creation de la liste des fichiers restant
147        find ${SIMU_BP} -printf "%y %s %p \n" > ${USER_OUTPUT_PROGRESS}/lastFiles_afterSurPack.txt
148
149    fi
150done
151
152
Note: See TracBrowser for help on using the repository browser.