C C PURPOSE: C Read in the location of the Parker Solar Probe and the date it's C at that location. C C INPUTS: C None C C OUTPUTS: C npoints = integer, number of locations that were read from the C file. C date = real, dimension(2, npoints), row 1 = year, C row 2 = day of year C coords = real, dimension(3, npoints), row 1 = radius (AU), C row 2 = SE_LAT, row 3 = SE_LON C C DEPENDENCIES: C None C C NOTES: C This assumes the data starts on the fourth line of the file, and C that the first three lines are headers. Thus, we will start C reading the data on the fourth line. C C VARIABLES: C nmax = integer, maximum number of points that will be C read from the file. C C DATE: C February 13, 2020 @ 1:03 PM C C AUTHOR: C Luke Cota C subroutine read_locations(nmax, infile, npoints, date, coords) implicit none integer, parameter :: INUNIT = 10 integer :: io character(len=*) :: infile integer, intent(in) :: nmax integer, intent(out) :: npoints real, dimension(2,nmax), intent(out) :: date real, dimension(3,nmax), intent(out) :: coords infile = trim(infile) c print *, 'Reading locations from file: ', infile open(unit = INUNIT, file = infile, action = 'read', iostat = io) if (io .ne. 0) then print *, 'ERROR: Cannot open file "', infile, '"' stop end if C Reading in the first 3 lines. They are not used. read(INUNIT,*) read(INUNIT,*) read(INUNIT,*) npoints = 1 do while (io .eq. 0) read(INUNIT,*,iostat=io) date(1,npoints), date(2,npoints), & coords(1,npoints), coords(2,npoints), coords(3,npoints) if (npoints .eq. NMAX) then print *, 'The number of data points in file: ', infile print *, 'has exeeded the max number (NMAX) that can be' print *, 'read. See subroutine Extractdvd to' print *, 'increase NMAX, and read more values' exit end if npoints = npoints + 1 end do npoints = npoints - 1 close(INUNIT) return end subroutine read_locations