Skip to content
Snippets Groups Projects
Commit c429358b authored by famen's avatar famen
Browse files

bugfix/improvements on loading ".so" controller from the third party called by...

bugfix/improvements on loading ".so" controller from the third party called by Linux version of HAWC2
parent 15c23836
No related tags found
1 merge request!62bugfix/improvements on calling the third party ".so" controller
Pipeline #32104 passed
......@@ -25,9 +25,10 @@ module dtu_we_controller
! Remember to test this implementation on Linux
! Define external function/subroutine abstract interface
interface
subroutine WTController(GenRot,YawBrTAyp,time,ShutDown, U) bind(c,name='WTController')
subroutine WTController(ctrl_input_name, GenRot,YawBrTAyp,time,ShutDown, U) bind(c,name='WTController')
use, intrinsic :: iso_c_binding
implicit none
character(kind=c_char),dimension(*) :: ctrl_input_name
real(c_float) , value :: GenRot,YawBrTAyp,time
integer(c_int), value :: ShutDown
real(c_float) , intent(inout) :: U(*)
......@@ -633,7 +634,8 @@ subroutine initstring(istring) bind(c,name='initstring')
n_idx = index(tmp1,':')
if (n_idx /= 0) then
name = tmp1(1:n_idx-1) ! dll name
external_dll%func_name = tmp1(n_idx+1:len_trim(tmp1)) ! function name
! external_dll%func_name = tmp1(n_idx+1:len_trim(tmp1)) ! function name
external_dll%par_filename = tmp1(n_idx+1:len_trim(tmp1)) ! function name
else
name = tmp1
end if
......@@ -956,6 +958,7 @@ subroutine update_external_ctrl_dll(array1, array2) bind(c, name='update_externa
logical, save :: is_verbose = .false.
real(4), save :: ctrl_output(50)
real(mk) time
character(len=256), save :: ctrl_cfg_file
!--------------------------------------------------------------------------------------------
!Required inputs from hawc2 to controller in array1:
......@@ -1019,7 +1022,8 @@ subroutine update_external_ctrl_dll(array1, array2) bind(c, name='update_externa
write(6,'(8a20)') 'Time [s]','RotorSpeed [rad/s]','PitchAngle [deg]','GenTorq [Nm]','Pe[W]','RegionSwitch [-]','AdditionPitch [deg]','TwrTopVel [m/s]'
endif
! Run the external 3rd part controller
call fp_WTController(external_dll%avrSWAP(1),external_dll%avrSWAP(2), &
ctrl_cfg_file = trim(adjustl(external_dll%par_filename))//C_NULL_CHAR
call fp_WTController(ctrl_cfg_file, external_dll%avrSWAP(1),external_dll%avrSWAP(2), &
external_dll%avrSWAP(3),external_dll%is_shutdown, &
ctrl_output)
external_dll%aero_power = external_dll%avrSWAP(1)*ctrl_output(2)
......
......@@ -207,6 +207,7 @@ module user_defined_types
character*256 :: infile =''
character*256 :: outfile=''
character*256 :: func_name=''
character*256 :: par_filename=''
real(4),dimension(32) :: avrSWAP=0.0 ! The swap array, used to pass data to, and receive data from, the DLL controller.
integer(c_int) :: is_shutdown
integer(c_int) :: hawc2_status
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment