I am trying to print numbers calculated from an netcdf file onto the same line after going through a for loop. However, for every iteration of the loop the program prints out every step. Moving the print statement outside of the for loop doesn't work either. How can I just print the last line of the for loop data?
Here is the relevant code:
qT = where(IN eq 10 and SC eq 'T1')
if n_elements(qT) eq 1 and qT(0) ne -1 then begin
cTval = MR(qT(0))-MRA(qT(0))
cT = string(cTval,format='(F0.2)')
if cTval le lowlim_cT or cTval ge uplim_cT then begin
print, 'T1: ' + cT + "*************** RESIDUALS ARE OUT OF LIMIT " + strtrim(string(uplim_cT),2)
endif else begin
print, 'T1: ' + cT
endelse
endif
if n_elements(qT) eq 1 and qT(0) eq -1 then begin print, 'QT ERROR' + '$'
endif
if n_elements(qT) gt 1 then begin
cT = strarr(n_elements(qT))
cTval = fltarr(n_elements(qT))
for h = 0, n_elements(qT)-1 do begin
cTval(h)= MR(qT(h))-MRA(qT(h))
cT(h) = string(cTval(h),format='(F0.2)')
if cTval(h) lt lowlim_cT or cTval(h) gt uplim_cT then begin
print, 'T1: ' + cT + "*************** RESIDUALS ARE OUT OF LIMIT " + strtrim(string(uplim_cT),2)
endif else begin
print, 'T1: ' + cT
endelse
endfor
endif
With the following output:
T1: -59.67*************** RESIDUALS ARE OUT OF LIMIT 10 T1: *************** RESIDUALS ARE OUT OF LIMIT 10 T1: *************** RESIDUALS ARE OUT OF LIMIT 10
T1: -59.67*************** RESIDUALS ARE OUT OF LIMIT 10 T1: -65.91*************** RESIDUALS ARE OUT OF LIMIT 10 T1: *************** RESIDUALS ARE OUT OF LIMIT 10
T1: -59.67*************** RESIDUALS ARE OUT OF LIMIT 10 T1: -65.91*************** RESIDUALS ARE OUT OF LIMIT 10 T1: -48.13*************** RESIDUALS ARE OUT OF LIMIT 10
How do I only print out that last line? Thank you!
I ended up setting a boolean variable and working from there. Here is the working code: