Skip to content

Commit 870fd3b

Browse files
author
Jim-215-Fisher
committed
Merge branch 'master' into Distribution-Uniform
2 parents edf6ac8 + 916f69a commit 870fd3b

13 files changed

+79
-148
lines changed

Makefile.manual

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

3-
FC = gfortran
4-
FFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all
5-
FYPPFLAGS=
3+
FC ?= gfortran
4+
FFLAGS ?= -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all
5+
FYPPFLAGS ?=
66

77
export FC
88
export FFLAGS

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ Important options are
134134
Compiling with maximum rank 15 can be resource intensive and requires at least 16 GB of memory to allow parallel compilation or 4 GB memory for sequential compilation.
135135
- `-DBUILD_SHARED_LIBS` set to `on` in case you want link your application dynamically against the standard library (default: `off`).
136136

137-
For example, to configure a build using the Ninja backend and generating procedures up to rank 7, which is installed to your home directory use
137+
For example, to configure a build using the Ninja backend while specifying compiler flags `FFLAGS`, generating procedures up to rank 7, and installing to your home directory, use
138138

139139
```sh
140+
export FFLAGS="-O3"
140141
cmake -B build -G Ninja -DCMAKE_MAXIMUM_RANK:String=7 -DCMAKE_INSTALL_PREFIX=$HOME/.local
141142
```
142143

@@ -162,6 +163,10 @@ cmake --install build
162163

163164
Now you have a working version of stdlib you can use for your project.
164165

166+
If at some point you wish to recompile `stdlib` with different options, you might
167+
want to delete the `build` folder. This will ensure that cached variables from
168+
earlier builds do not affect the new build.
169+
165170

166171
### Build with make
167172

