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.
limhdf.F90 in branches/UKMO/2015_CO6_CO5_zenv_wr_direct_dwl_temp/NEMOGCM/NEMO/LIM_SRC_3 – NEMO

source: branches/UKMO/2015_CO6_CO5_zenv_wr_direct_dwl_temp/NEMOGCM/NEMO/LIM_SRC_3/limhdf.F90 @ 5418

Last change on this file since 5418 was 5418, checked in by deazer, 9 years ago

Removed SVN KEYWORDS ready for adding code changes before fcm merges

File size: 8.2 KB
Line 
1MODULE limhdf
2   !!======================================================================
3   !!                    ***  MODULE limhdf   ***
4   !! LIM ice model : horizontal diffusion of sea-ice quantities
5   !!======================================================================
6   !! History :  LIM  !  2000-01 (LIM) Original code
7   !!             -   !  2001-05 (G. Madec, R. Hordoir) opa norm
8   !!            1.0  !  2002-08 (C. Ethe)  F90, free form
9   !!----------------------------------------------------------------------
10#if defined key_lim3
11   !!----------------------------------------------------------------------
12   !!   'key_lim3'                                      LIM3 sea-ice model
13   !!----------------------------------------------------------------------
14   !!   lim_hdf       : diffusion trend on sea-ice variable
15   !!----------------------------------------------------------------------
16   USE dom_oce        ! ocean domain
17   USE ice            ! LIM-3: ice variables
18   USE lbclnk         ! lateral boundary condition - MPP exchanges
19   USE lib_mpp        ! MPP library
20   USE wrk_nemo       ! work arrays
21   USE prtctl         ! Print control
22   USE in_out_manager ! I/O manager
23   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
24
25   IMPLICIT NONE
26   PRIVATE
27
28   PUBLIC   lim_hdf     ! called by lim_trp
29
30   LOGICAL  ::   linit = .TRUE.                             ! initialization flag (set to flase after the 1st call)
31   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   efact   ! metric coefficient
32
33   !! * Substitution
34#  include "vectopt_loop_substitute.h90"
35   !!----------------------------------------------------------------------
36   !! NEMO/LIM3 4.0 , UCL - NEMO Consortium (2010)
37   !! $Id$
38   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
39   !!----------------------------------------------------------------------
40CONTAINS
41
42   SUBROUTINE lim_hdf( ptab )
43      !!-------------------------------------------------------------------
44      !!                  ***  ROUTINE lim_hdf  ***
45      !!
46      !! ** purpose :   Compute and add the diffusive trend on sea-ice variables
47      !!
48      !! ** method  :   Second order diffusive operator evaluated using a
49      !!              Cranck-Nicholson time Scheme.
50      !!
51      !! ** Action  :    update ptab with the diffusive contribution
52      !!-------------------------------------------------------------------
53      REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   ptab    ! Field on which the diffusion is applied
54      !
55      INTEGER                           ::  ji, jj                    ! dummy loop indices
56      INTEGER                           ::  iter, ierr           ! local integers
57      REAL(wp)                          ::  zrlxint, zconv     ! local scalars
58      REAL(wp), POINTER, DIMENSION(:,:) ::  zrlx, zflu, zflv, zdiv0, zdiv, ztab0
59      CHARACTER(lc)                     ::  charout                   ! local character
60      REAL(wp), PARAMETER               ::  zrelax = 0.5_wp           ! relaxation constant for iterative procedure
61      REAL(wp), PARAMETER               ::  zalfa  = 0.5_wp           ! =1.0/0.5/0.0 = implicit/Cranck-Nicholson/explicit
62      INTEGER , PARAMETER               ::  its    = 100              ! Maximum number of iteration
63      !!-------------------------------------------------------------------
64     
65      CALL wrk_alloc( jpi, jpj, zrlx, zflu, zflv, zdiv0, zdiv, ztab0 )
66
67      !                       !==  Initialisation  ==!
68      !
69      IF( linit ) THEN              ! Metric coefficient (compute at the first call and saved in efact)
70         ALLOCATE( efact(jpi,jpj) , STAT=ierr )
71         IF( lk_mpp    )   CALL mpp_sum( ierr )
72         IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'lim_hdf : unable to allocate arrays' )
73         DO jj = 2, jpjm1 
74            DO ji = fs_2 , fs_jpim1   ! vector opt.
75               efact(ji,jj) = ( e2u(ji,jj) + e2u(ji-1,jj) + e1v(ji,jj) + e1v(ji,jj-1) ) * r1_e12t(ji,jj)
76            END DO
77         END DO
78         linit = .FALSE.
79      ENDIF
80      !                             ! Time integration parameters
81      !
82      ztab0(:, : ) = ptab(:,:)      ! Arrays initialization
83      zdiv0(:, 1 ) = 0._wp
84      zdiv0(:,jpj) = 0._wp
85      zflu (jpi,:) = 0._wp   
86      zflv (jpi,:) = 0._wp
87      zdiv0(1,  :) = 0._wp
88      zdiv0(jpi,:) = 0._wp
89
90      zconv = 1._wp           !==  horizontal diffusion using a Crant-Nicholson scheme  ==!
91      iter  = 0
92      !
93      DO WHILE( zconv > ( 2._wp * 1.e-04 ) .AND. iter <= its )   ! Sub-time step loop
94         !
95         iter = iter + 1                                 ! incrementation of the sub-time step number
96         !
97         DO jj = 1, jpjm1                                ! diffusive fluxes in U- and V- direction
98            DO ji = 1 , fs_jpim1   ! vector opt.
99               zflu(ji,jj) = pahu(ji,jj) * e2u(ji,jj) * r1_e1u(ji,jj) * ( ptab(ji+1,jj) - ptab(ji,jj) )
100               zflv(ji,jj) = pahv(ji,jj) * e1v(ji,jj) * r1_e2v(ji,jj) * ( ptab(ji,jj+1) - ptab(ji,jj) )
101            END DO
102         END DO
103         !
104         DO jj= 2, jpjm1                                 ! diffusive trend : divergence of the fluxes
105            DO ji = fs_2 , fs_jpim1   ! vector opt.
106               zdiv(ji,jj) = ( zflu(ji,jj) - zflu(ji-1,jj) + zflv(ji,jj) - zflv(ji,jj-1) ) * r1_e12t(ji,jj)
107            END DO
108         END DO
109         !
110         IF( iter == 1 )   zdiv0(:,:) = zdiv(:,:)        ! save the 1st evaluation of the diffusive trend in zdiv0
111         !
112         DO jj = 2, jpjm1                                ! iterative evaluation
113            DO ji = fs_2 , fs_jpim1   ! vector opt.
114               zrlxint = (   ztab0(ji,jj)    &
115                  &       +  rdt_ice * (           zalfa   * ( zdiv(ji,jj) + efact(ji,jj) * ptab(ji,jj) )   &
116                  &                      + ( 1.0 - zalfa ) *   zdiv0(ji,jj) )                               & 
117                  &      ) / ( 1.0 + zalfa * rdt_ice * efact(ji,jj) )
118               zrlx(ji,jj) = ptab(ji,jj) + zrelax * ( zrlxint - ptab(ji,jj) )
119            END DO
120         END DO
121         CALL lbc_lnk( zrlx, 'T', 1. )                   ! lateral boundary condition
122         !
123         zconv = 0._wp                                   ! convergence test
124         DO jj = 2, jpjm1
125            DO ji = fs_2, fs_jpim1
126               zconv = MAX( zconv, ABS( zrlx(ji,jj) - ptab(ji,jj) )  )
127            END DO
128         END DO
129         IF( lk_mpp )   CALL mpp_max( zconv )            ! max over the global domain
130         !
131         ptab(:,:) = zrlx(:,:)
132         !
133      END DO                                       ! end of sub-time step loop
134
135      ! -----------------------
136      !!! final step (clem) !!!
137      DO jj = 1, jpjm1                                ! diffusive fluxes in U- and V- direction
138         DO ji = 1 , fs_jpim1   ! vector opt.
139            zflu(ji,jj) = pahu(ji,jj) * e2u(ji,jj) * r1_e1u(ji,jj) * ( ptab(ji+1,jj) - ptab(ji,jj) )
140            zflv(ji,jj) = pahv(ji,jj) * e1v(ji,jj) * r1_e2v(ji,jj) * ( ptab(ji,jj+1) - ptab(ji,jj) )
141         END DO
142      END DO
143      !
144      DO jj= 2, jpjm1                                 ! diffusive trend : divergence of the fluxes
145         DO ji = fs_2 , fs_jpim1   ! vector opt.
146            zdiv(ji,jj) = ( zflu(ji,jj) - zflu(ji-1,jj) + zflv(ji,jj) - zflv(ji,jj-1) ) * r1_e12t(ji,jj)
147            ptab(ji,jj) = ztab0(ji,jj) + 0.5 * ( zdiv(ji,jj) + zdiv0(ji,jj) )
148         END DO
149      END DO
150      CALL lbc_lnk( ptab, 'T', 1. )                   ! lateral boundary condition
151      !!! final step (clem) !!!
152      ! -----------------------
153
154      IF(ln_ctl)   THEN
155         zrlx(:,:) = ptab(:,:) - ztab0(:,:)
156         WRITE(charout,FMT="(' lim_hdf  : zconv =',D23.16, ' iter =',I4,2X)") zconv, iter
157         CALL prt_ctl( tab2d_1=zrlx, clinfo1=charout )
158      ENDIF
159      !
160      CALL wrk_dealloc( jpi, jpj, zrlx, zflu, zflv, zdiv0, zdiv, ztab0 )
161      !
162   END SUBROUTINE lim_hdf
163
164#else
165   !!----------------------------------------------------------------------
166   !!   Default option          Dummy module           NO LIM sea-ice model
167   !!----------------------------------------------------------------------
168CONTAINS
169   SUBROUTINE lim_hdf         ! Empty routine
170   END SUBROUTINE lim_hdf
171#endif
172
173   !!======================================================================
174END MODULE limhdf
Note: See TracBrowser for help on using the repository browser.