Skip to content

Commit 9eccdd8

Browse files
authored
Merge branch 'fortran-lang:master' into iterative
2 parents 297a18d + 60d0a76 commit 9eccdd8

24 files changed

+510
-107
lines changed

config/cmake/Findtest-drive.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ foreach(method ${${_pkg}_FIND_METHOD})
123123

124124
# We need the module directory in the subproject before we finish the configure stage
125125
if(NOT EXISTS "${${_pkg}_BINARY_DIR}/include")
126-
make_directory("${${_pkg}_BINARY_DIR}/include")
126+
file(MAKE_DIRECTORY "${${_pkg}_BINARY_DIR}/include")
127127
endif()
128128

129129
break()
@@ -147,7 +147,7 @@ foreach(method ${${_pkg}_FIND_METHOD})
147147
FetchContent_GetProperties("${_lib}" SOURCE_DIR "${_pkg}_SOURCE_DIR")
148148
FetchContent_GetProperties("${_lib}" BINARY_DIR "${_pkg}_BINARY_DIR")
149149
if(NOT EXISTS "${${_pkg}_BINARY_DIR}/include")
150-
make_directory("${${_pkg}_BINARY_DIR}/include")
150+
file(MAKE_DIRECTORY "${${_pkg}_BINARY_DIR}/include")
151151
endif()
152152

153153
break()

doc/specs/stdlib_io.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Loads a rank-2 `array` from a text file.
1717

1818
### Syntax
1919

20-
`call ` [[stdlib_io(module):loadtxt(interface)]] `(filename, array [, skiprows] [, max_rows] [, fmt])`
20+
`call ` [[stdlib_io(module):loadtxt(interface)]] `(filename, array [, skiprows] [, max_rows] [, fmt] [, delimiter])`
2121

2222
### Arguments
2323

@@ -31,7 +31,7 @@ Loads a rank-2 `array` from a text file.
3131

3232
`fmt` (optional): Fortran format specifier for the text read. Defaults to the write format for the data type. Setting fmt='*' will specify list directed read.
3333

34-
34+
`delimiter` (optional): Shall be a character expression of length 1 that contains the delimiter used to separate the columns. The default is `' '`.
3535

3636
### Return value
3737

@@ -52,7 +52,8 @@ Experimental
5252

5353
### Description
5454

55-
Returns the unit number of a file opened to read, to write, or to read and write. The file might be a text file or a binary file. All files are opened using a streamed access.
55+
Returns the unit number of a file opened to read, to write, or to read and write. The file might be a text file or a binary file.
56+
Text files are opened using a sequential access, while binary files are opened using a streamed access.
5657

5758
### Syntax
5859

@@ -105,14 +106,16 @@ Saves a rank-2 `array` into a text file.
105106

106107
### Syntax
107108

108-
`call ` [[stdlib_io(module):savetxt(interface)]] `(filename, array)`
109+
`call ` [[stdlib_io(module):savetxt(interface)]] `(filename, array [, delimiter])`
109110

110111
### Arguments
111112

112113
`filename`: Shall be a character expression containing the name of the file that will contain the 2D `array`.
113114

114115
`array`: Shall be a rank-2 array of type `real`, `complex` or `integer`.
115116

117+
`delimiter` (optional): Shall be a character expression of length 1 that contains the delimiter used to separate the columns. The default is `' '`.
118+
116119
### Output
117120

118121
Provides a text file called `filename` that contains the rank-2 `array`.

doc/specs/stdlib_math.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ Experimental
427427

428428
Elemenal function.
429429

430-
### Description
430+
#### Description
431431

432432
`deg2rad` converts phase angles from degrees to radians.
433433

doc/specs/stdlib_sparse.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Type-bound procedures to enable requesting data from a sparse matrix.
178178

179179
`v` : Shall be a `real` or `complex` value in accordance to the declared sparse matrix object. If the `ij` tuple is within the sparse pattern, `v` contains the value in the data buffer. If the `ij` tuple is outside the sparse pattern, `v` is equal `0`. If the `ij` tuple is outside the matrix pattern `(nrows,ncols)`, `v` is `NaN`.
180180

181-
## Example
181+
### Example
182182
```fortran
183183
{!example/linalg/example_sparse_data_accessors.f90!}
184184
```
@@ -257,7 +257,7 @@ This module provides facility functions for converting between storage formats.
257257

