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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

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