Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extraction of the demo programs from the specs #662

Merged
merged 45 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0db0de1
fix issues in examples in specs
jvdp1 Jun 20, 2022
7536c0c
create demo programs from specs
jvdp1 Jun 21, 2022
3d4d8a7
rename examples to example
jvdp1 Jun 21, 2022
03df63e
fix issues in most demo programs
jvdp1 Jun 21, 2022
6e75462
fix issue hashmap_wrappers
jvdp1 Jun 21, 2022
af11e23
Generation of all demo programs + modif specs
jvdp1 Jun 21, 2022
f93dc4a
add examples in fpm
jvdp1 Jun 21, 2022
7bebf15
formatting
jvdp1 Jun 21, 2022
8e2dfc9
fix demo_copy_otehr
jvdp1 Jun 22, 2022
b003080
Update test/example/array/demo_falseloc.f90
jvdp1 Jun 22, 2022
ec8d47c
progress
jvdp1 Jun 22, 2022
e8d840c
Update test/example/logger/demo_log_text_error.f90
jvdp1 Jun 27, 2022
0a2f030
Update test/example/strings/demo_padl.f90
jvdp1 Jun 27, 2022
c3ca0c8
Update test/example/strings/demo_replace_all.f90
jvdp1 Jun 27, 2022
aec3691
Update test/example/strings/demo_padr.f90
jvdp1 Jun 27, 2022
b390dc8
Update test/example/strings/demo_padr.f90
jvdp1 Jun 27, 2022
faa1bc3
Update test/example/strings/demo_padr.f90
jvdp1 Jun 27, 2022
dc42cf5
Update test/example/logger/demo_log_text_error.f90
jvdp1 Jun 27, 2022
7fd1ac9
remove `int()` out of a `logical` expression
14NGiestas Jun 27, 2022
729b403
fix demo to pass all tests
jvdp1 Jun 27, 2022
e9cd24f
add example files in io
jvdp1 Jun 27, 2022
5954f51
fix issue with Intel compiler
jvdp1 Jun 28, 2022
6d7f889
use 2 spaces for indentation
jvdp1 Jun 28, 2022
bf00288
replace the prefix demo_ by example_
jvdp1 Jun 28, 2022
5d0024b
Update example_padr.f90
14NGiestas Jul 4, 2022
6a6900c
Revert last change using unformatted, but this time use the DT descri…
14NGiestas Jul 4, 2022
e208c2b
Merge remote-tracking branch 'upstream/master' into extract_demo
jvdp1 Jul 7, 2022
31d02cb
fix issues with examples in strings
jvdp1 Jul 7, 2022
e98384d
Merge remote-tracking branch 'origin/extract_demo' into extract_demo
jvdp1 Jul 7, 2022
948cf4d
Merge remote-tracking branch 'upstream/master' into extract_demo
jvdp1 Jul 7, 2022
9d17482
mv tests/examples to src/examples
jvdp1 Jul 14, 2022
e2f362d
fix ci/fpm-deployment.sh
jvdp1 Jul 14, 2022
b607ef3
Update README.md
jvdp1 Jul 22, 2022
83902b6
Merge remote-tracking branch 'upstream/master' into extract_demo
jvdp1 Jul 22, 2022
6988336
fix log_text_error
jvdp1 Jul 22, 2022
d644482
add log_text_error in CMakeLists.txt
jvdp1 Jul 22, 2022
29a091e
add a dummy file for logger examples
jvdp1 Jul 22, 2022
5fc1caa
add instructions to run the examples with fpm
jvdp1 Jul 25, 2022
9794b86
Merge remote-tracking branch 'upstream/master' into extract_demo
jvdp1 Jul 31, 2022
a647c5d
mv src/examples to example
jvdp1 Jul 31, 2022
dda3b45
update CMakeLists.txt
jvdp1 Jul 31, 2022
79b53a2
update fpm-deployment
jvdp1 Jul 31, 2022
6b2b5d2
update specs
jvdp1 Jul 31, 2022
ead3440
Mv src/examples to example
jvdp1 Jul 31, 2022
d0aeb90
update README.md
jvdp1 Jul 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/example/array/demo_falseloc.f90
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
program demo_falseloc
use stdlib_array, only : falseloc
implicit none
real, allocatable :: array(:)
allocate(array(-200:200))
call random_number(array)
array(falseloc(array < 0.5), lbound(array)) = 0.0
use stdlib_array, only: falseloc
implicit none
real, allocatable :: array(:)
allocate (array(-200:200))
call random_number(array)
array(falseloc(array < 0.5), lbound(array)) = 0.0
jvdp1 marked this conversation as resolved.
Show resolved Hide resolved
end program demo_falseloc
12 changes: 6 additions & 6 deletions test/example/array/demo_trueloc.f90
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
program demo_trueloc
use stdlib_array, only : trueloc
implicit none
real, allocatable :: array(:)
allocate(array(500))
call random_number(array)
array(trueloc(array > 0.5)) = 0.0
use stdlib_array, only: trueloc
implicit none
real, allocatable :: array(:)
allocate (array(500))
call random_number(array)
array(trueloc(array > 0.5)) = 0.0
end program demo_trueloc
6 changes: 3 additions & 3 deletions test/example/ascii/demo_ascii_reverse.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program demo_reverse
use stdlib_ascii, only : reverse
implicit none
print'(a)', reverse("Hello, World!") ! returns "!dlroW ,olleH"
use stdlib_ascii, only: reverse
implicit none
print'(a)', reverse("Hello, World!") ! returns "!dlroW ,olleH"
end program demo_reverse
6 changes: 3 additions & 3 deletions test/example/ascii/demo_ascii_to_lower.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program demo_to_lower
use stdlib_ascii, only : to_lower
implicit none
print'(a)', to_lower("HELLo!") ! returns "hello!"
use stdlib_ascii, only: to_lower
implicit none
print'(a)', to_lower("HELLo!") ! returns "hello!"
end program demo_to_lower
10 changes: 5 additions & 5 deletions test/example/ascii/demo_ascii_to_sentence.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
program demo_to_sentence
use stdlib_ascii, only : to_sentence
implicit none
print*, to_sentence("hello!") ! returns "Hello!"
print*, to_sentence("'enquoted'") ! returns "'Enquoted'"
print*, to_sentence("1st") ! returns "1st"
use stdlib_ascii, only: to_sentence
implicit none
print *, to_sentence("hello!") ! returns "Hello!"
print *, to_sentence("'enquoted'") ! returns "'Enquoted'"
print *, to_sentence("1st") ! returns "1st"
end program demo_to_sentence
10 changes: 5 additions & 5 deletions test/example/ascii/demo_ascii_to_title.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
program demo_to_title
use stdlib_ascii, only : to_title
implicit none
print*, to_title("hello there!") ! returns "Hello There!"
print*, to_title("'enquoted'") ! returns "'Enquoted'"
print*, to_title("1st") ! returns "1st"
use stdlib_ascii, only: to_title
implicit none
print *, to_title("hello there!") ! returns "Hello There!"
print *, to_title("'enquoted'") ! returns "'Enquoted'"
print *, to_title("1st") ! returns "1st"
end program demo_to_title
6 changes: 3 additions & 3 deletions test/example/ascii/demo_ascii_to_upper.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program demo_to_upper
use stdlib_ascii, only : to_upper
implicit none
print'(a)', to_upper("hello!") ! returns "HELLO!"
use stdlib_ascii, only: to_upper
implicit none
print'(a)', to_upper("hello!") ! returns "HELLO!"
end program demo_to_upper
24 changes: 12 additions & 12 deletions test/example/bitsets/demo_bitsets_all.f90
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
program demo_all
use stdlib_bitsets
character(*), parameter :: &
bits_all = '111111111111111111111111111111111'
type(bitset_64) :: set0
call set0 % from_string( bits_all )
if ( .not. set0 % all() ) then
error stop "FROM_STRING failed to interpret" // &
"BITS_ALL's value properly."
else
write(*,*) "FROM_STRING transferred BITS_ALL properly" // &
" into set0."
end if
use stdlib_bitsets
character(*), parameter :: &
bits_all = '111111111111111111111111111111111'
type(bitset_64) :: set0
call set0%from_string(bits_all)
if (.not. set0%all()) then
error stop "FROM_STRING failed to interpret"// &
"BITS_ALL's value properly."
else
write (*, *) "FROM_STRING transferred BITS_ALL properly"// &
" into set0."
end if
end program demo_all
30 changes: 15 additions & 15 deletions test/example/bitsets/demo_bitsets_and.f90
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
program demo_and
use stdlib_bitsets
type(bitset_large) :: set0, set1
call set0 % init(166)
call set1 % init(166)
call and( set0, set1 ) ! none none
if ( set0 % none() ) write(*,*) 'First test of AND worked.'
call set0 % not()
call and( set0, set1 ) ! all none
if ( set0 % none() ) write(*,*) 'Second test of AND worked.'
call set1 % not()
call and( set0, set1 ) ! none all
if ( set0 % none() ) write(*,*) 'Third test of AND worked.'
call set0 % not()
call and( set0, set1 ) ! all all
if ( set0 % all() ) write(*,*) 'Fourth test of AND worked.'
use stdlib_bitsets
type(bitset_large) :: set0, set1
call set0%init(166)
call set1%init(166)
call and(set0, set1) ! none none
if (set0%none()) write (*, *) 'First test of AND worked.'
call set0%not()
call and(set0, set1) ! all none
if (set0%none()) write (*, *) 'Second test of AND worked.'
call set1%not()
call and(set0, set1) ! none all
if (set0%none()) write (*, *) 'Third test of AND worked.'
call set0%not()
call and(set0, set1) ! all all
if (set0%all()) write (*, *) 'Fourth test of AND worked.'
end program demo_and
32 changes: 16 additions & 16 deletions test/example/bitsets/demo_bitsets_and_not.f90
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
program demo_and_not
use stdlib_bitsets
type(bitset_large) :: set0, set1
call set0 % init(166)
call set1 % init(166)
call and_not( set0, set1 ) ! none none
if ( set0 % none() ) write(*,*) 'First test of AND_NOT worked.'
call set0 % not()
call and_not( set0, set1 ) ! all none
if ( set0 % all() ) write(*,*) 'Second test of AND_NOT worked.'
call set0 % not()
call set1 % not()
call and_not( set0, set1 ) ! none all
if ( set0 % none() ) write(*,*) 'Third test of AND_NOT worked.'
call set0 % not()
call and_not( set0, set1 ) ! all all
if ( set0 % none() ) write(*,*) 'Fourth test of AND_NOT worked.'
use stdlib_bitsets
type(bitset_large) :: set0, set1
call set0%init(166)
call set1%init(166)
call and_not(set0, set1) ! none none
if (set0%none()) write (*, *) 'First test of AND_NOT worked.'
call set0%not()
call and_not(set0, set1) ! all none
if (set0%all()) write (*, *) 'Second test of AND_NOT worked.'
call set0%not()
call set1%not()
call and_not(set0, set1) ! none all
if (set0%none()) write (*, *) 'Third test of AND_NOT worked.'
call set0%not()
call and_not(set0, set1) ! all all
if (set0%none()) write (*, *) 'Fourth test of AND_NOT worked.'
end program demo_and_not
26 changes: 13 additions & 13 deletions test/example/bitsets/demo_bitsets_any.f90
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
program demo_any
use stdlib_bitsets
character(*), parameter :: &
bits_0 = '0000000000000000000'
type(bitset_64) :: set0
call set0 % from_string( bits_0 )
if ( .not. set0 % any() ) then
write(*,*) "FROM_STRING interpreted " // &
"BITS_0's value properly."
end if
call set0 % set(5)
if ( set0 % any() ) then
write(*,*) "ANY interpreted SET0's value properly."
end if
use stdlib_bitsets
character(*), parameter :: &
bits_0 = '0000000000000000000'
type(bitset_64) :: set0
call set0%from_string(bits_0)
if (.not. set0%any()) then
write (*, *) "FROM_STRING interpreted "// &
"BITS_0's value properly."
end if
call set0%set(5)
if (set0%any()) then
write (*, *) "ANY interpreted SET0's value properly."
end if
end program demo_any
48 changes: 24 additions & 24 deletions test/example/bitsets/demo_bitsets_assignment.f90
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
program demo_assignment
use stdlib_bitsets
use stdlib_kinds, only: int8, int32
implicit none
logical(int8) :: logical1(64) = .true.
logical(int32), allocatable :: logical2(:)
type(bitset_64) :: set0, set1
set0 = logical1
if ( set0 % bits() /= 64 ) then
error stop &
' initialization with logical(int8) failed to set' // &
' the right size.'
else if ( .not. set0 % all() ) then
error stop ' initialization with' // &
' logical(int8) failed to set the right values.'
else
write(*,*) 'Initialization with logical(int8) succeeded.'
end if
set1 = set0
if ( set1 == set0 ) &
write(*,*) 'Initialization by assignment succeeded'
logical2 = set1
if ( all( logical2 ) ) then
write(*,*) 'Initialization of logical(int32) succeeded.'
end if
use stdlib_bitsets
use stdlib_kinds, only: int8, int32
implicit none
logical(int8) :: logical1(64) = .true.
logical(int32), allocatable :: logical2(:)
type(bitset_64) :: set0, set1
set0 = logical1
if (set0%bits() /= 64) then
error stop &
' initialization with logical(int8) failed to set'// &
' the right size.'
else if (.not. set0%all()) then
error stop ' initialization with'// &
' logical(int8) failed to set the right values.'
else
write (*, *) 'Initialization with logical(int8) succeeded.'
end if
set1 = set0
if (set1 == set0) &
write (*, *) 'Initialization by assignment succeeded'
logical2 = set1
if (all(logical2)) then
write (*, *) 'Initialization of logical(int32) succeeded.'
end if
end program demo_assignment
26 changes: 13 additions & 13 deletions test/example/bitsets/demo_bitsets_bit_count.f90
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
program demo_bit_count
use stdlib_bitsets
character(*), parameter :: &
bits_0 = '0000000000000000000'
type(bitset_64) :: set0
call set0 % from_string( bits_0 )
if ( set0 % bit_count() == 0 ) then
write(*,*) "FROM_STRING interpreted " // &
"BITS_0's value properly."
end if
call set0 % set(5)
if ( set0 % bit_count() == 1 ) then
write(*,*) "BIT_COUNT interpreted SET0's value properly."
end if
use stdlib_bitsets
character(*), parameter :: &
bits_0 = '0000000000000000000'
type(bitset_64) :: set0
call set0%from_string(bits_0)
if (set0%bit_count() == 0) then
write (*, *) "FROM_STRING interpreted "// &
"BITS_0's value properly."
end if
call set0%set(5)
if (set0%bit_count() == 1) then
write (*, *) "BIT_COUNT interpreted SET0's value properly."
end if
end program demo_bit_count
18 changes: 9 additions & 9 deletions test/example/bitsets/demo_bitsets_bits.f90
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
program demo_bits
use stdlib_bitsets
character(*), parameter :: &
bits_0 = '0000000000000000000'
type(bitset_64) :: set0
call set0 % from_string( bits_0 )
if ( set0 % bits() == 19 ) then
write(*,*) "FROM_STRING interpreted " // &
"BITS_0's size properly."
end if
use stdlib_bitsets
character(*), parameter :: &
bits_0 = '0000000000000000000'
type(bitset_64) :: set0
call set0%from_string(bits_0)
if (set0%bits() == 19) then
write (*, *) "FROM_STRING interpreted "// &
"BITS_0's size properly."
end if
end program demo_bits
18 changes: 9 additions & 9 deletions test/example/bitsets/demo_bitsets_clear.f90
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
program demo_clear
use stdlib_bitsets
type(bitset_large) :: set0
call set0 % init(166)
call set0 % not()
if ( set0 % all() ) write(*,*) 'SET0 is properly initialized.'
call set0 % clear(165)
if ( .not. set0 % test(165) ) write(*,*) 'Bit 165 is cleared.'
call set0 % clear(0,164)
if ( set0 % none() ) write(*,*) 'All bits are cleared.'
use stdlib_bitsets
type(bitset_large) :: set0
call set0%init(166)
call set0%not()
if (set0%all()) write (*, *) 'SET0 is properly initialized.'
call set0%clear(165)
if (.not. set0%test(165)) write (*, *) 'Bit 165 is cleared.'
call set0%clear(0, 164)
if (set0%none()) write (*, *) 'All bits are cleared.'
end program demo_clear
28 changes: 14 additions & 14 deletions test/example/bitsets/demo_bitsets_equality.f90
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
program demo_equality
use stdlib_bitsets
type(bitset_64) :: set0, set1, set2
call set0 % init( 33 )
call set1 % init( 33 )
call set2 % init( 33 )
call set1 % set( 0 )
call set2 % set( 32 )
if ( set0 == set0 .and. set1 == set1 .and. set2 == set2 .and. &
.not. set0 == set1 .and. .not. set0 == set2 .and. .not. &
set1 == set2 ) then
write(*,*) 'Passed 64 bit equality tests.'
else
error stop 'Failed 64 bit equality tests.'
end if
use stdlib_bitsets
type(bitset_64) :: set0, set1, set2
call set0%init(33)
call set1%init(33)
call set2%init(33)
call set1%set(0)
call set2%set(32)
if (set0 == set0 .and. set1 == set1 .and. set2 == set2 .and. &
.not. set0 == set1 .and. .not. set0 == set2 .and. .not. &
set1 == set2) then
write (*, *) 'Passed 64 bit equality tests.'
else
error stop 'Failed 64 bit equality tests.'
end if
end program demo_equality
16 changes: 8 additions & 8 deletions test/example/bitsets/demo_bitsets_extract.f90
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
program demo_extract
use stdlib_bitsets
type(bitset_large) :: set0, set1
call set0 % init(166)
call set0 % set(100,150)
call extract( set1, set0, 100, 150)
if ( set1 % bits() == 51 ) &
write(*,*) 'SET1 has the proper size.'
if ( set1 % all() ) write(*,*) 'SET1 has the proper values.'
use stdlib_bitsets
type(bitset_large) :: set0, set1
call set0%init(166)
call set0%set(100, 150)
call extract(set1, set0, 100, 150)
if (set1%bits() == 51) &
write (*, *) 'SET1 has the proper size.'
if (set1%all()) write (*, *) 'SET1 has the proper values.'
end program demo_extract
16 changes: 8 additions & 8 deletions test/example/bitsets/demo_bitsets_flip.f90
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
program demo_flip
use stdlib_bitsets
type(bitset_large) :: set0
call set0 % init(166)
if ( set0 % none() ) write(*,*) 'SET0 is properly initialized.'
call set0 % flip(165)
if ( set0 % test(165) ) write(*,*) 'Bit 165 is flipped.'
call set0 % flip(0,164)
if ( set0 % all() ) write(*,*) 'All bits are flipped.'
use stdlib_bitsets
type(bitset_large) :: set0
call set0%init(166)
if (set0%none()) write (*, *) 'SET0 is properly initialized.'
call set0%flip(165)
if (set0%test(165)) write (*, *) 'Bit 165 is flipped.'
call set0%flip(0, 164)
if (set0%all()) write (*, *) 'All bits are flipped.'
end program demo_flip
Loading