Configure error, and newline operator in preprocessor  [SOLVED]

option, parallelism,...

Moderators: fgoudreault, mcote

Forum rules
Please have a look at ~abinit/doc/config/build-config.ac in the source package for detailed and up-to-date information about the configuration of Abinit 8 builds.
For a video explanation on how to build Abinit 7.x for Linux, please go to: http://www.youtube.com/watch?v=DppLQ-KQA68.
IMPORTANT: when an answer solves your problem, please check the little green V-like button on its upper-right corner to accept it.
Locked
zeroth
Posts: 12
Joined: Fri Jan 24, 2014 5:12 pm

Configure error, and newline operator in preprocessor

Post by zeroth » Fri Jan 31, 2014 11:08 am

I am currently trying to install Abinit 7.6.1 on my machine.

1.
The first thing is a configure error for detecting netcdf.
By doing:

Code: Select all

grep "call nf90" configure
in the abinit folder you get this output:

Code: Select all

ncerr = call nf90_open_par(path, cmode, comm, info, ncid)

which clearly is wrong. nf90_open_par is a function, not both a function and a subroutine (which would be cool though! ;) ).
I always do this before compiling to correct this error:

Code: Select all

sed -i -e 's:= call nf90:= nf90:g' configure

Notice that I have not tried to recreate the configure script (as that should not be needed on a user-install), however the error stems from this file:

Code: Select all

config/m4/conn-trio.m4

where the same grep shows the same error.

2. newline operator in the header files for abinit
In the file:
src/incs/abi_common.h
an entry for a newline occurs like this:

Code: Select all

/** define WHEREARG __FILE__,__LINE__**/
#if defined(HAVE_FC_LONG_LINES) || defined(__INTEL_COMPILER)
# define NEWLINE ;
#else
# define NEWLINE \newline
#endif

However, not all preprocessors take into account substituting an actual new-line.
Noticeably the gcc/gfortran compiler v4.4.5-8 and v4.7.2-5 which simply inserts the text "\newline" which obviously does not compile.
I could enforce the HAVE_FC_LONG_LINES, but I would suspect that others will encounter the same problem?
Also, I have no problems compiling the program using the Intel compiler (which is due to the __INTEL_COMPILER flag).

I have attached my build.ac file for completeness (if you wondered about my setup).

It seems like Abinit requires the compiler to take care of the preprocessing, or can you actually use FPP/CPP flags?

Here is my build.ac (I was not allowed to attach it):

Code: Select all

# This is Nicks build.ac for Abinit
prefix="/opt/abinit/7.6.1/gnu-4.7.2"
FC="mpif90"
CC="mpicc"
CXX="mpicxx"
FCFLAGS="-fopenmp -m64 -fPIC -O2 -ftree-vectorize -fexpensive-optimizations -funroll-loops -fprefetch-loop-arrays -fno-second-underscore -DHAVE_FC_LONG_LINES"
CFLAGS="-fopenmp -m64 -fPIC -O2 -ftree-vectorize -fexpensive-optimizations -funroll-loops -fprefetch-loop-arrays"
CXXFLAGS=""
enable_fc_wrapper="no"
enable_64bit_flags="yes"
enable_lotf="yes"
enable_openmp="yes"
enable_mpi_inplace="yes"
enable_mpi_io="yes"
enable_mpi="yes"
with_mpi_prefix="/opt/openmpi/1.6.5/gnu-4.7.2"
with_math_flavor="gsl"
with_linalg_flavor="custom"
with_math_incs=" -I/opt/gsl/1.16/gnu-4.7.2/include"
with_math_libs=" -L/opt/gsl/1.16/gnu-4.7.2/lib -Wl,-rpath=/opt/gsl/1.16/gnu-4.7.2/lib -lgsl"

