C+ C NAME: C SetRotations C PURPOSE: C Use specified wildcard to locate directory with data files for the C Carrington programs. If located, define a logical pointing to the C data directory. C Also return first and last Carrington rotations numbers for which files C are available. C CALLING SEQUENCE: subroutine SetRotations(iPrompt,cWild,IClo,IChi) C INPUTS: C iPrompt integer = 0/1 C 0 : check directory assigned to logical only. C 1 : check directory assigned to logical. If unsuccessful, prompt C for directories until data files are located C cWild*(*) character wildcard used to search for data files C (only file name and type are used) C OUTPUTS: C IClo integer First and .. C IChi integer last Carrington rotation located C CALLS: C SetLog2Dir, Say, iGetLogical, iSetFileSpec, iGetFileSpec C INCLUDE: include 'filparts.h' include 'str2str_inc.h' include 'dirspec.h' C PROCEDURE: C > The wildcard is used to search for data files. C The Carrington rotation should be encoded into file name as a 4 digit C integer. Mark the location with the 4 char string %%%% or ####. C (use #### if there is there is another %%%% present in the wildcard C preceding the location of the Carrington number. C > The wildcard must have the same number of characters as the real C file name+file extension, i.e. do NOT use the wildcard *, but only C the single character wildcard %. C > The file type (extension) is used to construct the name of the logical C assigned to the data directory. C > If the logical is already assigned to a directory, that directory is C searched first. If data files are found, the value is retained. If not, C the logical is deassigned. C > If no files are found in the previous step, then C - if iPrompt = 0 then return IClo = IChi = 0 C - if iPrompt = 1 continue to prompt for a directory until one is specified C which contains data files or until program is aborted. C MODIFICATION HISTORY: C JUL-1993, Paul Hick (UCSD/CASS; pphick@ucsd.edu), modification of SetGipsy C- integer iPrompt character cWild*(*) integer IClo integer IChi character cName*8 ! Logical name (e.g. $SRF) character cDirSpec *120 ! Data dir (full name) character cFileSpec*120 character cFileName*120 character cFound*120 character cSay*12 /'SetRotations'/ integer Str2Str integer Str2StrSet I = iSetFileSpec(cWild) I = iGetFileSpec(FIL__NAME,FIL__NAME,cFileName) iFour = 4 if (index(cFileName,cWildChar(:iFour)) .eq. 0) & call Say(cSay,'E','Wildcard','must include '//cWildChar(:iFour)) I = iGetFileSpec(FIL__TYPE,FIL__TYPE,cName(iEnvi:)) ! cName(iEnvi:iEnvi) = '.' if (itrim(cName(iEnvi:)) .eq. 1) call Say(cSay,'E','Wildcard','must include valid file type') cName(:iEnvi) = cEnvi ! Replaces '.' by '$' I = iGetFileSpec(FIL__NAME,FIL__TYPE,cFileName) ! File name+type (containing wildcard) call SetLog2Dir(iPrompt,cName,cFileName,cFound) if (cFound .eq. ' ') then IClo = 0 IChi = 0 call Say(cSay,'W',cName,' no rotations found') else !------- ! Extract the Carrington rotation number from the file name. ! Keep searching for more rotations until the last is located. I = iSetFileSpec(cFound) I = iGetFileSpec(0,FIL__DIRECTORY,cDirSpec) ! Directory where files are located I = iFilePath(cDirSpec,0,' ',cFileName,cFileSpec) iRot = index(cFileSpec,cWildChar(:iFour)) I = 0 I = I+Str2Str('(I' ,cName(I+1:)) I = I+Int2Str(iFour,cName(I+1:)) I = I+Str2Str(')' ,cName(I+1:)) read (cFound(iRot:iRot+iFour-1),cName) IClo I = 11 do while (iSearch(I,cFileSpec,cFound) .eq. 1) read (cFound(iRot:iRot+iFour-1),cName) IChi I = 0 end do kStr = Str2StrSet(STR__NOTRIM) kInt = Int2StrSet(STR__TRIM) I = 0 I = I+Str2Str('rotation(s) are ',cFound(I+1:)) I = I+Int2Str(IClo ,cFound(I+1:)) I = I+Str2Str(' to ',cFound(I+1:)) I = I+Int2Str(IChi ,cFound(I+1:)) kStr = Str2StrSet(kStr) kInt = Int2StrSet(kInt) call Say(cSay,'I','Available',cFound) end if return end