-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpdstemplates.F90
752 lines (692 loc) · 28.9 KB
/
pdstemplates.F90
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
!> @file
!> @brief Information on all GRIB2 Product Definition Templates used
!> in [Section 4 - the Product Definition Section
!> (PDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect4.shtml)
!> @author Stephen Gilbert @date 2000-05-11
!> @brief Information on all GRIB2 Product Definition Templates used
!> in [Section 4 - the Product Definition Section
!> (PDS)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect4.shtml)
!>
!> Each Template has three parts:
!> 1. The number of entries in the template (mapppdslen);
!> 2. A map of the template (mappds), which contains the number of
!> octets in which to pack each of the template values;
!> 3. a logical value (needext) that indicates whether the Template
!> needs to be extended. In some cases the number of entries in a
!> template can vary depending upon values specified in the static
!> part of the template. (Template 4.3 as an example).
!>
!> This module also contains two subroutines.
!> - getpdstemplate() returns the octet map for a specified
!> Template number.
!> - extpdstemplate() will calculate the extended octet map of an
!> appropriate template given values for the static part of the
!> template.
!>
!> @note Array mapgrid contains the number of octets in which the
!> corresponding template values will be stored. A negative value in
!> mapgrid is used to indicate that the corresponding template entry
!> can contain negative values. This information is used later when
!> packing (or unpacking) the template data values. Negative data
!> values in GRIB are stored with the left most bit set to one, and
!> a negative number of octets value in mapgrid indicates that this
!> possibility should be considered. The number of octets used to
!> store the data value in this case would be the absolute value of
!> the negative value in mapgrid.
!>
!> @author Stephen Gilbert @date 2000-05-11
module pdstemplates
integer, parameter :: MAXLEN = 200 !< MAXLEN max length of entries
integer, parameter :: MAXTEMP = 48 !< MAXTEMP maximum number of templates
!> This is the defined type for a Product Definition Section (PDS)
!> template.
type pdstemplate
integer :: template_num !< Template number.
integer :: mappdslen !< The number of entries in the template.
integer, dimension(MAXLEN) :: mappds !< Number of octets in which to pack each value.
logical :: needext !< Does template need to be extended?
end type pdstemplate
type(pdstemplate), dimension(MAXTEMP) :: templates !< template in type of pdstemplate
data templates(1)%template_num /0/ ! Fcst at Level/Layer
data templates(1)%mappdslen /15/
data templates(1)%needext /.false./
data (templates(1)%mappds(j), j = 1, 15) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4/
data templates(2)%template_num /1/ ! Ens fcst at level/layer
data templates(2)%mappdslen /18/
data templates(2)%needext /.false./
data (templates(2)%mappds(j), j = 1, 18) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1/
data templates(3)%template_num /2/ ! Derived Ens fcst at level/layer
data templates(3)%mappdslen /17/
data templates(3)%needext /.false./
data (templates(3)%mappds(j), j = 1, 17) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1/
data templates(4)%template_num /3/ ! Ens cluster fcst rect. area
data templates(4)%mappdslen /31/
data templates(4)%needext /.true./
data (templates(4)%mappds(j), j = 1, 31) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, 1, 1, 1, 1, -4, -4, 4, 4, &
1, -1, 4, -1, 4/
data templates(5)%template_num /4/ ! Ens cluster fcst circ. area
data templates(5)%mappdslen /30/
data templates(5)%needext /.true./
data (templates(5)%mappds(j), j = 1, 30) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, 1, 1, 1, 1, -4, 4, 4, &
1, -1, 4, -1, 4/
data templates(6)%template_num /5/ ! Prob fcst at level/layer
data templates(6)%mappdslen /22/
data templates(6)%needext /.false./
data (templates(6)%mappds(j), j = 1, 22) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, -1, -4, -1, -4/
data templates(7)%template_num /6/ ! Percentile fcst at level/layer
data templates(7)%mappdslen /16/
data templates(7)%needext /.false./
data (templates(7)%mappds(j), j = 1, 16) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1/
data templates(8)%template_num /7/ ! Error at level/layer
data templates(8)%mappdslen /15/
data templates(8)%needext /.false./
data (templates(8)%mappds(j), j = 1, 15) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4/
data templates(9)%template_num /8/ ! Ave or Accum at level/layer
data templates(9)%mappdslen /29/
data templates(9)%needext /.true./
data (templates(9)%mappds(j), j = 1, 29) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 2, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 4, 1, 4/
data templates(10)%template_num /9/ ! Prob over time interval
data templates(10)%mappdslen /36/
data templates(10)%needext /.true./
data (templates(10)%mappds(j), j = 1, 36) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, -1, -4, -1, -4, 2, 1, 1, 1, &
1, 1, 1, 4, 1, 1, 1, 4, 1, 4/
data templates(11)%template_num /10/ ! Percentile over time interval
data templates(11)%mappdslen /30/
data templates(11)%needext /.true./
data (templates(11)%mappds(j), j = 1, 30) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 2, 1, 1, 1, 1, 1, 1, 4, &
1, 1, 1, 4, 1, 4/
data templates(12)%template_num /11/ ! Ens member over time interval
data templates(12)%mappdslen /32/
data templates(12)%needext /.true./
data (templates(12)%mappds(j), j = 1, 32) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, &
4, 1, 1, 1, 4, 1, 4/
data templates(13)%template_num /12/ ! Derived Ens fcst over time int
data templates(13)%mappdslen /31/
data templates(13)%needext /.true./
data (templates(13)%mappds(j), j = 1, 31) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, &
2, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 4, 1, 4/
data templates(14)%template_num /13/ ! Ens cluster fcst rect. area
data templates(14)%mappdslen /45/
data templates(14)%needext /.true./
data (templates(14)%mappds(j), j = 1, 45) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, 1, 1, 1, 1, -4, -4, 4, 4, &
1, -1, 4, -1, 4, 2, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 4, 1, 4/
data templates(15)%template_num /14/ ! Ens cluster fcst circ. area
data templates(15)%mappdslen /44/
data templates(15)%needext /.true./
data (templates(15)%mappds(j), j = 1, 44) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, 1, 1, 1, 1, -4, 4, 4, &
1, -1, 4, -1, 4, 2, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 4, 1, 4/
data templates(16)%template_num /20/ ! Radar Product
data templates(16)%mappdslen /19/
data templates(16)%needext /.false./
data (templates(16)%mappds(j), j = 1, 19) &
/1, 1, 1, 1, 1, -4, 4, 2, 4, 2, 1, 1, 1, 1, 1, 2, 1, 3, 2/
data templates(17)%template_num /30/ ! Satellite Product
data templates(17)%mappdslen /5/
data templates(17)%needext /.true./
data (templates(17)%mappds(j), j = 1, 5) &
/1, 1, 1, 1, 1/
data templates(18)%template_num /254/ ! CCITTIA5 Character String
data templates(18)%mappdslen /3/
data templates(18)%needext /.false./
data (templates(18)%mappds(j), j = 1, 3) &
/1, 1, 4/
data templates(19)%template_num /1000/ ! Cross section
data templates(19)%mappdslen /9/
data templates(19)%needext /.false./
data (templates(19)%mappds(j), j = 1, 9) &
/1, 1, 1, 1, 1, 2, 1, 1, -4/
data templates(20)%template_num /1001/ ! Cross section over time
data templates(20)%mappdslen /16/
data templates(20)%needext /.false./
data (templates(20)%mappds(j), j = 1, 16) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 4, 1, 1, 1, 4, 1, 4/
data templates(21)%template_num /1002/ ! Cross section processed time
data templates(21)%mappdslen /15/
data templates(21)%needext /.false./
data (templates(21)%mappds(j), j = 1, 15) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, 1, 1, 4, 4, 2/
data templates(22)%template_num /1100/ ! Hovmoller grid
data templates(22)%mappdslen /15/
data templates(22)%needext /.false./
data (templates(22)%mappds(j), j = 1, 15) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4/
data templates(23)%template_num /1101/ ! Hovmoller with stat proc
data templates(23)%mappdslen /22/
data templates(23)%needext /.false./
data (templates(23)%mappds(j), j = 1, 22) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 4, 1, 1, 1, 4, 1, 4/
data templates(24)%template_num /31/ ! Satellite Product
data templates(24)%mappdslen /5/
data templates(24)%needext /.true./
data (templates(24)%mappds(j), j = 1, 5) &
/1, 1, 1, 1, 1/
data templates(25)%template_num /15/ ! Ave or Accum at level/layer
data templates(25)%mappdslen /18/ ! For ICAO WAFS products
data templates(25)%needext /.false./
data (templates(25)%mappds(j), j = 1, 18) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1/
data templates(26)%template_num /40/ ! Analysis or Forecast at a horizontal or in a
data templates(26)%mappdslen /16/ ! horizontal layer at a point in time for
data templates(26)%needext /.false./ ! atmospheric chemical constituents
data (templates(26)%mappds(j), j = 1, 16) &
/1, 1, 2, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4/
data templates(27)%template_num /41/ ! Individual ensemble forecast, control and
data templates(27)%mappdslen /19/ ! perturbed, at horizontal level or
data templates(27)%needext /.false./ ! in a horizontal layer at a point in time for
data (templates(27)%mappds(j), j = 1, 19) & ! atmospheric chemical constituents
/1, 1, 2, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1/
data templates(28)%template_num /42/ ! Average, Accumulation, and/or extreme values or other
data templates(28)%mappdslen /30/ ! statistically-processed values at horizontal level or
data templates(28)%needext /.true./ ! in a horizontal layer in contnunuous or non-continuous time
data (templates(28)%mappds(j), j = 1, 30) & ! interval for atmospheric chemical constituents
/1, 1, 2, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 2, 1, 1, 1, 1, 1, 1, 4, &
1, 1, 1, 4, 1, 4/
data templates(29)%template_num /43/ ! Individual ensemble forecast, control and
data templates(29)%mappdslen /33/ ! perturbed, at horizontal level or in a horizontal
data templates(29)%needext /.true./ ! layer at a point in a continuous or non-continuous time
data (templates(29)%mappds(j), j = 1, 33) & ! interval for atmospheric chemical constituents
/1, 1, 2, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 4, &
1, 1, 1, 4, 1, 4/
data templates(30)%template_num /44/ ! Analysis or Forecast at a horizontal or in a
data templates(30)%mappdslen /21/ ! horizontal layer at a point in time for
data templates(30)%needext /.false./ ! Aerosol
data (templates(30)%mappds(j), j = 1, 21) &
/1, 1, 2, 1, -1, -4, -1, -4, 1, 1, 1, 2, 1, 1, -2, 1, -1, -4, 1, -1, -4/
data templates(31)%template_num /45/ ! Individual ensemble forecast, control and
data templates(31)%mappdslen /24/ ! perturbed, at horizontal level or in a horizontal
data templates(31)%needext /.false./ ! layer at a point in time for Aerosol
data (templates(31)%mappds(j), j = 1, 24) &
/1, 1, 2, 1, -1, -4, -1, -4, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1/
data templates(32)%template_num /46/ ! Ave or Accum or Extreme value at level/layer
data templates(32)%mappdslen /35/ ! in a continuous or non-continuous time interval
data templates(32)%needext /.true./ ! for Aerosol
data (templates(32)%mappds(j), j = 1, 35) &
/1, 1, 2, 1, -1, -4, -1, -4, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 2, 1, 1, 1, 1, &
1, 1, 4, 1, 1, 1, 4, 1, 4/
data templates(33)%template_num /47/ ! Individual ensemble forecast, control and
data templates(33)%mappdslen /38/ ! perturbed, at horizontal level or in a horizontal
data templates(33)%needext /.true./ ! in a continuous or non-continuous time interval
data (templates(33)%mappds(j), j = 1, 38) & ! for Aerosol
/1, 1, 1, 2, 1, -1, -4, -1, -4, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, 2, 1, &
1, 1, 1, 1, 1, 4, 1, 1, 1, 4, 1, 4/
data templates(34)%template_num /51/ ! Categorical forecasts at a horizontal level or
data templates(34)%mappdslen /16/ ! in a horizontal layer at a point in time
data templates(34)%needext /.true./
data (templates(34)%mappds(j), j = 1, 16) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1/
!
! PDT 4.91
!
data templates(35)%template_num /91/ ! Categorical forecasts at a horizontal level or
data templates(35)%mappdslen /36/ ! in a horizontal layer in a continuous or
data templates(35)%needext /.true./ ! non-continuous time interval
data (templates(35)%mappds(j), j = 1, 36) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, -1, -4, -1, -4, &
2, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 4, 1, 4/
data templates(36)%template_num /32/ ! Analysis or forecast at a horizontal level or
data templates(36)%mappdslen /10/ ! in a horizontal layer at a point in time for
data templates(36)%needext /.true./ ! for simulate (synthetic) Satellite data
data (templates(36)%mappds(j), j = 1, 10) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1/
!
! PDT 4.48
!
data templates(37)%template_num /48/ ! Analysis or forecast at a horizontal level or
data templates(37)%mappdslen /26/ ! in a horizontal layer at a point in time for
data templates(37)%needext /.false./ ! Optical Properties of Aerosol
data (templates(37)%mappds(j), j = 1, 26) &
/1, 1, 2, 1, -1, -4, -1, -4, 1, -1, -4, -1, -4, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, &
1, -1, -4/
!
! PDT 4.50 VALIDATION
!
data templates(38)%template_num /50/ ! Analysis or Forecast of a multi component
data templates(38)%mappdslen /21/ ! parameter or matrix element at a point in time
data templates(38)%needext /.false./ !
data (templates(38)%mappds(j), j = 1, 21) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 4, 4, 4, 4/
!
! PDT 4.52 VALIDATION
!
data templates(39)%template_num /52/ ! Analysis or forecast of Wave parameters
data templates(39)%mappdslen /15/ ! at the Sea surface at a point in time
data templates(39)%needext /.false./ !
data (templates(39)%mappds(j), j = 1, 15) &
/1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4/
!
! PDT 4.33 (07/29/2013)
!
data templates(40)%template_num /33/ ! Individual ensemble forecast, control, perturbed,
data templates(40)%mappdslen /18/ ! at a horizontal level or in a horizontal layer
data templates(40)%needext /.true./ ! at a point in time for simulate (synthetic) Satellite data
data (templates(40)%mappds(j), j = 1, 18) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, 2, 2, 2, -1, -4, 1, 1, 1/
!
! PDT 4.34 (07/29/2013)
!
data templates(41)%template_num /34/ ! Individual ensemble forecast, control, perturbed,
data templates(41)%mappdslen /32/ ! at a horizontal level or in a horizontal layer,
data templates(41)%needext /.true./ ! in a continuous or non-continuous interval
data (templates(41)%mappds(j), j = 1, 32) & ! for simulate (synthetic) Satellite data
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, 2, 2, 2, -1, -4, 1, 1, 1, 2, 1, 1, 1, &
1, 1, 1, 4, 1, 1, 1, 4, 1, 4/
!
! PDT 4.53 (07/30/2013)
!
data templates(42)%template_num /53/ ! Partitioned parameters at
data templates(42)%mappdslen /19/ ! horizontal level or horizontal layer
data templates(42)%needext /.true./ ! at a point in time
data (templates(42)%mappds(j), j = 1, 19) &
/1, 1, 1, 1, 4, 2, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4/
!
! PDT 4.54 (07/30/2013)
!
data templates(43)%template_num /54/ ! Individual ensemble forecast, controli and perturbed,
data templates(43)%mappdslen /22/ ! at a horizontal level or in a horizontal layer
data templates(43)%needext /.true./ ! at a point in time for partitioned parameters
data (templates(43)%mappds(j), j = 1, 22) &
/1, 1, 1, 1, 4, 2, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1/
!
! PDT 4.49
!
data templates(44)%template_num /49/ ! Individual Ensemble Forecast, Control and Perturbed,
data templates(44)%mappdslen /29/ ! at a horizontal level or in a horizontal layer at a
data templates(44)%needext /.false./ ! point in time for Optical Properties of Aerosol for
data (templates(44)%mappds(j), j = 1, 29) & ! Optical Properties of Aerosol
/1, 1, 2, 1, -1, -4, -1, -4, 1, -1, -4, -1, -4, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, &
1, -1, -4, 1, 1, 1/
!
! PDT 4.57 (10/07/2015)
!
data templates(45)%template_num /57/ ! Analysis or Forecast at a horizontal level or in a
data templates(45)%mappdslen /7/ ! horizontal layer at a point in time for
data templates(45)%needext /.true./ ! atmospheric chemical constituents based on
data (templates(45)%mappds(j), j = 1, 7) & ! a distribution function.
/1, 1, 2, 2, 2, 2, 1/
!
! PDT 4.60 (10/07/2015)
!
data templates(46)%template_num /60/ ! Individual ensemble reforecast, control and perturbed,
data templates(46)%mappdslen /24/ ! at a horizontal level or in a horizontal layer
data templates(46)%needext /.false./ ! at a point in time.
data (templates(46)%mappds(j), j = 1, 24) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, 2, 1, 1, 1, 1, 1/
!
! PDT 4.61 (10/07/2015)
!
data templates(47)%template_num /61/ ! Individual ensemble reforecast, control and perturbed,
data templates(47)%mappdslen /38/ ! at a horizontal level or in a horizontal layer
data templates(47)%needext /.true./ ! in a continuous or non-continuous time interval.
data (templates(47)%mappds(j), j = 1, 38) &
/1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1, 2, 1, 1, 1, 1, &
1, 2, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 4, 1, 4/
!
! VALIDATION --- PDT 4.35 (10/07/2015)
!
data templates(48)%template_num /35/ ! Satellite product with or without associated
data templates(48)%mappdslen /6/ ! quality values
data templates(48)%needext /.true./
data (templates(48)%mappds(j), j = 1, 6) &
/1, 1, 1, 1, 1, 1/
contains
!> This function returns the index of specified Product
!> Definition Template in array templates.
!>
!> @param[in] number the Product Definition Template number.
!> @return
!> - Index of PDT in array templates, if template exists.
!> - -1, otherwise.
!>
!> @author Stephen Gilbert @date 2001-06-28
integer function getpdsindex(number)
implicit none
integer, intent(in) :: number
integer :: j
getpdsindex = -1
do j = 1, MAXTEMP
if (number .eq. templates(j)%template_num) then
getpdsindex = j
return
endif
enddo
end function getpdsindex
!> This subroutine returns PDS template information for a specified
!> Product Definition Template. The number of entries in the
!> template is returned along with a map of the number of octets
!> occupied by each entry. Also, a flag is returned to indicate
!> whether the template would need to be extended.
!>
!> @param[in] number the Product Definition Template number that is
!> being requested.
!> @param[out] nummap Number of entries in the Template.
!> @param[out] map An array containing the number of octets that each
!> template entry occupies when packed up into the PDS.
!> @param[out] needext Logical variable indicating whether the
!> Product Defintion Template has to be extended.
!> @param[out] iret Error return code.
!> - 0 no error.
!> - 1 Undefine Product Template number.
!>
!> @author Stephen Gilbert @date 2000-05-11
subroutine getpdstemplate(number, nummap, map, needext, iret)
implicit none
integer, intent(in) :: number
integer, intent(out) :: nummap, map(*), iret
logical, intent(out) :: needext
integer :: index
iret = 0
index = getpdsindex(number)
if (index.ne.-1) then
nummap = templates(index)%mappdslen
needext = templates(index)%needext
map(1:nummap) = templates(index)%mappds(1:nummap)
else
nummap = 0
needext = .false.
print *, 'getpdstemplate: PDS Template ', number, &
' not defined.'
iret = 1
endif
end subroutine getpdstemplate
!> This subroutine generates the remaining octet map for a given
!> Product Definition Template, if required. Some Templates can
!> vary depending on data values given in an earlier part of the
!> Template, and it is necessary to know some of the earlier entry
!> values to generate the full octet map of the Template.
!>
!> @param[in] number the Product Definition Template number.
!> @param[in] list An array containing the number of octets that match
!> the Product Definition Template.
!> @param[out] nummap Number of entries in the Template.
!> @param[out] map An array containing the number of octets that each
!> template entry occupies when packed up into the PDS.
!>
!> @author Stephen Gilbert @date 2000-05-11
subroutine extpdstemplate(number, list, nummap, map)
implicit none
integer, intent(in) :: number, list(*)
integer, intent(out) :: nummap, map(*)
integer :: i, index, k, n, j
index = getpdsindex(number)
if (index .eq. -1) return
if (.not. templates(index)%needext) return
nummap = templates(index)%mappdslen
map(1:nummap) = templates(index)%mappds(1:nummap)
if (number .eq. 3) then
N = list(27)
do i = 1, N
map(nummap + i) = 1
enddo
nummap = nummap + N
elseif (number .eq. 4) then
N = list(26)
do i = 1, N
map(nummap + i) = 1
enddo
nummap = nummap + N
elseif (number .eq. 8) then
if (list(22).gt.1) then
do j = 2, list(22)
do k = 1, 6
map(nummap + k) = map(23 + k)
enddo
nummap = nummap + 6
enddo
endif
elseif (number .eq. 9) then
if (list(29).gt.1) then
do j = 2, list(29)
do k = 1, 6
map(nummap + k) = map(30 + k)
enddo
nummap = nummap + 6
enddo
endif
elseif (number .eq. 10) then
if (list(23).gt.1) then
do j = 2, list(23)
do k = 1, 6
map(nummap + k) = map(24 + k)
enddo
nummap = nummap + 6
enddo
endif
elseif (number .eq. 11) then
if (list(25).gt.1) then
do j = 2, list(25)
do k = 1, 6
map(nummap + k) = map(26 + k)
enddo
nummap = nummap + 6
enddo
endif
elseif (number .eq. 12) then
if (list(24).gt.1) then
do j = 2, list(24)
do k = 1, 6
map(nummap + k) = map(25 + k)
enddo
nummap = nummap + 6
enddo
endif
elseif (number .eq. 13) then
if (list(38).gt.1) then
do j = 2, list(38)
do k = 1, 6
map(nummap + k) = map(39 + k)
enddo
nummap = nummap + 6
enddo
endif
N = list(27)
do i = 1, N
map(nummap + i) = 1
enddo
nummap = nummap + N
elseif (number .eq. 14) then
if (list(37).gt.1) then
do j = 2, list(37)
do k = 1, 6
map(nummap + k) = map(38 + k)
enddo
nummap = nummap + 6
enddo
endif
N = list(26)
do i = 1, N
map(nummap + i) = 1
enddo
nummap = nummap + N
elseif (number .eq. 30) then
do j = 1, list(5)
map(nummap + 1) = 2
map(nummap + 2) = 2
map(nummap + 3) = 1
map(nummap + 4) = 1
map(nummap + 5) = 4
nummap = nummap + 5
enddo
elseif (number .eq. 31) then
do j = 1, list(5)
map(nummap + 1) = 2
map(nummap + 2) = 2
map(nummap + 3) = 2
map(nummap + 4) = 1
map(nummap + 5) = 4
nummap = nummap + 5
enddo
elseif (number .eq. 32) then
do j = 1, list(10)
map(nummap + 1) = 2
map(nummap + 2) = 2
map(nummap + 3) = 2
map(nummap + 4) = -1
map(nummap + 5) = -4
nummap = nummap + 5
enddo
elseif (number .eq. 33) then
N = list(10)
do i = 1, N
map(nummap + i) = 1
enddo
nummap = nummap + N
elseif (number .eq. 34) then
if (list(25).gt.1) then
do j = 2, list(25)
do k = 1, 6
map(nummap + k) = map(26 + k)
enddo
nummap = nummap + 6
enddo
endif
N = list(10)
do i = 1, N
map(nummap + i) = 1
enddo
nummap = nummap + N
elseif (number .eq. 35) then
do j = 1, list(6)
map(nummap + 1) = 2
map(nummap + 2) = 2
map(nummap + 3) = 2
map(nummap + 4) = 1
map(nummap + 5) = 4
nummap = nummap + 5
enddo
elseif (number .eq. 42) then
if (list(23).gt.1) then
do j = 2, list(23)
do k = 1, 6
map(nummap + k) = map(24 + k)
enddo
nummap = nummap + 6
enddo
endif
elseif (number .eq. 43) then
if (list(26).gt.1) then
do j = 2, list(26)
do k = 1, 6
map(nummap + k) = map(27 + k)
enddo
nummap = nummap + 6
enddo
endif
elseif (number .eq. 46) then
if (list(28).gt.1) then
do j = 2, list(28)
do k = 1, 6
map(nummap + k) = map(29 + k)
enddo
nummap = nummap + 6
enddo
endif
elseif (number .eq. 47) then
if (list(31).gt.1) then
do j = 2, list(31)
do k = 1, 6
map(nummap + k) = map(32 + k)
enddo
nummap = nummap + 6
enddo
endif
elseif (number .eq. 51) then
do j = 1, list(16)
map(nummap + 1) = 1
map(nummap + 2) = 1
map(nummap + 3) = -1
map(nummap + 4) = -4
map(nummap + 5) = -1
map(nummap + 6) = -4
nummap = nummap + 6
enddo
elseif (number .eq. 53) then
N = list(4)
do i = 1, N
map(nummap + i) = 1
enddo
nummap = nummap + N
elseif (number .eq. 54) then
N = list(4)
do i = 1, N
map(nummap + i) = 1
enddo
nummap = nummap + N
elseif (number .eq. 57) then
do j = 1, list(7)
map(nummap + 1) = 1
map(nummap + 2) = -4
map(nummap + 3) = 1
map(nummap + 4) = 1
map(nummap + 5) = 1
map(nummap + 6) = 2
map(nummap + 7) = 1
map(nummap + 8) = 1
map(nummap + 9) = -4
map(nummap + 10) = 1
map(nummap + 11) = -1
map(nummap + 12) = -4
map(nummap + 13) = 1
map(nummap + 14) = -1
map(nummap + 15) = -4
nummap = nummap + 15
enddo
elseif (number .eq. 61) then
if (list(31) .gt. 1) then
do j = 2, list(31)
do k = 1, 6
map(nummap + k) = map(32 +k)
end do
nummap = nummap + 6
enddo
endif
elseif (number .eq. 91) then
if (list(29).gt.1 ) then
do j = 2, list(29)
do k = 1, 6
map(nummap + k) = map(30 + k)
enddo
nummap = nummap + 6
enddo
endif
N = list(16)
do i = 1, N
map(nummap + i) = 1
enddo
nummap = nummap + N
endif
end subroutine extpdstemplate
!> This function returns the initial length (number of entries) in
!> the static part of specified Product Definition Template.
!>
!> @param[in] number the Product Definition Template number.
!> @return
!> - Number of entries in the static part of PDT.
!> - 0, if requested template is not found.
!>
!> @author Stephen Gilbert @date 2004-05-11
integer function getpdtlen(number)
implicit none
integer, intent(in) :: number
integer :: index
getpdtlen = 0
index = getpdsindex(number)
if (index .ne. -1) then
getpdtlen=templates(index)%mappdslen
endif
end function getpdtlen
end module pdstemplates