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.
Changeset 2600 for branches – NEMO

Changeset 2600 for branches


Ignore:
Timestamp:
2011-02-20T16:29:08+01:00 (13 years ago)
Author:
gm
Message:

dynamic mem: #785 ; LIM-2 case: DOCTOR norm zfact changed in efact + style

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limhdf_2.F90

    r2590 r2600  
    44   !! LIM 2.0 ice model : horizontal diffusion of sea-ice quantities 
    55   !!====================================================================== 
     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   !!---------------------------------------------------------------------- 
    610#if defined key_lim2 
    711   !!---------------------------------------------------------------------- 
     
    1014   !!   lim_hdf_2  : diffusion trend on sea-ice variable 
    1115   !!---------------------------------------------------------------------- 
    12    !! * Modules used 
    13    USE dom_oce 
    14    USE in_out_manager 
    15    USE ice_2 
    16    USE lbclnk 
    17    USE lib_mpp 
    18    USE prtctl          ! Print control 
     16   USE dom_oce          ! ocean domain 
     17   USE ice_2            ! LIM-2: ice variables 
     18   USE lbclnk           ! lateral boundary condition - MPP exchanges 
     19   USE lib_mpp          ! MPP library 
     20   USE prtctl           ! Print control 
     21   USE in_out_manager   ! I/O manager 
    1922 
    2023   IMPLICIT NONE 
    2124   PRIVATE 
    2225 
    23    !! * Routine accessibility 
    24    PUBLIC lim_hdf_2    ! called by    lim_tra_2 
    25    PUBLIC lim_hdf_alloc_2 ! called by nemogcm 
     26   PUBLIC   lim_hdf_2         ! called by limtrp_2.F90 
     27   PUBLIC   lim_hdf_alloc_2   ! called by nemogcm.F90 
    2628 
    27    !! * Module variables 
    28    LOGICAL  ::   linit = .TRUE.              ! ??? 
    29    REAL(wp) ::   epsi04 = 1e-04              ! constant 
    30    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zfact   ! ??? 
     29   LOGICAL  ::   linit = .TRUE.   ! ! initialization flag (set to flase after the 1st call) 
     30   REAL(wp) ::   epsi04 = 1e-04   ! constant 
     31    
     32   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   efact   ! ??? 
    3133 
    3234   !! * Substitution  
    3335#  include "vectopt_loop_substitute.h90" 
    3436   !!---------------------------------------------------------------------- 
    35    !! NEMO/LIM2 3.3 , UCL - NEMO Consortium (2010) 
     37   !! NEMO/LIM2 4.0 , UCL - NEMO Consortium (2010) 
    3638   !! $Id$ 
    37    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
     39   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
    3840   !!---------------------------------------------------------------------- 
    39  
    4041CONTAINS 
    4142 
     
    4445      !!                  ***  ROUTINE lim_hdf_alloc_2  *** 
    4546      !!------------------------------------------------------------------- 
    46       IMPLICIT none 
    4747      INTEGER :: lim_hdf_alloc_2 
    4848      !!------------------------------------------------------------------- 
    49  
    50       ALLOCATE(zfact(jpi,jpj), Stat=lim_hdf_alloc_2) 
    51  
    52       IF(lim_hdf_alloc_2 /= 0)THEN 
    53          CALL ctl_warn('lim_hdf_alloc_2: failed to allocate zfact array.') 
    54       END IF 
    55  
     49      ! 
     50      ALLOCATE( efact(jpi,jpj) , STAT=lim_hdf_alloc_2 ) 
     51      ! 
     52      IF( lim_hdf_alloc_2 /= 0 ) THEN 
     53         CALL ctl_warn( 'lim_hdf_alloc_2: failed to allocate efact array.' ) 
     54      ENDIF 
     55      ! 
    5656   END FUNCTION lim_hdf_alloc_2 
    5757 
     
    6161      !!                  ***  ROUTINE lim_hdf_2  *** 
    6262      !! 
    63       !! ** purpose :   Compute and add the diffusive trend on sea-ice 
    64       !!      variables 
     63      !! ** purpose :   Compute and add the diffusive trend on sea-ice variables 
    6564      !! 
    6665      !! ** method  :   Second order diffusive operator evaluated using a 
    67       !!      Cranck-Nicholson time Scheme. 
     66      !!              Cranck-Nicholson time Scheme. 
    6867      !! 
    6968      !! ** Action  :    update ptab with the diffusive contribution 
    70       !! 
    71       !! History : 
    72       !!        !  00-01 (LIM) Original code 
    73       !!        !  01-05 (G. Madec, R. Hordoir) opa norm 
    74       !!        !  02-08 (C. Ethe)  F90, free form 
    7569      !!------------------------------------------------------------------- 
    7670      USE wrk_nemo, ONLY: wrk_use, wrk_release 
    77       USE wrk_nemo, ONLY: zrlx  => wrk_2d_11, zflu  => wrk_2d_12 
    78       USE wrk_nemo, ONLY: zflv  => wrk_2d_13, ptab0 => wrk_2d_14 
    79       USE wrk_nemo, ONLY: zdiv0 => wrk_2d_15, zdiv  => wrk_2d_16 
    80       !! 
    81       ! * Arguments 
    82       REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   & 
    83          ptab                 ! Field on which the diffusion is applied   
    84  
    85       ! * Local variables 
    86       INTEGER ::  ji, jj      ! dummy loop indices 
    87       INTEGER ::  & 
    88          its, iter            ! temporary integers 
     71      USE wrk_nemo, ONLY:   zflu => wrk_2d_11, zdiv  => wrk_2d_13, zrlx  => wrk_2d_15  
     72      USE wrk_nemo, ONLY:   zflv => wrk_2d_12, zdiv0 => wrk_2d_14, ztab0 => wrk_2d_16 
     73      ! 
     74      REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   ptab   ! Field on which the diffusion is applied   
     75      ! 
     76      INTEGER  ::  ji, jj      ! dummy loop indices 
     77      INTEGER  ::  its, iter   ! local integers 
     78      REAL(wp) ::   zalfa, zrlxint, zconv, zeps   ! local scalars 
    8979      CHARACTER (len=55) :: charout 
    90       REAL(wp) ::  & 
    91          zalfa, zrlxint, zconv, zeps   ! temporary scalars 
    9280      !!------------------------------------------------------------------- 
    9381 
    94       IF(.NOT. wrk_use(2, 11,12,13,14,15,16))THEN 
    95          CALL ctl_stop('lim_hdf_2 : requested workspace arrays unavailable.') 
    96          RETURN 
     82      IF( .NOT. wrk_use(2, 11,12,13,14,15,16) ) THEN 
     83         CALL ctl_stop( 'lim_hdf_2 : requested workspace arrays unavailable.' )   ;   RETURN 
    9784      END IF 
    9885 
    99       ! Initialisation 
    100       ! ---------------    
    101       ! Time integration parameters 
    102       zalfa = 0.5       ! =1.0/0.5/0.0 = implicit/Cranck-Nicholson/explicit 
    103       its   = 100       ! Maximum number of iteration 
    104       zeps  =  2. * epsi04 
    105  
    106       ! Arrays initialization 
    107       ptab0 (:, : ) = ptab(:,:) 
    108 !bug  zflu (:,jpj) = 0.e0 
    109 !bug  zflv (:,jpj) = 0.e0 
    110       zdiv0(:, 1 ) = 0.e0 
    111       zdiv0(:,jpj) = 0.e0 
    112       IF( .NOT.lk_vopt_loop ) THEN 
    113          zflu (jpi,:) = 0.e0    
    114          zflv (jpi,:) = 0.e0 
    115          zdiv0(1,  :) = 0.e0 
    116          zdiv0(jpi,:) = 0.e0 
    117       ENDIF 
    118  
    119       ! Metric coefficient (compute at the first call and saved in 
    120       IF( linit ) THEN 
     86      !                       !==  Initialisation  ==! 
     87      ! 
     88      IF( linit ) THEN              ! Metric coefficient (compute at the first call and saved in efact) 
    12189         DO jj = 2, jpjm1   
    12290            DO ji = fs_2 , fs_jpim1   ! vector opt. 
    123                zfact(ji,jj) = ( e2u(ji,jj) + e2u(ji-1,jj  ) + e1v(ji,jj) + e1v(ji,jj-1) ) & 
     91               efact(ji,jj) = ( e2u(ji,jj) + e2u(ji-1,jj  ) + e1v(ji,jj) + e1v(ji,jj-1) ) & 
    12492                  &          / ( e1t(ji,jj) * e2t(ji,jj) ) 
    12593            END DO 
     
    12795         linit = .FALSE. 
    12896      ENDIF 
     97      ! 
     98      !                             ! Time integration parameters 
     99      zalfa = 0.5_wp                      ! =1.0/0.5/0.0 = implicit/Cranck-Nicholson/explicit 
     100      its   = 100                         ! Maximum number of iteration 
     101      zeps  =  2._wp * epsi04 
     102      ! 
     103      ztab0(:, : ) = ptab(:,:)      ! Arrays initialization 
     104      zdiv0(:, 1 ) = 0._wp 
     105      zdiv0(:,jpj) = 0._wp 
     106      IF( .NOT.lk_vopt_loop ) THEN 
     107         zflu (jpi,:) = 0._wp    
     108         zflv (jpi,:) = 0._wp 
     109         zdiv0(1,  :) = 0._wp 
     110         zdiv0(jpi,:) = 0._wp 
     111      ENDIF 
    129112 
    130  
    131       ! Sub-time step loop 
    132       zconv = 1.e0 
     113      zconv = 1._wp           !==  horizontal diffusion using a Crant-Nicholson scheme  ==! 
    133114      iter  = 0 
    134  
    135       !                                                   !=================== 
    136       DO WHILE ( ( zconv > zeps ) .AND. (iter <= its) )   ! Sub-time step loop 
    137          !                                                !=================== 
    138          ! incrementation of the sub-time step number 
    139          iter = iter + 1 
    140  
    141          ! diffusive fluxes in U- and V- direction 
    142          DO jj = 1, jpjm1 
     115      ! 
     116      DO WHILE (  zconv > zeps  .AND.  iter <= its  )    ! Sub-time step loop 
     117         ! 
     118         iter = iter + 1                                       ! incrementation of the sub-time step number 
     119         ! 
     120         DO jj = 1, jpjm1                                      ! diffusive fluxes in U- and V- direction 
    143121            DO ji = 1 , fs_jpim1   ! vector opt. 
    144122               zflu(ji,jj) = pahu(ji,jj) * e2u(ji,jj) / e1u(ji,jj) * ( ptab(ji+1,jj) - ptab(ji,jj) ) 
     
    146124            END DO 
    147125         END DO 
    148  
    149          ! diffusive trend : divergence of the fluxes 
    150          DO jj= 2, jpjm1 
     126         ! 
     127         DO jj= 2, jpjm1                                       ! diffusive trend : divergence of the fluxes 
    151128            DO ji = fs_2 , fs_jpim1   ! vector opt.  
    152129               zdiv (ji,jj) = (  zflu(ji,jj) - zflu(ji-1,jj  )   & 
     
    154131            END DO 
    155132         END DO 
    156  
    157          ! save the first evaluation of the diffusive trend in zdiv0 
    158          IF( iter == 1 )   zdiv0(:,:) = zdiv(:,:)        
    159  
    160          ! XXXX iterative evaluation????? 
    161          DO jj = 2, jpjm1 
     133         ! 
     134         IF( iter == 1 )   zdiv0(:,:) = zdiv(:,:)              ! save the 1st evaluation of the diffusive trend in zdiv0 
     135         ! 
     136         DO jj = 2, jpjm1                                      ! iterative evaluation 
    162137            DO ji = fs_2 , fs_jpim1   ! vector opt. 
    163                zrlxint = (   ptab0(ji,jj)    & 
    164                   &       +  rdt_ice * (           zalfa   * ( zdiv(ji,jj) + zfact(ji,jj) * ptab(ji,jj) )   & 
     138               zrlxint = (   ztab0(ji,jj)    & 
     139                  &       +  rdt_ice * (           zalfa   * ( zdiv(ji,jj) + efact(ji,jj) * ptab(ji,jj) )   & 
    165140                  &                      + ( 1.0 - zalfa ) *   zdiv0(ji,jj) )  )                             &  
    166                   &    / ( 1.0 + zalfa * rdt_ice * zfact(ji,jj) ) 
     141                  &    / ( 1.0 + zalfa * rdt_ice * efact(ji,jj) ) 
    167142               zrlx(ji,jj) = ptab(ji,jj) + om * ( zrlxint - ptab(ji,jj) ) 
    168143            END DO 
    169144         END DO 
     145         CALL lbc_lnk( zrlx, 'T', 1. )                         ! lateral boundary condition 
    170146 
    171          ! lateral boundary condition on ptab 
    172          CALL lbc_lnk( zrlx, 'T', 1. ) 
     147         zconv = 0._wp                                         ! convergence test 
    173148 
    174          ! convergence test 
    175          zconv = 0.e0 
    176149         DO jj = 2, jpjm1 
    177150            DO ji = 2, jpim1 
     
    179152            END DO 
    180153         END DO 
    181          IF( lk_mpp )   CALL mpp_max( zconv )   ! max over the global domain 
     154         IF( lk_mpp )   CALL mpp_max( zconv )                  ! max over the global domain 
    182155 
    183156         ptab(:,:) = zrlx(:,:) 
    184  
    185          !                                         !========================== 
    186       END DO                                       ! end of sub-time step loop 
    187       !                                            !========================== 
     157         ! 
     158      END DO                                             ! end of sub-time step loop 
    188159 
    189160      IF(ln_ctl)   THEN 
    190          zrlx(:,:) = ptab(:,:) - ptab0(:,:) 
     161         zrlx(:,:) = ptab(:,:) - ztab0(:,:) 
    191162         WRITE(charout,FMT="(' lim_hdf  : zconv =',D23.16, ' iter =',I4,2X)") zconv, iter 
    192          CALL prt_ctl(tab2d_1=zrlx, clinfo1=charout) 
     163         CALL prt_ctl( tab2d_1=zrlx, clinfo1=charout ) 
    193164      ENDIF 
    194  
    195       IF(.NOT. wrk_release(2, 11,12,13,14,15,16))THEN 
    196          CALL ctl_stop('lim_hdf_2 : failed to release workspace arrays.') 
    197          RETURN 
     165      ! 
     166      IF( .NOT. wrk_release(2, 11,12,13,14,15,16) ) THEN 
     167         CALL ctl_stop( 'lim_hdf_2 : failed to release workspace arrays.' )   ;   RETURN 
    198168      END IF 
    199  
     169      ! 
    200170   END SUBROUTINE lim_hdf_2 
    201171 
Note: See TracChangeset for help on using the changeset viewer.