Skip to content

FortranCon 2021 stdlib presentation #21

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

Merged
merged 20 commits into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added FortranCon2021-stdlib/contrib.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions FortranCon2021-stdlib/examples/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FC = gfortran
STDLIB_CFLAGS = $(shell pkg-config --cflags fortran_stdlib)
STDLIB_LIBS = $(shell pkg-config --libs fortran_stdlib)

all: ex_bitsets ex_logger ex_sorting

ex_bitsets: ex_bitsets.f90
$(FC) $(STDLIB_CFLAGS) $^ -o $@ $(STDLIB_LIBS)

ex_logger: ex_logger.f90
$(FC) $(STDLIB_CFLAGS) $^ -o $@ $(STDLIB_LIBS)

ex_sorting: ex_sorting.f90
$(FC) $(STDLIB_CFLAGS) $^ -o $@ $(STDLIB_LIBS)

clean:
$(RM) ex_bitsets
$(RM) ex_logger
$(RM) ex_sorting

25 changes: 25 additions & 0 deletions FortranCon2021-stdlib/examples/ex_bitsets.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use, intrinsic :: iso_fortran_env, only: output_unit
use stdlib_bitsets
implicit none

integer :: i
type(bitset_64) :: b1, b2

! initialization from string
call b1%from_string('001100')
call b1%write_bitset(output_unit) ! S6B001110

! initialization from logical array
b2 = [(.true., i=1,6)]
call b2%write_bitset(output_unit) ! S6B111111

! binary operations overwrite first arg
call xor(b1, b2)
call b1%write_bitset(output_unit) ! S6B110001
call b2%write_bitset(output_unit) ! S6B111111

! set specific position/contiguous subset (zero-based!)
call b1%set(2, 4)
print *, b1 == b2 ! T
end

10 changes: 10 additions & 0 deletions FortranCon2021-stdlib/examples/ex_logger.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
program ex_logger
use stdlib_logger, only: global_logger
implicit none

call global_logger%add_log_file('log.txt')

call global_logger%log_debug('I am invisible')
call global_logger%log_information('Something informative')
call global_logger%log_error('Oopsie daisy')
end program
12 changes: 12 additions & 0 deletions FortranCon2021-stdlib/examples/ex_sorting.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use stdlib_sorting, only: sort_index
use stdlib_kinds, only: int64
implicit none

integer :: digits(6) = [3,1,4,1,5,9]
character :: chars(6) = ['a','b','c','d','e','f']
integer(int64) :: index(6)
call sort_index(digits, index)
print '(6i1)', digits ! 113459
print '(6i1)', index ! 241356
print '(6a1)', chars(index) ! bdacef
end
Binary file added FortranCon2021-stdlib/fortran_logo_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FortranCon2021-stdlib/stdlib-talk.pdf
Binary file not shown.
Loading