Fix openfastcpp restart parsing of file name #2792
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Short story
This is a safer way to get the restart file name from the netcdf file. First, get the actual length of the string with
nc_inq_attlen, then create a char pointer that is that length + 1. Then make sure that char pointer ends with a null char. And only then is it safe to use theassignoperator from that char pointer to a string.Really long story
I found this because I was having restart issues on Frontier. Basically one of my runs died and the restart procedure of openfast was picking up a restart time (and therefore a chkp file) (total aside: I did not realize that openfast ignored
restart_filename: "5MW_Land_BD_DLL_WTurb_T1/5MW_Land_BD_DLL_WTurb.5760"and really just used the_rst.ncfiletimevariable to compute a chkp tstep and used that. Is this expected? Can it be overriden? If this is the case, should we not allow the user to use this option?) that was after the time I wanted to restart from (I wanted to back up the sim a bit). Easy enough, right? Just open the nc file in python, remove the last time step from all the variables, write it out again (making sure to use the classic format) and good to go.However, openfast kept mangling the restart file name that it read from
out_file_rootglobal attribute. This is the output from several separate runsYou notice the garbled, random chars between the
T1and the.? With these edits, those go away.I am not sure how reproduceable this is and how much it depends on compilers, etc.
I attached the
_rst.ncandopenfastcppyaml file that I used to reproduce this and test my fix. I am leaving out the chkp files and turbine defs (standard NREL5MW)Archive.zip