← back to index

src/diagnostics/MOM_PointAccel.F90

portedportable, not yet portedexecuted, not portableexecutable, not hit by this run

1! This file is part of MOM6, the Modular Ocean Model version 6.
2! See the LICENSE file for licensing information.
3! SPDX-License-Identifier: Apache-2.0
4
5!> Debug accelerations at a given point
6!!
7!! The two subroutines in this file write out all of the terms
8!! in the u- or v-momentum balance at a given point. Usually
9!! these subroutines are called after the velocities exceed some
10!! threshold, in order to determine which term is culpable.
11!! often this is done for debugging purposes.
12module MOM_PointAccel
13
14use MOM_diag_mediator, only : diag_ctrl
15use MOM_domains, only : pe_here
16use MOM_error_handler, only : MOM_error, NOTE
17use MOM_file_parser, only : get_param, log_param, log_version, param_file_type
18use MOM_get_input, only : directories
19use MOM_grid, only : ocean_grid_type
20use MOM_io, only : open_ASCII_file, APPEND_FILE, MULTIPLE, SINGLE_FILE
21use MOM_time_manager, only : time_type, get_time, get_date, set_date, operator(-)
22use MOM_unit_scaling, only : unit_scale_type
23use MOM_variables, only : ocean_internal_state, accel_diag_ptrs, cont_diag_ptrs
24use MOM_verticalGrid, only : verticalGrid_type
25
26implicit none ; private
27
28#include <MOM_memory.h>
29
30public write_u_accel, write_v_accel, PointAccel_init
31
32!> The control structure for the MOM_PointAccel module
33type, public :: PointAccel_CS ; private
34 character(len=200) :: u_trunc_file !< The complete path to the file in which a column's worth of
35 !! u-accelerations are written if u-velocity truncations occur.
36 character(len=200) :: v_trunc_file !< The complete path to the file in which a column's worth of
37 !! v-accelerations are written if v-velocity truncations occur.
38 integer :: u_file !< The unit number for an opened u-truncation files, or -1 if it has not yet been opened.
39 integer :: v_file !< The unit number for an opened v-truncation files, or -1 if it has not yet been opened.
40 integer :: cols_written !< The number of columns whose output has been
41 !! written by this PE during the current run.
42 integer :: max_writes !< The maximum number of times any PE can write out
43 !! a column's worth of accelerations during a run.
44 logical :: full_column !< If true, write out the accelerations in all massive layers,
45 !! otherwise just document the ones with large velocities.
46 type(time_type), pointer :: Time => NULL() !< A pointer to the ocean model's clock.
47 type(diag_ctrl), pointer :: diag => NULL() !< A structure that is used to
48 !! regulate the timing of diagnostic output.
49! The following are pointers to many of the state variables and accelerations
50! that are used to step the physical model forward. They all use the same
51! names as the variables they point to in MOM.F90
52 real, pointer, dimension(:,:,:) :: &
53 u_av => NULL(), & !< Time average u-velocity [L T-1 ~> m s-1]
54 v_av => NULL(), & !< Time average velocity [L T-1 ~> m s-1]
55 u_prev => NULL(), & !< Previous u-velocity [L T-1 ~> m s-1]
56 v_prev => NULL(), & !< Previous v-velocity [L T-1 ~> m s-1]
57 T => NULL(), & !< Temperature [C ~> degC]
58 S => NULL(), & !< Salinity [S ~> ppt]
59 u_accel_bt => NULL(), & !< Barotropic u-accelerations [L T-2 ~> m s-2]
60 v_accel_bt => NULL() !< Barotropic v-accelerations [L T-2 ~> m s-2]
61end type PointAccel_CS
62
63contains
64
65!> This subroutine writes to an output file all of the accelerations
66!! that have been applied to a column of zonal velocities over the
67!! previous timestep. This subroutine is called from vertvisc.
680subroutine write_u_accel(I, j, um, hin, ADp, CDp, dt, G, GV, US, CS, vel_rpt, str, a, hv)
69 integer, intent(in) :: I !< The zonal index of the column to be documented.
70 integer, intent(in) :: j !< The meridional index of the column to be documented.
71 type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure.
72 type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure.
73 type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
74 real, dimension(SZIB_(G),SZJ_(G),SZK_(GV)), &
75 intent(in) :: um !< The new zonal velocity [L T-1 ~> m s-1].
76 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
77 intent(in) :: hin !< The layer thickness [H ~> m or kg m-2].
78 type(accel_diag_ptrs), intent(in) :: ADp !< A structure pointing to the various
79 !! accelerations in the momentum equations.
80 type(cont_diag_ptrs), intent(in) :: CDp !< A structure with pointers to various terms
81 !! in the continuity equations.
82 real, intent(in) :: dt !< The ocean dynamics time step [T ~> s].
83 type(PointAccel_CS), pointer :: CS !< The control structure returned by a previous
84 !! call to PointAccel_init.
85 real, intent(in) :: vel_rpt !< The velocity magnitude that triggers a report [L T-1 ~> m s-1]
86 real, optional, intent(in) :: str !< The surface wind stress [R L Z T-2 ~> Pa]
87 real, dimension(SZIB_(G),SZJ_(G),SZK_(GV)+1), &
88 optional, intent(in) :: a !< The layer coupling coefficients from vertvisc
89 !! [H T-1 ~> m s-1 or Pa s m-1]
90 real, dimension(SZIB_(G),SZJ_(G),SZK_(GV)), &
91 optional, intent(in) :: hv !< The layer thicknesses at velocity grid points,
92 !! from vertvisc [H ~> m or kg m-2].
93
94 ! Local variables
95 real :: CFL ! The local velocity-based CFL number [nondim]
96 real :: Angstrom ! A negligibly small thickness [H ~> m or kg m-2]
97 real :: du ! A velocity change [L T-1 ~> m s-1]
980 real :: Inorm(SZK_(GV)) ! The inverse of the normalized velocity change [L T-1 ~> m s-1]
990 real :: e(SZK_(GV)+1) ! Simple estimates of interface heights based on the sum of thicknesses [m]
100 real :: h_scale ! A scaling factor for thicknesses [m H-1 ~> 1] or [kg m-2 H-1 ~> 1]
101 real :: vel_scale ! A scaling factor for velocities [m T s-1 L-1 ~> 1]
102 real :: uh_scale ! A scaling factor for transport per unit length [m2 T s-1 L-1 H-1 ~> 1]
103 ! or [kg T m-1 s-1 L-1 H-1 ~> 1]
104 real :: temp_scale ! A scaling factor for temperatures [degC C-1 ~> 1]
105 real :: saln_scale ! A scaling factor for salinities [ppt S-1 ~> 1]
106 integer :: yr, mo, day, hr, minute, sec, yearday
107 integer :: k, ks, ke
108 integer :: nz
1090 logical :: do_k(SZK_(GV)+1)
110 logical :: prev_avail
111 integer :: file
112
1130 Angstrom = GV%Angstrom_H + GV%H_subroundoff
1140 h_scale = GV%H_to_mks ; vel_scale = US%L_T_to_m_s ; uh_scale = h_scale*vel_scale
1150 temp_scale = US%C_to_degC ; saln_scale = US%S_to_ppt
116
117! if (.not.associated(CS)) return
1180 nz = GV%ke
1190 if (CS%cols_written < CS%max_writes) then
1200 CS%cols_written = CS%cols_written + 1
121
1220 ks = 1 ; ke = nz
1230 do_k(:) = .false.
124
125 ! Open up the file for output if this is the first call.
1260 if (CS%u_file == -1) then
1270 if (len_trim(CS%u_trunc_file) < 1) return
128 call open_ASCII_file(CS%u_file, trim(CS%u_trunc_file), action=APPEND_FILE, &
1290 threading=MULTIPLE, fileset=SINGLE_FILE)
1300 if (CS%u_file == -1) then
1310 call MOM_error(NOTE, 'Unable to open file '//trim(CS%u_trunc_file)//'.')
1320 return
133 endif
134 endif
1350 file = CS%u_file
136
1370 prev_avail = (associated(CS%u_prev) .and. associated(CS%v_prev))
138
139 ! Determine which layers to write out accelerations for.
1400 do k=1,nz
141 if (((max(CS%u_av(I,j,k),um(I,j,k)) >= vel_rpt) .or. &
1420 (min(CS%u_av(I,j,k),um(I,j,k)) <= -vel_rpt)) .and. &
1430 ((hin(i,j,k) + hin(i+1,j,k)) > 3.0*Angstrom)) exit
144 enddo
1450 ks = k
1460 do k=nz,1,-1
147 if (((max(CS%u_av(I,j,k), um(I,j,k)) >= vel_rpt) .or. &
1480 (min(CS%u_av(I,j,k), um(I,j,k)) <= -vel_rpt)) .and. &
1490 ((hin(i,j,k) + hin(i+1,j,k)) > 3.0*Angstrom)) exit
150 enddo
1510 ke = k
1520 if (ke < ks) then
1530 ks = 1 ; ke = nz ; write(file,'("U: Unable to set ks & ke.")')
154 endif
1550 if (CS%full_column) then
1560 ks = 1 ; ke = nz
157 endif
158
1590 call get_date(CS%Time, yr, mo, day, hr, minute, sec)
1600 call get_time((CS%Time - set_date(yr, 1, 1, 0, 0, 0)), sec, yearday)
1610 write (file,'(/,"--------------------------")')
162 write (file,'(/,"Time ",I0," ",I0," ",F6.2," U-velocity violation at ",I0,": ",I0,", ",I0, &
163 & " (",F7.2," E ",F7.2," N) Layers ",I0," to ",I0,". dt = ",1PG10.4)') &
1640 yr, yearday, (REAL(sec)/3600.0), pe_here(), I, j, &
1650 G%geoLonCu(I,j), G%geoLatCu(I,j), ks, ke, US%T_to_s*dt
166
1670 if (ks <= GV%nk_rho_varies) ks = 1
1680 do k=ks,ke
1690 if ((hin(i,j,k) + hin(i+1,j,k)) > 3.0*Angstrom) do_k(k) = .true.
170 enddo
171
1720 write(file,'(/,"Layers:")', advance='no')
1730 do k=ks,ke ; if (do_k(k)) write(file,'(I10," ")', advance='no') (k) ; enddo
1740 write(file,'(/,"u(m): ")', advance='no')
1750 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*um(I,j,k)) ; enddo
1760 if (prev_avail) then
1770 write(file,'(/,"u(mp): ")', advance='no')
1780 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*CS%u_prev(I,j,k)) ; enddo
179 endif
1800 write(file,'(/,"u(3): ")', advance='no')
1810 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*CS%u_av(I,j,k)) ; enddo
182
1830 write(file,'(/,"CFL u: ")', advance='no')
1840 do k=ks,ke ; if (do_k(k)) then
1850 CFL = abs(um(I,j,k)) * dt * G%dy_Cu(I,j)
1860 if (um(I,j,k) < 0.0) then ; CFL = CFL * G%IareaT(i+1,j)
1870 else ; CFL = CFL * G%IareaT(i,j) ; endif
1880 write(file,'(ES10.3," ")', advance='no') CFL
189 endif ; enddo
1900 write(file,'(/,"CFL0 u:")', advance='no')
1910 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
1920 abs(um(I,j,k)) * dt * G%IdxCu(I,j) ; enddo
193
1940 if (prev_avail) then
1950 write(file,'(/,"du: ")', advance='no')
1960 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
1970 (vel_scale*(um(I,j,k)-CS%u_prev(I,j,k))) ; enddo
198 endif
1990 write(file,'(/,"CAu: ")', advance='no')
2000 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*dt*ADp%CAu(I,j,k)) ; enddo
2010 write(file,'(/,"PFu: ")', advance='no')
2020 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*dt*ADp%PFu(I,j,k)) ; enddo
2030 write(file,'(/,"diffu: ")', advance='no')
2040 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*dt*ADp%diffu(I,j,k)) ; enddo
205
2060 if (associated(ADp%gradKEu)) then
2070 write(file,'(/,"KEu: ")', advance='no')
2080 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
2090 (vel_scale*dt*ADp%gradKEu(I,j,k)) ; enddo
210 endif
2110 if (associated(ADp%rv_x_v)) then
2120 write(file,'(/,"Coru: ")', advance='no')
2130 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
2140 vel_scale*dt*(ADp%CAu(I,j,k)-ADp%rv_x_v(I,j,k)) ; enddo
215 endif
2160 if (associated(ADp%du_dt_visc)) then
2170 write(file,'(/,"ubv: ")', advance='no')
2180 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
2190 vel_scale*(um(I,j,k) - dt*ADp%du_dt_visc(I,j,k)) ; enddo
2200 write(file,'(/,"duv: ")', advance='no')
2210 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
2220 (vel_scale*dt*ADp%du_dt_visc(I,j,k)) ; enddo
223 endif
2240 if (associated(ADp%du_other)) then
2250 write(file,'(/,"du_other: ")', advance='no')
2260 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
2270 (vel_scale*ADp%du_other(I,j,k)) ; enddo
228 endif
2290 if (present(a)) then
2300 write(file,'(/,"a: ",ES10.3," ")', advance='no') h_scale*a(I,j,ks)*dt
2310 do K=ks+1,ke+1 ; if (do_k(k-1)) write(file,'(ES10.3," ")', advance='no') (h_scale*a(I,j,K)*dt) ; enddo
232 endif
2330 if (present(hv)) then
2340 write(file,'(/,"hvel: ")', advance='no')
2350 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') h_scale*hv(I,j,k) ; enddo
236 endif
2370 if (present(str)) then
2380 write(file,'(/,"Stress: ",ES10.3)', advance='no') (uh_scale*GV%RZ_to_H) * (str*dt)
239 endif
240
2410 if (associated(CS%u_accel_bt)) then
2420 write(file,'(/,"dubt: ")', advance='no')
2430 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
2440 (vel_scale*dt*CS%u_accel_bt(I,j,k)) ; enddo
245 endif
2460 write(file,'(/)')
247
2480 write(file,'(/,"h--: ")', advance='no')
2490 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (h_scale*hin(i,j-1,k)) ; enddo
2500 write(file,'(/,"h+-: ")', advance='no')
2510 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (h_scale*hin(i+1,j-1,k)) ; enddo
2520 write(file,'(/,"h-0: ")', advance='no')
2530 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (h_scale*hin(i,j,k)) ; enddo
2540 write(file,'(/,"h+0: ")', advance='no')
2550 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (h_scale*hin(i+1,j,k)) ; enddo
2560 write(file,'(/,"h-+: ")', advance='no')
2570 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (h_scale*hin(i,j+1,k)) ; enddo
2580 write(file,'(/,"h++: ")', advance='no')
2590 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (h_scale*hin(i+1,j+1,k)) ; enddo
260
261
2620 e(nz+1) = -US%Z_to_m*(G%bathyT(i,j) + G%Z_ref)
2630 do k=nz,1,-1 ; e(K) = e(K+1) + h_scale*hin(i,j,k) ; enddo
2640 write(file,'(/,"e-: ",ES10.3," ")', advance='no') e(ks)
2650 do K=ks+1,ke+1 ; if (do_k(k-1)) write(file,'(ES10.3," ")', advance='no') e(K) ; enddo
266
2670 e(nz+1) = -US%Z_to_m*(G%bathyT(i+1,j) + G%Z_ref)
2680 do k=nz,1,-1 ; e(K) = e(K+1) + h_scale*hin(i+1,j,k) ; enddo
2690 write(file,'(/,"e+: ",ES10.3," ")', advance='no') e(ks)
2700 do K=ks+1,ke+1 ; if (do_k(k-1)) write(file,'(ES10.3," ")', advance='no') e(K) ; enddo
2710 if (associated(CS%T)) then
2720 write(file,'(/,"T-: ")', advance='no')
2730 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') temp_scale*CS%T(i,j,k) ; enddo
2740 write(file,'(/,"T+: ")', advance='no')
2750 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') temp_scale*CS%T(i+1,j,k) ; enddo
276 endif
2770 if (associated(CS%S)) then
2780 write(file,'(/,"S-: ")', advance='no')
2790 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') saln_scale*CS%S(i,j,k) ; enddo
2800 write(file,'(/,"S+: ")', advance='no')
2810 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') saln_scale*CS%S(i+1,j,k) ; enddo
282 endif
283
2840 if (prev_avail) then
2850 write(file,'(/,"v--: ")', advance='no')
2860 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*CS%v_prev(i,J-1,k)) ; enddo
2870 write(file,'(/,"v-+: ")', advance='no')
2880 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*CS%v_prev(i,J,k)) ; enddo
2890 write(file,'(/,"v+-: ")', advance='no')
2900 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*CS%v_prev(i+1,J-1,k)) ; enddo
2910 write(file,'(/,"v++: ")', advance='no')
2920 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*CS%v_prev(i+1,J,k)) ; enddo
293 endif
294
2950 write(file,'(/,"vh--: ")', advance='no')
2960 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
2970 (uh_scale*CDp%vh(i,J-1,k)*G%IdxCv(i,J-1)) ; enddo
2980 write(file,'(/," vhC--:")', advance='no')
2990 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3000 (0.5*CS%v_av(i,j-1,k)*uh_scale*(hin(i,j-1,k) + hin(i,j,k))) ; enddo
3010 if (prev_avail) then
3020 write(file,'(/," vhCp--:")', advance='no')
3030 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3040 (0.5*CS%v_prev(i,j-1,k)*uh_scale*(hin(i,j-1,k) + hin(i,j,k))) ; enddo
305 endif
306
3070 write(file,'(/,"vh-+: ")', advance='no')
3080 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3090 (uh_scale*CDp%vh(i,J,k)*G%IdxCv(i,J)) ; enddo
3100 write(file,'(/," vhC-+:")', advance='no')
3110 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3120 (0.5*CS%v_av(i,J,k)*uh_scale*(hin(i,j,k) + hin(i,j+1,k))) ; enddo
3130 if (prev_avail) then
3140 write(file,'(/," vhCp-+:")', advance='no')
3150 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3160 (0.5*CS%v_prev(i,J,k)*uh_scale*(hin(i,j,k) + hin(i,j+1,k))) ; enddo
317 endif
318
3190 write(file,'(/,"vh+-: ")', advance='no')
3200 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3210 (uh_scale*CDp%vh(i+1,J-1,k)*G%IdxCv(i+1,J-1)) ; enddo
3220 write(file,'(/," vhC+-:")', advance='no')
3230 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3240 (0.5*CS%v_av(i+1,J-1,k)*uh_scale*(hin(i+1,j-1,k) + hin(i+1,j,k))) ; enddo
3250 if (prev_avail) then
3260 write(file,'(/," vhCp+-:")', advance='no')
3270 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3280 (0.5*CS%v_prev(i+1,J-1,k)*uh_scale*(hin(i+1,j-1,k) + hin(i+1,j,k))) ; enddo
329 endif
330
3310 write(file,'(/,"vh++: ")', advance='no')
3320 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3330 (uh_scale*CDp%vh(i+1,J,k)*G%IdxCv(i+1,J)) ; enddo
3340 write(file,'(/," vhC++:")', advance='no')
3350 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3360 (0.5*CS%v_av(i+1,J,k)*uh_scale*(hin(i+1,j,k) + hin(i+1,j+1,k))) ; enddo
3370 if (prev_avail) then
3380 write(file,'(/," vhCp++:")', advance='no')
3390 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
3400 (0.5*CS%v_av(i+1,J,k)*uh_scale*(hin(i+1,j,k) + hin(i+1,j+1,k))) ; enddo
341 endif
342
3430 write(file,'(/,"D: ",2(ES10.3))') US%Z_to_m*(G%bathyT(i,j) + G%Z_ref), US%Z_to_m*(G%bathyT(i+1,j) + G%Z_ref)
344
345 ! From here on, the normalized accelerations are written.
3460 if (prev_avail) then
3470 do k=ks,ke
3480 du = um(I,j,k) - CS%u_prev(I,j,k)
3490 if (abs(du) < 1.0e-6*US%m_s_to_L_T) du = 1.0e-6*US%m_s_to_L_T
3500 Inorm(k) = 1.0 / du
351 enddo
352
3530 write(file,'(2/,"Norm: ")', advance='no')
3540 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') (vel_scale / Inorm(k)) ; enddo
355
3560 write(file,'(/,"du: ")', advance='no')
3570 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
3580 ((um(I,j,k)-CS%u_prev(I,j,k)) * Inorm(k)) ; enddo
359
3600 write(file,'(/,"CAu: ")', advance='no')
3610 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
3620 (dt*ADp%CAu(I,j,k) * Inorm(k)) ; enddo
363
3640 write(file,'(/,"PFu: ")', advance='no')
3650 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
3660 (dt*ADp%PFu(I,j,k) * Inorm(k)) ; enddo
367
3680 write(file,'(/,"diffu: ")', advance='no')
3690 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
3700 (dt*ADp%diffu(I,j,k) * Inorm(k)) ; enddo
371
3720 if (associated(ADp%gradKEu)) then
3730 write(file,'(/,"KEu: ")', advance='no')
3740 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
3750 (dt*ADp%gradKEu(I,j,k) * Inorm(k)) ; enddo
376 endif
3770 if (associated(ADp%rv_x_v)) then
3780 write(file,'(/,"Coru: ")', advance='no')
3790 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
3800 (dt*(ADp%CAu(I,j,k)-ADp%rv_x_v(I,j,k)) * Inorm(k)) ; enddo
381 endif
3820 if (associated(ADp%du_dt_visc)) then
3830 write(file,'(/,"duv: ")', advance='no')
3840 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
3850 (dt*ADp%du_dt_visc(I,j,k) * Inorm(k)) ; enddo
386 endif
3870 if (associated(ADp%du_other)) then
3880 write(file,'(/,"du_other: ")', advance='no')
3890 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
3900 (ADp%du_other(I,j,k) * Inorm(k)) ; enddo
391 endif
3920 if (associated(CS%u_accel_bt)) then
3930 write(file,'(/,"dubt: ")', advance='no')
3940 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
3950 (dt*CS%u_accel_bt(I,j,k) * Inorm(k)) ; enddo
396 endif
397 endif
398
3990 write(file,'(2/)')
400
4010 flush(file)
402 endif
403
4040end subroutine write_u_accel
405
406!> This subroutine writes to an output file all of the accelerations
407!! that have been applied to a column of meridional velocities over
408!! the previous timestep. This subroutine is called from vertvisc.
4090subroutine write_v_accel(i, J, vm, hin, ADp, CDp, dt, G, GV, US, CS, vel_rpt, str, a, hv)
410 integer, intent(in) :: i !< The zonal index of the column to be documented.
411 integer, intent(in) :: J !< The meridional index of the column to be documented.
412 type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure.
413 type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure.
414 type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
415 real, dimension(SZI_(G),SZJB_(G),SZK_(GV)), &
416 intent(in) :: vm !< The new meridional velocity [L T-1 ~> m s-1].
417 real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
418 intent(in) :: hin !< The layer thickness [H ~> m or kg m-2].
419 type(accel_diag_ptrs), intent(in) :: ADp !< A structure pointing to the various
420 !! accelerations in the momentum equations.
421 type(cont_diag_ptrs), intent(in) :: CDp !< A structure with pointers to various terms in
422 !! the continuity equations.
423 real, intent(in) :: dt !< The ocean dynamics time step [T ~> s].
424 type(PointAccel_CS), pointer :: CS !< The control structure returned by a previous
425 !! call to PointAccel_init.
426 real, intent(in) :: vel_rpt !< The velocity magnitude that triggers a report [L T-1 ~> m s-1]
427 real, optional, intent(in) :: str !< The surface wind stress [R L Z T-2 ~> Pa]
428 real, dimension(SZI_(G),SZJB_(G),SZK_(GV)+1), &
429 optional, intent(in) :: a !< The layer coupling coefficients from vertvisc
430 !! [H T-1 ~> m s-1 or Pa s m-1]
431 real, dimension(SZI_(G),SZJB_(G),SZK_(GV)), &
432 optional, intent(in) :: hv !< The layer thicknesses at velocity grid points,
433 !! from vertvisc [H ~> m or kg m-2].
434
435 ! Local variables
436 real :: CFL ! The local velocity-based CFL number [nondim]
437 real :: Angstrom ! A negligibly small thickness [H ~> m or kg m-2]
438 real :: dv ! A velocity change [L T-1 ~> m s-1]
4390 real :: Inorm(SZK_(GV)) ! The inverse of the normalized velocity change [L T-1 ~> m s-1]
4400 real :: e(SZK_(GV)+1) ! Simple estimates of interface heights based on the sum of thicknesses [m]
441 real :: h_scale ! A scaling factor for thicknesses [m H-1 ~> 1] or [kg m-2 H-1 ~> 1]
442 real :: vel_scale ! A scaling factor for velocities [m T s-1 L-1 ~> 1]
443 real :: uh_scale ! A scaling factor for transport per unit length [m2 T s-1 L-1 H-1 ~> 1]
444 ! or [kg T m-1 s-1 L-1 H-1 ~> 1]
445 real :: temp_scale ! A scaling factor for temperatures [degC C-1 ~> 1]
446 real :: saln_scale ! A scaling factor for salinities [ppt S-1 ~> 1]
447 integer :: yr, mo, day, hr, minute, sec, yearday
448 integer :: k, ks, ke
449 integer :: nz
4500 logical :: do_k(SZK_(GV)+1)
451 logical :: prev_avail
452 integer :: file
453
4540 Angstrom = GV%Angstrom_H + GV%H_subroundoff
4550 h_scale = GV%H_to_mks ; vel_scale = US%L_T_to_m_s ; uh_scale = h_scale*vel_scale
4560 temp_scale = US%C_to_degC ; saln_scale = US%S_to_ppt
457
458! if (.not.associated(CS)) return
4590 nz = GV%ke
4600 if (CS%cols_written < CS%max_writes) then
4610 CS%cols_written = CS%cols_written + 1
462
4630 ks = 1 ; ke = nz
4640 do_k(:) = .false.
465
466 ! Open up the file for output if this is the first call.
4670 if (CS%v_file == -1) then
4680 if (len_trim(CS%v_trunc_file) < 1) return
469 call open_ASCII_file(CS%v_file, trim(CS%v_trunc_file), action=APPEND_FILE, &
4700 threading=MULTIPLE, fileset=SINGLE_FILE)
4710 if (CS%v_file == -1) then
4720 call MOM_error(NOTE, 'Unable to open file '//trim(CS%v_trunc_file)//'.')
4730 return
474 endif
475 endif
4760 file = CS%v_file
477
4780 prev_avail = (associated(CS%u_prev) .and. associated(CS%v_prev))
479
4800 do k=1,nz
481 if (((max(CS%v_av(i,J,k), vm(i,J,k)) >= vel_rpt) .or. &
4820 (min(CS%v_av(i,J,k), vm(i,J,k)) <= -vel_rpt)) .and. &
4830 ((hin(i,j,k) + hin(i,j+1,k)) > 3.0*Angstrom)) exit
484 enddo
4850 ks = k
4860 do k=nz,1,-1
487 if (((max(CS%v_av(i,J,k), vm(i,J,k)) >= vel_rpt) .or. &
4880 (min(CS%v_av(i,J,k), vm(i,J,k)) <= -vel_rpt)) .and. &
4890 ((hin(i,j,k) + hin(i,j+1,k)) > 3.0*Angstrom)) exit
490 enddo
4910 ke = k
4920 if (ke < ks) then
4930 ks = 1 ; ke = nz ; write(file,'("V: Unable to set ks & ke.")')
494 endif
4950 if (CS%full_column) then
4960 ks = 1 ; ke = nz
497 endif
498
4990 call get_date(CS%Time, yr, mo, day, hr, minute, sec)
5000 call get_time((CS%Time - set_date(yr, 1, 1, 0, 0, 0)), sec, yearday)
5010 write (file,'(/,"--------------------------")')
502 write (file,'(/,"Time ",I0," ",I0," ",F6.2," V-velocity violation at ",I0,": ",I0,", ",I0, &
503 & " (",F7.2," E ",F7.2," N) Layers ",I0," to ",I0,". dt = ",1PG10.4)') &
5040 yr, yearday, (REAL(sec)/3600.0), pe_here(), i, J, &
5050 G%geoLonCv(i,J), G%geoLatCv(i,J), ks, ke, US%T_to_s*dt
506
5070 if (ks <= GV%nk_rho_varies) ks = 1
5080 do k=ks,ke
5090 if ((hin(i,j,k) + hin(i,j+1,k)) > 3.0*Angstrom) do_k(k) = .true.
510 enddo
511
5120 write(file,'(/,"Layers:")', advance='no')
5130 do k=ks,ke ; if (do_k(k)) write(file,'(I10," ")', advance='no') (k) ; enddo
5140 write(file,'(/,"v(m): ")', advance='no')
5150 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*vm(i,J,k)) ; enddo
516
5170 if (prev_avail) then
5180 write(file,'(/,"v(mp): ")', advance='no')
5190 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*CS%v_prev(i,J,k)) ; enddo
520 endif
521
5220 write(file,'(/,"v(3): ")', advance='no')
5230 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*CS%v_av(i,J,k)) ; enddo
5240 write(file,'(/,"CFL v: ")', advance='no')
5250 do k=ks,ke ; if (do_k(k)) then
5260 CFL = abs(vm(i,J,k)) * dt * G%dx_Cv(i,J)
5270 if (vm(i,J,k) < 0.0) then ; CFL = CFL * G%IareaT(i,j+1)
5280 else ; CFL = CFL * G%IareaT(i,j) ; endif
5290 write(file,'(ES10.3," ")', advance='no') CFL
530 endif ; enddo
5310 write(file,'(/,"CFL0 v:")', advance='no')
5320 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
5330 abs(vm(i,J,k)) * dt * G%IdyCv(i,J) ; enddo
534
5350 if (prev_avail) then
5360 write(file,'(/,"dv: ")', advance='no')
5370 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
5380 (vel_scale*(vm(i,J,k)-CS%v_prev(i,J,k))) ; enddo
539 endif
540
5410 write(file,'(/,"CAv: ")', advance='no')
5420 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*dt*ADp%CAv(i,J,k)) ; enddo
543
5440 write(file,'(/,"PFv: ")', advance='no')
5450 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*dt*ADp%PFv(i,J,k)) ; enddo
546
5470 write(file,'(/,"diffv: ")', advance='no')
5480 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') (vel_scale*dt*ADp%diffv(i,J,k)) ; enddo
549
5500 if (associated(ADp%gradKEv)) then
5510 write(file,'(/,"KEv: ")', advance='no')
5520 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
5530 (vel_scale*dt*ADp%gradKEv(i,J,k)) ; enddo
554 endif
5550 if (associated(ADp%rv_x_u)) then
5560 write(file,'(/,"Corv: ")', advance='no')
5570 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
5580 vel_scale*dt*(ADp%CAv(i,J,k)-ADp%rv_x_u(i,J,k)) ; enddo
559 endif
5600 if (associated(ADp%dv_dt_visc)) then
5610 write(file,'(/,"vbv: ")', advance='no')
5620 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
5630 vel_scale*(vm(i,J,k) - dt*ADp%dv_dt_visc(i,J,k)) ; enddo
564
5650 write(file,'(/,"dvv: ")', advance='no')
5660 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
5670 (vel_scale*dt*ADp%dv_dt_visc(i,J,k)) ; enddo
568 endif
5690 if (associated(ADp%dv_other)) then
5700 write(file,'(/,"dv_other: ")', advance='no')
5710 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
5720 (vel_scale*ADp%dv_other(i,J,k)) ; enddo
573 endif
5740 if (present(a)) then
5750 write(file,'(/,"a: ",ES10.3," ")', advance='no') h_scale*a(i,J,ks)*dt
5760 do K=ks+1,ke+1 ; if (do_k(k-1)) write(file,'(ES10.3," ")', advance='no') (h_scale*a(i,J,K)*dt) ; enddo
577 endif
5780 if (present(hv)) then
5790 write(file,'(/,"hvel: ")', advance='no')
5800 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') h_scale*hv(i,J,k) ; enddo
581 endif
5820 if (present(str)) then
5830 write(file,'(/,"Stress: ",ES10.3)', advance='no') (uh_scale*GV%RZ_to_H) * (str*dt)
584 endif
585
5860 if (associated(CS%v_accel_bt)) then
5870 write(file,'("dvbt: ")', advance='no')
5880 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
5890 (vel_scale*dt*CS%v_accel_bt(i,J,k)) ; enddo
590 endif
5910 write(file,'(/)')
592
5930 write(file,'("h--: ")', advance='no')
5940 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') h_scale*hin(i-1,j,k) ; enddo
5950 write(file,'(/,"h0-: ")', advance='no')
5960 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') h_scale*hin(i,j,k) ; enddo
5970 write(file,'(/,"h+-: ")', advance='no')
5980 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') h_scale*hin(i+1,j,k) ; enddo
5990 write(file,'(/,"h-+: ")', advance='no')
6000 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') h_scale*hin(i-1,j+1,k) ; enddo
6010 write(file,'(/,"h0+: ")', advance='no')
6020 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') h_scale*hin(i,j+1,k) ; enddo
6030 write(file,'(/,"h++: ")', advance='no')
6040 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') h_scale*hin(i+1,j+1,k) ; enddo
605
6060 e(nz+1) = -US%Z_to_m*(G%bathyT(i,j) + G%Z_ref)
6070 do k=nz,1,-1 ; e(K) = e(K+1) + h_scale*hin(i,j,k) ; enddo
6080 write(file,'(/,"e-: ",ES10.3," ")', advance='no') e(ks)
6090 do K=ks+1,ke+1 ; if (do_k(k-1)) write(file,'(ES10.3," ")', advance='no') e(K) ; enddo
610
6110 e(nz+1) = -US%Z_to_m*(G%bathyT(i,j+1) + G%Z_ref)
6120 do k=nz,1,-1 ; e(K) = e(K+1) + h_scale*hin(i,j+1,k) ; enddo
6130 write(file,'(/,"e+: ",ES10.3," ")', advance='no') e(ks)
6140 do K=ks+1,ke+1 ; if (do_k(k-1)) write(file,'(ES10.3," ")', advance='no') e(K) ; enddo
6150 if (associated(CS%T)) then
6160 write(file,'(/,"T-: ")', advance='no')
6170 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') temp_scale*CS%T(i,j,k) ; enddo
6180 write(file,'(/,"T+: ")', advance='no')
6190 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') temp_scale*CS%T(i,j+1,k) ; enddo
620 endif
6210 if (associated(CS%S)) then
6220 write(file,'(/,"S-: ")', advance='no')
6230 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') saln_scale*CS%S(i,j,k) ; enddo
6240 write(file,'(/,"S+: ")', advance='no')
6250 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') saln_scale*CS%S(i,j+1,k) ; enddo
626 endif
627
6280 if (prev_avail) then
6290 write(file,'(/,"u--: ")', advance='no')
6300 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') vel_scale*CS%u_prev(I-1,j,k) ; enddo
6310 write(file,'(/,"u-+: ")', advance='no')
6320 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') vel_scale*CS%u_prev(I-1,j+1,k) ; enddo
6330 write(file,'(/,"u+-: ")', advance='no')
6340 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') vel_scale*CS%u_prev(I,j,k) ; enddo
6350 write(file,'(/,"u++: ")', advance='no')
6360 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') vel_scale*CS%u_prev(I,j+1,k) ; enddo
637 endif
638
6390 write(file,'(/,"uh--: ")', advance='no')
6400 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6410 (uh_scale*CDp%uh(I-1,j,k)*G%IdyCu(I-1,j)) ; enddo
6420 write(file,'(/," uhC--: ")', advance='no')
6430 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6440 (CS%u_av(I-1,j,k) * uh_scale*0.5*(hin(i-1,j,k) + hin(i,j,k))) ; enddo
6450 if (prev_avail) then
6460 write(file,'(/," uhCp--:")', advance='no')
6470 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6480 (CS%u_prev(I-1,j,k) * uh_scale*0.5*(hin(i-1,j,k) + hin(i,j,k))) ; enddo
649 endif
650
6510 write(file,'(/,"uh-+: ")', advance='no')
6520 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6530 (uh_scale*CDp%uh(I-1,j+1,k)*G%IdyCu(I-1,j+1)) ; enddo
6540 write(file,'(/," uhC-+: ")', advance='no')
6550 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6560 (CS%u_av(I-1,j+1,k) * uh_scale*0.5*(hin(i-1,j+1,k) + hin(i,j+1,k))) ; enddo
6570 if (prev_avail) then
6580 write(file,'(/," uhCp-+:")', advance='no')
6590 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6600 (CS%u_prev(I-1,j+1,k) * uh_scale*0.5*(hin(i-1,j+1,k) + hin(i,j+1,k))) ; enddo
661 endif
662
6630 write(file,'(/,"uh+-: ")', advance='no')
6640 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6650 (uh_scale*CDp%uh(I,j,k)*G%IdyCu(I,j)) ; enddo
6660 write(file,'(/," uhC+-: ")', advance='no')
6670 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6680 (CS%u_av(I,j,k) * uh_scale*0.5*(hin(i,j,k) + hin(i+1,j,k))) ; enddo
6690 if (prev_avail) then
6700 write(file,'(/," uhCp+-:")', advance='no')
6710 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6720 (CS%u_prev(I,j,k) * uh_scale*0.5*(hin(i,j,k) + hin(i+1,j,k))) ; enddo
673 endif
674
6750 write(file,'(/,"uh++: ")', advance='no')
6760 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6770 (uh_scale*CDp%uh(I,j+1,k)*G%IdyCu(I,j+1)) ; enddo
6780 write(file,'(/," uhC++: ")', advance='no')
6790 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6800 (CS%u_av(I,j+1,k) * uh_scale*0.5*(hin(i,j+1,k) + hin(i+1,j+1,k))) ; enddo
6810 if (prev_avail) then
6820 write(file,'(/," uhCp++:")', advance='no')
6830 do k=ks,ke ; if (do_k(k)) write(file,'(ES10.3," ")', advance='no') &
6840 (CS%u_prev(I,j+1,k) * uh_scale*0.5*(hin(i,j+1,k) + hin(i+1,j+1,k))) ; enddo
685 endif
686
6870 write(file,'(/,"D: ",2(ES10.3))') US%Z_to_m*(G%bathyT(i,j) + G%Z_ref), US%Z_to_m*(G%bathyT(i,j+1) + G%Z_ref)
688
689 ! From here on, the normalized accelerations are written.
6900 if (prev_avail) then
6910 do k=ks,ke
6920 dv = vm(i,J,k) - CS%v_prev(i,J,k)
6930 if (abs(dv) < 1.0e-6*US%m_s_to_L_T) dv = 1.0e-6*US%m_s_to_L_T
6940 Inorm(k) = 1.0 / dv
695 enddo
696
6970 write(file,'(2/,"Norm: ")', advance='no')
6980 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') (vel_scale / Inorm(k)) ; enddo
6990 write(file,'(/,"dv: ")', advance='no')
7000 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
7010 ((vm(i,J,k)-CS%v_prev(i,J,k)) * Inorm(k)) ; enddo
7020 write(file,'(/,"CAv: ")', advance='no')
7030 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
7040 (dt*ADp%CAv(i,J,k) * Inorm(k)) ; enddo
7050 write(file,'(/,"PFv: ")', advance='no')
7060 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
7070 (dt*ADp%PFv(i,J,k) * Inorm(k)) ; enddo
7080 write(file,'(/,"diffv: ")', advance='no')
7090 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
7100 (dt*ADp%diffv(i,J,k) * Inorm(k)) ; enddo
711
7120 if (associated(ADp%gradKEu)) then
7130 write(file,'(/,"KEv: ")', advance='no')
7140 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
7150 (dt*ADp%gradKEv(i,J,k) * Inorm(k)) ; enddo
716 endif
7170 if (associated(ADp%rv_x_u)) then
7180 write(file,'(/,"Corv: ")', advance='no')
7190 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
7200 (dt*(ADp%CAv(i,J,k)-ADp%rv_x_u(i,J,k)) * Inorm(k)) ; enddo
721 endif
7220 if (associated(ADp%dv_dt_visc)) then
7230 write(file,'(/,"dvv: ")', advance='no')
7240 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
7250 (dt*ADp%dv_dt_visc(i,J,k) * Inorm(k)) ; enddo
726 endif
7270 if (associated(ADp%dv_other)) then
7280 write(file,'(/,"dv_other: ")', advance='no')
7290 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
7300 (ADp%dv_other(i,J,k) * Inorm(k)) ; enddo
731 endif
7320 if (associated(CS%v_accel_bt)) then
7330 write(file,'(/,"dvbt: ")', advance='no')
7340 do k=ks,ke ; if (do_k(k)) write(file,'(F10.6," ")', advance='no') &
7350 (dt*CS%v_accel_bt(i,J,k) * Inorm(k)) ; enddo
736 endif
737 endif
738
7390 write(file,'(2/)')
740
7410 flush(file)
742 endif
743
7440end subroutine write_v_accel
745
746!> This subroutine initializes the parameters regulating how truncations are logged.
7471subroutine PointAccel_init(MIS, Time, G, param_file, diag, dirs, CS)
748 type(ocean_internal_state), &
749 target, intent(in) :: MIS !< For "MOM Internal State" a set of pointers
750 !! to the fields and accelerations that make
751 !! up the ocean's physical state.
752 type(time_type), target, intent(in) :: Time !< The current model time.
753 type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure.
754 type(param_file_type), intent(in) :: param_file !< A structure to parse for run-time
755 !! parameters.
756 type(diag_ctrl), target, intent(inout) :: diag !< A structure that is used to regulate
757 !! diagnostic output.
758 type(directories), intent(in) :: dirs !< A structure containing several relevant
759 !! directory paths.
760 type(PointAccel_CS), pointer :: CS !< A pointer that is set to point to the
761 !! control structure for this module.
762 ! This include declares and sets the variable "version".
763# include "version_variable.h"
764 character(len=40) :: mdl = "MOM_PointAccel" ! This module's name.
765
7661 if (associated(CS)) return
7671 allocate(CS)
768
7691 CS%diag => diag ; CS%Time => Time
770
7711 CS%T => MIS%T ; CS%S => MIS%S
7721 CS%u_accel_bt => MIS%u_accel_bt ; CS%v_accel_bt => MIS%v_accel_bt
7731 CS%u_prev => MIS%u_prev ; CS%v_prev => MIS%v_prev
7741 CS%u_av => MIS%u_av ; if (.not.associated(MIS%u_av)) CS%u_av => MIS%u(:,:,:)
7751 CS%v_av => MIS%v_av ; if (.not.associated(MIS%v_av)) CS%v_av => MIS%v(:,:,:)
776
777 ! Read all relevant parameters and write them to the model log.
7781 call log_version(param_file, mdl, version, "", debugging=.true.)
779 call get_param(param_file, mdl, "U_TRUNC_FILE", CS%u_trunc_file, &
780 "The absolute path to the file where the accelerations "//&
781 "leading to zonal velocity truncations are written. \n"//&
782 "Leave this empty for efficiency if this diagnostic is "//&
7831 "not needed.", default="", debuggingParam=.true.)
784 call get_param(param_file, mdl, "V_TRUNC_FILE", CS%v_trunc_file, &
785 "The absolute path to the file where the accelerations "//&
786 "leading to meridional velocity truncations are written. \n"//&
787 "Leave this empty for efficiency if this diagnostic is "//&
7881 "not needed.", default="", debuggingParam=.true.)
789 call get_param(param_file, mdl, "MAX_TRUNC_FILE_SIZE_PER_PE", CS%max_writes, &
790 "The maximum number of columns of truncations that any PE "//&
7911 "will write out during a run.", default=50, debuggingParam=.true.)
792 call get_param(param_file, mdl, "DEBUG_FULL_COLUMN", CS%full_column, &
793 "If true, write out the accelerations in all massive layers; otherwise "//&
794 "just document the ones with large velocities.", &
7951 default=.false., debuggingParam=.true.)
796
7971 if (len_trim(dirs%output_directory) > 0) then
7981 if (len_trim(CS%u_trunc_file) > 0) &
7991 CS%u_trunc_file = trim(dirs%output_directory)//trim(CS%u_trunc_file)
8001 if (len_trim(CS%v_trunc_file) > 0) &
8011 CS%v_trunc_file = trim(dirs%output_directory)//trim(CS%v_trunc_file)
8021 call log_param(param_file, mdl, "output_dir/U_TRUNC_FILE", CS%u_trunc_file, debuggingParam=.true.)
8031 call log_param(param_file, mdl, "output_dir/V_TRUNC_FILE", CS%v_trunc_file, debuggingParam=.true.)
804 endif
8051 CS%u_file = -1 ; CS%v_file = -1 ; CS%cols_written = 0
806
807end subroutine PointAccel_init
808
8090end module MOM_PointAccel