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

Generate and return the index of the last character of the hostname part of the input UNC path.
More...

Detailed Description

Generate and return the index of the last character of the hostname part of the input UNC path.

  1. The Universal Naming Convention (UNC) is a standard for identifying servers, printers and other resources in a network.
  2. According to the US patent 5341499 (by IBM), the UNC was jointly invented by IBM and Microsoft for use in their jointly developed Local Area Network (LAN) software products.
  3. A UNC path uses double slashes or backslashes to precede the name of the computer.
  4. The host-name portion of a UNC path can consist of either a network name string set by an administrator and maintained by a network naming service like DNS or WINS, or by an IP address.
  5. These hostnames normally refer to either a PC, printer, or other devices.
  6. The path (disk and directories) within the computer are separated with a single slash or backslash, as usual.
  7. Note that in under Microsoft DOS/Windows platforms, drive letters (c:, d:, etc.) are not used in UNC names and if used, the : character is dropped.
  8. The typical structure of a UNC path is the following,
    1. On Windows systems: \\hostname\path or //hostname/path has the hostname \\hostname.
    2. On Unix systems: //hostname/path has the hostname //hostname.
  9. Note that UNC path names are not universally recognized on all Unix platforms.
    For more information, see the POSIX standard.
Parameters
[in]path: The input scalar character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of arbitrary length type parameter containing the potentially UNC path whose hostname portion is to be identified and the index of its last character returned.
[in]dirsep: The input scalar character of the same kind as path, of arbitrary length type parameter containing the directory separators that might be present in the input path. For example,
  1. On Windows platforms, this can be DIR_SEP_WINDOWS_ALL.
  2. On Unix platforms, this can be DIR_SEP_POSIX_ALL.
Returns
index : The output scalar integer of default kind IK containing the index of the last character of hostname portion of the input UNC path.
If there is no hostname, index = 0 on output.


Possible calling interfaces

