function write_sounding_in() b = fopen('sounding.in','w'); pressure = [1000:-25:100,80,60,40,30,25,20,15,10,5]; % Default temperature = [23.097,20.945,18.859,18.446,17.178,15.962,14.706,13.402,12.048,10.637,9.162,7.604,5.98,4.275,2.482,0.599,-1.355,-2.966,-4.663,-6.493,-8.537,-10.881,-13.601,-16.747,-20.608,-25.111,-28.696,-33.103,-37.811,-43.044,-48.499,-55.02,-61.581,-68.88,-64.993,-64.89,-64.806,-63.305,-58.781,-52.377,-48.398,-46.694,-44.741,-41.925,-36.678,-16.725]; % This is where I figured out how to do this without retyping the whole % silly thing. specific_humidity = [13.9406770000000;13.7776820000000;13.7033140000000;11.1605630000000;9.99056200000000;8.98750000000000;8.15985000000000;7.45406400000000;6.83384500000000;6.27302200000000;5.78938800000000;5.33197100000000;4.89058300000000;4.47216100000000;4.06095900000000;3.57056400000000;2.87300000000000;2.22646500000000;1.75131000000000;1.41786300000000;1.19974900000000;1.07053500000000;1.00346700000000;0.973912000000000;0.964770000000000;0.966449000000000;0.367977000000000;0.175534000000000;0.114358000000000;0.0769640000000000;0.0427110000000000;0.0304100000000000;0.0269260000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;0.00300000000000000;]'; ozone = [0.0480000000000000;0.0490000000000000;0.0510000000000000;0.0510000000000000;0.0540000000000000;0.0550000000000000;0.0550000000000000;0.0570000000000000;0.0570000000000000;0.0580000000000000;0.0590000000000000;0.0600000000000000;0.0610000000000000;0.0610000000000000;0.0610000000000000;0.0620000000000000;0.0630000000000000;0.0650000000000000;0.0660000000000000;0.0680000000000000;0.0690000000000000;0.0700000000000000;0.0730000000000000;0.0750000000000000;0.0780000000000000;0.0810000000000000;0.0850000000000000;0.0910000000000000;0.0970000000000000;0.107000000000000;0.119000000000000;0.135000000000000;0.154000000000000;0.176000000000000;0.206000000000000;0.265000000000000;0.405000000000000;0.755000000000000;2.04200000000000;5.23800000000000;8.44000000000000;10.1240000000000;11.7730000000000;13.8820000000000;13.8730000000000;10.5480000000000;]'; omega = zeros(size(ozone)); rad_cooling = [1.28500000000000;1.75500000000000;1.45200000000000;1.72100000000000;1.41400000000000;1.32300000000000;1.22600000000000;1.15600000000000;1.10300000000000;1.06400000000000;1.04500000000000;1.03800000000000;1.04800000000000;1.08000000000000;1.13600000000000;1.19500000000000;1.12500000000000;1.14300000000000;1.10700000000000;1.06400000000000;1.02400000000000;0.990000000000000;0.969000000000000;0.227000000000000;-0.227000000000000;1.97800000000000;0.880000000000000;0.916000000000000;0.762000000000000;1.05200000000000;0.159000000000000;1.22700000000000;0.303000000000000;0;-0.00100000000000000;-0.00100000000000000;-0.00100000000000000;-0.00100000000000000;-0.00100000000000000;-0.00100000000000000;-0.00100000000000000;-0.00100000000000000;-0.00100000000000000;-0.00100000000000000;-0.00100000000000000;0.00200000000000000;]'; N_lvl = length(pressure); cbmf = 9.563; SST = 25; line1 = [' N levels = ',sprintf('%2.0f',N_lvl),' CBMF= ',sprintf('%5.3f',cbmf),' SST= ',sprintf('%5.2f',SST),' C\n']; fprintf(b,line1); % line 2 is a newline fprintf(b,'\n'); lines3to5 = ' Pressure Temp. Spec. humid. O3 mr Omega Rad. cooling\n (mb) (C) (g/kg) 10**-6 (mb/hr) (deg/day)\n ------- ----- ------------ ----- ----- ------------\n'; fprintf(b,lines3to5); for i = 1:N_lvl % Instead of explicitly padding spaces, I'm going to give the data the % chance to be longer %fprintf(b,repmat(' ',1,3)); fprintf(b,'%9.1f',pressure(i)); % Formerly 6.1f %fprintf(b,repmat(' ',1,3)); fprintf(b,'%10.3f',temperature(i)); fprintf(b,'%15.6f',specific_humidity(i)); fprintf(b,'%10.3f',ozone(i)); fprintf(b,'%8.2f',omega(i)); fprintf(b,'%12.3f',rad_cooling(i)); fprintf(b,'\n'); end fclose(b);