[Wien] Fortran 90 bug (?) causes Segmentation fault in DSTART (doreallocate)

Hong Jiang jiang at fhi-berlin.mpg.de
Tue Mar 3 08:54:38 CET 2009


I think the problem is caused by unintentional use of a huge temporary 
array. In the code     
    hilfsfeld(1:min1,1:min2)=tf(1:min1,1:min2)
when hilfsfeld and tf have different dimensions and the subarray 
tf(1:min1,1:min2) is not contiguous in memory, then an additional 
temporary array of min1*min2 size is required to perform this 
operation.  For large cases, this requirement may fail, leading to a 
Segmentation fault.
A much safer way is probably like

    do j = 1 , min2
       hilfsfeld(1:min1,j)=tf(1:min1,j)
    end do

  -Hong

Oleg Rubel wrote:
> Dear Wien2k Users and Developers,
>
> I have got a segmentation fault error in DSTART while attempting to initialize a surface structure. I use WIEN2k_08.3 (Release 18/9/2008) compiled with Intel Fortran (version 11.0) using the following options:
> FOPT     = -FR -mp1 -w -prec_div -pc80 -pad -align -DINTEL_VML -traceback
> FGEN     =
> LDFLAGS  = $(FOPT) -L/act/intel/mkl/10.1.0.015/lib/em64t -i-static
>
> The segfault takes place at 'module.f' in  'module reallocate' in line
>
>     hilfsfeld(1:min1,1:min2)=tf(1:min1,1:min2)
>    
> I was able to fix the error by changing to an old fashion
>
>     integer*4 :: i, j
>     ...
>     do i = 1 , min1
>        do j = 1 , min2
>            hilfsfeld(i,j)=tf(i,j)
>        end do
>     end do
>
> for all instances 'hilfsfeld(1:min1,1:min2)=tf(1:min1,1:min2)' and 'hilfsfeld(1:min1)=tf(1:min1)' in module.f
>
> It is interesting that the error shows up only for relatively large cases. (In my case min2 = 2507459).
>
>
> Sincerely,
>
> Oleg Rubel
>
> --
> Oleg Rubel, PhD
> Thunder Bay Regional Research Institute
> 290 Munro St
> Thunder Bay, ON
> P7A  7T1, Canada
> Phone: +1-807-7663350
> E-mail: rubelo at tbh.net 
> Homepage: http://www.staff.uni-marburg.de/~rubel/ 
> _______________________________________________
> Wien mailing list
> Wien at zeus.theochem.tuwien.ac.at
> http://zeus.theochem.tuwien.ac.at/mailman/listinfo/wien
>   


-- 
-------------------------------------------------------------------------
 Dr Hong Jiang
 Theory Department               + Phone: ++49-30-8413 4833       
 Fritz-Haber-Institut der MPG    + Fax: ++49-30-8413 4701 
 Faradayweg 4-6                  + E-mail: jiang at fhi-Berlin.mpg.de
 D-14195 Berlin,German           + Homepage: w3.rz-berlin.mpg.de/~jiang



More information about the Wien mailing list