258258
`chunk`, `optional`: chunk size, only valid in the case of a `SELLC` matrix, by default it will be taken from the `SELLC` default attribute chunk size. It is an `intent(in)` argument.
259259

260-
## Example
260+
### Example
261261
```fortran
262262
{!example/linalg/example_sparse_from_ijv.f90!}
263263
```
@@ -358,7 +358,7 @@ If the `diagonal` array has not been previously allocated, the `diag` subroutine
358358

359359
`coo` : Shall be a `COO` type of `real` or `complex` type. It is an `intent(out)` argument.
360360

361-
## Example
361+
### Example
362362
```fortran
363363
{!example/linalg/example_sparse_spmv.f90!}
364364
```

doc/specs/stdlib_system.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,85 @@ None.
410410

411411
Returns one of the `integer` `OS_*` parameters representing the OS type, from the `stdlib_system` module, or `OS_UNKNOWN` if undetermined.
412412

413+
### Example
414+
415+
```fortran
416+
{!example/system/example_os_type.f90!}
417+
```
418+
413419
---
414420

421+
## `is_directory` - Test if a path is a directory
422+
423+
### Status
424+
425+
Experimental
426+
427+
### Description
428+
429+
This function checks if a specified file system path is a directory.
430+
It is designed to work across multiple platforms. On Windows, paths with both forward `/` and backward `\` slashes are accepted.
431+
432+
### Syntax
433+
434+
`result = [[stdlib_io(module):is_directory(function)]] (path)`
435+
436+
### Class
437+
438+
Function
439+
440+
### Arguments
441+
442+
`path`: Shall be a character string containing the file system path to evaluate. It is an `intent(in)` argument.
443+
444+
### Return values
445+
446+
The function returns a `logical` value:
447+
448+
- `.true.` if the path matches an existing directory.
449+
- `.false.` otherwise, or if the operating system is unsupported.
450+
415451
### Example
416452

417453
```fortran
418-
{!example/system/example_os_type.f90!}
454+
{!example/system/example_is_directory.f90!}
455+
```
456+
457+
---
458+
459+
## `null_device` - Return the null device file path
460+
461+
### Status
462+
463+
Experimental
464+
465+
### Description
466+
467+
This function returns the file path of the null device, which is a special file used to discard any data written to it.
468+
It reads as an empty file. The null device's path varies by operating system:
469+
- On Windows, the null device is represented as `NUL`.
470+
- On UNIX-like systems (Linux, macOS), the null device is represented as `/dev/null`.
471+
472+
### Syntax
473+
474+
`path = [[stdlib_system(module):null_device(function)]]()`
475+
476+
### Class
477+
478+
Function
479+
480+
### Arguments
481+
482+
None.
483+
484+
### Return Value
485+
486+
- **Type:** `character(:), allocatable`
487+
- Returns the null device file path as a character string, appropriate for the operating system.
488+
489+
### Example
490+
491+
```fortran
492+
{!example/system/example_null_device.f90!}
419493
```
494+

example/io/example.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1.00000000E+00, 1.00000000E+00
2+
1.00000000E+00, 1.00000000E+00
3+
1.00000000E+00, 1.00000000E+00

example/io/example_loadtxt.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ program example_loadtxt
66

77
! Can also use list directed format if the default read fails.
88
call loadtxt('example.dat', x, fmt='*')
9+
10+
call loadtxt('example.csv', x, delimiter=',')
11+
912
end program example_loadtxt

example/io/example_savetxt.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ program example_savetxt
33
implicit none
44
real :: x(3, 2) = 1
55
call savetxt('example.dat', x)
6+
call savetxt('example.csv', x, delimiter=',')
67
end program example_savetxt

example/system/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
ADD_EXAMPLE(get_runtime_os)
2+
ADD_EXAMPLE(is_directory)
3+
ADD_EXAMPLE(null_device)
24
ADD_EXAMPLE(os_type)
35
ADD_EXAMPLE(process_1)
46
ADD_EXAMPLE(process_2)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
! Demonstrate usage of `is_directory`
2+
program example_is_directory
3+
use stdlib_system, only: is_directory
4+
implicit none
5+
! Test a directory path
6+
if (is_directory("/path/to/check")) then
7+
print *, "The specified path is a directory."
8+
else
9+
print *, "The specified path is not a directory."
10+
end if
11+
end program example_is_directory

0 commit comments

Comments
 (0)