Silverfrost Forums

Welcome to our forums

Salford run-time library

14 Nov 2016 10:55 #18369

Hi all, I'm new Fortran user

I have the following error:

Salford run-time library. Re-link program with bigger stack value. (stack:reserve, commit)

Can someone help me? please!

I use a SO Windows 8.1 64bit with 4GB of ram.

Thanks for collaboration [/b]

14 Nov 2016 11:09 #18370

How big is your program? Can you post it here? If not then can you produce the failure in a small program?

You may need a larger stack size when linking but it may be a programming error.

14 Nov 2016 11:16 #18371

Quoted from PaulLaidler How big is your program? Can you post it here? If not then can you produce the failure in a small program?

You may need a larger stack size when linking but it may be a programming error.

How check the total size of the program?

This program calculate a matrix.

So, I tried with a small matrix and it is all correct but as soon as I insert a bix matrix 1000 rows per 1000 column the error above display.

14 Nov 2016 12:08 #18372

Quoted from AndreaFTN95 How check the total size of the program?

This is a basic task in using any operating system. In a command window, the DIR command will show you the size of the file. Or, in the Windows Explorer, highlight the file in question and right click to view the properties of the file.

14 Nov 2016 12:24 #18373

Quoted from mecej4

Quoted from AndreaFTN95 How check the total size of the program?

This is a basic task in using any operating system. In a command window, the DIR command will show you the size of the file. Or, in the Windows Explorer, highlight the file in question and right click to view the properties of the file.

you are right but my doubt is why the code invokes several files, however progrm.exe has a size of 80MB

14 Nov 2016 12:56 #18374

Quoted from AndreaFTN95 ... my doubt is why the code invokes several files, however progrm.exe has a size of 80MB The request in #2 was for, I think, information on the size of the source files, not the size of the EXE.

A short program may produce a huge EXE, or vice versa. Mostly, it is the presence of large saved arrays in the program that causes the EXE to be large. On the other hand, stack overflow is often caused by having large local arrays.

In order to troubleshoot the issue, it would be helpful to have access to the source code, if it is acceptable to you to make it available. If you do not wish to make the source code public, you can zip up the source files, load the zip file to a cloud service such as Dropbox, and pass along the download link in a private message to Paul. Otherwise, post the link in your reply.

You can only post source code in the forum if the size is about a hundred lines.

14 Nov 2016 1:15 #18375

I'm sorry but in this moment I can't post or sent privitly the source code, becase It is copyrighted.

I know that is difficult for you solve the problem without the source code.

The program works correctly, but when I increase the number or rows and column of matrix, It appears the error:

Salford run-time library. Re-link program with bigger stack value. (stack:reserve, commit)

So I think it is a problem of memory of pc, but I know if it possible change the setting of Fortran or Plato per increase the memory.

14 Nov 2016 1:25 (Edited: 14 Nov 2016 2:16) #18377

Try in command prompt after you have made your OBJ file

slink your.obj /stack:100000000

you may also add /3GB switch too

If not help that means you may have made some stupid error in array sizes. One-two arrays of the size (1000,1000) are easily bearable without modification of the stack.

Some here already use 64 bit compiler for super large sizes, no stack needed

14 Nov 2016 1:51 #18378

Quoted from DanRRight Try slink your.obj /stack:100000000

you may also add /3GB switch too

If not help that means you may have made some stupid error in array sizes. One-two arrays of the size (1000,1000) are easily bearable without modification of the stack.

Some here already use 64 bit compiler for super large sizes, no stack needed

Sorry, but I not understand what I will try with **slink your.obj /stack:100000000 ** I'm a new user and I'm not very practical.

I use a Plato 4.73 version Silverfrost Ltd 2016 and use this library salflibc.dll within the program folder (else it nor start)

and I use a CheckMate x32 becouse if use CheckMate x64 tthis error appears:

Compiling file: corretto-Bingham.for error 1205: - /CHECK is not available in FTN95/64 Compilation completed with no errors.

thanks again for the collaboration

14 Nov 2016 2:11 #18379

You can increase the stack available to your EXE by specifying the option /stack:<nnnnnnn> to the linker. If you are building inside Plato, look for a place to set the project options. Typically, you will have one place for specifying compilation options and another for linking options.

Alternatively, you can use the EDITBIN.EXE utility that is included in many Windows SDKS. This utility allows you to display and, optionally, change the stack size by directly editing the header of the EXE file.

If your program is already debugged, you can build using the 64 bit compiler by removing any /check and /opt options.

14 Nov 2016 3:57 #18381

Have you created a project in Plato or are you just directly building from one file?

14 Nov 2016 4:30 #18383

I download gFortran and loccate the path after I open a file .for in Plato and then I compile it.......it seems work correctly

I'm doing a complete test...but is very long time....If it is all correctly I will post the sucess tonight or tomorrow, else I will write again.

thanks again for your collaboration

14 Nov 2016 10:54 #18384

My advice is to avoid the use of the stack wherever possible, especially with large arrays. Stack overflow is an error that should be better managed, but isn't.

You should try to change your program so the arrays do not go onto the stack. You can do this by placing the arrays in COMMON or a MODULE, with a MODULE required if the arrays are allocatable.

!  program to have large arrays not on teh stack
module aaa
   real*8, allocatable :: a_array(:,:)
end module aaa

use aaa
   common /xyz/ b_array
   real*8 b_array(1000,2000)
   integer*4 n,stat
!
!  use b_array
   b_array = 1
   write (*,*) 'b_array has been used', b_array(1000,2000), size(b_array)
!
!  use a_array
   do n = 1000,8000,1000
     allocate (a_array(n,n),stat=stat)
     write (*,*) 'a_array set to',n,' stat=',stat
     a_array = n
     write (*,*) 'a_array size =',size(a_array)
     deallocate (a_array)
   end do
 end
