Skip to content

Commit 259360f

Browse files
authored
Merge branch 'fortran-lang:master' into activations
2 parents 1c3fbda + 69eaa20 commit 259360f

File tree

71 files changed

+4989
-1004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4989
-1004
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14.0)
44
set(CMAKE_USER_MAKE_RULES_OVERRIDE ${CMAKE_CURRENT_SOURCE_DIR}/config/DefaultFlags.cmake)
55

66
project(fortran_stdlib
7-
LANGUAGES Fortran
7+
LANGUAGES Fortran C
88
DESCRIPTION "Community driven and agreed upon de facto standard library for Fortran"
99
)
1010

config/fypp_deployment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def recursive_copy(folder):
105105
for root, _, files in os.walk(folder):
106106
for file in files:
107107
if file not in prune:
108-
if file.endswith(".f90") or file.endswith(".F90") or file.endswith(".dat") or file.endswith(".npy"):
108+
if file.endswith((".f90", ".F90", ".dat", ".npy", ".c")):
109109
shutil.copy2(os.path.join(root, file), base_folder+os.sep+folder+os.sep+file)
110110
recursive_copy('src')
111111
recursive_copy('test')

doc/specs/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This is an index/directory of the specifications (specs) for each new module/fea
1717
- [constants](./stdlib_constants.html) - Constants
1818
- [bitsets](./stdlib_bitsets.html) - Bitset data types and procedures
1919
- [error](./stdlib_error.html) - Catching and handling errors
20+
- [state_type](./stdlib_error_state_type.html) - General state and error handling
2021
- [hash](./stdlib_hash_procedures.html) - Hashing integer
2122
vectors or character strings
2223
- [hashmaps](./stdlib_hashmaps.html) - Hash maps/tables
@@ -37,6 +38,7 @@ This is an index/directory of the specifications (specs) for each new module/fea
3738
- [string\_type](./stdlib_string_type.html) - Basic string support
3839
- [stringlist_type](./stdlib_stringlist_type.html) - 1-Dimensional list of strings
3940
- [strings](./stdlib_strings.html) - String handling and manipulation routines
41+
- [system](./stdlib_system.html) - OS and sub-processing routines
4042
- [version](./stdlib_version.html) - Version information
4143

4244
## Released/Stable Features & Modules

doc/specs/stdlib_error_state_type.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: state_type
3+
---
4+
5+
# State and Error Handling Derived Type
6+
7+
[TOC]
8+
9+
## Introduction
10+
11+
The `stdlib_error` module provides a derived type holding information on the state of operations within the standard library and procedures for expert control of workflows.
12+
An optional `state_type` variable to hold such information is provided as a form of expert API.
13+
If the user does not require state information but fatal errors are encountered during execution, the program will undergo a hard stop.
14+
Instead, if the state argument is present, the program will never stop but will return detailed error information into the state handler.
15+
16+
## Derived types provided
17+
18+
<!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
19+
### The `state_type` derived type
20+
21+
The `state_type` is defined as a derived type containing an integer error flag and fixed-size character strings to store an error message and the location of the error state change.
22+
Fixed-size string storage was chosen to facilitate the compiler's memory allocation and ultimately ensure maximum computational performance.
23+
24+
A similarly named generic interface, `state_type`, is provided to allow the developer to create diagnostic messages and raise error flags easily.
25+
The call starts with an error flag or the location of the event and is followed by an arbitrary list of `integer`, `real`, `complex`, or `character` variables.
26+
Numeric variables may be provided as either scalars or rank-1 (array) inputs.
27+
28+
#### Type-bound procedures
29+
30+
The following convenience type-bound procedures are provided:
31+
- `print()` returns an allocatable character string containing state location, message, and error flag;
32+
- `print_message()` returns an allocatable character string containing the state message;
33+
- `ok()` returns a `logical` flag that is `.true.` in case of successful state (`flag==STDLIB_SUCCESS`);
34+
- `error()` returns a `logical` flag that is `.true.` in case of an error state (`flag/=STDLIB_SUCCESS`).
35+
36+
#### Status
37+
38+
Experimental
39+
40+
#### Example
41+
42+
```fortran
43+
{!example/error/example_error_state1.f90!}
44+
```
45+
46+
## Error flags provided
47+
48+
The module provides the following state flags:
49+
- `STDLIB_SUCCESS`: Successful execution
50+
- `STDLIB_VALUE_ERROR`: Numerical errors (such as infinity, not-a-number, range bounds) are encountered.
51+
- `STDLIB_LINALG_ERROR`: Linear Algebra errors are encountered, such as non-converging iterations, impossible operations, etc.
52+
- `STDLIB_INTERNAL_ERROR`: Provided as a developer safeguard for internal errors that should never occur.
53+
- `STDLIB_IO_ERROR`: Input/Output-related errors, such as file reading/writing failures.
54+
- `STDLIB_FS_ERROR`: File system-related errors, such as directory access issues.
55+
56+
## Comparison operators provided
57+
58+
The module provides overloaded comparison operators for all comparisons of a `state_type` variable with an integer error flag: `<`, `<=`, `==`, `>=`, `>`, `/=`.
59+

0 commit comments

Comments
 (0)