-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
executable file
·2621 lines (2480 loc) · 110 KB
/
README
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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Documentation of the spectral transform library splib May 2, 1996
--------------------------------------------------------------------------------
I. Introduction
The spectral transform library splib contains FORTRAN subprograms
to be used for a variety of spectral transform functions.
The library has been optimized for the CRAY machines, taking full advantage
of both the vector and parallel capabilities. The library is particularly
efficient when transforming many fields at one time. Some entry points
will diagnose the environmental number of CPUs available, but others require
the number of CPUs used be specified. The library is reasonably transportable
to other platforms with compilers allowing dynamic automatic arrays.
The library can handle both scalar and two-dimensional vector fields.
Each vector field will be represented in spectral space appropriately
by its respective spherical divergence and curl (vorticity), thus
avoiding the pole problems associated with representing components separately.
Some of the functions performed by the library are spectral interpolations
between two grids, spectral truncations in place on a grid, and basic
spectral transforms between grid and wave space. Only global Gaussian
or global equidistant cylindrical grids are allowed for transforming into
wave space. There are no such restricitions on grids for transforming from
wave space. However, there are special fast entry points for transforming wave
space to polar stereographic and Mercator grids as well as the aforementioned
cylindrical grids.
The indexing of the cylindrical transform grids is totally general.
The grids may run north to south or south to north; they may run east to west
or west to east; they may start at any longitude as long as the prime meridian
is on the grid; they may be dimensioned in any order (e.g. (i,j,k), (k,j,i),
(i,k,nfield,j), etc.). Furthermore, the transform may be performed on only
some of the latitudes at one time as long as both hemisphere counterparts
are transformed at the same time (as in the global spectral model).
The grid indexing will default to the customary global indexing, i.e. north to
south, east to west, prime meridian as first longitude, and (i,j,k) order.
The wave space may be either triangular or rhomboidal in shape.
Its internal indexing is strictly "IBM order", i.e. zonal wavenumber is the
slower index with the real and imaginary components always paired together.
The imaginary components of all the zonally symmetric modes should always
be zero, as should the global mean of any divergence and vorticity fields.
The stride between the start of successive wave fields is general,
defaulting to the computed length of each field.
This documentation is divided into 4 chapters. Chapter I is this introduction.
Chapter II is a list of all entry points. Chapter III is a set of examples.
Chapter IV is a recapitulation of all the docblocks. The chapters all start
on a line number that is 1 modulo 60 in order to facilitate laser printing.
II. Entry point list
Name Function
---- ------------------------------------------------------------------
Spectral interpolations or truncations between grid and grid
SPTRUN SPECTRALLY TRUNCATE GRIDDED SCALAR FIELDS
SPTRUNV SPECTRALLY TRUNCATE GRIDDED VECTOR FIELDS
SPTRUNG SPECTRALLY INTERPOLATE SCALARS TO STATIONS
SPTRUNGV SPECTRALLY INTERPOLATE VECTORS TO STATIONS
SPTRUNS SPECTRALLY INTERPOLATE SCALARS TO POLAR STEREO
SPTRUNSV SPECTRALLY INTERPOLATE VECTORS TO POLAR STEREO
SPTRUNM SPECTRALLY INTERPOLATE SCALARS TO MERCATOR
SPTRUNMV SPECTRALLY INTERPOLATE VECTORS TO MERCATOR
Spectral transforms between wave and grid
SPTRAN PERFORM A SCALAR SPHERICAL TRANSFORM
SPTRANV PERFORM A VECTOR SPHERICAL TRANSFORM
SPTRAND PERFORM A GRADIENT SPHERICAL TRANSFORM
SPTGPT TRANSFORM SPECTRAL SCALAR TO STATION POINTS
SPTGPTV TRANSFORM SPECTRAL VECTOR TO STATION POINTS
SPTGPTD TRANSFORM SPECTRAL TO STATION POINT GRADIENTS
SPTGPS TRANSFORM SPECTRAL SCALAR TO POLAR STEREO
SPTGPSV TRANSFORM SPECTRAL VECTOR TO POLAR STEREO
SPTGPSD TRANSFORM SPECTRAL TO POLAR STEREO GRADIENTS
SPTGPM TRANSFORM SPECTRAL SCALAR TO MERCATOR
SPTGPMV TRANSFORM SPECTRAL VECTOR TO MERCATOR
SPTGPMD TRANSFORM SPECTRAL TO MERCATOR GRADIENTS
Spectral transform utilities
SPGGET GET GRID-SPACE CONSTANTS
SPWGET GET WAVE-SPACE CONSTANTS
SPLAT COMPUTE LATITUDE FUNCTIONS
SPEPS COMPUTE UTILITY SPECTRAL FIELDS
SPLEGEND COMPUTE LEGENDRE POLYNOMIALS
SPANALY ANALYZE SPECTRAL FROM FOURIER
SPSYNTH SYNTHESIZE FOURIER FROM SPECTRAL
SPDZ2UV COMPUTE WINDS FROM DIVERGENCE AND VORTICITY
SPUV2DZ COMPUTE DIVERGENCE AND VORTICITY FROM WINDS
SPGRADQ COMPUTE GRADIENT IN SPECTRAL SPACE
SPLAPLAC COMPUTE LAPLACIAN IN SPECTRAL SPACE
III. Examples
Example 1. Interpolate heights and winds from a latlon grid
to two antipodal polar stereographic grids.
Subprograms GETGB and PUTGB from w3lib are referenced.
c unit number 11 is the input latlon grib file
c unit number 31 is the input latlon grib index file
c unit number 51 is the output northern polar stereographic grib file
c unit number 52 is the output southern polar stereographic grib file
c nominal spectral truncation is r40
c maximum input gridsize is 360x181
c maximum number of levels wanted is 12
parameter(lug=11,lui=31,lun=51,lus=52)
parameter(iromb=1,maxwv=40,jf=360*181,kx=12)
integer kp5(kx),kp6(kx),kp7(kx)
integer kpo(kx)
data kpo/1000,850,700,500,400,300,250,200,150,100,70,50/
c height
km=12
kp5=7
kp6=100
kp7=kpo
call gs65(lug,lui,lun,lus,jf,km,kp5,kp6,kp7,iromb,maxwv)
c winds
km=12
kp5=33
kp6=100
kp7=kpo
call gv65(lug,lui,lun,lus,jf,km,kp5,kp6,kp7,iromb,maxwv)
c
stop
end
c
subroutine gs65(lug,lui,lun,lus,jf,km,kp5,kp6,kp7,iromb,maxwv)
c interpolates a scalar field using spectral transforms.
integer kp5(km),kp6(km),kp7(km)
c output grids are 65x65 (381 km true at latitide 60).
c nh grid oriented at 280E; sh grid oriented at 100E.
parameter(nph=32,nps=2*nph+1,npq=nps*nps)
parameter(true=60.,xmesh=381.e3,orient=280.)
parameter(rerth=6.3712e6)
parameter(pi=3.14159265358979,dpr=180./pi)
real gn(npq,km),gs(npq,km)
integer jpds(25),jgds(22),kpds(25,km),kgds(22,km)
logical lb(jf)
real f(jf,km)
c
g2=((1.+sin(abs(true)/dpr))*rerth/xmesh)**2
r2=2*nph**2
rlatn1=dpr*asin((g2-r2)/(g2+r2))
rlonn1=mod(orient+315,360.)
rlats1=-rlatn1
rlons1=mod(rlonn1+270,360.)
jpds=-1
do k=1,km
jpds(5)=kp5(k)
jpds(6)=kp6(k)
jpds(7)=kp7(k)
j=0
call getgb(lug,lui,jf,j,jpds,jgds,kf,j,kpds(1,k),kgds(1,k),
& lb,f(1,k),iret)
if(iret.ne.0) call exit(1)
if(mod(kpds(4,k)/64,2).eq.1) call exit(2)
enddo
idrt=kgds(1,1)
imax=kgds(2,1)
jmax=kgds(3,1)
c
call sptruns(iromb,maxwv,idrt,imax,jmax,km,nps,
& 0,0,0,jf,0,0,0,0,true,xmesh,orient,f,gn,gs)
c
do k=1,km
kpds(3,k)=27
kgds(1,k)=5
kgds(2,k)=nps
kgds(3,k)=nps
kgds(4,k)=nint(rlatn1*1.e3)
kgds(5,k)=nint(rlonn1*1.e3)
kgds(6,k)=8
kgds(7,k)=nint(orient*1.e3)
kgds(8,k)=nint(xmesh)
kgds(9,k)=nint(xmesh)
kgds(10,k)=0
kgds(11,k)=64
call putgb(lun,npq,kpds(1,k),kgds(1,k),lb,gn(1,k),iret)
enddo
do k=1,km
kpds(3,k)=28
kgds(1,k)=5
kgds(2,k)=nps
kgds(3,k)=nps
kgds(4,k)=nint(rlats1*1.e3)
kgds(5,k)=nint(rlons1*1.e3)
kgds(6,k)=8
kgds(7,k)=nint(mod(orient+180,360.)*1.e3)
kgds(8,k)=nint(xmesh)
kgds(9,k)=nint(xmesh)
kgds(10,k)=128
kgds(11,k)=64
call putgb(lus,npq,kpds(1,k),kgds(1,k),lb,gs(1,k),iret)
enddo
c
end
c
subroutine gv65(lug,lui,lun,lus,jf,km,kp5,kp6,kp7,iromb,maxwv)
c interpolates a vector field using spectral transforms.
integer kp5(km),kp6(km),kp7(km)
c output grids are 65x65 (381 km true at latitide 60).
c nh grid oriented at 280E; sh grid oriented at 100E.
c winds are rotated to be relative to grid coordinates.
parameter(nph=32,nps=2*nph+1,npq=nps*nps)
parameter(true=60.,xmesh=381.e3,orient=280.)
parameter(rerth=6.3712e6)
parameter(pi=3.14159265358979,dpr=180./pi)
real un(npq,km),vn(npq,km),us(npq,km),vs(npq,km)
integer jpds(25),jgds(22),kpds(25,km),kgds(22,km)
logical lb(jf)
real u(jf,km),v(jf,km)
c
g2=((1.+sin(abs(true)/dpr))*rerth/xmesh)**2
r2=2*nph**2
rlatn1=dpr*asin((g2-r2)/(g2+r2))
rlonn1=mod(orient+315,360.)
rlats1=-rlatn1
rlons1=mod(rlonn1+270,360.)
jpds=-1
do k=1,km
jpds(5)=kp5(k)
jpds(6)=kp6(k)
jpds(7)=kp7(k)
j=0
call getgb(lug,lui,jf,j,jpds,jgds,kf,j,kpds(1,k),kgds(1,k),
& lb,u(1,k),iret)
if(iret.ne.0) call exit(1)
if(mod(kpds(4,k)/64,2).eq.1) call exit(2)
jpds=kpds(:,k)
jgds=kgds(:,k)
jpds(5)=jpds(5)+1
j=0
call getgb(lug,lui,jf,j,jpds,jgds,kf,j,kpds(1,k),kgds(1,k),
& lb,v(1,k),iret)
if(iret.ne.0) call exit(1)
if(mod(kpds(4,k)/64,2).eq.1) call exit(2)
enddo
idrt=kgds(1,1)
imax=kgds(2,1)
jmax=kgds(3,1)
c
call sptrunsv(iromb,maxwv,idrt,imax,jmax,km,nps,
& 0,0,0,jf,0,0,0,0,true,xmesh,orient,u,v,
& .true.,un,vn,us,vs,.false.,dum,dum,dum,dum,
& .false.,dum,dum,dum,dum)
c
do k=1,km
kpds(3,k)=27
kgds(1,k)=5
kgds(2,k)=nps
kgds(3,k)=nps
kgds(4,k)=nint(rlatn1*1.e3)
kgds(5,k)=nint(rlonn1*1.e3)
kgds(6,k)=8
kgds(7,k)=nint(orient*1.e3)
kgds(8,k)=nint(xmesh)
kgds(9,k)=nint(xmesh)
kgds(10,k)=0
kgds(11,k)=64
kpds(5,k)=kp5(k)
call putgb(lun,npq,kpds(1,k),kgds(1,k),lb,un(1,k),iret)
enddo
do k=1,km
kpds(3,k)=27
kgds(1,k)=5
kgds(2,k)=nps
kgds(3,k)=nps
kgds(4,k)=nint(rlatn1*1.e3)
kgds(5,k)=nint(rlonn1*1.e3)
kgds(6,k)=8
kgds(7,k)=nint(orient*1.e3)
kgds(8,k)=nint(xmesh)
kgds(9,k)=nint(xmesh)
kgds(10,k)=0
kgds(11,k)=64
kpds(5,k)=kp5(k)+1
call putgb(lun,npq,kpds(1,k),kgds(1,k),lb,vn(1,k),iret)
enddo
do k=1,km
kpds(3,k)=28
kgds(1,k)=5
kgds(2,k)=nps
kgds(3,k)=nps
kgds(4,k)=nint(rlats1*1.e3)
kgds(5,k)=nint(rlons1*1.e3)
kgds(6,k)=8
kgds(7,k)=nint(mod(orient+180,360.)*1.e3)
kgds(8,k)=nint(xmesh)
kgds(9,k)=nint(xmesh)
kgds(10,k)=128
kgds(11,k)=64
kpds(5,k)=kp5(k)
call putgb(lus,npq,kpds(1,k),kgds(1,k),lb,us(1,k),iret)
enddo
do k=1,km
kpds(3,k)=28
kgds(1,k)=5
kgds(2,k)=nps
kgds(3,k)=nps
kgds(4,k)=nint(rlats1*1.e3)
kgds(5,k)=nint(rlons1*1.e3)
kgds(6,k)=8
kgds(7,k)=nint(mod(orient+180,360.)*1.e3)
kgds(8,k)=nint(xmesh)
kgds(9,k)=nint(xmesh)
kgds(10,k)=128
kgds(11,k)=64
kpds(5,k)=kp5(k)+1
call putgb(lus,npq,kpds(1,k),kgds(1,k),lb,vs(1,k),iret)
enddo
c
end
Example 2. Spectrally truncate winds in place on a latlon grid.
c unit number 11 is the input latlon grib file
c unit number 31 is the input latlon grib index file
c unit number 51 is the output latlon grib file
c nominal spectral truncation is r40
c maximum input gridsize is 360x181
c maximum number of levels wanted is 12
parameter(lug=11,lui=31,luo=51)
parameter(iromb=1,maxwv=40,jf=360*181,kx=12)
integer kp5(kx),kp6(kx),kp7(kx)
integer kpo(kx)
data kpo/1000,850,700,500,400,300,250,200,150,100,70,50/
c winds
km=12
kp5=33
kp6=100
kp7=kpo
call gvr40(lug,lui,luo,jf,km,kp5,kp6,kp7,iromb,maxwv)
c
stop
end
c
subroutine gvr40(lug,lui,luo,jf,km,kp5,kp6,kp7,iromb,maxwv)
c interpolates a vector field using spectral transforms.
integer kp5(km),kp6(km),kp7(km)
integer jpds(25),jgds(22),kpds(25,km),kgds(22,km)
logical lb(jf)
real u(jf,km),v(jf,km)
c
jpds=-1
do k=1,km
jpds(5)=kp5(k)
jpds(6)=kp6(k)
jpds(7)=kp7(k)
j=0
call getgb(lug,lui,jf,j,jpds,jgds,kf,j,kpds(1,k),kgds(1,k),
& lb,u(1,k),iret)
if(iret.ne.0) call exit(1)
if(mod(kpds(4,k)/64,2).eq.1) call exit(2)
jpds=kpds(:,k)
jgds=kgds(:,k)
jpds(5)=jpds(5)+1
j=0
call getgb(lug,lui,jf,j,jpds,jgds,kf,j,kpds(1,k),kgds(1,k),
& lb,v(1,k),iret)
if(iret.ne.0) call exit(1)
if(mod(kpds(4,k)/64,2).eq.1) call exit(2)
enddo
idrt=kgds(1,1)
imax=kgds(2,1)
jmax=kgds(3,1)
c
call sptrunv(iromb,maxwv,idrt,imax,jmax,idrt,imax,jmax,km,
& 0,0,0,jf,0,0,jf,0,u,v,.true.,u,v,
& .false.,dum,dum,.false.,dum,dum)
c
do k=1,km
kpds(5,k)=kp5(k)
call putgb(luo,kf,kpds(1,k),kgds(1,k),lb,u(1,k),iret)
enddo
do k=1,km
kpds(5,k)=kp5(k)+1
call putgb(luo,kf,kpds(1,k),kgds(1,k),lb,v(1,k),iret)
enddo
c
end
Example 3. Compute latlon temperatures from spectral temperatures and
compute latlon winds from spectral divergence and vorticity.
c unit number 11 is the input sigma file
c unit number 51 is the output latlon file
c nominal spectral truncation is t62
c output gridsize is 144x73
c number of levels is 28
parameter(iromb=0,maxwv=62)
parameter(idrt=0,im=144,jm=73)
parameter(levs=28)
parameter(mx=(maxwv+1)*((iromb+1)*maxwv+2)/2)
real t(mx,levs),d(mx,levs),z(mx,levs)
real tg(im,jm,km),ug(im,jm,km),vg(im,jm,km)
c temperature
do k=1,4
read(11)
enddo
do k=1,levs
read(11) (t(m,k),m=1,mx)
enddo
call sptran(iromb,maxwv,idrt,im,jm,levs,0,0,0,0,0,0,0,0,1,
& t,tg(1,1,1),tg(1,jm,1),1)
call sptran(
do k=1,levs
write(51) ((tg(i,j,k),i=1,im),j=1,jm)
enddo
c winds
do k=1,levs
read(11) (d(m,k),m=1,mx)
read(11) (z(m,k),m=1,mx)
enddo
call sptranv(iromb,maxwv,idrt,im,jm,levs,0,0,0,0,0,0,0,0,1,
& d,z,ug(1,1,1),ug(1,jm,1),vg(1,1,1),vg(1,jm,1),1)
do k=1,levs
write(51) ((ug(i,j,k),i=1,im),j=1,jm)
write(51) ((vg(i,j,k),i=1,im),j=1,jm)
enddo
end
IV. Docblocks
The primary documentation of splib is via the docblocks in its subprograms.
The following recapitulation of docblocks is current as of May, 1996.
Docblock for sptrun.
C$$$ SUBPROGRAM DOCUMENTATION BLOCK
C
C SUBPROGRAM: SPTRUN SPECTRALLY TRUNCATE GRIDDED SCALAR FIELDS
C PRGMMR: IREDELL ORG: W/NMC23 DATE: 96-02-29
C
C ABSTRACT: THIS SUBPROGRAM SPECTRALLY TRUNCATES SCALAR FIELDS
C ON A GLOBAL CYLINDRICAL GRID, RETURNING THE FIELDS
C TO A POSSIBLY DIFFERENT GLOBAL CYLINDRICAL GRID.
C THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
C EITHER GRID-SPACE CAN BE EITHER AN EQUALLY-SPACED GRID
C (WITH OR WITHOUT POLE POINTS) OR A GAUSSIAN GRID.
C THE GRID FIELDS MAY HAVE GENERAL INDEXING.
C THE TRANSFORMS ARE ALL MULTIPROCESSED.
C TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
C SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
C
C PROGRAM HISTORY LOG:
C 96-02-29 IREDELL
C
C USAGE: CALL SPTRUN(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,IDRTO,IMAXO,JMAXO,
C & KMAX,IPRIME,ISKIPI,JSKIPI,KSKIPI,
C & ISKIPO,JSKIPO,KSKIPO,JCPU,GRIDI,GRIDO)
C INPUT ARGUMENTS:
C IROMB - INTEGER SPECTRAL DOMAIN SHAPE
C (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
C MAXWV - INTEGER SPECTRAL TRUNCATION
C IDRTI - INTEGER INPUT GRID IDENTIFIER
C (IDRTI=4 FOR GAUSSIAN GRID,
C IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
C IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
C IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
C JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
C IDRTO - INTEGER OUTPUT GRID IDENTIFIER
C (IDRTO=4 FOR GAUSSIAN GRID,
C IDRTO=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
C IDRTO=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
C IMAXO - INTEGER EVEN NUMBER OF OUTPUT LONGITUDES.
C JMAXO - INTEGER NUMBER OF OUTPUT LATITUDES.
C KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
C IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
C (DEFAULTS TO 1 IF IPRIME=0)
C (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
C ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
C (DEFAULTS TO 1 IF ISKIPI=0)
C JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
C (DEFAULTS TO -IMAXI IF JSKIPI=0)
C KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
C (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
C ISKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LONGITUDES
C (DEFAULTS TO 1 IF ISKIPO=0)
C JSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LATITUDES FROM SOUTH
C (DEFAULTS TO -IMAXO IF JSKIPO=0)
C KSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT GRID FIELDS
C (DEFAULTS TO IMAXO*JMAXO IF KSKIPO=0)
C JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
C (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
C GRIDI - REAL (*) INPUT GRID FIELDS
C OUTPUT ARGUMENTS:
C GRIDO - REAL (*) OUTPUT GRID FIELDS
C (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
C
C SUBPROGRAMS CALLED:
C SPTRAN PERFORM A SCALAR SPHERICAL TRANSFORM
C NCPUS GETS ENVIRONMENT NUMBER OF CPUS
C
C REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
C DIMENSION LINEAR QUADRATIC
C ----------------------- --------- -------------
C IMAX 2*MAXWV+2 3*MAXWV/2*2+2
C JMAX (IDRT=4,IROMB=0) 1*MAXWV+1 3*MAXWV/2+1
C JMAX (IDRT=4,IROMB=1) 2*MAXWV+1 5*MAXWV/2+1
C JMAX (IDRT=0,IROMB=0) 2*MAXWV+3 3*MAXWV/2*2+3
C JMAX (IDRT=0,IROMB=1) 4*MAXWV+3 5*MAXWV/2*2+3
C JMAX (IDRT=256,IROMB=0) 2*MAXWV+1 3*MAXWV/2*2+1
C JMAX (IDRT=256,IROMB=1) 4*MAXWV+1 5*MAXWV/2*2+1
C ----------------------- --------- -------------
C
C ATTRIBUTES:
C LANGUAGE: FORTRAN 77
C
C$$$
Docblock for sptrunv.
C$$$ SUBPROGRAM DOCUMENTATION BLOCK
C
C SUBPROGRAM: SPTRUNV SPECTRALLY TRUNCATE GRIDDED VECTOR FIELDS
C PRGMMR: IREDELL ORG: W/NMC23 DATE: 96-02-29
C
C ABSTRACT: THIS SUBPROGRAM SPECTRALLY TRUNCATES VECTOR FIELDS
C ON A GLOBAL CYLINDRICAL GRID, RETURNING THE FIELDS
C TO A POSSIBLY DIFFERENT GLOBAL CYLINDRICAL GRID.
C THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
C EITHER GRID-SPACE CAN BE EITHER AN EQUALLY-SPACED GRID
C (WITH OR WITHOUT POLE POINTS) OR A GAUSSIAN GRID.
C THE GRID FIELDS MAY HAVE GENERAL INDEXING.
C THE TRANSFORMS ARE ALL MULTIPROCESSED.
C OVER ZONAL WAVENUMBER TO ENSURE REPRODUCIBILITY.
C TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
C SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
C
C PROGRAM HISTORY LOG:
C 96-02-29 IREDELL
C
C USAGE: CALL SPTRUNV(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,
C & IDRTO,IMAXO,JMAXO,KMAX,
C & IPRIME,ISKIPI,JSKIPI,KSKIPI,
C & ISKIPO,JSKIPO,KSKIPO,JCPU,GRIDUI,GRIDVI,
C & LUV,GRIDUO,GRIDVO,LDZ,GRIDDO,GRIDZO,
C & LPS,GRIDPO,GRIDSO)
C INPUT ARGUMENTS:
C IROMB - INTEGER SPECTRAL DOMAIN SHAPE
C (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
C MAXWV - INTEGER SPECTRAL TRUNCATION
C IDRTI - INTEGER INPUT GRID IDENTIFIER
C (IDRTI=4 FOR GAUSSIAN GRID,
C IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
C IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
C IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
C JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
C IDRTO - INTEGER OUTPUT GRID IDENTIFIER
C (IDRTO=4 FOR GAUSSIAN GRID,
C IDRTO=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
C IDRTO=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
C IMAXO - INTEGER EVEN NUMBER OF OUTPUT LONGITUDES.
C JMAXO - INTEGER NUMBER OF OUTPUT LATITUDES.
C KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
C IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
C (DEFAULTS TO 1 IF IPRIME=0)
C (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
C ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
C (DEFAULTS TO 1 IF ISKIPI=0)
C JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
C (DEFAULTS TO -IMAXI IF JSKIPI=0)
C KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
C (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
C ISKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LONGITUDES
C (DEFAULTS TO 1 IF ISKIPO=0)
C JSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT LATITUDES FROM SOUTH
C (DEFAULTS TO -IMAXO IF JSKIPO=0)
C KSKIPO - INTEGER SKIP NUMBER BETWEEN OUTPUT GRID FIELDS
C (DEFAULTS TO IMAXO*JMAXO IF KSKIPO=0)
C JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
C (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
C GRIDUI - REAL (*) INPUT GRID U-WINDS
C GRIDVI - REAL (*) INPUT GRID V-WINDS
C LUV - LOGICAL FLAG WHETHER TO RETURN WINDS
C LDZ - LOGICAL FLAG WHETHER TO RETURN DIVERGENCE AND VORTICITY
C LPS - LOGICAL FLAG WHETHER TO RETURN POTENTIAL AND STREAMFCN
C OUTPUT ARGUMENTS:
C GRIDUO - REAL (*) OUTPUT U-WINDS IF LUV
C (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
C GRIDVO - REAL (*) OUTPUT V-WINDS IF LUV
C (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
C GRIDDO - REAL (*) OUTPUT DIVERGENCES IF LDZ
C (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
C GRIDZO - REAL (*) OUTPUT VORTICITIES IF LDZ
C (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
C GRIDPO - REAL (*) OUTPUT POTENTIALS IF LPS
C (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
C GRIDSO - REAL (*) OUTPUT STREAMFCNS IF LPS
C (MAY OVERLAY INPUT FIELDS IF GRID SHAPE IS APPROPRIATE)
C
C SUBPROGRAMS CALLED:
C SPWGET GET WAVE-SPACE CONSTANTS
C SPLAPLAC COMPUTE LAPLACIAN IN SPECTRAL SPACE
C SPTRAN PERFORM A SCALAR SPHERICAL TRANSFORM
C SPTRANV PERFORM A VECTOR SPHERICAL TRANSFORM
C NCPUS GETS ENVIRONMENT NUMBER OF CPUS
C
C REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
C DIMENSION LINEAR QUADRATIC
C ----------------------- --------- -------------
C IMAX 2*MAXWV+2 3*MAXWV/2*2+2
C JMAX (IDRT=4,IROMB=0) 1*MAXWV+1 3*MAXWV/2+1
C JMAX (IDRT=4,IROMB=1) 2*MAXWV+1 5*MAXWV/2+1
C JMAX (IDRT=0,IROMB=0) 2*MAXWV+3 3*MAXWV/2*2+3
C JMAX (IDRT=0,IROMB=1) 4*MAXWV+3 5*MAXWV/2*2+3
C JMAX (IDRT=256,IROMB=0) 2*MAXWV+1 3*MAXWV/2*2+1
C JMAX (IDRT=256,IROMB=1) 4*MAXWV+1 5*MAXWV/2*2+1
C ----------------------- --------- -------------
C
C ATTRIBUTES:
C LANGUAGE: FORTRAN 77
C
C$$$
Docblock for sptrung.
C$$$ SUBPROGRAM DOCUMENTATION BLOCK
C
C SUBPROGRAM: SPTRUNG SPECTRALLY INTERPOLATE SCALARS TO STATIONS
C PRGMMR: IREDELL ORG: W/NMC23 DATE: 96-02-29
C
C ABSTRACT: THIS SUBPROGRAM SPECTRALLY TRUNCATES SCALAR FIELDS
C ON A GLOBAL CYLINDRICAL GRID, RETURNING THE FIELDS
C TO SPECIFIED SETS OF STATION POINTS ON THE GLOBE.
C THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
C THE GRID-SPACE CAN BE EITHER AN EQUALLY-SPACED GRID
C (WITH OR WITHOUT POLE POINTS) OR A GAUSSIAN GRID.
C THE GRID AND POINT FIELDS MAY HAVE GENERAL INDEXING.
C THE TRANSFORMS ARE ALL MULTIPROCESSED.
C TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
C SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
C
C PROGRAM HISTORY LOG:
C 96-02-29 IREDELL
C
C USAGE: CALL SPTRUNG(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,KMAX,NMAX,
C & IPRIME,ISKIPI,JSKIPI,KSKIPI,KGSKIP,
C & NRSKIP,NGSKIP,JCPU,RLAT,RLON,GRIDI,GP)
C INPUT ARGUMENTS:
C IROMB - INTEGER SPECTRAL DOMAIN SHAPE
C (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
C MAXWV - INTEGER SPECTRAL TRUNCATION
C IDRTI - INTEGER INPUT GRID IDENTIFIER
C (IDRTI=4 FOR GAUSSIAN GRID,
C IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
C IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
C IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
C JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
C KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
C NMAX - INTEGER NUMBER OF STATION POINTS TO RETURN
C IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
C (DEFAULTS TO 1 IF IPRIME=0)
C (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
C ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
C (DEFAULTS TO 1 IF ISKIPI=0)
C JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
C (DEFAULTS TO -IMAXI IF JSKIPI=0)
C KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
C (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
C KGSKIP - INTEGER SKIP NUMBER BETWEEN STATION POINT SETS
C (DEFAULTS TO NMAX IF KGSKIP=0)
C NRSKIP - INTEGER SKIP NUMBER BETWEEN STATION LATS AND LONS
C (DEFAULTS TO 1 IF NRSKIP=0)
C NGSKIP - INTEGER SKIP NUMBER BETWEEN STATION POINTS
C (DEFAULTS TO 1 IF NGSKIP=0)
C RLAT - REAL (*) STATION LATITUDES IN DEGREES
C RLON - REAL (*) STATION LONGITUDES IN DEGREES
C JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
C (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
C GRIDI - REAL (*) INPUT GRID FIELDS
C OUTPUT ARGUMENTS:
C GP - REAL (*) STATION POINT SETS
C
C SUBPROGRAMS CALLED:
C SPTRAN PERFORM A SCALAR SPHERICAL TRANSFORM
C SPTGPT TRANSFORM SPECTRAL SCALAR TO STATION POINTS
C NCPUS GETS ENVIRONMENT NUMBER OF CPUS
C
C REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
C DIMENSION LINEAR QUADRATIC
C ----------------------- --------- -------------
C IMAX 2*MAXWV+2 3*MAXWV/2*2+2
C JMAX (IDRT=4,IROMB=0) 1*MAXWV+1 3*MAXWV/2+1
C JMAX (IDRT=4,IROMB=1) 2*MAXWV+1 5*MAXWV/2+1
C JMAX (IDRT=0,IROMB=0) 2*MAXWV+3 3*MAXWV/2*2+3
C JMAX (IDRT=0,IROMB=1) 4*MAXWV+3 5*MAXWV/2*2+3
C JMAX (IDRT=256,IROMB=0) 2*MAXWV+1 3*MAXWV/2*2+1
C JMAX (IDRT=256,IROMB=1) 4*MAXWV+1 5*MAXWV/2*2+1
C ----------------------- --------- -------------
C
C ATTRIBUTES:
C LANGUAGE: FORTRAN 77
C
C$$$
Docblock for sptrungv.
C$$$ SUBPROGRAM DOCUMENTATION BLOCK
C
C SUBPROGRAM: SPTRUNGV SPECTRALLY INTERPOLATE VECTORS TO STATIONS
C PRGMMR: IREDELL ORG: W/NMC23 DATE: 96-02-29
C
C ABSTRACT: THIS SUBPROGRAM SPECTRALLY TRUNCATES VECTORS FIELDS
C ON A GLOBAL CYLINDRICAL GRID, RETURNING THE FIELDS
C TO SPECIFIED SETS OF STATION POINTS ON THE GLOBE.
C THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
C THE GRID-SPACE CAN BE EITHER AN EQUALLY-SPACED GRID
C (WITH OR WITHOUT POLE POINTS) OR A GAUSSIAN GRID.
C THE GRID AND POINT FIELDS MAY HAVE GENERAL INDEXING.
C THE TRANSFORMS ARE ALL MULTIPROCESSED.
C TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
C SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
C
C PROGRAM HISTORY LOG:
C 96-02-29 IREDELL
C
C USAGE: CALL SPTRUNGV(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,KMAX,NMAX,
C & IPRIME,ISKIPI,JSKIPI,KSKIPI,KGSKIP,
C & NRSKIP,NGSKIP,JCPU,RLAT,RLON,GRIDUI,GRIDVI,
C & LUV,UP,VP,LDZ,DP,ZP,LPS,PP,SP)
C INPUT ARGUMENTS:
C IROMB - INTEGER SPECTRAL DOMAIN SHAPE
C (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
C MAXWV - INTEGER SPECTRAL TRUNCATION
C IDRTI - INTEGER INPUT GRID IDENTIFIER
C (IDRTI=4 FOR GAUSSIAN GRID,
C IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
C IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
C IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
C JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
C KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
C NMAX - INTEGER NUMBER OF STATION POINTS TO RETURN
C IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
C (DEFAULTS TO 1 IF IPRIME=0)
C (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
C ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
C (DEFAULTS TO 1 IF ISKIPI=0)
C JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
C (DEFAULTS TO -IMAXI IF JSKIPI=0)
C KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
C (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
C KGSKIP - INTEGER SKIP NUMBER BETWEEN STATION POINT SETS
C (DEFAULTS TO NMAX IF KGSKIP=0)
C NRSKIP - INTEGER SKIP NUMBER BETWEEN STATION LATS AND LONS
C (DEFAULTS TO 1 IF NRSKIP=0)
C NGSKIP - INTEGER SKIP NUMBER BETWEEN STATION POINTS
C (DEFAULTS TO 1 IF NGSKIP=0)
C RLAT - REAL (*) STATION LATITUDES IN DEGREES
C RLON - REAL (*) STATION LONGITUDES IN DEGREES
C JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
C (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
C GRIDUI - REAL (*) INPUT GRID U-WINDS
C GRIDVI - REAL (*) INPUT GRID V-WINDS
C LUV - LOGICAL FLAG WHETHER TO RETURN WINDS
C LDZ - LOGICAL FLAG WHETHER TO RETURN DIVERGENCE AND VORTICITY
C LPS - LOGICAL FLAG WHETHER TO RETURN POTENTIAL AND STREAMFCN
C OUTPUT ARGUMENTS:
C UP - REAL (*) STATION U-WINDS IF LUV
C VP - REAL (*) STATION V-WINDS IF LUV
C DP - REAL (*) STATION DIVERGENCES IF LDZ
C ZP - REAL (*) STATION VORTICITIES IF LDZ
C PP - REAL (*) STATION POTENTIALS IF LPS
C SP - REAL (*) STATION STREAMFCNS IF LPS
C
C SUBPROGRAMS CALLED:
C SPWGET GET WAVE-SPACE CONSTANTS
C SPLAPLAC COMPUTE LAPLACIAN IN SPECTRAL SPACE
C SPTRANV PERFORM A VECTOR SPHERICAL TRANSFORM
C SPTGPT TRANSFORM SPECTRAL SCALAR TO STATION POINTS
C SPTGPTV TRANSFORM SPECTRAL VECTOR TO STATION POINTS
C NCPUS GETS ENVIRONMENT NUMBER OF CPUS
C
C REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
C DIMENSION LINEAR QUADRATIC
C ----------------------- --------- -------------
C IMAX 2*MAXWV+2 3*MAXWV/2*2+2
C JMAX (IDRT=4,IROMB=0) 1*MAXWV+1 3*MAXWV/2+1
C JMAX (IDRT=4,IROMB=1) 2*MAXWV+1 5*MAXWV/2+1
C JMAX (IDRT=0,IROMB=0) 2*MAXWV+3 3*MAXWV/2*2+3
C JMAX (IDRT=0,IROMB=1) 4*MAXWV+3 5*MAXWV/2*2+3
C JMAX (IDRT=256,IROMB=0) 2*MAXWV+1 3*MAXWV/2*2+1
C JMAX (IDRT=256,IROMB=1) 4*MAXWV+1 5*MAXWV/2*2+1
C ----------------------- --------- -------------
C
C ATTRIBUTES:
C LANGUAGE: FORTRAN 77
C
C$$$
Docblock for sptruns.
C$$$ SUBPROGRAM DOCUMENTATION BLOCK
C
C SUBPROGRAM: SPTRUNS SPECTRALLY INTERPOLATE SCALARS TO POLAR STEREO
C PRGMMR: IREDELL ORG: W/NMC23 DATE: 96-02-29
C
C ABSTRACT: THIS SUBPROGRAM SPECTRALLY TRUNCATES SCALAR FIELDS
C ON A GLOBAL CYLINDRICAL GRID, RETURNING THE FIELDS
C TO SPECIFIC PAIRS OF POLAR STEREOGRAPHIC SCALAR FIELDS.
C THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
C THE GRID-SPACE CAN BE EITHER AN EQUALLY-SPACED GRID
C (WITH OR WITHOUT POLE POINTS) OR A GAUSSIAN GRID.
C THE GRID FIELDS MAY HAVE GENERAL INDEXING.
C THE TRANSFORMS ARE ALL MULTIPROCESSED.
C TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
C SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
C
C PROGRAM HISTORY LOG:
C 96-02-29 IREDELL
C
C USAGE: CALL SPTRUNS(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,KMAX,NPS,
C & IPRIME,ISKIPI,JSKIPI,KSKIPI,KGSKIP,
C & NISKIP,NJSKIP,JCPU,TRUE,XMESH,ORIENT,
C & GRIDI,GN,GS)
C INPUT ARGUMENTS:
C IROMB - INTEGER SPECTRAL DOMAIN SHAPE
C (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
C MAXWV - INTEGER SPECTRAL TRUNCATION
C IDRTI - INTEGER INPUT GRID IDENTIFIER
C (IDRTI=4 FOR GAUSSIAN GRID,
C IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
C IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
C IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
C JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
C KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
C NPS - INTEGER ODD ORDER OF THE POLAR STEREOGRAPHIC GRIDS
C IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
C (DEFAULTS TO 1 IF IPRIME=0)
C (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
C ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
C (DEFAULTS TO 1 IF ISKIPI=0)
C JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
C (DEFAULTS TO -IMAXI IF JSKIPI=0)
C KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
C (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
C KGSKIP - INTEGER SKIP NUMBER BETWEEN GRID FIELDS
C (DEFAULTS TO NPS*NPS IF KGSKIP=0)
C NISKIP - INTEGER SKIP NUMBER BETWEEN GRID I-POINTS
C (DEFAULTS TO 1 IF NISKIP=0)
C NJSKIP - INTEGER SKIP NUMBER BETWEEN GRID J-POINTS
C (DEFAULTS TO NPS IF NJSKIP=0)
C JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
C (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
C TRUE - REAL LATITUDE AT WHICH PS GRID IS TRUE (USUALLY 60.)
C XMESH - REAL GRID LENGTH AT TRUE LATITUDE (M)
C ORIENT - REAL LONGITUDE AT BOTTOM OF NORTHERN PS GRID
C (SOUTHERN PS GRID WILL HAVE OPPOSITE ORIENTATION.)
C GRIDI - REAL (*) INPUT GRID FIELDS
C OUTPUT ARGUMENTS:
C GN - REAL (*) NORTHERN POLAR STEREOGRAPHIC FIELDS
C GS - REAL (*) SOUTHERN POLAR STEREOGRAPHIC FIELDS
C
C SUBPROGRAMS CALLED:
C SPTRAN PERFORM A SCALAR SPHERICAL TRANSFORM
C SPTGPS TRANSFORM SPECTRAL SCALAR TO POLAR STEREO.
C NCPUS GETS ENVIRONMENT NUMBER OF CPUS
C
C REMARKS: MINIMUM GRID DIMENSIONS FOR UNALIASED TRANSFORMS TO SPECTRAL:
C DIMENSION LINEAR QUADRATIC
C ----------------------- --------- -------------
C IMAX 2*MAXWV+2 3*MAXWV/2*2+2
C JMAX (IDRT=4,IROMB=0) 1*MAXWV+1 3*MAXWV/2+1
C JMAX (IDRT=4,IROMB=1) 2*MAXWV+1 5*MAXWV/2+1
C JMAX (IDRT=0,IROMB=0) 2*MAXWV+3 3*MAXWV/2*2+3
C JMAX (IDRT=0,IROMB=1) 4*MAXWV+3 5*MAXWV/2*2+3
C JMAX (IDRT=256,IROMB=0) 2*MAXWV+1 3*MAXWV/2*2+1
C JMAX (IDRT=256,IROMB=1) 4*MAXWV+1 5*MAXWV/2*2+1
C ----------------------- --------- -------------
C
C ATTRIBUTES:
C LANGUAGE: FORTRAN 77
C
C$$$
Docblock for sptrunsv.
C$$$ SUBPROGRAM DOCUMENTATION BLOCK
C
C SUBPROGRAM: SPTRUNSV SPECTRALLY INTERPOLATE VECTORS TO POLAR STEREO
C PRGMMR: IREDELL ORG: W/NMC23 DATE: 96-02-29
C
C ABSTRACT: THIS SUBPROGRAM SPECTRALLY TRUNCATES VECTOR FIELDS
C ON A GLOBAL CYLINDRICAL GRID, RETURNING THE FIELDS
C TO SPECIFIC PAIRS OF POLAR STEREOGRAPHIC SCALAR FIELDS.
C THE WAVE-SPACE CAN BE EITHER TRIANGULAR OR RHOMBOIDAL.
C THE GRID-SPACE CAN BE EITHER AN EQUALLY-SPACED GRID
C (WITH OR WITHOUT POLE POINTS) OR A GAUSSIAN GRID.
C THE GRID FIELDS MAY HAVE GENERAL INDEXING.
C THE TRANSFORMS ARE ALL MULTIPROCESSED.
C TRANSFORM SEVERAL FIELDS AT A TIME TO IMPROVE VECTORIZATION.
C SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
C
C PROGRAM HISTORY LOG:
C 96-02-29 IREDELL
C
C USAGE: CALL SPTRUNSV(IROMB,MAXWV,IDRTI,IMAXI,JMAXI,KMAX,NPS,
C & IPRIME,ISKIPI,JSKIPI,KSKIPI,KGSKIP,
C & NISKIP,NJSKIP,JCPU,TRUE,XMESH,ORIENT,
C & GRIDUI,GRIDVI,
C & LUV,UN,VN,US,VS,LDZ,DN,ZN,DS,ZS,
C & LPS,PN,SN,PS,SS)
C INPUT ARGUMENTS:
C IROMB - INTEGER SPECTRAL DOMAIN SHAPE
C (0 FOR TRIANGULAR, 1 FOR RHOMBOIDAL)
C MAXWV - INTEGER SPECTRAL TRUNCATION
C IDRTI - INTEGER INPUT GRID IDENTIFIER
C (IDRTI=4 FOR GAUSSIAN GRID,
C IDRTI=0 FOR EQUALLY-SPACED GRID INCLUDING POLES,
C IDRTI=256 FOR EQUALLY-SPACED GRID EXCLUDING POLES)
C IMAXI - INTEGER EVEN NUMBER OF INPUT LONGITUDES.
C JMAXI - INTEGER NUMBER OF INPUT LATITUDES.
C KMAX - INTEGER NUMBER OF FIELDS TO TRANSFORM.
C NPS - INTEGER ODD ORDER OF THE POLAR STEREOGRAPHIC GRIDS
C IPRIME - INTEGER INPUT LONGITUDE INDEX FOR THE PRIME MERIDIAN.
C (DEFAULTS TO 1 IF IPRIME=0)
C (OUTPUT LONGITUDE INDEX FOR PRIME MERIDIAN ASSUMED 1.)
C ISKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LONGITUDES
C (DEFAULTS TO 1 IF ISKIPI=0)
C JSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT LATITUDES FROM SOUTH
C (DEFAULTS TO -IMAXI IF JSKIPI=0)
C KSKIPI - INTEGER SKIP NUMBER BETWEEN INPUT GRID FIELDS
C (DEFAULTS TO IMAXI*JMAXI IF KSKIPI=0)
C KGSKIP - INTEGER SKIP NUMBER BETWEEN GRID FIELDS
C (DEFAULTS TO NPS*NPS IF KGSKIP=0)
C NISKIP - INTEGER SKIP NUMBER BETWEEN GRID I-POINTS
C (DEFAULTS TO 1 IF NISKIP=0)
C NJSKIP - INTEGER SKIP NUMBER BETWEEN GRID J-POINTS
C (DEFAULTS TO NPS IF NJSKIP=0)
C JCPU - INTEGER NUMBER OF CPUS OVER WHICH TO MULTIPROCESS
C (DEFAULTS TO ENVIRONMENT NCPUS IF JCPU=0)
C TRUE - REAL LATITUDE AT WHICH PS GRID IS TRUE (USUALLY 60.)
C XMESH - REAL GRID LENGTH AT TRUE LATITUDE (M)
C ORIENT - REAL LONGITUDE AT BOTTOM OF NORTHERN PS GRID
C (SOUTHERN PS GRID WILL HAVE OPPOSITE ORIENTATION.)
C GRIDUI - REAL (*) INPUT GRID U-WINDS
C GRIDVI - REAL (*) INPUT GRID V-WINDS
C LUV - LOGICAL FLAG WHETHER TO RETURN WINDS
C LDZ - LOGICAL FLAG WHETHER TO RETURN DIVERGENCE AND VORTICITY
C LPS - LOGICAL FLAG WHETHER TO RETURN POTENTIAL AND STREAMFCN
C OUTPUT ARGUMENTS: