My Project
internal_step.f90
Go to the documentation of this file.
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 !/===========================================================================/
13 ! Copyright (c) 2007, The University of Massachusetts Dartmouth
14 ! Produced at the School of Marine Science & Technology
15 ! Marine Ecosystem Dynamics Modeling group
16 ! All rights reserved.
17 !
18 ! FVCOM has been developed by the joint UMASSD-WHOI research team. For
19 ! details of authorship and attribution of credit please see the FVCOM
20 ! technical manual or contact the MEDM group.
21 !
22 !
23 ! This file is part of FVCOM. For details, see http://fvcom.smast.umassd.edu
24 ! The full copyright notice is contained in the file COPYRIGHT located in the
25 ! root directory of the FVCOM code. This original header must be maintained
26 ! in all distributed versions.
27 !
28 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 ! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30 ! THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 ! PURPOSE ARE DISCLAIMED.
32 !
33 !/---------------------------------------------------------------------------/
34 ! CVS VERSION INFORMATION
35 ! $Id$
36 ! $Name$
37 ! $Revision$
38 !/===========================================================================/
39 
40 SUBROUTINE internal_step
42  USE all_vars
43  USE mod_utils
44  USE mod_obcs
45  USE mod_time
46  USE eqs_of_state
47  USE mod_wd
48  USE mod_assim
49  USE mod_par
50  USE mod_ice
51  USE mod_ice2d
52  USE mod_northpole
53 
54 
55 
56  IMPLICIT NONE
57  INTEGER :: I,J,K
58  REAL(SP) :: UTMP,VTMP
59  integer :: i1,i2
60 !------------------------------------------------------------------------------|
61 
62  if(dbg_set(dbg_sbr)) write(ipt,*)&
63  & "Start: internal_step"
64 
65 !----SET RAMP FACTOR TO EASE SPINUP--------------------------------------------!
66  ramp = 0.0_sp
67  IF(iramp /= 0) THEN
68  ramp=tanh(real(iint,sp)/real(iramp,sp))
69  ELSE
70  ramp = 1.0_sp
71  END IF
72 
73 !----OFFLINE SEDIMENT UPDATE
74 !----loop end for offline sediment
75 
76 
77 
78 !----SET UP WATER QUALITY MODEL COEFFICIENTS-----------------------------------!
79 
80 
81 
82 
83  !----ADJUST CONSISTENCY BETWEEN 3-D VELOCITY AND VERT-AVERAGED VELOCITIES------!
84  CALL adjust2d3d(1)
85 
86  !----SPECIFY THE SOLID BOUNDARY CONDITIONS OF U&V INTERNAL MODES---------------!
87  CALL bcond_gcn(5,0)
88 
89 ! end defined semi-implicit && nh
90 
91  !----SPECIFY THE SURFACE FORCING OF INTERNAL MODES-----------------------------!
92  CALL bcond_gcn(8,0)
93 
94  ! New Open Boundary Condition ----3
95 
96  !end !defined (TWO_D_MODEL)
97 
98  !----SPECIFY THE BOTTOM ROUGHNESS AND CALCULATE THE BOTTOM STRESSES------------!
99  CALL bottom_roughness
100 
101 
102 !==============================================================================!
103 ! CALCULATE DISPERSION (GX/GY) AND BAROCLINIC PRESSURE GRADIENT TERMS !
104 !==============================================================================!
105 
106  CALL advection_edge_gcn(advx,advy) !Calculate 3-D Adv/Diff !
107 
108  IF(recalculate_rho_mean) THEN
109  IF(recalc_rho_mean .LT. inttime)THEN
110  recalc_rho_mean = recalc_rho_mean + delt_rho_mean
111  CALL rho_pmean
112  END IF
113  END IF
114 
115 
116  IF(.NOT. barotropic)THEN !Barotropic Flow ? !
117  SELECT CASE(baroclinic_pressure_gradient)
118  CASE ("sigma levels")
119  CALL baropg !Sigma Level Pressure Gradient!
120  CASE('z coordinates')
121  CALL phy_baropg !Z Level Pressure Gradient !
122  CASE DEFAULT
123  CALL fatal_error("UNKNOW BAROCLINIC PRESURE GRADIENT TYPE",&
124  & trim(baroclinic_pressure_gradient))
125  END SELECT
126 
127  END IF ! !
128 
129 
130  adx2d = 0.0_sp ; ady2d = 0.0_sp !Initialize GX/GY Terms !
131  drx2d = 0.0_sp ; dry2d = 0.0_sp !Initialize BCPG for Ext Mode !
132 
133  DO k=1,kbm1
134  DO i=1, n
135  adx2d(i)=adx2d(i)+advx(i,k) !*DZ1(I,K)
136  ady2d(i)=ady2d(i)+advy(i,k) !*DZ1(I,K)
137  drx2d(i)=drx2d(i)+drhox(i,k) !*DZ1(I,K)
138  dry2d(i)=dry2d(i)+drhoy(i,k) !*DZ1(I,K)
139  END DO
140  END DO
141 
142  CALL advave_edge_gcn(advua,advva) !Compute Ext Mode Adv/Diff
143  adx2d = adx2d - advua !Subtract to Form GX
144  ady2d = ady2d - advva !Subtract to Form GY
145 
146  !----INITIALIZE ARRAYS USED TO CALCULATE AVERAGE UA/E OVER EXTERNAL STEPS-----!
147  uard = 0.0_sp
148  vard = 0.0_sp
149  egf = 0.0_sp
150 
151 
152 !!# if defined (1)
153 !! UARDS = 0.0_SP
154 !! VARDS = 0.0_SP
155 !!# endif
156 
157  IF(iobcn > 0) THEN
158  uard_obcn(1:iobcn)=0.0_sp
159  END IF
160 ! end defined semi-implicit
161 ! end defined (TWO_D_MODEL)
162 
163 
164  ! New Open Boundary Condition ----4
165 
166 
167 
168  !==============================================================================!
169  ! LOOP OVER EXTERNAL TIME STEPS !
170  !==============================================================================!
171  DO iext=1,isplit
172 
173  IF (dbg_set(dbg_sbrio)) WRITE(ipt,*) "/// EXT SETP: ",iext
174 
175  exttime = exttime + imdte
176 
177  CALL external_step
178 
179 
180  END DO
181 
182 
183 ! new update ! jqi ggao 0730/2007 for E-P
184 
185 ! new update ! jqi ggao 0730/2007
186 
187 ! end defined semi-implicit
188 
189 !==============================================================================!
190 !==============================================================================!
191 ! BEGIN THREE D ADJUSTMENTS
192 !==============================================================================!
193 !==============================================================================!
194 
195  !==============================================================================!
196  ! ADJUST INTERNAL VELOCITY FIELD TO CORRESPOND TO EXTERNAL !
197  !==============================================================================!
198 
199  CALL adjust2d3d(2)
200 
201  ! New Open Boundary Condition ----9
202 
203  !==============================================================================!
204  ! CALCULATE INTERNAL VELOCITY FLUXES |
205  !==============================================================================!
206  ! !
207 !!
208 
209 !end !defined (TWO_D_MODEL)
210 
211 !==============================================================================!
212 ! CALCULATE INTERNAL VELOCITY FLUXES |
213 !==============================================================================!
214 
215 
216  CALL vertvl_edge ! Calculate/Update Sigma Vertical Velocity (Omega) !
217 
218  IF(wetting_drying_on) CALL wd_update(2)
219 
220  CALL viscof_h ! Calculate horizontal diffusion coefficient scalars !
221 
222  CALL adv_uv_edge_gcn ! Horizontal Advect/Diff + Vertical Advection !
223 
224  CALL vdif_uv ! Implicit Integration of Vertical Diffusion of U/V !
225 
226  IF(adcor_on) THEN
227  CALL adcor
228  CALL vdif_uv ! Implicit Integration of Vertical Diffusion of U/V !
229 ! CALL VDIF_UV ! Implicit Integration of Vertical Diffusion of U/V !
230 
231  ENDIF
232 
233  DO i=1,n
234  IF(h1(i) <= static_ssh_adj ) THEN
235  DO k=1,kbm1
236  uf(i,k)=ua(i)
237  vf(i,k)=va(i)
238  END DO
239  END IF
240  END DO
241 
242  CALL bcond_gcn(3,0) ! Boundary Condition on U/V At River Input !
243 
244 
245 
246 
247  IF(nesting_on )THEN
248  CALL set_var(inttime,u=uf)
249  CALL set_var(inttime,v=vf)
250  END IF
251 
252 
253 !if !defined (SEMI_IMPLICIT)
254 
255 
256  CALL wreal ! Calculate True Vertical Velocity (W) !
257 
258 ! CALL REPORT("before VISCOF_H")
259 
260  !==============================================================================!
261  ! TURBULENCE MODEL SECTION |
262  !==============================================================================!
263 
264 
265  SELECT CASE(vertical_mixing_type)
266  CASE('closure')
267  !=================General Ocean Turbulence Model==========================!
268  !===================Original FVCOM MY-2.5/Galperin 1988 Model=============!
269 
270  CALL adv_q(q2,q2f) !!Advection of Q2
271 
272  CALL adv_q(q2l,q2lf)
273 
274 
275 
276  IF(scalar_positivity_control) CALL fct_q2 !Conservation Correction !
277  IF(scalar_positivity_control) CALL fct_q2l !Conservation Correction !
278 !end !defined (ONE_D_MODEL)
279 
280 
281 
282  CALL vdif_q !! Solve Q2,Q2*L eqns for KH/KM/KQ
283  q2 = q2f
284  q2l = q2lf
285 
286 
287 ! end if defined(GOTM)
288  CASE('constant')
289  km = umol
290  kh = umol*vprnu
291  END SELECT
292 
293 
294  CALL n2e3d(km,km1)
295 
296 
297 
298 
299 !==============================================================================!
300 ! SEDIMENT MODEL SECTION
301 ! Advance Sed Model (Erode/Deposit/Advect/Diffuse)
302 ! Change bathymetry (if MORPHO_MODEL=T)
303 ! Note: morph array returned from sed: Deposition: morph > 0
304 ! 0 < morpho_factor < 1
305 ! morpho_model and morpho_factor are stored and set in mod_sed.F
306 !==============================================================================!
307 
308 
309  !==============================================================================!
310  ! UPDATE TEMPERATURE IN NON-BAROTROPIC CASE !
311  !==============================================================================!
312  IF(temperature_active)THEN
313 
314  CALL adv_t !Advection !
315 
316 
317 
318  !# if !defined (DOUBLE_PRECISION)
319  IF(scalar_positivity_control) CALL fct_t !Conservation Correction !
320  !# endif
321  !end !defined (ONE_D_MODEL) ! !
322 
323  IF(casename(1:3) == 'gom')THEN
324  CALL vdif_ts_gom(1,tf1)
325  ELSE
326  CALL vdif_ts(1,tf1) !Vertical Diffusion !
327  END IF
328 
329 
330  CALL bcond_ts(1) !Boundary Conditions !
331 
332  IF(nesting_on )THEN
333  CALL set_var(inttime,t1=tf1)
334  END IF
335 
336 !!$!QXU{
337 !!$# if defined (SST_GRID_ASSIM)
338 !!$ IF(ASSIM_FLAG==0 .AND. .NOT. SST_ASSIM_GRD)CALL TEMP_NUDGING
339 !!$ IF(ASSIM_FLAG==1 .AND. SST_ASSIM_GRD)CALL TEMP_NUDGING
340 !!$# else
341 !!$ IF(ASSIM_FLAG==0 .AND. .NOT. SST_ASSIM)CALL TEMP_NUDGING
342 !!$ IF(ASSIM_FLAG==1 .AND. SST_ASSIM)CALL TEMP_NUDGING
343 !!$# endif
344 !!$!QXU}
345 
346 
347 
348 
349 
350 ! IF(NESTING_ON )THEN
351 ! CALL SET_VAR(intTime,T1=TF1)
352 ! END IF
353 
354 !J. Ge for tracer advection
355  IF(backward_advection==.true.)THEN
356  IF(backward_step==1)THEN
357  t0 = t1
358  ELSEIF(backward_step==2)THEN
359  t2 = t0
360  t0 = t1
361  ENDIF
362  ENDIF
363 !J. Ge for tracer advection
364  t1 = tf1 !Update to new time level !
365 
366  CALL n2e3d(t1,t) !Shift to Elements !
367 
368 
369  END IF ! !
370 
371  !==============================================================================!
372  ! UPDATE SALINITY IN NON-BAROTROPIC CASE !
373  !==============================================================================!
374 
375  IF(salinity_active)THEN ! !
376 
377  CALL adv_s !Advection !
378 
379 
380 
381  !# if !defined (DOUBLE_PRECISION)
382  IF(scalar_positivity_control) CALL fct_s !Conservation Correction !
383  !# endif
384  !end !defined (ONE_D_MODEL) ! !
385 
386  IF(casename(1:3) == 'gom')THEN
387  CALL vdif_ts_gom(2,sf1)
388  ELSE
389  CALL vdif_ts(2,sf1) !Vertical Diffusion !
390  END IF
391 
392 
393  CALL bcond_ts(2) !Boundary Conditions !
394 
395  IF(nesting_on )THEN
396  CALL set_var(inttime,s1=sf1)
397  END IF
398 
399 
400 
401 
402 ! IF(NESTING_ON )THEN
403 ! CALL SET_VAR(intTime,S1=SF1)
404 ! END IF
405 
406 !J. Ge for tracer advection
407  IF(backward_advection==.true.)THEN
408  IF(backward_step==1)THEN
409  s0 = s1
410  ELSEIF(backward_step==2)THEN
411  s2 = s0
412  s0 = s1
413  ENDIF
414  ENDIF
415 !J. Ge for tracer advection
416  s1 = sf1 !Update to new time level !
417 
418  CALL n2e3d(s1,s) !Shift to Elements !
419 
420 
421  END IF
422 
423  !==============================================================================!
424  !endif defined (DYE)
425 
426 !==================================================================================!
427 ! ADJUST TEMPERATURE AND SALINITY AT RIVER MOUTHS
428 !==================================================================================!
429  IF( river_ts_setting == 'calculated')THEN
430  CALL adjust_ts
431  END IF
432 
433 
434 
435 
436 
437 
438 
439  !==============================================================================!
440  ! UPDATE THE DENSITY IN NON-BAROTROPIC CASE |
441  !==============================================================================!
442  IF(.NOT.barotropic)THEN
443  SELECT CASE(sea_water_density_function)
444  CASE(sw_dens1)
445  CALL dens1
446  CASE(sw_dens2)
447  CALL dens2
448  CASE(sw_dens3)
449  CALL dens3
450  CASE DEFAULT
451  CALL fatal_error("INVALID DENSITY FUNCTION SELECTED:",&
452  & " "//trim(sea_water_density_function) )
453  END SELECT
454  END IF
455  !==============================================================================!
456  ! MIMIC CONVECTIVE OVERTURNING TO STABILIZE VERTICAL DENSITY PROFILE |
457  !==============================================================================!
458 
459  IF(convective_overturning)THEN
460  CALL conv_over
461  IF(.NOT.barotropic)THEN
462  SELECT CASE(sea_water_density_function)
463  CASE(sw_dens1)
464  CALL dens1
465  CASE(sw_dens2)
466  CALL dens2
467  CASE(sw_dens3)
468  CALL dens3
469  CASE DEFAULT
470  CALL fatal_error("INVALID DENSITY FUNCTION SELECTED:",&
471  & " "//trim(sea_water_density_function) )
472  END SELECT
473 
474  END IF
475  END IF
476 !==============================================================================!
477 !==============================================================================!
478  ! end if !defined (TWO_D_MODEL)
479 !==============================================================================!
480 !==============================================================================!
481 
482 
483 
484 
485  !==============================================================================!
486  ! UPDATE VELOCITY FIELD (NEEDED TO WAIT FOR SALINITY/TEMP/TURB/TRACER) |
487  !==============================================================================!
488  u = uf
489  v = vf
490  !==============================================================================!
491  ! PERFORM DATA EXCHANGE FOR ELEMENT BASED INFORMATION AT PROC BNDRIES |
492  !==============================================================================!
493 
494  !==============================================================================!
495  ! PERFORM DATA EXCHANGE FOR WATER QUALITY VARIABLES |
496  !==============================================================================!
497  ! end if !defined (TWO_D_MODEL)
498 
499 
500 
501  !
502  !----SHIFT SEA SURFACE ELEVATION AND DEPTH TO CURRENT TIME LEVEL---------------!
503  !
504  et = el
505  dt = d
506  et1 = el1
507  dt1 = d1
508 
509  IF(wetting_drying_on) CALL wd_update(3)
510 
511  ! New Open Boundary Condition ----10
512 
513 
514 !!$ CALL DUMP_PROBE_DATA
515 
516 
517  if(dbg_set(dbg_sbr)) write(ipt,*)&
518  & "End: internal_step"
519 
520 END SUBROUTINE internal_step
real(sp), dimension(:,:), allocatable, target q2
Definition: mod_main.f90:1290
real(sp), dimension(:,:), allocatable, target km
Definition: mod_main.f90:1293
real(sp), dimension(:), allocatable, target va
Definition: mod_main.f90:1104
real(sp), dimension(:), allocatable, target d
Definition: mod_main.f90:1132
real(sp), dimension(:), allocatable, target d1
Definition: mod_main.f90:1116
real(sp), dimension(:), allocatable, target adx2d
Definition: mod_main.f90:1258
real(sp), dimension(:,:), allocatable, target t2
Definition: mod_main.f90:1314
real(sp), dimension(:,:), allocatable, target q2lf
Definition: mod_main.f90:1298
subroutine conv_over
Definition: conv_over.f90:45
real(sp), dimension(:,:), allocatable, target s
Definition: mod_main.f90:1288
subroutine internal_step
subroutine fct_t
Definition: fct_t.f90:45
real(sp), dimension(:,:), allocatable, target advx
Definition: mod_main.f90:1263
subroutine adv_q(Q, QF)
Definition: adv_q.f90:47
real(sp), dimension(:), allocatable, target el
Definition: mod_main.f90:1134
real(sp), dimension(:), allocatable, target advua
Definition: mod_main.f90:1256
real(sp), dimension(:,:), allocatable, target v
Definition: mod_main.f90:1269
logical function dbg_set(vrb)
Definition: mod_utils.f90:182
real(sp), dimension(:,:), allocatable, target t1
Definition: mod_main.f90:1307
real(sp), dimension(:), allocatable, target egf
Definition: mod_main.f90:1136
subroutine bcond_gcn(IDX, K_RK)
Definition: bcond_gcn.f90:58
real(sp), dimension(:,:), allocatable, target vf
Definition: mod_main.f90:1282
subroutine set_var(NOW, UA, VA, EL, U, V, S1, T1, HYW)
real(sp), dimension(:,:), allocatable, target q2l
Definition: mod_main.f90:1292
real(sp), dimension(:,:), allocatable, target u
Definition: mod_main.f90:1268
logical nesting_on
real(sp), dimension(:,:), allocatable, target s1
Definition: mod_main.f90:1308
real(sp), dimension(:), allocatable, target vard
Definition: mod_main.f90:1111
real(sp), dimension(:,:), allocatable, target drhox
Definition: mod_main.f90:1326
real(sp), dimension(:), allocatable, target el1
Definition: mod_main.f90:1118
real(sp), dimension(:), allocatable, target et
Definition: mod_main.f90:1135
subroutine rho_pmean
Definition: rho_pmean.f90:42
real(sp), dimension(:), allocatable, target uard
Definition: mod_main.f90:1110
subroutine dens2
real(sp), dimension(:,:), allocatable, target tf1
Definition: mod_main.f90:1310
real(sp), dimension(:,:), allocatable, target uf
Definition: mod_main.f90:1281
real(sp), dimension(:), allocatable uard_obcn
Definition: mod_obcs.f90:112
subroutine bcond_ts(NCON2)
Definition: bcond_ts.f90:47
subroutine fct_q2
Definition: fct_q2.f90:45
real(sp), dimension(:,:), allocatable, target sf1
Definition: mod_main.f90:1311
real(sp), dimension(:,:), allocatable, target advy
Definition: mod_main.f90:1264
subroutine vdif_uv
Definition: vdif_uv.f90:46
integer, parameter dbg_sbrio
Definition: mod_utils.f90:70
subroutine bottom_roughness
Definition: brough.f90:53
subroutine vertvl_edge
Definition: vertvl_edge.f90:49
subroutine vdif_q
Definition: vdif_q.f90:46
subroutine adjust2d3d(ADJUST_TYPE)
Definition: adjust2d3d.f90:41
real(sp), dimension(:,:), allocatable, target drhoy
Definition: mod_main.f90:1327
subroutine phy_baropg
Definition: phy_baropg.f90:49
subroutine viscof_h
Definition: viscofh.f90:45
subroutine adcor
Definition: adcor.f90:40
real(sp), dimension(:), allocatable, target ua
Definition: mod_main.f90:1103
subroutine adv_t
Definition: adv_t.f90:46
subroutine adjust_ts
Definition: adjust_ts.f90:46
real(sp), dimension(:,:), allocatable, target q2f
Definition: mod_main.f90:1297
real(sp), dimension(:,:), allocatable, target kh
Definition: mod_main.f90:1294
real(sp), dimension(:), allocatable, target ady2d
Definition: mod_main.f90:1259
subroutine dens3
real(sp), dimension(:), allocatable, target dt1
Definition: mod_main.f90:1117
subroutine fct_q2l
Definition: fct_q2l.f90:45
subroutine vdif_ts_gom(NCON1, F)
Definition: vdif_ts_gom.f90:50
subroutine fatal_error(ER1, ER2, ER3, ER4)
Definition: mod_utils.f90:230
real(sp), dimension(:), allocatable, target h1
Definition: mod_main.f90:1115
subroutine external_step
real(sp), dimension(:), allocatable, target dry2d
Definition: mod_main.f90:1261
real(sp), dimension(:,:), allocatable, target t0
Definition: mod_main.f90:1313
subroutine dens1
subroutine n2e3d(NVAR, EVAR)
Definition: mod_main.f90:1370
subroutine adv_s
Definition: adv_s.f90:46
subroutine fct_s
Definition: fct_s.f90:45
subroutine advave_edge_gcn(XFLUX, YFLUX)
real(sp), dimension(:,:), allocatable, target t
Definition: mod_main.f90:1286
real(sp), dimension(:,:), allocatable, target s2
Definition: mod_main.f90:1316
integer, parameter dbg_sbr
Definition: mod_utils.f90:69
subroutine wd_update(INCASE)
Definition: mod_wd.f90:253
real(sp), dimension(:,:), allocatable, target km1
Definition: mod_main.f90:1299
real(sp), dimension(:,:), allocatable, target s0
Definition: mod_main.f90:1315
real(sp), dimension(:), allocatable, target advva
Definition: mod_main.f90:1257
real(sp), dimension(:), allocatable, target et1
Definition: mod_main.f90:1119
subroutine wreal
Definition: wreal.f90:44
subroutine baropg
Definition: baropg.f90:45
subroutine vdif_ts(NCON1, F)
Definition: vdif_ts.f90:54
real(sp), dimension(:), allocatable, target dt
Definition: mod_main.f90:1133
real(sp), dimension(:), allocatable, target drx2d
Definition: mod_main.f90:1260
subroutine advection_edge_gcn(XFLUX, YFLUX)
subroutine adv_uv_edge_gcn