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

[BugFix] Sys files for MATLAB #668

Merged
merged 2 commits into from
Feb 25, 2021
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
7 changes: 6 additions & 1 deletion cmake/FindMatlab.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ if(NOT MATLAB_ADDITIONAL_VERSIONS)
endif()

set(MATLAB_VERSIONS_MAPPING
"R2020b=9.9"
"R2020a=9.8"
"R2019b=9.7"
"R2019a=9.6"
"R2018b=9.5"
"R2018a=9.4"
"R2017b=9.3"
"R2017a=9.2"
Expand Down Expand Up @@ -1712,4 +1717,4 @@ if(Matlab_INCLUDE_DIRS AND Matlab_LIBRARIES)
Matlab_MEXEXTENSIONS_PROG
Matlab_MEX_EXTENSION
)
endif()
endif()
17 changes: 12 additions & 5 deletions modules/nwtc-library/src/SysMatlabLinuxGnu.f90
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ SUBROUTINE ProgExit ( StatCode )

END SUBROUTINE ProgExit ! ( StatCode )
!=======================================================================
SUBROUTINE Set_IEEE_Constants( NaN_D, Inf_D, NaN, Inf )
SUBROUTINE Set_IEEE_Constants( NaN_D, Inf_D, NaN, Inf, NaN_S, Inf_S )

