首页 > 解决方案 > Maximum elements to loop over in fortran in linux and windows

问题描述

I am writing some parallel Fortran90/95 code and I just came across some thing I can't understand.

I work on a Toshiba laptop with 6Go RAM.

A minimal version of the encountered code causing issue is:

program main
  implicit none

  integer :: i
  integer, parameter :: n=500000
  real, dimension(n) :: A, B
  real :: som

  som=0

  do i =1, n
    A(i)= 1.0
    B(i)= 2.0
  end do

  do i=1, n
    som = som + A(i)*B(i)
  end do

  print *,"somme:", som
end program main

I then let vary the value of the parameter n.

My question is how one can explain that ubuntu, in spite of having far less memory available can handle 10 times more iterations ?

Is there anything I can do on the Windows size to make it able to handle more loop iterations ?

标签: windowsloopsubuntufortrancodeblocks

解决方案


根据 Rodrigo Rodrigues 的评论,我在编译器设置中又添加了一个标志:

-fmax-stack-var-size=65535

文档说默认值为 32767,但我认为代码块和 ubuntu 的本机 gfortran 中有不同的设置。


推荐阅读