1 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/system_routines.f90"
4 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/system_routines.f90"
10 use,
intrinsic :: iso_c_binding
27 function isdirectory_c(path)
bind(C)
28 use,
intrinsic :: iso_c_binding, only: &
34 integer(C_INT) :: isdirectory_c
35 character(kind=C_CHAR),
dimension(pPathLen),
intent(in) :: path
36 end function isdirectory_c
38 subroutine getcurrentworkdir_c(path, stat)
bind(C)
39 use,
intrinsic :: iso_c_binding, only: &
45 character(kind=C_CHAR),
dimension(pPathLen),
intent(out) :: path
46 integer(C_INT),
intent(out) :: stat
47 end subroutine getcurrentworkdir_c
49 subroutine gethostname_c(str, stat)
bind(C)
50 use,
intrinsic :: iso_c_binding, only: &
56 character(kind=C_CHAR),
dimension(pStringLen),
intent(out) :: str
57 integer(C_INT),
intent(out) :: stat
58 end subroutine gethostname_c
60 function chdir_c(path)
bind(C)
61 use,
intrinsic :: iso_c_binding, only: &
67 integer(C_INT) :: chdir_c
68 character(kind=C_CHAR),
dimension(pPathLen),
intent(in) :: path
71 subroutine signalterm_c(handler)
bind(C)
72 use,
intrinsic :: iso_c_binding, only: &
75 type(c_funptr),
intent(in),
value :: handler
76 end subroutine signalterm_c
78 subroutine signalusr1_c(handler)
bind(C)
79 use,
intrinsic :: iso_c_binding, only: &
82 type(c_funptr),
intent(in),
value :: handler
83 end subroutine signalusr1_c
85 subroutine signalusr2_c(handler)
bind(C)
86 use,
intrinsic :: iso_c_binding, only: &
89 type(c_funptr),
intent(in),
value :: handler
90 end subroutine signalusr2_c
101 character(len=*),
intent(in) :: path
102 character(kind=C_CHAR),
dimension(pPathLen) :: strfixedlength
105 strfixedlength = repeat(c_null_char,len(strfixedlength))
107 strfixedlength(i)=path(i:i)
109 isdirectory=merge(.true.,.false.,isdirectory_c(strfixedlength) /= 0_c_int)
119 character(kind=C_CHAR),
dimension(pPathLen) :: chararray
120 character(len=:),
allocatable ::
getcwd
121 integer(C_INT) :: stat
124 call getcurrentworkdir_c(chararray,stat)
126 if (stat /= 0_c_int)
then
127 getcwd =
'Error occured when getting currend working directory'
129 allocate(
character(len=pPathLen)::
getcwd)
130 arraytostring:
do i=1,len(
getcwd)
131 if (chararray(i) /= c_null_char)
then
148 character(kind=C_CHAR),
dimension(pPathLen) :: chararray
150 integer(C_INT) :: stat
153 call gethostname_c(chararray,stat)
155 if (stat /= 0_c_int)
then
156 gethostname =
'Error occured when getting host name'
160 if (chararray(i) /= c_null_char)
then
175 logical function setcwd(path)
177 character(len=*),
intent(in) :: path
178 character(kind=C_CHAR),
dimension(pPathLen) :: strfixedlength
181 strfixedlength = repeat(c_null_char,len(strfixedlength))
183 strfixedlength(i)=path(i:i)
185 setcwd=merge(.true.,.false.,chdir_c(strfixedlength) /= 0_c_int)