include fftw3.f instead of #include fftw3.f breaks build

Issue #1 closed
Joseph Parker created an issue

@steve_biggs wrote here

"I just tried to build the latest trunk (r4424). However, it appears that a recent commit (r4421 - https://sourceforge.net/p/gyrokinetics/code/4421/) has broken the build. This is true on both a YPI server (sausage) and YARCC. Reverting that commit allows the build to complete successfully on both sausage and YARCC.

However, the comments seem to suggest that others may be having problems with the old way so the fix might not be as simple as just reverting that commit."

Comments (7)

  1. Joseph Parker reporter

    I also see this bug and would like to revert the commit.

    @rnumata, is it right that you need this change because you don't add a -I argument to the preprocessor? For GS2, we do pass an -I which is handled by Makefiles/Makefile.<system>. For example, in my laptop's makefile, I have the lines:

    ifeq ($(USE_FFT),fftw3)  
            FFT_LIB = -L/usr/lib -L/usr/lib/x86_64-linux-gnu/ -lfftw3 -lfftw3f  
            FFT_INC = -I/usr/local/lib
    endif
    

    which get passed to CPPFLAGS by the main Makefile.

    If you put the equivalent lines into your system makefile, can you built with the original line?:

    #include "fftw3.f"
    
  2. Ryusuke Numata

    I'm sorry for breaking the code.

    I think the reason that agk fails is because it is missing the following lines in the main makefile.

    ifeq ($(USE_FFT),fftw3)
            CPPFLAGS += -DFFT=_FFTW3_ $(FFT_INC)
            FFT_LIB ?= -lfftw -lrfftw
    endif
    

    So, if we add $(FFT_INC) to $(CPPFLAGS) the original code should work. But, I wonder if this is the right way. Why does the new code fails for GS2? Is there any special reason to use the preprocessor's include directive over the Fortran statement? For me, using the Fortran statement seems more standard.

  3. Joseph Parker reporter

    Thanks Ryusuke. On my machine, I'd not set FFT_INC to the directory containing fftw3.f, so mpif90 couldn't find it. Changing the local makefile to

    ifeq ($(USE_FFT),fftw3)  
            FFT_LIB = -L/usr/lib -L/usr/lib/x86_64-linux-gnu/ -lfftw3 -lfftw3f  
            FFT_INC = -I/usr/local/include
    endif
    

    builds fine.

    @steve_biggs , does it build for you if you set FFT_INC to the result of locate fftw3.f?

  4. Stephen Biggs-Fox

    Yes, it builds fine when I set FFT_LIB and FFT_INC properly. I agree with @rnumata that include is better than #include as it is the standard Fortran way of doing it (and is also the method suggested in the FFTW documentation). Therefore, I say, let's keep Ryusuke's change. However, we need to update any affected Makefiles accordingly. I will open a new bugfix branch for this.

  5. Stephen Biggs-Fox

    No issue with utils so closed here but new issues opened in gs2 and makefiles as that is where changes are required.

  6. Log in to comment