49g2c_get_datetime(
int ipdtn,
long long int *ipdtmpl,
short year,
unsigned char month,
unsigned char day,
50 unsigned char hour,
unsigned char minute,
unsigned char second,
char *tabbrev)
52 int iutpos, iutpos2, iunit, iunit2;
55 int itemp, itemp2, is;
66 0, 0, 0, 0, 0, 0, 0, 16, 23, 17, 19, 18, 32, 31, 0, 0, 0, 0, 0, 0,
67 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
68 0, 17, 20, 0, 0, 22, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0,
71 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
72 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
73 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
74 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
75 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
81 0, 0, 0, 0, 0, 0, 0, 26, 33, 27,
82 29, 28, 42, 41, 0, 0, 0, 0, 0, 0,
83 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
84 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
85 0, 22, 30, 0, 0, 32, 35, 0, 0, 0,
86 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
87 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
88 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
89 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
90 33, 0, 0, 0, 0, 0, 0, 0, 0, 0,
91 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
92 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
93 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
94 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
97 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
98 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
99 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
105 assert(ipdtn >= 0 && ipdtmpl && tabbrev);
110 if (ipdtn <= 15 || ipdtn == 32 || ipdtn == 50 || ipdtn == 51 || ipdtn == 91)
112 else if (ipdtn >= 40 && ipdtn <= 43)
114 else if (ipdtn >= 44 && ipdtn <= 47)
116 else if (ipdtn == 48)
118 else if (ipdtn == 52)
124 switch (ipdtmpl[iutpos])
127 strcpy(tunit,
"minute");
131 strcpy(tunit,
"hour");
135 strcpy(tunit,
"day");
139 strcpy(tunit,
"month");
143 strcpy(tunit,
"year");
147 strcpy(tunit,
"hour");
151 strcpy(tunit,
"hour");
155 strcpy(tunit,
"hour");
161 iutpos2 = ipos2[ipdtn - 1];
164 switch (ipdtmpl[iutpos2])
167 strcpy(tunit2,
"minute");
171 strcpy(tunit2,
"hour");
175 strcpy(tunit2,
"day");
179 strcpy(tunit2,
"month");
183 strcpy(tunit2,
"year");
187 strcpy(tunit2,
"hour");
191 strcpy(tunit2,
"hour");
195 strcpy(tunit2,
"hour");
200 sprintf(reftime,
"%4.4d%2.2d%2.2d%2.2d:%2.2d:%2.2d", year, month, day, hour, minute, second);
202 itemp = abs(ipdtmpl[iutpos + 1]) * iunit;
206 sprintf(tabbrev,
"valid at %lld", ipdtmpl[iutpos + 1]);
211 if ((ipdtn >= 0 && ipdtn <= 7) || ipdtn == 15 || ipdtn == 20 || (ipdtn >= 30 && ipdtn <= 32) || ipdtn == 40 ||
212 ipdtn == 41 || ipdtn == 44 || ipdtn == 45 || ipdtn == 48 || (ipdtn >= 50 && ipdtn <= 52))
214 sprintf(tabbrev,
"valid %d %s after %s", itemp, tunit, reftime);
218 is = ipos[ipdtn - 1] - 1;
219 sprintf(endtime,
"%4.4d%2.2d%2.2d%2.2d:%2.2d:%2.2d", (
int)ipdtmpl[is], (
int)ipdtmpl[is + 1],
220 (
int)ipdtmpl[is + 2], (
int)ipdtmpl[is + 3], (
int)ipdtmpl[is + 4], (
int)ipdtmpl[is + 5]);
222 itemp2 = abs(ipdtmpl[iutpos2]) * iunit2;
223 itemp2 = itemp + itemp2;
224 sprintf(tmpval2,
"%d", itemp2);
225 if (ipdtn == 8 && ipdtmpl[8] < 0)
228 sprintf(tabbrev,
"(%d -%d) valid %d %s before %s to %s", itemp, itemp2, itemp, tunit, reftime, endtime);
230 else if ((ipdtn >= 8 && ipdtn <= 14) || (ipdtn >= 42 && ipdtn <= 47) ||
235 sprintf(tabbrev,
"(%d -%d hr) valid %d %s after %s to %s", itemp, itemp2, itemp, tunit, reftime, endtime);
320 assert(ipdtn >= 0 && ipdtmpl && level_desc);
327 else if (ipdtn >= 40 && ipdtn <= 43)
329 else if (ipdtn >= 44 && ipdtn <= 47)
331 else if (ipdtn == 48)
333 else if (ipdtn >= 50 && ipdtn <= 51)
335 else if (ipdtn == 52)
337 else if (ipdtn == 91)
343 if (ipdtmpl[ipos] == 100 && ipdtmpl[ipos + 3] == 255)
345 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1] + 2)))
347 sprintf(level_desc,
"%s %s", tmpval1,
"mb");
350 else if (ipdtmpl[ipos] == 100 && ipdtmpl[ipos + 3] == 100)
352 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1] + 2)))
354 if ((ret =
format_level(tmpval2, ipdtmpl[ipos + 5], ipdtmpl[ipos + 4] + 2)))
356 sprintf(level_desc,
"%s - %s mb", tmpval1, tmpval2);
361 else if (ipdtmpl[ipos] == 101)
363 strcpy(level_desc,
" Mean Sea Level");
366 else if (ipdtmpl[ipos] == 102 && ipdtmpl[ipos + 3] == 255)
368 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1])))
370 sprintf(level_desc,
"%s %s", tmpval1,
"m above MSL");
375 else if (ipdtmpl[ipos] == 103 && ipdtmpl[ipos + 3] == 255)
379 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1])))
381 sprintf(level_desc,
"%s %s", tmpval1,
"m above ground");
384 else if (ipdtmpl[ipos] == 103 && ipdtmpl[ipos + 3] == 103)
386 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1])))
388 if ((ret =
format_level(tmpval2, ipdtmpl[ipos + 5], ipdtmpl[ipos + 4])))
390 sprintf(level_desc,
"%s - %s m AGL", tmpval1, tmpval2);
396 else if (ipdtmpl[ipos] == 104 && ipdtmpl[ipos + 3] == 255)
398 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1])))
400 sprintf(level_desc,
"%s %s", tmpval1,
"sigma");
405 else if (ipdtmpl[ipos] == 104 && ipdtmpl[ipos + 3] == 104)
407 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1])))
409 if ((ret =
format_level(tmpval2, ipdtmpl[ipos + 5], ipdtmpl[ipos + 4])))
411 sprintf(level_desc,
"%s - %s sigma", tmpval1, tmpval2);
417 else if (ipdtmpl[ipos] == 105 && ipdtmpl[ipos + 3] == 255)
419 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1])))
421 sprintf(level_desc,
"%s %s", tmpval1,
"hybrid lvl");
426 else if (ipdtmpl[ipos] == 105 && ipdtmpl[ipos + 3] == 105)
428 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1])))
430 if ((ret =
format_level(tmpval2, ipdtmpl[ipos + 5], ipdtmpl[ipos + 4])))
432 sprintf(level_desc,
"%s - %s hybrid lvl", tmpval1, tmpval2);
438 else if (ipdtmpl[ipos] == 106 && ipdtmpl[ipos + 3] == 255)
440 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1])))
442 sprintf(level_desc,
"%s %s", tmpval1,
"m below land");
447 else if (ipdtmpl[ipos] == 106 && ipdtmpl[ipos + 3] == 106)
449 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1])))
451 if ((ret =
format_level(tmpval2, ipdtmpl[ipos + 5], ipdtmpl[ipos + 4])))
453 sprintf(level_desc,
"%s - %s m DBLY", tmpval1, tmpval2);
458 else if (ipdtmpl[ipos] == 107)
460 strcpy(level_desc,
" Isentropic level");
463 else if (ipdtmpl[ipos] == 108 && ipdtmpl[ipos + 3] == 108)
465 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1] + 2)))
467 if ((ret =
format_level(tmpval2, ipdtmpl[ipos + 5], ipdtmpl[ipos + 4] + 2)))
469 sprintf(level_desc,
"%s - %s mb SPDY", tmpval1, tmpval2);
476 else if (ipdtmpl[ipos] == 110)
478 strcpy(level_desc,
" Layer bet 2-hyb lvl");
481 else if (ipdtmpl[ipos] == 109 && ipdtmpl[ipos + 3] == 255)
483 if ((ret =
format_level(tmpval1, ipdtmpl[ipos + 2], ipdtmpl[ipos + 1])))
485 sprintf(level_desc,
"%s %s", tmpval1,
"pv surface");
490 else if (ipdtmpl[ipos] == 111)
491 strcpy(level_desc,
" Eta level");
492 else if (ipdtmpl[ipos] == 114)
493 strcpy(level_desc,
" Layer bet. 2-isent.");
494 else if (ipdtmpl[ipos] == 117)
495 strcpy(level_desc,
" Mixed layer depth");
496 else if (ipdtmpl[ipos] == 120)
497 strcpy(level_desc,
" Layer bet. 2-Eta lvl");
498 else if (ipdtmpl[ipos] == 121)
499 strcpy(level_desc,
" Layer bet. 2-isob.");
500 else if (ipdtmpl[ipos] == 125)
501 strcpy(level_desc,
" Specified height lvl");
502 else if (ipdtmpl[ipos] == 126)
503 strcpy(level_desc,
" Isobaric level");
504 else if (ipdtmpl[ipos] == 160)
505 strcpy(level_desc,
" Depth below sea lvl");
506 else if (ipdtmpl[ipos] == 170)
507 strcpy(level_desc,
" Ionospheric D-region lvl");
508 else if (ipdtmpl[ipos] == 1)
509 strcpy(level_desc,
" Surface");
510 else if (ipdtmpl[ipos] == 2)
511 strcpy(level_desc,
" Cloud base lvl");
512 else if (ipdtmpl[ipos] == 3)
513 strcpy(level_desc,
" Cloud top lvl");
514 else if (ipdtmpl[ipos] == 4)
515 strcpy(level_desc,
" 0 Deg Isotherm");
516 else if (ipdtmpl[ipos] == 5)
517 strcpy(level_desc,
" Level of adiabatic" );
518 else if (ipdtmpl[ipos] == 6)
519 strcpy(level_desc,
" Max wind lvl");
520 else if (ipdtmpl[ipos] == 7)
521 strcpy(level_desc,
" Tropopause");
522 else if (ipdtmpl[ipos] == 8)
523 strcpy(level_desc,
" Nom. top");
524 else if (ipdtmpl[ipos] == 9)
525 strcpy(level_desc,
" Sea Bottom");
526 else if (ipdtmpl[ipos] == 10)
527 strcpy(level_desc,
" Entire Atmosphere");
528 else if (ipdtmpl[ipos] == 11)
529 strcpy(level_desc,
" Cumulonimbus Base");
530 else if (ipdtmpl[ipos] == 12)
531 strcpy(level_desc,
" Cumulonimbus Top");
532 else if (ipdtmpl[ipos] == 20)
533 strcpy(level_desc,
" Isothermal level");
534 else if (ipdtmpl[ipos] == 200)
535 strcpy(level_desc,
" Entire Atmosphere");
536 else if (ipdtmpl[ipos] == 201)
537 strcpy(level_desc,
" Entire ocean");
538 else if (ipdtmpl[ipos] == 204)
539 strcpy(level_desc,
" Highest Frz. lvl");
540 else if (ipdtmpl[ipos] == 206)
541 strcpy(level_desc,
" Grid scale cloud bl");
542 else if (ipdtmpl[ipos] == 207)
543 strcpy(level_desc,
" Grid scale cloud tl");
544 else if (ipdtmpl[ipos] == 209)
545 strcpy(level_desc,
" Boundary layer cbl");
546 else if (ipdtmpl[ipos] == 210)
547 strcpy(level_desc,
" Boundary layer ctl");
548 else if (ipdtmpl[ipos] == 211)
549 strcpy(level_desc,
" Boundary layer cl");
550 else if (ipdtmpl[ipos] == 212)
551 strcpy(level_desc,
" Low cloud bot. lvl");
552 else if (ipdtmpl[ipos] == 213)
553 strcpy(level_desc,
" Low cloud top lvl");
554 else if (ipdtmpl[ipos] == 214)
555 strcpy(level_desc,
" Low cloud layer");
556 else if (ipdtmpl[ipos] == 215)
557 strcpy(level_desc,
" Cloud ceiling");
558 else if (ipdtmpl[ipos] == 220)
559 strcpy(level_desc,
" Planetary boundary");
560 else if (ipdtmpl[ipos] == 221)
561 strcpy(level_desc,
" Layer 2 Hybrid lvl");
562 else if (ipdtmpl[ipos] == 222)
563 strcpy(level_desc,
" Mid. cloud bot. lvl");
564 else if (ipdtmpl[ipos] == 223)
565 strcpy(level_desc,
" Mid. cloud top lvl");
566 else if (ipdtmpl[ipos] == 224)
567 strcpy(level_desc,
" Middle cloud layer");
568 else if (ipdtmpl[ipos] == 232)
569 strcpy(level_desc,
" High cloud bot. lvl");
570 else if (ipdtmpl[ipos] == 233)
571 strcpy(level_desc,
" High cloud top lvl");
572 else if (ipdtmpl[ipos] == 234)
573 strcpy(level_desc,
" High cloud layer");
574 else if (ipdtmpl[ipos] == 235)
575 strcpy(level_desc,
" Ocean Isotherm lvl");
576 else if (ipdtmpl[ipos] == 236)
577 strcpy(level_desc,
" Layer 2-depth below");
578 else if (ipdtmpl[ipos] == 237)
579 strcpy(level_desc,
" Bot. Ocean mix. lyr");
580 else if (ipdtmpl[ipos] == 238)
581 strcpy(level_desc,
" Bot. Ocean iso. lyr");
582 else if (ipdtmpl[ipos] == 239)
583 strcpy(level_desc,
" layer ocean sfc 26C" );
584 else if (ipdtmpl[ipos] == 240)
585 strcpy(level_desc,
" Ocean Mixed Layer");
586 else if (ipdtmpl[ipos] == 241)
587 strcpy(level_desc,
" Order Seq. Of Data");
588 else if (ipdtmpl[ipos] == 242)
589 strcpy(level_desc,
" Con. cloud bot. lvl");
590 else if (ipdtmpl[ipos] == 243)
591 strcpy(level_desc,
" Con. cloud top lvl");
592 else if (ipdtmpl[ipos] == 244)
593 strcpy(level_desc,
" Conv. cloud layer");
594 else if (ipdtmpl[ipos] == 245)
595 strcpy(level_desc,
" Lowest lvl wet bulb");
596 else if (ipdtmpl[ipos] == 246)
597 strcpy(level_desc,
" Max. equi. potential");
598 else if (ipdtmpl[ipos] == 247)
599 strcpy(level_desc,
" Equilibrium level");
600 else if (ipdtmpl[ipos] == 248)
601 strcpy(level_desc,
" Shallow con. cld bl");
602 else if (ipdtmpl[ipos] == 249)
603 strcpy(level_desc,
" Shallow con. cld tl");
604 else if (ipdtmpl[ipos] == 251)
605 strcpy(level_desc,
" Deep conv. cld bl");
606 else if (ipdtmpl[ipos] == 252)
607 strcpy(level_desc,
" Deep conv. cld tl");
608 else if (ipdtmpl[ipos] == 253)
609 strcpy(level_desc,
" Lowest bot. lvl sup" );
610 else if (ipdtmpl[ipos] == 254)
611 strcpy(level_desc,
" highest top lvl sup" );
614 sprintf(level_desc,
" %4d (Unknown Lvl)", (
int)ipdtmpl[ipos]);