- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying to call a C function within a FORTRAN file and I am getting the following error. Same function call works in gcc and gfortran but fails in icc and ifort. Any suggestions ?
Regards,
Ashwin.
[CC] write_geogrid.c: icc -D_DOUBLEUNDERSCORE -O2 -Wall -c write_geogrid.c
[FC] geogrid_SRTM.f90: ifort -D_DOUBLEUNDERSCORE -O2 -Wall -fsecond-underscore -c geogrid_SRTM.f90
ifort: command line warning #10157: ignoring option '-W'; argument is of wrong type
ifort: command line warning #10006: ignoring unknown option '-fsecond-underscore'
[LD] ConvSRTM: ifort -D_DOUBLEUNDERSCORE -O2 -Wall -fsecond-underscore write_geogrid.o geogrid_SRTM.o -o ConvSRTM
ifort: command line warning #10157: ignoring option '-W'; argument is of wrong type
ifort: command line warning #10006: ignoring unknown option '-fsecond-underscore'
geogrid_SRTM.o: In function `MAIN__':
geogrid_SRTM.f90:(.text+0x983): undefined reference to `write_geogrid_'
make: *** [ConvSRTM] Error 1
This here is my Makefile
CC=icc
# Put your Fortran compiler here
FC=ifort
CPPFLAGS=-D_DOUBLEUNDERSCORE
CFLAGS=-O2 -Wall
FFLAGS=-O2 -Wall -fsecond-underscore
EXEC_SRTM=ConvSRTM
EXEC_LANDUSE=ConvLANDUSE
.SUFFIXES:
.SUFFIXES: .c .f90 .o
all: $(EXEC_SRTM) $(EXEC_LANDUSE)
.c.o:
@echo -n "[CC] $<: "
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
.f90.o:
@echo -n "[FC] $<: "
$(FC) $(CPPFLAGS) $(FFLAGS) -c $<
$(EXEC_SRTM): write_geogrid.o geogrid_SRTM.o
@echo -n "[LD] $@: "
$(FC) $(CPPFLAGS) $(FFLAGS) write_geogrid.o geogrid_SRTM.o -o $(EXEC_SRTM)
@echo
$(EXEC_LANDUSE): write_geogrid.o geogrid_LAND.o
@echo -n "[LD] $@: "
$(FC) $(CPPFLAGS) $(FFLAGS) write_geogrid.o geogrid_LAND.o -o $(EXEC_LANDUSE)
@echo
clean:
rm -f *.o $(EXEC_SRTM) $(EXEC_LANDUSE)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
second-underscore is a g77 convention, best forgotten with current compilers. linux default (single appended underscore) is the same for ifort and gfortran. For portability, you should USE iso_c_binding (for example, gfortran still uses single appended underscore on Windows, while ifort needs additional options for that).
As you saw, ifort rejects -Wall (so don't use it).
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page