brucefan1983 / GPUMD

Graphics Processing Units Molecular Dynamics
https://gpumd.org/dev
GNU General Public License v3.0
466 stars 116 forks source link

Enhanced Error Handling: Provide More Context Information When Parsing Floats in NEP Structure File (train.xyz or test.xyz) #516

Closed xiaodeng125 closed 2 months ago

xiaodeng125 commented 1 year ago

Issue Description :

While using NEP to process structure file (train.xyz or test.xyz) in my training set, I encountered an error that halted the parsing process. The error message displayed was:

Standard exception: File: main_nep/structure. Cu Line: 145 Error message: stof

This suggests an issue with the "std::stof" function, which seems to have trouble converting a specific string token to a floating-point number during the parsing process. However, the error message provided lacks sufficient context, making it difficult to identify which part of my data caused the issue.

Suggested Enhancement:

To make such errors easier to diagnose, I suggest that the program provide more context when such exceptions are caught. Specifically, it could print out the specific token that caused the error, and potentially the line of the data point. For instance, the error message could be enhanced to something like:

Error message: Failed to get the value from the token "Energy=" in file "train.xyz" on line number 1234.

brucefan1983 commented 1 year ago

This is a good suggestion. We will aim to improve this kind of input/output aspects in GPUMD-v4.0.

brucefan1983 commented 2 months ago

fixed in #699