Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit abb4a3c

Browse files
authoredJan 3, 2020
Merge branch 'master' into master
2 parents ec6d900 + 84c75fb commit abb4a3c

25 files changed

+358
-114
lines changed
 

‎.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ root = true
1010

1111
[*.{f90,F90}]
1212
indent_style = space
13-
indent_size = 2
13+
indent_size = 4
1414
trim_trailing_whitespace = true
1515
max_line_length = 132
1616
insert_final_newline = true

‎.github/workflows/main.yml renamed to ‎.github/workflows/CI.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,10 @@ jobs:
6666
cmake .
6767
cmake --build .
6868
cmake --build . --target test
69+
70+
- name: Test manual makefiles
71+
if: contains(matrix.os, 'ubuntu') && contains(matrix.gcc_v, '9')
72+
run: |
73+
make -f Makefile.manual
74+
make -f Makefile.manual test
75+
make -f Makefile.manual clean

‎.github/workflows/PR-review.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: PR-Review
2+
on: [pull_request]
3+
jobs:
4+
misspell:
5+
name: review-dog / misspell
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Check out code.
9+
uses: actions/checkout@v1
10+
- name: misspell
11+
uses: reviewdog/action-misspell@v1
12+
with:
13+
github_token: ${{ secrets.github_token }}
14+
locale: "US"
15+
reporter: github-pr-review
16+
level: warning

‎.github/workflows/ci_windows.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI_windows
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
CI: "ON"
7+
8+
jobs:
9+
Build:
10+
runs-on: windows-latest
11+
strategy:
12+
fail-fast: false
13+
14+
steps:
15+
- uses: actions/checkout@v1
16+
17+
- run: cmake -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -Wdev -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_Fortran_FLAGS_DEBUG="-Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -fbacktrace"
18+
19+
env:
20+
FC: gfortran
21+
CC: gcc
22+
CXX: g++
23+
24+
- name: CMake build
25+
run: cmake --build build --parallel
26+
27+
- run: cmake --build build --verbose --parallel 1
28+
if: failure()
29+
30+
- name: CTest
31+
run: ctest --output-on-failure --parallel -V -LE quadruple_precision
32+
working-directory: build
33+
34+
- uses: actions/upload-artifact@v1
35+
if: failure()
36+
with:
37+
name: WindowsCMakeTestlog
38+
path: build/Testing/Temporary/LastTest.log

‎CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ enable_testing()
55
# this avoids stdlib and projects using stdlib from having to introspect stdlib's directory structure
66
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR})
77

8+
# compiler feature checks
9+
include(CheckFortranSourceCompiles)
10+
check_fortran_source_compiles("error stop i; end" f18errorstop SRC_EXT f90)
11+
812
add_subdirectory(src)

‎Makefile.manual

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# Fortran stdlib Makefile
22

33
FC = gfortran
4-
FCFLAGS=-O0
4+
FFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all
55

6-
.PHONY: all clean
6+
export FC
7+
export FFLAGS
78

8-
all: stdlib tests
9+
.PHONY: all clean test
910

10-
stdlib:
11-
$(MAKE) -f Makefile.manual FC=${FC} FCFLAGS=${FCFLAGS} --directory=src
11+
all:
12+
$(MAKE) -f Makefile.manual --directory=src
13+
$(MAKE) -f Makefile.manual --directory=src/tests
1214

13-
tests: stdlib
14-
$(MAKE) -f Makefile.manual FC=${FC} FCFLAGS=${FCFLAGS} --directory=src/tests
15+
test:
16+
$(MAKE) -f Makefile.manual --directory=src/tests test
17+
@echo
18+
@echo "All tests passed."
1519

1620
clean:
1721
$(MAKE) -f Makefile.manual clean --directory=src

‎README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Fortran Standard Library
22

3+
## Scope
4+
5+
The goal of the Fortran Standard Library is to achieve the following general scope:
6+
7+
* Utilities (containers, strings, files, OS/environment integration, unit
8+
testing & assertions, logging, ...)
9+
* Algorithms (searching and sorting, merging, ...)
10+
* Mathematics (linear algebra, sparse matrices, special functions, fast Fourier
11+
transform, random numbers, statistics, ordinary differential equations,
12+
numerical integration, optimization, ...)
13+
14+
315
## Getting started
416

517
### Get the code

‎STYLE_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This style guide is a living document and proposed changes may be adopted after
2929
By setting and following a convention for indentation and whitespace, code reviews and git-diffs can
3030
focus on the semantics of the proposed changes rather than style and formatting.
3131

