C+ C NAME: C smei_frm_path C PURPOSE: C Determines directory where frame for given time and camera C is located C CATEGORY: C CALLING SEQUENCE: integer function smei_frm_path(bdig, cFile, TT, camera, cBase, cPath) C INPUTS: C bdig logical =.FALSE.: return base drive (e.g. /smeidb/db3/ C =.TRUE. : return base directory (e.g. /smeidb/db3/2004_001/) C cFile character*(*) file name of SMEI frame (without directory) C if itrim(cFile) .ne. 0 then TT and camera are C extracted from the frame name C TT(2) integer standard 2-element time C camera integer camera number C cBase*(*) character root directory of SMEI DB C if left blank than the environment variables C SMEIDB1, SMEIDB2, etc. are used C OUTPUTS: C TT(2) integer if cFile .ne. ' ', frame time C camera integer if cFile .ne. ' ', camera number C cPath*(*) character directory where frame is located C CALLS: C Time2Differ, Time2Str, Time2YDoy, smei_Time2Split, cInt2Str, bOpenFile C iFilePath, iGetLogical, Say, Str2Flt, Str2Flt_Format, itrim, iFreeLun C INCLUDE: include 'dirspec.h' include 'openfile.h' include 'filparts.h' include 'smei_frm_layout.h' C RESTRICTIONS: C Env variables $SMEIDB1, $SMEIDB2, etc. need to be stored in the C log file $HOME/LOGFIL.TXT (this should be done automatically by the login C script $com/login. C PROCEDURE: C If cFile is not a blank string, it should be the filename (without directory) C of a SMEI frame, e.g. c1frm_2003_123456. The file type is ignored. C If cFile is the blank string then arguments TT and camera are used to construct C a frame name. C MODIFICATION HISTORY: C JUN-2004, Paul Hick (UCSD/CASS) C NOV-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Maximum number of drives is now 16 (was 8) C- logical bdig character cFile*(*) integer TT(2) integer camera character cBase*(*) character cPath*(*) character cSay*13 /'smei_frm_path'/ integer Time2Str character cInt2Str*14 logical bOpenFile character cParts(3)*7 /'camera','idl','toolbox'/ character cDrive*15 /'smei_drives.txt'/ character cTmp*(FIL__LENGTH) character cStr*(FIL__LENGTH) parameter (nVec = 5) real rVec(nVec) logical bNext integer tb(2) /2*0/ integer te(2) /2*0/ logical bInit /.TRUE./ parameter (nDrv = 16) integer DRV ( nDrv) integer TBeg(2,nDrv) integer TEnd(2,nDrv) integer Time2Differ save bInit, iDrv, DRV, TBeg, TEnd if (itrim(cFile) .ne. 0) then ! Extract camera number and frame time from cFile call smei_Time2Split(0,cFile,TT) read (cFile(2:2), '(I1.1)') camera end if if (cBase .eq. ' ' .or. cBase .eq. 'SMEIDB?' .or. cBase .eq. 'SMEIDC?') then if (bInit) then cTmp = 'SMEI_UCSD' if (iGetLogical(cTmp, cPath) .eq. 0) call Say(cSay,'E',cTmp,'not defined') I = iFilePath(cPath,3,cParts,cDrive,cStr) if (bOpenFile(OPN__TEXT+OPN__REOPEN+OPN__NOMESSAGE+OPN__STOP,iU,cStr,iRecl)) then read (iU, '(A)', iostat=iostat) cStr do while (iostat .eq. 0 .and. (itrim(cStr) .eq. 0 .or. cStr(:1) .eq. ';')) read (iU, '(A)', iostat=iostat) cStr end do I = nVec call Str2Flt(cStr, I, rVec) call Str2Flt_Format(cTmp) iDrv = 0 do while (iostat .eq. 0) iDrv = iDrv+1 read (cStr,cTmp) DRV(iDrv), iYrBeg, tb(1), iYrEnd, te(1) call Time2YDoy(1,TBeg(1,iDrv),iYrBeg,tb) call Time2YDoy(1,TEnd(1,iDrv),iYrEnd,te) read (iU, '(A)', iostat=iostat) cStr end do iU = iFreeLun(iU) end if bInit = .FALSE. end if jDrv = 1 bNext = jDrv .le. iDrv do while (bNext) bNext = Time2Differ(TT,TBeg(1,jDrv)) .lt. 0 if (.not. bNext) bNext = Time2Differ(TT,TEnd(1,jDrv)) .ge. 0 if (bNext) then jDrv = jDrv+1 bNext = jDrv .le. iDrv end if end do if (jDrv .gt. iDrv) call Say(cSay,'E','time','not available') if (cBase .eq. 'SMEIDC?') then cTmp = 'SMEIDC'//cInt2Str(jDrv) else cTmp = 'SMEIDB'//cInt2Str(jDrv) end if if (iGetLogical(cTmp, cPath) .eq. 0) call Say(cSay,'E',cTmp,'not defined') else cPath = cBase end if smei_frm_path = itrim(cPath) if (bdig) then cStr = cPath I = Time2Str('YYYY_DOY',TT,cTmp) smei_frm_path = iFilePath(cStr,1,cTmp,' ',cPath) if (camera .ne. 0) then cStr = cPath smei_frm_path = iFilePath(cStr,1,'c'//cInt2Str(camera),' ',cPath) end if else cStr = cPath smei_frm_path = iFilePath(cStr,0,' ',' ',cPath) end if return end