Search code examples
fortranreturnargumentslabelsubroutine

What the asterisk * symbol mean in a Fortran subroutine argument list?


What does the * mean as the argument in the subroutine? Does it mean a label and it returns to main program? is it related to return, return 1, ERR or ERROR? I don't know why we have these, but I think that asterisk is related to them.

  !>Start the creation of boundary conditions for the equation set.
SUBROUTINE  BOUNDARY_CONDITIONS_CREATE_START(SOLVER_EQUATIONS,BOUNDARY_CONDITIONS,ERR,ERROR,*)

!Argument variables
INTEGER(INTG), INTENT(OUT) :: ERR !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: ERROR !<The error string
!Local Variables
TYPE(VARYING_STRING) :: LOCAL_ERROR

ENTERS("BOUNDARY_CONDITIONS_CREATE_START",ERR,ERROR,*999)

    IF(ASSOCIATED(BOUNDARY_CONDITIONS)) THEN
      CALL FlagError("Boundary conditions is already associated.",ERR,ERROR,*999)
    ELSE
      IF(ASSOCIATED(SOLVER_EQUATIONS%SOLVER_MAPPING)) THEN
        !Initialise the boundary conditions
        CALL BOUNDARY_CONDITIONS_INITIALISE(SOLVER_EQUATIONS,ERR,ERROR,*999)
      ELSE
        LOCAL_ERROR="Solver equations solver mapping is not associated."
        CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
      ENDIF
    ENDIF
  ENDIF

EXITS("BOUNDARY_CONDITIONS_CREATE_START")
RETURN
999 ERRORSEXITS("BOUNDARY_CONDITIONS_CREATE_START",ERR,ERROR)
RETURN 1
END SUBROUTINE BOUNDARY_CONDITIONS_CREATE_START

Solution

  • This is a label for the alternate return from the function. It is the label where the function can eventually return to when using

     return 1
    

    instead of

    return
    

    which returns to the location from which the subroutine was called.

    This feature is strongly discouraged for new code although I have seen a proposal how to use this code for a kind of exceptions.

    Very related question, almost a duplicate (asking for the return statement instead): Fortran return statement