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 | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

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

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

# Fortran 90 Vs Matlab

**Physics Forums | Science Articles, Homework Help, Discussion**