ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation. |
Generate and return a unique (directory or file) path name in the specified directory or the default current working directory.
More...
Generate and return a unique (directory or file) path name in the specified directory or the default current working directory.
The procedures under this generic interface return a full unique path that is,
dir
,prefix
,ext
, that can be either.*
, if a file path is desired as the output, orThe procedures under this generic interface use the current date and time and the process ID to generate new unique non-existing directory or file paths.
The general format of the output directory path is the following:
<dir><prefix><ccyymmdd><sep><hhmmss><sep><sss><sep>pid<sep><pid><ext>
where,
<dir>
is replaced with the contents of the input argument dir
or its default value (followed by the path-separator symbol if needed), <prefix>
is replaced with the contents of the input argument prefix
or its default value, <sep>
is replaced with the contents of the input argument sep
or its default value, <ccyymmdd>
is replaced with the current century, year, month, and day, each represented by two characters, <hhmmss>
is replaced with the current hour hh
, minute mm
, second ss
, in the specified ordered, <sss>
is replaced with the current millisecond mmm
, <pid>
is replaced with the user-specified processor ID pid
which can be the output of getImageID.<ext>
is replaced with the contents of the input argument ext
or its default value.If no unique path is found after 1000
attempts, the procedure returns and reports a failure.
[in] | dir | : The input scalar character of default kind SK containing the directory where the new path should reside.If dir does not end with the proper system shell path-separator symbol, it will be suffixed with the proper symbol.However, it is recommended to pass an input dir that is already suffixed with the proper path-separator.The input dir is prefixed to the new path name that is to be constructed.(optional, default = "" ) |
[in] | prefix | : The input scalar character of default kind SK containing the requested input prefix to the path that appears immediately after the input dir in the newly-constructed path.(optional, default = "new"//sep where sep is the other optional argument of the interface.) |
[in] | sep | : The input scalar character of default kind SK containing the requested separator character to be inserted between the individual components of the new path to be constructed.This is different from the system shell directory separator. (optional, default = "_" ) |
[in] | ext | : The input scalar character of default kind SK containing the requested input file extension or directory path-separator to appear at the end of the path.(optional, default = "" ) |
[in] | pid | : The input scalar integer of default kind IK representing the processor ID (e.g., processor MPI rank or Coarray image ID).If present, it will be used in the generated path to make it processor-specific. The processor MPI rank or Coarray image ID can be for example obtained by calling getImageID. (optional, default = getImageID()) |
[out] | failed | : The output logical of default kind LK that is .true. if and only if the procedure fails to find a new unique (non-existent) path.(optional, if missing and the procedure fails, then the program will halt by calling error stop .) |
pathNew
: The output allocatable
scalar of type character
of default kind SK containing a new unique non-existent path.
Possible calling interfaces ⛓
ext
argument, if it is present and contains a file extension, must the proper file extension separator symbol (e.g., .
)..
) will not be added to the input extension by this procedure.dir
on Windows OS, the following steps are taken:dir
does not end with a directory separator recognized by Windows (DIR_SEP_WINDOWS_ALL), then dir
will be suffixed with a Windows-style path-separator.dir
does not end with a directory separator (DIR_SEP_POSIX_ALL) recognized by POSIX-style runtime shells (including Fish), then dir
will be suffixed with a POSIX-style path-separator.impure
.
Example usage ⛓
ifort
compiler ⛓ ifort
compiler ⛓ gfortran
compiler ⛓ character
kinds leads to compile-time kind mismatch errors.suffix
argument can be added in the future. Currently, the path suffix is hard-coded in the procedure, unlike prefix
.
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.
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.
Definition at line 4367 of file pm_sysPath.F90.