-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwriteusrlvlsp.c
90 lines (65 loc) · 3.35 KB
/
writeusrlvlsp.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
/** FILE NAME: writeusrlvlsp.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 level based output to appropriate files. It writes
interpolated values for a user defined pressure level structure. The data lines in
the output file have pressure as the first variable. Input data are taken from the
University of Wyoming web site, the NOAA archive, or other source of upper air files.
If input data are in m/s "uncomment" the appropriate lines near the end.
*/
#include "convert.h"
int writeusrlvl(struct sound *user, char *outpath)
{
FILE *fuseroutl;
int i, size;
float zone;
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, "_USRLVL_P");
/* Open output file. ************************************/
if(!(fuseroutl = fopen(outfile,"w")))
{
fprintf(stderr,"Unable to open user data file.\n");
exit(1);
}
/* Print output to files. ************************************/
size = user->nht; /*** loop indices ***/
/*printf("\n size = %5d\n\n", size);*/
/* USER DEFINED level output ***********************/
fprintf(fuseroutl,"USER DEFINED level output\n\n");
fprintf(fuseroutl,"Date: %s Time: %s Latitude: %9.4f Longitude: %9.4f\n",
user->site.date, user->site.time, user->site.lat, user->site.lon);
fprintf(fuseroutl,"Elevation: %7.2f Ceiling: %7.1f Visibility: %7.1f\n\n",
user->site.elev, user->site.ceil, user->site.vis);
fprintf(fuseroutl," Line Pressure Height Wind Direction Wind Speed Virt Temp Temperature\n");
fprintf(fuseroutl," (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;*/ /*U Wyoming data already in knots. No need to convert.*/
/*}*/
fprintf(fuseroutl,"%3d %8.0f %7.0f %7.0f %8.1f %8.1f %8.1f\n",
i, user->level[i].prs, 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 USRLVL_P output.\n");
/**********End of output statements**********************/
fclose(fuseroutl);
return;
}