1 |
|
|
MODULE SUWAVEDI_MOD |
2 |
|
|
CONTAINS |
3 |
|
|
SUBROUTINE SUWAVEDI(KSMAX,KTMAX,KPRTRW,KMYSETW,KASM0,KSPOLEGL,KPROCM,& |
4 |
|
|
&KUMPP,KSPEC,KSPEC2,KSPEC2MX,KPOSSP,KMYMS,& |
5 |
|
|
&KPTRMS,KALLMS,KDIM0G) |
6 |
|
|
|
7 |
|
|
!**** *SUWAVEDI * - Routine to initialize spectral wave distribution |
8 |
|
|
|
9 |
|
|
! Purpose. |
10 |
|
|
! -------- |
11 |
|
|
! Initialize arrays controlling spectral wave distribution |
12 |
|
|
|
13 |
|
|
!** Interface. |
14 |
|
|
! ---------- |
15 |
|
|
! *CALL* *SUWAVEDI * |
16 |
|
|
|
17 |
|
|
! Explicit arguments : |
18 |
|
|
! -------------------- |
19 |
|
|
! KSMAX - Spectral truncation limit (input) |
20 |
|
|
! KTMAX - Overtruncation for KSMAX (input) |
21 |
|
|
! KPRTRW - Number of processors in A-direction (input) |
22 |
|
|
! KMYSETW - A-set for present processor (input) |
23 |
|
|
! KASM0 - Offsets for spectral waves (output) |
24 |
|
|
! KSPOLEGL - Local version of NSPOLEG (output) |
25 |
|
|
! KPROCM - Where a certain spectral wave belongs (output) |
26 |
|
|
! KUMPP - Number of spectral waves on this PE (output) |
27 |
|
|
! KSPEC - Local version on NSPEC (output) |
28 |
|
|
! KSPEC2 - Local version on NSPEC2 (output) |
29 |
|
|
! KSPEC2MX - Maximum KSPEC2 across PEs (output) |
30 |
|
|
! KPOSSP - Global spectral fields partitioning (output) |
31 |
|
|
! KMYMS - This PEs spectral zonal wavenumbers (output) |
32 |
|
|
|
33 |
|
|
! Implicit arguments : NONE |
34 |
|
|
! -------------------- |
35 |
|
|
|
36 |
|
|
! Method. |
37 |
|
|
! ------- |
38 |
|
|
! See documentation |
39 |
|
|
|
40 |
|
|
! Externals. NONE. |
41 |
|
|
! ---------- |
42 |
|
|
|
43 |
|
|
! Reference. |
44 |
|
|
! ---------- |
45 |
|
|
! ECMWF Research Department documentation of the IFS |
46 |
|
|
|
47 |
|
|
! Author. |
48 |
|
|
! ------- |
49 |
|
|
! MPP Group *ECMWF* |
50 |
|
|
|
51 |
|
|
! Modifications. |
52 |
|
|
! -------------- |
53 |
|
|
! Original : 96-01-10 |
54 |
|
|
! L.Isaksen: 96-02-02 - Calculation of KSPEC2MX added |
55 |
|
|
! K.YESSAD : 97-02-18 - Add KTMAX, bug correction for KSPOLEGL. |
56 |
|
|
! ------------------------------------------------------------------ |
57 |
|
|
|
58 |
|
|
USE PARKIND1 ,ONLY : JPIM ,JPRB |
59 |
|
|
|
60 |
|
|
IMPLICIT NONE |
61 |
|
|
|
62 |
|
|
|
63 |
|
|
! DUMMY |
64 |
|
|
INTEGER(KIND=JPIM),INTENT(IN) :: KSMAX |
65 |
|
|
INTEGER(KIND=JPIM),INTENT(IN) :: KTMAX |
66 |
|
|
INTEGER(KIND=JPIM),INTENT(IN) :: KPRTRW |
67 |
|
|
INTEGER(KIND=JPIM),INTENT(IN) :: KMYSETW |
68 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KSPEC |
69 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KSPEC2 |
70 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KSPEC2MX |
71 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KSPOLEGL |
72 |
|
|
|
73 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KASM0(0:KSMAX) |
74 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KPROCM(0:KSMAX) |
75 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KUMPP(KPRTRW) |
76 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KMYMS(KSMAX+1) |
77 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KPOSSP(KPRTRW+1) |
78 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KPTRMS(KPRTRW) |
79 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KALLMS(KSMAX+1) |
80 |
|
|
INTEGER(KIND=JPIM),OPTIONAL,INTENT(OUT) :: KDIM0G(0:KSMAX) |
81 |
|
|
|
82 |
|
|
! LOCAL |
83 |
|
|
INTEGER(KIND=JPIM) :: IK, IL, IND, IPOS, ISPEC2P, JA, JM,JMLOC,IM |
84 |
|
|
INTEGER(KIND=JPIM) :: ISPOLEGL,ISPEC2MX,IASM0(0:KSMAX),IPROCM(0:KSMAX) |
85 |
|
|
INTEGER(KIND=JPIM) :: IUMPP(KPRTRW),IMYMS(KSMAX+1),IPOSSP(KPRTRW+1) |
86 |
|
|
INTEGER(KIND=JPIM) :: IPTRMS(KPRTRW),IALLMS(KSMAX+1),IDIM0G(0:KSMAX) |
87 |
|
|
INTEGER(KIND=JPIM) :: ISPEC(KPRTRW),IC(KPRTRW) |
88 |
|
|
|
89 |
|
|
|
90 |
|
|
! ----------------------------------------------------------------- |
91 |
|
|
|
92 |
|
|
!* 1. Initialize partitioning of wave numbers to PEs |
93 |
|
|
! ---------------------------------------------- |
94 |
|
|
|
95 |
|
|
ISPEC(:) = 0 |
96 |
|
|
|
97 |
|
|
IUMPP(:) = 0 |
98 |
|
|
IASM0(:) = -99 |
99 |
|
|
ISPOLEGL = 0 |
100 |
|
|
|
101 |
|
|
IL = 1 |
102 |
|
|
IND = 1 |
103 |
|
|
IK = 0 |
104 |
|
|
IPOS = 1 |
105 |
|
|
DO JM=0,KSMAX |
106 |
|
|
IK = IK + IND |
107 |
|
|
IF (IK > KPRTRW) THEN |
108 |
|
|
IK = KPRTRW |
109 |
|
|
IND = -1 |
110 |
|
|
ELSEIF (IK < 1) THEN |
111 |
|
|
IK = 1 |
112 |
|
|
IND = 1 |
113 |
|
|
ENDIF |
114 |
|
|
IPROCM(JM) = IK |
115 |
|
|
ISPEC(IK) = ISPEC(IK)+KSMAX-JM+1 |
116 |
|
|
IUMPP(IK) = IUMPP(IK)+1 |
117 |
|
|
IF (IK == KMYSETW) THEN |
118 |
|
|
ISPOLEGL = ISPOLEGL +KTMAX+1-JM+1 |
119 |
|
|
IMYMS(IL) = JM |
120 |
|
|
IASM0(JM) = IPOS |
121 |
|
|
IPOS = IPOS+(KSMAX-JM+1)*2 |
122 |
|
|
IL = IL+1 |
123 |
|
|
ENDIF |
124 |
|
|
ENDDO |
125 |
|
|
|
126 |
|
|
IPOSSP(1) = 1 |
127 |
|
|
ISPEC2P = 2*ISPEC(1) |
128 |
|
|
ISPEC2MX = ISPEC2P |
129 |
|
|
IPTRMS(1) = 1 |
130 |
|
|
DO JA=2,KPRTRW |
131 |
|
|
IPOSSP(JA) = IPOSSP(JA-1)+ISPEC2P |
132 |
|
|
ISPEC2P = 2*ISPEC(JA) |
133 |
|
|
ISPEC2MX = MAX(ISPEC2MX,ISPEC2P) |
134 |
|
|
! pointer to the first wave number of a given wave-set in NALLMS array |
135 |
|
|
IPTRMS(JA) = IPTRMS(JA-1)+IUMPP(JA-1) |
136 |
|
|
ENDDO |
137 |
|
|
IPOSSP(KPRTRW+1) = IPOSSP(KPRTRW)+ISPEC2P |
138 |
|
|
|
139 |
|
|
! IALLMS : wave numbers for all wave-set concatenated together to give all |
140 |
|
|
! wave numbers in wave-set order. |
141 |
|
|
IC(:) = 0 |
142 |
|
|
DO JM=0,KSMAX |
143 |
|
|
IALLMS(IC(IPROCM(JM))+IPTRMS(IPROCM(JM))) = JM |
144 |
|
|
IC(IPROCM(JM)) = IC(IPROCM(JM))+1 |
145 |
|
|
ENDDO |
146 |
|
|
|
147 |
|
|
IPOS = 1 |
148 |
|
|
DO JA=1,KPRTRW |
149 |
|
|
DO JMLOC=1,IUMPP(JA) |
150 |
|
|
IM = IALLMS(IPTRMS(JA)+JMLOC-1) |
151 |
|
|
IDIM0G(IM) = IPOS |
152 |
|
|
IPOS = IPOS+(KSMAX+1-IM)*2 |
153 |
|
|
ENDDO |
154 |
|
|
ENDDO |
155 |
|
|
|
156 |
|
|
IF(PRESENT(KSPEC)) KSPEC = ISPEC(KMYSETW) |
157 |
|
|
IF(PRESENT(KSPEC2)) KSPEC2 = 2*ISPEC(KMYSETW) |
158 |
|
|
IF(PRESENT(KSPEC2MX)) KSPEC2MX = ISPEC2MX |
159 |
|
|
IF(PRESENT(KSPOLEGL)) KSPOLEGL = ISPOLEGL |
160 |
|
|
|
161 |
|
|
IF(PRESENT(KASM0)) KASM0(:) = IASM0(:) |
162 |
|
|
IF(PRESENT(KPROCM)) KPROCM(:) = IPROCM(:) |
163 |
|
|
IF(PRESENT(KUMPP)) KUMPP(:) = IUMPP(:) |
164 |
|
|
IF(PRESENT(KMYMS)) KMYMS(:) = IMYMS(:) |
165 |
|
|
IF(PRESENT(KPOSSP)) KPOSSP(:) = IPOSSP(:) |
166 |
|
|
IF(PRESENT(KPTRMS)) KPTRMS(:) = IPTRMS(:) |
167 |
|
|
IF(PRESENT(KALLMS)) KALLMS(:) = IALLMS(:) |
168 |
|
|
IF(PRESENT(KDIM0G)) KDIM0G(:) = IDIM0G(:) |
169 |
|
|
|
170 |
|
|
END SUBROUTINE SUWAVEDI |
171 |
|
|
END MODULE SUWAVEDI_MOD |
172 |
|
|
|
173 |
|
|
|