with_linalg_incs=" -I/opt/atlas/3.10.1/gnu-4.7.2/include"
with_linalg_libs=" -L/opt/atlas/3.10.1/gnu-4.7.2/lib -L/opt/scalapack/2.0.2/gnu-4.7.2/lib -Wl,-rpath=/opt/atlas/3.10.1/gnu-4.7.2/lib -Wl,-rpath=/opt/scalapack/2.0.2/gnu-4.7.2/lib -lscalapack -llapack_atlas -lf77blas -lcblas -latlas"
FCFLAGS_OPENMP="-fopenmp"
with_trio_flavor="etsf_io+netcdf"
with_etsf_io_incs=" -I/opt/etsf_io/1.0.4/gnu-4.7.2/include"
with_etsf_io_libs=" -L/opt/etsf_io/1.0.4/gnu-4.7.2/lib -Wl,-rpath=/opt/etsf_io/1.0.4/gnu-4.7.2/lib -letsf_io -letsf_io_utils -letsf_io_low_level"
with_netcdf_incs=" -I/opt/netcdf/4.3.1/gnu-4.7.2/include"
with_netcdf_libs=" -L/opt/netcdf/4.3.1/gnu-4.7.2/lib -L/opt/pnetcdf/1.4.1/gnu-4.7.2/lib -L/opt/hdf5/1.8.12/gnu-4.7.2/lib -L/opt/zlib/1.2.8/gnu-4.7.2/lib -Wl,-rpath=/opt/netcdf/4.3.1/gnu-4.7.2/lib -Wl,-rpath=/opt/pnetcdf/1.4.1/gnu-4.7.2/lib -Wl,-rpath=/opt/hdf5/1.8.12/gnu-4.7.2/lib -Wl,-rpath=/opt/zlib/1.2.8/gnu-4.7.2/lib -lnetcdff -lnetcdf -lpnetcdf -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5 -lz"
with_fft_flavor="fftw3-mpi"
with_fft_incs=" -I/opt/fftw/3.3.3/gnu-4.7.2/include"
with_fft_libs=" -L/opt/fftw/3.3.3/gnu-4.7.2/lib -Wl,-rpath=/opt/fftw/3.3.3/gnu-4.7.2/lib -lfftw3f_omp -lfftw3f_mpi -lfftw3f -lfftw3_omp -lfftw3_mpi -lfftw3"

with_libxc_incs=" -I/opt/libxc/2.0.2/gnu-4.7.2/include"
with_libxc_libs=" -L/opt/libxc/2.0.2/gnu-4.7.2/lib -Wl,-rpath=/opt/libxc/2.0.2/gnu-4.7.2/lib -lxc"
with_dft_flavor="atompaw+wannier90+libxc"
with_atompaw_bins="/opt/atompaw/4.0.0.5/gnu-4.7.2/bin"
with_atompaw_incs=" -I/opt/atompaw/4.0.0.5/gnu-4.7.2/include"
with_atompaw_libs=" -L/opt/atompaw/4.0.0.5/gnu-4.7.2/lib -Wl,-rpath=/opt/atompaw/4.0.0.5/gnu-4.7.2/lib -latompaw"
with_wannier90_bins="/opt/wannier90/1.2/gnu-4.7.2/bin"
with_wannier90_incs=" -I/opt/wannier90/1.2/gnu-4.7.2/include"
with_wannier90_libs=" -L/opt/wannier90/1.2/gnu-4.7.2/lib -Wl,-rpath=/opt/wannier90/1.2/gnu-4.7.2/lib -lwannier"


Regards Nick
/ Nick Papior

User avatar
gmatteo
Posts: 291
Joined: Sun Aug 16, 2009 5:40 pm

Re: Configure error, and newline operator in preprocessor

Post by gmatteo » Fri Jan 31, 2014 5:18 pm

Dear Nick,

thanks for your bug reports.

Notice that I have not tried to recreate the configure script (as that should not be needed on a user-install), however the error stems from this file:
config/m4/conn-trio.m4


Fixed in 7.6.2

However, not all preprocessors take into account substituting an actual new-line.


