ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_sysPath::getDirName Interface Reference

Generate and return the dirname (directory name) part of the input path.
More...

Detailed Description

Generate and return the dirname (directory name) part of the input path.

By definition, the dirname segment of a path corresponds to the part that starts from the beginning of the path and ends with the character before the last directory separator in the path.
The behavior is consistent with the Unix dirname software the last directory separator from the output dirname.
For example, getDirName("./paramonte", "/") yields "." similar to the dirname software behavior.
Also, getDirName("/", "/") yields "/", again similar to the behavior of Unix dirname.

Note
Counterintuitively, the UNIX dirname command treats paths that end in a trailing slash not as a directory.
The trailing slash represents all files within the directory.
For example according to the POSIX dirname implementation,
/home/martin/docs/
represents the listing of all files within the specified directory.
To point to the directory, one has to add a . character after the final directory separator character / as in,
/home/martin/docs/.
By default, this generic interface follows the behavior implemented in POSIX dirname.
Alternatively, however, one may be interested in extracting the dirname of a path verbatim while keeping the trailing directory separator character in the output dirname.
For example, one may prefer to treat paths ending with a directory separator characters (e.g., DIR_SEP_POSIX_ALL or DIR_SEP_WINDOWS_ALL) as full directory names followed by an empty basename.
This leads to the more intuitive behavior of yielding "/" as the result of getIndexDirName("/", "/") (similar to POSIX dirname software) while yielding "paramonte" as the result of getIndexDirName("paramonte/", "/") (unlike the POSIX dirname software which returns ".") In order to also allow this interpretation and behavior, the procedures of this generic interface implement this latter style by setting the style argument of this generic interface to an object of type verbatim_type such as the constant verbatim.
For more details on this alternative behavior, see the examples below.

See also the details of the documentation of the generic interface getIndexDirName.

Parameters
[in]path: The input scalar character of default kind SK of arbitrary length type parameter containing the path to split.
[in]dirsep: The input scalar character of default kind SK of arbitrary length type parameter containing the runtime directory separator(s).
The directory separator can be obtained from either the dirsep component of an object of type shell_type or getDirSep.
The directory separator is \ or / in Windows-based terminals (e.g., CMD or PowerShell) and / in POSIX-compliant shells.
When in doubt (for example, in Windows terminals), dirsep can be set to multiple characters, for example dirsep = "/\".
In such a case, the input path will be scanned for the presence of any of the individual characters in dirsep.
[in]style: The input scalar that can be,
  1. the constant verbatim or an object of type verbatim_type implying the use of the ParaMonte style described above in extracting the output dirname.
(optional. If missing, the default behavior corresponds to that of the dirname command on POSIX systems. See examples below.)
Returns
dirname : The output allocatable scalar character of default kind SK containing the dirname segment of the input path.


Possible calling interfaces

character(:, SK), allocatable :: dirname
dirname = getDirName(path, dirsep)
dirname = getDirName(path, dirsep, style)
Generate and return the dirname (directory name) part of the input path.
This module contains classes and procedures for manipulating system file/folder paths.
Definition: pm_sysPath.F90:274
type(verbatim_type), parameter verbatim
The scalar constant of type verbatim_type that can be used to signify the verbatim interpretation of ...
Definition: pm_sysPath.F90:367
Warning
The condition 0 < len(dirsep) must hold for the corresponding input arguments.
This condition is verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
Note
See getIndexDirName for a faster method of getting the dirname segment of a path that avoids memory allocation.
See also
getDirName
getExtName
getFileName
getBaseName
getIndexDirName
getIndexExtName
getIndexBaseName


Example usage

