C+ C NAME: C Read_ASHI_track.f C PURPOSE: C Read the ASHI track into a file C CATEGORY: C I/O C CALLING SEQUENCE: C call Read_ASHI_track(cWildASHI_T,nCar,JDCar,XCtest1,XCtest2,Dlimitu,DlimitL,NCoff,Radius, C & NLmax,NLmaxs,NL,N_IN,cvgfiles,SRCVG,SRCV,SRCVGsav,SRCVsav, C & IYRF,IREC,IYRS,DOYS8,DIST,XLS,XLL,XDL,XCE,XE,XC,YL,DDOBS) C C INPUTS: C Read_ASHI_track: C cWildASHI_T character location of the ACE2 input file C nCar integer dimension of JDCar C JDCar(nCar) integer start times (Julian days) of Carrington rotations C XCtest1 real modified Carrington variable for start of search C XCtest2 real modified Carrington variable for end of search C Dlimitu real upper density limit C DlimitL real lower density limit C NCoff integer JDCar(I) is the start of rotation NCoff+I C Radius real reference distance (AU) C C XElow real C XEhigh real C C NLmax integer max. # points read into arrays C NLmaxs integer max. # points read into small arrays C NL integer C C OUTPUTS: C NL integer # valid data points in arrays XC,YL,DD C SRC(NLmax) character*8 Character Source identifier C IYRF(NLmax) integer year of file from which observation was extracted (should be same as IYRS) C IREC(NLmax) integer record number on file IYRF C DOYS8(NLmax) real*8 time of observation: day of year (incl. fraction for time of day) C XDS (NLmax) real Sun-Earth distance C XLS (NLmax) real geocentric ecliptic longitude Sun C XLL (NLmax) real geocentric ecliptic lng(P)-lng(Sun) (deg) C XDL (NLmax) real geocentric ecliptic lat(P) (deg) C XCE (NLmax) real modified Carrington variable of sub-Earth point on Sun C XE (NLmax) real elongation (deg) (>0: East of Sun; <0: West of Sun) C XC (NLmax) real modified Carrington variable point P after traceback to C heliocentric distance Radius at speed VV C YL(NLmax) real heliographic latitude point P C DD(NLmax) real ACE Density (Np) C NSmax integer # data points saved in XCsav,YLsav C SRCsav(NSmax) character scratch arrays (used internally only), C IYRFsav(NSmax) integer C IRECsav(NSmax) integer C IYRSsav(NSmax) integer C DOYSsav(NSmax) real*8 C XDSsav (NSmax) real C XLLsav (NSmax) real C XDLsav (NSmax) real C XCEsav (NSmax) real C XEsav (NSmax) real C XCsav (NSmax) real C YLsav (NSmax) real C DDsav (NSmax) real C MODIFICATION HISTORY: C April-2009, Bernard Jackson (UCSD) C- subroutine read_ashi_track(cWildASHI_T,nCar,JDCar,XCtest1,XCtest2,Dlimitu,DlimitL,NCoff,Radius, & NLmax,NLmaxs,NL,N_IN,cvgfiles,SRCVG,SRC, & IYRS,DOYS8,XDS,XLS,XLL,XDL,XCE,XE,XC,YL,DD) real*8 JDCar(nCar), & JEpoch, & Doy8, & DOYS8(NLmax) ! Time: doy of year real*8 dLngSun, dLatSun, dDisSun integer IYRS(NLmax) real XDS (NLmax), ! Sun-Earth distance & XLS (NLmax), ! Ecliptic longitude Sun & XLL (NLmax), & XDL (NLmax), & XCE (NLmax), & XE (NLmax), ! Elongation point P & XC (NLmax), ! Carrington variable of Point P & YL (NLmax), ! Heliographic latitude of Point P & DD (NLmax) ! Solar wind density (Np) character cvgfiles(*)*11,SRCVG(NLmaxs)*115,SRC(NLmaxs)*9, C & cFile*80 /'acesw_2007.hravg'/ & cFile*80, & cWildACE2*(*), & cWildINSITU*80 C function iReadNagoyan8(iU,iFirst) character cMon*3, & cSrc*9,cSRCVG*66 C character cFmt41*41 /'(A9,3I2,F6.2,F5.2,I4,I5,I4,3I5,I4,F8.5)'/ character cFmt30*30 /'(A9,3I2,F6.2,28X,I5,4X,F8.5)'/ C character cFmt24*24 /'(I4,2I3,I4,23X,2F11.1)'/ character cFmtA30*30 /'(I4,2I4,10X,E12.4,24X,E12.4)'/ external EARTH8 include 'sun.h' include 'dirspec.h' call Julian(1,iYr1,Doy,JDCar(int(XCtest1)),JEpoch) write (*,'(A,F9.4,A,I5)') 'In readace28_d. The in-situ analysis begins after Doy',Doy,' of',iYr1 call Julian(1,iYr2,Doy,JDCar(int(XCtest2+1.0)),JEpoch) write (*,'(A,F9.4,A,I5)') 'In readace28_d. The in-situ analysis ends before Doy',Doy,' of',iYr2 Iyrno = 1 if(iYr1.ne.iYr2) Iyrno = 2 I = 0 Ifst = 1 do N=1,Iyrno if(Ifst.eq.1) iYr = iYr1 if(Ifst.eq.2) iYr = iYr2 write (*,*) cWildACE2 cWildINSITU = cWildACE2 III = iSetFileSpec(cWildINSITU) III = iGetFileSpec(FIL__NAME,FIL__TYPE,cFile) iFile = index(cFile, cWildChar(:4)) III = 1 call Str2Flt_Int(.TRUE.) call Str2Flt(cFile(iFile:iFile+4-1),III,0) iFile = index(cWildINSITU,cWildChar(:4)) cFile = cWildINSITU III = Int2Str(iYr,cFile(iFile:iFile+4-1)) write (*,*) cFile open (13, file=cFile,status='old',recl=120,access='sequential',form='formatted',iostat=iReadACE2) if(iReadACE2.ne.0.and.Ifst.eq.2) then close(13) return ! assume if no file esists on second year, the second year has not yet happened end if C print *, cfile do II=1,10000 read (13,cFmtA30,iostat=iReadACE2) iY,iDoy,iUT,DEN,VEL if(iReadACE2.eq.0) then call DATE_DOY(1,iY,cMon,iM,iD,iDoy) cSrc = 'ACE L2 ' UT = float(iUT) iVEL = nint(VEL) write(cSRCVG(1:66),cFmt30) & cSrc,iY-2000,iM,iD,UT,iVEL,DEN C & cSrc,iY,iM,iD,UT,DP,iHLA,iHLO,iGLA,iGLO,iROT,iVEL,iDVEL,GVAL if (DEN.ge.DlimitL.and.DEN.le.Dlimitu) then ! If density inside limits, accept nYr = iY cMon = ' ' ! Make sure iM is used call DATE_DOY(0,nYr,cMon,iM,iD,iDoy) Doy8 = iDoy+dble(UT/24.) C print *, nYr, Doy8, nCar, JDcar XCsc = XMAP_SC_POS8(EARTH8,nYr,Doy8,-nCar,JDCar) if (XCsc .ne. BadR4()) then ! Time outside JDCar range C print *, 'Time outside JDCar range in readACE8' C print *, cSRCVG,nYr,Doy8,nCar,XCsc XCbeg = XCtest1 XCend = XCtest2 ! Sub-Earth position if (XCsc.ge.XCbeg.and.XCsc.le.XCend) then ! Sub-Earth past XCend C print *, 'XCsc =',XCsc,' Sub-Earth after XCbeg =',XCbeg,' or before XCend =', XCend, nYr,DOY8 I = I + 1 IYRS(I+NL) = nYr SRCVG(I+NL) = cSRCVG SRC(I+NL) = cSrc DOYS8(I+NL) = Doy8 XCE(I+NL) = XCsc YL(I+NL) = 0.0 ! Heliographic lat(P) (not needed) DD(I+NL) = DEN ! Density call SunNewcomb8(0,nYr,Doy8,dLngSun,dLatSun,dDisSun) XDS(I+NL) = sngl(dDisSun) XLS(I+NL) = sngl(dLngSun) ! Geocentric ecliptic lng(Sun) XLL(I+NL) = 0.0 ! needs to be zero XDL(I+NL) = 0.0 ! (not needed) XE(I+NL) = 0.0 ! (not needed) rP = dDisSun ! Heliographic coord(P) XCobs = XCsc+(Radius-rP)/iVEL*SUN__SPIRAL ! Earth traced to Radius XC(I+NL) = XCobs end if end if end if end if end do Ifst = Ifst + 1 close(13) end do N_IN = I print *, 'Number of ACE L2 in-situ density sources =',N_IN print *, ' ' return end