source: trunk/libIGCM/AA_purge_simulation @ 1525

Last change on this file since 1525 was 1525, checked in by cetlod, 4 years ago

Update Scripts for Post-processing on Irene-Rome

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