CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   C++ & F90 Compilation on SGIs (http://www.cfd-online.com/Forums/main/2270-c-f90-compilation-sgis.html)

David Hunt June 21, 2000 13:53

C++ & F90 Compilation on SGIs
 
Dear All,

this is not strictly a CFD query other than its target application. I'm trying to call an f90 sub-program from a C++ routine on an SGI. I suspect this is not an uncommon thing for CFD folk to do. I've read lots of manuals and still can't get it to work. I've put below example soucre code and command line stuff. If you can see where I'm going wrong, please let me know.

Many thanks Dave Hunt.

ccode.cpp: ========== #include<iostream> using namespace std; extern "C" void subr_(int*); main() { int nlen=3;

cout << "Hello World" << std::endl; subr_(&nlen); }

csubr.f90: ========== subroutine subr(nlen) integer :: nlen write(6,*) nlen end subroutine subr

command line: ============= (note, I'm using the SG CC and f90 compilers)

f90 -c csubr.f90 CC -LANG:std -c ccode.cpp CC -LANG:std ccode.o csubr.o

the last step gives me the following ERROR: ld32: ERROR 33 : Unresolved text symbol "_FWF" -- 1st referenced by csubr.o.

Use linker option -v to see when and which objects, archives and dsos are loaded. ld32: INFO 152: Output file removed because of error.


Oliver Gloth June 21, 2000 14:01

Re: C++ & F90 Compilation on SGIs
 
Check out the "Object-Oriented Numerics Page" oonumerics.org. There is a number of good links, including tools for language interoperability. A tool for C++/F77 exists and is called CPPF77. I don't know how useful it is for FORTRAN-90, though.

Stefan Nilsson June 22, 2000 03:43

Re: C++ & F90 Compilation on SGIs
 
Hi,

I think the problem is that since you're using CC to link your application the correct fortran90 libraries are not included, and therefore the _FWF (whatever that is) cannot be found. You'll have to explicitly include the correct libraries when linking.

If you compile some simple f90-program (hello world) using the -v flag, you will se all libraries included when linking a f90 program, then just add these when linking the C++/f90 program.

Best wishes Stefan

David Hunt June 22, 2000 03:55

Thanks: C++ & F90 Compilation sorted
 
Stefan,

thanks, that was sound advice. I needed a -lfortran flag to link one of the f90 libraries.

Dave


All times are GMT -4. The time now is 06:49.