简体   繁体   English

如何结合Fortran77和Fortran90应用程序? MPI,PVM还是其他方式?

[英]How to couple Fortran77 and Fortran90 applications? MPI, PVM or another way?

I need to couple two codes ( one is in Fortran77 and the other in Fortran90 ) which have to be controlled by a daemon and being able to pass information between them. 我需要耦合两个代码(一个在Fortran77中,另一个在Fortran90中),这些代码必须由守护进程控制并能够在它们之间传递信息。

I have been searching and two possible options are PVM or MPI. 我一直在寻找,两种可能的选择是PVM或MPI。 The problem is that I need to compile them separately, any ideas? 问题是我需要单独编译它们,任何想法?

MPI is well adapted to the SPMD paradigm (Single Program / Multiple data). MPI非常适合SPMD范例(单程序/多数据)。 If you want to couple 2 different binaries, MPI is probably not the best tool. 如果你想结合两个不同的二进制文件,MPI可能不是最好的工具。 Inter-process communication is more like what you want to do. 进程间通信更像是您想要做的事情。 In Linux, if you stay on the same machine, you can use named pipes (see man mkfifo ) and you can transfer your data using Fortran I/O calls. 在Linux中,如果你停留在同一台机器上,你可以使用命名管道(参见man mkfifo ),你可以使用Fortran I / O调用传输数据。 Another possibility if you want to communicate between different machines is to use ZeroMQ for example, and there exists a Fortran binding . 如果要在不同机器之间进行通信,另一种可能性是使用ZeroMQ ,并且存在Fortran绑定

The simplest way is using POSIX sockets - but you will need to do data serialization/deserialization and it is pretty slow in general. 最简单的方法是使用POSIX套接字 - 但是你需要进行数据序列化/反序列化,而且它通常很慢。 So I would not recommend using sockets. 所以我不建议使用套接字。

Technically MPI can work. 从技术上讲,MPI可以工作。 If you can use MPI 2.0 compliant library then you can use the client-server mechanism implemented there. 如果您可以使用MPI 2.0兼容库,那么您可以使用在那里实现的客户端 - 服务器机制。 Look at the documentation for MPI_Open_port and MPI_Comm_connect . 查看MPI_Open_portMPI_Comm_connect的文档。 The first one will give you the port name that you will need to pass this name to the client somehow. 第一个将为您提供端口名称,您需要以某种方式将此名称传递给客户端。 One option is to use name publishing but it may not work with any MPI library. 一种选择是使用名称发布,但它可能不适用于任何MPI库。 The other option is to share it using some other mechanism (socket connection, file system or anything else). 另一种选择是使用其他机制(套接字连接,文件系统或其他任何机制)共享它。

But, in fact, I still do not see the reason why you should compile these two apps separately (unless there is a licensing issue) - you can just compile them into one package (I anticipate some code change but it is minor) and then run them as one app. 但是,事实上,我仍然没有看到你应该单独编译这两个应用程序的原因(除非存在许可问题) - 你可以将它们编译成一个包(我预计会有一些代码更改,但它很小)然后将它们作为一个应用运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM