Skip to content

Commit b4e174c

Browse files
committed
Solved errors. Support for optval seems to work
1 parent 4926dd5 commit b4e174c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/stdlib_experimental_optval.fypp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#:include "common.fypp"
22

33
#:set KINDS_TYPES = REAL_KINDS_TYPES + INT_KINDS_TYPES + CMPLX_KINDS_TYPES + &
4-
& [('l1','logical'), ('C1','character')]
4+
& [('l1','logical')]
55

66
module stdlib_experimental_optval
77
!!
@@ -25,6 +25,7 @@ module stdlib_experimental_optval
2525
#:for k1, t1 in KINDS_TYPES
2626
module procedure optval_${t1[0]}$${k1}$
2727
#:endfor
28+
module procedure optval_character
2829
! TODO: differentiate ascii & ucs char kinds
2930
end interface optval
3031

@@ -45,4 +46,17 @@ contains
4546
end function optval_${t1[0]}$${k1}$
4647
#:endfor
4748

49+
! Cannot be made elemental
50+
pure function optval_character(x, default) result(y)
51+
character(len=*), intent(in), optional :: x
52+
character(len=*), intent(in) :: default
53+
character(len=:), allocatable :: y
54+
55+
if (present(x)) then
56+
y = x
57+
else
58+
y = default
59+
end if
60+
end function optval_character
61+
4862
end module stdlib_experimental_optval

0 commit comments

Comments
 (0)