# Fortran vs Matlab Help

 Register Blogs Members List Search Today's Posts Mark Forums Read

 June 28, 2008, 18:05 Fortran vs Matlab Help #1 idee Guest   Posts: n/a Am having a problem with my code. Am doing simulation for a system of PDEs. I managed to get results using Matlab after ages of time. I decided to do the simulation in fortran. The question now: Is it necessarily that I will get the same numerical results? thanks

 June 28, 2008, 20:15 Re: Fortran vs Matlab Help #2 Paolo Lampitella Guest   Posts: n/a It's nearly impossible that you have the same numerical results but you should have some control over this, that is you should be able to control up to which digit the results will be the same (e.g. the tollerance of an iterative solver, the precision of the variables in fortran and so on)

 July 2, 2008, 11:48 Re: Fortran vs Matlab Help #3 Brendan Guest   Posts: n/a The code structure in Matlab and Fortran is very similar, Matlab is a great way to prototype code that you want to run in Fortran (which, in my experience, is much faster). You can pretty much change a Matlab code to Fortran using the find/replace option. Your results should be essentially the same but you will rarely get complete agreement. From experience the differences are around the order of machine accuracy (it's to do with the way that matlab and fortran deal with real numbers). One piece of advice - if you're trying to change a code from matlab to fortran be careful with the loop structure: Matlab: for I=1:10 ..... end Fortran: DO I=1,10 ....... ENDDO If you accidently use "I=1:10" in Fortran it means something entirely different. A good way to check your solution is to subtract your matlab solution from the fortran one and plot the results - if the difference is small (1e-14 ish) then your results are the same.

 July 2, 2008, 15:05 Re: Fortran vs Matlab Help #4 idee Guest   Posts: n/a Many thanks your support very much appreciated. I finally managed to get results it is the same behavior but there is a difference. In other words the fortran code was able to capture discontinuity, according to the method am using of course, in a better way and fast enough. May be am having problems with things from matlab to fortran e.g. R=zeos(k,2) R=ones(k,2) R=find(r1>=r2)........ w1=max(max(find(w3>w4))).... Many thanks for your help.

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post HaKu Main CFD Forum 0 July 16, 2009 15:35 Ally Main CFD Forum 4 July 12, 2007 03:51 ztdep Main CFD Forum 4 November 15, 2006 09:15 prasat Main CFD Forum 5 February 4, 2003 17:04 Wole F. Main CFD Forum 11 September 26, 2000 10:01

All times are GMT -4. The time now is 02:12.