From 5a0ba677e646df47300aee1e54cd4e6616bc7352 Mon Sep 17 00:00:00 2001 From: mike-dixon Date: Wed, 1 Nov 2023 20:23:39 -0600 Subject: [PATCH] apps/ingest/src/Era5Nc2Mdv - work in progress --- .../apps/ingest/src/Era5Nc2Mdv/InputPath.cc | 212 ------------------ .../apps/ingest/src/Era5Nc2Mdv/InputPath.hh | 143 ------------ codebase/apps/ingest/src/Era5Nc2Mdv/Makefile | 2 - 3 files changed, 357 deletions(-) delete mode 100644 codebase/apps/ingest/src/Era5Nc2Mdv/InputPath.cc delete mode 100644 codebase/apps/ingest/src/Era5Nc2Mdv/InputPath.hh diff --git a/codebase/apps/ingest/src/Era5Nc2Mdv/InputPath.cc b/codebase/apps/ingest/src/Era5Nc2Mdv/InputPath.cc deleted file mode 100644 index b15a1e611e..0000000000 --- a/codebase/apps/ingest/src/Era5Nc2Mdv/InputPath.cc +++ /dev/null @@ -1,212 +0,0 @@ -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -// ** Copyright UCAR (c) 1990 - 2016 -// ** University Corporation for Atmospheric Research (UCAR) -// ** National Center for Atmospheric Research (NCAR) -// ** Boulder, Colorado, USA -// ** BSD licence applies - redistribution and use in source and binary -// ** forms, with or without modification, are permitted provided that -// ** the following conditions are met: -// ** 1) If the software is modified to produce derivative works, -// ** such modified software should be clearly marked, so as not -// ** to confuse it with the version available from UCAR. -// ** 2) Redistributions of source code must retain the above copyright -// ** notice, this list of conditions and the following disclaimer. -// ** 3) Redistributions in binary form must reproduce the above copyright -// ** notice, this list of conditions and the following disclaimer in the -// ** documentation and/or other materials provided with the distribution. -// ** 4) Neither the name of UCAR nor the names of its contributors, -// ** if any, may be used to endorse or promote products derived from -// ** this software without specific prior written permission. -// ** DISCLAIMER: THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS -// ** OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -// ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -////////////////////////////////////////////////////////// -// InputPath.cc : Input Wrf file handling -// -// Mike Dixon, RAP, NCAR, P.O.Box 3000, Boulder, CO, 80307-3000, USA -// -// Sept 1998 -// -////////////////////////////////////////////////////////// -// -// See "InputPath.hh" for details. -// -/////////////////////////////////////////////////////////// - -#include "InputPath.hh" -#include -#include -using namespace std; - -///////////////////////////// -// Constructor - Archive mode -// -// Pass in a list of file paths. -// - -InputPath::InputPath (const string &prog_name, - const Params ¶ms, - int n_files, - char **file_paths) : - _progName(prog_name), _params(params) - -{ - - // initialize - - _archiveMode = true; - for (int i = 0; i < n_files; i++) { - _filePaths.insert(file_paths[i]); - } - _currentPath = _filePaths.begin(); - - _dsInputPath = NULL; - -} - -////////////////////////////// -// Constructor - realtime mode -// -// Pass in (a) the input directory to be watched. -// (b) the max valid age for a realtime file (secs) -// the routine will wait for a file with the age -// less than this. -// (c) pointer to heartbeat_func. If NULL this is ignored. -// If non-NULL, this is called once per second while -// the routine is waiting for new data. - -InputPath::InputPath (const string &prog_name, - const Params ¶ms, - MdvInput_heartbeat_t heartbeat_func) : - _progName(prog_name), _params(params) - -{ - - // initialize - - _archiveMode = false; - _heartbeatFunc = heartbeat_func; - - _dsInputPath = new DsInputPath("Wrf2Mdv", - _params.debug >= Params::DEBUG_VERBOSE, - _params.input_dir, - 300, - _heartbeatFunc, - false, - false); - -#ifdef JUNK - // Will periodically search the input dir. - if (! _params.use_ldata){ - - // Don't look too deep, due to circular links in the FDDA data tree. - _dsInputPath->setMaxRecursionDepth(_params.Dir_search_depth); - - // Make sure Wrf is done with the file. - _dsInputPath->setFileQuiescence(_params.File_quiescence_secs); - - // This app checks at the - // lowest rate allowed by - // DsInputPath - _dsInputPath->setDirScanSleep(_params.Dir_scan_interval_secs); - - // Set file naming requirements - if (strlen(_params.DomainString) > 0) { - _dsInputPath->setSubString(_params.DomainString); - } - if (strlen(_params.File_extension) > 0) { - _dsInputPath->setSearchExt(_params.File_extension); - } - } -#endif - -} - -///////////// -// Destructor - -InputPath::~InputPath() - -{ - delete _dsInputPath; -} - -///////////////////// -// get next file path -// -// returns empty string on failure - -const string &InputPath::next() - -{ - - if (_archiveMode) { - - // in archive mode, go through the file list - - if (_currentPath != _filePaths.end()) { - _inputPath = *_currentPath; - _currentPath++; - } else { - _inputPath = ""; - } - - } else { - - // in realtime mode wait for change in latest info - // sleep 1 second between tries. - // - // Check to see if the substring _params.DomainString - // is in the filename. Keep looping until it is, - // if this parameter has been specified. - // This change made by Niles for WSMR. - // This loop needs to be done even if we - // have setSubString on the DsInputPath object, since - // setting that only applies if we are not using - // ldata_info files. - // - - char *filePath; - do { // String check loop. - - filePath = _dsInputPath->next(); - - if (_params.debug >= Params::DEBUG_NORM){ - cerr << "File " << filePath << " detected." << endl; - } - - _inputPath = filePath; - - }while (true); - - // (strlen(_params.DomainString) > 0) && - // (NULL == strstr(filePath, _params.DomainString)) - // ); - - if (_params.debug >= Params::DEBUG_NORM){ - cerr << "Input path returned is " << _inputPath << endl; - } - - - } // if (archiveMode) - - return (_inputPath); - -} - -///////////////////////// -// reset to start of list -// -// Archive mode only. - -void InputPath::reset() - -{ - if (_archiveMode) { - _currentPath = _filePaths.begin(); - } -} - - - diff --git a/codebase/apps/ingest/src/Era5Nc2Mdv/InputPath.hh b/codebase/apps/ingest/src/Era5Nc2Mdv/InputPath.hh deleted file mode 100644 index 09f428d35c..0000000000 --- a/codebase/apps/ingest/src/Era5Nc2Mdv/InputPath.hh +++ /dev/null @@ -1,143 +0,0 @@ -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -// ** Copyright UCAR (c) 1990 - 2016 -// ** University Corporation for Atmospheric Research (UCAR) -// ** National Center for Atmospheric Research (NCAR) -// ** Boulder, Colorado, USA -// ** BSD licence applies - redistribution and use in source and binary -// ** forms, with or without modification, are permitted provided that -// ** the following conditions are met: -// ** 1) If the software is modified to produce derivative works, -// ** such modified software should be clearly marked, so as not -// ** to confuse it with the version available from UCAR. -// ** 2) Redistributions of source code must retain the above copyright -// ** notice, this list of conditions and the following disclaimer. -// ** 3) Redistributions in binary form must reproduce the above copyright -// ** notice, this list of conditions and the following disclaimer in the -// ** documentation and/or other materials provided with the distribution. -// ** 4) Neither the name of UCAR nor the names of its contributors, -// ** if any, may be used to endorse or promote products derived from -// ** this software without specific prior written permission. -// ** DISCLAIMER: THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS -// ** OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -// ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -///////////////////////////////////////////////////////////// -// InputPath.hh -// -// Handling of input paths for MDV files into archive and -// realtime programs. -// -// There are two modes of operation, reflected by the two -// constructors. -// -// Archive mode: -// The constructor passes in a list of MDV file paths. -// This list is stored, and then the paths are served out -// when next() is called. If next() returns NULL, the list -// is exhausted. -// -// Realtime mode: -// The constructor passes in an input directory to watch, as well as -// as max valid age and a heartbeat function to be called while -// waiting for new data to arrive. When next() is called, the -// routine will watch the input directory for a new file. When -// a new file arrives the path is returned by next(). If the -// heartbeat_func is not NULL, it gets called every second while -// next() is waiting for a file to arrive. -// -// Mike Dixon, RAP, NCAR, P.O.Box 3000, Boulder, CO, 80307-3000, USA -// -// Sept 1998 -// -///////////////////////////////////////////////////////////// - -#ifndef InputPath_H -#define InputPath_H - -#include "Params.hh" -#include -#include -#include -#include -using namespace std; - -// typedef for heartbeat function. If heartbeat_func is non-null, -// the client must provide a pointer to a function which fits this -// prototype. The label will be generated by this class prior -// to calling the heartbeat function. - -typedef void (*MdvInput_heartbeat_t)(const char *label); - -class InputPath { - -public: - - ///////////////////////////// - // Constructor - Archive mode - // - // Pass in a list of file paths. - // - - InputPath (const string &prog_name, - const Params ¶ms, - int n_files, - char **file_paths); - - ////////////////////////////// - // Constructor - realtime mode - // - // Pass in (a) the input directory to be watched. - // (b) the max valid age for a realtime file (secs) - // the routine will wait for a file with the age - // less than this. - // (c) pointer to heartbeat_func. If NULL this is ignored. - // If non-NULL, this is called once per second while - // the routine is waiting for new data. - - InputPath (const string &prog_name, - const Params ¶ms, - MdvInput_heartbeat_t heartbeat_func); - - ///////////// - // destructor - - ~InputPath(); - - //////////////// - // get next file - // - // returns empty string on failure - - const string &next(); - - ///////////////////////// - // reset to start of list - // - // Archive mode only. - - void reset(); - - -protected: - -private: - - const string &_progName; - const Params &_params; - - set > _filePaths; - set >::iterator _currentPath; - - string _inputPath; - bool _archiveMode; - DsInputPath *_dsInputPath; - MdvInput_heartbeat_t _heartbeatFunc; - - void _loadDay(char *subdir_path, - date_time_t *midday, - time_t start_time, - time_t end_time); - -}; - -#endif diff --git a/codebase/apps/ingest/src/Era5Nc2Mdv/Makefile b/codebase/apps/ingest/src/Era5Nc2Mdv/Makefile index 2ddb15e9c5..5b9a951dfd 100644 --- a/codebase/apps/ingest/src/Era5Nc2Mdv/Makefile +++ b/codebase/apps/ingest/src/Era5Nc2Mdv/Makefile @@ -55,7 +55,6 @@ HDRS = \ Args.hh \ Era5Data.hh \ Era5Nc2Mdv.hh \ - InputPath.hh \ PresInterp.hh \ OutputFile.hh \ WRFGrid.hh @@ -65,7 +64,6 @@ CPPC_SRCS = \ Args.cc \ Era5Data.cc \ Era5Nc2Mdv.cc \ - InputPath.cc \ Main.cc \ PresInterp.cc \ OutputFile.cc \