Skip to content

Fix ascii2nc to handle bad records in little_r format. #1737

@JohnHalleyGotway

Description

@JohnHalleyGotway

Describe the Problem

This issue arose via met-help:
https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=99278

The user reported that ascii2nc was unable to read some global little_r formatted ascii data. The sample data is on cheyenne in /glade/collections/rda/data/ds351.0/little_r/2015. Running one of these files through ascii2nc results in the following error message:

ascii2nc OBS:2015080700 OBS:2015080700.nc
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 11) > this->size() (which is 9)
Abort trap: 6

Debugging reveals that of the 618227 records, 4 of them are corrupted. Specifically the 18-th entry of the header line should contain a timestamp but does not.

Expected Behavior

Ascii2nc should be able to process these files and safely skip over the bad data records without aborting. Add more error checking to recognize a bad timestamp and skip over all data lines for the corrupt header.

Environment

Describe your runtime environment:
*1. Found on cheyenne but can reproduce on my Mac laptop.
2. MET version 9.1

To Reproduce

Describe the steps to reproduce the behavior:
*1. Download this small sample input file:
little_r_bad_record.txt
*
2. Run:

ascii2nc little_r_bad_record.txt little_r_bad_record.nc

3. Observe the error:

terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 11) > this->size() (which is 9)
Abort trap: 6

Relevant Deadlines

Fix for 10.0.0 and include in the main_v9.1 branch as well.

Funding Source

Define the source of funding and account keys here or state NONE.

Define the Metadata

Assignee

  • Select engineer(s) or no engineer required: John HG
  • Select scientist(s) or no scientist required: no scientist required

Labels

  • Select component(s)
  • Select priority
  • Select requestor(s)

Projects and Milestone

  • Review projects and select relevant Repository and Organization ones or add "alert:NEED PROJECT ASSIGNMENT" label
  • Select milestone to relevant bugfix version

Define Related Issue(s)

Consider the impact to the other METplus components.

Bugfix Checklist

See the METplus Workflow for details.

  • Complete the issue definition above, including the Time Estimate and Funding Source.
  • Fork this repository or create a branch of main_<Version>.
    Branch name: bugfix_<Issue Number>_main_<Version>_<Description>
  • Fix the bug and test your changes.
  • Add/update log messages for easier debugging.
  • Add/update unit tests.
  • Add/update documentation.
  • Push local changes to GitHub.
  • Submit a pull request to merge into main_<Version>.
    Pull request: bugfix <Issue Number> main_<Version> <Description>
  • Define the pull request metadata, as permissions allow.
    Select: Reviewer(s), Project(s), Milestone, and Linked issues
  • Iterate until the reviewer(s) accept and merge your changes.
  • Delete your fork or branch.
  • Complete the steps above to fix the bug on the develop branch.
    Branch name: bugfix_<Issue Number>_develop_<Description>
    Pull request: bugfix <Issue Number> develop <Description>
  • Close this issue.

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions