ROMS
Loading...
Searching...
No Matches
ad_set_zeta.F
Go to the documentation of this file.
1#include "cppdefs.h"
3
4#if defined ADJOINT && defined SOLVE3D
5!
6!git $Id$
7!================================================== Hernan G. Arango ===
8! Copyright (c) 2002-2025 The ROMS Group !
9! Licensed under a MIT/X style license !
10! See License_ROMS.md !
11!=======================================================================
12! !
13! This routine sets adjoint free-surface to its fast-time averaged !
14! value. !
15! !
16!=======================================================================
17!
18 implicit none
19!
20 PRIVATE
21 PUBLIC :: ad_set_zeta
22!
23 CONTAINS
24!
25!***********************************************************************
26 SUBROUTINE ad_set_zeta (ng, tile)
27!***********************************************************************
28!
29 USE mod_param
30 USE mod_coupling
31 USE mod_ocean
32!
33! Imported variable declarations.
34!
35 integer, intent(in) :: ng, tile
36!
37! Local variable declarations.
38!
39 character (len=*), parameter :: myfile = &
40 & __FILE__
41!
42# include "tile.h"
43!
44# ifdef PROFILE
45 CALL wclock_on (ng, iadm, 12, __line__, myfile)
46# endif
47 CALL ad_set_zeta_tile (ng, tile, &
48 & lbi, ubi, lbj, ubj, &
49 & imins, imaxs, jmins, jmaxs, &
50 & coupling(ng) % ad_Zt_avg1, &
51 & ocean(ng) % ad_zeta, &
52 & ocean(ng) % ad_zeta_sol)
53# ifdef PROFILE
54 CALL wclock_off (ng, iadm, 12, __line__, myfile)
55# endif
56!
57 RETURN
58 END SUBROUTINE ad_set_zeta
59!
60!***********************************************************************
61 SUBROUTINE ad_set_zeta_tile (ng, tile, &
62 & LBi, UBi, LBj, UBj, &
63 & IminS, ImaxS, JminS, JmaxS, &
64 & ad_Zt_avg1, ad_zeta, ad_zeta_sol)
65!***********************************************************************
66!
67 USE mod_param
68 USE mod_scalars
69!
71# ifdef DISTRIBUTE
73# endif
74!
75! Imported variable declarations.
76!
77 integer, intent(in) :: ng, tile
78 integer, intent(in) :: LBi, UBi, LBj, UBj
79 integer, intent(in) :: IminS, ImaxS, JminS, JmaxS
80!
81# ifdef ASSUMED_SHAPE
82 real(r8), intent(inout) :: ad_Zt_avg1(LBi:,LBj:)
83 real(r8), intent(inout) :: ad_zeta(LBi:,LBj:,:)
84
85 real(r8), intent(out) :: ad_zeta_sol(LBi:,LBj:)
86# else
87 real(r8), intent(inout) :: ad_Zt_avg1(LBi:UBi,LBj:UBj)
88 real(r8), intent(inout) :: ad_zeta(LBi:UBi,LBj:UBj,3)
89
90 real(r8), intent(out) :: ad_zeta_sol(LBi:UBi,LBj:UBj)
91# endif
92!
93! Local variable declarations.
94!
95 integer :: i, j
96
97# include "set_bounds.h"
98!
99!-----------------------------------------------------------------------
100! Prepare to time-step adjoint 2D equations: set initial free-surface
101! to its fast-time averaged values (which corresponds to the time
102! step "n").
103!-----------------------------------------------------------------------
104!
105# ifdef DISTRIBUTE
106!^ CALL mp_exchange2d (ng, tile, iTLM, 2, &
107!^ & LBi, UBi, LBj, UBj, &
108!^ & NghostPoints, &
109!^ & EWperiodic(ng), NSperiodic(ng), &
110!^ & tl_zeta(:,:,1), &
111!^ & tl_zeta(:,:,2))
112!^
113 CALL ad_mp_exchange2d (ng, tile, iadm, 2, &
114 & lbi, ubi, lbj, ubj, &
115 & nghostpoints, &
116 & ewperiodic(ng), nsperiodic(ng), &
117 & ad_zeta(:,:,1), &
118 & ad_zeta(:,:,2))
119!
120# endif
121
122 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
123!^ CALL exchange_r2d_tile (ng, tile, &
124!^ & LBi, UBi, LBj, UBj, &
125!^ & tl_zeta(:,:,2))
126!^
127 CALL ad_exchange_r2d_tile (ng, tile, &
128 & lbi, ubi, lbj, ubj, &
129 & ad_zeta(:,:,2))
130!^ CALL exchange_r2d_tile (ng, tile, &
131!^ & LBi, UBi, LBj, UBj, &
132!^ & tl_zeta(:,:,1))
133!^
134 CALL ad_exchange_r2d_tile (ng, tile, &
135 & lbi, ubi, lbj, ubj, &
136 & ad_zeta(:,:,1))
137 END IF
138!
139! Save the adjoint free-surface solution for the current time-step
140! (sum of time indices 1 and 2).
141!
142 DO j=jstrr,jendr
143 DO i=istrr,iendr
144 ad_zeta_sol(i,j)=ad_zeta(i,j,1)+ad_zeta(i,j,2)
145 END DO
146 END DO
147!
148 DO j=jstrr,jendr
149 DO i=istrr,iendr
150!^ tl_zeta(i,j,2)=tl_Zt_avg1(i,j)
151!^ tl_zeta(i,j,1)=tl_Zt_avg1(i,j)
152!^
153 ad_zt_avg1(i,j)=ad_zt_avg1(i,j)+ &
154 & ad_zeta(i,j,1)+ad_zeta(i,j,2)
155 ad_zeta(i,j,2)=0.0_r8
156 ad_zeta(i,j,1)=0.0_r8
157 END DO
158 END DO
159!
160 RETURN
161 END SUBROUTINE ad_set_zeta_tile
162#endif
163 END MODULE ad_set_zeta_mod
subroutine ad_exchange_r2d_tile(ng, tile, lbi, ubi, lbj, ubj, ad_a)
subroutine, public ad_set_zeta(ng, tile)
Definition ad_set_zeta.F:27
subroutine ad_set_zeta_tile(ng, tile, lbi, ubi, lbj, ubj, imins, imaxs, jmins, jmaxs, ad_zt_avg1, ad_zeta, ad_zeta_sol)
Definition ad_set_zeta.F:65
type(t_coupling), dimension(:), allocatable coupling
type(t_ocean), dimension(:), allocatable ocean
Definition mod_ocean.F:351
integer nghostpoints
Definition mod_param.F:710
integer, parameter iadm
Definition mod_param.F:665
logical, dimension(:), allocatable ewperiodic
logical, dimension(:), allocatable nsperiodic
subroutine ad_mp_exchange2d(ng, tile, model, nvar, lbi, ubi, lbj, ubj, nghost, ew_periodic, ns_periodic, ad_a, ad_b, ad_c, ad_d)
recursive subroutine wclock_off(ng, model, region, line, routine)
Definition timers.F:148
recursive subroutine wclock_on(ng, model, region, line, routine)
Definition timers.F:3