Skip to content

Commit d538078

Browse files
committed
Add examples
1 parent 666bd51 commit d538078

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

example/io/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ ADD_EXAMPLE(loadtxt)
55
ADD_EXAMPLE(open)
66
ADD_EXAMPLE(savenpy)
77
ADD_EXAMPLE(savetxt)
8+
ADD_EXAMPLE(load_npz)
9+
ADD_EXAMPLE(save_npz)

example/io/example_load_npz.f90

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
program example_load_npz
2+
use stdlib_array
3+
use stdlib_io_np, only: load_npz
4+
implicit none
5+
6+
type(t_array_wrapper), allocatable :: arrays(:)
7+
integer :: i
8+
9+
call load_npz('example_load.npz', arrays)
10+
11+
do i = 1, size(arrays)
12+
select type (array => arrays(i)%array)
13+
class is (t_array_rsp_2)
14+
print *, array%values
15+
class is (t_array_iint32_2)
16+
print *, array%values
17+
class default
18+
print *, 'Array ', i, ' is of unknown type.'
19+
end select
20+
end do
21+
end

example/io/example_save_npz.f90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
program example_save_npz
2+
use stdlib_array, only: t_array_wrapper
3+
use stdlib_io_np, only: add_array, save_npz
4+
implicit none
5+
6+
type(t_array_wrapper), allocatable :: arrays(:)
7+
real :: x(3, 2) = 1
8+
integer :: y(2, 3) = 2
9+
10+
call add_array(arrays, x)
11+
call add_array(arrays, y)
12+
13+
call save_npz('example_save.npz', arrays)
14+
end

example_load.npz

618 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)