Line data Source code
1 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3 : !!!! !!!!
4 : !!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5 : !!!! !!!!
6 : !!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7 : !!!! !!!!
8 : !!!! This file is part of the ParaMonte library. !!!!
9 : !!!! !!!!
10 : !!!! LICENSE !!!!
11 : !!!! !!!!
12 : !!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13 : !!!! !!!!
14 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 :
17 : !> \brief
18 : !> This file contains procedure implementations of [pm_sysShell](@ref pm_sysShell).
19 : !>
20 : !> \finmain
21 : !>
22 : !> \author
23 : !> \FatemehBagheri, Wednesday 12:20 AM, October 13, 2021, Dallas, TX
24 :
25 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 :
27 : submodule (pm_os) routines ! LCOV_EXCL_LINE
28 :
29 : #if CHECK_ENABLED
30 : use pm_err, only: getFine
31 : use pm_val2str, only: getStr
32 : use pm_err, only: setAsserted
33 : #define CHECK_ASSERTION(LINE,ASSERTION,MSG) \
34 : call setAsserted(ASSERTION,getFine(__FILE__,LINE)//MODULE_NAME//MSG);
35 : #else
36 : #define CHECK_ASSERTION(LINE,ASSERTION,MSG) continue;
37 : #endif
38 :
39 : use pm_sysShell, only: isFailedGetEnvVar
40 : use pm_sysShell, only: isFailedGetOutput
41 : use pm_strASCII, only: setStrLower
42 : use pm_io, only: setContentsFrom
43 : use pm_io, only: LEN_IOMSG
44 :
45 : implicit none
46 :
47 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 :
49 : contains
50 :
51 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 :
53 6 : module procedure isLinux
54 : #if LINUX_ENABLED
55 : itis = .true._LK
56 : #else
57 : logical(LK) :: failed
58 : character(LEN_IOMSG, SK) :: errmsg
59 : itis = isLinux(failed, errmsg)
60 : if (failed) error stop MODULE_NAME//SK_"@isLinux(): "//trim(errmsg) ! LCOV_EXCL_LINE
61 : #endif
62 6 : end procedure
63 :
64 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 :
66 0 : module procedure isLinuxFailed
67 : #if LINUX_ENABLED
68 0 : failed = .false._LK
69 : itis = .true._LK
70 : #else
71 : character(LEN_IOMSG, SK) :: errmsg
72 : itis = isLinux(failed, errmsg)
73 : #endif
74 0 : end procedure
75 :
76 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 :
78 0 : module procedure isLinuxFailedMsg
79 : #if LINUX_ENABLED
80 0 : failed = .false._LK
81 : itis = .true._LK
82 : #else
83 : character(:, SK), allocatable :: output
84 : integer(IK) :: exitstat
85 : itis = .false._LK
86 : failed = isFailedGetOutput(SK_"uname - o", output, errmsg = errmsg, exitstat = exitstat)
87 : if (.not. failed) then
88 : call setStrLower(output)
89 : itis = 0 < index(output, "linux")
90 : end if
91 : #endif
92 0 : end procedure
93 :
94 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 :
96 50 : module procedure isDarwin
97 : #if DARWIN_ENABLED
98 : itis = .true._LK
99 : #else
100 : logical(LK) :: failed
101 : character(LEN_IOMSG, SK) :: errmsg
102 50 : itis = isDarwin(failed, errmsg)
103 : if (failed) error stop MODULE_NAME//SK_"@isDarwin(): "//trim(errmsg) ! LCOV_EXCL_LINE
104 : #endif
105 50 : end procedure
106 :
107 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108 :
109 0 : module procedure isDarwinFailed
110 : #if DARWIN_ENABLED
111 : failed = .false._LK
112 : itis = .true._LK
113 : #else
114 : character(LEN_IOMSG, SK) :: errmsg
115 0 : itis = isDarwin(failed, errmsg)
116 : #endif
117 0 : end procedure
118 :
119 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120 :
121 50 : module procedure isDarwinFailedMsg
122 : #if DARWIN_ENABLED
123 : failed = .false._LK
124 : itis = .true._LK
125 : #else
126 50 : character(:, SK), allocatable :: output
127 : integer(IK) :: exitstat
128 : itis = .false._LK
129 50 : failed = isFailedGetOutput(SK_"uname - o", output, errmsg = errmsg, exitstat = exitstat)
130 50 : if (.not. failed) then
131 50 : call setStrLower(output)
132 50 : itis = 0 < index(output, "darwin") .or. 0 < index(output, "macos")
133 : end if
134 : #endif
135 50 : end procedure
136 :
137 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 :
139 6 : module procedure isWindows
140 : #if WINDOWS_ENABLED
141 : itis = .true._LK
142 : #else
143 : logical(LK) :: failed
144 : character(LEN_IOMSG, SK) :: errmsg
145 6 : itis = isWindows(failed, errmsg)
146 : if (failed) error stop MODULE_NAME//SK_"@isWindows(): "//trim(errmsg) ! LCOV_EXCL_LINE
147 : #endif
148 6 : end procedure
149 :
150 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
151 :
152 0 : module procedure isWindowsFailed
153 : #if WINDOWS_ENABLED
154 : failed = .false._LK
155 : itis = .true._LK
156 : #else
157 : character(LEN_IOMSG, SK) :: errmsg
158 0 : itis = isWindows(failed, errmsg)
159 : #endif
160 0 : end procedure
161 :
162 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 :
164 6 : module procedure isWindowsFailedMsg
165 : #if WINDOWS_ENABLED
166 : failed = .false._LK
167 : itis = .true._LK
168 : #else
169 6 : character(:, SK), allocatable :: value
170 : itis = .false._LK
171 6 : failed = isFailedGetEnvVar(SK_"OS", value, errmsg, length = 10_IK)
172 6 : if (.not. failed) then
173 6 : call setStrLower(value)
174 6 : itis = 0 < index(value, "windows")
175 : end if
176 : #endif
177 6 : end procedure
178 :
179 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 :
181 : #undef CHECK_ASSERTION
182 :
183 : end submodule routines
|