Skip to content

Commit

Permalink
This commit addresses PR comments (#1538)
Browse files Browse the repository at this point in the history
- A method was found to initial ProcAddr in DLL_Type by creating an
array of null pointers (seems like a hack)
- Comments were added in SD_FEM.f90 and SubDyn.f90 explaining that
changes were made to satisfy the Flang compiler
  • Loading branch information
deslaughter committed Apr 20, 2023
1 parent 8774ec4 commit 55eb00c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions modules/nwtc-library/src/NWTC_Base.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ MODULE NWTC_Base

INTEGER(IntKi), PARAMETER :: NWTC_MAX_DLL_PROC = 5 !< maximum number of procedures that can be dynamically loaded from a DLL (see DLL_Type nwtc_base::dll_type)

TYPE(C_FUNPTR), PARAMETER :: NULL_PROC_ADDR(NWTC_MAX_DLL_PROC) = C_NULL_FUNPTR !< this is a hack so the Flang compiler will initialize ProcAddr to C_NULL_FUNPTR in DLL_Type (remove if no longer needed)

!> Type definition for dynamically loaded libraries:
!! Note that changes here may need to be reflected in DLLTypePack() (nwtc_io::dlltypepack) DLLTypeUnPack() (nwtc_io::dlltypeunpack),
!! and the FAST Registry executable.

TYPE DLL_Type

INTEGER(C_INTPTR_T) :: FileAddr = INT(0,C_INTPTR_T) !< The address of file FileName. (RETURN value from LoadLibrary ) [Windows]
TYPE(C_PTR) :: FileAddrX = C_NULL_PTR !< The address of file FileName. (RETURN value from dlopen ) [Linux]
TYPE(C_FUNPTR) :: ProcAddr(NWTC_MAX_DLL_PROC) !< The address of procedure ProcName. (RETURN value from GetProcAddress or dlsym) [initialized to Null for pack/unpack]
TYPE(C_FUNPTR) :: ProcAddr(NWTC_MAX_DLL_PROC) = NULL_PROC_ADDR !< The address of procedure ProcName. (RETURN value from GetProcAddress or dlsym) [initialized to Null for pack/unpack]

CHARACTER(1024) :: FileName !< The name of the DLL file including the full path to the current working directory.
CHARACTER(1024) :: ProcName(NWTC_MAX_DLL_PROC) = "" !< The name of the procedure in the DLL that will be called.
Expand Down
2 changes: 1 addition & 1 deletion modules/subdyn/src/SD_FEM.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ SUBROUTINE DirectElimination(Init, p, ErrStat, ErrMsg)
! --- DOF elimination for system matrices and RHS vector
nDOF = p%nDOF_red
if (p%reduced) then
! Temporary backup of M and K of full system
! Temporary backup of M and K of full system (Flang compiler failed when move_alloc was used here, so arrays are allocated, moved, and deallocated manually)
CALL AllocAry(KK, size(Init%K,1), size(Init%K,2), 'KK', ErrStat2, ErrMsg2); if(Failed()) return; ! system stiffness matrix
CALL AllocAry(MM, size(Init%M,1), size(Init%M,2), 'MM', ErrStat2, ErrMsg2); if(Failed()) return; ! system mass matrix
KK = Init%K
Expand Down
4 changes: 2 additions & 2 deletions modules/subdyn/src/SubDyn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ SUBROUTINE SD_Input(SDInputFile, Init, p, ErrStat,ErrMsg)
! Reading reaction lines one by one, allowing for 1, 7 or 8 columns, with col8 being a string for the SSIfile
do I = 1, p%nNodes_C
READ(UnIn, FMT='(A)', IOSTAT=ErrStat2) Line; ErrMsg2='Error reading reaction line'; if (Failed()) return
j = index(line, achar(13))
j = index(line, achar(13)) ! Remove any carriage returns in this line (required by the Flang compiler)
do while (j > 0)
line(j:j) = " "
j = index(line, achar(13))
Expand Down Expand Up @@ -1128,7 +1128,7 @@ SUBROUTINE SD_Input(SDInputFile, Init, p, ErrStat,ErrMsg)
! Reading interface lines one by one, allowing for 1 or 7 columns (cannot use ReadIAry)
DO I = 1, p%nNodes_I
READ(UnIn, FMT='(A)', IOSTAT=ErrStat2) Line ; ErrMsg2='Error reading interface line'; if (Failed()) return
j = index(line, achar(13))
j = index(line, achar(13)) ! Remove any carriage returns in this line (required by the Flang compiler)
do while (j > 0)
line(j:j) = " "
j = index(line, achar(13))
Expand Down

0 comments on commit 55eb00c

Please sign in to comment.