So your tests show: 1. "Shared library in FORTRAN + MPI executable in FORTRAN" works. 2. "Shared library in C++ + MPI executable in FORTRAN " does not work.
It seems to me that the symbols in C library are not really recognized by FORTRAN executable as you thought. What compilers did yo use to built OpenMPI? Different compiler has different convention to handle symbols. E.g. if there is a variable "var_foo" in your FORTRAN code, some FORTRN compiler will save "var_foo_" in the object file by default; if you want to access "var_foo" in C code, you actually need to refer "var_foo_" in C code. If you define "var_foo" in a module in the FORTAN compiler, some FORTRAN compiler may append the module name to "var_foo". So I suggest to check the symbols in the object files generated by your FORTAN and C compiler to see the difference. Mi "Rajesh Ramaya" <rajesh.ramaya@e- xstream.com> To Sent by: "'Open MPI Users'" users-bounces@ope <us...@open-mpi.org>, "'Jeff n-mpi.org Squyres'" <jsquy...@cisco.com> cc 10/31/2008 03:07 Subject PM Re: [OMPI users] MPI + Mixed language coding(Fortran90 + C++) Please respond to Open MPI Users <users@open-mpi.o rg> Hello Jeff Squyres, Thank you very much for the immediate reply. I am able to successfully access the data from the common block but the values are zero. In my algorithm I even update a common block but the update made by the shared library is not taken in to account by the executable. Can you please be very specific how to make the parallel algorithm aware of the data? Actually I am not writing any MPI code inside? It's the executable (third party software) who does that part. All that I am doing is to compile my code with MPI c compiler and add it in the LD_LIBIRARY_PATH. In fact I did a simple test by creating a shared library using a FORTRAN code and the update made to the common block is taken in to account by the executable. Is there any flag or pragma that need to be activated for mixed language MPI? Thank you once again for the reply. Rajesh -----Original Message----- From: users-boun...@open-mpi.org [mailto:users-boun...@open-mpi.org] On Behalf Of Jeff Squyres Sent: vendredi 31 octobre 2008 18:53 To: Open MPI Users Subject: Re: [OMPI users] MPI + Mixed language coding(Fortran90 + C++) On Oct 31, 2008, at 11:57 AM, Rajesh Ramaya wrote: > I am completely new to MPI. I have a basic question concerning > MPI and mixed language coding. I hope any of you could help me out. > Is it possible to access FORTRAN common blocks in C++ in a MPI > compiled code. It works without MPI but as soon I switch to MPI the > access of common block does not work anymore. > I have a Linux MPI executable which loads a shared library at > runtime and resolves all undefined symbols etc The shared library > is written in C++ and the MPI executable in written in FORTRAN. Some > of the input that the shared library looking for are in the Fortran > common blocks. As I access those common blocks during runtime the > values are not initialized. I would like to know if what I am > doing is possible ?I hope that my problem is clear...... Generally, MPI should not get in the way of sharing common blocks between Fortran and C/C++. Indeed, in Open MPI itself, we share a few common blocks between Fortran and the main C Open MPI implementation. What is the exact symptom that you are seeing? Is the application failing to resolve symbols at run-time, possibly indicating that something hasn't instantiated a common block? Or are you able to successfully access the data from the common block, but it doesn't have the values you expect (e.g., perhaps you're seeing all zeros)? If the former, you might want to check your build procedure. You *should* be able to simply replace your C++ / F90 compilers with mpicxx and mpif90, respectively, and be able to build an MPI version of your app. If the latter, you might need to make your parallel algorithm aware of what data is available in which MPI process -- perhaps not all the data is filled in on each MPI process...? -- Jeff Squyres Cisco Systems _______________________________________________ users mailing list us...@open-mpi.org http://www.open-mpi.org/mailman/listinfo.cgi/users _______________________________________________ users mailing list us...@open-mpi.org http://www.open-mpi.org/mailman/listinfo.cgi/users