@@ -228,8 +228,7 @@ setup (const std::map<std::string,std::shared_ptr<fm_type>>& field_mgrs,
228
228
const auto & last_output_filename = get_attribute<std::string>(rhist_file," GLOBAL" ," last_output_filename" );
229
229
m_resume_output_file = last_output_filename!=" " and not restart_pl.get (" force_new_file" ,false );
230
230
if (m_resume_output_file) {
231
- int num_snaps = scorpio::get_attribute<int >(rhist_file," GLOBAL" ," last_output_file_num_snaps" );
232
- m_output_file_specs.storage .num_snapshots_in_file = num_snaps;
231
+ m_output_file_specs.storage .num_snapshots_in_file = scorpio::get_attribute<int >(rhist_file," GLOBAL" ," last_output_file_num_snaps" );
233
232
234
233
if (m_output_file_specs.storage .snapshot_fits (m_output_control.next_write_ts )) {
235
234
// The setup_file call will not register any new variable (the file is in Append mode,
@@ -500,10 +499,7 @@ void OutputManager::run(const util::TimeStamp& timestamp)
500
499
write_timestamp (filespecs.filename ," last_write" ,m_output_control.last_write_ts ,true );
501
500
scorpio::set_attribute (filespecs.filename ," GLOBAL" ," last_output_filename" ,m_output_file_specs.filename );
502
501
scorpio::set_attribute (filespecs.filename ," GLOBAL" ," num_snapshots_since_last_write" ,m_output_control.nsamples_since_last_write );
503
-
504
- int nsnaps = m_output_file_specs.is_open
505
- ? scorpio::get_dimlen (m_output_file_specs.filename ," time" ) : 0 ;
506
- scorpio::set_attribute (filespecs.filename ," GLOBAL" ," last_output_file_num_snaps" ,nsnaps);
502
+ scorpio::set_attribute (filespecs.filename ," GLOBAL" ," last_output_file_num_snaps" ,m_output_file_specs.storage .num_snapshots_in_file );
507
503
}
508
504
// Write these in both output and rhist file. The former, b/c we need these info when we postprocess
509
505
// output, and the latter b/c we want to make sure these params don't change across restarts
@@ -563,6 +559,11 @@ void OutputManager::run(const util::TimeStamp& timestamp)
563
559
}
564
560
if (is_checkpoint_step) {
565
561
write_global_data (m_checkpoint_control,m_checkpoint_file_specs);
562
+
563
+ // Always flush output during checkpoints (assuming we opened it already)
564
+ if (m_output_file_specs.is_open ) {
565
+ scorpio::flush_file (m_output_file_specs.filename );
566
+ }
566
567
}
567
568
stop_timer (timer_root+" ::update_snapshot_tally" );
568
569
if (is_output_step && m_time_bnds.size ()>0 ) {
@@ -636,16 +637,16 @@ compute_filename (const IOFileSpecs& file_specs,
636
637
auto ts = (m_avg_type==OutputAvgType::Instant || file_specs.ftype ==FileType::HistoryRestart)
637
638
? timestamp : control.last_write_ts ;
638
639
640
+ int ts_string_len = 0 ;
639
641
switch (file_specs.storage .type ) {
640
- case NumSnaps:
641
- filename += " ." + ts.to_string (); break ;
642
- case Yearly:
643
- filename += " ." + std::to_string (ts.get_year ()); break ;
644
- case Monthly:
645
- filename += " ." + std::to_string (ts.get_year ()) + " -" + std::to_string (ts.get_month ()); break ;
642
+ case Yearly: ts_string_len = 4 ; break ; // YYYY
643
+ case Monthly: ts_string_len = 7 ; break ; // YYYY-MM
644
+ case Daily: ts_string_len = 10 ; break ; // YYYY-MM-DD
645
+ case NumSnaps: ts_string_len = 16 ; break ; // YYYY-MM-DD-XXXXX
646
646
default :
647
647
EKAT_ERROR_MSG (" Error! Unrecognized/unsupported file storage type.\n " );
648
648
}
649
+ filename += " ." + ts.to_string ().substr (0 ,ts_string_len);
649
650
650
651
return filename + " .nc" ;
651
652
}
@@ -701,6 +702,8 @@ setup_internals (const std::map<std::string,std::shared_ptr<fm_type>>& field_mgr
701
702
storage.type = Yearly;
702
703
} else if (storage_type==" one_month" ) {
703
704
storage.type = Monthly;
705
+ } else if (storage_type==" one_day" ) {
706
+ storage.type = Daily;
704
707
} else {
705
708
EKAT_ERROR_MSG (" Error! Unrecognized/unsupported file storage type.\n " );
706
709
}
0 commit comments