I'd like to mimic C code in a simple fortran project, where I would #define some macros and use them in my code.
For instance, an animal module would be as follows:
#define timestwo(x) (2 * (x))
module animal_module
implicit none
! ...
! test
procedure :: answer
! ...
function answer(this) result(n)
class(animal), intent(in) :: this
integer :: n
n = timestwo(42)
end function answer
end module animal_module
If I use the macro in the module, as you can see, I have no errors and it works just fine.
However, using that macro in the main file doesn't work at all:
program oo
use animal_module
implicit none
print *, 'the macro ', timestwo(5)
end program
With the compiler complaining about the macro:
main.F90(21): error #6404: This name does not have a type, and must have an explicit type. [TIMESTWO]
print *, 'the macro ', timestwo(5)
What am I missing?
