simplified
This commit is contained in:
parent
519ca6f990
commit
0cf0112029
|
@ -24,7 +24,7 @@ module system_routines
|
||||||
|
|
||||||
function setCWD_C(cwd) bind(C)
|
function setCWD_C(cwd) bind(C)
|
||||||
use, intrinsic :: ISO_C_Binding, only: C_INT, C_CHAR
|
use, intrinsic :: ISO_C_Binding, only: C_INT, C_CHAR
|
||||||
|
|
||||||
integer(C_INT) :: setCWD_C
|
integer(C_INT) :: setCWD_C
|
||||||
character(kind=C_CHAR), dimension(*), intent(in) :: cwd
|
character(kind=C_CHAR), dimension(*), intent(in) :: cwd
|
||||||
end function setCWD_C
|
end function setCWD_C
|
||||||
|
@ -150,14 +150,14 @@ function getUserName()
|
||||||
getUserName = c_f_string(getUserName_Cstring)
|
getUserName = c_f_string(getUserName_Cstring)
|
||||||
else
|
else
|
||||||
getUserName = 'n/a (Error!)'
|
getUserName = 'n/a (Error!)'
|
||||||
endif
|
end if
|
||||||
|
|
||||||
end function getUserName
|
end function getUserName
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief convert C string to Fortran string
|
!> @brief Convert C string to Fortran string.
|
||||||
!> @details: C string is NULL terminated and, hence, longer by one than the Fortran string
|
!> @details: C string is NULL terminated and, hence, longer by one than the Fortran string.
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
pure function c_f_string(c_string) result(f_string)
|
pure function c_f_string(c_string) result(f_string)
|
||||||
|
|
||||||
|
@ -174,28 +174,23 @@ pure function c_f_string(c_string) result(f_string)
|
||||||
else
|
else
|
||||||
f_string = f_string(:i-1)
|
f_string = f_string(:i-1)
|
||||||
exit
|
exit
|
||||||
endif
|
end if
|
||||||
enddo arrayToString
|
end do arrayToString
|
||||||
|
|
||||||
end function c_f_string
|
end function c_f_string
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief convert Fortran string to C string
|
!> @brief Convert Fortran string to C string.
|
||||||
!> @details: C string is NULL terminated and, hence, longer by one than the Fortran string
|
!> @details: C string is NULL terminated and, hence, longer by one than the Fortran string.
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
pure function f_c_string(f_string) result(c_string)
|
pure function f_c_string(f_string) result(c_string)
|
||||||
|
|
||||||
character(len=*), intent(in) :: f_string
|
character(len=*), intent(in) :: f_string
|
||||||
character(kind=C_CHAR), dimension(len_trim(f_string)+1) :: c_string
|
character(kind=C_CHAR), dimension(len_trim(f_string)+1) :: c_string
|
||||||
|
|
||||||
integer :: i
|
|
||||||
|
|
||||||
|
c_string = transfer(trim(f_string)//C_NULL_CHAR,c_string,size=size(c_string))
|
||||||
do i=1,len_trim(f_string)
|
|
||||||
c_string(i)=f_string(i:i)
|
|
||||||
enddo
|
|
||||||
c_string(len_trim(f_string)+1) = C_NULL_CHAR
|
|
||||||
|
|
||||||
end function f_c_string
|
end function f_c_string
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue