Skip to content

Conversation

@marchdf
Copy link
Contributor

@marchdf marchdf commented May 1, 2025

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 the assign operator 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.nc file time variable 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_root global attribute. This is the output from several separate runs

Restarting from time 53.9256 at time step 62640 from file name 5MW_Land_BD_DLL_WTurb_T1/5MW_Land_BD_DLL_WTurb.T1EО.62640
Restarting from time 53.9256 at time step 62640 from file name
 5MW_Land_BD_DLL_WTurb_T1/5MW_Land_BD_DLL_WTurb.T1V.62640
Restarting from time 53.9256 at time step 62640 from file name 5MW_Land_BD_DLL_WTurb_T1/5MW_Land_BD_DLL_WTurb.T1uf.62640

You notice the garbled, random chars between the T1 and 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.nc and openfastcpp yaml 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

@marchdf
Copy link
Contributor Author

marchdf commented May 1, 2025

Here's where openfastcpp computes the chkp step extension (ignoring user input): https://github.com/OpenFAST/openfast/blob/v4.0.3/glue-codes/openfast-cpp/src/OpenFAST.cpp#L113

@marchdf
Copy link
Contributor Author

marchdf commented May 1, 2025

@andrew-platt andrew-platt changed the base branch from main to dev May 1, 2025 17:29
@andrew-platt
Copy link
Collaborator

Consider for backport to 4.0.5

@andrew-platt andrew-platt requested a review from deslaughter May 1, 2025 19:50
@andrew-platt andrew-platt self-assigned this May 1, 2025
@andrew-platt andrew-platt added this to the v4.1.0 milestone May 1, 2025
@andrew-platt andrew-platt merged commit 326a9ea into OpenFAST:dev May 2, 2025
45 checks passed
@marchdf marchdf deleted the fix-restart-name branch May 2, 2025 15:34
@andrew-platt andrew-platt modified the milestones: v4.1.0, 4.0.5 May 15, 2025
andrew-platt added a commit that referenced this pull request May 15, 2025
…tParse

Fix restart parsing of file name (backport of #2792 and #2793)
@andrew-platt andrew-platt mentioned this pull request Jun 11, 2025
35 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants