DLL usage calling function

Calling a function that squares a number:

program Square_prog
    use, intrinsic :: iso_fortran_env, only: RK => real64
    use Square_mod, only: getSquare
    implicit none
    real(RK) :: val = 100_RK  
	interface
	    function getSq(val) result(valSquared)
        !DEC$ ATTRIBUTES DLLIMPORT, DECORATE, ALIAS: 'getSq' :: getSq
        use, intrinsic :: iso_fortran_env, only: RK => real64
        real(RK), intent(in) :: val
        real(RK)             :: valSquared
    end function getSq
    end interface
    write(*,"(*(g0.13,:,' '))") "getSquare(", val, ") =", getSquare(val)
    write(*,"(*(g0.13,:,' '))") "    getSq(", val, ") =", getSq(val)
end program Square_prog

The number to be squared (val) is hard coded, I would like to be able to enter the number with a write read statement.
However that doesn’t work. When I try to do that I get an error: A specification statement cannot appear in the executable section

Roger

The rhs of this is an integer, while the lhs is a real. You probably want something like val=100._RK instead. Fortran will do implicit conversion, so maybe that is what you wanted, but there is the possibility that RK is not a valid integer kind, which would result in compile time errors.

As for your error, put the read statement right before the first write statement, and after the interface block, and it should work.

Thank you!
It worked.
Still a lot to learn.

Roger