Ok, the trick is not portable and should not be used in production. Note, however, that the NEWLINE macro is used
only if you compile the code in debug mode (#ifdef HAVE_MEM_PROFILING, an option for developers).
Could you post the the error message of the compiler and the name of the routine where the compilation stops so that
I can pinpoint the problem. Thanks in advance

Regards,
Matteo

Jordan
Posts: 282
Joined: Tue May 07, 2013 9:47 am

Re: Configure error, and newline operator in preprocessor  [SOLVED]

Post by Jordan » Fri Jan 31, 2014 11:06 pm

gmatteo wrote:
Ok, the trick is not portable and should not be used in production. Note, however, that the NEWLINE macro is used
only if you compile the code in debug mode (#ifdef HAVE_MEM_PROFILING, an option for developers).
Could you post the the error message of the compiler and the name of the routine where the compilation stops so that
I can pinpoint the problem. Thanks in advance


Dear Nick and Matteo

@Matteo : This is not true anymore and that is why I added intel compilers in

Code: Select all

#if defined(HAVE_FC_LONG_LINES) || defined(__INTEL_COMPILER)

Actually, only Intel11 or 12 (I don't remerber) had a problem with \newline.

This NEWLINE macro is used in 62_ctqmc/def.h (please forgive me in advance.)
But the code has been tested on gcc4.4.4, gcc 4.4.7, gcc 4.6 and gcc4.7.2, it worked.

I can have a look to fix this issue.

Regards,

Jordan

zeroth
Posts: 12
Joined: Fri Jan 24, 2014 5:12 pm

Re: Configure error, and newline operator in preprocessor

Post by zeroth » Mon Feb 03, 2014 10:06 am

Dear Matteo and Jordan,

So it seems like Jordan knows how to fix it? Do you need anymore information then?

And yes, the error stems from compiling files in the 62_ctqmc directory, sorry about not saying the directory.
It goes for all files which includes the mentioned file in my original post.

The error is the equivalent to compiling this code:

Code: Select all

program test
real, allocatable :: i
if ( allocated(i) ) then \newline deallocate(i) \newline end if
end program test
(the actual error message of course tells the line etc., however it is the insertion of "\newline" which is the problem, not the code)

Jordan you mentioned that it did work using gcc4.7.2?
Did you include any additional flags to allow the configurer to enable HAVE_FC_LONG_LINES? Or?

Kind regards Nick
/ Nick Papior

Jordan
Posts: 282
Joined: Tue May 07, 2013 9:47 am

Re: Configure error, and newline operator in preprocessor

Post by Jordan » Mon Feb 03, 2014 11:17 pm

Dear Nick,

The code has been tested on an amd cpu with the configure file you can find in
~abinit/doc/config/build-examples/bb_amd-gfortran4.7_vishnu_misc.ac (as well as all the other config files tested)

As you can see in this file, there is nothing special. If you intent to use this config file don't forget to change all the FC, CC, CPP,.... variables.
In the config.h file generated after the configure step, I checked that on this computer (vishnu) the HAVE_FC_LONG_LINES is indeed defined.

A "gfortran --version" on this computer gives

Code: Select all

vishnu vishnu_gcc47_nofbmisc]$ gfortran --version
GNU Fortran (GCC) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
...


Since HAVE_FC_LONG_LINES works, then you can enforce it as an easy patch. Use FCFLAGS_EXTRA="-DHAVE_FC_LONG_LINES -ffree-line-length-none"

If it still does not work, please let me know

Regards,

Jordan

EDIT : I tried many combinaisons of the \newline with preprocessor macros and I am afraid I could not get it working even on gcc 4.8.1. I'll work on this issue.
Could you give the result of the following command line, being in your build directory ? (For gcc4.7)

Code: Select all

grep -A 3 "Fortran compiler accepts long lines" config.log

zeroth
Posts: 12
Joined: Fri Jan 24, 2014 5:12 pm

Re: Configure error, and newline operator in preprocessor

Post by zeroth » Tue Feb 04, 2014 10:26 am

Here it is:

Code: Select all

configure:21913: checking whether the Fortran compiler accepts long lines
configure:21928: /home/nicpa/phd/code/install/.compile/abinit-7.6.1/build-tmp/config/wrappers/wrap-mpifc -m64 -o conftest -m64 -fPIC -O3 -ftree-vectorize -fexpensive-optimizations -funroll-loops -fprefetch-loop-arrays -fno-second-underscore -L/opt/hwloc/1.8/gnu-4.7.2/lib -L/opt/openmpi/1.6.5/gnu-4.7.2/lib -L/opt/atlas/3.10.1/gnu-4.7.2/lib -L/opt/gsl/1.16/gnu-4.7.2/lib -L/opt/libxc/2.0.2/gnu-4.7.2/lib -L/opt/atompaw/4.0.0.5/gnu-4.7.2/lib -L/opt/zlib/1.2.8/gnu-4.7.2/lib -L/opt/hdf5/1.8.12/gnu-4.7.2/lib -L/opt/pnetcdf/1.4.1/gnu-4.7.2/lib -L/opt/netcdf/4.3.1/gnu-4.7.2/lib -L/opt/etsf_io/1.0.4/gnu-4.7.2/lib -L/opt/wannier90/1.2/gnu-4.7.2/lib -L/opt/fftw/3.3.3/gnu-4.7.2/lib -L/opt/scalapack/2.0.2/gnu-4.7.2/lib -Wl,-rpath=/opt/hwloc/1.8/gnu-4.7.2/lib -Wl,-rpath=/opt/openmpi/1.6.5/gnu-4.7.2/lib -Wl,-rpath=/opt/atlas/3.10.1/gnu-4.7.2/lib -Wl,-rpath=/opt/gsl/1.16/gnu-4.7.2/lib -Wl,-rpath=/opt/libxc/2.0.2/gnu-4.7.2/lib -Wl,-rpath=/opt/atompaw/4.0.0.5/gnu-4.7.2/lib -Wl,-rpath=/opt/zlib/1.2.8/gnu-4.7.2/lib -Wl,-rpath=/opt/hdf5/1.8.12/gnu-4.7.2/lib -Wl,-rpath=/opt/pnetcdf/1.4.1/gnu-4.7.2/lib -Wl,-rpath=/opt/netcdf/4.3.1/gnu-4.7.2/lib -Wl,-rpath=/opt/etsf_io/1.0.4/gnu-4.7.2/lib -Wl,-rpath=/opt/wannier90/1.2/gnu-4.7.2/lib -Wl,-rpath=/opt/fftw/3.3.3/gnu-4.7.2/lib -Wl,-rpath=/opt/scalapack/2.0.2/gnu-4.7.2/lib  -L/opt/hwloc/1.8/gnu-4.7.2/lib -L/opt/openmpi/1.6.5/gnu-4.7.2/lib -L/opt/atlas/3.10.1/gnu-4.7.2/lib -L/opt/gsl/1.16/gnu-4.7.2/lib -L/opt/libxc/2.0.2/gnu-4.7.2/lib -L/opt/atompaw/4.0.0.5/gnu-4.7.2/lib -L/opt/zlib/1.2.8/gnu-4.7.2/lib -L/opt/hdf5/1.8.12/gnu-4.7.2/lib -L/opt/pnetcdf/1.4.1/gnu-4.7.2/lib -L/opt/netcdf/4.3.1/gnu-4.7.2/lib -L/opt/etsf_io/1.0.4/gnu-4.7.2/lib -L/opt/wannier90/1.2/gnu-4.7.2/lib -L/opt/fftw/3.3.3/gnu-4.7.2/lib -L/opt/scalapack/2.0.2/gnu-4.7.2/lib -Wl,-rpath=/opt/hwloc/1.8/gnu-4.7.2/lib -Wl,-rpath=/opt/openmpi/1.6.5/gnu-4.7.2/lib -Wl,-rpath=/opt/atlas/3.10.1/gnu-4.7.2/lib -Wl,-rpath=/opt/gsl/1.16/gnu-4.7.2/lib -Wl,-rpath=/opt/libxc/2.0.2/gnu-4.7.2/lib -Wl,-rpath=/opt/atompaw/4.0.0.5/gnu-4.7.2/lib -Wl,-rpath=/opt/zlib/1.2.8/gnu-4.7.2/lib -Wl,-rpath=/opt/hdf5/1.8.12/gnu-4.7.2/lib -Wl,-rpath=/opt/pnetcdf/1.4.1/gnu-4.7.2/lib -Wl,-rpath=/opt/netcdf/4.3.1/gnu-4.7.2/lib -Wl,-rpath=/opt/etsf_io/1.0.4/gnu-4.7.2/lib -Wl,-rpath=/opt/wannier90/1.2/gnu-4.7.2/lib -Wl,-rpath=/opt/fftw/3.3.3/gnu-4.7.2/lib -Wl,-rpath=/opt/scalapack/2.0.2/gnu-4.7.2/lib  conftest.F90  >&5
conftest.F90:3.20:

         write(*,*)'01234567890123456789012345678901234567890123456789012345678
                    1
Error: Unterminated character constant beginning at (1)
configure:21928: $? = 1
configure: failed program was:
|       program main
|
|          write(*,*)'0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' !142
|
|       end

And here is my wrapper compiler call (for completeness sake):

Code: Select all

#!/bin/sh

FC="gfortran"
export FC

/opt/openmpi/1.6.5/gnu-4.7.2/bin/mpif90 ${*}

And compiler version output:

Code: Select all

$>/opt/openmpi/1.6.5/gnu-4.7.2/bin/mpif90 --version
GNU Fortran (Debian 4.7.2-5) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING


Please advice if you need any more information.
It seems like there are some default flags somewhere disturbing the call. So it could be a local thing, maybe related to the Debian distributed GCC compiler.
In any case, I still regard it as resolved.

Regards Nick
/ Nick Papior

Jordan
Posts: 282
Joined: Tue May 07, 2013 9:47 am

Re: Configure error, and newline operator in preprocessor

Post by Jordan » Wed Feb 05, 2014 8:31 pm

Dear Nick,

It seems that in your .ac file you've defined the variable FCFLAGS with many options. Defining this variable disables the check for appropriate options by the build system of abinit. As a consequence, abinit doesn't use the -ffree-length-line-none option and you don't specify it in your FCFLAGS definition.
Therefore the test for long lines fails and the NEWLINE macro is set to \newline.

The best way to add compilation flags -- if you want to do so -- is in my opinion to use the FCFLAGS_EXTRA variable instead of FCFLAGS. FCFLAGS_EXTRA content will be append to FCFLAGS during the compilation.

Regards,

Jordan

zeroth
Posts: 12
Joined: Fri Jan 24, 2014 5:12 pm

Re: Configure error, and newline operator in preprocessor

Post by zeroth » Thu Feb 06, 2014 4:45 pm

Ok, great!

I will go that route then.

Thanks for all the help!
/ Nick Papior

Locked