linking errors in C language from fortran library

Les Neilson
Total Points:
5,816
Status Points:
5,316
Brown Belt
July 3, 2009 3:44 AM PDT
Rate
 
#3 Reply to #2
Quoting - cvnravi


Hi Thanks for your reply.. Part of your investigation is correct.. But serverstuff is a COMMON data which is included in  "server.for" file. Check the below code from server.for file.

INTEGER clientIndex !index into client list
CHARACTER*136 Buffer(17) !buffer for pipe i/o
CHARACTER dBuffer(2313) !buffer for pipe i/o
EQUIVALENCE(dBuffer,Buffer)
COMMON/serverstuff/clientIndex,dBuffer

DATA dBuffer(2313)/0/


As you said, server.for is included in some of the other files, though it is a global variable, serverstuff is giving redecleration problem when linking libraries. How can i split that COMMON data in such a way that, it should include in all required files and should not give redecleration error??

clientindex and dBuffer are using in C language piping calls(PipeRead and PipeWrite) which are called from fortran.

Thanks in advance..

If server.for is only to be used as an include file maybe you could try renaming it to server.inc (or something similar - some people prefer server.fi for example). Change all of your "include server.for" to "include server.inc"
{ I don't see how from the code you have shown, but it sounds like server.for is being compiled as a function/subroutine in its own right, every time - hence the multiple declarations }

A better option would be to make server.for a MODULE (instead of common) which you then USE in those routines that need that data.

module serverstuff
INTEGER clientIndex !index into client list
CHARACTER*136 Buffer(17) !buffer for pipe i/o
CHARACTER dBuffer(2313) !buffer for pipe i/o
EQUIVALENCE(dBuffer,Buffer)
...
end module serverstuff

Les

Les

Intel Software Network Forums Statistics

8470 users have contributed to 31601 threads and 100646 posts to date.
In the past 24 hours, we have 30 new thread(s) 113 new posts(s), and 159 new user(s).

In the past 3 days, the most popular thread for everyone has been gemm(A,A,A) like possible? The most posts were made to gemm(A,A,A) like possible? The post with the most views is Dear Steve, excuse me for a d

Please welcome our newest member kopernikus