Hello.(adsbygoogle = window.adsbygoogle || []).push({});

I am trying to translate a program written in matlab to a fortran code and I have found out that the fortran code is slower. I couldn't believe it so I decided to do a simple program in fortran 90 and matlab in order to be sure. The code in matlab is:

function D2D()

Nx=2^11;

Ny=2^9;

Yr=ones(Ny,Nx);

for i=1:3000

Yr=Yr.*Yr;

end

'done'

end

and the code in fortran 90 is:

program D2D

IMPLICIT NONE

integer, parameter::NxL=11

integer, parameter::NyL=9

integer, parameter::Nx=(2**NxL) ! Grid size X

integer, parameter::Ny=(2**NyL) ! Grid size Y

INTEGER::i,IC,JC

complex*8, dimension(Ny,Nx):: Yr

DO i=1,3000

FORALL(IC=1:Ny,JC=1:Nx) Yr(IC,JC)=Yr(IC,JC)*Yr(IC,JC)

ENDDO

WRITE(*,*) 'done'

end program D2D

The fortran code is twice slower. Any idea why? What am I coding wrong in fortran?

thx.

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Fortran 90 Vs Matlab

Loading...

Similar Threads - Fortran Matlab | Date |
---|---|

[matlab-fortran] translate interpolation | Feb 10, 2014 |

Stella to fortran,matlab ecc | Apr 19, 2012 |

Loading Data in Matlab (or Fortran) | Aug 8, 2011 |

Fortran <-> Perl Wrapper<-> Matlab | Feb 8, 2011 |

MATLAB To FORTRAN Troubles (eig.m equivalent?) | Jun 7, 2010 |

**Physics Forums - The Fusion of Science and Community**