Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system: subprocessing interface #911

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
979ba84
add c source
perazz Dec 24, 2024
79ddfc4
add subprocess module
perazz Dec 24, 2024
adacbcf
`to_c_string`: move to strings, document
perazz Dec 24, 2024
5b543a2
use temporary `getfile` and `linalg_state_type` f
perazz Dec 24, 2024
519d53d
implement `join`
perazz Dec 24, 2024
1449b8d
fixes to build
perazz Dec 24, 2024
cf35194
create submodule
perazz Dec 24, 2024
e8451b2
unify `sleep` interface
perazz Dec 24, 2024
48da380
add single-command `run` API
perazz Dec 24, 2024
1f4de32
add tests
perazz Dec 24, 2024
6fbc2e6
getfile: remove trailing new line characters
perazz Dec 24, 2024
f9bf304
fix tests to be cross-platform
perazz Dec 24, 2024
71facb3
use `nanosleep` rather than `usleep`
perazz Dec 24, 2024
6ea72d1
add examples
perazz Dec 24, 2024
e35b37a
`kill` process
perazz Dec 24, 2024
237e9ff
add process killing example
perazz Dec 24, 2024
2c58fca
on Windows, redirect to `NUL` if output not requested
perazz Dec 24, 2024
136b5b8
remove unused process handle
perazz Dec 25, 2024
d8df028
document `run` interface
perazz Dec 25, 2024
94f2bdf
document `is_running`, `is_completed`, `elapsed`
perazz Dec 25, 2024
3fb88e4
add `system` page
perazz Dec 25, 2024
53fc8e5
document `wait`
perazz Dec 25, 2024
b30cae4
document `update`
perazz Dec 25, 2024
122fbc6
document `kill`
perazz Dec 25, 2024
56ed7c8
document `sleep`
perazz Dec 25, 2024
c617048
document `has_win32`
perazz Dec 25, 2024
ed0565c
fix
perazz Dec 25, 2024
c03655a
Merge branch 'subprocess' of github.com:perazz/stdlib into subprocess
perazz Dec 26, 2024
eb77455
Merge branch 'fortran-lang:master' into subprocess
perazz Dec 26, 2024
74b6ebe
change syntax for `ifx` fix
perazz Dec 26, 2024
9873bc9
fix `sleep` us -> ns
perazz Dec 26, 2024
34732ff
fix `pid` size
perazz Dec 26, 2024
53b03b0
full-cmd: do not use stack
perazz Dec 26, 2024
5a1bd54
fix `sleep`
perazz Dec 26, 2024
9b74bea
process example 2: set max_wait_time
perazz Dec 26, 2024
bdb2840
sleep: fix `bind(C)` interface
perazz Dec 26, 2024
a1aaf2f
split `run` vs `runasync`
perazz Jan 28, 2025
4d5eb32
`run/runasync` docs
perazz Jan 28, 2025
56f02ab
`has_win32` -> `is_windows`
perazz Jan 28, 2025
15689bc
Update example_process_1.f90
perazz Jan 28, 2025
060dec7
Merge branch 'master' into subprocess
perazz Jan 28, 2025
3560a6f
missing `is_windows` tests
perazz Jan 28, 2025
e75bbc9
Merge branch 'subprocess' of github.com:perazz/stdlib into subprocess
perazz Jan 28, 2025
d1a4715
Update example_process_4.f90
perazz Jan 28, 2025
68dca8d
Merge branch 'fortran-lang:master' into subprocess
perazz Jan 29, 2025
7653cc4
add object oriented interface
perazz Feb 4, 2025
06c7136
add oop example
perazz Feb 4, 2025
f40a547
process ID (`pid`) getter interface
perazz Feb 4, 2025
d2ee2f2
implement callback
perazz Feb 4, 2025
3f08a8b
add callback example
perazz Feb 4, 2025
d694dcf
fix submodule
perazz Feb 4, 2025
80a2d0a
intel fix: no inline type
perazz Feb 4, 2025
20c045d
document callback and payload functionality
perazz Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14.0)
set(CMAKE_USER_MAKE_RULES_OVERRIDE ${CMAKE_CURRENT_SOURCE_DIR}/config/DefaultFlags.cmake)

