%clustcmd -s -n 22 32 '/usr/local/bin/matlabR13.1 -nojvm -nodisplay <
% /home/sergio/KCARTA/SRC/
% NONLTE2/sergio/NONLTE_MATLAB/loop_background_highres_Dec04_clustcmd.m  > 
% /airs/s1/sergio/nltelogfile 2>&1 &'

path(path,'/home/sergio/KCARTA/SRC/NONLTE2/sergio/NONLTE_MATLAB');

cd /home/sergio/KCARTA/SRC/NONLTE2/sergio/NONLTE_MATLAB
airs_nodes_co2back;

homedir = pwd;

clear topts

topts.RemoveSomeBands = +1;
toptsRMV.iKCBand = [2310 2311 2320 2321 2350 2351 2352 2353 2354 2355];
toptsRMV.iISO =    [   1    2    1    2    1    2    3    1    1    4];  
toptsRMV.iL =      [   4    4    2    2    1    1    1    3    5    1];
toptsRMV.iU =      [  24   24   16   16    9    9    9   23   25    9];

iaTemp = -50:10:50;

iaFr = 2200 : 5 : 2505;
%iaFr = 2205-5;

iT = iDoJob;    %%%from airs_nodes_co2back

%% make the reference profile
fprintf('doing temperature = %4i \n',iaTemp(iT));
prof = load('refgas2');
prof(:,4) = prof(:,4) + iaTemp(iT);
fname = ['refgas2_' num2str(iT)];
fid = fopen(fname,'w');
fprintf(fid,'%3i  %10.8e %10.8e %7.3f %10.8e \n',prof');  
fclose(fid);

profname = pwd;
profname = [profname '/' fname];

iaFr
for iF = 1 : length(iaFr)
  %% run run7lbl
  clear fr k
  f1 = iaFr(iF);
  f2 = f1 + 5.0;

  fprintf(1,'doing %3i of %3i : %8.4f %8.4f\n',iF,length(iaFr),f1,f2);

  cd /home/sergio/SPECTRA;

  topts.ffin = 0.0001;
  topts.nbox = 5;

  [fr,k] = run7co2_weakbackgnd(2,f1,f2,profname,topts,toptsRMV);      

  %% save the data

  outname = ...
    ['/carrot/s1/sergio/AIRSCO2/BACKGND_DEC2004_COUSIN_HIGHRES/' fname];

  outname = [outname '_highres_' num2str(f1) '.mat'];
  saver = ['save ' outname ' fr k prof f1 f2 topts toptsRMV profname'];
  eval(saver);
  end

%%%%now read in the data
%frall = [];
%kall = [];
%for iF = 1 : length(iaFr)
%  f1 = iaFr(iF);
%  iname = ['/carrot/s1/sergio/AIRSCO2/BACKGND_DEC2004/refgas2_' num2str(iT)];
%  iname = [iname '_' num2str(f1) '.mat'];
%  loader = ['load ' iname]
%  eval(loader);
%  [f1 f2]
%  frall = [frall fr];
%  kall = [kall k];
%  end
