#!/bin/ksh #************************************************************** # Author: Sebastien Denvil # Contact: Sebastien.Denvil@ipsl.jussieu.fr # $Date: $ # $Author: $ # $Revision: $ # IPSL (2006) # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC # History: # Modification: # #************************************************************** # Check that everything went well during time series production # Display a short report # Launch what's missing # libIGCM=${libIGCM:=::modipsl::/libIGCM} # POST_DIR=${POST_DIR:=OutScript} # Type de run EXPERIMENT=${EXPERIMENT:=historical} # Type de run JobName=${JobName:=HISTORC2} # CURRENT_DIR=$( pwd ) # CARD_DIR=${CURRENT_DIR}/${EXPERIMENT}/${JobName} if [ ! -d ${CARD_DIR} ]; then echo "No ${CARD_DIR}, we stop here" exit fi ######################################################################## . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh ; . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh #; IGCM_debug_Check . ${libIGCM}/libIGCM_card/libIGCM_card.ksh #; IGCM_card_Check . ${libIGCM}/libIGCM_date/libIGCM_date.ksh #; IGCM_date_Check ######################################################################## # First of all IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card UserChoices typeset option for option in ${config_UserChoices[*]} ; do IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card UserChoices ${option} done echo IGCM_debug_Print 1 "DefineArrayFromOption : config_UserChoices" IGCM_debug_PrintVariables 3 config_UserChoices_JobName #IGCM_debug_PrintVariables 3 config_UserChoices_SpaceName #IGCM_debug_PrintVariables 3 config_UserChoices_ExperimentName IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd echo #set -vx #==================================================== #R_SAVE : Job output directory if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} else R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} fi IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents for comp in ${config_ListOfComponents[*]} ; do # Debug Print IGCM_debug_Print 1 ${comp} # Define component IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp} eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 # Read libIGCM compatibility version in ${compname}.card card=${CARD_DIR}/COMP/${compname}.card # Read and Build Output File stuff #IGCM_debug_Print 1 "DefineArrayFromOption : ${compname}_OutputFiles ${card}" IGCM_card_DefineArrayFromOption ${card} OutputFiles List ListFilesName=${compname}_OutputFiles_List eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 # if [ X${FileName0} != X${NULL_STR} ] ; then # #IGCM_debug_Print 1 "Component : ${compname}" # # INITIALISATION # eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 i=2 # until [ $i -ge $NbFiles ]; do # eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1 # if [ X${flag_post} != XNONE ] ; then # # First of all # IGCM_card_DefineArrayFromSection ${card} ${flag_post} # IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not found ${flag_post}" ] ; then # New TimeSeriesVar description, with 2D, 3D and associate ChunckJob. ListDimension[0]=2D ListDimension[1]=3D TimeSeries=false TimeSeries2D=false TimeSeries3D=false iLoop=${#ListDimension[*]} j=0 until [ $j -ge ${iLoop} ]; do Dimension=${ListDimension[${j}]} IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars${Dimension} IGCM_card_DefineVariableFromOption ${card} ${flag_post} ChunckJob${Dimension} # # Time series WITHOUT chunk # if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then if [ $( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) = NONE ] ; then IGCM_debug_Print 2 "${Dimension} time series activated for ${flag_post}" eval TimeSeries${Dimension}=true chunck=false fi fi # # Time series WITH chunk # if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then chunck_size=$( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) if [ ! ${chunck_size} = NONE ] && [ ! ${chunck_size} = OFF ] ; then IGCM_debug_Print 2 "${Dimension} time series activated with ${chunck_size} chunck for ${flag_post}" eval TimeSeriesChunck${Dimension}=true chunck=true fi fi (( j=j+1 )) # # ICI ON TEST QUE LES FICHIERS TS SONT LA! # # FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' ) IGCM_card_DefineArrayFromOption ${card} Post_${FILE} TimeSeriesVars${Dimension} IGCM_card_DefineVariableFromOption ${card} Post_${FILE} ChunckJob${Dimension} # FlagDir=$( echo ${FILE} | awk -F "_" '{print $1}' ) case ${FlagDir} in *Y) TS_Dir=TS_YE ;; *M) TS_Dir=TS_MO ;; *D) TS_Dir=TS_DA ;; 3H|HF) TS_Dir=TS_HF ;; INS) TS_Dir=TS_INS ;; esac # # If TimeSeriesVars list is empty we skip # if [ $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then #(( i=i+3 )) continue fi # # We need LIST of variables not allready produced (useful for standalone mode) # DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) IGCM_date_GetYearMonth ${DateBegin} YearBegin MonthBegin IGCM_date_GetYearMonth ${DateEnd} YearEnd MonthEnd # Si on n'a pas de chunck, dans ce cas chunck_size=la durée de la simulation en années YearsChunckLength=$( echo ${chunck_size} | sed -e "s/[yY]//" ) [ ${chunck} = false ] && YearsChunckLength=$( expr \( ${YearEnd} \- ${YearBegin} \+ 1 \) ) NbYearsChunckLoop=$( expr \( ${YearEnd} \- ${YearBegin} \+ 1 \) / ${YearsChunckLength} ) Reste=$( expr \( ${YearEnd} \- ${YearBegin} \+ 1 \) % ${YearsChunckLength} ) if [ ${Reste} != 0 ] ; then NbYearsChunckLoop=$( expr ${NbYearsChunckLoop} + 1 ) fi if [ ${NbYearsChunckLoop} -eq 1 ] ; then PeriodDateEnd=${DateEnd} else DaysInYear=$( IGCM_date_DaysInYear ${YearBegin} ) PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( YearsChunckLength * DaysInYear - 1 )) ) fi # DIRECTORY=${R_SAVE}/${comp}/Analyse/${TS_Dir} YearsChunckLoop=1 ChunckDebut=${DateBegin} ChunckFin=${PeriodDateEnd} while [ ${YearsChunckLoop} -le ${NbYearsChunckLoop} ] ; do countTotal=0 countGood=0 countBad=0 for var in $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}[*]} ) ; do TestedFile=${config_UserChoices_JobName}_${ChunckDebut}_${ChunckFin}_${FlagDir}_${var}.nc # if [ ! -f ${DIRECTORY}/${TestedFile} ] ; then (( countBad = countBad + 1 )) [ ${countBad} = 1 ] && IGCM_debug_Print 3 "Missing time series from ${FILE} :" IGCM_debug_Print 3 ${DIRECTORY}/${TestedFile} else (( countGood = countGood + 1 )) fi (( countTotal = countTotal + 1 )) done SuccessRate=$(( countGood * 100 / countTotal )) if [ ! ${SuccessRate} = 100 ] ; then IGCM_debug_Print 2 -e "\033[1;31m${SuccessRate}% files OK.\033[m for period ${ChunckDebut}-${ChunckFin}" else IGCM_debug_Print 2 -e "\033[1;32m${SuccessRate}% files OK.\033[m for period ${ChunckDebut}-${ChunckFin}" fi echo if ( [ ${chunck} = true ] && [ ! ${SuccessRate} = 100 ] ) ; then IGCM_debug_Print 2 -e "\033[1;31mSubmit ${FILE} chunck ${Dimension}\033[m period ${ChunckDebut}-${ChunckFin}" listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,TsTask,CompToRead,FlagToRead" export libIGCM=${libIGCM} export SUBMIT_DIR=${CARD_DIR} export POST_DIR=${POST_DIR} export DateBegin=${ChunckDebut} export PeriodDateEnd=${ChunckFin} export TsTask=Chunck${Dimension} export CompToRead=${comp} export FlagToRead=${i} export listVarEnv=${listVarEnv} IGCM_sys_MkdirWork ${POST_DIR} IGCM_debug_Verif_Exit IGCM_sys_QsubPost create_ts echo fi if ( [ ${chunck} = false ] && [ ! ${SuccessRate} = 100 ] ) ; then eval Launch${Dimension}=true fi # Date update ChunckDebut=$( IGCM_date_AddDaysToGregorianDate ${ChunckFin} 1 ) (( YearsChunckLoop = YearsChunckLoop + 1 )) if [ ${YearsChunckLoop} -eq ${NbYearsChunckLoop} ] ; then ChunckFin=${DateEnd} else #PeriodDateEnd=$( expr ${YearBegin} + ${YearsChunckLength} - 1 ) ChunckFin=$( IGCM_date_AddDaysToGregorianDate ${ChunckDebut} $(( YearsChunckLength * DaysInYear - 1 )) ) fi done done else ListDimension[0]="" TimeSeries=true TimeSeries2D=false TimeSeries3D=false TimeSeriesChunck2D=false TimeSeriesChunck3D=false fi fi (( i=i+3 )) done fi done # comp loop echo if [ X${Launch2D} = Xtrue ] ; then IGCM_debug_Print 2 -e "\033[1;31mSubmit 2D\033[m without chunck period ${DateBegin}-${DateEnd}" listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,TsTask" export libIGCM=${libIGCM} export SUBMIT_DIR=${CARD_DIR} export POST_DIR=${POST_DIR} export DateBegin=${DateBegin} export PeriodDateEnd=${DateEnd} export TsTask=2D export listVarEnv=${listVarEnv} IGCM_sys_MkdirWork ${POST_DIR} IGCM_debug_Verif_Exit IGCM_sys_QsubPost create_ts echo fi if [ X${Launch3D} = Xtrue ] ; then IGCM_debug_Print 2 -e "\033[1;31mSubmit 3D\033[m without chunck period ${DateBegin}-${DateEnd}" listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,TsTask" export libIGCM=${libIGCM} export SUBMIT_DIR=${CARD_DIR} export POST_DIR=${POST_DIR} export DateBegin=${DateBegin} export PeriodDateEnd=${DateEnd} export TsTask=3D export listVarEnv=${listVarEnv} IGCM_sys_MkdirWork ${POST_DIR} IGCM_debug_Verif_Exit IGCM_sys_QsubPost create_ts echo fi