Skip to content

Commit 53874c9

Browse files
authored
Merge branch 'master' into add_close
2 parents adfb820 + 7758a1d commit 53874c9

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

+3313
-177
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!--
2+
Thank you for contributing to stdlib.
3+
To help us get your pull request merged more quickly, please consider reviewing any of the already open pull requests.
4+
-->

.github/workflows/CI.yml

+23-15
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@ jobs:
2121
matrix:
2222
os: [ubuntu-latest, macos-latest]
2323
gcc_v: [9, 10, 11] # Version of GFortran we want to use.
24+
build: [cmake]
25+
include:
26+
- os: ubuntu-latest
27+
gcc_v: 10
28+
build: cmake-inline
29+
- os: ubuntu-latest
30+
gcc_v: 10
31+
build: make
2432
env:
2533
FC: gfortran-${{ matrix.gcc_v }}
2634
GCC_V: ${{ matrix.gcc_v }}
35+
BUILD_DIR: ${{ matrix.build == 'cmake' && 'build' || '.' }}
2736

2837
steps:
2938
- name: Checkout code
@@ -58,39 +67,38 @@ jobs:
5867
brew link gcc@${GCC_V}
5968
6069
- name: Configure with CMake
70+
if: ${{ contains(matrix.build, 'cmake') }}
6171
run: >-
6272
cmake -Wdev
6373
-DCMAKE_BUILD_TYPE=Release
6474
-DCMAKE_MAXIMUM_RANK:String=4
6575
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
66-
-S . -B build
76+
-S . -B ${{ env.BUILD_DIR }}
6777
6878
- name: Build and compile
69-
run: cmake --build build --parallel
79+
if: ${{ contains(matrix.build, 'cmake') }}
80+
run: cmake --build ${{ env.BUILD_DIR }} --parallel
7081

7182
- name: catch build fail
72-
run: cmake --build build --verbose --parallel 1
73-
if: failure()
83+
run: cmake --build ${{ env.BUILD_DIR }} --verbose --parallel 1
84+
if: ${{ failure() && contains(matrix.build, 'cmake') }}
7485

7586
- name: test
76-
run: ctest --test-dir build --parallel --output-on-failure
87+
if: ${{ contains(matrix.build, 'cmake') }}
88+
run: ctest --test-dir ${{ env.BUILD_DIR }} --parallel --output-on-failure
7789

7890
- name: Install project
79-
run: cmake --install build
80-
81-
- name: Test in-tree builds
82-
if: contains( matrix.gcc_v, '10') # Only test one compiler on each platform
83-
run: |
84-
cmake -DCMAKE_MAXIMUM_RANK=4 .
85-
cmake --build .
86-
cmake --build . --target test
91+
if: ${{ contains(matrix.build, 'cmake') }}
92+
run: cmake --install ${{ env.BUILD_DIR }}
8793

8894
- name: Test manual makefiles
89-
if: contains(matrix.os, 'ubuntu') && contains(matrix.gcc_v, '10')
95+
if: ${{ matrix.build == 'make' }}
9096
run: |
91-
make -f Makefile.manual FYPPFLAGS="-DMAXRANK=4" -j
97+
make -f Makefile.manual -j
9298
make -f Makefile.manual test
9399
make -f Makefile.manual clean
100+
env:
101+
FYPPFLAGS: "-DMAXRANK=4"
94102

95103
intel-build:
96104
runs-on: ${{ matrix.os }}

API-doc-FORD-file.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ media_dir: doc/media
99
fpp_extensions: fypp
1010
preprocess: true
1111
macro: MAXRANK=3
12+
PROJECT_VERSION_MAJOR=0
13+
PROJECT_VERSION_MINOR=0
14+
PROJECT_VERSION_PATCH=0
1215
preprocessor: fypp
1316
display: public
1417
protected

CHANGELOG.md

+25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Unreleased
22

