Skip to content

Commit 0add5b9

Browse files
committed
add more shap tests
1 parent 87d96ca commit 0add5b9

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

test/test_shape.f90

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,43 @@ program test_shape
55

66
implicit none (type, external)
77

8-
type(netcdf_file) :: h
9-
character(*), parameter :: path = 'test_shape.nc'
10-
integer, allocatable :: dims(:)
11-
character(NF90_MAX_NAME), allocatable :: dimnames(:)
8+
character(*), parameter :: fn = 'test_shape.nc'
9+
10+
11+
call test_shape_write(fn)
12+
13+
call test_shape_read(fn)
14+
print *, "OK: test_shape"
1215

16+
17+
contains
18+
19+
20+
subroutine test_shape_write(fn)
21+
22+
character(*), intent(in) :: fn
23+
24+
type(netcdf_file) :: h
1325
integer :: d2(3,4), d7(2,1,3,4,7,6,5)
1426

15-
call h%open(path, action='w')
27+
call h%open(fn, action='w')
1628
call h%write('d2', d2)
1729
call h%write('d7', d7, dims=['x','y','z', 'p','q','r','s'])
30+
call h%close()
31+
32+
end subroutine test_shape_write
33+
1834

35+
subroutine test_shape_read(fn)
36+
37+
character(*), intent(in) :: fn
38+
39+
type(netcdf_file) :: h
40+
character(NF90_MAX_NAME), allocatable :: dimnames(:)
41+
integer, allocatable :: dims(:)
42+
integer :: d2(3,4), d7(2,1,3,4,7,6,5)
43+
44+
call h%open(fn, action='r')
1945
call h%shape('d2', dims)
2046
if (h%ndim('d2') /= size(dims)) error stop 'rank /= size(dims)'
2147
if (any(dims /= shape(d2))) error stop '2-D: file shape not match variable shape'
@@ -26,4 +52,6 @@ program test_shape
2652

2753
call h%close()
2854

55+
end subroutine test_shape_read
56+
2957
end program

0 commit comments

Comments
 (0)