|
| 1 | +! Test for conditional arguments (Fortran 2023) |
| 2 | + |
| 3 | +module M_condexpr_array_lval_02 |
| 4 | +contains |
| 5 | + subroutine final_sub( S_OUTPUT, S_INPUT ) |
| 6 | + real, intent(out) :: S_OUTPUT(5) |
| 7 | + real, intent(in) :: S_INPUT(5) |
| 8 | + |
| 9 | + S_OUTPUT = S_INPUT |
| 10 | + end subroutine final_sub |
| 11 | + |
| 12 | + subroutine intermediate_sub(cond, ANSWER, TRUE_INPUT, FALSE_INPUT) |
| 13 | + logical, intent(in) :: cond |
| 14 | + real, contiguous, intent(out) :: ANSWER(:) |
| 15 | + real, contiguous, intent(in) :: TRUE_INPUT(:) |
| 16 | + real, contiguous, intent(in) :: FALSE_INPUT(:) |
| 17 | + call final_sub( ANSWER, (cond ? TRUE_INPUT : FALSE_INPUT)) |
| 18 | + end subroutine intermediate_sub |
| 19 | +end module M_condexpr_array_lval_02 |
| 20 | + |
| 21 | +program main |
| 22 | + use M_condexpr_array_lval_02 |
| 23 | + REAL :: MAIN_A(5) |
| 24 | + REAL :: MAIN_T(5) |
| 25 | + REAL :: MAIN_F(5) |
| 26 | + logical, parameter :: c(5) = [ .false., .true., .true., .false., .true. ] |
| 27 | + |
| 28 | + do i = 1, 5 |
| 29 | + MAIN_T = [ 1.0, 2.0, 3.0, 4.0, 5.0 ] |
| 30 | + MAIN_F = MAIN_T + 10.0 !-- [ 11.0, 12.0, 13.0, 14.0, 15.0 ] |
| 31 | + call intermediate_sub(c(i), MAIN_A, MAIN_T, MAIN_F) |
| 32 | + print '(I2,": ",5F8.2)', i, MAIN_A |
| 33 | + enddo |
| 34 | +end program main |
0 commit comments