source: trunk/libIGCM/AA_purge_simulation @ 1436

Last change on this file since 1436 was 1403, checked in by sdipsl, 7 years ago
  • Add one more security to the purge script
  • Property svn:keywords set to Date Author Revision
File size: 4.6 KB
Line 
1#!/bin/ksh
2#**************************************************************
3# Author: Sebastien Denvil
4# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
5# $Revision::                                          $ Revision of last commit
6# $Author::                                            $ Author of last commit
7# $Date::                                              $ Date of last commit
8# IPSL (2006)
9#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
10#
11#**************************************************************
12# ID of your genci project. Curie only : post-processing jobs need it to run properly
13#-Q- curie export BRIDGE_MSUB_PROJECT=::default_project::
14
15#set -eu
16#set -vx
17
18libIGCM=::modipsl::/libIGCM
19
20#D- Task type DO NOT CHANGE (computing, post-processing or checking)
21TaskType=checking
22
23#D--------------------------------------------------------------------==
24#D-                   -1. User modification place
25#D--------------------------------------------------------------------==
26
27#D- Increased verbosity (1, 2, 3)
28Verbosity=3
29
30#D- Low level debug : to perform lib test checks, stack construction and IO functions instrumentation
31#D- Default=true
32DEBUG_debug=true
33
34#D- Messaging : all activities and call stacks will be sent to ipsl servers
35#D- If true will imply DEBUG_debug=true
36#D- Default=false
37#D-
38BigBrother=true
39
40
41#D--------------------------------------------------------------------==
42
43echo "purge an entire simulation :"
44echo "Script used to purge a simulation from the IGCM_OUT directory !"
45echo "This script will completely wipe out your simulation and will erase all files !!!"
46echo "Be careful and read all informations !"
47echo "----"
48echo "It must be called in Experience directory (so-called SUBMIT_DIR)."
49echo "----"
50
51#D--------------------------------------------------------------------==
52
53. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
54. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
55. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
56#-------
57SUBMIT_DIR=$( pwd )
58. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
59. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
60#-------
61( ${DEBUG_debug} ) && IGCM_debug_Check
62( ${DEBUG_debug} ) && IGCM_card_Check
63( ${DEBUG_debug} ) && IGCM_date_Check
64
65if [ ! -f ${SUBMIT_DIR}/config.card ] ; then
66  echo "A config.card is needed to proceed"
67  exit
68fi
69
70if [ ! -f ${SUBMIT_DIR}/run.card ] ; then
71  echo "A run.card is needed to proceed"
72  exit
73fi
74
75#==================================
76# First of all
77#
78# Read libIGCM compatibility version in config.card
79# Read UserChoices section
80# Read Ensemble section
81# Read Post section
82# Define all netcdf output directories
83#==================================
84IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
85
86# ------------------------------------------------------------------
87# Activate BigBrother so as to supervise this simulation
88# ------------------------------------------------------------------
89IGCM_debug_BigBro_Initialize
90
91# List whats need to be done
92echo "Search directories in ${R_SAVE}"
93set +A ListDirectories -- $( IGCM_sys_RshArchive "find ${R_SAVE} ${R_BUFR} ${R_FIGR} -type d | sort | uniq" )
94CountListDirectories=${#ListDirectories[@]}
95
96# And proceed
97if [ ${CountListDirectories} -gt 0 ] ; then
98  for dir in ${ListDirectories[@]} ; do
99    IGCM_debug_Print 2 -e "\033[1;31m ${dir}\033[m"
100  done
101  IGCM_debug_Print 2 -e "\033[1;31m ${SUBMIT_DIR}/run.card\033[m"
102  IGCM_debug_Print 2 -e "\033[1;31m ${SUBMIT_DIR}/Debug\033[m"
103  IGCM_debug_Print 2 -e "\033[1;31m ${SUBMIT_DIR}/Script_Output_*.??????\033[m"
104
105  echo -e "\033[1;32mDo you REALLY want to erase all those directories and files?\033[m"
106  echo -n " Your answer (y/n) :"
107  read reponse
108  case ${reponse} in
109
110  oui|OUI|o|y|yes|YES)
111
112    ERASE=FALSE
113    if [ X${config_UserChoices_SpaceName} = XTEST ] ; then
114      ERASE=TRUE
115    else
116      echo -e "\033[1;32mPlease type in the exact Job Name of the simulation to erase?\033[m"
117      read jobname
118      if [ X${config_UserChoices_JobName} = X${jobname} ] ; then
119        ERASE=TRUE
120      else
121        echo "JobName you gave and the one from config.card do not match. Stop here."
122      fi
123    fi
124
125    if [ X${ERASE} = XTRUE ] ; then
126      echo "OK. It will be erased."
127      for dir in ${ListDirectories[@]} ; do
128        IGCM_sys_RshArchive rm -rf ${dir}
129      done
130      # Remove dods hardlink
131      IGCM_sys_Dods_Rm
132      # Remove run.card
133      rm -f ${SUBMIT_DIR}/run.card
134      # Remove Script_Output
135      rm -f ${SUBMIT_DIR}/Script_Output_*.??????
136      # Remove the Debug directory
137      rm -rf ${SUBMIT_DIR}/Debug
138      # Send a message telling we want to purge
139      IGCM_debug_sendAMQP_Purge
140      echo "done."
141    fi
142    ;;
143  non|NON|n|no|NO)
144    echo "Nothing to do !"
145    ;;
146  esac
147fi
148
149exit 0
Note: See TracBrowser for help on using the repository browser.