use pm_kind, only: IK
integer(IK) :: index
index = getPathHostNameIndex(path, dirsep)
Generate and return the index of the last character of the hostname part of the input UNC path.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
This module contains classes and procedures for manipulating system file/folder paths.
Definition: pm_sysPath.F90:274
Warning
Note that no trimming of the input path is performed by the procedure.
Consequently, any leading or trailing whitespace characters will be significant.
Similarly, single and double quotation marks that appear anywhere in path are significant and kept.
Remarks
The procedures under discussion are pure.
The procedures under discussion are elemental.
See also
getPathNew
getPathPosix
setPathPosix
getPathWindows
setPathWindows
getPathHostNameIndex


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
7
8 implicit none
9
10 character(:), allocatable :: path
11
12 type(display_type) :: disp
13 disp = display_type(file = "main.out.F90")
14
15 call disp%skip()
16 call disp%show("path = SK_''")
17 path = SK_''
18 call disp%show("getPathHostNameIndex(path, SK_'/')")
19 call disp%show( getPathHostNameIndex(path, SK_'/') )
20 call disp%show("path(1:getPathHostNameIndex(path, SK_'/'))")
21 call disp%show( path(1:getPathHostNameIndex(path, SK_'/')) , deliml = """" )
22 call disp%skip()
23
24 call disp%skip()
25 call disp%show("path = SK_'.'")
26 path = SK_'.'
27 call disp%show("getPathHostNameIndex(path, SK_'/')")
28 call disp%show( getPathHostNameIndex(path, SK_'/') )
29 call disp%show("path(1:getPathHostNameIndex(path, SK_'/'))")
30 call disp%show( path(1:getPathHostNameIndex(path, SK_'/')) , deliml = """" )
31 call disp%skip()
32
33 call disp%skip()
34 call disp%show("path = SK_'..'")
35 path = SK_'..'
36 call disp%show("getPathHostNameIndex(path, SK_'/')")
37 call disp%show( getPathHostNameIndex(path, SK_'/') )
38 call disp%show("path(1:getPathHostNameIndex(path, SK_'/'))")
39 call disp%show( path(1:getPathHostNameIndex(path, SK_'/')) , deliml = """" )
40 call disp%skip()
41
42 call disp%skip()
43 call disp%show("path = SK_'/..'")
44 path = SK_'/..'
45 call disp%show("getPathHostNameIndex(path, SK_'/')")
46 call disp%show( getPathHostNameIndex(path, SK_'/') )
47 call disp%show("path(1:getPathHostNameIndex(path, SK_'/'))")
48 call disp%show( path(1:getPathHostNameIndex(path, SK_'/')) , deliml = """" )
49 call disp%skip()
50
51 call disp%skip()
52 call disp%show("path = SK_'//..'")
53 path = SK_'//..'
54 call disp%show("getPathHostNameIndex(path, SK_'/')")
55 call disp%show( getPathHostNameIndex(path, SK_'/') )
56 call disp%show("path(1:getPathHostNameIndex(path, SK_'/'))")
57 call disp%show( path(1:getPathHostNameIndex(path, SK_'/')) , deliml = """" )
58 call disp%skip()
59
60 call disp%skip()
61 call disp%show("path = SK_'/\..\'")
62 path = SK_'/\..\'
63 call disp%show("getPathHostNameIndex(path, SK_'/\')")
64 call disp%show( getPathHostNameIndex(path, SK_'/\') )
65 call disp%show("path(1:getPathHostNameIndex(path, SK_'/\'))")
66 call disp%show( path(1:getPathHostNameIndex(path, SK_'/\')) , deliml = """" )
67 call disp%skip()
68
69 call disp%skip()
70 call disp%show("path = SK_'/\.\'")
71 path = SK_'/\.\'
72 call disp%show("getPathHostNameIndex(path, SK_'/\')")
73 call disp%show( getPathHostNameIndex(path, SK_'/\') )
74 call disp%show("path(1:getPathHostNameIndex(path, SK_'/\'))")
75 call disp%show( path(1:getPathHostNameIndex(path, SK_'/\')) , deliml = """" )
76 call disp%skip()
77
78 call disp%skip()
79 call disp%show("path = SK_'../'")
80 path = SK_'../'
81 call disp%show("getPathHostNameIndex(path, SK_'/')")
82 call disp%show( getPathHostNameIndex(path, SK_'/') )
83 call disp%show("path(1:getPathHostNameIndex(path, SK_'/'))")
84 call disp%show( path(1:getPathHostNameIndex(path, SK_'/')) , deliml = """" )
85 call disp%skip()
86
87 call disp%skip()
88 call disp%show("path = SK_'/'")
89 path = SK_'/'
90 call disp%show("getPathHostNameIndex(path, SK_'/')")
91 call disp%show( getPathHostNameIndex(path, SK_'/') )
92 call disp%show("path(1:getPathHostNameIndex(path, SK_'/'))")
93 call disp%show( path(1:getPathHostNameIndex(path, SK_'/')) , deliml = """" )
94 call disp%skip()
95
96 call disp%skip()
97 call disp%show("path = SK_'/paramonte'")
98 path = SK_'/paramonte'
99 call disp%show("getPathHostNameIndex(path, SK_'/')")
100 call disp%show( getPathHostNameIndex(path, SK_'/') )
101 call disp%show("path(1:getPathHostNameIndex(path, SK_'/'))")
102 call disp%show( path(1:getPathHostNameIndex(path, SK_'/')) , deliml = """" )
103 call disp%skip()
104
105 call disp%skip()
106 call disp%show("path = SK_'./paramonte'")
107 path = SK_'./paramonte'
108 call disp%show("getPathHostNameIndex(path, SK_'/')")
109 call disp%show( getPathHostNameIndex(path, SK_'/') )
110 call disp%show("path(1:getPathHostNameIndex(path, SK_'/'))")
111 call disp%show( path(1:getPathHostNameIndex(path, SK_'/')) , deliml = """" )
112 call disp%skip()
113
114 call disp%skip()
115 call disp%show("path = SK_'//paramonte\parallel/library.txt'")
116 path = SK_'//paramonte\parallel/library.txt'
117 call disp%show("getPathHostNameIndex(path, SK_'/')")
118 call disp%show( getPathHostNameIndex(path, SK_'/') )
119 call disp%show("path(1:getPathHostNameIndex(path, SK_'/'))")
120 call disp%show( path(1:getPathHostNameIndex(path, SK_'/')) , deliml = """" )
121 call disp%skip()
122
123 call disp%skip()
124 call disp%show("path = SK_'//paramonte\parallel/library.txt'")
125 path = SK_'//paramonte\parallel/library.txt'
126 call disp%show("getPathHostNameIndex(path, SK_'/\')")
127 call disp%show( getPathHostNameIndex(path, SK_'/\') )
128 call disp%show("path(1:getPathHostNameIndex(path, SK_'/\'))")
129 call disp%show( path(1:getPathHostNameIndex(path, SK_'/\')) , deliml = """" )
130 call disp%skip()
131
132 call disp%skip()
133 call disp%show("path = SK_'\\wsl$\Ubuntu-20.04\home\'")
134 path = SK_'\\wsl$\Ubuntu-20.04\home\'
135 call disp%show("getPathHostNameIndex(path, SK_'\')")
136 call disp%show( getPathHostNameIndex(path, SK_'\') )
137 call disp%show("path(1:getPathHostNameIndex(path, SK_'\'))")
138 call disp%show( path(1:getPathHostNameIndex(path, SK_'\')) , deliml = """" )
139 call disp%skip()
140
141end 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
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
2path = SK_''
3getPathHostNameIndex(path, SK_'/')
4+0
5path(1:getPathHostNameIndex(path, SK_'/'))
6""
7
8
9path = SK_'.'
10getPathHostNameIndex(path, SK_'/')
11+0
12path(1:getPathHostNameIndex(path, SK_'/'))
13""
14
15
16path = SK_'..'
17getPathHostNameIndex(path, SK_'/')
18+0
19path(1:getPathHostNameIndex(path, SK_'/'))
20""
21
22
23path = SK_'/..'
24getPathHostNameIndex(path, SK_'/')
25+0
26path(1:getPathHostNameIndex(path, SK_'/'))
27""
28
29
30path = SK_'//..'
31getPathHostNameIndex(path, SK_'/')
32+4
33path(1:getPathHostNameIndex(path, SK_'/'))
34"//.."
35
36
37path = SK_'/\..\'
38getPathHostNameIndex(path, SK_'/\')
39+4
40path(1:getPathHostNameIndex(path, SK_'/\'))
41"/\.."
42
43
44path = SK_'/\.\'
45getPathHostNameIndex(path, SK_'/\')
46+3
47path(1:getPathHostNameIndex(path, SK_'/\'))
48"/\."
49
50
51path = SK_'../'
52getPathHostNameIndex(path, SK_'/')
53+0
54path(1:getPathHostNameIndex(path, SK_'/'))
55""
56
57
58path = SK_'/'
59getPathHostNameIndex(path, SK_'/')
60+0
61path(1:getPathHostNameIndex(path, SK_'/'))
62""
63
64
65path = SK_'/paramonte'
66getPathHostNameIndex(path, SK_'/')
67+0
68path(1:getPathHostNameIndex(path, SK_'/'))
69""
70
71
72path = SK_'./paramonte'
73getPathHostNameIndex(path, SK_'/')
74+0
75path(1:getPathHostNameIndex(path, SK_'/'))
76""
77
78
79path = SK_'//paramonte\parallel/library.txt'
80getPathHostNameIndex(path, SK_'/')
81+20
82path(1:getPathHostNameIndex(path, SK_'/'))
83"//paramonte\parallel"
84
85
86path = SK_'//paramonte\parallel/library.txt'
87getPathHostNameIndex(path, SK_'/\')
88+11
89path(1:getPathHostNameIndex(path, SK_'/\'))
90"//paramonte"
91
92
93path = SK_'\\wsl$\Ubuntu-20.04\home\'
94getPathHostNameIndex(path, SK_'\')
95+6
96path(1:getPathHostNameIndex(path, SK_'\'))
97"\\wsl$"
98
99
Test:
test_pm_sysPath


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, 3:50 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin

Definition at line 2135 of file pm_sysPath.F90.


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