1 | // profile for WRF initialization |
---|
2 | // update: january 2008 |
---|
3 | |
---|
4 | |
---|
5 | //// ---------------------------------------------- |
---|
6 | //// Allow user to define input parameters |
---|
7 | //// ---------------------------------------------- |
---|
8 | //lat=evstr(x_dialog('Latitude (deg)?','20')); |
---|
9 | //lon=evstr(x_dialog('East Longitude (deg)?','0')); |
---|
10 | //l_s=evstr(x_dialog('Aerocentric longitude (deg)?','90')); |
---|
11 | //lt=evstr(x_dialog('Local time ?','12')); |
---|
12 | // |
---|
13 | //alt=evstr(x_dialog('Altitude top (km)?','50')); |
---|
14 | //resol=evstr(x_dialog('Vertical resolution (points)?','100')); |
---|
15 | |
---|
16 | |
---|
17 | [finput]=file('open', 'input_coord', 'old'); |
---|
18 | [vinput]=read(finput,6,1); |
---|
19 | |
---|
20 | lon = vinput(1); |
---|
21 | lat = vinput(2); |
---|
22 | l_s = vinput(3); |
---|
23 | lt = vinput(4); |
---|
24 | alt = vinput(5); |
---|
25 | resol = vinput(6); |
---|
26 | |
---|
27 | disp(lon) |
---|
28 | disp(lat) |
---|
29 | disp(l_s) |
---|
30 | disp(lt) |
---|
31 | disp(alt) |
---|
32 | disp(resol) |
---|
33 | |
---|
34 | //vert_coord=evstr(x_dialog('Vertical coordinate type (1-4)?','3')); |
---|
35 | vert_coord = 3; |
---|
36 | //dust_scenario=evstr(x_dialog('Dust scenario (1-8)?','3')); |
---|
37 | dust_scenario = 3; |
---|
38 | //hireskey=evstr(x_dialog('High resolution (0-1)?','1')); |
---|
39 | hireskey=1; |
---|
40 | |
---|
41 | |
---|
42 | // create atltitude array at the required resolution |
---|
43 | alt_profile = [0,1,5,10,20,50,100,[linspace(200,alt*1000,resol)]]; |
---|
44 | resol=resol+7; |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | // MCD profiles |
---|
49 | //// - profils_mcd(Ls,Loct,Lat,Lon,dust,zkey,hireskey,xz) |
---|
50 | //getf('./profils_mcd.sci'); |
---|
51 | exec('./profils_mcd.sci');//,7); |
---|
52 | [p,m] = profils_mcd(l_s,lt,lat,lon,dust_scenario,vert_coord,hireskey,alt_profile); |
---|
53 | |
---|
54 | |
---|
55 | // In Scilab arrays have to be initialized |
---|
56 | utab=ones(max(size(alt_profile))); |
---|
57 | vtab=ones(max(size(alt_profile))); |
---|
58 | ttab=ones(max(size(alt_profile))); |
---|
59 | |
---|
60 | |
---|
61 | // % "-espace occupe- . -precision apres la virgule- -type de nombre-" |
---|
62 | // \n pour passer a la ligne |
---|
63 | |
---|
64 | fid = mtlb_fopen("input_sounding","w") |
---|
65 | fid2= mtlb_fopen("input_more","w") |
---|
66 | fid3= mtlb_fopen("input_therm","w") |
---|
67 | // pression de surface (1ere couche) |
---|
68 | ref_p = p(1,1,1) // equiv. a m(1,1,19) |
---|
69 | ref_p_mbar = ref_p/100; |
---|
70 | ref_dummy = 0; |
---|
71 | // temp_pot de surface (1ere couche) |
---|
72 | disp(m(1,1,15)); // equiv. a p(1,1,3) |
---|
73 | //ref_temppot = m(1,1,15)*(610./ref_p)^(1.0/4.4); |
---|
74 | ref_temppot = m(1,1,15)*(610./ref_p)^(1.0/3.9); |
---|
75 | // ecriture |
---|
76 | mfprintf(fid,"%10.2f",ref_p_mbar); |
---|
77 | mfprintf(fid,"%12.2f",ref_temppot); |
---|
78 | mfprintf(fid,"%12.2f\n",ref_dummy); |
---|
79 | |
---|
80 | // ecriture du profil |
---|
81 | for i=1:resol |
---|
82 | dummy=0; |
---|
83 | pression=p(1,i,1); |
---|
84 | altitude=m(1,i,2); // altitude zero MOLA |
---|
85 | temperature=p(1,i,3); |
---|
86 | density=p(1,i,2); |
---|
87 | cp = m(1,i,8); |
---|
88 | rr = m(1,i,49); |
---|
89 | rcp = rr / cp ; |
---|
90 | //temppot=temperature*(610./pression)^rcp; |
---|
91 | //temppot=temperature*(610./pression)^(1.0/4.4); |
---|
92 | temppot=temperature*(610./pression)^(1.0/3.9); |
---|
93 | u=p(1,i,4); |
---|
94 | v=p(1,i,5); |
---|
95 | |
---|
96 | mfprintf(fid,"%10.2f",altitude); |
---|
97 | mfprintf(fid,"%12.2f",temppot); |
---|
98 | ttab(i)=temppot; |
---|
99 | mfprintf(fid,"%12.2f",dummy); |
---|
100 | mfprintf(fid,"%12.2f",u); |
---|
101 | utab(i)=u; |
---|
102 | mfprintf(fid,"%12.2f\n",v); |
---|
103 | vtab(i)=v; |
---|
104 | mfprintf(fid3,"%12.2f",rr); |
---|
105 | mfprintf(fid3,"%12.2f",cp); |
---|
106 | mfprintf(fid3,"%18.6e",pression); |
---|
107 | mfprintf(fid3,"%18.6e",density); |
---|
108 | mfprintf(fid3,"%12.2f\n",temperature); |
---|
109 | end |
---|
110 | altimetry=m(1,1,2) |
---|
111 | //altimetry=0. //OK |
---|
112 | surftemp=m(1,1,15) |
---|
113 | mfprintf(fid2,"%10.2f",altimetry); |
---|
114 | mfprintf(fid2,"%10.2f",surftemp); |
---|
115 | |
---|
116 | exit |
---|
117 | |
---|
118 | // Plot |
---|
119 | alt_profile=alt_profile/1000; |
---|
120 | xset("window",1) |
---|
121 | style = [1,5]; |
---|
122 | strf = "111"; |
---|
123 | leg = "Zonal@Meridional"; |
---|
124 | rect = [0,min([utab,vtab])-5,max(alt_profile),max([utab,vtab])+5]; //BEWARE : xmin ymin xmax ymax |
---|
125 | plot2d([alt_profile',alt_profile'],[utab,vtab],style,strf,leg,rect); |
---|
126 | // BEWARE : column vector in plot2d |
---|
127 | xtitle("MCD 4.2 wind profiles at longitude "+string(lon)+" deg, latitude "+string(max(lat))+" deg, localtime "+string(lt)+" h, ls "+string(l_s)+" deg","Altitude (km)","Wind (m/s)"); |
---|
128 | |
---|
129 | xset("window",2) |
---|
130 | style = [1]; |
---|
131 | strf = "111"; |
---|
132 | leg = ""; |
---|
133 | rect = [0,min(ttab)-5,max(alt_profile),max(ttab)+5]; //BEWARE : xmin ymin xmax ymax |
---|
134 | plot2d(alt_profile',ttab,style,strf,leg,rect); |
---|
135 | // BEWARE : column vector in plot2d |
---|
136 | xtitle("MCD 4.2 temperature at longitude "+string(lon)+" deg, latitude "+string(max(lat))+" deg, localtime "+string(lt)+" h, ls "+string(l_s)+" deg","Altitude (km)","Temperature (K)"); |
---|
137 | |
---|
138 | //exit |
---|
139 | |
---|
140 | |
---|
141 | |
---|