0

i have an issue about filling a bidimensional array in Fortran90. in my program I extract different sets of random numbers and check them as uncertainties to my measurements ustar and Tstar, and i get uerr and terr. Now I want to put uerr and terr in a two-dimensional array because then I have to repeat this procedure n times to get different dataset (the Monte Carlo method for the estimation of errors). How do I assign uerr and terr to my array? And how do I iterate the process n times each time you run the program? I tried giving my array "set" the indexes r and c but at compile I get:

Warning: Extension: REAL array index at (1)

i read ustar and tstar from an input file, the code is below:

program stimerr
 implicit none

 character(len=12) filein,fileout
 integer,dimension(1) :: seed = (/4/)
 real, dimension(2) :: num
 integer :: n,h,i
 real, dimension(24,2) :: set 
 real :: pi = 3.14159
 real :: g1,g2,ustar,tstar,uerr,terr

 write(*,'(2x,''File di input .......''/)')
 read(*,'(a12)') filein
 open(unit=120,File=filein)

 set = 0.

 call init_random_seed ()
  do n=1,24
  read(120,*) h,ustar,tstar
  call random_number(num)

  g1 =(sqrt(-2*log(num(1)))*(cos(2*pi*(num(2)))))/10.
  g2 =(sqrt(-2*log(num(1)))*(sin(2*pi*(num(2)))))/10.

  uerr = ustar + g1
  terr = tstar + g2

  write(*,*) set(uerr,terr)


  enddo


close(120)



end program stimerr
  • The error seems self explanatory, you are trying to use real variables as array indices. the indices to `set` should be like `set(n,1)` , `set(n,2)`. You never assign anything to set before you try to write it by the way. Very unclear what you are trying to do. – agentp Nov 24 '14 at 17:41
  • While I agree with the general thrust of your comment @agentp the line `set = 0.` does assign a value to the elements of `set`. – High Performance Mark Nov 24 '14 at 21:18
  • oh thanks, i corrected those lines with set(n,:) = uerr set(:,n) = terr and ask to write the array "set" but now it prints 24 times the same values for every loop. How can i solve this problem? – Alessio De Luca Nov 25 '14 at 09:15
  • Use the `fortran` tag if you want to get more attention. Use `fortran90` in addition if you have something specific to this version what cannot be found in later ones or some other particularity. – Vladimir F Героям слава Nov 25 '14 at 14:53

0 Answers0