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

  • Thread starter Thread starter Milentije
  • Start date Start date
  • Tags Tags
    Array Fortran
AI Thread Summary
The discussion revolves around the challenge of managing and storing iterative results in arrays within a programming context. The user has two arrays, each containing 21 numerical values, and seeks guidance on how to effectively allocate and store results from iterative calculations for later use. Key points include confusion over how to write and manage the arrays, specifically regarding the variables l(m0) and l(m1), and the need for a proper WRITE statement. The user is attempting to store the results of a calculation involving matrix operations and is struggling with the implementation of a loop that should allocate values to the array l for each iteration. There is an emphasis on the need for consistent array dimensions, as the user is facing issues with the loop counter and the definition of variables. The discussion highlights the necessity of clarifying array dimensions and ensuring that the program logic aligns with the intended data structure to achieve the desired results.
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.
 
Technology 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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.

Similar threads

Replies
13
Views
3K
Replies
8
Views
3K
Replies
5
Views
3K
Replies
21
Views
3K
Replies
7
Views
3K
Replies
3
Views
4K
Back
Top