I'm trying to add a suffix to the name of my subroutines, but I can't get the concatenation token of the C preprocessor to work properly. I have the following example:
test.f90:
#define ADD_SUFFIX(name) name##_r
subroutine ADD_SUFFIX(mysub)()
print*,'Success'
end subroutine
program test
implicit none
call mysub_r()
end program
Then I run gfortran -cpp test.f90 -o test.x
and get:
test.f90:3.16:
subroutine mysub##_r
1
Error: Syntax error in SUBROUTINE statement at (1)
I'm not very experienced in using preprocessor directives and everywhere I looked I see people using the operator like that (see here for example). Why does it copy the "##" literally in my case and how can I fix it to add suffixes?