Skip to content

Commit 6a1945f

Browse files
authored
Merge branch 'master' into master
2 parents 7f91f1d + bc37bcc commit 6a1945f

31 files changed

+4732
-87
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
- name: Test manual makefiles
9191
if: contains(matrix.os, 'ubuntu') && contains(matrix.gcc_v, '10')
9292
run: |
93-
make -f Makefile.manual FYPPFLAGS="-DMAXRANK=4"
93+
make -f Makefile.manual FYPPFLAGS="-DMAXRANK=4" -j
9494
make -f Makefile.manual test
9595
make -f Makefile.manual clean
9696

.github/workflows/ci_windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
mingw-w64-${{ matrix.arch }}-gcc-fortran
7171
mingw-w64-${{ matrix.arch }}-python
7272
mingw-w64-${{ matrix.arch }}-python-pip
73+
mingw-w64-${{ matrix.arch }}-python-setuptools
7374
mingw-w64-${{ matrix.arch }}-cmake
7475
mingw-w64-${{ matrix.arch }}-ninja
7576

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
cmake_minimum_required(VERSION 3.14.0)
2-
project(fortran_stdlib Fortran)
2+
project(fortran_stdlib
3+
LANGUAGES Fortran
4+
VERSION 0
5+
DESCRIPTION "Community driven and agreed upon de facto standard library for Fortran"
6+
)
37
enable_testing()
48

59
# Follow GNU conventions for installation directories
610
include(GNUInstallDirs)
711

812
include(${PROJECT_SOURCE_DIR}/cmake/stdlib.cmake)
913

