%%%%%%%%%%%
% loadf.m %
%%%%%%%%%%%

global H npa symbol mass B cn fc;

if exist('fname')==0
  fname = 'fconst';
end;

fp = fopen( [fname '.spec'], 'r' );
H = fscanf(fp, '%e', [ 3 3 ]);
npa = fscanf(fp, '%d', [ 1 1 ]);

for i=1:npa
  fscanf(fp, '%c', [1 1]);
  symbol(i,1) = fscanf(fp, '%c', [1 1]);
  symbol(i,2) = fscanf(fp, '%c', [1 1]);
  mass(i) = fscanf(fp, '%e', [1 1]);
end;

B = fscanf(fp, '%e', [ 1 1 ]);
cn = fscanf(fp, '%d', [ npa*(npa+1)/2 1 ]);
fclose(fp);

fp = fopen( [fname '.out'], 'r' );
fc = fscanf(fp, '%e', [ 12 sum(cn) ])';
fclose(fp);

fprintf(1, 'Force constant fname = ''%s''; npa = %d; %d entries.\n', ...
        fname, npa, sum(cn));
