-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwriteusrmsgp_wrf.c
92 lines (66 loc) · 3.39 KB
/
writeusrmsgp_wrf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/** FILE NAME: writeusrmsgp_wrf.c
________________________________________________________________________
2017 U.S. Government
Licensed under the U.S. Army Research Laboratory CC0 1.0 Universal (CC0_1.0) Public Domain Dedication
and the Contributor License Agreement (CLA) (together known as the "License"); you may not use this
file except in compliance with the License. You may obtain a copy of the License at
https://github.com/USArmyResearchLab.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
_________________________________________________________________________
This function prints pressure based layer output to the appropriate file. It writes profiles for a user
defined pressure level profile. The data lines in the output file have pressure as the first variable.
Input data are taken from WRF generated "soundings".
*/
#include "convert.h"
int writeusrmsg(struct sound *user, char *outpath)
{
FILE *fuserout;
int i, size;
float zone, midpressure;
char outfile[121], infilename[71];
/* Get output file name. ********************/
strcpy(outfile, outpath);
sscanf(user->site.filename, "%29s", infilename);
/*printf("infilename: %s\n\n", infilename);*/
strcat(outfile, infilename);
strcat(outfile, "_USRMSG_P");
/* Open output file. ************************************/
if(!(fuserout = fopen(outfile,"w")))
{
fprintf(stderr,"Unable to open user data file.\n");
exit(1);
}
/* Print output to files. ************************************/
size = user->nht+1; /*** loop indices ***/
/* USER DEFINED layer output output ***********************/
fprintf(fuserout,"USER DEFINED layer output\n\n");
fprintf(fuserout,"Date: %s Time: %s Latitude: %9.4f Longitude: %9.4f\n",
user->site.date, user->site.time, user->site.lat, user->site.lon);
fprintf(fuserout,"Elevation: %7.2f Ceiling: %7.1f Visibility: %7.1f\n\n",
user->site.elev, user->site.ceil, user->site.vis);
fprintf(fuserout," Line Pres Midpt Hgt Midpt Wind Direction Wind Speed Virt Temp Temperature\n");
fprintf(fuserout," (hPa) (m) (degrees) (kn) (K) (K)\n\n");
for(i=0;i<size;i++)
{
if(user->level[i].spd != ERROR)
{
user->level[i].spd *= NM; /*WRF wind speed in m/s, need knots.*/
}
if(user->level[i].prs != ERROR && i > 0) /*Mean value for midpoint.*/
midpressure = (user->level[i].prs + user->level[i-1].prs) * 0.5;
else if (user->level[i].prs != ERROR)
midpressure = user->level[0].prs;
fprintf(fuserout,"%3d %8.1f %7.0f %7.0f %8.1f %8.1f %8.1f\n",
i, midpressure, user->level[i].hgt,
user->level[i].dir, user->level[i].spd,
user->level[i].vtmp, user->level[i].tmp);
}
printf("\n User defined message printed to USRMSG_P output.\n");
/**********End of output statements**********************/
fclose(fuserout);
return;
}