14+
# --- CMake specific configuration and package data export
15+
add_subdirectory(config)
16+
1017
# --- compiler options
1118
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
1219
add_compile_options(-fimplicit-none)

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
[![Actions Status](https://github.com/fortran-lang/stdlib/workflows/CI/badge.svg)](https://github.com/fortran-lang/stdlib/actions)
44
[![Actions Status](https://github.com/fortran-lang/stdlib/workflows/CI_windows/badge.svg)](https://github.com/fortran-lang/stdlib/actions)
55

6+
* [Goals and Motivation](#goals-and-motivation)
7+
* [Scope](#scope)
8+
* [Getting started](#getting-started)
9+
- [Get the code](#get-the-code)
10+
- [Requirements](#requirements)
11+
- [Supported compilers](#supported-compilers)
12+
- [Build with CMake](#build-with-cmake)
13+
- [Build with make](#build-with-make)
14+
* [Using stdlib in your project](#using-stdlib-in-your-project)
15+
* [Documentation](#documentation)
16+
* [Contributing](#contributing)
17+
* [Links](#links)
618

719
## Goals and Motivation
820

@@ -82,6 +94,12 @@ GCC Fortran (MSYS) | 10 | Windows Server 2019 | x86_64
8294
GCC Fortran (MinGW) | 10 | Windows Server 2019 | x86_64, i686
8395
Intel oneAPI classic | 2021.1 | Ubuntu 20.04 | x86_64
8496

97+
The following combinations are known to work, but they are not tested in the CI:
98+
99+
Name | Version | Platform | Architecture
100+
--- | --- | --- | ---
101+
GCC Fortran (MinGW) | 8.4.0, 9.3.0, 10.2.0 | Windows 10 | x86_64, i686
102+
85103
We try to test as many available compilers and platforms as possible.
86104
A list of tested compilers which are currently not working and the respective issue are listed below.
87105

@@ -132,7 +150,7 @@ To test your build, run the test suite after the build has finished with
132150
cmake --build build --target test
133151
```
134152

135-
Please report failing tests on our [issue tracker](https://github.com/fortran-lang/stdlib/issues/new/choose) including details on the compiler used, the operating system and platform architecture.
153+
Please report failing tests on our [issue tracker](https://github.com/fortran-lang/stdlib/issues/new/choose) including details of the compiler used, the operating system and platform architecture.
136154

137155
To install the project to the declared prefix run
138156

@@ -158,6 +176,36 @@ make -f Makefile.manual FYPPFLAGS=-DMAXRANK=4
158176
```
159177

160178

179+
180+
## Using stdlib in your project
181+
182+
The stdlib project exports CMake package files and pkg-config files to make stdlib usable for other projects.
183+
The package files are located in the library directory in the installation prefix.
184+
185+
For CMake builds of stdlib you can find a local installation with
186+
187+
```cmake
188+
find_package(fortran_stdlib REQUIRED)
189+
...
190+
target_link_libraries(
191+
${PROJECT_NAME}
192+
PRIVATE
193+
fortran_stdlib::fortran_stdlib
194+
)
195+
```
196+
197+
To make the installed stdlib project discoverable add the stdlib directory to the ``CMAKE_PREFIX_PATH``.
198+
The usual install localtion of the package files is ``$PREFIX/lib/cmake/fortran_stdlib``.
199+
200+
For non-CMake build systems (like make) you can use the exported pkg-config file by setting ``PKG_CONFIG_PATH`` to include the directory containing the exported pc-file.
201+
The usual install location of the pc-file is ``$PREFIX/lib/pkgconfig``.
202+
In make you can obtain the required compile and link arguments with
203+
204+
```make
205+
STDLIB_CFLAGS := $(shell pkg-config --cflags fortran_stdlib)
206+
STDLIB_LIBS := $(shell pkg-config --libs fortran_stdlib)
207+
```
208+
161209
## Documentation
162210

163211
Documentation is a work in progress (see issue [#4](https://github.com/fortran-lang/stdlib/issues/4)) but already available at [stdlib.fortran-lang.org](https://stdlib.fortran-lang.org).

STYLE_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ focus on the semantics of the proposed changes rather than style and formatting.
4747
<!-- ATTENTION! This section includes intentional trailing whitespace to get decent formatting with GFM and Python Markdown. -->
4848

4949
* Always specify `intent` for dummy arguments.
50-
* Don't use `dimension` attribute to declare arrays because it is less verbose.
50+
* Don't use `dimension` attribute to declare arrays because it is more verbose.
5151
Use this:
5252
```
5353
real, allocatable :: a(:), b(:,:)

config/CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-Identifier: MIT
2+
3+
# Export a pkg-config file
4+
configure_file(
5+
"${CMAKE_CURRENT_SOURCE_DIR}/template.pc"
6+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
7+
@ONLY
8+
)
9+
install(
10+
FILES
11+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
12+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
13+
)
14+
15+
# Export CMake package file
16+
include(CMakePackageConfigHelpers)
17+
configure_package_config_file(
18+
"${CMAKE_CURRENT_SOURCE_DIR}/template.cmake"
19+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
20+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
21+
)
22+
if(BUILD_SHARED_LIBS OR PROJECT_VERSION_MAJOR EQUAL 0)
23+
# Due to the uncertain ABI compatibility of Fortran shared libraries
24+
# limit compatibility for dynamic linking to same minor version.
25+
set(COMPATIBILITY SameMinorVersion)
26+
else()
27+
# Require API compatibility via semantic versioning for static linking.
28+
set(COMPATIBILITY SameMajorVersion)
29+
endif()
30+
write_basic_package_version_file(
31+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
32+
VERSION "${PROJECT_VERSION}"
33+
COMPATIBILITY ${COMPATIBILITY}
34+
)
35+
install(
36+
FILES
37+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
38+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
39+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
40+
)

config/template.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@PACKAGE_INIT@
2+
3+
if(NOT TARGET "@PROJECT_NAME@::@PROJECT_NAME@")
4+
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
5+
endif()

config/template.pc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
3+
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
4+
5+
Name: @PROJECT_NAME@
6+
Description: @PROJECT_DESCRIPTION@
7+
Version: @PROJECT_VERSION@
8+
Libs: -L${libdir} -l@PROJECT_NAME@
9+
Cflags: -I${includedir}

doc/specs/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This is and index/directory of the specifications (specs) for each new module/fe
1111

1212
## Experimental Features & Modules
1313

14+
- [ascii](./stdlib_ascii.html) - Procedures for handling ASCII characters
1415
- [bitsets](./stdlib_bitsets.html) - Bitset data types and procedures
1516
- [error](./stdlib_error.html) - Catching and handling errors
1617
- [IO](./stdlib_io.html) - Input/output helper & convenience
@@ -19,10 +20,11 @@ This is and index/directory of the specifications (specs) for each new module/fe
1920
- [optval](./stdlib_optval.html) - Fallback value for optional arguments
2021
- [quadrature](./stdlib_quadrature.html) - Numerical integration
2122
- [stats](./stdlib_stats.html) - Descriptive Statistics
23+
- [stats_distribution_PRNG](./stdlib_stats_distribution_PRNG.html) - Probability Distributions random number generator
24+
- [string\_type](./stdlib_string_type.html) - Basic string support
2225

2326
## Missing specs
2427

25-
- [ascii](https://github.com/fortran-lang/stdlib/blob/master/src/stdlib_ascii.f90)
2628
- [kinds](https://github.com/fortran-lang/stdlib/blob/master/src/stdlib_kinds.f90)
2729

2830
## Released/Stable Features & Modules

doc/specs/stdlib_ascii.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
---
2+
title: ASCII
3+
---
4+
5+
# The `stdlib_ascii` module
6+
7+
[TOC]
8+
9+
## Introduction
10+
11+
The `stdlib_ascii` module provides procedures for handling and manipulating
12+
intrinsic character variables and constants.
13+
14+
15+
## Constants provided by `stdlib_ascii`
16+
17+
@note Specification of constants is currently incomplete.
18+
19+
20+
## Specification of the `stdlib_ascii` procedures
21+
22+
@note Specification of procedures is currently incomplete.
23+
24+
25+
### `to_lower`
26+
27+
#### Status
28+
29+
Experimental
30+
31+
#### Description
32+
33+
Converts input character variable to all lowercase.
34+
35+
#### Syntax
36+
37+
`res = [[stdlib_ascii(module):to_lower(function)]] (string)`
38+
39+
#### Class
40+
41+
Pure function.
42+
43+
#### Argument
44+
45+
`string`: shall be an intrinsic character type. It is an `intent(in)` argument.
46+
47+
#### Result value
48+
49+
The result is an intrinsic character type of the same length as `string`.
50+
51+
#### Example
52+
53+
```fortran
54+
program demo_to_lower
55+
use stdlib_ascii, only : to_lower
56+
implicit none
57+
print'(a)', to_lower("HELLo!") ! returns "hello!"
58+
end program demo_to_lower
59+
```
60+
61+
### `to_upper`
62+
63+
#### Status
64+
65+
Experimental
66+
67+
#### Description
68+
69+
Converts input character variable to all uppercase.
70+
71+
#### Syntax
72+
73+
`res = [[stdlib_ascii(module):to_upper(function)]] (string)`
74+
75+
#### Class
76+
77+
Pure function.
78+
79+
#### Argument
80+
81+
`string`: shall be an intrinsic character type. It is an `intent(in)` argument.
82+
83+
#### Result value
84+
85+
The result is an intrinsic character type of the same length as `string`.
86+
87+
#### Example
88+
89+
```fortran
90+
program demo_to_upper
91+
use stdlib_ascii, only : to_upper
92+
implicit none
93+
print'(a)', to_upper("hello!") ! returns "HELLO!"
94+
end program demo_to_upper
95+
```
96+
97+
### `to_title`
98+
99+
#### Status
100+
101+
Experimental
102+
103+
#### Description
104+
105+
Returns a capitalized version of an input character variable.
106+
The first alphabetical character is transformed to uppercase unless it follows a numeral.
107+
The rest of the character sequence is transformed to lowercase.
108+
109+
#### Syntax
110+
111+
`res = [[stdlib_ascii(module):to_title(function)]] (string)`
112+
113+
#### Class
114+
115+
Pure function.
116+
117+
#### Argument
118+
119+
`string`: shall be an intrinsic character type. It is an `intent(in)` argument.
120+
121+
#### Result value
122+
123+
The result is an intrinsic character type of the same length as `string`.
124+
125+
#### Example
126+
127+
```fortran
128+
program demo_to_title
129+
use stdlib_ascii, only : to_title
130+
implicit none
131+
print*, to_title("hello!") ! returns "Hello!"
132+
print*, to_title("'enquoted'") ! returns "'Enquoted'"
133+
print*, to_title("1st") ! returns "1st"
134+
end program demo_to_title
135+
```
136+
137+
### `reverse`
138+
139+
#### Status
140+
141+
Experimental
142+
143+
#### Description
144+
145+
Reverses the order of all characters in the input character type.
146+
147+
#### Syntax
148+
149+
`res = [[stdlib_ascii(module):reverse(function)]] (string)`
150+
151+
#### Class
152+
153+
Pure function.
154+
155+
#### Argument
156+
157+
`string`: shall be an intrinsic character type. It is an `intent(in)` argument.
158+
159+
#### Result value
160+
161+
The result is an intrinsic character type of the same length as `string`.
162+
163+
#### Example
164+
165+
```fortran
166+
program demo_reverse
167+
use stdlib_ascii, only : reverse
168+
implicit none
169+
print'(a)', reverse("Hello, World!") ! returns "!dlroW ,olleH"
170+
end program demo_reverse
171+
```

0 commit comments

Comments
 (0)