Changeset 2036
- Timestamp:
- 03/27/13 14:47:27 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modipsl/trunk/util/ins_job
r1908 r2036 14 14 15 15 Usage : 16 ${b_n} [-h] [-v] [-e] 16 ${b_n} [-h] [-v] [-e] [-p project] 17 17 18 18 Options : 19 -h : help 20 -v : verbose mode 21 -e : turn on hindcast/forecast ensemble mode 19 -h : help 20 -v : verbose mode 21 -e : turn on hindcast/forecast ensemble mode 22 -p project : add default project on curie 22 23 " 23 24 } … … 37 38 x_v='silencious'; 38 39 x_e=false; 39 while getopts :hve V ; do 40 x_p=false; 41 while getopts :hvep: V ; do 40 42 case $V in 41 43 (h) ins_job_Usage; exit 0;; 42 44 (v) x_v='verbose';; 43 45 (e) x_e=true;; 46 (p) x_p=true 47 ProjectID=${OPTARG} ;; 44 48 (:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2; 45 exit 2;;49 exit 2;; 46 50 (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2; 47 exit 2;;51 exit 2;; 48 52 esac 49 53 done … … 105 109 . ${libIGCM}/libIGCM_ensemble/libIGCM_ensemble.ksh 106 110 fi 111 112 #- 113 # Define Project ID to set up jobs header for Curie (TGCC) 114 #- 115 if ( ! ${x_p} ) ; then 116 if [ "X${x_t}" == "Xcurie" ] ; then 117 ProjectID=$( ccc_myproject | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | head -n 1 ) 118 ProjectID=${ProjectID:="gen2211"} 119 answer="" 120 print - "Hit Enter or give project ID (default is ${ProjectID}):" 121 read answer 122 123 if [ "X${answer}" != "X" ] ; then 124 ProjectID=${answer} 125 fi 126 fi 127 else 128 if ( "X${x_t}" != "Xcurie" ) ; then 129 print - "\nOption -p invalid with this host (${x_t}): it will be ignored" 1>&2; 130 fi 131 fi 132 107 133 #- 108 134 # Define the pattern string to substitute … … 116 142 for i in $(find ${d_n}/.. -name ${F_CFG} -print) 117 143 do 118 j=$(cd ${i%/*};/bin/pwd;)119 n_f=${F_RCI##*/};120 121 if [ ! X$( echo ${j} | grep EXPERIMENTS ) = X ] ; then122 # Do not treat config.card if it is in sub-directory of EXPERIMENTS123 # Continue to next config.card124 125 else126 127 fi128 129 # Find out if new structure and set .resol filename130 if [ -d ${j}/EXPERIMENTS ] && [ -d ${j}/GENERAL ] ; then131 132 133 134 135 else136 137 138 139 fi140 141 # Get all variables declared in section UserChoices in config.card142 IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} UserChoices143 # Set default values144 config_UserChoices_JobClass=mono145 config_UserChoices_JobNumProcTot=1146 config_UserChoices_ExpType=""147 RESOL_ATM_3D=this_is_a_test_string148 RESOL=this_is_another_test_string149 typeset option150 for option in ${config_UserChoices[*]} ; do151 152 done153 154 # Find the JobName : JobName might contain the variable RESOL_ATM_3D that will be replaced by what is in .resol file155 if [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL_ATM_3D} ) = X ] ; then144 j=$(cd ${i%/*};/bin/pwd;) 145 n_f=${F_RCI##*/}; 146 147 if [ ! X$( echo ${j} | grep EXPERIMENTS ) = X ] ; then 148 # Do not treat config.card if it is in sub-directory of EXPERIMENTS 149 # Continue to next config.card 150 continue 151 else 152 [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; 153 fi 154 155 # Find out if new structure and set .resol filename 156 if [ -d ${j}/EXPERIMENTS ] && [ -d ${j}/GENERAL ] ; then 157 # New Structure 158 [[ ${x_v} = 'verbose' ]] && echo "This is new configuration structure" 159 new_struct=yes 160 resolfile=$j/.resol 161 else 162 # Old Structure 163 new_struct=no 164 resolfile=$j/../.resol 165 fi 166 167 # Get all variables declared in section UserChoices in config.card 168 IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} UserChoices 169 # Set default values 170 config_UserChoices_JobClass=mono 171 config_UserChoices_JobNumProcTot=1 172 config_UserChoices_ExpType="" 173 RESOL_ATM_3D=this_is_a_test_string 174 RESOL=this_is_another_test_string 175 typeset option 176 for option in ${config_UserChoices[*]} ; do 177 IGCM_card_DefineVariableFromOption ${j}'/'${F_CFG} UserChoices ${option} 178 done 179 180 # Find the JobName : JobName might contain the variable RESOL_ATM_3D that will be replaced by what is in .resol file 181 if [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL_ATM_3D} ) = X ] ; then 156 182 TRUERESOL=$( tail -1 $resolfile | awk "-F=" '{print $2}' ) 157 183 echo TRUERESOL = $TRUERESOL 158 184 JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL_ATM_3D}/${TRUERESOL}/" ) 159 185 IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} 160 elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL} ) = X ] ; then161 162 163 164 else165 166 fi167 [[ ${x_v} = 'verbose' ]] && echo "JobName=${JobName}"168 169 # Add specific treatment for new type of directory structure186 elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL} ) = X ] ; then 187 TRUERESOL=$( head -1 $resolfile ) 188 JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL}/${TRUERESOL}/" ) 189 IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} 190 else 191 JobName=${config_UserChoices_JobName} 192 fi 193 [[ ${x_v} = 'verbose' ]] && echo "JobName=${JobName}" 194 195 # Add specific treatment for new type of directory structure 170 196 if [ ${new_struct} == yes ] ; then 171 197 172 if [ "X${config_UserChoices_ExpType}" = X ] ; then 173 echo "\nERROR in ${j}/config.card" 174 echo "ins_job stops here" 175 echo "=> The variable ExpType must be added in config.card in section UserChoices" 176 echo "=> ExpType gives the directory for the .card configurtaion files for the wanted experiement. For exemple ExpType=IPSLCM5/historical" 177 exit 4 178 else 179 [[ ${x_v} = 'verbose' ]] && echo "ExpType= ${config_UserChoices_ExpType}" 180 fi 181 182 if [ -d ${j}/${JobName} ] ; then 183 echo "Directory ${j}/${JobName} exist already, continue next config.card" 184 continue 185 fi 186 echo "=> Submit directory ${JobName} will be created with cards from EXPERIMENTS/${config_UserChoices_ExpType}" 187 cp -r ${j}/EXPERIMENTS/${config_UserChoices_ExpType} ${j}/${JobName} 188 cp -r ${j}/GENERAL/* ${j}/${JobName}/. 189 cp -f ${j}/${F_CFG} ${j}/${JobName}/. 190 rm -f ${j}/${F_CFG} 191 rm -f ${j}/${F_CFG}.bak 192 j=${j}/${JobName} 193 [[ ${x_v} = 'verbose' ]] && echo new j=$j 194 fi 195 # end specific treatment for new type directory structure 196 197 [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; } || \ 198 { 199 [[ ${x_v} = 'verbose' ]] && print - "\nCopying file ${F_RCI}\nin directory ${j}"; 200 \cp ${F_RCI} ${j}; 201 } 202 203 # File name for Job 204 n_f='Job_'${JobName}; 205 [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } 206 [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; 207 sed -e "/^${W_W} */ s///" \ 208 -e "/^${W_P}/d" \ 209 -e "s%::modipsl::%${F_MOD}%" \ 210 -e "s/::Jobname::/${JobName}/" \ 211 -e "s/::JobClass::/${config_UserChoices_JobClass}/" \ 212 -e "s/::JobNumProcTot::/${config_UserChoices_JobNumProcTot}/" \ 213 ${F_JOB} > ${j}'/'${n_f} 214 chmod u+x ${j}'/'${n_f} 198 if [ "X${config_UserChoices_ExpType}" = X ] ; then 199 echo "\nERROR in ${j}/config.card" 200 echo "ins_job stops here" 201 echo "=> The variable ExpType must be added in config.card in section UserChoices" 202 echo "=> ExpType gives the directory for the .card configurtaion files for the wanted experiement. For exemple ExpType=IPSLCM5/historical" 203 exit 4 204 else 205 [[ ${x_v} = 'verbose' ]] && echo "ExpType= ${config_UserChoices_ExpType}" 206 fi 207 208 if [ -d ${j}/${JobName} ] ; then 209 echo "Directory ${j}/${JobName} exist already, continue next config.card" 210 continue 211 fi 212 echo "=> Submit directory ${JobName} will be created with cards from EXPERIMENTS/${config_UserChoices_ExpType}" 213 cp -r ${j}/EXPERIMENTS/${config_UserChoices_ExpType} ${j}/${JobName} 214 cp -r ${j}/GENERAL/* ${j}/${JobName}/. 215 cp -f ${j}/${F_CFG} ${j}/${JobName}/. 216 rm -f ${j}/${F_CFG} 217 rm -f ${j}/${F_CFG}.bak 218 j=${j}/${JobName} 219 [[ ${x_v} = 'verbose' ]] && echo new j=$j 220 fi 221 # end specific treatment for new type directory structure 222 223 [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; } || \ 224 { 225 [[ ${x_v} = 'verbose' ]] && print - "\nCopying file ${F_RCI}\nin directory ${j}"; 226 \cp ${F_RCI} ${j}; 227 } 228 229 # File name for Job 230 n_f='Job_'${JobName}; 231 [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } 232 [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; 233 sed -e "/^${W_W} */ s///" \ 234 -e "/^${W_P}/d" \ 235 -e "s%::modipsl::%${F_MOD}%" \ 236 -e "s/::Jobname::/${JobName}/" \ 237 -e "s/::JobClass::/${config_UserChoices_JobClass}/" \ 238 -e "s/::JobNumProcTot::/${config_UserChoices_JobNumProcTot}/" \ 239 -e "s/::default_project::/${ProjectID}/" \ 240 ${F_JOB} > ${j}'/'${n_f} 241 chmod u+x ${j}'/'${n_f} 215 242 done 216 243 #- … … 220 247 for i in $(find ${libIGCM} -name "AA_*" -print | grep -v .svn ) 221 248 do 222 i_f=${i##*/}; 223 [[ ${i_f} = 'AA_job' ]] && { continue; } 224 j=${i%/*}; n_f=${i_f#AA_}'.job'; 225 [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } 226 [[ ${x_v} = 'verbose' ]] && print - "\nIn directory ${j}\n${i_f} -> ${n_f}" 227 sed -e "/^${W_W} */ s///" \ 228 -e "s%::modipsl::%${F_MOD}%" \ 229 -e "/^${W_P}/d" \ 230 ${i} > ${j}'/'${n_f} 231 chmod u+x ${j}'/'${n_f} 249 i_f=${i##*/}; 250 [[ ${i_f} = 'AA_job' ]] && { continue; } 251 j=${i%/*}; n_f=${i_f#AA_}'.job'; 252 [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } 253 [[ ${x_v} = 'verbose' ]] && print - "\nIn directory ${j}\n${i_f} -> ${n_f}" 254 sed -e "/^${W_W} */ s///" \ 255 -e "s%::modipsl::%${F_MOD}%" \ 256 -e "/^${W_P}/d" \ 257 -e "s/::default_project::/${ProjectID}/" \ 258 ${i} > ${j}'/'${n_f} 259 chmod u+x ${j}'/'${n_f} 232 260 done 233 261 #-
Note: See TracChangeset
for help on using the changeset viewer.