202X feature: Conditional Expressions

Great point! Using the idea you can do the named parameters too.

module m_ifthen
   implicit none
contains
   function if(condition, then, else) result(val)
      logical, intent(in) :: condition
      real, intent(in), optional, target :: then, else
      real, pointer :: val
      val => null()
      if (condition) then
         if (present(then)) val => then
      else
         if (present(else)) val => else
      end if
   end function if
end module m_ifthen

module m_test
   use m_ifthen
   implicit none
contains
   subroutine test_ifthen(x, d)
       real, intent(in) :: x
       real, intent(in), optional :: d
       real :: a, b, c
   
       call sub(a, b, c, if(present(d), then=d, else=if(x < 1, then=epsilon(x), else=spacing(x))))
   
       print *, a, b, c
   end subroutine test_ifthen
   
   subroutine sub(a, b, c, d)
       real, intent(out) :: a, b, c
       real, intent(in) :: d
       a = sqrt(d)
       b = sqrt(a)
       c = sqrt(b)
   end subroutine sub
end module m_test
   
program demo
   use m_test
   implicit none
   call test_ifthen(0.5)
end program demo