Using Matlab functions in Fortran -

Click For Summary
SUMMARY

The discussion focuses on integrating MATLAB functions into existing Fortran code to solve large sparse matrix equations, specifically the Ax=b system, where A is a 20000x20000 matrix. The user has successfully utilized MATLAB's 'bicgstab' command for single iterations but seeks a method to automate this process for multiple iterations while generating the vector 'b' in Fortran. The conversation highlights the challenges of MATLAB-Fortran communication, emphasizing that while using Fortran routines in MATLAB is straightforward, the reverse is complex. The user aims to leverage MATLAB's built-in functions for efficiency without extensive learning.

PREREQUISITES
  • Understanding of sparse matrix operations in numerical methods
  • Familiarity with Fortran programming, particularly in numerical computations
  • Basic knowledge of MATLAB functions, specifically 'bicgstab' and 'luinc'
  • Experience with file I/O operations between Fortran and MATLAB
NEXT STEPS
  • Research MATLAB's capabilities for handling large sparse matrices
  • Explore MATLAB's 'bicgstab' command for iterative solutions in depth
  • Investigate methods for efficient data exchange between Fortran and MATLAB
  • Learn about MATLAB's built-in functions for preconditioning and matrix manipulation
USEFUL FOR

This discussion is beneficial for numerical analysts, Fortran developers looking to enhance their applications with MATLAB's capabilities, and researchers working with large sparse systems in computational mathematics.

confi999
Messages
18
Reaction score
0
Hello,
My work is on numerical techniques which require to solve sparse matrices etc. All my work is in fortran and I have almost no skill in Matlab.But I have just realized that Matlab can do some computations quite easily with its built-in functions and I want to take advantage of this. I have no time to learn Matlab deeply or work on matlab-fortran communication (very much off-focus issues and have deadline soon)

Some details:
I need to solve Ax=b system where A is very large and sparse matrix (20000x20000 or more). At every time step (iteration) I need to solve this system, get 'x' and reuse it for further computation in that step. [A] is fixed and formed before the iteration begins - but vector 'b' changes at every iteration. So in the iteration -- i) vector 'b' is formed, ii) solve Ax=b to find 'x' iii) use many other (explicit algebraic) equations to calculate some other values / fields (magnetic fields) iv) save field values for that step and move to the next step. Then these steps are repeated once and again. I am doing steps i), iii), iv) in fortran and want to do step ii) in matlab. Actually I have the whole code written in fortran but want to do some analysis by just doing the step ii) in Matlab. Can you please advise me if that is possible and if, how can I do that?

I have tried Matlab to solve Ax=b just for a single iteration. That means, I could read matrix [A], an instance of vector 'b' in MATLAB (after saving them in files from fortran). Then I solved them in Matlab command window using 'bicgstab' command (also used 'luinc' preconditioner etc, did some matrix blocking etc). But I need to repeatedly do this for the whole system and also calculate 'b' vector in fortran using the obtained solution. Can you please advise me on this. Thank you so much.
 
Physics news on Phys.org
Using Fortran routines in Matlab is fairly straight forward, the opposite isn't true at all. I'd convert over to Matlab because of the functionality and it won't take too long to get up to speed.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K