New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
agrif_lim3_update.F90 in branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/NST_SRC – NEMO

source: branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/NST_SRC/agrif_lim3_update.F90 @ 9012

Last change on this file since 9012 was 8885, checked in by clem, 6 years ago

remove useless references to clem's comments

File size: 10.3 KB
Line 
1#define TWO_WAY
2
3MODULE agrif_lim3_update
4   !!=====================================================================================
5   !!                       ***  MODULE agrif_lim3_update ***
6   !! Nesting module :  update surface ocean boundary condition over ice from a child grid
7   !! Sea-Ice model  :  LIM 3.6 Sea ice model time-stepping
8   !!=====================================================================================
9   !! History :  2.0   !  04-2008  (F. Dupont)  initial version
10   !!            3.4   !  08-2012  (R. Benshila, C. Herbaut) update and EVP
11   !!            3.6   !  05-2016  (C. Rousset)  Add LIM3 compatibility
12   !!----------------------------------------------------------------------
13#if defined key_agrif && defined key_lim3
14   !!----------------------------------------------------------------------
15   !!   'key_lim3'  :                                 LIM 3.6 sea-ice model
16   !!   'key_agrif' :                                 AGRIF library
17   !!----------------------------------------------------------------------
18   !!   agrif_update_lim3  : update sea-ice on boundaries or total
19   !!                        child domain for velocities and ice properties
20   !!   update_tra_ice     : sea-ice properties
21   !!   update_u_ice       : zonal      ice velocity
22   !!   update_v_ice       : meridional ice velocity
23   !!----------------------------------------------------------------------
24   USE dom_oce
25   USE sbc_oce
26   USE agrif_oce
27   USE ice
28   USE agrif_ice 
29
30   IMPLICIT NONE
31   PRIVATE
32
33   PUBLIC   agrif_update_lim3   ! called by agrif_user.F90
34
35   !!----------------------------------------------------------------------
36   !! NEMO/NST 4.0 , LOCEAN-IPSL (2017)
37   !! $Id: agrif_lim3_update.F90 6204 2016-01-04 13:47:06Z cetlod $
38   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
39   !!----------------------------------------------------------------------
40CONTAINS
41
42   SUBROUTINE agrif_update_lim3( kt )
43      !!----------------------------------------------------------------------
44      !!                     *** ROUTINE agrif_update_lim3 ***
45      !! ** Method  :   Call the hydrostaticupdate pressure at the boundary or the entire domain
46      !!
47      !! ** Action : - Update (u_ice,v_ice) and ice tracers
48      !!----------------------------------------------------------------------
49      INTEGER, INTENT(in) :: kt
50      !!----------------------------------------------------------------------
51      !
52      !! clem: I think the update should take place each time the ocean sees the surface forcings
53      !!       (but maybe I am wrong and we should update every rhot time steps)
54      IF( ( MOD( (kt-nit000)/nn_fsbc + 1, Agrif_irhot() * Agrif_Parent(nn_fsbc) / nn_fsbc ) /=0 ) .AND. (kt /= 0) ) RETURN ! do not update if nb of child time steps differ from time refinement
55                                                                                                                           ! i.e. update only at the parent time step
56      IF( nn_ice == 0 ) RETURN   ! do not update if child domain does not have ice
57      !
58      Agrif_SpecialValueFineGrid    = -9999.
59      Agrif_UseSpecialValueInUpdate = .TRUE.
60# if defined TWO_WAY
61      IF( MOD(nbcline,nbclineupdate) == 0) THEN ! update the whole basin at each nbclineupdate (=nn_cln_update) baroclinic parent time steps
62                                                ! nbcline is incremented (+1) at the end of each parent time step from 0 (1st time step)
63         CALL Agrif_Update_Variable( tra_ice_id , procname = update_tra_ice  )
64         CALL Agrif_Update_Variable( u_ice_id   , procname = update_u_ice    )
65         CALL Agrif_Update_Variable( v_ice_id   , procname = update_v_ice    )
66      ELSE                                      ! update only the boundaries defined par locupdate
67         CALL Agrif_Update_Variable( tra_ice_id , locupdate=(/0,2/), procname = update_tra_ice  )
68         CALL Agrif_Update_Variable( u_ice_id   , locupdate=(/0,1/), procname = update_u_ice    )
69         CALL Agrif_Update_Variable( v_ice_id   , locupdate=(/0,1/), procname = update_v_ice    )
70      ENDIF
71# endif
72      Agrif_SpecialValueFineGrid    = 0.
73      Agrif_UseSpecialValueInUpdate = .FALSE.
74      !
75   END SUBROUTINE agrif_update_lim3
76
77
78   SUBROUTINE update_tra_ice( ptab, i1, i2, j1, j2, k1, k2, before )
79      !!-----------------------------------------------------------------------
80      !!                        *** ROUTINE update_tra_ice ***
81      !! ** Method  : Compute the mass properties on the fine grid and recover
82      !!              the properties per mass on the coarse grid
83      !!-----------------------------------------------------------------------
84      INTEGER                               , INTENT(in   ) ::   i1, i2, j1, j2, k1, k2
85      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) ::   ptab
86      LOGICAL                               , INTENT(in   ) ::   before
87      !!
88      INTEGER  :: ji, jj, jk, jl, jm
89      !!-----------------------------------------------------------------------
90      ! it is ok not to multiply by e1*e2 since we conserve tracers here (same as in the ocean).
91      IF( before ) THEN
92         jm = 1
93         DO jl = 1, jpl
94            ptab(i1:i2,j1:j2,jm  ) = a_i (i1:i2,j1:j2,jl)
95            ptab(i1:i2,j1:j2,jm+1) = v_i (i1:i2,j1:j2,jl)
96            ptab(i1:i2,j1:j2,jm+2) = v_s (i1:i2,j1:j2,jl)
97            ptab(i1:i2,j1:j2,jm+3) = sv_i(i1:i2,j1:j2,jl)
98            ptab(i1:i2,j1:j2,jm+4) = oa_i (i1:i2,j1:j2,jl)
99            jm = jm + 5
100            DO jk = 1, nlay_s
101               ptab(i1:i2,j1:j2,jm) = e_s(i1:i2,j1:j2,jk,jl)   ;   jm = jm + 1
102            END DO
103            DO jk = 1, nlay_i
104               ptab(i1:i2,j1:j2,jm) = e_i(i1:i2,j1:j2,jk,jl)   ;   jm = jm + 1
105            END DO
106         END DO
107         !
108         DO jk = k1, k2
109            WHERE( tmask(i1:i2,j1:j2,1) == 0. )   ptab(i1:i2,j1:j2,jk) = Agrif_SpecialValueFineGrid 
110         END DO
111         !
112      ELSE
113         !
114         jm = 1
115         DO jl = 1, jpl
116            !
117            DO jj = j1, j2
118               DO ji = i1, i2
119                  IF( ptab(ji,jj,jm) /= Agrif_SpecialValueFineGrid ) THEN
120                     a_i (ji,jj,jl) = ptab(ji,jj,jm  ) * tmask(ji,jj,1)
121                     v_i (ji,jj,jl) = ptab(ji,jj,jm+1) * tmask(ji,jj,1)
122                     v_s (ji,jj,jl) = ptab(ji,jj,jm+2) * tmask(ji,jj,1)
123                     sv_i(ji,jj,jl) = ptab(ji,jj,jm+3) * tmask(ji,jj,1)
124                     oa_i(ji,jj,jl) = ptab(ji,jj,jm+4) * tmask(ji,jj,1)
125                  ENDIF
126               END DO
127            END DO
128            jm = jm + 5
129            !
130            DO jk = 1, nlay_s
131               WHERE( ptab(i1:i2,j1:j2,jm) /= Agrif_SpecialValueFineGrid )
132                  e_s(i1:i2,j1:j2,jk,jl) = ptab(i1:i2,j1:j2,jm) * tmask(i1:i2,j1:j2,1)
133               ENDWHERE
134               jm = jm + 1
135            END DO
136            !
137            DO jk = 1, nlay_i
138               WHERE( ptab(i1:i2,j1:j2,jm) /= Agrif_SpecialValueFineGrid )
139                  e_i(i1:i2,j1:j2,jk,jl) = ptab(i1:i2,j1:j2,jm) * tmask(i1:i2,j1:j2,1)
140               ENDWHERE
141               jm = jm + 1
142            END DO
143            !
144         END DO
145         !
146         ! integrated values
147         vt_i (i1:i2,j1:j2) = SUM(      v_i(i1:i2,j1:j2,:)           , dim=3 )
148         vt_s (i1:i2,j1:j2) = SUM(      v_s(i1:i2,j1:j2,:)           , dim=3 )
149         at_i (i1:i2,j1:j2) = SUM(      a_i(i1:i2,j1:j2,:)           , dim=3 )
150         et_s(i1:i2,j1:j2)  = SUM( SUM( e_s(i1:i2,j1:j2,:,:), dim=4 ), dim=3 )
151         et_i(i1:i2,j1:j2)  = SUM( SUM( e_i(i1:i2,j1:j2,:,:), dim=4 ), dim=3 )
152         
153      ENDIF
154      !
155   END SUBROUTINE update_tra_ice
156
157
158   SUBROUTINE update_u_ice( ptab, i1, i2, j1, j2, before )
159      !!-----------------------------------------------------------------------
160      !!                        *** ROUTINE update_u_ice ***
161      !! ** Method  : Update the fluxes and recover the properties (C-grid)
162      !!-----------------------------------------------------------------------
163      INTEGER                         , INTENT(in   ) ::   i1, i2, j1, j2
164      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) ::   ptab
165      LOGICAL                         , INTENT(in   ) ::   before
166      !!
167      REAL(wp) ::   zrhoy   ! local scalar
168      !!-----------------------------------------------------------------------
169      !
170      IF( before ) THEN
171         zrhoy = Agrif_Rhoy()
172         ptab(:,:) = e2u(i1:i2,j1:j2) * u_ice(i1:i2,j1:j2) * zrhoy
173         WHERE( umask(i1:i2,j1:j2,1) == 0._wp )   ptab(:,:) = Agrif_SpecialValueFineGrid
174      ELSE
175         WHERE( ptab(i1:i2,j1:j2) /= Agrif_SpecialValueFineGrid )
176            u_ice(i1:i2,j1:j2) = ptab(i1:i2,j1:j2) / e2u(i1:i2,j1:j2) * umask(i1:i2,j1:j2,1)
177         ENDWHERE
178      ENDIF
179      !
180   END SUBROUTINE update_u_ice
181
182
183   SUBROUTINE update_v_ice( ptab, i1, i2, j1, j2, before )
184      !!-----------------------------------------------------------------------
185      !!                    *** ROUTINE update_v_ice ***
186      !! ** Method  : Update the fluxes and recover the properties (C-grid)
187      !!-----------------------------------------------------------------------
188      INTEGER                         , INTENT(in   ) ::   i1, i2, j1, j2
189      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) ::   ptab
190      LOGICAL                         , INTENT(in   ) ::   before
191      !!
192      REAL(wp) ::   zrhox   ! local scalar
193      !!-----------------------------------------------------------------------
194      !
195      IF( before ) THEN
196         zrhox = Agrif_Rhox()
197         ptab(:,:) = e1v(i1:i2,j1:j2) * v_ice(i1:i2,j1:j2) * zrhox
198         WHERE( vmask(i1:i2,j1:j2,1) == 0._wp )   ptab(:,:) = Agrif_SpecialValueFineGrid
199      ELSE
200         WHERE( ptab(i1:i2,j1:j2) /= Agrif_SpecialValueFineGrid )
201            v_ice(i1:i2,j1:j2) = ptab(i1:i2,j1:j2) / e1v(i1:i2,j1:j2) * vmask(i1:i2,j1:j2,1)
202         ENDWHERE
203      ENDIF
204      !
205   END SUBROUTINE update_v_ice
206
207#else
208   !!----------------------------------------------------------------------
209   !!   Empty module                                             no sea-ice
210   !!----------------------------------------------------------------------
211CONTAINS
212   SUBROUTINE agrif_lim3_update_empty
213      WRITE(*,*)  'agrif_lim3_update : You should not have seen this print! error?'
214   END SUBROUTINE agrif_lim3_update_empty
215#endif
216
217   !!======================================================================
218END MODULE agrif_lim3_update
Note: See TracBrowser for help on using the repository browser.