@@ -177,6 +182,11 @@ You can limit the maximum rank by setting ``-DMAXRANK=<num>`` in the ``FYPPFLAGS
177182
make -f Makefile.manual FYPPFLAGS=-DMAXRANK=4
178183
```
179184

185+
You can also specify the compiler and compiler-flags by setting the ``FC`` and ``FFLAGS`` environmental variables. Among other things, this facilitates use of compiler optimizations that are not specified in the Makefile.manual defaults.
186+
```sh
187+
make -f Makefile.manual FYPPFLAGS=-DMAXRANK=4 FC=gfortran FFLAGS="-O3 -flto"
188+
```
189+
180190
### Build with [fortran-lang/fpm](https://github.com/fortran-lang/fpm)
181191

182192
Fortran Package Manager (fpm) is a package manager and build system for Fortran.

src/stdlib_bitsets.fypp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module stdlib_bitsets
1313
int16, &
1414
int32, &
1515
int64
16+
use stdlib_optval, only : optval
1617

1718
use, intrinsic :: &
1819
iso_fortran_env, only: &

src/stdlib_bitsets_64.fypp

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -812,23 +812,13 @@ contains
812812
end if
813813
end do
814814

815-
if ( present(advance) ) then
816-
read( unit, &
817-
advance=advance, &
818-
FMT='(A1)', &
819-
err=997, &
820-
end=998, &
821-
iostat=ierr, &
822-
iomsg=message ) char
823-
else
824-
read( unit, &
825-
advance='YES', &
826-
FMT='(A1)', &
827-
err=997, &
828-
end=998, &
829-
iostat=ierr, &
830-
iomsg=message ) char
831-
end if
815+
read( unit, &
816+
advance=optval(advance, 'YES'), &
817+
FMT='(A1)', &
818+
err=997, &
819+
end=998, &
820+
iostat=ierr, &
821+
iomsg=message ) char
832822
if ( char == '0' ) then
833823
call self % clear( bits-bit )
834824
else if ( char == '1' ) then
@@ -1080,21 +1070,12 @@ contains
10801070
end if
10811071

10821072

1083-
if ( present( advance ) ) then
1084-
write( unit, &
1085-
FMT='(A)', &
1086-
advance=advance, &
1087-
iostat=ierr, &
1088-
iomsg=message ) &
1089-
string
1090-
else
1091-
write( unit, &
1092-
FMT='(A)', &
1093-
advance='YES', &
1094-
iostat=ierr, &
1095-
iomsg=message ) &
1096-
string
1097-
end if
1073+
write( unit, &
1074+
FMT='(A)', &
1075+
advance=optval(advance, 'YES'), &
1076+
iostat=ierr, &
1077+
iomsg=message ) &
1078+
string
10981079
if (ierr /= 0) then
10991080
call error_handler( 'Failure on a WRITE statement for UNIT.', &
11001081
write_failure, status, module_name, procedure )

src/stdlib_bitsets_large.fypp

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -997,23 +997,13 @@ contains
997997
end if
998998
end do
999999

1000-
if ( present(advance) ) then
1001-
read( unit, &
1002-
advance=advance, &
1003-
FMT='(A1)', &
1004-
err=997, &
1005-
end=998, &
1006-
iostat=ierr, &
1007-
iomsg=message ) char
1008-
else
1009-
read( unit, &
1010-
advance='YES', &
1011-
FMT='(A1)', &
1012-
err=997, &
1013-
end=998, &
1014-
iostat=ierr, &
1015-
iomsg=message ) char
1016-
end if
1000+
read( unit, &
1001+
advance=optval(advance, 'YES'), &
1002+
FMT='(A1)', &
1003+
err=997, &
1004+
end=998, &
1005+
iostat=ierr, &
1006+
iomsg=message ) char
10171007

10181008
if ( char == '0' ) then
10191009
call self % clear( bits-bit )
@@ -1302,21 +1292,12 @@ contains
13021292
end if
13031293

13041294

1305-
if ( present( advance ) ) then
1306-
write( unit, &
1307-
FMT='(A)', &
1308-
advance=advance, &
1309-
iostat=ierr, &
1310-
iomsg=message ) &
1311-
string
1312-
else
1313-
write( unit, &
1314-
FMT='(A)', &
1315-
advance='YES', &
1316-
iostat=ierr, &
1317-
iomsg=message ) &
1318-
string
1319-
end if
1295+
write( unit, &
1296+
FMT='(A)', &
1297+
advance=optval(advance, 'YES'), &
1298+
iostat=ierr, &
1299+
iomsg=message ) &
1300+
string
13201301
if (ierr /= 0) then
13211302
call error_handler( 'Failure on a WRITE statement for UNIT.', &
13221303
write_failure, status, module_name, procedure )

src/stdlib_logger.f90

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,11 +1147,8 @@ subroutine log_message( self, message, module, procedure, prefix )
11471147
character(:), allocatable :: d_and_t, m_and_p, pref
11481148
character(:), allocatable :: buffer
11491149

1150-
if ( present(prefix) ) then
1151-
pref = prefix // ': '
1152-
else
1153-
pref = ''
1154-
end if
1150+
pref = optval(prefix, '')
1151+
if ( len(pref) > 0 ) pref = pref // ': '
11551152

11561153
if ( self % time_stamp ) then
11571154
d_and_t = time_stamp() // ': '

src/stdlib_sorting.fypp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ module stdlib_sorting
123123
dp, &
124124
qp
125125

126+
use stdlib_optval, only: optval
127+
126128
use stdlib_string_type, only: string_type, assignment(=), operator(>), &
127129
operator(>=), operator(<), operator(<=)
128130

src/stdlib_sorting_ord_sort.fypp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ contains
7575
${t3}$, intent(out), optional :: work(0:)
7676
logical, intent(in), optional :: reverse
7777

78-
logical :: reverse_
79-
80-
reverse_ = .false.
81-
if(present(reverse)) reverse_ = reverse
82-
83-
if (reverse_) then
78+
if (optval(reverse, .false.)) then
8479
call ${name1}$_decrease_ord_sort(array, work)
8580
else
8681
call ${name1}$_increase_ord_sort(array, work)

src/stdlib_sorting_sort.fypp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,7 @@ contains
7878
${t1}$, intent(inout) :: array(0:)
7979
logical, intent(in), optional :: reverse
8080

81-
logical :: reverse_
82-
83-
reverse_ = .false.
84-
if(present(reverse)) reverse_ = reverse
85-
86-
if(reverse_)then
81+
if(optval(reverse, .false.))then
8782
call ${name1}$_decrease_sort(array)
8883
else
8984
call ${name1}$_increase_sort(array)

src/stdlib_sorting_sort_index.fypp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,8 @@ contains
107107
index(i) = i+1
108108
end do
109109

110-
if ( present(reverse) ) then
111-
if ( reverse ) then
112-
call reverse_segment( array, index )
113-
end if
110+
if ( optval(reverse, .false.) ) then
111+
call reverse_segment( array, index )
114112
end if
115113

116114
! If necessary allocate buffers to serve as scratch memory.
@@ -148,10 +146,8 @@ contains
148146
end if
149147
end if
150148

151-
if ( present(reverse) ) then
152-
if ( reverse ) then
153-
call reverse_segment( array, index )
154-
end if
149+
if ( optval(reverse, .false.) ) then
150+
call reverse_segment( array, index )
155151
end if
156152

157153
contains

0 commit comments

Comments
 (0)