Hi Guys,
After the great and encouraging help that i received from my last post....
I have written a program that does a fourier transform on input Time Histories. As a novice (but keen learner) I'm very proud of my progress so far learning Fortran. The program works great so far but it is only applicable to TH's of the same length as I have specified the array size. The TH's can vary in length therefore I would like Fortran to be able to cope with this.
The step I need to take (i think) are:
1. Define a 1D Array of unknown size, f)
2. Open the Text file containing the TH (single column containing real numbers)
3. Read the Text file
4. Allocate it to the 'undefined size' array, f
I therefore have produced the following code:
Note: This is just and extract from my overall program to illustrate the problem (hence why I have print *, so i can see if it worked). In my head (thinking like an engineer, not a programmer, probably where I am going wrong) this seems to make sense, as set out by the bullet points at the start. Hopefully this helps all the experts understand what I am thinking, and what my approach is.
I am a keen learner so any help would be appreciated. PS feel free to use layman's terms, as an engineer it often helps my understanding, learning Fortran for this program is not a quick fix but I have a general interest in properly learning the language
Thanks for your time,
Martin
After the great and encouraging help that i received from my last post....
I have written a program that does a fourier transform on input Time Histories. As a novice (but keen learner) I'm very proud of my progress so far learning Fortran. The program works great so far but it is only applicable to TH's of the same length as I have specified the array size. The TH's can vary in length therefore I would like Fortran to be able to cope with this.
The step I need to take (i think) are:
1. Define a 1D Array of unknown size, f)
2. Open the Text file containing the TH (single column containing real numbers)
3. Read the Text file
4. Allocate it to the 'undefined size' array, f
I therefore have produced the following code:
Code:
program Freq
implicit none
real, allocatable :: f(:)
open (unit=1, file='C:\Users\Martin\Desktop\SRS\Freq.txt', status='old', action='read')
read(1, *) f
allocate (f(:))
close(1)
print *, f
end program Freq
Note: This is just and extract from my overall program to illustrate the problem (hence why I have print *, so i can see if it worked). In my head (thinking like an engineer, not a programmer, probably where I am going wrong) this seems to make sense, as set out by the bullet points at the start. Hopefully this helps all the experts understand what I am thinking, and what my approach is.
I am a keen learner so any help would be appreciated. PS feel free to use layman's terms, as an engineer it often helps my understanding, learning Fortran for this program is not a quick fix but I have a general interest in properly learning the language
Thanks for your time,
Martin