Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Writing checkpoint files created empty fort.# files #2186

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/automated-dev-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ jobs:
- name: Run 5MW tests
working-directory: ${{runner.workspace}}/openfast/build
run: |
ctest -VV -L openfast -LE "cpp|linear|python" -R 5MW_OC3Mnpl_DLL_WTurb_WavesIrr
ctest -VV -L openfast -LE "cpp|linear|python" -R 5MW_OC3Mnpl_DLL_WTurb_WavesIrr -j1
- name: Failing test artifacts
uses: actions/upload-artifact@v4
if: failure()
Expand Down
12 changes: 7 additions & 5 deletions modules/nwtc-library/src/ModReg.f90
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,24 @@ subroutine CloseRegFile(RF, ErrStat, ErrMsg)
ErrStat = ErrID_None
ErrMsg = ""

! If registry has already been closed, return
if (RF%Unit < 0) return

! Check if there have been any errors while writing to the file
if (RF%ErrStat /= ErrID_None) then
call SetErrStat(RF%ErrStat, RF%ErrMsg, ErrStat, ErrMsg, RoutineName)
return
end if

! Write the actual number of pointers
write (RF%Unit, POS=RF%Offset, iostat=stat) RF%NumPointers
if (stat /= 0) then
ErrStat = ErrID_Fatal
write (ErrMsg, *) 'CloseRegFile: Unable to write offset at beginning of file'
return
call SetErrStat(ErrID_Fatal, 'CloseRegFile: Unable to write offset at beginning of file', &
ErrStat, ErrMsg, RoutineName)
end if

! Close the file
! Close the file and set unit to -1 so file won't be closed again
close (RF%Unit)
RF%Unit = -1

! Deallocate pointer array
if (allocated(RF%Pointers)) deallocate (RF%Pointers)
Expand Down
28 changes: 7 additions & 21 deletions modules/openfast-library/src/FAST_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9962,16 +9962,14 @@ SUBROUTINE FAST_CreateCheckpoint_T(t_initial, n_t_global, NumTurbines, Turbine,

IF ( unOut < 0 ) THEN

CALL GetNewUnit( unOut, ErrStat2, ErrMsg2 )
CALL OpenBOutFile ( unOut, FileName, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (ErrStat >= AbortErrLev ) then

CALL GetNewUnit(unOut, ErrStat2, ErrMsg2)
CALL OpenBOutFile (unOut, FileName, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if (ErrStat >= AbortErrLev) then
IF (.NOT. PRESENT(Unit)) THEN
CLOSE(unOut)
unOut = -1
end if
call cleanup()
return
end if

Expand All @@ -9985,20 +9983,15 @@ SUBROUTINE FAST_CreateCheckpoint_T(t_initial, n_t_global, NumTurbines, Turbine,

! Initialize the registry file
call InitRegFile(RF, unOut, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if (ErrStat >= AbortErrLev) return

! Pack data into the registry file
call FAST_PackTurbineType(RF, Turbine)
call SetErrStat(RF%ErrStat, RF%ErrMsg, ErrStat, ErrMsg, RoutineName )
if (ErrStat >= AbortErrLev ) then
call cleanup()
return
end if

! Close registry file
! Close registry file and get any errors that occurred while writing
call CloseRegFile(RF, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if (ErrStat >= AbortErrLev) return

! If last turbine or no unit, close output unit
Expand Down Expand Up @@ -10030,13 +10023,6 @@ SUBROUTINE FAST_CreateCheckpoint_T(t_initial, n_t_global, NumTurbines, Turbine,
Turbine%SrvD%m%dll_data%SimStatus = Turbine%SrvD%m%dll_data%avrSWAP( 1)
end if
END IF

call cleanup()

contains
subroutine cleanup()
call CloseRegFile(RF, ErrStat2, ErrMsg2)
end subroutine cleanup

END SUBROUTINE FAST_CreateCheckpoint_T
!----------------------------------------------------------------------------------------------------------------------------------
Expand Down