Ignore:
Timestamp:
01/26/24 09:27:27 (4 months ago)
Author:
jgipsl
Message:

Added possibility to declare a restart file as optional which means that libIGCM want stop if the file is not found. Only a warning will be written.

For example, in the following case, if the routing_restart file is not available when starting the model or if it is not produced, libIGCM will not stop. But if the file sechiba_rest is not available, libIGCM will stop as usual.

[RestartFiles]
List=   (sechiba_rest_out.nc, sechiba_rest.nc, sechiba_rest_in.nc) ,\
        (routing_restart.nc, routing_restart.nc, routing_start.nc, OPTIONAL)
  • Read optional argument OPTIONAL on the line where the restart file is declared.
  • Each time when a restart file is not found for coping in or out, if the argument OPTIONAL is set, then just continue. If not set, the file is considered as MANDATORY and libIGCM will exist if it is missing as before.
  • on irene-amd and jean-zay, corrected a bug for the case in config.card DataProject?=DEFAULT


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh

    r1603 r1624  
    752752            eval file_out=${file_out_} 
    753753 
     754            (( i_ = i+2 )) 
     755            eval is_opt=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     756            if [ X${is_opt} = XOPTIONAL ] ; then 
     757                echo ${file_in} is optional 
     758                (( i=i+4 )) 
     759            else 
     760                is_opt="MANDATORY" 
     761                echo ${file_in} is mandatory 
     762                (( i=i+3 )) 
     763            fi 
     764            IGCM_debug_Print 3 "Now search for restart file ${file_in} which is ${is_opt} (in section do_start=y)" 
     765 
    754766            eval Date_tmp=\${config_${comp}_RestartDate} 
    755767            Date_r=$( IGCM_date_ConvertFormatToGregorian ${Date_tmp} ) 
     
    810822                  IGCM_debug_Print 3 "Restart files have been searched for in buffer and archive directory." 
    811823                  IGCM_debug_Print 3 "They have been searched for in packed and unpacked format." 
    812                   IGCM_debug_Exit "Please double check restart settings in config.card" 
    813                   IGCM_debug_Verif_Exit 
     824                  if [ ${is_opt} = 'OPTIONAL' ] ; then 
     825                    IGCM_debug_Print 3 "The restart file is optional. Now continue." 
     826                    nb_restart_file=0 
     827                    Tared=false 
     828                  else 
     829                    IGCM_debug_Exit "Please double check restart settings in config.card" 
     830                    IGCM_debug_Verif_Exit 
     831                  fi 
     832                fi       
     833              fi 
     834 
     835              if [ X${Tared} = Xtrue ] ; then 
     836                # The tar file exist but not sure all files are inside  
     837                IGCM_sys_PrepareTaredRestart ${TarFileFound} 
     838                TarFileLocation=$( basename ${TarFileFound} ) 
     839                nb_files=$( tar tvf ${TarFileLocation} | grep ${comp}_${generic_restart_file_name_in}*.${extension_in} | wc -l ) 
     840                if [ ${nb_files} -gt 0 ] ; then 
     841                    IGCM_debug_Print 1 "tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in}" 
     842                    tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in} 
     843                    nb_restart_file=$( IGCM_sys_CountFileBuffer ${comp}_${generic_restart_file_name_in}_????.${extension_in} ) 
     844                else 
     845                    # No file was found 
     846                    if [ ${is_opt} = 'OPTIONAL' ] ; then 
     847                        IGCM_debug_Print 3 "The restart file is not found in the tar file but it is optional. Now continue." 
     848                        nb_restart_file=0 
     849                        Tared=false 
     850                    else 
     851                        IGCM_debug_Print 3 "The restart file was not found in the tar file but it is mandatory." 
     852                        IGCM_debug_Exit "Please double check restart settings in config.card" 
     853                        IGCM_debug_Verif_Exit 
     854                    fi 
    814855                fi 
    815               fi 
    816               IGCM_sys_PrepareTaredRestart ${TarFileFound} 
    817               TarFileLocation=$( basename ${TarFileFound} ) 
    818               IGCM_debug_Print 1 "tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in}" 
    819               tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in} 
    820               nb_restart_file=$( IGCM_sys_CountFileBuffer ${comp}_${generic_restart_file_name_in}_????.${extension_in} ) 
     856              fi 
    821857            fi 
    822  
     858             
    823859            if [ ${nb_restart_file} -gt 1 ] ; then 
    824860              j=0                                      # BASH LINE NOT NEEDED 
     
    849885                IGCM_sys_Get ${Path_r}/${file_in_Name} ${file_out} 
    850886              elif [ X${Tared} = Xtrue ] ; then 
    851                 IGCM_sys_Mv ${comp}_${file_in_Name} ${file_out} 
     887                if [ -f ${comp}_${file_in_Name} ] ; then 
     888                   # The file exixt 
     889                   IGCM_sys_Mv ${comp}_${file_in_Name} ${file_out} 
     890                elif [ ${is_opt} = 'OPTIONAL' ] ; then 
     891                   IGCM_debug_Print 3 "The restart file is not found in the tar file but it is optional. Now continue." 
     892                else 
     893                   IGCM_debug_Print 3 "The restart file was not found in the tar file but it is mandatory." 
     894                   IGCM_debug_Exit "Please double check restart settings in config.card" 
     895                   IGCM_debug_Verif_Exit 
     896                fi 
    852897              fi 
    853898            fi 
    854             (( i=i+3 )) 
    855899          done 
    856900        else 
     
    874918          eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    875919          eval file_in=${file_in_} 
     920 
    876921          (( i_ = i+1 )) 
    877922          eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
    878923          eval file_out=${file_out_} 
     924 
     925          (( i_ = i+2 )) 
     926          eval is_opt=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     927          if [ X${is_opt} = XOPTIONAL ] ; then 
     928              # Read a forth argument 
     929              echo ${file_in} is optional 
     930              (( i=i+4 )) 
     931          else 
     932              is_opt="MANDATORY" 
     933              echo ${file_in} is mandatory 
     934              (( i=i+3 )) 
     935          fi 
     936 
     937          IGCM_debug_Print 3 "Now search for restart file ${file_in} which is ${is_opt} (in section do_start=n)" 
    879938 
    880939          file_in_Name=${config_UserChoices_JobName}_${LastPeriodDateEnd}_${file_in} 
     
    922981              IGCM_debug_Print 3 "Restart files have been searched for in buffer and archive directory." 
    923982              IGCM_debug_Print 3 "They have been searched for in packed and unpacked format." 
    924               IGCM_debug_Exit "Please double check restart settings in config.card" 
    925               IGCM_debug_Verif_Exit 
     983              if [ ${is_opt} = 'OPTIONAL' ] ; then 
     984                 IGCM_debug_Print 3 "The restart file is optional. Now continue." 
     985                 nb_restart_file=0 
     986                 Tared=false 
     987              else 
     988                 IGCM_debug_Print 3 "The restart file is mandatory." 
     989                 IGCM_debug_Exit "Please double check restart settings in config.card" 
     990                 IGCM_debug_Verif_Exit 
     991              fi 
     992            else 
     993              # The tar file exist but not sure all files are inside  
     994              IGCM_sys_PrepareTaredRestart ${TarFileFound} 
     995              TarFileLocation=$( basename ${TarFileFound} ) 
     996              nb_files=$( tar tvf ${TarFileLocation} | grep ${comp}_${generic_restart_file_name_in}*.${extension_in} | wc -l ) 
     997              if [ ${nb_files} -gt 0 ] ; then 
     998                IGCM_debug_Print 1 "tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in}" 
     999                tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in} 
     1000                nb_restart_file=$( IGCM_sys_CountFileBuffer ${comp}_${generic_restart_file_name_in}_????.${extension_in} ) 
     1001              else 
     1002                # No file was found 
     1003                if [ ${is_opt} = 'OPTIONAL' ] ; then 
     1004                  IGCM_debug_Print 3 "The restart file is not found in the tar file but it is optional. Now continue." 
     1005                  nb_restart_file=0 
     1006                  Tared=false 
     1007                else 
     1008                  IGCM_debug_Print 3 "The restart file was not found in the tar file but it is mandatory." 
     1009                  IGCM_debug_Exit "Please double check restart settings in config.card" 
     1010                  IGCM_debug_Verif_Exit 
     1011                fi 
     1012              fi 
     1013 
    9261014            fi 
    927             IGCM_sys_PrepareTaredRestart ${TarFileFound} 
    928             TarFileLocation=$( basename ${TarFileFound} ) 
    929             IGCM_debug_Print 1 "tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in}" 
    930             tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in} 
    931             nb_restart_file=$( IGCM_sys_CountFileBuffer ${comp}_${generic_restart_file_name_in}_????.${extension_in} ) 
    9321015          fi 
    9331016 
     
    9551038            fi 
    9561039          fi 
    957           (( i=i+3 )) 
    9581040        done 
    9591041      else 
     
    17321814    ListFilesName=${compname}_RestartFiles_List 
    17331815    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
    1734  
     1816     
    17351817    if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then 
    17361818      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
    1737  
    17381819      (( i=0 )) 
    17391820      until [ $i -ge $NbFiles ]; do 
     
    17491830        eval file_outin=${file_outin_} 
    17501831 
     1832        (( i_ = i+3 )) 
     1833        eval is_opt=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     1834        if [ X${is_opt} = XOPTIONAL ] ; then 
     1835            echo ${file_in} is optional 
     1836            (( i=i+4 )) 
     1837        else 
     1838            is_opt="" 
     1839            echo ${file_in} is mandatory 
     1840            (( i=i+3 )) 
     1841        fi 
     1842         
    17511843        generic_restart_file_name_in=$(    basename ${file_in} .nc ) 
    17521844        generic_restart_file_name_out=$(   basename ${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} .nc ) 
     
    17601852            j4=${j}                               # BASH LINE NOT NEEDED 
    17611853            if [ X${Pack} = Xtrue ] ; then 
    1762               eval IGCM_sys_PutBuffer_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_BUF_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc 
     1854              eval IGCM_sys_PutBuffer_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_BUF_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc ${is_opt} 
    17631855            else 
    1764               eval IGCM_sys_Put_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_OUT_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc 
     1856              eval IGCM_sys_Put_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_OUT_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc ${is_opt} 
    17651857            fi 
    1766             if [ ! ${file_in} = ${file_outin} ] ; then 
    1767               if ( ${ExitFlag} ) ; then 
    1768                 echo "IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc not executed." 
    1769               else 
    1770                 IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc 
    1771               fi 
    1772             fi 
     1858 
     1859            if [ -f  ${generic_restart_file_name_in}_${j4}.nc ] ; then 
     1860                if [ ! ${file_in} = ${file_outin} ] ; then 
     1861                    if ( ${ExitFlag} ) ; then 
     1862                        echo "IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc not executed." 
     1863                    else 
     1864                        IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc 
     1865                    fi 
     1866                fi 
     1867            else 
     1868                # This is the case where the restart file no not exist. 
     1869                # It has already been checked if the model should stop for this case. 
     1870                IGCM_debug_Print 1 "Restart file does not exist, no move in RUN_DIR done :  ${generic_restart_file_name_in}_${j4}.nc" 
     1871            fi 
    17731872            (( j=j+1 ))                           # BASH LINE NOT NEEDED 
    17741873          done 
    17751874        else 
    17761875          if [ X${Pack} = Xtrue ] ; then 
    1777             eval IGCM_sys_PutBuffer_Rest ${file_in} \${R_BUF_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} 
     1876            eval IGCM_sys_PutBuffer_Rest ${file_in} \${R_BUF_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} ${is_opt} 
    17781877          else 
    1779             eval IGCM_sys_Put_Rest ${file_in} \${R_OUT_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} 
     1878            eval IGCM_sys_Put_Rest ${file_in} \${R_OUT_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} ${is_opt} 
    17801879          fi 
    1781           if [ ! ${file_in} = ${file_outin} ] ; then 
    1782             if ( ${ExitFlag} ) ; then 
    1783               echo "IGCM_sys_Mv ${file_in} ${file_outin} not executed." 
    1784             else 
    1785               IGCM_sys_Mv ${file_in} ${file_outin} 
    1786             fi 
    1787           fi 
     1880 
     1881          if [ -f ${file_in} ] ; then 
     1882              if [ ! ${file_in} = ${file_outin} ] ; then 
     1883                  if ( ${ExitFlag} ) ; then 
     1884                      echo "IGCM_sys_Mv ${file_in} ${file_outin} not executed." 
     1885                  else 
     1886                      IGCM_sys_Mv ${file_in} ${file_outin} 
     1887                  fi 
     1888              fi 
     1889          else 
     1890              # This is the case where the restart file no not exist. 
     1891              # It has already been checked if the model should stop for this case. 
     1892              IGCM_debug_Print 1 "Restart file does not exist, no move in RUN_DIR done :   ${file_in}" 
     1893          fi 
    17881894        fi 
    17891895 
    1790         (( i=i+3 )) 
    17911896      done 
    17921897    else 
Note: See TracChangeset for help on using the changeset viewer.