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 6607 for trunk/NEMOGCM/NEMO/TOP_SRC/trcdta.F90 – NEMO

Ignore:
Timestamp:
2016-05-23T17:18:38+02:00 (8 years ago)
Author:
cetlod
Message:

trunk:bugfix on passive tracers restoring ; the previous one was not properly done, see ticket 16677

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMOGCM/NEMO/TOP_SRC/trcdta.F90

    r6309 r6607  
    159159 
    160160 
    161    SUBROUTINE trc_dta( kt, sf_dta ) 
     161   SUBROUTINE trc_dta( kt, ptrc ) 
    162162      !!---------------------------------------------------------------------- 
    163163      !!                   ***  ROUTINE trc_dta  *** 
     
    169169      !!              - ln_trcdmp=F: deallocates the data structure as they are not used 
    170170      !! 
    171       !! ** Action  :   sf_dta   passive tracer data on medl mesh and interpolated at time-step kt 
    172       !!---------------------------------------------------------------------- 
    173       INTEGER                     , INTENT(in ) ::   kt     ! ocean time-step 
    174       TYPE(FLD), DIMENSION(1)   , INTENT(inout) ::   sf_dta     ! array of information on the field to read 
     171      !! ** Action  :   sf_trcdta   passive tracer data on medl mesh and interpolated at time-step kt 
     172      !!---------------------------------------------------------------------- 
     173      INTEGER                       , INTENT(in  ) ::   kt     ! ocean time-step 
     174      REAL(wp), DIMENSION(jpi,jpj,jpk,nb_trcdta), INTENT(inout) ::   ptrc     ! array of information on the field to read 
    175175      ! 
    176176      INTEGER ::   ji, jj, jk, jl, jkk, ik    ! dummy loop indices 
    177177      REAL(wp)::   zl, zi 
    178178      REAL(wp), DIMENSION(jpk) ::  ztp                ! 1D workspace 
    179       CHARACTER(len=100) :: clndta 
    180179      !!---------------------------------------------------------------------- 
    181180      ! 
     
    184183      IF( nb_trcdta > 0 ) THEN 
    185184         ! 
    186          CALL fld_read( kt, 1, sf_dta )      !==   read data at kt time step   ==! 
     185         CALL fld_read( kt, 1, sf_trcdta )      !==   read data at kt time step   ==! 
     186         ! 
     187         DO jl = 1, nb_trcdta 
     188            ptrc(:,:,:,jl) = sf_trcdta(jl)%fnow(:,:,:) * tmask(:,:,:)    ! Mask 
     189         ENDDO 
    187190         ! 
    188191         IF( ln_sco ) THEN                   !==   s- or mixed s-zps-coordinate   ==! 
     
    192195               WRITE(numout,*) 'trc_dta: interpolates passive tracer data onto the s- or mixed s-z-coordinate mesh' 
    193196            ENDIF 
    194             ! 
     197            DO jl = 1, nb_trcdta 
    195198               DO jj = 1, jpj                         ! vertical interpolation of T & S 
    196199                  DO ji = 1, jpi 
    197200                     DO jk = 1, jpk                        ! determines the intepolated T-S profiles at each (i,j) points 
    198                         zl = gdept_n(ji,jj,jk) 
     201                        zl = fsdept_n(ji,jj,jk) 
    199202                        IF(     zl < gdept_1d(1  ) ) THEN         ! above the first level of data 
    200                            ztp(jk) =  sf_dta(1)%fnow(ji,jj,1) 
     203                           ztp(jk) =  ptrc(ji,jj,1,jl) 
    201204                        ELSEIF( zl > gdept_1d(jpk) ) THEN         ! below the last level of data 
    202                            ztp(jk) =  sf_dta(1)%fnow(ji,jj,jpkm1) 
     205                           ztp(jk) =  ptrc(ji,jj,jpkm1,jl) 
    203206                        ELSE                                      ! inbetween : vertical interpolation between jkk & jkk+1 
    204207                           DO jkk = 1, jpkm1                                  ! when  gdept(jkk) < zl < gdept(jkk+1) 
    205208                              IF( (zl-gdept_1d(jkk)) * (zl-gdept_1d(jkk+1)) <= 0._wp ) THEN 
    206209                                 zi = ( zl - gdept_1d(jkk) ) / (gdept_1d(jkk+1)-gdept_1d(jkk)) 
    207                                  ztp(jk) = sf_dta(1)%fnow(ji,jj,jkk) + ( sf_dta(1)%fnow(ji,jj,jkk+1) - & 
    208                                            sf_dta(1)%fnow(ji,jj,jkk) ) * zi  
     210                                 ztp(jk) = ptrc(ji,jj,jkk,jl) + ( ptrc(ji,jj,jkk+1,jl) - ptrc(ji,jj,jkk,jl) ) * zi  
    209211                              ENDIF 
    210212                           END DO 
     
    212214                     END DO 
    213215                     DO jk = 1, jpkm1 
    214                         sf_dta(1)%fnow(ji,jj,jk) = ztp(jk) * tmask(ji,jj,jk)     ! mask required for mixed zps-s-coord 
     216                        ptrc(ji,jj,jk,jl) = ztp(jk) * tmask(ji,jj,jk)     ! mask required for mixed zps-s-coord 
    215217                     END DO 
    216                      sf_dta(1)%fnow(ji,jj,jpk) = 0._wp 
     218                     ptrc(ji,jj,jpk,jl) = 0._wp 
    217219                  END DO 
    218220               END DO 
     221            END DO 
    219222            !  
    220223         ELSE                                !==   z- or zps- coordinate   ==! 
    221224            !                              
    222                sf_dta(1)%fnow(:,:,:) = sf_dta(1)%fnow(:,:,:) * tmask(:,:,:)    ! Mask 
    223                ! 
    224                IF( ln_zps ) THEN                      ! zps-coordinate (partial steps) interpolation at the last ocean level 
     225            IF( ln_zps ) THEN                      ! zps-coordinate (partial steps) interpolation at the last ocean level 
     226               DO jl = 1, nb_trcdta 
     227                  ! 
    225228                  DO jj = 1, jpj 
    226229                     DO ji = 1, jpi 
    227230                        ik = mbkt(ji,jj)  
    228231                        IF( ik > 1 ) THEN 
    229                            zl = ( gdept_1d(ik) - gdept_n(ji,jj,ik) ) / ( gdept_1d(ik) - gdept_1d(ik-1) ) 
    230                            sf_dta(1)%fnow(ji,jj,ik) = (1.-zl) * sf_dta(1)%fnow(ji,jj,ik) + zl * sf_dta(1)%fnow(ji,jj,ik-1) 
     232                           zl = ( gdept_1d(ik) - fsdept_n(ji,jj,ik) ) / ( gdept_1d(ik) - gdept_1d(ik-1) ) 
     233                           ptrc(ji,jj,ik,jl) = (1.-zl) * ptrc(ji,jj,ik,jl) + zl * ptrc(ji,jj,ik-1,jl) 
    231234                        ENDIF 
    232235                     END DO 
    233236                  END DO 
    234                ENDIF 
     237              END DO 
     238            ENDIF 
    235239            ! 
    236240         ENDIF 
    237241         ! 
    238242      ENDIF 
     243      !  
     244      IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN      !== deallocate data structure   ==! 
     245        !                                                    (data used only for initialisation) 
     246        IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run' 
     247        DO jl = 1, nb_trcdta 
     248                                        DEALLOCATE( sf_trcdta(jl)%fnow)     !  arrays in the structure 
     249           IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta) 
     250        ENDDO 
     251      ENDIF 
    239252      ! 
    240253      IF( nn_timing == 1 )  CALL timing_stop('trc_dta') 
    241254      ! 
    242255   END SUBROUTINE trc_dta 
    243     
     256 
    244257#else 
    245258   !!---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.