At several locations a subroutine is defined with optional variables. I the executable part of the subroutine, then this optional variable is used in for instance a decision. Unfortunately the optional variable is not set if not provided in the call to the subroutine. then the code will break
solution is to add the value attribute to the optional variable
an example
PROGRAM PDEFAULT
REAL :: a
REAL :: b
a = 4
b = 2
CALL SUB (a,b)
CALL SUB(a,b,.TRUE.)
CONTAINS
SUBROUTINE SUB(a, b, VAL)
REAL, INTENT(IN) :: a, b
logical, OPTIONAL, VALUE:: VAL
IF (.NOT. PRESENT(val) .OR. (PRESENT(val) .AND. (.NOT. val))) THEN
WRITE(*,*) VAL
endif
write (*,*) a*b
END SUBROUTINE SUB
END PROGRAM PDEFAULT
This code will run successfully on ubuntu 22.03 using up to date gfortran compiler
removing the "value" i the definition of the logical VAL will break the code.
you can test this using your favorite compiler.
The construct in the subroutine is used at several locations in selected modules.
solution is to add the value attribute to the optional variable
an example
PROGRAM PDEFAULT
REAL :: a
REAL :: b
a = 4
b = 2
CALL SUB (a,b)
CALL SUB(a,b,.TRUE.)
CONTAINS
SUBROUTINE SUB(a, b, VAL)
REAL, INTENT(IN) :: a, b
logical, OPTIONAL, VALUE:: VAL
IF (.NOT. PRESENT(val) .OR. (PRESENT(val) .AND. (.NOT. val))) THEN
WRITE(*,*) VAL
endif
write (*,*) a*b
END SUBROUTINE SUB
END PROGRAM PDEFAULT
This code will run successfully on ubuntu 22.03 using up to date gfortran compiler
removing the "value" i the definition of the logical VAL will break the code.
you can test this using your favorite compiler.
The construct in the subroutine is used at several locations in selected modules.