0

I was having a stack overflow error in a fortran code compiled with fortran compiler 2013 and VS2010 under windows 7. I first try to set HeapArrays=0 in Project Properties ->Fortran -> Optimization -> Heap (Allocates temporary arrays of size n in the heap rather than in the stack). In that way all the arrays should move to the heap. However, nothing changed and the stack overflow error was still there. Then I added the flag /stack:2000000 in the Link Options and now everything runs smoothly. Why HeapArrays=0 does not work? I have a bunch of character*2650 declarations, both in the main code and in subroutines. Is it possible the declarations in the main code are not considered "temporary arrays" ? The stack overflow error shows up right at the beginning.

EDIT: this is my declaration in the main program. I have similar ones (but shorter ) in subroutines:

character*2560 DOScallINV,FORMdosCALLtxt,FORMdosCALLinv,filenam,FILEinv,provSTR,FMTtimeMETEO,&
            TIMEstring,fmtGRID,fmtTIMEstring,FMTdataMETEO,WORKINGdir,path,DIRgribs,PATHgribs,&
            DIRresultsRUN,PATHoutput,previousDIR,filePATH,PATHresultsRUN,PATHinputD3D,textFILE,&
            newLINE,textFILE1,textFILE2,PATHlogs,LOGfile,LOGdir,ilineTXT,message,PATHresultsREST,&
            LastRUNfolder,PATHobs,PATHopenda,PATHresultsRUNm1,workworkWITHnum,pathSTOBS,pathSTMOD,pathALG,&
            toBEfound,COLLECTdirect,COLLECTdirectLOC,PATHwork,filePATHtot,filePATHlong,stringCAL,string,&
            pathNM,filePATH_d3model,CDstring,toBEadded,stringCALini,filePATH_d3wrapper,fileWIND,dudFILE,stringL,stringU,fileWINDcal,&
            PATHweb,pathREGR,fileWEB,PATHfileANALYSIS,threadFILE,threadFILEcopy
Millemila
  • 1,612
  • 4
  • 24
  • 45
  • 1
    Where is your code? Which particular temporary arrays do you believe are responsible for the overflow? – Vladimir F Героям слава Apr 07 '16 at 08:59
  • In your other question http://stackoverflow.com/questions/36470055/can-a-stack-overflow-be-sometimes-misinterpreted-as-an-access-violation you are speaking (not very clearly, show the code!) about large characters. Why would HeapArrays affect them? They are not arrays. – Vladimir F Героям слава Apr 07 '16 at 09:02
  • Well I already wrote that I declared a bunch of character*2650. I was especting that a long character*2650 was considered in the same way of an array... ok its a scalar string but memory-wise it can take any amount of memory. I think it is not that obvious and it is not explained in the help. I added the declaration but I dont see how that would help. – Millemila Apr 07 '16 at 10:06
  • If it does not change the meaning of the program you could declare them as `save`. It might help. – Vladimir F Героям слава Apr 07 '16 at 10:12
  • Also see http://superuser.com/questions/340239/how-to-increase-stack-size-permanently-on-windows-7 – Vladimir F Героям слава Apr 07 '16 at 10:15
  • Mmm thanks its a good hint to use save... That moves everything to the heap.... Anyways if you write a nice short answer it would be nice and helpful for everybody and I will accept it. Its not obvious at all that long string are not affected by the HeapArrays option. At least not for me. And also the save trick is nice. Also it would be nice to comment on possible performance advantages of one approach or one other (using save and therefore moving to the heap or increasing the stack). I added in the title "for long scalar strings". Thanks. – Millemila Apr 07 '16 at 10:25
  • Mmm seems like save does not work for variables in the main program. I still have stack overflow. You can just try a minimal example with that declaration i posted (you need to progressively increase 2560 until you overflow). Save does not fix it. – Millemila Apr 07 '16 at 11:15
  • well I would just use /stack:2000000 for now since it works. looks like there is not a easy way to put it in the heap. – Millemila Apr 07 '16 at 11:19
  • I can't reproduce your problem on Linux. I would really ask Intel for help. – Vladimir F Героям слава Apr 07 '16 at 11:24

0 Answers0