Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
公告
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Mixing Laguages

Intel_C_Intel
员工
576 次查看
Cananyonegiveme a thorough example of Fortran and C mixing including the commands for compiling/linking? I want Fortran to call C functions/subroutines. I followed the example on the manual and DOES NOT work. I have Intel Fortran 7.1 running on Win 2000. Thanks in advance.
This is what I have done:
Fortran Code:
PROGRAM test

REAL X, Y
EXTERNAL pointer_by2
X = 10
CALL pointer_by2(X,Y)
WRITE(*,*) X, Y
END
C Code:
#include
#include
void pointer_by2_(const float *input,float *output)
{
*output=*input * 2.0;
}
Using a C compiler I have make an object file from the C Code example. Then, I have used the following command to link:
ifl -o myprog f_code.for c_code.o
I get the following error:
Intel Fortran Compiler for 32-bit applications, Version 7.1 Build 20030307Z
Copyright (C) 1985-2003 Intel Corporation. All rights reserved.
ifl: Command line warning: unrecognized source type 'p_test.o'; object file assu
med
EPC Fortran-95 Version F95 Intel:200200:131124
Copyright (c) 1993-2000 EPCL. All Rights Reserved.
test_2.f90
program TEST
13 Lines Compiled
Microsoft Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
-out:myprog.exe
test_2.obj
p_test.o
p_test.o : warning LNK4078: multiple ".comment" sections found with different at
tributes (00000200)
test_2.obj : error LNK2001: unresolved external symbol _POINTER_BY2
myprog.exe : fatal error LNK1120: 1 unresolved externals
HELP!
0 项奖励
2 回复数
TimP
名誉分销商 III
576 次查看

You have followed the instructions for linux. The Windows compiler sets the link symbols to upper case by default, with no appended underscore. You should be OK if the C function is named POINTER_BY2().

I'm not sure which Windows C compiler would like to make a .o file rather than .obj, other than gcc, and I'm not sure that IFL will recognize -o. There is no supported compatibility between gcc and Intel compilers on Windows, but this may work.

0 项奖励
Intel_C_Intel
员工
576 次查看

I tried changing from lowercase to uppercase, appending an underscore or removing the underscore, but it doesn't work. Can youcompile/link my two simple code examples and tell me if they work? If they work, can you email me the object file of the C example.

Thank you in advance.

0 项奖励
回复