3+
Features available from the latest git source
4+
5+
- new module `stdlib_distribution_uniform`
6+
[#272](https://github.com/fortran-lang/stdlib/pull/272)
7+
- new module `stdlib_selection`
8+
[#500](https://github.com/fortran-lang/stdlib/pull/500)
9+
- new procedures `select`, `arg_select`
10+
- new module `stdlib_version`
11+
[#579](https://github.com/fortran-lang/stdlib/pull/579)
12+
- new procedure `get_stdlib_version`
13+
- new module `stdlib_io_npy`
14+
[#581](https://github.com/fortran-lang/stdlib/pull/581)
15+
- new procedures `save_npy`, `load_npy`
16+
17+
Changes to existing modules
18+
19+
- change in module `stdlib_math`
20+
- `linspace` and `logspace` made pure
21+
[#549](https://github.com/fortran-lang/stdlib/pull/549)
22+
- change in module `stdlib_string_type`
23+
- `move` procedure made *pure*/*elemental*
24+
[#562](https://github.com/fortran-lang/stdlib/pull/562)
25+
- support for quadruple precision made optional
26+
[#565](https://github.com/fortran-lang/stdlib/pull/565)
27+
328

429
# Version 0.1.0
530

CMakeLists.txt

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
cmake_minimum_required(VERSION 3.14.0)
22
project(fortran_stdlib
33
LANGUAGES Fortran
4-
VERSION 0.1.0
54
DESCRIPTION "Community driven and agreed upon de facto standard library for Fortran"
65
)
6+
7+
# Read version from file
8+
file(STRINGS "${PROJECT_SOURCE_DIR}/VERSION" PROJECT_VERSION)
9+
string(REPLACE "." ";" VERSION_LIST ${PROJECT_VERSION})
10+
list(GET VERSION_LIST 0 PROJECT_VERSION_MAJOR)
11+
list(GET VERSION_LIST 1 PROJECT_VERSION_MINOR)
12+
list(GET VERSION_LIST 2 PROJECT_VERSION_PATCH)
13+
unset(VERSION_LIST)
14+
715
enable_testing()
816

917
# Follow GNU conventions for installation directories
@@ -24,7 +32,6 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
2432
add_compile_options(-Wall)
2533
add_compile_options(-Wextra)
2634
add_compile_options(-Wimplicit-procedure)
27-
add_compile_options(-Wconversion-extra)
2835
# -pedantic-errors triggers a false positive for optional arguments of elemental functions,
2936
# see test_optval and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95446
3037
if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 11.0)
@@ -55,7 +62,7 @@ endif()
5562
# --- find preprocessor
5663
find_program(FYPP fypp)
5764
if(NOT FYPP)
58-
message(FATAL_ERROR "Preprocessor fypp not found!")
65+
message(FATAL_ERROR "Preprocessor fypp not found! Please install fypp following the instructions in https://fypp.readthedocs.io/en/stable/fypp.html#installing")
5966
endif()
6067

6168
add_subdirectory(src)

CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ You are welcome to propose changes to the workflow by
8989
* Smaller PRs are better than large PRs, and will lead to a shorter review and
9090
merge cycle.
9191
* Add tests for your feature or bug fix to be sure that it stays functional and useful.
92+
* Include new features and changes in the
93+
[CHANGELOG](https://github.com/fortran-lang/stdlib/blob/master/CHANGELOG.md)
9294
* Be open to constructive criticism and requests for improving your code.
9395
* Again, please follow the
9496
[Fortran stdlib style guide](https://github.com/fortran-lang/stdlib/blob/master/STYLE_GUIDE.md).

Makefile.manual

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ FC ?= gfortran
44
FFLAGS ?= -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all
55
FYPPFLAGS ?=
66

7+
VERSION := $(subst ., ,$(file < VERSION))
8+
FYPPFLAGS += \
9+
-DPROJECT_VERSION_MAJOR=$(word 1,$(VERSION)) \
10+
-DPROJECT_VERSION_MINOR=$(word 2,$(VERSION)) \
11+
-DPROJECT_VERSION_PATCH=$(word 3,$(VERSION))
12+
713
export FC
814
export FFLAGS
915
export FYPPFLAGS

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

ci/fpm-deployment.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ fypp="${FYPP:-$(which fypp)}"
1212
fyflags="${FYFLAGS:--DMAXRANK=4}"
1313

1414
# Number of parallel jobs for preprocessing
15-
njob="$(nproc)"
15+
if [ $(uname) = "Darwin" ]; then
16+
njob="$(sysctl -n hw.ncpu)"
17+
else
18+
njob="$(nproc)"
19+
fi
1620

1721
# Additional files to include
1822
include=(
1923
"ci/fpm.toml"
2024
"LICENSE"
25+
"VERSION"
2126
)
2227

2328
# Files to remove from collection
@@ -28,6 +33,11 @@ prune=(
2833
"$destdir/src/f18estop.f90"
2934
)
3035

36+
major=$(cut -d. -f1 VERSION)
37+
minor=$(cut -d. -f2 VERSION)
38+
patch=$(cut -d. -f3 VERSION)
39+
fyflags="${fyflags} -DPROJECT_VERSION_MAJOR=${major} -DPROJECT_VERSION_MINOR=${minor} -DPROJECT_VERSION_PATCH=${patch}"
40+
3141
mkdir -p "$destdir/src" "$destdir/test"
3242

3343
# Preprocess stdlib sources

ci/fpm.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name = "stdlib"
2-
version = "0.1.0"
2+
version = "VERSION"
33
license = "MIT"
44
author = "stdlib contributors"
55
maintainer = "@fortran-lang/stdlib"
66
copyright = "2019-2021 stdlib contributors"
77

88
[dev-dependencies]
99
test-drive.git = "https://github.com/fortran-lang/test-drive"
10+
test-drive.tag = "v0.4.0"

config/CMakeLists.txt

+18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ endif()
1313
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1414
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
1515

16+
# Check for available features
17+
# Note: users can overwrite the automatic check by setting the value at configure time
18+
include(CheckFortranSourceRuns)
19+
if (NOT DEFINED WITH_QP)
20+
check_fortran_source_runs(
21+
"if (selected_real_kind(33) == -1) stop 1; end"
22+
WITH_QP
23+
)
24+
set(WITH_QP ${WITH_QP} PARENT_SCOPE)
25+
endif()
26+
if (NOT DEFINED WITH_XDP)
27+
check_fortran_source_runs(
28+
"if (any(selected_real_kind(18) == [-1, selected_real_kind(33)])) stop 1; end"
29+
WITH_XDP
30+
)
31+
set(WITH_XDP ${WITH_XDP} PARENT_SCOPE)
32+
endif()
33+
1634
# Export a pkg-config file
1735
configure_file(
1836
"${CMAKE_CURRENT_SOURCE_DIR}/template.pc"

config/cmake/Findtest-drive.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ foreach(method ${${_pkg}_FIND_METHOD})
136136
FetchContent_Declare(
137137
"${_lib}"
138138
GIT_REPOSITORY "${_url}"
139-
GIT_TAG "HEAD"
139+
GIT_TAG "v0.4.0"
140140
)
141141
FetchContent_MakeAvailable("${_lib}")
142142

config/template.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@PACKAGE_INIT@
22

3+
set("@PROJECT_NAME@_WITH_QP" @WITH_QP@)
4+
set("@PROJECT_NAME@_WITH_XDP" @WITH_XDP@)
5+
36
if(NOT TARGET "@PROJECT_NAME@::@PROJECT_NAME@")
47
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
58
endif()

doc/specs/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This is and index/directory of the specifications (specs) for each new module/fe
2828
- [string\_type](./stdlib_string_type.html) - Basic string support
2929
- [strings](./stdlib_strings.html) - String handling and manipulation routines
3030
- [stringlist_type](./stdlib_stringlist_type.html) - 1-Dimensional list of strings
31+
- [version](./stdlib_version.html) - Version information
3132

3233
## Released/Stable Features & Modules
3334

doc/specs/stdlib_io.md

+94-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ program demo_loadtxt
3636
use stdlib_io, only: loadtxt
3737
implicit none
3838
real, allocatable :: x(:,:)
39-
call loadtxt('example.dat', x)
39+
call loadtxt('example.dat', x)
4040
end program demo_loadtxt
4141
```
4242

@@ -128,6 +128,98 @@ program demo_savetxt
128128
use stdlib_io, only: savetxt
129129
implicit none
130130
real :: x(3,2) = 1
131-
call savetxt('example.dat', x)
131+
call savetxt('example.dat', x)
132132
end program demo_savetxt
133133
```
134+
135+
136+
## `load_npy`
137+
138+
### Status
139+
140+
Experimental
141+
142+
### Description
143+
144+
Loads an `array` from a npy formatted binary file.
145+
146+
### Syntax
147+
148+
`call [[stdlib_io_npy(module):load_npy(interface)]](filename, array[, iostat][, iomsg])`
149+
150+
### Arguments
151+
152+
`filename`: Shall be a character expression containing the file name from which to load the `array`.
153+
This argument is `intent(in)`.
154+
155+
`array`: Shall be an allocatable array of any rank of type `real`, `complex` or `integer`.
156+
This argument is `intent(out)`.
157+
158+
`iostat`: Default integer, contains status of loading to file, zero in case of success.
159+
It is an optional argument, in case not present the program will halt for non-zero status.
160+
This argument is `intent(out)`.
161+
162+
`iomsg`: Deferred length character value, contains error message in case `iostat` is non-zero.
163+
It is an optional argument, error message will be dropped if not present.
164+
This argument is `intent(out)`.
165+
166+
### Return value
167+
168+
Returns an allocated `array` with the content of `filename` in case of success.
169+
170+
### Example
171+
172+
```fortran
173+
program demo_loadnpy
174+
use stdlib_io_npy, only: load_npy
175+
implicit none
176+
real, allocatable :: x(:,:)
177+
call loadtxt('example.npy', x)
178+
end program demo_loadnpy
179+
```
180+
181+
182+
## `save_npy`
183+
184+
### Status
185+
186+
Experimental
187+
188+
### Description
189+
190+
Saves an `array` into a npy formatted binary file.
191+
192+
### Syntax
193+
194+
`call [[stdlib_io_npy(module):save_npy(interface)]](filename, array[, iostat][, iomsg])`
195+
196+
### Arguments
197+
198+
`filename`: Shall be a character expression containing the name of the file that will contain the `array`.
199+
This argument is `intent(in)`.
200+
201+
`array`: Shall be an array of any rank of type `real`, `complex` or `integer`.
202+
This argument is `intent(in)`.
203+
204+
`iostat`: Default integer, contains status of saving to file, zero in case of success.
205+
It is an optional argument, in case not present the program will halt for non-zero status.
206+
This argument is `intent(out)`.
207+
208+
`iomsg`: Deferred length character value, contains error message in case `iostat` is non-zero.
209+
It is an optional argument, error message will be dropped if not present.
210+
This argument is `intent(out)`.
211+
212+
### Output
213+
214+
Provides a npy file called `filename` that contains the rank-2 `array`.
215+
216+
### Example
217+
218+
```fortran
219+
program demo_savenpy
220+
use stdlib_io_npy, only: save_npy
221+
implicit none
222+
real :: x(3,2) = 1
223+
call save_npy('example.npy', x)
224+
end program demo_savenpy
225+
```

0 commit comments

Comments
 (0)