C+ C NAME: C sort_ascii_line.f C PURPOSE: C Sort the ascci IPS input data into an ascending time series order. C C CATEGORY: C Sorting C CALLING SEQUENCE: C call sort_ascii_line(NL,NLMAX,IYRS,DOYS8,casciiln) C INPUTS: C NL integer length of the data set C NLMAX integer maximum possible length of the data set (must be 2*NL) C IYRS (NLMAX) integer Year of the data C DOYS8 (NLMAX) real*8 DOY of the data C casciiln(NLMAX) character*115 The ascii line to be sorted C C OUTPUTS: C IYRS (NLMAX) integer Year of the data C DOYS8 (NLMAX) real*8 DOY of the data C casciiln(NLMAX) character*115 The sorted line C C RESTRICTIONS: C To avoid having double arrays for each input parameter, the parameters are first placed into the array at its end, and then recopied C to the beginning of each array. This means each array needs to be double the length of the data set. This is checked and the C subroutine stopped with an error message if the inputs arrays are not double the data set values. C C PROCEDURE: C C MODIFICATION HISTORY: C 2014 B.Jackson (UCSD) C- subroutine sort_ascii_line(NL,NLMAX,IYRS,DOYS8,casciiln) C integer IYRS (NLMAX) real*8 DOYS8 (NLMAX) real*8 RA (NLMAX) ! Input dummy array to be loaded with times real*8 RV C character casciiln(NLMAX)*138 C if(NL*2.gt.NLMAX) then print *, 'The input arrays are not double the length of the data set. The sorting must stop.' stop end if C do I=1, NL RA(I) = dble(IYRS(I)) + DOYS8(I)/400.0d0 end do C call sortr8(1,NL,1,NL,RA) C do I=1, NL RV = dble(IYRS(I)) + DOYS8(I)/400.0d0 do J=1, NL if(RV.eq.RA(J)) then NLEND = NLMAX - NL + J C DOYS8 (NLEND) = DOYS8 (I) IYRS (NLEND) = IYRS (I) casciiln(NLEND) = casciiln(I) end if end do end do do I=1, NL NLEND = NLMAX - NL + I C casciiln(I) = casciiln(NLEND) DOYS8 (I) = DOYS8 (NLEND) IYRS (I) = IYRS (NLEND) end do return end