Silverfrost Forums

Welcome to our forums

How to make done variable getting reset between the runs?

25 Mar 2015 3:10 #15990

I want to repeat my main program 1000 times. Unfortunately, only few results is what I want. But if I do it one by one by hand. It's all right. I have almost 20 variable need to be reseted.

25 Mar 2015 3:19 #15991

I use a 'stupid' way to do it . Setting every variable = 0 before the main program. Is there a simple way to do it?

25 Mar 2015 10:47 #15995

You could put a do loop into your program that encloses the code you want repeated. That way it would run 1000 times and the variables would retain their value after each iteration. The initialisation of the variables could be outside the do loop. You could include logic in the code to reset selected variables when required, eg

 integer run
!
!  first initialise all variables for test 1
  ...
!
 do run = 1,1000
!
! first set up variables for this test
   if ( mod(run,50) == 1 ) then ! reset some variables every 50 tests
   ...
   end if
   if ( mod(run,10) == 1 ) then ! reset other variables every 10 tests
   ...
   end if
!
!  now carry out test
  ...
  end do
Please login to reply.