I have a data file containing over 100 years of high, low, and average temperature data which I want to read-in and assign to variables of ddt "temps."
type temps
integer :: dates, hi, lo, av
end type temps
So each date will have the three temperature values assigned to it for easy access. I need to store these data, however, and so I was going to create an array of length determined by first reading through the file and counting the lines. The problem is, I can't define an array of my derived type with a variable length...
length = 0
do
read(99,*,end=1)dates
length = length + 1
enddo
1 rewind(99)
type(temps) :: array(length)
The error at the command line is:
type(temps), pointer :: array(length)
1
Error: Unexpected data declaration statement at (1)
In reading my downloaded manual "Fortran 95," Martin Counihan, I see that I may need to use a pointer, or an array pointer? This is where I get confused... Should the pointer be defined as type "temps" or the target or both? Also, is my methodology ideal for the task?
Thanks for any insight!
Dave
type temps
integer :: dates, hi, lo, av
end type temps
So each date will have the three temperature values assigned to it for easy access. I need to store these data, however, and so I was going to create an array of length determined by first reading through the file and counting the lines. The problem is, I can't define an array of my derived type with a variable length...
length = 0
do
read(99,*,end=1)dates
length = length + 1
enddo
1 rewind(99)
type(temps) :: array(length)
The error at the command line is:
type(temps), pointer :: array(length)
1
Error: Unexpected data declaration statement at (1)
In reading my downloaded manual "Fortran 95," Martin Counihan, I see that I may need to use a pointer, or an array pointer? This is where I get confused... Should the pointer be defined as type "temps" or the target or both? Also, is my methodology ideal for the task?
Thanks for any insight!
Dave