32-
* The body of every Fortran construct should be indented by __two (2) spaces__
32+
* The body of every Fortran construct should be indented by __two (4) spaces__
3333
* Line length *should be limited to 80 characters* and __must not exceed 132__
3434
* Please do not use <kbd>Tab</kbd> characters for indentation
3535
* Please remove trailing white space before committing code

‎src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ set(SRC
77

88
add_library(fortran_stdlib ${SRC})
99

10+
if(f18errorstop)
11+
target_sources(fortran_stdlib PRIVATE f18estop.f90)
12+
else()
13+
target_sources(fortran_stdlib PRIVATE f08estop.f90)
14+
endif()
15+
1016
add_subdirectory(tests)
1117

1218
install(TARGETS fortran_stdlib

‎src/Makefile.manual

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1-
OBJS = stdlib_experimental_ascii.o \
2-
stdlib_experimental_error.o \
3-
stdlib_experimental_io.o \
4-
stdlib_experimental_default.o \
1+
SRC = stdlib_experimental_ascii.f90 \
2+
stdlib_experimental_error.f90 \
3+
stdlib_experimental_io.f90 \
4+
stdlib_experimental_default.f90 \
5+
f18estop.f90
6+
7+
LIB = libstdlib.a
58

6-
.PHONY: all clean
7-
.SUFFIXES: .f90 .o
89

9-
all: $(OBJS)
1010

11-
.f90.o:
12-
$(FC) $(FCFLAGS) -c $<
11+
OBJS = $(SRC:.f90=.o)
12+
MODS = $(OBJS:.o=.mod)
13+
SMODS = $(OBJS:.o=*.smod)
14+
15+
.PHONY: all clean
1316

14-
%.o: %.mod
17+
all: $(LIB)
1518

16-
stdlib_experimental_ascii.o: stdlib_experimental_ascii.f90
17-
stdlib_experimental_error.o: stdlib_experimental_error.f90
18-
stdlib_experimental_io.o: stdlib_experimental_io.f90
19-
stdlib_experimental_default.o: stdlib_experimental_default.f90
19+
$(LIB): $(OBJS)
20+
ar rcs $@ $(OBJS)
2021

2122
clean:
22-
$(RM) *.o *.mod
23+
$(RM) $(LIB) $(OBJS) $(MODS) $(SMODS)
24+
25+
%.o: %.f90
26+
$(FC) $(FFLAGS) -c $<
27+
28+
29+
# Fortran module dependencies
30+
f18estop.o: stdlib_experimental_error.o

‎src/f08estop.f90

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
submodule (stdlib_experimental_error) estop
2+
3+
contains
4+
5+
module procedure error_stop
6+
! Aborts the program with nonzero exit code
7+
! this is a fallback for Fortran 2008 error stop (e.g. Intel 19.1/2020 compiler)
8+
!
9+
! The "stop <character>" statement generally has return code 0.
10+
! To allow non-zero return code termination with character message,
11+
! error_stop() uses the statement "error stop", which by default
12+
! has exit code 1 and prints the message to stderr.
13+
! An optional integer return code "code" may be specified.
14+
!
15+
! Example
16+
! -------
17+
!
18+
! call error_stop("Invalid argument")
19+
20+
write(stderr,*) msg
21+
22+
if(present(code)) then
23+
select case (code)
24+
case (1)
25+
error stop 1
26+
case (2)
27+
error stop 2
28+
case (77)
29+
error stop 77
30+
case default
31+
write(stderr,*) 'ERROR: code ',code,' was specified.'
32+
error stop
33+
end select
34+
else
35+
error stop
36+
endif
37+
end procedure
38+
39+
end submodule

‎src/f18estop.f90

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
submodule (stdlib_experimental_error) estop
2+
3+
contains
4+
5+
module procedure error_stop
6+
! Aborts the program with nonzero exit code
7+
!
8+
! The "stop <character>" statement generally has return code 0.
9+
! To allow non-zero return code termination with character message,
10+
! error_stop() uses the statement "error stop", which by default
11+
! has exit code 1 and prints the message to stderr.
12+
! An optional integer return code "code" may be specified.
13+
!
14+
! Example
15+
! -------
16+
!
17+
! call error_stop("Invalid argument")
18+
19+
if(present(code)) then
20+
write(stderr,*) msg
21+
error stop code
22+
else
23+
error stop msg
24+
endif
25+
end procedure
26+
27+
end submodule estop

‎src/stdlib_experimental_error.f90

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
11
module stdlib_experimental_error
2+
use, intrinsic :: iso_fortran_env, only: stderr=>error_unit
23
implicit none
34
private
5+
6+
interface ! f{08,18}estop.f90
7+
module subroutine error_stop(msg, code)
8+
character(*), intent(in) :: msg
9+
integer, intent(in), optional :: code
10+
end subroutine error_stop
11+
end interface
12+
413
public :: assert, error_stop
514

615
contains
716

8-
subroutine assert(condition)
17+
subroutine assert(condition, code)
918
! If condition == .false., it aborts the program.
1019
!
1120
! Arguments
1221
! ---------
1322
!
1423
logical, intent(in) :: condition
24+
integer, intent(in), optional :: code
1525
!
1626
! Example
1727
! -------
1828
!
1929
! call assert(a == 5)
2030

21-
if (.not. condition) call error_stop("Assert failed.")
22-
end subroutine
23-
24-
subroutine error_stop(msg)
25-
! Aborts the program with nonzero exit code
26-
!
27-
! The statement "stop msg" will return 0 exit code when compiled using
28-
! gfortran. error_stop() uses the statement "stop 1" which returns an exit code
29-
! 1 and a print statement to print the message.
30-
!
31-
! Example
32-
! -------
33-
!
34-
! call error_stop("Invalid argument")
35-
36-
character(len=*) :: msg ! Message to print on stdout
37-
print *, msg
38-
stop 1
31+
if (.not. condition) call error_stop("Assert failed.", code)
3932
end subroutine
4033

4134
end module

‎src/tests/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
add_subdirectory(ascii)
22
add_subdirectory(loadtxt)
33

4+
add_executable(test_skip test_skip.f90)
5+
target_link_libraries(test_skip fortran_stdlib)
6+
add_test(NAME AlwaysSkip COMMAND $<TARGET_FILE:test_skip>)
7+
set_tests_properties(AlwaysSkip PROPERTIES SKIP_RETURN_CODE 77)
8+
9+
add_executable(test_fail test_fail.f90)
10+
target_link_libraries(test_fail fortran_stdlib)
11+
add_test(NAME AlwaysFail COMMAND $<TARGET_FILE:test_fail>)
12+
set_tests_properties(AlwaysFail PROPERTIES WILL_FAIL true)

‎src/tests/Makefile.manual

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
.PHONY: all clean
1+
.PHONY: all clean test
22

3-
all: ascii/test_ascii loadtxt/test_loadtxt
4-
5-
ascii/test_ascii:
3+
all:
64
$(MAKE) -f Makefile.manual --directory=ascii
7-
8-
loadtxt/test_loadtxt:
95
$(MAKE) -f Makefile.manual --directory=loadtxt
106

7+
test:
8+
$(MAKE) -f Makefile.manual --directory=ascii test
9+
$(MAKE) -f Makefile.manual --directory=loadtxt test
10+
1111
clean:
1212
$(MAKE) -f Makefile.manual --directory=ascii clean
1313
$(MAKE) -f Makefile.manual --directory=loadtxt clean

‎src/tests/Makefile.manual.test.mk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Common Makefile rules that are included from each test subdirectory's
2+
# Makefile
3+
4+
CPPFLAGS += -I../..
5+
LDFLAGS += -L../.. -lstdlib
6+
7+
OBJS = $(PROGS_SRC:.f90=.o)
8+
PROGS = $(OBJS:.o=)
9+
TESTPROGS = $(PROGS:=TEST)
10+
11+
.PHONY: all clean test $(TESTPROGS)
12+
13+
all: $(PROGS)
14+
15+
test: $(TESTPROGS)
16+
17+
$(TESTPROGS):
18+
./$(@:TEST=)
19+
20+
clean:
21+
$(RM) $(PROGS) $(OBJS) $(CLEAN_FILES)
22+
23+
%.o: %.f90
24+
$(FC) $(FFLAGS) $(CPPFLAGS) -c $<
25+
26+
$(PROGS): %: %.o
27+
$(FC) $(FFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS)

‎src/tests/ascii/Makefile.manual

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
CPPFLAGS = -I../..
2-
OBJS = ../../stdlib_experimental_ascii.o \
3-
../../stdlib_experimental_error.o
1+
PROGS_SRC = test_ascii.f90
42

5-
.PHONY: all clean
6-
.SUFFIXES: .f90 .o
73

8-
all: test_ascii
9-
10-
test_ascii: test_ascii.f90 $(OBJS)
11-
$(FC) $(FCFLAGS) $(CPPFLAGS) $< -o $@ $(OBJS)
12-
13-
%.o: %.mod
14-
15-
clean:
16-
$(RM) test_ascii
17-
$(RM) *.o *.mod
4+
include ../Makefile.manual.test.mk

‎src/tests/loadtxt/CMakeLists.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@ target_link_libraries(test_loadtxt fortran_stdlib)
44
add_executable(test_savetxt test_savetxt.f90)
55
target_link_libraries(test_savetxt fortran_stdlib)
66

7-
add_test(NAME load_text COMMAND $<TARGET_FILE:test_loadtxt> ${CMAKE_CURRENT_BINARY_DIR}
7+
add_executable(test_loadtxt_qp test_loadtxt_qp.f90)
8+
target_link_libraries(test_loadtxt_qp fortran_stdlib)
9+
10+
add_executable(test_savetxt_qp test_savetxt_qp.f90)
11+
target_link_libraries(test_savetxt_qp fortran_stdlib)
12+
13+
add_test(NAME loadtxt COMMAND $<TARGET_FILE:test_loadtxt> ${CMAKE_CURRENT_BINARY_DIR}
14+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
15+
add_test(NAME savetxt COMMAND $<TARGET_FILE:test_savetxt> ${CMAKE_CURRENT_BINARY_DIR}
816
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
9-
add_test(NAME save_text COMMAND $<TARGET_FILE:test_savetxt> ${CMAKE_CURRENT_BINARY_DIR}
17+
add_test(NAME loadtxt_qp COMMAND $<TARGET_FILE:test_loadtxt_qp> ${CMAKE_CURRENT_BINARY_DIR}
1018
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
19+
add_test(NAME savetxt_qp COMMAND $<TARGET_FILE:test_savetxt_qp> ${CMAKE_CURRENT_BINARY_DIR}
20+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
21+
22+
set_tests_properties(loadtxt_qp PROPERTIES LABELS quadruple_precision)
23+
set_tests_properties(savetxt_qp PROPERTIES LABELS quadruple_precision)

‎src/tests/loadtxt/Makefile.manual

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1-
CPPFLAGS = -I../..
2-
OBJS = ../../stdlib_experimental_error.o \
3-
../../stdlib_experimental_io.o
1+
PROGS_SRC = test_loadtxt.f90 \
2+
test_savetxt.f90 \
3+
test_loadtxt_qp.f90 \
4+
test_savetxt_qp.f90
45

5-
.PHONY: all clean
6-
.SUFFIXES: .f90 .o
6+
CLEAN_FILES = tmp.dat tmp_qp.dat
77

8-
all: test_loadtxt test_savetxt
98

10-
test_loadtxt: test_loadtxt.f90 $(OBJS)
11-
$(FC) $(FCFLAGS) $(CPPFLAGS) $< -o $@ $(OBJS)
12-
13-
test_savetxt: test_savetxt.f90 $(OBJS)
14-
$(FC) $(FCFLAGS) $(CPPFLAGS) $< -o $@ $(OBJS)
15-
16-
%.o: %.mod
17-
18-
clean:
19-
$(RM) test_loadtxt test_savetxt
20-
$(RM) *.o *.mod
9+
include ../Makefile.manual.test.mk

‎src/tests/loadtxt/test_loadtxt.f90

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
program test_loadtxt
2-
use iso_fortran_env, only: sp=>real32, dp=>real64 ,qp=>real128
2+
use iso_fortran_env, only: sp=>real32, dp=>real64
33
use stdlib_experimental_io, only: loadtxt
4+
use stdlib_experimental_error, only: error_stop
45
implicit none
56

67
real(sp), allocatable :: s(:, :)
78
real(dp), allocatable :: d(:, :)
8-
real(qp), allocatable :: q(:, :)
99

1010
call loadtxt("array1.dat", s)
1111
call print_array(s)
@@ -22,9 +22,6 @@ program test_loadtxt
2222
call loadtxt("array4.dat", d)
2323
call print_array(d)
2424

25-
call loadtxt("array4.dat", q)
26-
call print_array(q)
27-
2825
contains
2926

3027
subroutine print_array(a)
@@ -41,13 +38,8 @@ subroutine print_array(a)
4138
do i = 1, size(a, 1)
4239
print *, a(i, :)
4340
end do
44-
type is(real(qp))
45-
do i = 1, size(a, 1)
46-
print *, a(i, :)
47-
end do
4841
class default
49-
write(*,'(a)')'The proposed type is not supported'
50-
error stop
42+
call error_stop('The proposed type is not supported')
5143
end select
5244

5345
end subroutine

‎src/tests/loadtxt/test_loadtxt_qp.f90

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
program test_loadtxt_qp
2+
use iso_fortran_env, only: qp=>real128
3+
use stdlib_experimental_io, only: loadtxt
4+
implicit none
5+
6+
real(qp), allocatable :: q(:, :)
7+
8+
call loadtxt("array4.dat", q)
9+
call print_array(q)
10+
11+
contains
12+
13+
subroutine print_array(a)
14+
class(*),intent(in) :: a(:, :)
15+
integer :: i
16+
print *, "Array, shape=(", size(a, 1), ",", size(a, 2), ")"
17+
18+
select type(a)
19+
type is(real(qp))
20+
do i = 1, size(a, 1)
21+
print *, a(i, :)
22+
end do
23+
class default
24+
write(*,'(a)')'The proposed type is not supported'
25+
error stop
26+
end select
27+
28+
end subroutine
29+
30+
end program

‎src/tests/loadtxt/test_savetxt.f90

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
program test_loadtxt
2-
use iso_fortran_env, only: sp=>real32, dp=>real64 ,qp=>real128
1+
program test_savetxt
2+
use iso_fortran_env, only: sp=>real32, dp=>real64
33
use stdlib_experimental_io, only: loadtxt, savetxt
44
use stdlib_experimental_error, only: assert
55
implicit none
@@ -10,7 +10,6 @@ program test_loadtxt
1010

1111
call test_sp(outpath)
1212
call test_dp(outpath)
13-
call test_qp(outpath)
1413

1514
contains
1615

@@ -62,21 +61,4 @@ subroutine test_dp(outpath)
6261
call assert(all(abs(e-d2) < epsilon(1._dp)))
6362
end subroutine
6463

65-
subroutine test_qp(outpath)
66-
character(*), intent(in) :: outpath
67-
real(qp) :: d(3, 2), e(2, 3)
68-
real(qp), allocatable :: d2(:, :)
69-
d = reshape([1, 2, 3, 4, 5, 6], [3, 2])
70-
call savetxt(outpath, d)
71-
call loadtxt(outpath, d2)
72-
call assert(all(shape(d2) == [3, 2]))
73-
call assert(all(abs(d-d2) < epsilon(1._qp)))
74-
75-
e = reshape([1, 2, 3, 4, 5, 6], [2, 3])
76-
call savetxt(outpath, e)
77-
call loadtxt(outpath, d2)
78-
call assert(all(shape(d2) == [2, 3]))
79-
call assert(all(abs(e-d2) < epsilon(1._qp)))
80-
end subroutine
81-
8264
end program

‎src/tests/loadtxt/test_savetxt_qp.f90

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
program test_savetxt_qp
2+
use iso_fortran_env, only: qp=>real128
3+
use stdlib_experimental_io, only: loadtxt, savetxt
4+
use stdlib_experimental_error, only: assert
5+
implicit none
6+
7+
character(:), allocatable :: outpath
8+
9+
outpath = get_outpath() // "/tmp_qp.dat"
10+
11+
call test_qp(outpath)
12+
13+
contains
14+
15+
function get_outpath() result(outpath)
16+
integer :: ierr
17+
character(256) :: argv
18+
character(:), allocatable :: outpath
19+
20+
call get_command_argument(1, argv, status=ierr)
21+
if (ierr==0) then
22+
outpath = trim(argv)
23+
else
24+
outpath = '.'
25+
endif
26+
end function get_outpath
27+
28+
subroutine test_qp(outpath)
29+
character(*), intent(in) :: outpath
30+
real(qp) :: d(3, 2), e(2, 3)
31+
real(qp), allocatable :: d2(:, :)
32+
d = reshape([1, 2, 3, 4, 5, 6], [3, 2])
33+
call savetxt(outpath, d)
34+
call loadtxt(outpath, d2)
35+
call assert(all(shape(d2) == [3, 2]))
36+
call assert(all(abs(d-d2) < epsilon(1._qp)))
37+
38+
e = reshape([1, 2, 3, 4, 5, 6], [2, 3])
39+
call savetxt(outpath, e)
40+
call loadtxt(outpath, d2)
41+
call assert(all(shape(d2) == [2, 3]))
42+
call assert(all(abs(e-d2) < epsilon(1._qp)))
43+
end subroutine
44+
45+
end program

‎src/tests/test_fail.f90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
program AlwaysFail
2+
3+
use stdlib_experimental_error, only : assert
4+
implicit none
5+
6+
call assert(.false.)
7+
8+
end program

‎src/tests/test_skip.f90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
program AlwaysSkip
2+
3+
use stdlib_experimental_error, only : assert
4+
implicit none
5+
6+
call assert(.false., 77)
7+
8+
end program

0 commit comments

Comments
 (0)
Please sign in to comment.