1program example
2
3 use pm_kind, only: LK
4 use pm_kind, only: SK ! all processor types and kinds are supported.
5 use pm_io, only: display_type
6 use pm_sysPath, only: verbatim
7 use pm_sysPath, only: getDirName
8
9 implicit none
10
11 character(:, SK), allocatable :: path
12
13 type(display_type) :: disp
14 disp = display_type(file = "main.out.F90")
15
16 call disp%skip()
17 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
18 call disp%show("! Get the dirname of a POSIX-compliant path.")
19 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
20 call disp%skip()
21
22 call disp%skip()
23 call disp%show("path = SK_''")
24 path = SK_''
25 call disp%show("getDirName(path, SK_'/')")
26 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
27 call disp%show("getDirName(path, SK_'/', verbatim)")
28 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
29 call disp%skip()
30
31 call disp%skip()
32 call disp%show("path = SK_'.'")
33 path = SK_'.'
34 call disp%show("getDirName(path, SK_'/')")
35 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
36 call disp%show("getDirName(path, SK_'/', verbatim)")
37 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
38 call disp%skip()
39
40 call disp%skip()
41 call disp%show("path = SK_'a'")
42 path = SK_'a'
43 call disp%show("getDirName(path, SK_'/')")
44 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
45 call disp%show("getDirName(path, SK_'/', verbatim)")
46 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
47 call disp%skip()
48
49 call disp%skip()
50 call disp%show("path = SK_'..'")
51 path = SK_'..'
52 call disp%show("getDirName(path, SK_'/')")
53 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
54 call disp%show("getDirName(path, SK_'/', verbatim)")
55 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
56 call disp%skip()
57
58 call disp%skip()
59 call disp%show("path = SK_'/.'")
60 path = SK_'/.'
61 call disp%show("getDirName(path, SK_'/')")
62 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
63 call disp%show("getDirName(path, SK_'/', verbatim)")
64 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
65 call disp%skip()
66
67 call disp%skip()
68 call disp%show("path = SK_'/..'")
69 path = SK_'/..'
70 call disp%show("getDirName(path, SK_'/')")
71 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
72 call disp%show("getDirName(path, SK_'/', verbatim)")
73 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
74 call disp%skip()
75
76 call disp%skip()
77 call disp%show("path = SK_'./'")
78 path = SK_'./'
79 call disp%show("getDirName(path, SK_'/')")
80 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
81 call disp%show("getDirName(path, SK_'/', verbatim)")
82 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
83 call disp%skip()
84
85 call disp%skip()
86 call disp%show("path = SK_'.//'")
87 path = SK_'.//'
88 call disp%show("getDirName(path, SK_'/')")
89 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
90 call disp%show("getDirName(path, SK_'/', verbatim)")
91 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
92 call disp%skip()
93
94 call disp%skip()
95 call disp%show("path = SK_'../'")
96 path = SK_'../'
97 call disp%show("getDirName(path, SK_'/')")
98 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
99 call disp%show("getDirName(path, SK_'/', verbatim)")
100 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
101 call disp%skip()
102
103 call disp%skip()
104 call disp%show("path = SK_'..///'")
105 path = SK_'..///'
106 call disp%show("getDirName(path, SK_'/')")
107 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
108 call disp%show("getDirName(path, SK_'/', verbatim)")
109 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
110 call disp%skip()
111
112 call disp%skip()
113 call disp%show("path = SK_'/'")
114 path = SK_'/'
115 call disp%show("getDirName(path, SK_'/')")
116 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
117 call disp%show("getDirName(path, SK_'/', verbatim)")
118 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
119 call disp%skip()
120
121 call disp%skip()
122 call disp%show("path = SK_'//'")
123 path = SK_'//'
124 call disp%show("getDirName(path, SK_'/')")
125 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
126 call disp%show("getDirName(path, SK_'/', verbatim)")
127 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
128 call disp%skip()
129
130 call disp%skip()
131 call disp%show("path = SK_'//./'")
132 path = SK_'//./'
133 call disp%show("getDirName(path, SK_'/')")
134 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
135 call disp%show("getDirName(path, SK_'/', verbatim)")
136 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
137 call disp%skip()
138
139 call disp%skip()
140 call disp%show("path = SK_'//.//'")
141 path = SK_'//.//'
142 call disp%show("getDirName(path, SK_'/')")
143 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
144 call disp%show("getDirName(path, SK_'/', verbatim)")
145 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
146 call disp%skip()
147
148 call disp%skip()
149 call disp%show("path = SK_'//.//a'")
150 path = SK_'//.//a'
151 call disp%show("getDirName(path, SK_'/')")
152 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
153 call disp%show("getDirName(path, SK_'/', verbatim)")
154 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
155 call disp%skip()
156
157 call disp%skip()
158 call disp%show("path = SK_'paramonte'")
159 path = SK_'paramonte'
160 call disp%show("getDirName(path, SK_'/')")
161 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
162 call disp%show("getDirName(path, SK_'/', verbatim)")
163 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
164 call disp%skip()
165
166 call disp%skip()
167 call disp%show("path = SK_'/paramonte'")
168 path = SK_'/paramonte'
169 call disp%show("getDirName(path, SK_'/')")
170 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
171 call disp%show("getDirName(path, SK_'/', verbatim)")
172 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
173 call disp%skip()
174
175 call disp%skip()
176 call disp%show("path = SK_'paramonte/'")
177 path = SK_'paramonte/'
178 call disp%show("getDirName(path, SK_'/')")
179 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
180 call disp%show("getDirName(path, SK_'/', verbatim)")
181 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
182 call disp%skip()
183
184 call disp%skip()
185 call disp%show("path = SK_'./paramonte'")
186 path = SK_'./paramonte'
187 call disp%show("getDirName(path, SK_'/')")
188 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
189 call disp%show("getDirName(path, SK_'/', verbatim)")
190 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
191 call disp%skip()
192
193 call disp%skip()
194 call disp%show("path = SK_'./paramonte/'")
195 path = SK_'./paramonte/'
196 call disp%show("getDirName(path, SK_'/')")
197 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
198 call disp%show("getDirName(path, SK_'/', verbatim)")
199 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
200 call disp%skip()
201
202 call disp%skip()
203 call disp%show("path = SK_'./paramonte/parallel/library.txt'")
204 path = SK_'./paramonte/parallel/library.txt'
205 call disp%show("getDirName(path, SK_'/')")
206 call disp%show( getDirName(path, SK_'/') , deliml = SK_"""" )
207 call disp%show("getDirName(path, SK_'/', verbatim)")
208 call disp%show( getDirName(path, SK_'/', verbatim) , deliml = SK_"""" )
209 call disp%skip()
210
211 call disp%skip()
212 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
213 call disp%show("! Get the dirname of a Windows-compliant path.")
214 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
215 call disp%skip()
216
217 call disp%skip()
218 call disp%show("path = SK_''")
219 path = SK_''
220 call disp%show("getDirName(path, SK_'/\')")
221 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
222 call disp%show("getDirName(path, SK_'/\', verbatim)")
223 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
224 call disp%skip()
225
226 call disp%skip()
227 call disp%show("path = SK_'.'")
228 path = SK_'.'
229 call disp%show("getDirName(path, SK_'/\')")
230 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
231 call disp%show("getDirName(path, SK_'/\', verbatim)")
232 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
233 call disp%skip()
234
235 call disp%skip()
236 call disp%show("path = SK_'..'")
237 path = SK_'..'
238 call disp%show("getDirName(path, SK_'/\')")
239 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
240 call disp%show("getDirName(path, SK_'/\', verbatim)")
241 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
242 call disp%skip()
243
244 call disp%skip()
245 call disp%show("path = SK_'/.'")
246 path = SK_'/.'
247 call disp%show("getDirName(path, SK_'/\')")
248 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
249 call disp%show("getDirName(path, SK_'/\', verbatim)")
250 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
251 call disp%skip()
252
253 call disp%skip()
254 call disp%show("path = SK_'\.'")
255 path = SK_'\.'
256 call disp%show("getDirName(path, SK_'/\')")
257 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
258 call disp%show("getDirName(path, SK_'/\', verbatim)")
259 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
260 call disp%skip()
261
262 call disp%skip()
263 call disp%show("path = SK_'/\..'")
264 path = SK_'/\..'
265 call disp%show("getDirName(path, SK_'/\')")
266 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
267 call disp%show("getDirName(path, SK_'/\', verbatim)")
268 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
269 call disp%skip()
270
271 call disp%skip()
272 call disp%show("path = SK_'./'")
273 path = SK_'./'
274 call disp%show("getDirName(path, SK_'/\')")
275 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
276 call disp%show("getDirName(path, SK_'/\', verbatim)")
277 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
278 call disp%skip()
279
280 call disp%skip()
281 call disp%show("path = SK_'../'")
282 path = SK_'../'
283 call disp%show("getDirName(path, SK_'/\')")
284 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
285 call disp%show("getDirName(path, SK_'/\', verbatim)")
286 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
287 call disp%skip()
288
289 call disp%skip()
290 call disp%show("path = SK_'/'")
291 path = SK_'/'
292 call disp%show("getDirName(path, SK_'/\')")
293 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
294 call disp%show("getDirName(path, SK_'/\', verbatim)")
295 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
296 call disp%skip()
297
298 call disp%skip()
299 call disp%show("path = SK_'/\'")
300 path = SK_'/\'
301 call disp%show("getDirName(path, SK_'/\')")
302 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
303 call disp%show("getDirName(path, SK_'/\', verbatim)")
304 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
305 call disp%skip()
306
307 call disp%skip()
308 call disp%show("path = SK_'//'")
309 path = SK_'//'
310 call disp%show("getDirName(path, SK_'/\')")
311 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
312 call disp%show("getDirName(path, SK_'/\', verbatim)")
313 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
314 call disp%skip()
315
316 call disp%skip()
317 call disp%show("path = SK_'//.\'")
318 path = SK_'//.\'
319 call disp%show("getDirName(path, SK_'/\')")
320 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
321 call disp%show("getDirName(path, SK_'/\', verbatim)")
322 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
323 call disp%skip()
324
325 call disp%skip()
326 call disp%show("path = SK_'//.\/'")
327 path = SK_'//.\/'
328 call disp%show("getDirName(path, SK_'/\')")
329 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
330 call disp%show("getDirName(path, SK_'/\', verbatim)")
331 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
332 call disp%skip()
333
334 call disp%skip()
335 call disp%show("path = SK_'\\.//a'")
336 path = SK_'\\.//a'
337 call disp%show("getDirName(path, SK_'/\')")
338 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
339 call disp%show("getDirName(path, SK_'/\', verbatim)")
340 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
341 call disp%skip()
342
343 call disp%skip()
344 call disp%show("path = SK_'paramonte'")
345 path = SK_'paramonte'
346 call disp%show("getDirName(path, SK_'/\')")
347 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
348 call disp%show("getDirName(path, SK_'/\', verbatim)")
349 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
350 call disp%skip()
351
352 call disp%skip()
353 call disp%show("path = SK_'/paramonte\'")
354 path = SK_'/paramonte\'
355 call disp%show("getDirName(path, SK_'/\')")
356 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
357 call disp%show("getDirName(path, SK_'/\', verbatim)")
358 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
359 call disp%skip()
360
361 call disp%skip()
362 call disp%show("path = SK_'paramonte/\'")
363 path = SK_'paramonte/\'
364 call disp%show("getDirName(path, SK_'/\')")
365 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
366 call disp%show("getDirName(path, SK_'/\', verbatim)")
367 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
368 call disp%skip()
369
370 call disp%skip()
371 call disp%show("path = SK_'./paramonte'")
372 path = SK_'./paramonte'
373 call disp%show("getDirName(path, SK_'/\')")
374 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
375 call disp%show("getDirName(path, SK_'/\', verbatim)")
376 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
377 call disp%skip()
378
379 call disp%skip()
380 call disp%show("path = SK_'./paramonte/'")
381 path = SK_'./paramonte/'
382 call disp%show("getDirName(path, SK_'/\')")
383 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
384 call disp%show("getDirName(path, SK_'/\', verbatim)")
385 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
386 call disp%skip()
387
388 call disp%skip()
389 call disp%show("path = SK_'.\paramonte/parallel\library.txt'")
390 path = SK_'.\paramonte/parallel\library.txt'
391 call disp%show("getDirName(path, SK_'/\')")
392 call disp%show( getDirName(path, SK_'/\') , deliml = SK_"""" )
393 call disp%show("getDirName(path, SK_'/\', verbatim)")
394 call disp%show( getDirName(path, SK_'/\', verbatim) , deliml = SK_"""" )
395 call disp%skip()
396
397end program example
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3! Get the dirname of a POSIX-compliant path.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
7path = SK_''
8getDirName(path, SK_'/')
9"."
10getDirName(path, SK_'/', verbatim)
11""
12
13
14path = SK_'.'
15getDirName(path, SK_'/')
16"."
17getDirName(path, SK_'/', verbatim)
18""
19
20
21path = SK_'a'
22getDirName(path, SK_'/')
23"."
24getDirName(path, SK_'/', verbatim)
25""
26
27
28path = SK_'..'
29getDirName(path, SK_'/')
30"."
31getDirName(path, SK_'/', verbatim)
32""
33
34
35path = SK_'/.'
36getDirName(path, SK_'/')
37"/"
38getDirName(path, SK_'/', verbatim)
39"/"
40
41
42path = SK_'/..'
43getDirName(path, SK_'/')
44"/"
45getDirName(path, SK_'/', verbatim)
46"/"
47
48
49path = SK_'./'
50getDirName(path, SK_'/')
51"."
52getDirName(path, SK_'/', verbatim)
53"./"
54
55
56path = SK_'.//'
57getDirName(path, SK_'/')
58"."
59getDirName(path, SK_'/', verbatim)
60".//"
61
62
63path = SK_'../'
64getDirName(path, SK_'/')
65"."
66getDirName(path, SK_'/', verbatim)
67"../"
68
69
70path = SK_'..///'
71getDirName(path, SK_'/')
72"."
73getDirName(path, SK_'/', verbatim)
74"..///"
75
76
77path = SK_'/'
78getDirName(path, SK_'/')
79"/"
80getDirName(path, SK_'/', verbatim)
81"/"
82
83
84path = SK_'//'
85getDirName(path, SK_'/')
86"/"
87getDirName(path, SK_'/', verbatim)
88"//"
89
90
91path = SK_'//./'
92getDirName(path, SK_'/')
93"/"
94getDirName(path, SK_'/', verbatim)
95"//./"
96
97
98path = SK_'//.//'
99getDirName(path, SK_'/')
100"/"
101getDirName(path, SK_'/', verbatim)
102"//.//"
103
104
105path = SK_'//.//a'
106getDirName(path, SK_'/')
107"//."
108getDirName(path, SK_'/', verbatim)
109"//.//"
110
111
112path = SK_'paramonte'
113getDirName(path, SK_'/')
114"."
115getDirName(path, SK_'/', verbatim)
116""
117
118
119path = SK_'/paramonte'
120getDirName(path, SK_'/')
121"/"
122getDirName(path, SK_'/', verbatim)
123"/"
124
125
126path = SK_'paramonte/'
127getDirName(path, SK_'/')
128"."
129getDirName(path, SK_'/', verbatim)
130"paramonte/"
131
132
133path = SK_'./paramonte'
134getDirName(path, SK_'/')
135"."
136getDirName(path, SK_'/', verbatim)
137"./"
138
139
140path = SK_'./paramonte/'
141getDirName(path, SK_'/')
142"."
143getDirName(path, SK_'/', verbatim)
144"./paramonte/"
145
146
147path = SK_'./paramonte/parallel/library.txt'
148getDirName(path, SK_'/')
149"./paramonte/parallel"
150getDirName(path, SK_'/', verbatim)
151"./paramonte/parallel/"
152
153
154!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155! Get the dirname of a Windows-compliant path.
156!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157
158
159path = SK_''
160getDirName(path, SK_'/\')
161"."
162getDirName(path, SK_'/\', verbatim)
163""
164
165
166path = SK_'.'
167getDirName(path, SK_'/\')
168"."
169getDirName(path, SK_'/\', verbatim)
170""
171
172
173path = SK_'..'
174getDirName(path, SK_'/\')
175"."
176getDirName(path, SK_'/\', verbatim)
177""
178
179
180path = SK_'/.'
181getDirName(path, SK_'/\')
182"/"
183getDirName(path, SK_'/\', verbatim)
184"/"
185
186
187path = SK_'\.'
188getDirName(path, SK_'/\')
189"\"
190getDirName(path, SK_'/\', verbatim)
191"\"
192
193
194path = SK_'/\..'
195getDirName(path, SK_'/\')
196"/"
197getDirName(path, SK_'/\', verbatim)
198"/\"
199
200
201path = SK_'./'
202getDirName(path, SK_'/\')
203"."
204getDirName(path, SK_'/\', verbatim)
205"./"
206
207
208path = SK_'../'
209getDirName(path, SK_'/\')
210"."
211getDirName(path, SK_'/\', verbatim)
212"../"
213
214
215path = SK_'/'
216getDirName(path, SK_'/\')
217"/"
218getDirName(path, SK_'/\', verbatim)
219"/"
220
221
222path = SK_'/\'
223getDirName(path, SK_'/\')
224"/"
225getDirName(path, SK_'/\', verbatim)
226"/\"
227
228
229path = SK_'//'
230getDirName(path, SK_'/\')
231"/"
232getDirName(path, SK_'/\', verbatim)
233"//"
234
235
236path = SK_'//.\'
237getDirName(path, SK_'/\')
238"/"
239getDirName(path, SK_'/\', verbatim)
240"//.\"
241
242
243path = SK_'//.\/'
244getDirName(path, SK_'/\')
245"/"
246getDirName(path, SK_'/\', verbatim)
247"//.\/"
248
249
250path = SK_'\\.//a'
251getDirName(path, SK_'/\')
252"\\."
253getDirName(path, SK_'/\', verbatim)
254"\\.//"
255
256
257path = SK_'paramonte'
258getDirName(path, SK_'/\')
259"."
260getDirName(path, SK_'/\', verbatim)
261""
262
263
264path = SK_'/paramonte\'
265getDirName(path, SK_'/\')
266"/"
267getDirName(path, SK_'/\', verbatim)
268"/paramonte\"
269
270
271path = SK_'paramonte/\'
272getDirName(path, SK_'/\')
273"."
274getDirName(path, SK_'/\', verbatim)
275"paramonte/\"
276
277
278path = SK_'./paramonte'
279getDirName(path, SK_'/\')
280"."
281getDirName(path, SK_'/\', verbatim)
282"./"
283
284
285path = SK_'./paramonte/'
286getDirName(path, SK_'/\')
287"."
288getDirName(path, SK_'/\', verbatim)
289"./paramonte/"
290
291
292path = SK_'.\paramonte/parallel\library.txt'
293getDirName(path, SK_'/\')
294".\paramonte/parallel"
295getDirName(path, SK_'/\', verbatim)
296".\paramonte/parallel\"
297
298
Test:
test_pm_sysPath
Todo:
High Priority: The current Fortran standard 202x does not allow passing characters of non-default kind to the intrinsic Fortran statements and procedures.
As such, the implementation of this procedure for non-default character kinds leads to compile-time kind mismatch errors.
This procedure should be converted back to a generic interface in the future when non-default character kinds are also fully supported by the intrinsic functions.


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, Tuesday March 7, 2017, 7:03 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin

Definition at line 5874 of file pm_sysPath.F90.


The documentation for this interface was generated from the following file: