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 2715 for trunk/NEMOGCM/NEMO/OPA_SRC/TRD/trdmod.F90 – NEMO

Ignore:
Timestamp:
2011-03-30T17:58:35+02:00 (13 years ago)
Author:
rblod
Message:

First attempt to put dynamic allocation on the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMOGCM/NEMO/OPA_SRC/TRD/trdmod.F90

    r2528 r2715  
    2424   USE trdmld                  ! ocean active mixed layer tracers trends  
    2525   USE in_out_manager          ! I/O manager 
     26   USE lib_mpp         ! MPP library 
    2627 
    2728   IMPLICIT NONE 
     
    3940   !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
    4041   !! $Id$ 
    41    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
     42   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
    4243   !!---------------------------------------------------------------------- 
    4344 
     
    5152      !!              integral constraints 
    5253      !!---------------------------------------------------------------------- 
    53       INTEGER, INTENT( in ) ::   kt                                ! time step 
    54       INTEGER, INTENT( in ) ::   ktrd                              ! tracer trend index 
    55       CHARACTER(len=3), INTENT( in ) ::   ctype                    ! momentum or tracers trends type 'DYN'/'TRA' 
    56       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   ptrdx ! Temperature or U trend  
    57       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::   ptrdy ! Salinity    or V trend 
     54      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released 
     55      USE wrk_nemo, ONLY: ztswu => wrk_2d_1,  & 
     56                          ztswv => wrk_2d_2,  & 
     57                          ztbfu => wrk_2d_3,  & 
     58                          ztbfv => wrk_2d_4,  & 
     59                          z2dx  => wrk_2d_5,  & 
     60                          z2dy  => wrk_2d_6 
     61      ! 
     62      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   ptrdx   ! Temperature or U trend  
     63      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   ptrdy   ! Salinity    or V trend 
     64      CHARACTER(len=3)          , INTENT(in   ) ::   ctype   ! momentum or tracers trends type 'DYN'/'TRA' 
     65      INTEGER                   , INTENT(in   ) ::   kt      ! time step 
     66      INTEGER                   , INTENT(in   ) ::   ktrd    ! tracer trend index 
    5867      !! 
    59       INTEGER ::   ji, jj 
    60       REAL(wp), DIMENSION(jpi,jpj) ::   ztswu, ztswv               ! 2D workspace 
    61       REAL(wp), DIMENSION(jpi,jpj) ::   ztbfu, ztbfv               ! 2D workspace 
    62       REAL(wp), DIMENSION(jpi,jpj) ::   z2dx, z2dy                 ! workspace arrays 
    63       !!---------------------------------------------------------------------- 
    64  
    65       z2dx(:,:)   = 0.e0   ;   z2dy(:,:)   = 0.e0                  ! initialization of workspace arrays 
    66  
    67       IF( neuler == 0 .AND. kt == nit000    ) THEN   ;   r2dt =      rdt      ! = rdtra (restarting with Euler time stepping) 
    68       ELSEIF(               kt <= nit000 + 1) THEN   ;   r2dt = 2. * rdt      ! = 2 rdttra (leapfrog) 
     68      INTEGER ::   ji, jj   ! dummy loop indices 
     69      !!---------------------------------------------------------------------- 
     70 
     71      IF(wrk_in_use(2, 1,2,3,4,5,6))THEN 
     72         CALL ctl_warn('trd_mod: Requested workspace arrays already in use.')   ;   RETURN 
     73      END IF 
     74 
     75      z2dx(:,:) = 0._wp   ;   z2dy(:,:) = 0._wp                            ! initialization of workspace arrays 
     76 
     77      IF( neuler == 0 .AND. kt == nit000    ) THEN   ;   r2dt =      rdt   ! = rdtra (restart with Euler time stepping) 
     78      ELSEIF(               kt <= nit000 + 1) THEN   ;   r2dt = 2. * rdt   ! = 2 rdttra (leapfrog) 
    6979      ENDIF 
    7080 
     
    8494            CASE ( jptra_trd_dmp )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_dmp, ctype )   ! damping 
    8595            CASE ( jptra_trd_qsr )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_qsr, ctype )   ! penetrative solar radiat. 
    86             CASE ( jptra_trd_nsr )    
    87                z2dx(:,:) = ptrdx(:,:,1)   ;   z2dy(:,:) = ptrdy(:,:,1) 
    88                CALL trd_icp( z2dx, z2dy, jpicpt_nsr, ctype )                               ! non solar radiation 
     96            CASE ( jptra_trd_nsr )   ;   z2dx(:,:) = ptrdx(:,:,1)    
     97                                         z2dy(:,:) = ptrdy(:,:,1) 
     98                                         CALL trd_icp( z2dx , z2dy , jpicpt_nsr, ctype )   ! non solar radiation 
    8999            CASE ( jptra_trd_xad )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_xad, ctype )   ! x- horiz adv 
    90100            CASE ( jptra_trd_yad )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_yad, ctype )   ! y- horiz adv 
    91             CASE ( jptra_trd_zad )                                                         ! z- vertical adv  
    92                CALL trd_icp( ptrdx, ptrdy, jpicpt_zad, ctype )    
    93                ! compute the surface flux condition wn(:,:,1)*tn(:,:,1) 
    94                z2dx(:,:) = wn(:,:,1)*tn(:,:,1)/fse3t(:,:,1) 
    95                z2dy(:,:) = wn(:,:,1)*sn(:,:,1)/fse3t(:,:,1) 
    96                CALL trd_icp( z2dx , z2dy , jpicpt_zl1, ctype )                             ! 1st z- vertical adv  
     101            CASE ( jptra_trd_zad )   ;   CALL trd_icp( ptrdx, ptrdy, jpicpt_zad, ctype )   ! z- vertical adv  
     102                                         CALL trd_icp( ptrdx, ptrdy, jpicpt_zad, ctype )    
     103                                         ! compute the surface flux condition wn(:,:,1)*tn(:,:,1) 
     104                                         z2dx(:,:) = wn(:,:,1)*tn(:,:,1)/fse3t(:,:,1) 
     105                                         z2dy(:,:) = wn(:,:,1)*sn(:,:,1)/fse3t(:,:,1) 
     106                                         CALL trd_icp( z2dx , z2dy , jpicpt_zl1, ctype )   ! 1st z- vertical adv  
    97107            END SELECT 
    98108         END IF 
     
    113123               ! subtract surface forcing/bottom friction trends  
    114124               ! from vertical diffusive momentum trends 
    115                ztswu(:,:) = 0.e0   ;   ztswv(:,:) = 0.e0 
    116                ztbfu(:,:) = 0.e0   ;   ztbfv(:,:) = 0.e0  
     125               ztswu(:,:) = 0._wp   ;   ztswv(:,:) = 0._wp 
     126               ztbfu(:,:) = 0._wp   ;   ztbfv(:,:) = 0._wp  
    117127               DO jj = 2, jpjm1    
    118128                  DO ji = fs_2, fs_jpim1   ! vector opt. 
     
    121131                     ztswv(ji,jj) = vtau(ji,jj) / ( fse3v(ji,jj,1)*rau0 ) 
    122132                     ! bottom friction contribution now handled explicitly 
    123                      ! 
    124                      ptrdx(ji,jj,1     ) = ptrdx(ji,jj,1     ) - ztswu(ji,jj) 
    125                      ptrdy(ji,jj,1     ) = ptrdy(ji,jj,1     ) - ztswv(ji,jj) 
     133                     ptrdx(ji,jj,1) = ptrdx(ji,jj,1) - ztswu(ji,jj) 
     134                     ptrdy(ji,jj,1) = ptrdy(ji,jj,1) - ztswv(ji,jj) 
    126135                  END DO 
    127136               END DO 
     
    218227      ENDIF 
    219228      ! 
     229      IF( wrk_not_released(2, 1,2,3,4,5,6) )   CALL ctl_warn('trd_mod: Failed to release workspace arrays.') 
     230      ! 
    220231   END SUBROUTINE trd_mod 
    221232 
     
    228239   USE trdicp          ! ocean bassin integral constraints properties 
    229240   USE trdmld          ! ocean active mixed layer tracers trends  
    230  
     241   !!---------------------------------------------------------------------- 
    231242CONTAINS 
    232243   SUBROUTINE trd_mod(ptrd3dx, ptrd3dy, ktrd , ctype, kt )   ! Empty routine 
    233       REAL    ::   ptrd3dx(:,:,:), ptrd3dy(:,:,:) 
    234       INTEGER ::   ktrd, kt                             
     244      REAL(wp) ::   ptrd3dx(:,:,:), ptrd3dy(:,:,:) 
     245      INTEGER  ::   ktrd, kt                             
    235246      CHARACTER(len=3) ::  ctype                   
    236247      WRITE(*,*) 'trd_3d: You should not have seen this print! error ?', ptrd3dx(1,1,1), ptrd3dy(1,1,1) 
Note: See TracChangeset for help on using the changeset viewer.