function sonde=read_sonde(filename)
fid=fopen(char(filename));
status=fseek(fid,0,'eof');
filesize=ftell(fid);
frewind(fid)
current_loc=ftell(fid);
iloop=1;
while current_loc<filesize
    C=textscan(fid,'%71c',1);
    cc=char(C);
    id=cc(2:12);
    Year=str2num(cc(14:17));
    Month=str2num(cc(19:20));
    Day=str2num(cc(22:23));
    Hour=str2num(cc(25:26));
    time=datenum([Year,Month,Day,Hour,0,0]);
    rel_time=str2num(cc(28:31));
    num_levels=str2num(cc(33:36));
    Lat=str2num(cc(56:62))/100;
    Lon=str2num(cc(64:71))/100;
    
    for j=1:num_levels
        C=textscan(fid,'%51c',1);
        cc=char(C);
        lvltyp(j)=str2num(cc(1:2));
        etime(j)=str2num(cc(4:8));
        PRESS(j)=str2num(cc(10:15))/100;
        pflag(j)=cc(16:16);
        GPH(j)=str2num(cc(17:21));
        zflag(j)=cc(22:22);
        TEMP(j)=str2num(cc(23:27))/10;
        tflag(j)=cc(28:28);
        RH(j)=str2num(cc(29:33))/10;
        DPDP(j)=str2num(cc(35:39))/10;
        WDIR(j)=str2num(cc(41:45));
        WSPD(j)=str2num(cc(47:51))/10;
    end
    sonde(iloop).id=id;
    sonde(iloop).time=time;
    sonde(iloop).rel_time=rel_time;
    sonde(iloop).num_levels=num_levels;
    sonde(iloop).Lat=Lat;
    sonde(iloop).Lon=Lon;
        sonde(iloop).lvltyp=lvltyp;
        sonde(iloop).etime=etime;
        sonde(iloop).PRESS=PRESS;
        sonde(iloop).pflag=pflag;
        sonde(iloop).GPH=GPH;
        sonde(iloop).zflag=zflag;
        sonde(iloop).TEMP=TEMP;
        sonde(iloop).tflag=tflag;
        sonde(iloop).RH=RH;
        sonde(iloop).DPDP=DPDP;
        sonde(iloop).WDIR=WDIR;
        sonde(iloop).WSPD=WSPD;

    iloop=iloop+1;
   current_loc=ftell(fid);
end
fclose(fid)
return