source: trunk/libIGCM/AA_purge_simulation @ 1516

Last change on this file since 1516 was 1483, checked in by jgipsl, 5 years ago

Ticket #344 : Added same section as in the end of AA_clean_PeriodLength to reset counter to 000001 for Script_Output in main job.

  • Property svn:keywords set to Date Author Revision
File size: 5.8 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#-Q- irene export BRIDGE_MSUB_PROJECT=::default_project::
15
16#set -eu
17#set -vx
18
19libIGCM=::modipsl::/libIGCM
20
21#D- Task type DO NOT CHANGE (computing, post-processing or checking)
22TaskType=checking
23
24#D--------------------------------------------------------------------==
25#D-                   -1. User modification place
26#D--------------------------------------------------------------------==
27
28#D- Increased verbosity (1, 2, 3)
29Verbosity=3
30
31#D- Low level debug : to perform lib test checks, stack construction and IO functions instrumentation
32#D- Default=true
33DEBUG_debug=true
34
35#D- Messaging : all activities and call stacks will be sent to ipsl servers
36#D- If true will imply DEBUG_debug=true
37#D- Default=false
38#D-
39BigBrother=true
40
41
42#D--------------------------------------------------------------------==
43
44echo "purge an entire simulation :"
45echo "Script used to purge a simulation from the IGCM_OUT directory !"
46echo "This script will completely wipe out your simulation and will erase all files !!!"
47echo "Be careful and read all informations !"
48echo "----"
49echo "It must be called in Experience directory (so-called SUBMIT_DIR)."
50echo "----"
51
52#D--------------------------------------------------------------------==
53
54. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
55. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
56. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
57#-------
58SUBMIT_DIR=$( pwd )
59. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
60. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
61#-------
62( ${DEBUG_debug} ) && IGCM_debug_Check
63( ${DEBUG_debug} ) && IGCM_card_Check
64( ${DEBUG_debug} ) && IGCM_date_Check
65
66if [ ! -f ${SUBMIT_DIR}/config.card ] ; then
67  echo "A config.card is needed to proceed"
68  exit
69fi
70
71if [ ! -f ${SUBMIT_DIR}/run.card ] ; then
72  echo "A run.card is needed to proceed"
73  exit
74fi
75
76#==================================
77# First of all
78#
79# Read libIGCM compatibility version in config.card
80# Read UserChoices section
81# Read Ensemble section
82# Read Post section
83# Define all netcdf output directories
84#==================================
85IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
86
87# ------------------------------------------------------------------
88# Activate BigBrother so as to supervise this simulation
89# ------------------------------------------------------------------
90IGCM_debug_BigBro_Initialize
91
92# List whats need to be done
93echo "Search directories in ${R_SAVE}"
94set +A ListDirectories -- $( IGCM_sys_RshArchive "find ${R_SAVE} ${R_BUFR} ${R_FIGR} -type d | sort | uniq" )
95CountListDirectories=${#ListDirectories[@]}
96
97# And proceed
98if [ ${CountListDirectories} -gt 0 ] ; then
99  for dir in ${ListDirectories[@]} ; do
100    IGCM_debug_Print 2 -e "\033[1;31m ${dir}\033[m"
101  done
102  IGCM_debug_Print 2 -e "\033[1;31m ${SUBMIT_DIR}/run.card\033[m"
103  IGCM_debug_Print 2 -e "\033[1;31m ${SUBMIT_DIR}/Debug\033[m"
104  IGCM_debug_Print 2 -e "\033[1;31m ${SUBMIT_DIR}/Script_Output_*.??????\033[m"
105
106  echo -e "\033[1;32mDo you REALLY want to erase all those directories and files?\033[m"
107  echo -n " Your answer (y/n) :"
108  read reponse
109  case ${reponse} in
110
111  oui|OUI|o|y|yes|YES)
112
113    ERASE=FALSE
114    if [ X${config_UserChoices_SpaceName} = XTEST ] ; then
115      ERASE=TRUE
116    else
117      echo -e "\033[1;32mPlease type in the exact Job Name of the simulation to erase?\033[m"
118      read jobname
119      if [ X${config_UserChoices_JobName} = X${jobname} ] ; then
120        ERASE=TRUE
121      else
122        echo "JobName you gave and the one from config.card do not match. Stop here."
123      fi
124    fi
125
126    if [ X${ERASE} = XTRUE ] ; then
127      echo "OK. It will be erased."
128      for dir in ${ListDirectories[@]} ; do
129        IGCM_sys_RshArchive rm -rf ${dir}
130      done
131      # Remove dods hardlink
132      IGCM_sys_Dods_Rm
133      # Remove run.card
134      rm -f ${SUBMIT_DIR}/run.card
135      # Remove Script_Output
136      rm -f ${SUBMIT_DIR}/Script_Output_*.??????
137      # Remove the Debug directory
138      rm -rf ${SUBMIT_DIR}/Debug
139      # Send a message telling we want to purge
140      IGCM_debug_sendAMQP_Purge
141      echo "done."
142
143      # Add reset of counter for Script_Output in the main Job
144      Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'}
145      Script_Output_Job=${Script_Output_Prefix}_${config_UserChoices_JobName}
146      Script_Output=${Script_Output_Prefix}_${config_UserChoices_JobName}.000001
147
148      echo -e "\033[1;32mDo you want to change the number in Script_Output? (${Script_Output} into Job) ?"
149      echo -n -e " Your answer (y/n) : \033[m"
150      read reponse
151      case ${reponse} in
152         
153          oui|OUI|o|y|yes|YES)
154              cp ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}_SAVED_$$
155              sed -e"s/${Script_Output_Job}.[0-9][0-9][0-9][0-9][0-9][0-9]/${Script_Output}/"  ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}_SAVED_$$  >${SUBMIT_DIR}/Job_${config_UserChoices_JobName}
156              echo "Job : Job_${config_UserChoices_JobName} modified."
157              echo "Old job saved here : Job_${config_UserChoices_JobName}_SAVED_$$"
158              ;;
159          non|NON|n|no|NO)
160              echo "Nothing done in Job_${config_UserChoices_JobName} !"
161              ;;
162      esac
163
164    fi
165    ;;
166  non|NON|n|no|NO)
167    echo "Nothing to do !"
168    ;;
169  esac
170fi
171
172exit 0
Note: See TracBrowser for help on using the repository browser.