ROMS
Loading...
Searching...
No Matches
mod_stepping.F
Go to the documentation of this file.
1#include "cppdefs.h"
3!
4!git $Id$
5!================================================== Hernan G. Arango ===
6! Copyright (c) 2002-2025 The ROMS Group !
7! Licensed under a MIT/X style license !
8! See License_ROMS.md !
9!=======================================================================
10! !
11! This MODULE contains time stepping indices. !
12! !
13#ifdef ADJUST_BOUNDARY
14! Lbinp Open boundary adjustment input fields index. !
15! Lbout Open boundary adjustment output fields index. !
16#endif
17#if defined ADJUST_BOUNDARY || defined ADJUST_STFLUX || \
18 defined adjust_wstress
19! Lfinp Surface forcing adjustment input fields index. !
20! Lfout Surface forcing adjustment output fields index. !
21#endif
22! Lnew New descent algorithm state solution index. !
23! Lold Previous descent algorithm state solution index. !
24! !
25! knew Barotropic (fast) time-step index corresponding to the !
26! newest values for 2D primitive equation variables. !
27! krhs Barotropic (fast) time-step index used to compute the !
28! right-hand-terms of 2D primitive equation variables. !
29! kstp Barotropic (fast) time-step index to which the current !
30! changes are added to compute new 2D primitive equation !
31! variables. !
32! !
33! nfm3 Float index for time level "n-3". !
34! nfm2 Float index for time level "n-2". !
35! nfm1 Float index for time level "n-1". !
36! nf Float index for time level "n". !
37! nfp1 Float index for time level "n+1". !
38! !
39! nnew Baroclinic (slow) time-step index corresponding to the !
40! newest values for 3D primitive equation variables. !
41! nrhs Baroclinic (slow) time-step index used to compute the !
42! right-hand-terms of 3D primitive equation variables. !
43! nstp Baroclinic (slow) time-step index to which the current !
44! changes are added to compute new 3D primitive equation !
45! variables. !
46#if defined SSH_TIDES || defined UV_TIDES
47! !
48! NTC Number of tidal components to consider. !
49#endif
50! !
51!=======================================================================
52!
53! USE mod_param
54!
55 implicit none
56!
57 PUBLIC :: allocate_stepping
58 PUBLIC :: deallocate_stepping
59!
60!-----------------------------------------------------------------------
61! Define module variables.
62!-----------------------------------------------------------------------
63!
64 integer, allocatable :: knew(:)
65 integer, allocatable :: krhs(:)
66 integer, allocatable :: kstp(:)
67!$OMP THREADPRIVATE (knew, krhs, kstp)
68!
69 integer, allocatable :: nnew(:)
70 integer, allocatable :: nrhs(:)
71 integer, allocatable :: nstp(:)
72!$OMP THREADPRIVATE (nnew, nrhs, nstp)
73
74#ifdef FLOATS
75!
76 integer, allocatable :: nf(:)
77 integer, allocatable :: nfp1(:)
78 integer, allocatable :: nfm3(:)
79 integer, allocatable :: nfm2(:)
80 integer, allocatable :: nfm1(:)
81!$OMP THREADPRIVATE (nf, nfp1, nfm3, nfm2, nfm1)
82#endif
83
84#ifdef ICE_MODEL
85!
86 integer, allocatable :: linew(:)
87 integer, allocatable :: liold(:)
88 integer, allocatable :: liunw(:)
89 integer, allocatable :: liuol(:)
90 integer, allocatable :: lienw(:)
91 integer, allocatable :: lieol(:)
92!$OMP THREADPRIVATE (linew, liold, liunw, liuol, lienw, lieol)
93#endif
94!
95#ifdef ADJUST_BOUNDARY
96 integer, allocatable :: lbinp(:)
97 integer, allocatable :: lbout(:)
98#endif
99
100#if defined ADJUST_BOUNDARY || defined ADJUST_STFLUX || \
101 defined adjust_wstress
102 integer, allocatable :: lfinp(:)
103 integer, allocatable :: lfout(:)
104#endif
105
106 integer, allocatable :: lnew(:)
107 integer, allocatable :: lold(:)
108
109#if defined SSH_TIDES || defined UV_TIDES
110 integer, allocatable :: ntc(:)
111#endif
112!
113 CONTAINS
114!
115 SUBROUTINE allocate_stepping (Ngrids)
116!
117!=======================================================================
118! !
119! This routine allocates several variables in the module that depend !
120! on the number of nested grids. !
121! !
122!=======================================================================
123!
124! Imported variable declarations
125!
126 integer, intent(in) :: ngrids
127!
128!-----------------------------------------------------------------------
129! Allocate and intialize time indices.
130!-----------------------------------------------------------------------
131!
132!$OMP PARALLEL
133 IF (.not.allocated(knew)) THEN
134 allocate ( knew(ngrids) )
135 END IF
136 knew(1:ngrids)=1
137
138 IF (.not.allocated(krhs)) THEN
139 allocate ( krhs(ngrids) )
140 END IF
141 krhs(1:ngrids)=1
142
143 IF (.not.allocated(kstp)) THEN
144 allocate ( kstp(ngrids) )
145 END IF
146 kstp(1:ngrids)=1
147
148 IF (.not.allocated(nnew)) THEN
149 allocate ( nnew(ngrids) )
150 END IF
151 nnew(1:ngrids)=1
152
153 IF (.not.allocated(nrhs)) THEN
154 allocate ( nrhs(ngrids) )
155 END IF
156 nrhs(1:ngrids)=1
157
158 IF (.not.allocated(nstp)) THEN
159 allocate ( nstp(ngrids) )
160 END IF
161 nstp(1:ngrids)=1
162
163#ifdef FLOATS
164!
165 IF (.not.allocated(nf)) THEN
166 allocate ( nf(ngrids) )
167 END IF
168 nf(1:ngrids)=0
169
170 IF (.not.allocated(nfp1)) THEN
171 allocate ( nfp1(ngrids) )
172 END IF
173 nfp1(1:ngrids)=1
174
175 IF (.not.allocated(nfm3)) THEN
176 allocate ( nfm3(ngrids) )
177 END IF
178 nfm3(1:ngrids)=2
179
180 IF (.not.allocated(nfm2)) THEN
181 allocate ( nfm2(ngrids) )
182 END IF
183 nfm2(1:ngrids)=3
184
185 IF (.not.allocated(nfm1)) THEN
186 allocate ( nfm1(ngrids) )
187 END IF
188 nfm1(1:ngrids)=4
189#endif
190
191#ifdef ICE_MODEL
192!
193 IF (.not.allocated(linew)) THEN
194 allocate ( linew(ngrids) )
195 END IF
196 linew(1:ngrids) = 1
197
198 IF (.not.allocated(liold)) THEN
199 allocate ( liold(ngrids) )
200 END IF
201 liold(1:ngrids) = 1
202
203 IF (.not.allocated(liunw)) THEN
204 allocate ( liunw(ngrids) )
205 END IF
206 liunw(1:ngrids) = 1
207
208 IF (.not.allocated(liuol)) THEN
209 allocate ( liuol(ngrids) )
210 END IF
211 liuol(1:ngrids) = 1
212
213 IF (.not.allocated(lienw)) THEN
214 allocate ( lienw(ngrids) )
215 END IF
216 lienw(1:ngrids) = 1
217
218 IF (.not.allocated(lieol)) THEN
219 allocate ( lieol(ngrids) )
220 END IF
221 lieol(1:ngrids) = 1
222#endif
223!$OMP END PARALLEL
224
225#ifdef ADJUST_BOUNDARY
226!
227 IF (.not.allocated(lbinp)) THEN
228 allocate ( lbinp(ngrids) )
229 END IF
230 lbinp(1:ngrids)=1
231
232 IF (.not.allocated(lbout)) THEN
233 allocate ( lbout(ngrids) )
234 END IF
235 lbout(1:ngrids)=1
236#endif
237
238#if defined ADJUST_BOUNDARY || defined ADJUST_STFLUX || \
239 defined adjust_wstress
240!
241 IF (.not.allocated(lfinp)) THEN
242 allocate ( lfinp(ngrids) )
243 END IF
244 lfinp(1:ngrids)=1
245
246 IF (.not.allocated(lfout)) THEN
247 allocate ( lfout(ngrids) )
248 END IF
249 lfout(1:ngrids)=1
250#endif
251!
252 IF (.not.allocated(lnew)) THEN
253 allocate ( lnew(ngrids) )
254 END IF
255 lnew(1:ngrids)=1
256
257 IF (.not.allocated(lold)) THEN
258 allocate ( lold(ngrids) )
259 END IF
260 lold(1:ngrids)=1
261
262#if defined SSH_TIDES || defined UV_TIDES
263 IF (.not.allocated(ntc)) THEN
264 allocate ( ntc(ngrids) )
265 END IF
266#endif
267!
268 RETURN
269 END SUBROUTINE allocate_stepping
270!
272!
273!=======================================================================
274! !
275! This routine deallocates several variables in the module that !
276! depend on the number of nested grids. !
277! !
278!=======================================================================
279!
280!-----------------------------------------------------------------------
281! Deallocate variables in module.
282!-----------------------------------------------------------------------
283!
284!$OMP PARALLEL
285 IF (allocated(knew)) deallocate ( knew )
286
287 IF (allocated(krhs)) deallocate ( krhs )
288
289 IF (allocated(kstp)) deallocate ( kstp )
290
291 IF (allocated(nnew)) deallocate ( nnew )
292
293 IF (allocated(nrhs)) deallocate ( nrhs )
294
295 IF (allocated(nstp)) deallocate ( nstp )
296
297#ifdef FLOATS
298 IF (allocated(nf)) deallocate ( nf )
299
300 IF (allocated(nfp1)) deallocate ( nfp1 )
301
302 IF (allocated(nfm3)) deallocate ( nfm3 )
303
304 IF (allocated(nfm2)) deallocate ( nfm2 )
305
306 IF (allocated(nfm1)) deallocate ( nfm1 )
307#endif
308!$OMP END PARALLEL
309
310#ifdef ADJUST_BOUNDARY
311 IF (allocated(lbinp)) deallocate ( lbinp )
312
313 IF (allocated(lbout)) deallocate ( lbout )
314#endif
315
316#if defined ADJUST_BOUNDARY || defined ADJUST_STFLUX || \
317 defined adjust_wstress
318 IF (allocated(lfinp)) deallocate ( lfinp )
319
320 IF (allocated(lfout)) deallocate ( lfout )
321#endif
322
323 IF (allocated(lnew)) deallocate ( lnew )
324
325 IF (allocated(lold)) deallocate ( lold )
326
327#if defined SSH_TIDES || defined UV_TIDES
328 IF (allocated(ntc)) deallocate ( ntc )
329#endif
330!
331 RETURN
332 END SUBROUTINE deallocate_stepping
333!
334 END MODULE mod_stepping
335
integer, dimension(:), allocatable lold
integer, dimension(:), allocatable nfm2
integer, dimension(:), allocatable lbout
integer, dimension(:), allocatable kstp
integer, dimension(:), allocatable knew
integer, dimension(:), allocatable nfm1
integer, dimension(:), allocatable nrhs
integer, dimension(:), allocatable lfinp
integer, dimension(:), allocatable lbinp
integer, dimension(:), allocatable nf
subroutine, public deallocate_stepping
integer, dimension(:), allocatable nfm3
integer, dimension(:), allocatable ntc
integer, dimension(:), allocatable nnew
integer, dimension(:), allocatable nfp1
integer, dimension(:), allocatable lnew
subroutine, public allocate_stepping(ngrids)
integer, dimension(:), allocatable krhs
integer, dimension(:), allocatable lfout
integer, dimension(:), allocatable nstp