How can I store values for every iteration in FORTRAN 90 using arrays?

  • Context: Fortran 
  • Thread starter Thread starter Milentije
  • Start date Start date
  • Tags Tags
    Array Fortran
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 3K views
Milentije
Messages
47
Reaction score
0
Well the issue here is that I will have 21 numerical values written into one array,but then goes iterative procedure and get 21 values for model 2.How to write l(m0),l(m1)?I will need these arrays later for calculations.
 
Physics news on Phys.org
I don't understand what you're asking. It looks like you have two arrays, each with 21 values. What do you mean "how to write l(m0), l(m1)"? What are m0 and m1? Are you asking about what sort of WRITE statement you need to use? If so, show us the kind of output you are trying to get.
 
Well the problem is iteration,how to allocate l.Part of the code:
call version3_solve_mt2d_directsens
dmfnorm= (sum(dmf(1:20,1:4)**2))
write(*,*)dmfnorm
rewind(214)
call readsens
ist=transpose(sens)
rewind(17)
call readwd
wd2=matmul(wd,wd)
ftw=matmul(ist,wd2)
p=matmul(ftw,dmf)
rewind(18)
call readwm
wm2=matmul(wm,wm)
wm3=alpha*wm2
rewind(222)
call deltard
q=matmul(wm3,dlm)
l=p+q
This will repeat for every model but I need to allocate l,and to use it later.
 
do i=1,iter
l(nc)=l(nc,iter)
end do
I tried the above but it doesn't work.l is vector dimension 21,every iteration gives me l.I do not know the number of iterations.How to store l for every iteration?
 
Milentije said:
do i=1,iter
l(nc)=l(nc,iter)
end do
I tried the above but it doesn't work.l is vector dimension 21,every iteration gives me l.I do not know the number of iterations.How to store l for every iteration?

In the loop above, the loop counter is i. nc is not defined and is not a function of i. You appear to have one single dimensional array l and a two dimensional array, also called l. Arrays must have consistent dimensions. Until you work out these problems, your program will not work.