project(fortran_stdlib
LANGUAGES Fortran
LANGUAGES Fortran C
DESCRIPTION "Community driven and agreed upon de facto standard library for Fortran"
)

Expand Down
4 changes: 2 additions & 2 deletions config/fypp_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def recursive_copy(folder):
for root, _, files in os.walk(folder):
for file in files:
if file not in prune:
if file.endswith(".f90") or file.endswith(".F90") or file.endswith(".dat") or file.endswith(".npy"):
if file.endswith((".f90", ".F90", ".dat", ".npy", ".c")):
shutil.copy2(os.path.join(root, file), 'stdlib-fpm'+os.sep+folder+os.sep+file)
recursive_copy('src')
recursive_copy('test')
Expand Down Expand Up @@ -162,4 +162,4 @@ def fpm_build(args,unknown):
#==========================================
# build using fpm
if args.build:
fpm_build(args,unknown)
fpm_build(args,unknown)
1 change: 1 addition & 0 deletions doc/specs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ This is an index/directory of the specifications (specs) for each new module/fea
- [string\_type](./stdlib_string_type.html) - Basic string support
- [stringlist_type](./stdlib_stringlist_type.html) - 1-Dimensional list of strings
- [strings](./stdlib_strings.html) - String handling and manipulation routines
- [system](./stdlib_system.html) - OS and sub-processing routines
- [version](./stdlib_version.html) - Version information

## Released/Stable Features & Modules
Expand Down
74 changes: 74 additions & 0 deletions doc/specs/stdlib_strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,52 @@ The result is of the same type as `string`.
{!example/strings/example_zfill.f90!}
```

<!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
### `join`

#### Description

Joins an array of strings into a single string. This function concatenates the strings from the input array,
inserting a separator between each string (default: space). A user-defined separator may be provided, The resulting string is returned.


#### Syntax

`cmd = ` [[stdlib_strings(module):join(interface)]] ` (strings, separator)`

#### Status

Experimental

#### Class

Pure function

#### Argument

- `strings`: Array of strings (either `type(string_type)` or `character(len=*)`).
This argument is `intent(in)`. It is an array of strings that will be concatenated together.
- `separator`: Character scalar (optional).
This argument is `intent(in)`. It specifies the separator to be used between the strings. If not provided, the default separator (a space) is used.

#### Result value

The result is of the same type as the elements of `strings` (`type(string_type)` or `character(len=:), allocatable`).

#### Example

```fortran
! Example usage:
program test_join
type(string_type) :: result
type(string_type), dimension(3) :: words = [string_type('hello'), string_type('world'), string_type('fortran')]
result = join_string(words, ', ') ! Joins with comma and space
print *, result ! Output: "hello, world, fortran"
end program test_join
```

<!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->

### `to_string`

#### Description
Expand Down Expand Up @@ -498,3 +542,33 @@ The result is an `allocatable` length `character` scalar with up to `128` cached
```fortran
{!example/strings/example_to_string.f90!}
```

<!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
### `to_c_string`

#### Description

Convert a Fortran character string to a C character array.
This function converts a Fortran string into a C-style string, ensuring proper null-termination for use in C functions or libraries.

#### Syntax

`cstr = ` [[stdlib_strings(module):to_c_string(function)]] ` (value)`

#### Status

Experimental

#### Class

Pure function.

#### Argument

- `value`: Shall be a `character(len=*)` string.
This is an `intent(in)` argument.
The Fortran string that will be converted to a C character array.

#### Result value

The result is a `character(kind=c_char)` array with a dimension of `len(value) + 1` to accommodate the null terminator.
Loading
Loading