diff options
| author | Melissa Weber Mendonça <melissawm@gmail.com> | 2021-12-08 11:49:27 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-08 11:49:27 -0300 |
| commit | 9a19457cdfab2525feb71f134e4c2ac3b93abfe8 (patch) | |
| tree | 470fb34be51932da8f31c53bb729c8eec5490fc5 /numpy/f2py/tests/src/string | |
| parent | ce4555cbfc216a72c19e7369fe3353806bb89b67 (diff) | |
| parent | e52472411e6596808963e1a34d7b9ef0a1f6ef41 (diff) | |
| download | numpy-9a19457cdfab2525feb71f134e4c2ac3b93abfe8.tar.gz | |
Merge pull request #20517 from HaoZeke/f2pyTestRefactor
Diffstat (limited to 'numpy/f2py/tests/src/string')
| -rw-r--r-- | numpy/f2py/tests/src/string/fixed_string.f90 | 34 | ||||
| -rw-r--r-- | numpy/f2py/tests/src/string/string.f | 12 |
2 files changed, 46 insertions, 0 deletions
diff --git a/numpy/f2py/tests/src/string/fixed_string.f90 b/numpy/f2py/tests/src/string/fixed_string.f90 new file mode 100644 index 000000000..7fd158543 --- /dev/null +++ b/numpy/f2py/tests/src/string/fixed_string.f90 @@ -0,0 +1,34 @@ +function sint(s) result(i) + implicit none + character(len=*) :: s + integer :: j, i + i = 0 + do j=len(s), 1, -1 + if (.not.((i.eq.0).and.(s(j:j).eq.' '))) then + i = i + ichar(s(j:j)) * 10 ** (j - 1) + endif + end do + return + end function sint + + function test_in_bytes4(a) result (i) + implicit none + integer :: sint + character(len=4) :: a + integer :: i + i = sint(a) + a(1:1) = 'A' + return + end function test_in_bytes4 + + function test_inout_bytes4(a) result (i) + implicit none + integer :: sint + character(len=4), intent(inout) :: a + integer :: i + if (a(1:1).ne.' ') then + a(1:1) = 'E' + endif + i = sint(a) + return + end function test_inout_bytes4 diff --git a/numpy/f2py/tests/src/string/string.f b/numpy/f2py/tests/src/string/string.f new file mode 100644 index 000000000..5210ca4dc --- /dev/null +++ b/numpy/f2py/tests/src/string/string.f @@ -0,0 +1,12 @@ +C FILE: STRING.F + SUBROUTINE FOO(A,B,C,D) + CHARACTER*5 A, B + CHARACTER*(*) C,D +Cf2py intent(in) a,c +Cf2py intent(inout) b,d + A(1:1) = 'A' + B(1:1) = 'B' + C(1:1) = 'C' + D(1:1) = 'D' + END +C END OF FILE STRING.F |
