- #1
twomsta
- 4
- 0
Hi folks,
To begin with, I have no past programming experience and have just begun to teach myself programming in FORTRAN 95 and I've hit a wall. I'd be very grateful for any assistance here.
I have around 150 text files with three columns of data (I have attached one as an example, and included as my code so far). Essentially, my aim is to normalize all the precipitation data values in the far right column. But to begin with I have written some code to learn the basics and familiarize myself with programming. So far the code counts how many rows of data are in the text file before using that number to limit how many rows are read (I believe so anyways... as I was having issues with the output when FORTRAN tried to read beyond the length of the text file). No doubt my code so far is unconventional as it was a bit of guessing and modifying, but so far it has done what I wanted.
My question comes down to this:
How exactly do I work with the data values read in as 'prcp', in such a way that I can calculate the mean, standard deviation and eventually the z-score. I assume I need to define an array or dimensions of some sort?
I have read and attempted many tutorials, but has left me a bit lost...Thanks for any help!
To begin with, I have no past programming experience and have just begun to teach myself programming in FORTRAN 95 and I've hit a wall. I'd be very grateful for any assistance here.
I have around 150 text files with three columns of data (I have attached one as an example, and included as my code so far). Essentially, my aim is to normalize all the precipitation data values in the far right column. But to begin with I have written some code to learn the basics and familiarize myself with programming. So far the code counts how many rows of data are in the text file before using that number to limit how many rows are read (I believe so anyways... as I was having issues with the output when FORTRAN tried to read beyond the length of the text file). No doubt my code so far is unconventional as it was a bit of guessing and modifying, but so far it has done what I wanted.
My question comes down to this:
How exactly do I work with the data values read in as 'prcp', in such a way that I can calculate the mean, standard deviation and eventually the z-score. I assume I need to define an array or dimensions of some sort?
I have read and attempted many tutorials, but has left me a bit lost...Thanks for any help!
Code:
program readmet
implicit none
character(6):: date !I only need the year and month
integer :: endd, period, Nlines
real :: prcp
print*, 'Reads in monthly rainfall values from bureau station data'
!Now calculate the number of rows located in text file (nlines)
Nlines=0
open (5, file='Tprcphq.097091.month.txt')
do
read (5,*,END=10)
nlines=nlines+1
end do
10 close (5)
open (6,file='metout.txt')
write(6,*)' YYYYMM, precipitation (mm)'
write (6,*)'______________________________________________________'
open (5,file='Tprcphq.097091.month.txt')
read (5,*)!read header
do period= 2, nlines
read (5,*)date,endd, prcp
write (6,*) date, prcp
print *, date, prcp
end do
end program readmet