Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Using Matlab functions in Fortran - need help

  1. Aug 11, 2009 #1
    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.
     
  2. jcsd
  3. Aug 11, 2009 #2

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Using Matlab functions in Fortran - need help
  1. Fortran - Functions (Replies: 0)

Loading...