[677] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Sonia Labetoulle |
---|
| 5 | # Contact: Sonia.Labetoulle__at__locean-ipsl.upmc.fr |
---|
| 6 | # $Revision::$ Revision of last commit |
---|
| 7 | # $Author::$ Author of last commit |
---|
| 8 | # $Date::$ Date of last commit |
---|
| 9 | # IPSL (2012) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
| 13 | |
---|
| 14 | function IGCM_ensemble_FilesUpdate |
---|
| 15 | { |
---|
| 16 | IGCM_debug_PushStack "IGCM_ensemble_FilesUpdate" |
---|
| 17 | |
---|
| 18 | # set -vx |
---|
| 19 | |
---|
| 20 | # Debug Print : |
---|
| 21 | echo |
---|
| 22 | IGCM_debug_Print 1 "IGCM_ensemble_FilesUpdate :" |
---|
| 23 | echo |
---|
| 24 | |
---|
| 25 | HumanDateBegin=$( IGCM_date_ConvertFormatToHuman ${1} ) |
---|
| 26 | HumanDateEnd=$( IGCM_date_ConvertFormatToHuman ${2} ) |
---|
| 27 | HumanRestartDate=$( IGCM_date_ConvertFormatToHuman ${3} ) |
---|
| 28 | # ==> config.card |
---|
| 29 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleRun 'y' |
---|
| 30 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleName ${ensemble_Ens_PERTURB_NAME} |
---|
| 31 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleDate ${StartDir} |
---|
| 32 | |
---|
| 33 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices JobName ${MemberDir} |
---|
| 34 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateBegin ${HumanDateBegin} |
---|
| 35 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateEnd ${HumanDateEnd} |
---|
| 36 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts OverRule "n" |
---|
| 37 | |
---|
| 38 | for Comp in ${config_ListOfComponents[*]} ; do |
---|
| 39 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} Restart "y" |
---|
| 40 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} RestartDate ${HumanRestartDate} |
---|
| 41 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} RestartJobName ${ensemble_Ens_PERTURB_INITFROM} |
---|
| 42 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} RestartPath ${ensemble_Ens_PERTURB_INITPATH} |
---|
| 43 | done |
---|
| 44 | # ==> Job |
---|
| 45 | # SD : to be encapsulated in a sys function |
---|
| 46 | sed -e "s/\(#MSUB -r \)[A-Za-z0-9]*\( *#.*\)/\1 ${MemberDir} \2/" \ |
---|
| 47 | -e "s/\(#MSUB -o Script_Output_\)[A-Za-z0-9]*\(\.*\)/\1${MemberDir}\2/" \ |
---|
| 48 | -e "s/\(#MSUB -e Script_Output_\)[A-Za-z0-9]*\(\.*\)/\1${MemberDir}\2/" \ |
---|
| 49 | ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp |
---|
| 50 | IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
| 51 | |
---|
| 52 | IGCM_debug_PopStack "IGCM_ensemble_FilesUpdate" |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | function IGCM_ensemble_DirectoryName |
---|
| 56 | { |
---|
| 57 | IGCM_debug_PushStack "IGCM_ensemble_DirectoryName" |
---|
| 58 | |
---|
| 59 | #.. Debug Print .. |
---|
| 60 | echo |
---|
| 61 | IGCM_debug_Print 1 "IGCM_ensemble_DirectoryName :" |
---|
| 62 | echo |
---|
| 63 | |
---|
| 64 | # set -vx |
---|
| 65 | |
---|
| 66 | Name=$1 |
---|
| 67 | Duree=$2 |
---|
| 68 | year=$3 |
---|
| 69 | month=$4 |
---|
| 70 | |
---|
| 71 | set -A AlphaMonth a b c d e f g h i j k l |
---|
| 72 | |
---|
| 73 | # - Build directory name |
---|
| 74 | case ${Duree} in |
---|
| 75 | *Y|*y) |
---|
| 76 | siecle="$( echo $year | cut -c1-2 )" |
---|
| 77 | siecle=$( (( $siecle - 18 )) ) |
---|
| 78 | StartYear="${siecle}$( echo $year | cut -c3-4 )" |
---|
| 79 | StartDir="${Name}${StartYear}" |
---|
| 80 | ;; |
---|
| 81 | *M|*m) |
---|
| 82 | echo $month |
---|
| 83 | siecle="$( echo $year | cut -c1-2 )" |
---|
| 84 | siecle=$( (( $siecle - 18 )) ) |
---|
| 85 | StartYear="${siecle}$( echo $year | cut -c3-4 )" |
---|
| 86 | StartMonth="${AlphaMonth[ (( $month - 1 )) ]}" |
---|
| 87 | StartDir="${Name}${StartYear}${StartMonth}" |
---|
| 88 | ;; |
---|
| 89 | esac |
---|
| 90 | |
---|
| 91 | IGCM_debug_PopStack "IGCM_ensemble_DirectoryName" |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | function IGCM_ensemble_PerturbFile |
---|
| 95 | { |
---|
| 96 | IGCM_debug_PushStack "IGCM_ensemble_PerturbFile" |
---|
| 97 | |
---|
| 98 | #.. Debug Print .. |
---|
| 99 | echo |
---|
| 100 | IGCM_debug_Print 1 "IGCM_ensemble_PerturbFile :" |
---|
| 101 | echo |
---|
| 102 | |
---|
| 103 | #.. FileIn ? => RestartDate .. |
---|
| 104 | DirIn="${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/${PerturbComp}/Restart" |
---|
| 105 | FileIn="${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${PerturbFile}.nc" |
---|
| 106 | DirOut="${RestartDir}/${MemberDir}/${PerturbComp}/Restart" |
---|
| 107 | # FileOut="${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${PerturbFile}_${MemberDir}.nc" |
---|
| 108 | # FileOut=${FileIn} |
---|
| 109 | FileOut="${MemberDir}_${RestartDate}_${PerturbFile}.nc" |
---|
| 110 | IGCM_debug_Print 1 "FileIn = ${DirIn}/${FileIn}" |
---|
| 111 | IGCM_debug_Print 1 "FileOut = ${DirOut}/${FileOut}" |
---|
| 112 | |
---|
| 113 | # * Create member restart directory |
---|
| 114 | IGCM_sys_TestDirArchive ${DirOut} |
---|
| 115 | RET=$? |
---|
| 116 | if [ $RET -gt 0 ] ; then |
---|
| 117 | IGCM_sys_MkdirArchive ${DirOut} |
---|
| 118 | fi |
---|
| 119 | |
---|
| 120 | IGCM_sys_TestFileArchive ${DirOut}/${FileOut} |
---|
| 121 | RET=$? |
---|
| 122 | if [ $RET -gt 0 ] ; then |
---|
| 123 | # ${PerturbExe} ${DirIn}/${FileIn} ${DirOut}/${FileOut} \ |
---|
| 124 | # ${PerturbVar} ${PerturbAmp} |
---|
| 125 | # IGCM_sys_Cp ${DirIn}/${FileIn} ${DirOut}/${FileOut} |
---|
| 126 | # IGCM_sys_Chmod u+w ${DirOut}/${FileOut} |
---|
| 127 | # ${PerturbExe} ${DirOut}/${FileOut} ${PerturbVar} ${PerturbAmp} |
---|
| 128 | IGCM_sys_Get ${DirIn}/${FileIn} ${RUN_DIR}/${FileOut} |
---|
| 129 | IGCM_sys_Chmod 744 ${RUN_DIR}/${FileOut} |
---|
| 130 | |
---|
| 131 | ${PerturbExe} ${RUN_DIR}/${FileOut} ${PerturbVar} ${PerturbAmp} |
---|
| 132 | if [ $? -ne 0 ] ; then |
---|
| 133 | echo "Abend $( basename ${PerturbExe} )" |
---|
| 134 | exit |
---|
| 135 | fi |
---|
| 136 | |
---|
| 137 | IGCM_sys_Put_Out ${RUN_DIR}/${FileOut} ${DirOut}/ 744 |
---|
| 138 | |
---|
| 139 | # IGCM_sys_Cd ${DirOut} |
---|
| 140 | # ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_flxat.nc ${MemberDir}_${RestartDate}_flxat.nc |
---|
| 141 | # IGCM_sys_Cd - |
---|
| 142 | IGCM_sys_RshArchive "cd ${DirOut} ; ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_flxat.nc ${MemberDir}_${RestartDate}_flxat.nc" |
---|
| 143 | fi |
---|
| 144 | |
---|
| 145 | #.. Update config.card.. |
---|
| 146 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} Restart "y" |
---|
| 147 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartDate ${HumanRestartDate} |
---|
| 148 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartJobName ${MemberDir} |
---|
| 149 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartPath ${RestartDir}/ |
---|
| 150 | |
---|
| 151 | IGCM_debug_PopStack "IGCM_ensemble_PerturbFile" |
---|
| 152 | } |
---|