prec provides IEEE module
This commit is contained in:
parent
2a8b5a1f0d
commit
90440b50b7
|
@ -7,11 +7,9 @@
|
||||||
!> @brief setting precision for real and int type
|
!> @brief setting precision for real and int type
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
module prec
|
module prec
|
||||||
use, intrinsic :: IEEE_arithmetic, only:&
|
use, intrinsic :: IEEE_arithmetic
|
||||||
IEEE_selected_real_kind
|
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
private
|
|
||||||
! https://software.intel.com/en-us/blogs/2017/03/27/doctor-fortran-in-it-takes-all-kinds
|
! https://software.intel.com/en-us/blogs/2017/03/27/doctor-fortran-in-it-takes-all-kinds
|
||||||
#ifdef Abaqus
|
#ifdef Abaqus
|
||||||
integer, parameter, public :: pReal = selected_real_kind(15,307) !< number with 15 significant digits, up to 1e+-307 (typically 64 bit)
|
integer, parameter, public :: pReal = selected_real_kind(15,307) !< number with 15 significant digits, up to 1e+-307 (typically 64 bit)
|
||||||
|
|
|
@ -3,10 +3,7 @@
|
||||||
!> @brief provides wrappers to C routines
|
!> @brief provides wrappers to C routines
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
module system_routines
|
module system_routines
|
||||||
use, intrinsic :: ISO_C_Binding, only: &
|
use, intrinsic :: ISO_C_Binding
|
||||||
C_INT, &
|
|
||||||
C_CHAR, &
|
|
||||||
C_NULL_CHAR
|
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
private
|
private
|
||||||
|
@ -81,15 +78,15 @@ contains
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
logical function isDirectory(path)
|
logical function isDirectory(path)
|
||||||
|
|
||||||
character(len=*), intent(in) :: path
|
character(len=*), intent(in) :: path
|
||||||
character(kind=C_CHAR), dimension(1024) :: strFixedLength ! C string as array
|
character(kind=C_CHAR), dimension(1024) :: strFixedLength ! C string as array
|
||||||
integer :: i
|
integer :: i
|
||||||
|
|
||||||
strFixedLength = repeat(C_NULL_CHAR,len(strFixedLength))
|
strFixedLength = repeat(C_NULL_CHAR,len(strFixedLength))
|
||||||
do i=1,len(path) ! copy array components
|
do i=1,len(path) ! copy array components
|
||||||
strFixedLength(i)=path(i:i)
|
strFixedLength(i)=path(i:i)
|
||||||
enddo
|
enddo
|
||||||
isDirectory=merge(.True.,.False.,isDirectory_C(strFixedLength) /= 0_C_INT)
|
isDirectory=merge(.True.,.False.,isDirectory_C(strFixedLength) /= 0_C_INT)
|
||||||
|
|
||||||
end function isDirectory
|
end function isDirectory
|
||||||
|
|
||||||
|
@ -99,23 +96,23 @@ end function isDirectory
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
character(len=1024) function getCWD()
|
character(len=1024) function getCWD()
|
||||||
|
|
||||||
character(kind=C_CHAR), dimension(1024) :: charArray ! C string is an array
|
character(kind=C_CHAR), dimension(1024) :: charArray ! C string is an array
|
||||||
integer(C_INT) :: stat
|
integer(C_INT) :: stat
|
||||||
integer :: i
|
integer :: i
|
||||||
|
|
||||||
call getCurrentWorkDir_C(charArray,stat)
|
call getCurrentWorkDir_C(charArray,stat)
|
||||||
if (stat /= 0_C_INT) then
|
if (stat /= 0_C_INT) then
|
||||||
getCWD = 'Error occured when getting currend working directory'
|
getCWD = 'Error occured when getting currend working directory'
|
||||||
else
|
else
|
||||||
getCWD = repeat('',len(getCWD))
|
getCWD = repeat('',len(getCWD))
|
||||||
arrayToString: do i=1,len(getCWD)
|
arrayToString: do i=1,len(getCWD)
|
||||||
if (charArray(i) /= C_NULL_CHAR) then
|
if (charArray(i) /= C_NULL_CHAR) then
|
||||||
getCWD(i:i)=charArray(i)
|
getCWD(i:i)=charArray(i)
|
||||||
else
|
else
|
||||||
exit
|
exit
|
||||||
endif
|
endif
|
||||||
enddo arrayToString
|
enddo arrayToString
|
||||||
endif
|
endif
|
||||||
|
|
||||||
end function getCWD
|
end function getCWD
|
||||||
|
|
||||||
|
@ -125,23 +122,23 @@ end function getCWD
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
character(len=1024) function getHostName()
|
character(len=1024) function getHostName()
|
||||||
|
|
||||||
character(kind=C_CHAR), dimension(1024) :: charArray ! C string is an array
|
character(kind=C_CHAR), dimension(1024) :: charArray ! C string is an array
|
||||||
integer(C_INT) :: stat
|
integer(C_INT) :: stat
|
||||||
integer :: i
|
integer :: i
|
||||||
|
|
||||||
call getHostName_C(charArray,stat)
|
call getHostName_C(charArray,stat)
|
||||||
if (stat /= 0_C_INT) then
|
if (stat /= 0_C_INT) then
|
||||||
getHostName = 'Error occured when getting host name'
|
getHostName = 'Error occured when getting host name'
|
||||||
else
|
else
|
||||||
getHostName = repeat('',len(getHostName))
|
getHostName = repeat('',len(getHostName))
|
||||||
arrayToString: do i=1,len(getHostName)
|
arrayToString: do i=1,len(getHostName)
|
||||||
if (charArray(i) /= C_NULL_CHAR) then
|
if (charArray(i) /= C_NULL_CHAR) then
|
||||||
getHostName(i:i)=charArray(i)
|
getHostName(i:i)=charArray(i)
|
||||||
else
|
else
|
||||||
exit
|
exit
|
||||||
endif
|
endif
|
||||||
enddo arrayToString
|
enddo arrayToString
|
||||||
endif
|
endif
|
||||||
|
|
||||||
end function getHostName
|
end function getHostName
|
||||||
|
|
||||||
|
@ -151,15 +148,15 @@ end function getHostName
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
logical function setCWD(path)
|
logical function setCWD(path)
|
||||||
|
|
||||||
character(len=*), intent(in) :: path
|
character(len=*), intent(in) :: path
|
||||||
character(kind=C_CHAR), dimension(1024) :: strFixedLength ! C string is an array
|
character(kind=C_CHAR), dimension(1024) :: strFixedLength ! C string is an array
|
||||||
integer :: i
|
integer :: i
|
||||||
|
|
||||||
strFixedLength = repeat(C_NULL_CHAR,len(strFixedLength))
|
strFixedLength = repeat(C_NULL_CHAR,len(strFixedLength))
|
||||||
do i=1,len(path) ! copy array components
|
do i=1,len(path) ! copy array components
|
||||||
strFixedLength(i)=path(i:i)
|
strFixedLength(i)=path(i:i)
|
||||||
enddo
|
enddo
|
||||||
setCWD=merge(.True.,.False.,chdir_C(strFixedLength) /= 0_C_INT)
|
setCWD=merge(.True.,.False.,chdir_C(strFixedLength) /= 0_C_INT)
|
||||||
|
|
||||||
end function setCWD
|
end function setCWD
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue