TRIVIAL: Using a REAL as mathematical function in the main program

Good day,
When reading old FORTRAN code I often encounter code like this:

When declaring variables:

PROGRAM ENTROPYINCREASER3000
IMPLICIT NONE
REAL :: FUNCTION, X, A, B, TRESH
REAL, ALLOCATABLE :: C(:), VALUE(:)
INTEGER :: STEP

which is later used in the code as follows (spoof example):

FUNCTION(X) = A*A*EXP(X)*SIN(X)/X
....
DO I=1,C_L
30 CONTINUE
      STEP = STEP +1 
      X = B+FUNCTION(X)*C(I)
      VALUE(I) = X*B
      IF (VALUE(I) .GT. TRESH) GOTO 30
   WRITE(35,50) C(I), VALUE(I), STEP
   STEP = 0
   X= 2.
END DO
50 FORMAT(2X, 'C-VAL=',E15.8,4X, 'VALUE=' ,E15.8,4X,'STEP=',I8)
....
END PROGRAM ENTROPYINCREASER3000 

…Which is often found inside a loop for some recursive task (i.e. finding roots) (also: the dots signify other unrelated code for example some if statement wether)

I would not expect this to work because as far as I know functions need to be declared separately behind some CONTAINS statement. Indeed when I try this inside a program I get errors of the form:

FUNCTION(X) = A*EXP(X)
1
Error: Unclassifiable statement at (1)

Yet… when I isolate such a snippet and:
… assign other parameters (like A) AFTER the FUNCTION(X) assignment
… make sure that FUNCTION(X)=... is the first line of the program

if all are met then it works perfectly.

TL;DR Why does it even work in the first place? And why does assigning a value to A before you use it in the FUNCTION(X)=… make it unclassifiable? If no value for A is available, does FORTRAN wait in a Lambda-function-esque way which forces it to work once A is declared or is it far more obvious? I can not seem to find anything online but most likely I am unaware of how some things are named and this is extremely trivial, in which case I apologize.

I think you are coming across statement functions, which have a different syntax than regular functions.

What you have encountered is a so-called statement function. It is superseded by internal routines or perhaps better: internal routines are a much better behaved feature that can be used to achieve the same thing. Try and find descriptions in old FORTRAN manuals.

Ah thank you all, it has a name! (Both of you solved my problem but I can only select one).