This module contains general routines for interacting with the file system
Directories are not files for the Intel compilers. If so, also use this compiler-dependent extension
Extract filename from path with/without suffix
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path | |||
| logical, | intent(in), | optional | :: | suffix |
Canonicalize path for comparison * Handles path string redundancies * Does not test existence of path
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
Extract dirname from path
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
test if pathname already exists
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | filename |
Ensure a windows path is converted to an 8.3 DOS path if it contains spaces No need to convert if there are no spaces
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path | |||
| type(error_t), | intent(out), | allocatable | :: | error |
Determine the path prefix to the local folder. Used for installation, registry etc.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in), | optional | :: | os |
Platform identifier |
Installation prefix
Get a unused temporary filename Calls posix ‘tempnam’ - not recommended, but we have no security concerns for this application and use here is temporary. Works with MinGW
Returns .true. if provided path is absolute.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path | |||
| logical, | intent(in), | optional | :: | is_unix |
test if a name matches an existing directory path
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | dir |
test if a file is hidden
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | file_basename |
Construct path by joining strings with os file separator
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | a1 | |||
| character(len=*), | intent(in) | :: | a2 | |||
| character(len=*), | intent(in), | optional | :: | a3 | ||
| character(len=*), | intent(in), | optional | :: | a4 | ||
| character(len=*), | intent(in), | optional | :: | a5 |
Determine number or rows in a file given a LUN
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | s |
Extract dirname from path
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
read lines into an array of TYPE(STRING_T) variables
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | filename |
read lines into an array of TYPE(STRING_T) variables expanding tabs
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | filename |
Replace file system separators for unix
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
function which(command) result(pathname)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | command |
Replace file system separators for windows
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
delete a file by filename
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | file |
Execute command line and return output as a string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | cmd |
Command to execute. |
||
| character(len=:), | intent(out), | allocatable | :: | output |
Command line output. |
|
| type(error_t), | intent(out), | allocatable | :: | error |
Error to handle. |
|
| logical, | intent(in), | optional | :: | verbose |
Print additional information if true. |
simple close of a LUN. On error show message and stop (by default)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | lun | |||
| integer, | intent(out), | optional | :: | ier |
procedure to open filename as a sequential “text” file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | filename | |||
| integer, | intent(out) | :: | lun | |||
| integer, | intent(out), | optional | :: | ier |
procedure to write filedata to file filename
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | filename | |||
| character(len=*), | intent(in) | :: | filedata(:) |
Get the HOME directory on Unix and the %USERPROFILE% directory on Windows.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=:), | intent(out), | allocatable | :: | home | ||
| type(error_t), | intent(out), | allocatable | :: | error |
subroutine getline(unit,line,iostat,iomsg)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | unit |
Formatted IO unit |
||
| character(len=:), | intent(out), | allocatable | :: | line |
Line to read |
|
| integer, | intent(out) | :: | iostat |
Status of operation |
||
| character(len=:), | optional, | allocatable | :: | iomsg |
Error message |
Get file & directory names in directory dir using iso_c_binding.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | dir | |||
| type(string_t), | intent(out), | allocatable | :: | files(:) | ||
| logical, | intent(in), | optional | :: | recurse |
Create a directory. Create subdirectories as needed
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | dir | |||
| logical, | intent(in), | optional | :: | echo |
Delete directory using system OS remove directory commands
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(in) | :: | is_unix | |||
| character(len=*), | intent(in) | :: | dir | |||
| logical, | intent(in), | optional | :: | echo |
Execute the specified system command. Optionally
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | cmd | |||
| logical, | intent(in), | optional | :: | echo | ||
| integer, | intent(out), | optional | :: | exitstat | ||
| logical, | intent(in), | optional | :: | verbose | ||
| character(len=*), | intent(in), | optional | :: | redirect |
write trimmed character data to a file if it does not exist
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | fname | |||
| character(len=*), | intent(in) | :: | data(:) |