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
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
module prec
|
||||
use, intrinsic :: IEEE_arithmetic, only:&
|
||||
IEEE_selected_real_kind
|
||||
use, intrinsic :: IEEE_arithmetic
|
||||
|
||||
implicit none
|
||||
private
|
||||
! https://software.intel.com/en-us/blogs/2017/03/27/doctor-fortran-in-it-takes-all-kinds
|
||||
#ifdef Abaqus
|
||||
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
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
module system_routines
|
||||
use, intrinsic :: ISO_C_Binding, only: &
|
||||
C_INT, &
|
||||
C_CHAR, &
|
||||
C_NULL_CHAR
|
||||
use, intrinsic :: ISO_C_Binding
|
||||
|
||||
implicit none
|
||||
private
|
||||
|
@ -81,15 +78,15 @@ contains
|
|||
!--------------------------------------------------------------------------------------------------
|
||||
logical function isDirectory(path)
|
||||
|
||||
character(len=*), intent(in) :: path
|
||||
character(kind=C_CHAR), dimension(1024) :: strFixedLength ! C string as array
|
||||
integer :: i
|
||||
character(len=*), intent(in) :: path
|
||||
character(kind=C_CHAR), dimension(1024) :: strFixedLength ! C string as array
|
||||
integer :: i
|
||||
|
||||
strFixedLength = repeat(C_NULL_CHAR,len(strFixedLength))
|
||||
do i=1,len(path) ! copy array components
|
||||
strFixedLength(i)=path(i:i)
|
||||
enddo
|
||||
isDirectory=merge(.True.,.False.,isDirectory_C(strFixedLength) /= 0_C_INT)
|
||||
strFixedLength = repeat(C_NULL_CHAR,len(strFixedLength))
|
||||
do i=1,len(path) ! copy array components
|
||||
strFixedLength(i)=path(i:i)
|
||||
enddo
|
||||
isDirectory=merge(.True.,.False.,isDirectory_C(strFixedLength) /= 0_C_INT)
|
||||
|
||||
end function isDirectory
|
||||
|
||||
|
@ -99,23 +96,23 @@ end function isDirectory
|
|||
!--------------------------------------------------------------------------------------------------
|
||||
character(len=1024) function getCWD()
|
||||
|
||||
character(kind=C_CHAR), dimension(1024) :: charArray ! C string is an array
|
||||
integer(C_INT) :: stat
|
||||
integer :: i
|
||||
character(kind=C_CHAR), dimension(1024) :: charArray ! C string is an array
|
||||
integer(C_INT) :: stat
|
||||
integer :: i
|
||||
|
||||
call getCurrentWorkDir_C(charArray,stat)
|
||||
if (stat /= 0_C_INT) then
|
||||
getCWD = 'Error occured when getting currend working directory'
|
||||
else
|
||||
getCWD = repeat('',len(getCWD))
|
||||
arrayToString: do i=1,len(getCWD)
|
||||
if (charArray(i) /= C_NULL_CHAR) then
|
||||
getCWD(i:i)=charArray(i)
|
||||
else
|
||||
exit
|
||||
endif
|
||||
enddo arrayToString
|
||||
endif
|
||||
call getCurrentWorkDir_C(charArray,stat)
|
||||
if (stat /= 0_C_INT) then
|
||||
getCWD = 'Error occured when getting currend working directory'
|
||||
else
|
||||
getCWD = repeat('',len(getCWD))
|
||||
arrayToString: do i=1,len(getCWD)
|
||||
if (charArray(i) /= C_NULL_CHAR) then
|
||||
getCWD(i:i)=charArray(i)
|
||||
else
|
||||
exit
|
||||
endif
|
||||
enddo arrayToString
|
||||
endif
|
||||
|
||||
end function getCWD
|
||||
|
||||
|
@ -125,23 +122,23 @@ end function getCWD
|
|||
!--------------------------------------------------------------------------------------------------
|
||||
character(len=1024) function getHostName()
|
||||
|
||||
character(kind=C_CHAR), dimension(1024) :: charArray ! C string is an array
|
||||
integer(C_INT) :: stat
|
||||
integer :: i
|
||||
character(kind=C_CHAR), dimension(1024) :: charArray ! C string is an array
|
||||
integer(C_INT) :: stat
|
||||
integer :: i
|
||||
|
||||
call getHostName_C(charArray,stat)
|
||||
if (stat /= 0_C_INT) then
|
||||
getHostName = 'Error occured when getting host name'
|
||||
else
|
||||
getHostName = repeat('',len(getHostName))
|
||||
arrayToString: do i=1,len(getHostName)
|
||||
if (charArray(i) /= C_NULL_CHAR) then
|
||||
getHostName(i:i)=charArray(i)
|
||||
else
|
||||
exit
|
||||
endif
|
||||
enddo arrayToString
|
||||
endif
|
||||
call getHostName_C(charArray,stat)
|
||||
if (stat /= 0_C_INT) then
|
||||
getHostName = 'Error occured when getting host name'
|
||||
else
|
||||
getHostName = repeat('',len(getHostName))
|
||||
arrayToString: do i=1,len(getHostName)
|
||||
if (charArray(i) /= C_NULL_CHAR) then
|
||||
getHostName(i:i)=charArray(i)
|
||||
else
|
||||
exit
|
||||
endif
|
||||
enddo arrayToString
|
||||
endif
|
||||
|
||||
end function getHostName
|
||||
|
||||
|
@ -151,15 +148,15 @@ end function getHostName
|
|||
!--------------------------------------------------------------------------------------------------
|
||||
logical function setCWD(path)
|
||||
|
||||
character(len=*), intent(in) :: path
|
||||
character(kind=C_CHAR), dimension(1024) :: strFixedLength ! C string is an array
|
||||
integer :: i
|
||||
character(len=*), intent(in) :: path
|
||||
character(kind=C_CHAR), dimension(1024) :: strFixedLength ! C string is an array
|
||||
integer :: i
|
||||
|
||||
strFixedLength = repeat(C_NULL_CHAR,len(strFixedLength))
|
||||
do i=1,len(path) ! copy array components
|
||||
strFixedLength(i)=path(i:i)
|
||||
enddo
|
||||
setCWD=merge(.True.,.False.,chdir_C(strFixedLength) /= 0_C_INT)
|
||||
strFixedLength = repeat(C_NULL_CHAR,len(strFixedLength))
|
||||
do i=1,len(path) ! copy array components
|
||||
strFixedLength(i)=path(i:i)
|
||||
enddo
|
||||
setCWD=merge(.True.,.False.,chdir_C(strFixedLength) /= 0_C_INT)
|
||||
|
||||
end function setCWD
|
||||
|
||||
|
|
Loading…
Reference in New Issue