View previous topic :: View next topic |
Author |
Message |
star2066
Joined: 27 Jan 2015 Posts: 19
|
Posted: Wed Mar 25, 2015 4:10 pm Post subject: How to make done variable getting reset between the runs? |
|
|
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. |
|
Back to top |
|
 |
star2066
Joined: 27 Jan 2015 Posts: 19
|
Posted: Wed Mar 25, 2015 4:19 pm Post subject: |
|
|
I use a "stupid" way to do it . Setting every variable = 0 before the main program. Is there a simple way to do it? |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Wed Mar 25, 2015 11:47 pm Post subject: |
|
|
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
Code: |
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
|
|
|
Back to top |
|
 |
|