简体   繁体   English

将Fortran输出传递给Matlab

[英]Pass Fortran output to Matlab

First of all, I am new to this area of using Fortran and Matlab together, so please bear with me if I did not see the very obvious. 首先,我是一起使用Fortran和Matlab的这个领域的新手,所以如果我看不到非常明显的地方,请耐心等待。

Here is my problem: I have a Fortran 90 code which will calculate 2 large complex matrices A and B . 这是我的问题:我有一个Fortran 90代码,它将计算2个大型复杂矩阵AB I write these matrices onto a file, read it in MATLAB and do some manipulations (solve for eigenvalues to be specific). 我将这些矩阵写到文件上,在MATLAB读取并做一些操作(解决特定的特征值)。 The problem with this method is that it takes very long time to write and read data even in binary format. 这种方法的问题在于即使以二进制格式写入和读取数据也要花费很长时间。 In some cases, the write and read operations are longer than actually solving the eigenvalue problem. 在某些情况下,写入和读取操作比实际解决特征值问题要长。

So, is there anyway I can directly pass the matrices generated by my Fortran 90 code to MATLAB without having to write and read? 因此,无论如何,我可以直接将我的Fortran 90代码生成的矩阵传递给MATLAB,而不必进行读写操作吗?

I have read about call system in Fortran but it doesn't seem to pass any arguments. 我已经阅读了有关Fortran中的call system ,但似乎没有传递任何参数。

If you have performance problems you might want to calculate the Eigenvalues in Fortran (by using LAPACK for example as Vladimir F already stated in the comments). 如果您有性能问题,则可能需要在Fortran中计算特征值(例如,使用LAPACK作为注释中已经说明的Vladimir F)。 However, instead of starting you Fortran program and trying to pass the matrices to Matlab you could call your Fortran program/your Fortran functions/subroutines/matrices/pointers from Matlab. 但是,不必启动Fortran程序并尝试将矩阵传递给Matlab,您可以从Matlab调用Fortran程序/ Fortran函数/子例程/矩阵/指针。 You would have to rewrite parts of your program but then you could use the Fortran Matrix Library API . 您必须重写程序的某些部分,然后才能使用Fortran Matrix Library API (Basically using mex as High Performance Mark mentioned in the comments) (基本上使用mex作为注释中提到的高性能标记)

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

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