;+------------------------------------------------------------- ; NAME: ; highestEfitRun ; PURPOSE: ; find highest efit version run (in the MDSplus tree) ; Checks up to 5, and contigously after that ; CATEGORY: ; EFIT, MDSplus ; CALLING SEQUENCE: ; IDL> run = highestEfitRun(shot) ; INPUTS: ; shot = shot # ; KEYWORD PARAMETERS: ; FITTYPE= fit type. Defaults to 'EFIT'. Works for 'LRDFIT', too. ; min2Check - will always check up to this number, and contigously ; after that. E.g. if there is a EFIT05 and EFIT07, ; 5 will be declared the highest unless this keyword ; is 6 or higher. ; OUTPUTS: ; integer # representing highest EFIT run in tree ; EXAMPLES: ; IDL> print,fitsrun(123001) ; EFIT01 EFIT02 EFITRT ; IDL> print,highestefitrun(123001) ; 2 ; ; IDL> print,fitsrun(117707) ; EFIT01 EFIT02 EFIT03 EFIT06 EFITRT LRDFIT04 LRDFIT06 ; IDL> print,highestefitrun(117707) ; 6 ; IDL> print,highestefitrun(117707,FIT='LRDFIT') ; 6 ; NOTES: ; When the routine is called with no parameters, or with the ; keyword hlp set, help information is printed. ; MODIFICATIONS: ; 29-Aug-2008 make min2check=20 for LRDfit ; 27-Aug-2007 check at least 5 runs. Add keyword for fit type and ; min2Check. ; Aug-2005 Written by Bill Davis ;----------------------------------------------------------------- function highestefitrun, shot, FITTYPE=fitType, min2Check=min2Check, $ status=status if n_elements( FITTYPE ) eq 0 then fitType = 'EFIT' if n_elements( min2Check ) eq 0 then begin if strupcase(fitType) eq 'LRDFIT' then min2Check = 20 else min2Check = 5 endif mdsopen, fittype, shot, status=status, /quiet if not status then begin print, ' *** '+fittype+' tree not found for shot '+strtrim(shot,2)+' ***' return, -1 endif ; check at least min2Check (defaults to 5) i=1 fit=0 for i=1,min2Check do begin tree = '\'+fittype+STRING(i,format='(I2.2)') result = mdsvalue('getnci('+tree+'::DATE_RUN,"length")', /quiet) if isnumber( result ) then begin if result gt 0 then fit=i endif endfor ; now check until one missing forever=1 while ( forever ) do begin tree = '\'+fittype+STRING(i,format='(I2.2)') result = mdsvalue('getnci('+tree+'::DATE_RUN,"length")', /quiet) if isnumber( result ) eq 0 then goto, noMore if result eq 0 then goto, noMore fit=i i=i+1 endwhile noMore: return, fit end