C+ C NAME: C SetGipsy C PURPOSE: C Set logical $CAM for GIPSY programs. Return data type (edited or C unedited data) and modified Julian day for earliest data file C CALLING SEQUENCE: subroutine SetGipsy(cDat,iOffUT,iEdt,MJDfrst,MJDlast) C INPUTS: C cDat character*(*) logical name pointing to location of C data files C iOffUT integer offset between local time and UT C OUTPUTS: C iEdt integer 0 = Unedited data; 1 = Edited data C MJDfrst integer Modified Julian day for earliest data file C MJDlast integer Modified Julian day for most recent file C CALLS: C AskI4, SetLog2Dir, Say, iGetLogical, iDeleteLogical, iFilePath C iSetFileSpec, iGetFileSpec, Str2Flt C INCLUDE: include 'filparts.h' include 'sun.h' include 'dirspec.h' C PROCEDURE: C MODIFICATION HISTORY: C JAN-1992, Paul Hick (UCSD) C JUL-1993, Paul Hick (UCSD), added search for MJDlast C SEP-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C hardwired return values MJDfrst = 48180 and MJDlast = 49622 C As a result the input value iOffUT is not used anymore. C- character cDat*(*) integer iOffUT integer iEdt integer MJDfrst integer MJDlast character UNEDT*80 character EDT*80 character XIPS*80 character cFound*80 !real*8 JD !real*8 JEpoch !real RVEC(1) !character cMJDlast*5 character cEdt(0:1)*10 character cEdtWild*5 cEdtWild = cWildChar(:len(cEdtWild)) cEdt(0) = 'g'//cEdtWild//'.' cEdt(1) = 'e'//cEdtWild//'.dat' !------- ! Check for existence of edited and unedited files ! The logical $CAM points to the directory where the Cambridge files are located. ! If the logical is not set then $CAM is set to subdirectory Cambridge in $dat ! ($dat points to the generic data directory). iEdt = -1 EDT = ' ' UNEDT = ' ' if (iGetLogical(cDat,XIPS) .eq. 0) then ! Logical $CAM not defined if (iGetLogical(cEnvi//'dat',XIPS) .ne. 0) then ! Translate $dat I = iFilePath(XIPS,1,'cambridge',' ',cFound) I = iSetFileSpec(cFound) I = iGetFileSpec(0,FIL__DIRECTORY,cFound)! Subdirectory Cambridge in $dat I = iSetLogical(cDat,cFound,'PROCESS') ! Set logical cDat end if end if !------- ! Check logical $dat. If it exists search for edited or unedited files. if (iGetLogical(cDat,XIPS) .ne. 0) then call SetLog2Dir(-2,cDat,cEdt(0),UNEDT) if (UNEDT .ne. ' ') iEdt = 0 call SetLog2Dir( 2,cDat,cEdt(1),EDT) if ( EDT .ne. ' ') iEdt = 1 if (iEdt .eq. -1) I = iDeleteLogical(cDat) else call Say('SetGipsy','W',cDat,'no translation for logical name') end if !------- ! If neither types or both types are located, prompt for type if (iEdt .eq. -1 .or. (UNEDT .ne. ' ' .and. EDT .ne. ' ') ) then write (*,*) ' ' call AskWhat('Edited data, Unedited data$0$0',iEdt) iEdt = 1-iEdt end if !------- ! Check for requested file type, if it has not been located yet ! Set the logical $CAM to the proper directory if (iEdt .eq. 0 .and. UNEDT .eq. ' ') call SetLog2Dir(1,cDat,cEdt(0),UNEDT) if (iEdt .eq. 1 .and. EDT .eq. ' ') call SetLog2Dir(1,cDat,cEdt(1),EDT) !------- ! Extract the modified Julian day from the file name if (iEdt .eq. 1) UNEDT = EDT I = iSetFileSpec(UNEDT) I = iGetFileSpec(FIL__NAME,FIL__NAME,cFound) read (cFound(2:6),'(I5)') MJDfrst I = iGetFileSpec(0,FIL__DIRECTORY,XIPS) XIPS(I+1:) = cEdt(iEdt) MJDfrst = 48180 MJDlast = 49622 !------- ! Find the most recent modified Julian day MJDlast for which ! data are available by calculating the current modified Julian day from ! the system time, and skipping backwards until a data file is located. !call Local2UT(iOffUT,iYr,Doy) ! Get current UT time !call Julian(0,iYr,Doy,JD,JEpoch) ! Convert to Julian day !if (iGetSymbol('MJDLAST',cMJDlast) .eq. 0) then ! MJDlast = JD-SUN__MJDtoJD ! Current modified Julian date !else ! I = 1 ! call Str2Flt(cMJDlast,I,RVEC) ! MJDlast = RVEC(1) !end if !I = index(XIPS,cEdtWild) !write (XIPS(I:I+4),'(I5.5)') MJDlast !do while (iSearch(11,XIPS,cFound) .ne. 1)! Skip backwards until file is located ! MJDlast = MJDlast-1 ! write (XIPS(I:I+4),'(I5)') MJDlast !end do return end