How to define a variable in a makefile and then use it within Fortran code
问题 I am trying to define a variable in a makefile, and then depending on whether that variable is set, change which code block is compiled in my Fortran routine. Simple example I can't get working: program test implicit none integer :: a #ifdef MYVAR a = 1 #else a = 0 #endif write(*,*) a end program test My makefile is: MYVAR=1 all: ifort temp.F90 -fpp echo $(MYVAR) The echo $(MYVAR) line correctly prints 1. However, when the test program is compiled it sets a=0. How do I get the Fortran code to