17 Nov 2016 6:30 #18422

I dont have created the source code and I not know what is its logic....and I not very experting in programming.....

I belive that this codex is created with fortran 90, and I wont replece it whit a new version for work with more date.....

In this moment the source code is compiled, whit no error but the results from the work is not correct...Maybe is a problem of code program...but my dubit concer the envirovement of Fortran/PLATO.

it is possible chage some setting for improve the compiletion????

17 Nov 2016 6:39 #18423

You can recompile with the /check or /checkmate options. Your program will run much more slowly, but most errors will be trapped. You can fix the errors, and recompile without /check.

There is no magical compiler option to make the code give you correct results.

9 Jan 2017 5:58 #18684

Hi, I ran into a similar problem.

I can run my program under release mode, but cannot do it under checkmate mode.

My program involves generating a large random matrix. I can actually run my code under the checkmate mode if I reduce the size of the matrix. I prefer to use checkmate at this stage, is there any way I can solve this problem and run it under checkmate mode without changing the size of my matrix?

Thanks

Quoted from PaulLaidler How big is your program? Can you post it here? If not then can you produce the failure in a small program?

You may need a larger stack size when linking but it may be a programming error.

9 Jan 2017 10:42 #18685

How are you allocating the array for the matrix? If the array is a local automatic variable, you may be able to do better by making it an allocatable array.

In any case, some details regarding what your code looks like and what it is intended to do would be needed in order to offer suggestions on improving it.

9 Jan 2017 11:10 #18686

You have not indicated the size of the array or the method of allocation.

Here is a cleaner example of using an allocatable array. This works up to varying sizes, depending on the compile option selected in Plato. Checkmate32 : 923 mb works Debug Win32 : 1953 mb works Release Win32 : 1953 mb works Release x64 : 6866 mb + works ( with adequate virtual/physical memory )

!  program to have large arrays not on the stack 
 module aaa 
    real*8, allocatable :: a_array(:,:) 
 end module aaa 

 program test_a
 use aaa 
    integer*4 n,stat,mb 
! 
!  use a_array 
    do n = 1000,30000,1000 
      mb = ((n*n)/1024)*8/1024
!
      allocate (a_array(n,n),stat=stat) 
      if ( stat /= 0 ) then
        write (*,*) 'a_array set to',n,' stat=',stat 
        write (*,*) 'unable to allocate array',mb,' mb'
        stop
      end if
!
      a_array = n 
      write (*,*) 'a_array size =',mb,' mb is ok'
!
      call use_a_array ( a_array, n )
!
      deallocate (a_array) 
    end do 
  end program test_a

  subroutine use_a_array ( a_array, n )
    integer*4 n
    real*8    a_array(n,n)
  end subroutine use_a_array

Allocating an array in a MODULE is the best approach to solve your problem, although with Cheakmate, you will have smaller contiguous memory available. Compiling with Release x64 will give the largest array possible, although don't exceed your available memory.

John

10 Jan 2017 8:37 (Edited: 11 Jan 2017 7:38) #18687

rayla_lsy, Curious, have you tried my suggestion above about stack change? Sorry, trying to make 1 GB allocation for stack I made a mistake there missing one more zero. With that number which was only 100 MB my suggestion actually decreased default stack which is larger ~200MB.

So you can increase this number using try and fail method up to probably 1.2-1.6 GB

But allocatable option as mecej4 and JohnCampbell suggested is the best.

10 Jan 2017 4:24 #18688

Here is the program that I ran into trouble. The problem occurs when I trying to call subroutine that generates a random matrix.

I just read the later post, and I will try that. Thank you.

program test integer, parameter :: ikind_real = selected_real_kind(p=8 ) integer, parameter :: NP106 = 70695 real(kind = ikind_real) :: rcoeff_dist(NP106,28 )

call init_random_seed() n=28 call r8_normal_mn(rcoeff_dist,NP106,n) end program test

!======================================================================================================================================== !A subroutine to generate random variable from N(0,1) !========================================================================================================================================

subroutine r8_normal_mn(X,m,n) implicit none integer, parameter :: ikind_real= selected_real_kind(p=8 ) integer :: m,n, i,j real(kind = ikind_real), dimension(m,n) :: r1,r2 real, parameter :: r4_pi = 3.141592653589793E+00 real(kind = ikind_real), dimension(m,n) :: X

call psurand(r1,m,n) call psurand(r2,m,n)

do i = 1,m do j = 1,n X(i,j) = sqrt ( - 2.0E+00 * log ( r1(i,j) ) ) * cos ( 2.0E+00 * r4_pi * r2(i,j) ) end do end do return end subroutine r8_normal_mn

! ======================================================================================================================================== ! A subroutine to generate random vector for uniform distribution ! ======================================================================================================================================== subroutine psurand(X,m,n) implicit none integer :: m,n integer, parameter :: ikind_real = selected_real_kind(p=8 ) real(kind = ikind_real), dimension(m,n) :: X CALL RANDOM_NUMBER(HARVEST = X) END subroutine psurand

!======================================================================================================================================== ! A subroutine to generate seed !========================================================================================================================================

!We just need to regenerate the seed each time I am starting the program.

subroutine init_random_seed()

INTEGER :: i, n, clock INTEGER, DIMENSION( : ), ALLOCATABLE :: seed

CALL RANDOM_SEED(size = n) ALLOCATE(seed(n))

CALL SYSTEM_CLOCK(COUNT=clock)

seed = clock + 37 * (/ (i - 1, i = 1, n) /) CALL RANDOM_SEED(PUT = seed) DEALLOCATE(seed)

end

Please login to reply.