! routine that sets the values of NaN_D, Inf_D, NaN, Inf (IEEE
! values for not-a-number and infinity in sindle and double
Expand All @@ -302,30 +302,37 @@ SUBROUTINE Set_IEEE_Constants( NaN_D, Inf_D, NaN, Inf )

REAL(DbKi), INTENT(inout) :: Inf_D ! IEEE value for NaN (not-a-number) in double precision
REAL(DbKi), INTENT(inout) :: NaN_D ! IEEE value for Inf (infinity) in double precision

REAL(ReKi), INTENT(inout) :: Inf ! IEEE value for NaN (not-a-number)
REAL(ReKi), INTENT(inout) :: NaN ! IEEE value for Inf (infinity)

! local variables for getting values of NaN and Inf (not necessary when using ieee_arithmetic)
REAL(DbKi) :: Neg_D ! a negative real(DbKi) number
REAL(ReKi) :: Neg ! a negative real(ReKi) number
REAL(SiKi), INTENT(inout) :: Inf_S ! IEEE value for NaN (not-a-number) in single precision
REAL(SiKi), INTENT(inout) :: NaN_S ! IEEE value for Inf (infinity) in single precision

real(DbKi) :: Neg_D
real(SiKi) :: Neg_S
real(ReKi) :: Neg


! if compiling with floating-point-exception traps, this will not work, so we've added a compiler directive.
! note that anything that refers to NaN or Inf will be incorrect in that case.

#ifndef FPE_TRAP_ENABLED
! set variables to negative numbers to calculate NaNs (compilers may complain when taking sqrt of negative constants)
Neg_D = -1.0_DbKi
Neg_S = -1.0_SiKi
Neg = -1.0_ReKi

NaN_D = SQRT ( Neg_D )
NaN_S = SQRT ( Neg_S )
NaN = SQRT ( Neg )

! set variables to zero to calculate Infs (using division by zero)
Neg_D = 0.0_DbKi
Neg_S = 0.0_SiKi
Neg = 0.0_ReKi

Inf_D = 1.0_DbKi / Neg_D
Inf_S = 1.0_SiKi / Neg_S
Inf = 1.0_ReKi / Neg
#endif

Expand Down
10 changes: 8 additions & 2 deletions modules/nwtc-library/src/SysMatlabLinuxIntel.f90
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ SUBROUTINE ProgExit ( StatCode )

END SUBROUTINE ProgExit ! ( StatCode )
!=======================================================================
SUBROUTINE Set_IEEE_Constants( NaN_D, Inf_D, NaN, Inf )

SUBROUTINE Set_IEEE_Constants( NaN_D, Inf_D, NaN, Inf, NaN_S, Inf_S )
! routine that sets the values of NaN_D, Inf_D, NaN, Inf (IEEE
! values for not-a-number and infinity in sindle and double
! precision) This uses standard F03 intrinsic routines,
Expand All @@ -313,13 +313,19 @@ SUBROUTINE Set_IEEE_Constants( NaN_D, Inf_D, NaN, Inf )
REAL(ReKi), INTENT(inout) :: Inf ! IEEE value for NaN (not-a-number)
REAL(ReKi), INTENT(inout) :: NaN ! IEEE value for Inf (infinity)

REAL(SiKi), INTENT(inout) :: Inf_S ! IEEE value for NaN (not-a-number) in single precision
REAL(SiKi), INTENT(inout) :: NaN_S ! IEEE value for Inf (infinity) in single precision


NaN_D = ieee_value(0.0_DbKi, ieee_quiet_nan)
Inf_D = ieee_value(0.0_DbKi, ieee_positive_inf)

NaN = ieee_value(0.0_ReKi, ieee_quiet_nan)
Inf = ieee_value(0.0_ReKi, ieee_positive_inf)

NaN_S = ieee_value(0.0_SiKi, ieee_quiet_nan)
Inf_S = ieee_value(0.0_SiKi, ieee_positive_inf)

END SUBROUTINE Set_IEEE_Constants
!=======================================================================
SUBROUTINE UsrAlarm
Expand Down
30 changes: 0 additions & 30 deletions modules/nwtc-library/src/SysMatlabWindows.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,6 @@ MODULE SysSubs



<<<<<<< HEAD:modules/nwtc-library/src/SysMatlab.f90
! It contains the following routines:

! FUNCTION FileSize( Unit ) ! Returns the size (in bytes) of an open file.
! SUBROUTINE FlushOut ( Unit )
! FUNCTION NWTC_ERF( x )
! FUNCTION NWTC_gamma( x )
! SUBROUTINE GET_CWD( DirName, Status )
! FUNCTION Is_NaN( DblNum ) ! Please use IEEE_IS_NAN() instead
! FUNCTION NWTC_Gamma( x ) ! Returns the gamma value of its argument.
! per MLB, this can be removed, but only if CU is OUTPUT_UNIT:
! SUBROUTINE OpenCon ! Actually, it can't be removed until we get Intel's FLUSH working. (mlb)
! SUBROUTINE OpenUnfInpBEFile ( Un, InFile, RecLen, Error )
! SUBROUTINE ProgExit ( StatCode )
! SUBROUTINE Set_IEEE_Constants( NaN_D, Inf_D, NaN, Inf, NaN_S, Inf_S )
! SUBROUTINE UsrAlarm
! SUBROUTINE WrNR ( Str )
! SUBROUTINE WrOver ( Str )
! SUBROUTINE WriteScr ( Str, Frm )
! SUBROUTINE LoadDynamicLib( DLL, ErrStat, ErrMsg )
! SUBROUTINE FreeDynamicLib( DLL, ErrStat, ErrMsg )

=======
>>>>>>> upstream/master:modules/nwtc-library/src/SysMatlabWindows.f90


USE NWTC_Base
Expand Down Expand Up @@ -363,12 +339,6 @@ SUBROUTINE Set_IEEE_Constants( NaN_D, Inf_D, NaN, Inf, NaN_S, Inf_S )

NaN_S = ieee_value(0.0_SiKi, ieee_quiet_nan)
Inf_S = ieee_value(0.0_SiKi, ieee_positive_inf)

NaN_D = ieee_value(0.0_DbKi, ieee_quiet_nan)
Inf_D = ieee_value(0.0_DbKi, ieee_positive_inf)

NaN = ieee_value(0.0_ReKi, ieee_quiet_nan)
Inf = ieee_value(0.0_ReKi, ieee_positive_inf)

END SUBROUTINE Set_IEEE_Constants
!=======================================================================
Expand Down