Commit b666c60b authored by famen's avatar famen
Browse files

added call to fp_discon() during the simulation steps

parent 5e3643ca
Pipeline #23524 passed with stage
in 4 minutes and 28 seconds
......@@ -5,12 +5,14 @@ module bladed_controller_hawc2
use BuildInfo
use dll_utils
use iso_c_binding
use global_constants
implicit none
! real(8) dump_array(50)
! real(8) time_old
! logical repeated
character(72) :: str_stars='***********************************************************************'
! DLL data type
Type Tdiscon_dll
......@@ -42,7 +44,7 @@ module bladed_controller_hawc2
! variables for debugging purpose
character(1) str
logical, save :: DEBUG_Flag = .true.
logical, save :: DEBUG_Flag = .false.
! declare the DISCON() function in the interface
Interface
......@@ -168,12 +170,9 @@ subroutine init_discon_dll(array1, array2) bind(c, name='init_discon_dll')
endif
! Now it works for Intel Fortran Compiler in VS 2017/2019 and GNU Fortran on Windows
! TODO:
! Remember to test this implementation on Linux
! Test this implementation on Linux
call c_f_procpointer(transfer(discon_dll%p_func,c_null_funptr),fp_discon)
!stepno = 0
!time_old = 0.0
end subroutine init_discon_dll
subroutine update_discon_dll(array1, array2) bind(c, name='update_discon_dll')
......@@ -196,8 +195,8 @@ subroutine update_discon_dll(array1, array2) bind(c, name='update_discon_dll')
integer(c_int) :: iStatus
INTEGER(4) :: aviFail
INTEGER(1) :: accInFile(256) ! CHARACTER string giving the name of the parameter input file stored as a 1-byte array.
INTEGER(1) :: avcMSG(256) = 20 ! CHARACTER string giving a message that will be displayed by the calling program if aviFAIL <> 0 stored as a 1-byte array.
INTEGER(1), SAVE :: accInFile(256) ! CHARACTER string giving the name of the parameter input file stored as a 1-byte array.
INTEGER(1), SAVE :: avcMSG(256) = 20 ! CHARACTER string giving a message that will be displayed by the calling program if aviFAIL <> 0 stored as a 1-byte array.
INTEGER(1), SAVE :: avcOutName(1024) ! CHARACTER string giving the simulation output name stored as a 1-byte array.
CHARACTER( 256) :: cInFile ! CHARACTER string giving the name of the parameter input file, 'DISCON.IN'
......@@ -282,7 +281,8 @@ subroutine update_discon_dll(array1, array2) bind(c, name='update_discon_dll')
! Ending with NULL character to make a proper C-String needed by bladed style discon interface
cInFile=trim(discon_dll%infile)//char(0)
discon_dll%avrSWAP(51) = len(trim(discon_dll%outfile)) ! Length of the output file name
! Length of the output file name
discon_dll%avrSWAP(51) = len(trim(discon_dll%outfile))
! Ending with NULL character to make a proper C-String needed by bladed style discon interface
cOutName=trim(discon_dll%outfile)//char(0)
......@@ -294,6 +294,7 @@ subroutine update_discon_dll(array1, array2) bind(c, name='update_discon_dll')
write(6,'(A)') 'Controller input parameter file: '// trim(cInFile) //' Openned successfully.'
write(6,'(A)') 'Controller output file: '//trim(cOutName)
write(6,'(A,I2)') trim(discon_dll%filename)//': aviFAIL = ', aviFail
i_step = i_step + 1
! write(6,'(A)') trim(discon_dll%filename)//': ' // trim(cMessage)
endif
......@@ -331,6 +332,17 @@ subroutine update_discon_dll(array1, array2) bind(c, name='update_discon_dll')
discon_dll%avrSWAP(82)=array1(25) ! PtfmRAyi
discon_dll%avrSWAP(83)=array1(26) ! PtfmRAzi
if(iStatus == 1) then
call fp_discon(discon_dll%avrSWAP,aviFail,accInFile,avcOutName,avcMSG)
i_step = i_step + 1
if((mod(i_step,500)==0) .and. DEBUG_Flag) then
write(6,'(i20,2E20.6)') i_step,discon_dll%avrSWAP(47), discon_dll%avrSWAP(45)*raddeg
endif
endif
if (aviFail == 0) then
continue ! call was succesfull
elseif (aviFAIL > 0) then
......@@ -343,11 +355,16 @@ subroutine update_discon_dll(array1, array2) bind(c, name='update_discon_dll')
endif
if (( iStatus == 0 ) .and. ( aviFail >= 0 ) ) then
write (0,*) '*** INFO *** In external dll: Calling to DISCON dll at FIRST timestep is successful!'
write (6,'(A)') '*** INFO *** In external dll: Calling to DISCON dll at FIRST timestep is successful!'
write(6,'(A)') str_stars
write(6,'(3a20)') 'Steps [-]','GenTorque [Nm]','PitchAngle [deg]'
write(6,'(A)') str_stars
stop
endif
array2 = 0.0
! It goes into HAWC2 directly because the servo models have been handled inside the DLL.
array2(1) = discon_dll%avrSWAP(47) ! generator torque hawc2 requires the torque on Low Speed Shaft (LSS) side [Nm]
array2(2:4) = discon_dll%avrSWAP(45) ! collective pitch angle return to hawc2 (simple pitch servo model is included) [rad]
return
end subroutine update_discon_dll
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment