I like how it's implemented in Python. Example(Python):
x = 1
y = 2
print(f"{x = }, {y = }")
# x = 1, y = 2
Im want to handle the errors and then print the variable name. Example(Fortran):
function check(var)
...
if (var < 0) print *, 'Error: var < 0'
...
end function check
There is no way in Fortran to get a variable name dynamically as variable names and types are required at compile time.
You could used Fortran derived types to associate a label to a value: