Compiler doesn't recognize flags - fortran

I have just started my work with FORTRAN and I want to compile a program. This is what I'm receiving from compiler after writing make in command line.
mpif77 -c -mcmodel=medium -i-dynamic -no-ipo -r8 -xW -traceback -O2 ../agile/agile_parameter_module.f
gfortran: error: unrecognized command line option ‘-i-dynamic’
gfortran: error: unrecognized command line option ‘-no-ipo’
gfortran: error: unrecognized command line option ‘-r8’
gfortran: error: unrecognized command line option ‘-traceback’
I have downloaded and install trial version of Intel Fortran Compiler but make still uses gfortran and I got that message.

The mpif77 wrapper you are using has been configured for gfortran, which does not understand options for ifort. If you don't have the cluster tools for Intel Fortran you won't have their MPI wrapper mpiifort and will have to configure openmpi to use ifort.
If you want to avoid compiling openmpi to set it up for ifort you can try to use the MPI wrapper for gfortran with ifort like this:
ifort <ifort command line arguments> `mpif77 -showme:compile`
for the compile steps and
ifort <ifrot command line arguments> `mpif77 -showme:link`
for the link steps.
If those don't work directly you can look at the options emitted by mpif77 and modify them for ifort as needed. This is a stop-gap solution just to get your software built but for a long term solution you should properly set up openmpi to use ifort.

Related

gfortran equivalent of the -native flag

I am trying to run the makefile of a program in Fortran 77 that I did not write.
It specifies the following flags:
FLT_FLAGS = -native -libmil
and then uses them to compile a Fortran 77 program:
f77 -O -native -libmil -c a2.f
but fails:
f77: error: unrecognized command line option ‘-native’
makefile:107: recipe for target 'vg.a(a2.o)' failed
make: *** [vg.a(a2.o)] Error 1
The only thing I have been able to find with respect to this issue is that -native is obsolete, and maybe that's why gfortran (f77) does not recognize it: https://docs.oracle.com/cd/E37069_01/html/E37076/aevft.html#scrolltoc
You are using gfortran version 5.4. I wouldn't call f77 but gfortran directly if I were you.
The correct gfortran option similar to -native in some other compilers is -march=native or -mtune=native. See the manual and GCC: how is march different from mtune?
Don't forget to use other optimization flags like -O2 or -O3. The native option alone is not too useful.

Trying to compile a C++ code with Root (Cern) parameters included

I working on trying to compile a code written in C++ and Root on my Mac. The code is from a colleague who works on a Linux laptop. In addition to the different OS's, I have both a different version of gcc and Root than her and I am not sure which difference is causing the code not to compile on my machine.
She has g++ 4.8 and root 5.(something). I have gcc 5.3.0 and root 6.06/02.
She has given to me the a line of code she uses to get her machine to compile the code
gcc -Wall -o executable_name code_name.cc `root-config --cflags --glibs`
But when I write on my machine, Terminal gives me the error
gcc: error: unrecognized command line option ‘-stdlib=libc++’
gcc: error: unrecognized command line option ‘-stdlib=libc++’
I need help generating the correct line to get gcc to compile the code.
The problem here is two-fold: You're on OSX and you are using GCC.
The problem with this is that root-config assumes that since you're on OSX you will be using the OSX-standard Clang compiler which have the -stdlib flag. Since you're not using Clang, but GCC (which doesn't have this flag) you get an error.
You have two possible solutions: Use clang++ instead of g++ to compile and build (requires you to install the compiler if it's not installed already, it comes with Xcode), or to modify the root-config script so it doesn't add -stdlib=libc++. There might be environment variables or flags that the root-config script checks that alter the behavior, but I don't know anything about the script, you have to check it for that.

gfortran is called instead of mpif90

I am trying to compile a big solver using a makefile. When typing make, the following command gets executed:
mpif90 -O2 -fpp -I/somePath/ -c precision.F90
I get the following error:
gfortran: error: unrecognized command line option ‘-fpp’
I typed which mpif90 to see where it is pointing to:
/usr/local/intel14/impi/4.1.3.048/intel64/bin/mpif90
I tried to manually enter the command to make sure it did not have anything to do with the makefile and I got the same error. Why is gfortran being called? It must be some linking error but I can't figure it out.
The comments put me on the right track. I did not know mpif90 was just a wrapper.
$ /usr/local/inter14/impi/4.1.3.048/intel64/bin/mpif90 -v
mpif90 for the Intel(R) MPI Library 4.1 for Linux*
Copyright(C) 2003-2014, Intel Corporation. All rights reserved.
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gcc5.2/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/usr/local/gcc5.2 --disable-multilib
Thread model: posix
gcc version 5.2.0 (GCC)
I asked the code's author to do the same, the output pointed to an intel compiler. So what remains is to link ifort. This fixed it for me (bash shell):
export I_MPI_F90=ifort
You can just use the alternative
/usr/local/intel14/impi/4.1.3.048/intel64/bin/mpiifort

How to let distcc use the specified compiler

I have two gcc versions installed on my linux host, one is 4.8.1, another is 4.4.7. I want to use 4.8.1 while compile my code.
After i set distcc, gcc -v will print the collect 4.8.1, but distcc -v will still print 4.4.7.
So when i use pump make -j4 CC=distcc CXX=distcc to compile my project, it will pop below error:
cc1plus: error: unrecognized command line option "-std=c++11"
It seems that distcc don't use the correct compiler. How can i specified the compiler for distcc?
Still didn't find the easy way, but can compile like below:
GCC_HOME=/path/of/gcc make -j4
CC="LD_LIBRARY_PATH=$GCC_HOME/mpfr-3.1.2/lib:$GCC_HOME/mpc-1.0.1/lib:$GCC_HOME/gmp-5.1.2/lib:$GCC_HOME/lib:$GCC_HOME/lib64
distcc $GCC_HOME/bin/gcc"
CXX="LD_LIBRARY_PATH=$GCC_HOME/mpfr-3.1.2/lib:$GCC_HOME/mpc-1.0.1/lib:$GCC_HOME/gmp-5.1.2/lib:$GCC_HOME/lib:$GCC_HOME/lib64
distcc $GCC_HOME/bin/g++"
But in my invironment, distcc still can't work for pump mode

Cannot compile using -std flag with g++

I'm running Windows 7 with cygwin installed and trying to have a play around with some of the newer C++ features. I'm aware that in order to enable these features I have to pass g++ the -std=c++0x flag, however that gives me the following error:
cc1plus: error: unrecognized command line option "-std=c++0x"
The command line I'm issueing that gives rise to that error is:
g++-3 hello.cpp -std=c++0x -o hello
The reason for the g++-3 is because windows has trouble with the symbolic link. I've used g++ in the cygwin terminal and the result is the same anyway.
Any ideas?
You need to be using a version of GCC which supports C++ 2011 features.
This page has a list of compilers and which features each one supports. If I were you, I'd try to use GCC 4.7 if at all possible.