C+ C NAME: C smei_foreign C PURPOSE: C Process command line arguments C CALLING SEQUENCE: subroutine smei_foreign(id,cList,cBase,cDest,min_orbit,beg_orbit,end_orbit,forbit,icam,mode,cArg) C INPUTS: C (from command line) C C id integer 1: cal_pattern (calibration 'closed shutter' patterns) C 2: orb_pattern (on-the-fly orbital patterns) C 3: smei_base (all data using patterns; CRX program) C 4: smei_htm C OPTIONAL INPUTS: C C destination= C begin= C orbits= C camera= C mode= C OUTPUTS: C cList*(*) character extracted from C where is the fully-qualified C file name of the ASCII file containing C the information defining each of the C 'closed shutter' data. C Remember to escape any wildcard chars in C to avoid wildcard expansion C at the command prompt. C cBase*(*) character source directory C cDest*(*) character extracted from C -destination= C where is the name of an existing C directory where to write the output file. C If not specified than $TUB is used. C min_orbit integer extracted from C -minimum_orbit= C -minimum_orbit= C orbit to be used for calculating the mimimum pattern C in orb_pattern. If a time is specified then the orbit C with the closest start time is used. C If absent then the first orbit starting after C the time from the closed shutter pattern is used. C beg_orbit integer extracted from C -start_time= C -start_time= C The first orbit for which a difference orbital pattern C is calculated. If a time is specified then the orbit C with the closest start time is used. C If absent then the first orbit starting after C the time from the closest shutter pattern is used. C end_orbit integer extracted from C -stop_time= C -stop_time= C The first orbit for which a minimum orbital pattern C is calculated. If a time is specified then the orbit C with the closest start time is used. C If omitted all orbits up to the time of the C closed shutter pattern following the one C specified in cList are processed. C norbit integer extracted from C -orbits= C Alternative to stop_time: # orbits processed starting C at beg_orbit. C forbit(2) double precision C (only accessed if id=2, i.e. for smei_orb) C extracted from C -lowfraction= C -highfraction= C two fractions of one defining the part of the orbit C used for the orbital minimum and difference patterns. C icam integer extracted from -camera= C camera number (default: 0) C mode integer extracted from -mode= C mode number (default: -1) C INCLUDE: include 'dirspec.h' include 'filparts.h' C CALLS: C ForeignArg, ForeignStrArg, ForeignI4Arg, ForeignR8Arg, ForeignArgSet C lowercase, LocFirst, iCheckDirectory, Say, iGetLogical, Time2Differ C Str2Dbl, smei_orbit2, smei_orbit_time2, iFilePath, iSetFileSpec C iGetFileSpec, smei_foreign_orbit_time, iSearch, smei_Time2Split C BadI4, Str2Str C MODIFICATION HISTORY: C- integer id character cList*(*) character cBase*(*) character cDest*(*) integer min_orbit(*) integer beg_orbit(*) integer end_orbit(*) double precision forbit(*) integer icam integer mode character cArg*(*) character cSay*12 /'smei_foreign'/ integer mode_cam(3) /2,2,1/ parameter (nVar = 5) character cVar(nVar)*(FIL__LENGTH) ! Foreign input array character cDir *(FIL__LENGTH) character cStr *(FIL__LENGTH) character cFile*(FIL__LENGTH) logical ForeignArgSet logical bFrameOK logical bTmp integer tlist(2) logical bOSFindClose integer BadI4 integer Time2Differ integer Str2Str integer iorbit double precision dorbit iBad = BadI4() !------- ! Process command line arguments iVar = nVar cVar(1) = 'quiet' call ForeignArg(' ',iVar,cVar,cArg) call ForeignStrArg(cArg,'source','SMEIDB?',cBase) if (cBase .eq. 'SMEIDB?' .or. cBase .eq. 'SMEIDC?') then cArg(itrim(cArg)+1:) = cSwitch(:iSwitch)//'digsource' else if (cBase(:iEnvi) .eq. cEnvi(:iEnvi)) i = iGetLogical(cBase,cBase) if (iCheckDirectory(cBase) .ne. 1) call Say(cSay,'E',cBase,'source does not exist') end if call ForeignStrArg(cArg,'destination',cEnvi(:iEnvi)//'TUB',cDest) if (cDest .eq. 'SMEIDB?' .or. cDest .eq. 'SMEIDC?') then cArg(itrim(cArg)+1:) = cSwitch(:iSwitch)//'digdestination' else if (cDest(:iEnvi) .eq. cEnvi(:iEnvi)) i = iGetLogical(cDest,cDest) if (iCheckDirectory(cDest) .ne. 1) call Say(cSay,'E',cDest,'destination does not exist') end if call ForeignI4Arg(cArg,'camera',iBad,icam) call ForeignI4Arg(cArg,'mode' ,iBad,mode) if (id .ne. 1) then ! NOT smei_cal call ForeignStrArg(cArg,'start_time',' ',cStr) call smei_foreign_orbit_time(id,cStr,beg_orbit) call ForeignStrArg(cArg,'stop_time',' ',cStr) call smei_foreign_orbit_time(id,cStr,end_orbit) call ForeignI4Arg(cArg,'orbits',iBad,norbit) ! Miminimum orbit is specified as an orbit number or as ! a time in SMEI format. if (id .eq. 2) then ! smei_orb call ForeignStrArg(cArg,'minimum_orbit',' ',cStr) call smei_foreign_orbit_time(id,cStr,min_orbit) end if if (id .eq. 2) then ! .or. id .eq. 4) then ! smei_orb or smei_htm call ForeignR8Arg(cArg,'lowfraction' ,0.0d0,forbit(1)) call ForeignR8Arg(cArg,'highfraction',1.0d0,forbit(2)) end if end if cList = cVar(1) call lowercase(cList) if (id .eq. 1) then ! smei_cal if (cList .eq. ' ') then if (.not. ForeignArgSet(cArg,'help' ) .and. & .not. ForeignArgSet(cArg,'version' ) .and. & .not. ForeignArgSet(cArg,'dumpversion')) then call Say(cSay,'E','list','no pattern text template specified') end if end if else if (cList .ne. ' ') then ! smei_orb, smei_base, smei_htm ! Pick up the first pattern file matching cList. cStr = cList if (iSearch(1,cStr,cList) .ne. 1) call Say(cSay,'E','#'//cStr,'closed shutter pattern not found') bTmp = bOSFindClose() ! Pick up camera from pattern file name i = iSetFileSpec(cList) i = iGetFileSpec(0,FIL__DIRECTORY,cDir) i = iGetFileSpec(FIL__NAME,FIL__NAME,cFile) read (cFile(2:2),'(I1)') icam call smei_Time2Split(0,cFile,tlist) ! If not set as keyword set min and begin orbit to orbit after ! time of calibration pattern. call smei_orbit2(tlist,iorbit,dorbit) iorbit = iorbit+1 if (id .eq. 2) then if (min_orbit(1) .eq. iBad) call smei_orbit_time2(iorbit,0.0d0,min_orbit) end if if (beg_orbit(1) .eq. iBad) call smei_orbit_time2(iorbit,0.0d0,beg_orbit) ! Number of orbits for which difference patterns are required. ! If not specified on the command line (norbit = iBad) then continue ! until the closed shutter pattern following the one used here ! is reached. if (end_orbit(1) .ne. iBad) then continue else if (norbit .ne. iBad) then call smei_orbit2(beg_orbit,iorbit,dorbit) iorbit = iorbit+norbit call smei_orbit_time2(iorbit,dorbit,end_orbit) else cFile(index(cFile,'_')+1:) = '*.fts.gz' ! c2pat_*.fts.gz i = iFilePath(cDir,0,' ',cFile, cStr) bFrameOK = iSearch(1,cStr,cFile) .eq. 1 do while (bFrameOK) call smei_Time2Split(1,cFile,end_orbit) bFrameOK = Time2Differ(end_orbit,tlist) .le. 0 if (bFrameOK) bFrameOK = iSearch(0,' ',cFile) .eq. 1 end do call smei_orbit2(end_orbit,iorbit,dorbit) call smei_orbit_time2(iorbit,0.0d0,end_orbit) end if else if (id .eq. 4) cList = 'SMEIDB?' ! smei_htm if (beg_orbit(1) .ne. iBad .and. end_orbit(1) .eq. iBad) then if (norbit .eq. iBad) norbit = 1 call smei_orbit2(beg_orbit,iorbit,dorbit) call smei_orbit_time2(iorbit+norbit,dorbit,end_orbit) end if end if if (icam .ne. iBad .and. mode .eq. iBad) mode = mode_cam(icam) return end subroutine smei_foreign_orbit_time(id,cStr,orbit_time) integer id character cStr*(*) integer orbit_time(2) double precision rvec(3) integer BadI4 double precision dorbit if (cStr .ne. ' ') then n = 3 call Str2Dbl(cStr,n,rvec) if (n .eq. 1) then ! Single orbit number iorbit = rvec(1) dorbit = rvec(1)-iorbit else if (n .eq. 2) then ! Int orbit, double fraction iorbit = nint(rvec(1)) dorbit = rvec(2) else ! Must be a time call Time2Split('SMEI',cStr,orbit_time) call smei_orbit2(orbit_time,iorbit,dorbit) end if if (id .eq. 2) then ! orb_pattern iorbit = nint(iorbit+dorbit) dorbit = 0.0d0 end if call smei_orbit_time2(iorbit,dorbit,orbit_time) else i = BadI4() orbit_time(1) = i orbit_time(2) = i end if return end