diff --git a/cime_config/cesm/archive.xml b/cime_config/cesm/archive.xml index a4f4e4a71c1..a0ce8071a07 100644 --- a/cime_config/cesm/archive.xml +++ b/cime_config/cesm/archive.xml @@ -345,7 +345,7 @@ hist false - + hist false diff --git a/cime_config/cesm/machines/config_lt_archive.xml b/cime_config/cesm/machines/config_lt_archive.xml index 3f10dc2116d..48c4504a503 100644 --- a/cime_config/cesm/machines/config_lt_archive.xml +++ b/cime_config/cesm/machines/config_lt_archive.xml @@ -16,10 +16,4 @@ --mode copy_dirs_ssh --ssh_loc lfe --rm_loc_files TRUE - - - - - --mode copy_files - diff --git a/cime_config/cesm/machines/template.ltarchive b/cime_config/cesm/machines/template.lt_archive similarity index 63% rename from cime_config/cesm/machines/template.ltarchive rename to cime_config/cesm/machines/template.lt_archive index 68db47dc788..131fe443a89 100644 --- a/cime_config/cesm/machines/template.ltarchive +++ b/cime_config/cesm/machines/template.lt_archive @@ -43,6 +43,64 @@ my $logger = Log::Log4perl::get_logger(); # global data needed by the script, stuff like the max number of threads, # ------------------------------------------------------------------------- +#----------------------------------------------------------------------------------------------- +# checkRun - check if run is complete +#----------------------------------------------------------------------------------------------- +sub checkRun +{ + my $statusFile = shift; + my $runComplete = 0; + + $logger->debug("In checkRun..."); +# +# check if the run completed successfully +# + if( -f $statusFile ) + { + open my $CASESTATUS, "<", "$statusFile" or die qq(lt_archive: unable to open $statusFile. Exiting...\n); + while( <$CASESTATUS> ) + { + chomp $_; + if( /^run SUCCESSFUL/ ) + { + $runComplete = 1; + } + } + close( $CASESTATUS ); + } +} + +#----------------------------------------------------------------------------------------------- +# checkSta - check if short term archive is complete +#----------------------------------------------------------------------------------------------- +sub checkSta +{ + my $statusFile = shift; + my $staComplete = 0; + + $logger->debug("In checkSta..."); +# +# check if the short term archive completed successfully +# + if( -f $statusFile ) + { + open my $STASTATUS, "<", "$statusFile" or die qq(lt_archive: unable to open $statusFile. Exiting...\n); + while( <$STASTATUS> ) + { + chomp $_; + if( /^st_archive process complete/ ) + { + $staComplete = 1; + } + } + close( $STASTATUS ); + } +} + + +#----------------------------------------------------------------------------------------------- +# main +#----------------------------------------------------------------------------------------------- sub main { $ENV{'maxthrds'} = 1; @@ -71,7 +129,6 @@ sub main $ENV{DOUT_S_ROOT} = $config{'DOUT_S_ROOT'}; $ENV{DOUT_L_MSROOT} = $config{'DOUT_L_MSROOT'}; $ENV{DOUT_L_HPSS_ACCNT} = $config{'DOUT_L_HPSS_ACCNT'}; - $ENV{DOUT_L_SAVE_ALL_ON_DISK} = $config{'DOUT_L_SAVE_ALL_ON_DISK'}; my $LID = strftime("%y%m%d-%H%M%S", localtime); @@ -93,6 +150,10 @@ sub main resubmitCheck(); } +#----------------------------------------------------------------------------------------------- +# resubmitCheck - check if the case needs to be resubmitted +#----------------------------------------------------------------------------------------------- + sub resubmitCheck() { if($config{RESUBMIT} > 0) @@ -100,7 +161,7 @@ sub resubmitCheck() my $submitscript = "$config{CASEROOT}/$config{CASE}.submit"; my $cwd = getcwd; chdir $config{CASEROOT}; - my $resubmitcomand = "$submitscript -resubmit -scriptname $config{'CASE'}.lt_archive"; + my $resubmitcommand = "$submitscript -resubmit -scriptname $config{'CASE'}.lt_archive"; $logger->debug(" running resubmit check $resubmitcommand"); if(-e $testlog) { diff --git a/cime_config/cesm/machines/template.starchive b/cime_config/cesm/machines/template.st_archive similarity index 100% rename from cime_config/cesm/machines/template.starchive rename to cime_config/cesm/machines/template.st_archive diff --git a/driver_cpl/cime_config/config_component.xml b/driver_cpl/cime_config/config_component.xml index 92e6c17e3d8..20c2678f3d9 100644 --- a/driver_cpl/cime_config/config_component.xml +++ b/driver_cpl/cime_config/config_component.xml @@ -432,25 +432,30 @@ We will not document this further in this guide. - - integer - 0 + + string + all run_data_archive env_run.xml - Save every Nth set of restart files and delete all others - If value is greater than 0, then only save the nth restart set in the $DOUT_S_ROOT/$CASE/rest location. - Always preserve the most recent restart set regardless. + Comma separated List with dates of the month to save restart file sets in the $DOUT_S_ROOT/$CASE/rest directory. + If one of the list elements is last, then it saves the last day of the month where the date is 28,29,30 or 31 + depending on the month. For example, if the list contains 10,20,last, then the corresponding restart sets + saved in $DOUT_S_ROOT/$CASE/rest are 2016-01-10-00000, 2016-01-20-00000, 2016-01-31-00000 for January and + 2016-02-10-00000, 2016-02-20-00000, 2016-02-29-00000 for February due to 2016 being a leap year. + If the list is set to none, then all restart sets are deleted. + If the list is set to all (default), then all restart sets are saved. + This variable is used by the clobber_archive script to selectively delete files in the short-term archive locations. - + logical TRUE,FALSE TRUE run_data_archive env_run.xml - logical to save contents of the short term archive on disk - If TRUE, create hardlinks from the short term archive $DOUT_S_ROOT.locked/$CASE - directory to the $DOUT_S_ROOT/$CASE directory. + Logical to save contents of the short term archive on disk. + If TRUE, create hardlinks from the short term archive $DOUT_S_ROOT/archive.locked/$CASE + directory to the $DOUT_S_ROOT/archive/$CASE directory. @@ -471,16 +476,6 @@ - - logical - TRUE,FALSE - TRUE - run_data_archive - env_run.xml - Save contents of short term archive on disk after the long term archiver has successfully completed - If TRUE, this keeps the output data in DOUT_S_ROOT on disk after the long term (lt_archive.sh) archiver is run. - - diff --git a/scripts/Tools/case.setup b/scripts/Tools/case.setup index 2db45f3e1a5..a7dc438071f 100755 --- a/scripts/Tools/case.setup +++ b/scripts/Tools/case.setup @@ -280,12 +280,12 @@ if (! $clean ) { $logger->info("Creating batch script case.st_archive"); $batchmaker->overrideNodeCount(1); $batchmaker->set({job=>'st_archive'}); - $batchmaker->makeBatchScript("$xmlvars{'MACHDIR'}/template.starchive", "$xmlvars{'CASEROOT'}/case.st_archive"); + $batchmaker->makeBatchScript("$xmlvars{'MACHDIR'}/template.st_archive", "$xmlvars{'CASEROOT'}/case.st_archive"); $logger->info("Creating batch script case.lt_archive"); $batchmaker->overrideNodeCount(1); $batchmaker->set({job=>'lt_archive'}); - $batchmaker->makeBatchScript("$xmlvars{'MACHDIR'}/template.ltarchive", "$xmlvars{'CASEROOT'}/case.lt_archive"); + $batchmaker->makeBatchScript("$xmlvars{'MACHDIR'}/template.lt_archive", "$xmlvars{'CASEROOT'}/case.lt_archive"); # Make a copy of env_mach_pes.xml in order to be able # to check that it does not change once case.setup is invoked diff --git a/scripts/Tools/lt_archive.sh b/scripts/Tools/lt_archive.sh index 9a2666afa0e..c943cb8f0f0 100755 --- a/scripts/Tools/lt_archive.sh +++ b/scripts/Tools/lt_archive.sh @@ -182,24 +182,14 @@ if [ "$mode" == "copy_dirs_hsi" ]; then exit -1 fi - # Long-term archiver for HPSS (Trey White, December 6, 2011) date - if [ ! $?DOUT_L_HPSS_ACCNT ]; then - DOUT_L_HPSS_ACCNT=0 - fi - - # check if files on st_archive should be saved or not - saveFlag="-dPR" - if [ $DOUT_L_SAVE_ALL_ON_DISK == "TRUE" ] ; then - saveFlag="-PR" - fi - - # send files to HPSS and delete upon success + # send files to HPSS + saveFlag="-PR" cd $DOUT_S_ROOT hsiArgs="mkdir -p $DOUT_L_MSROOT ; chmod +t $DOUT_L_MSROOT ; cd $DOUT_L_MSROOT ; put $saveFlag *" # echo $hsiArgs - if [ $DOUT_L_HPSS_ACCNT -gt 0 ]; then + if ! [[ "$DOUT_L_HPSS_ACCNT" =~ "0000*" ]]; then hsi -a $DOUT_L_HPSS_ACCNT "$hsiArgs" else hsi "$hsiArgs" @@ -317,8 +307,6 @@ if [ "$mode" == "copy_dirs_local" ]; then rm -f ${file} else echo "local file and long-term archive file are NOT the same size... ${file} will remain on local disk" - #exit -1 #??? ask francis if this is right - # Not sure what to do here... maybe make the log entry and carry on... fi fi done # for file diff --git a/scripts/Tools/st_archive b/scripts/Tools/st_archive index 23fa165659c..3b0573fca97 100755 --- a/scripts/Tools/st_archive +++ b/scripts/Tools/st_archive @@ -161,7 +161,7 @@ THAT ARE INCLUDED IN THE ENV_RUN.XML FILE archive files. The st_archive creates an archive locked directory (ARCHIVE_DIR_LOCKED) using the basename of the DOUT_S_ROOT location. - DOUT_S_SAVE_ALL_ON_DISK - [boolean] If set to TRUE (default), then + DOUT_S_CREATE_LINKED_ARCHIVE - [boolean] If set to TRUE (default), then the st_archive creates an archive linked directory (\$ARCHIVE_DIR_LINKED) using the basename of the \$DOUT_S_ROOT location. The \$ARCHIVE_DIR_LOCKED and \$ARCHIVE_DIR_LINKED @@ -188,32 +188,24 @@ THAT ARE INCLUDED IN THE ENV_RUN.XML FILE run. This is for expert users ONLY and requires expert knowledge. We will not document this further in this guide. - DOUT_S_SAVE_EVERY_NTH_RESTART_FILE_SET - [integer] If value is - greater than 0 (default), then only save the nth restart set in - the \$DOUT_S_ROOT/rest location. Always preserve the most recent - restart set regardless. - USAGE st_archive [options] OPTIONS - -help [or -h] Print usage to STDOUT. - - -input List out the contents of the env_archive.xml datafile in a - friendly format and check the env_archive.xml file for - validity. + -help|-h Print usage to STDOUT. - -output List out the contents of the archive directory. + -input|-in List out the contents of the env_archive.xml datafile in a + friendly format and check the env_archive.xml file for + validity. - -clean Create / update hardlinks in both the \$ARCHIVE_DIR_LOCKED - and \$ARCHIVE_DIR_LINKED for duplicate files. + -output|-out List out the contents of the archive directory. - -link Create / update the hardlinks from the \$ARCHIVE_DIR_LINKED - to the \$ARCHIVE_DIR_LOCKED. + -link Create / update the hardlinks from the \$ARCHIVE_DIR_LINKED + to the \$ARCHIVE_DIR_LOCKED. - -undo move all the files from the \$ARCHIVE_DIR_LOCKED back into the \$RUNDIR + -undo move all the files from the \$ARCHIVE_DIR_LOCKED back into the \$RUNDIR - -loglevel - set level of output from this script DEBUG, INFO, WARN, ERROR, FATAL (default INFO) + -loglevel set level of output from this script DEBUG, INFO, WARN, ERROR, FATAL (default INFO) EOF #" added per for emacs perl mode parsing @@ -232,7 +224,6 @@ sub getOptions "h|help" => \$opts{'help'}, "in|input" => \$opts{'input'}, "out|output" => \$opts{'output'}, - "clean" => \$opts{'clean'}, "link" => \$opts{'link'}, "undo" => \$opts{'undo'}, "loglevel" => \$opts{loglevel} @@ -282,7 +273,7 @@ and the short term st_archive is active. A parallel directory located in DOUT_S_ROOT is available for *READ ONLY* operations on CESM model output files. The short term archiver (st_archive) automatically creates and populates this directory with hard linked filenames -when the environment variable DOUT_S_SAVE_ALL_ON_DISK is set to TRUE. Users +when the environment variable DOUT_S_CREATE_LINKED_ARCHIVE is set to TRUE. Users may run diagnostics and post-processing routines in this location while the model is running and st_archive is also running. However, be aware that the file names in this directory may not change but @@ -318,10 +309,6 @@ EOD } close( $CASESTATUS ); } - if( !defined $config{'DOUT_S_SAVE_EVERY_NTH_RESTART_FILE_SET'} || uc($config{'DOUT_S_SAVE_EVERY_NTH_RESTART_FILE_SET'}) eq 'UNSET' ) - { - $config{'DOUT_S_SAVE_EVERY_NTH_RESTART_FILE_SET'} = 0; - } return $runComplete; } @@ -541,7 +528,7 @@ sub processHardlinks This directory is available for *READ ONLY* operations on CESM model output files that have been written by the short term archiver (st_archive). This directory is automatically created and populated with hard linked -filenames when the environment variable DOUT_S_SAVE_ALL_ON_DISK is set to TRUE. +filenames when the environment variable DOUT_S_CREATE_LINKED_ARCHIVE is set to TRUE. Users may run diagnostics and post-processing routines in this location while the model is running and st_archive is also running. @@ -566,8 +553,7 @@ EOD #----------------------------------------------------------------------------------------------- # undoArchive routine loops through the ARCHIVE_DIR_LOCKED getting the list of archived files -# and unlinks the corresponding file in the ARCHIVE_DIR_LINKED and then moves the file back -# into the RUNDIR +# and then moves the file back into the RUNDIR. This has no affect on the ARCHIVE_DIR_LINKED files. #----------------------------------------------------------------------------------------------- sub undoArchive { @@ -661,7 +647,7 @@ sub moveFiles } # # also get the file that matches the dname for this suffix and -# add a hardlink to the restdir +# copy to the restdir for a complete restart set # my @restFiles = grep(/${dname}/, @files); if( $#restFiles == 0 ) { @@ -669,7 +655,7 @@ sub moveFiles if ( $#path >= 0 ) { $restFile = $path[$#path]; if ( -f $dest . "/" . $restFile ) { - link ( $dest . "/" . $restFile, $restdir . "/" . $restFile ); + copy( $dest . "/" . $restFile, $restdir . "/" . $restFile ); } } } @@ -808,49 +794,6 @@ sub getRestartDirs return ( @sorteddirs ); } -#----------------------------------------------------------------------------------------------- -# short term archive clean - checks the DOUT_S_SAVE_EVERY_NTH_RESTART_FILE_SET option and deletes all -# restart sets that are not either the Nth set or the last set. -#----------------------------------------------------------------------------------------------- -sub cleanArchive -{ - my ($i, $j) = 0; - my @indeces; - my $linkeddir; - - $logger->debug("In cleanArchive..."); - - my @sorteddirs = getRestartDirs(); - my $numsubdirs = @sorteddirs; - -# this code may no longer be needed with the new DART loop in the run script... - if( $config{'DOUT_S_SAVE_EVERY_NTH_RESTART_FILE_SET'} > 1 ) - { -# save every nth restart file set - for( $i = 0; $i < $numsubdirs; $i += $config{'DOUT_S_SAVE_EVERY_NTH_RESTART_FILE_SET'} ) - { - push( @indeces, $i ); - } - - for my $index (0 .. $#indeces-1) - { - my $start = $index; - my $end = $indeces[$index+1]; - for( $j = $start+1; $j < $end; $j++ ) - { -# remove the restart directory - this deletes the rpointer files but not the component intermediate restart files - rmtree $sorteddirs[$j]; -# do the same for the archive dir - if( $config{'DOUT_S_SAVE_ALL_ON_DISK'} eq 'TRUE' ) { - $linkeddir = $sorteddirs[$j]; - $linkeddir =~ s/\.locked//; - rmtree $linkeddir; - } - } - } - } -} - #----------------------------------------------------------------------------------------------- # Main program #----------------------------------------------------------------------------------------------- @@ -880,15 +823,6 @@ sub main $logger->info("Short-term archive listing of $config{'ARCHIVE_DIR_LOCKED'}:"); listArchive( $config{'ARCHIVE_DIR_LOCKED'} ); } - elsif( defined $opts{'clean'} && $runComplete ) - { -# -# clean up the archive directory and check if need to delete -# the nth occurance of restart sets -# - $dname = getDname(); - cleanArchive(); - } elsif( defined $opts{'link'} && $runComplete ) { # @@ -918,13 +852,8 @@ sub main # run the short term archive process archiveProcess( $XMLin, $dname, \@runfiles ); -# -# clean up the archive directory and check if need to delete -# the nth occurance of restart sets -# - cleanArchive(); - if( $config{'DOUT_S_SAVE_ALL_ON_DISK'} eq 'TRUE' ) { + if( $config{'DOUT_S_CREATE_LINKED_ARCHIVE'} eq 'TRUE' ) { # # create the hard links in the ARCHIVE_DIR_LINKED directory #