Skip to content

Commit

Permalink
Per #2769, add tmp_nc_diag_flag config option to retain temporary files.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway committed Dec 28, 2023
1 parent 203bf44 commit c9e66c2
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 5 deletions.
5 changes: 5 additions & 0 deletions data/config/TCDiagConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ nc_cyl_grid_flag = TRUE; // ends with "_cyl_grid_{domain}.nc"
nc_diag_flag = TRUE; // ends with "_diag.nc"
cira_diag_flag = TRUE; // ends with "_diag.dat"

//
// Retain temporary NetCDF diagnostic files
//
tmp_nc_diag_flag = FALSE;

//
// Output base file naming convention
//
Expand Down
8 changes: 8 additions & 0 deletions docs/Users_Guide/tc-diag.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ These three flag entries are booleans specifying what output data types should b
- The **nc_diag_file** entry controls the writing of the computed diagnostics to a NetCDF file. These files are written with a `_diag.nc` suffix. One output file is written for each model track processed.
- The **cira_diag_flag** entry controls the writing of the computed diagnostics to a formatted ASCII output file. These files are written with a `_diag.dat` suffix. One output file is written for each model track processed.

.. code-block:: none
tmp_nc_diag_flag = FALSE;
This flag is a boolean specifying whether the temporary NetCDF files containing the cylindrical coordinate range-azimuth data for each storm location should be retained. By default, these temporary files are deleted. If set to true for debugging purposes, they are retained.

.. note:: Setting `tmp_nc_diag_flag` to true may fill up the temporary directory. It is the responsiblity of the user to monitor the temporary directory usage.

.. code-block:: none
output_base_format = "s{storm_id}_{model}_doper_{init_time}";
Expand Down
5 changes: 5 additions & 0 deletions internal/test_unit/config/TCDiagConfig_ian
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ nc_cyl_grid_flag = TRUE; // ends with "_cyl_grid_{domain}.nc"
nc_diag_flag = TRUE; // ends with "_diag.nc"
cira_diag_flag = TRUE; // ends with "_diag.dat"

//
// Retain temporary NetCDF diagnostic files
//
tmp_nc_diag_flag = FALSE;

//
// Output base file naming convention
//
Expand Down
1 change: 1 addition & 0 deletions src/basic/vx_config/config_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,7 @@ static const char conf_key_output_base_format[] = "output_base_format";
static const char conf_key_nc_cyl_grid_flag[] = "nc_cyl_grid_flag";
static const char conf_key_nc_diag_flag[] = "nc_diag_flag";
static const char conf_key_cira_diag_flag[] = "cira_diag_flag";
static const char conf_key_tmp_nc_diag_flag[] = "tmp_nc_diag_flag";

//
// Parameter value names common to multiple tools
Expand Down
15 changes: 12 additions & 3 deletions src/tools/tc_utils/tc_diag/tc_diag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,8 @@ void process_track_points(const TrackInfoArray& tracks) {
tmp_file_map[tmp_key].open(&tracks[k],
&tracks[k][i_pnt],
conf_info.domain_info[j],
conf_info.pressure_levels);
conf_info.pressure_levels,
conf_info.tmp_nc_diag_flag);

} // end for k
} // end for j
Expand Down Expand Up @@ -2074,7 +2075,11 @@ void TmpFileInfo::init_from_scratch() {
void TmpFileInfo::open(const TrackInfo *t_ptr,
const TrackPoint *p_ptr,
const DomainInfo &di,
const set<double> &prs_lev) {
const set<double> &prs_lev,
const bool keep) {

// Set keep flag
keep_file_flag = keep;

// Set pointers
trk_ptr = t_ptr;
Expand Down Expand Up @@ -2140,7 +2145,11 @@ void TmpFileInfo::clear() {
// Delete the temp file
if(tmp_out) {

remove_temp_file(tmp_file);
mlog << Debug(3)
<< (keep_file_flag ? "Retaining" : "Deleting")
<< " temp file: " << tmp_file << "\n";

if(!keep_file_flag) remove_temp_file(tmp_file);

tmp_out = (NcFile *) 0;
}
Expand Down
7 changes: 5 additions & 2 deletions src/tools/tc_utils/tc_diag/tc_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ class TmpFileInfo {

//////////////////////////////////////////////////////////////////

// Keep the temp file rather than deleting it
bool keep_file_flag;

// Track information
const TrackInfo *trk_ptr; // not allocated
const TrackPoint *pnt_ptr; // not allocated
Expand Down Expand Up @@ -157,8 +160,8 @@ class TmpFileInfo {
netCDF::NcDim prs_dim;

void open(const TrackInfo *, const TrackPoint *,
const DomainInfo &,
const std::set<double> &);
const DomainInfo &, const std::set<double> &,
const bool);
void close();

void clear();
Expand Down
3 changes: 3 additions & 0 deletions src/tools/tc_utils/tc_diag/tc_diag_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ void TCDiagConfInfo::process_config(GrdFileType file_type,
exit(1);
}

// Conf: tmp_nc_diag_flag
tmp_nc_diag_flag = conf.lookup_bool(conf_key_tmp_nc_diag_flag);

// Conf: tmp_dir
tmp_dir = parse_conf_tmp_dir(&conf);

Expand Down
1 change: 1 addition & 0 deletions src/tools/tc_utils/tc_diag/tc_diag_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class TCDiagConfInfo {
bool nc_cyl_grid_flag;
bool nc_diag_flag;
bool cira_diag_flag;
bool tmp_nc_diag_flag;

//////////////////////////////////////////////////////////////////

Expand Down

0 comments on commit c9e66c2

Please sign in to comment.