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 4176 for branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/trcdta.F90 – NEMO

Ignore:
Timestamp:
2013-11-11T12:13:04+01:00 (11 years ago)
Author:
vichi
Message:

ticket #1173 step 4: Add in changes from the 2013/dev_r3996_CMCC6_topbc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2013/dev_CMCC_2013/NEMOGCM/NEMO/TOP_SRC/trcdta.F90

    r3882 r4176  
    88   !!              -   !  2005-03  (O. Aumont, A. El Moussaoui) F90 
    99   !!            3.4   !  2010-11  (C. Ethe, G. Madec)  use of fldread + dynamical allocation  
     10   !!            3.5   !  2013-08  (M. Vichi)  generalization for other BGC models 
    1011   !!---------------------------------------------------------------------- 
    1112#if  defined key_top  
     
    3031   INTEGER  , SAVE, PUBLIC                             :: nb_trcdta   ! number of tracers to be initialised with data 
    3132   INTEGER  , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: n_trc_index ! indice of tracer which is initialised with data 
    32    INTEGER  , SAVE                                     :: ntra        ! MAX( 1, nb_trcdta ) to avoid compilation error with bounds checking 
    33    REAL(wp) , SAVE,         ALLOCATABLE, DIMENSION(:)  :: rf_trfac    ! multiplicative factor for tracer values 
    34    TYPE(FLD), SAVE,         ALLOCATABLE, DIMENSION(:)  :: sf_trcdta   ! structure of input SST (file informations, fields read) 
     33   INTEGER  , SAVE, PUBLIC                             :: ntra        ! MAX( 1, nb_trcdta ) to avoid compilation error with bounds checking 
     34   REAL(wp) , SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: rf_trfac    ! multiplicative factor for tracer values 
     35   TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:)  :: sf_trcdta   ! structure of input SST (file informations, fields read) 
    3536 
    3637   !! * Substitutions 
     
    4344CONTAINS 
    4445 
    45    SUBROUTINE trc_dta_init 
     46   SUBROUTINE trc_dta_init(ntrc) 
    4647      !!---------------------------------------------------------------------- 
    4748      !!                   ***  ROUTINE trc_dta_init  *** 
     
    5354      !!---------------------------------------------------------------------- 
    5455      ! 
    55       INTEGER            :: jl, jn                   ! dummy loop indicies 
     56      INTEGER,INTENT(IN) :: ntrc                             ! number of tracers 
     57      INTEGER            :: jl, jn                           ! dummy loop indices 
    5658      INTEGER            :: ierr0, ierr1, ierr2, ierr3       ! temporary integers 
     59      INTEGER            ::  ios                     ! Local integer output status for namelist read 
    5760      CHARACTER(len=100) :: clndta, clntrc 
    5861      REAL(wp)           :: zfact 
    5962      ! 
    6063      CHARACTER(len=100) :: cn_dir 
    61       TYPE(FLD_N), DIMENSION(jptra) :: slf_i    ! array of namelist informations on the fields to read 
    62       TYPE(FLD_N), DIMENSION(jptra) :: sn_trcdta 
    63       REAL(wp)   , DIMENSION(jptra) :: rn_trfac    ! multiplicative factor for tracer values 
     64      TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_i ! array of namelist informations on the fields to read 
     65      TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trcdta 
     66      REAL(wp)   , DIMENSION(jpmaxtrc) :: rn_trfac    ! multiplicative factor for tracer values 
    6467      !! 
    6568      NAMELIST/namtrc_dta/ sn_trcdta, cn_dir, rn_trfac  
     
    7174      ierr0 = 0  ;  ierr1 = 0  ;  ierr2 = 0  ;  ierr3 = 0   
    7275      ! Compute the number of tracers to be initialised with data 
    73       ALLOCATE( n_trc_index(jptra), STAT=ierr0 ) 
     76      ALLOCATE( n_trc_index(ntrc), slf_i(ntrc), STAT=ierr0 ) 
    7477      IF( ierr0 > 0 ) THEN 
    7578         CALL ctl_stop( 'trc_nam: unable to allocate n_trc_index' )   ;   RETURN 
     
    7780      nb_trcdta      = 0 
    7881      n_trc_index(:) = 0 
    79       DO jn = 1, jptra 
     82      DO jn = 1, ntrc 
    8083         IF( ln_trc_ini(jn) ) THEN 
    8184             nb_trcdta       = nb_trcdta + 1  
     
    9396      ! 
    9497      cn_dir  = './'            ! directory in which the model is executed 
    95       DO jn = 1, jptra 
     98      DO jn = 1, ntrc 
    9699         WRITE( clndta,'("TR_",I1)' ) jn 
    97100         clndta = TRIM( clndta ) 
     
    103106      END DO 
    104107      ! 
     108!MAV temporary code for 3.5 
    105109      REWIND( numnat )               ! read nattrc 
    106110      READ  ( numnat, namtrc_dta ) 
     111!MAV future code for 3.6 
     112!      REWIND( numnat_ref )              ! Namelist namtrc_dta in reference namelist : Passive tracer data 
     113!      READ  ( numnat_ref, namtrc_dta, IOSTAT = ios, ERR = 901) 
     114!901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dta in reference namelist', lwp ) 
     115! 
     116!      REWIND( numnat_cfg )              ! Namelist namtrc_dta in configuration namelist : Passive tracer data 
     117!      READ  ( numnat_cfg, namtrc_dta, IOSTAT = ios, ERR = 902 ) 
     118!902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dta in configuration namelist', lwp ) 
     119!      WRITE ( numont, namtrc_dta ) 
    107120 
    108121      IF( lwp ) THEN 
    109          DO jn = 1, jptra 
     122         DO jn = 1, ntrc 
    110123            IF( ln_trc_ini(jn) )  THEN    ! open input file only if ln_trc_ini(jn) is true 
    111124               clndta = TRIM( sn_trcdta(jn)%clvar )  
     
    129142         ENDIF 
    130143         ! 
    131          DO jn = 1, jptra 
     144         DO jn = 1, ntrc 
    132145            IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file 
    133146               jl = n_trc_index(jn) 
     
    147160      ENDIF 
    148161      ! 
     162      DEALLOCATE( slf_i )          ! deallocate local field structure 
    149163      IF( nn_timing == 1 )  CALL timing_stop('trc_dta_init') 
    150164      ! 
     
    152166 
    153167 
    154    SUBROUTINE trc_dta( kt, ptrc ) 
     168   SUBROUTINE trc_dta( kt, sf_dta, zrf_trfac ) 
    155169      !!---------------------------------------------------------------------- 
    156170      !!                   ***  ROUTINE trc_dta  *** 
     
    162176      !!              - ln_trcdmp=F: deallocates the data structure as they are not used 
    163177      !! 
    164       !! ** Action  :   ptrc   passive tracer data on medl mesh and interpolated at time-step kt 
     178      !! ** Action  :   sf_dta   passive tracer data on medl mesh and interpolated at time-step kt 
    165179      !!---------------------------------------------------------------------- 
    166180      INTEGER                     , INTENT(in   ) ::   kt     ! ocean time-step 
    167       REAL(wp), DIMENSION(:,:,:,:), INTENT(  out) ::   ptrc   ! passive tracer data 
    168       ! 
    169       INTEGER ::   ji, jj, jk, jl, jn, jkk, ik    ! dummy loop indicies 
     181      TYPE(FLD), DIMENSION(1)   , INTENT(inout) ::   sf_dta     ! array of information on the field to read 
     182      REAL(wp)                  , INTENT(in   ) ::   zrf_trfac  ! multiplication factor 
     183      ! 
     184      INTEGER ::   ji, jj, jk, jl, jkk, ik    ! dummy loop indices 
    170185      REAL(wp)::   zl, zi 
    171186      REAL(wp), DIMENSION(jpk) ::  ztp                ! 1D workspace 
     
    177192      IF( nb_trcdta > 0 ) THEN 
    178193         ! 
    179          CALL fld_read( kt, 1, sf_trcdta )      !==   read data at kt time step   ==! 
    180          ! 
    181          DO jn = 1, ntra 
    182             ptrc(:,:,:,jn) = sf_trcdta(jn)%fnow(:,:,:)    ! NO mask 
    183          ENDDO 
     194         CALL fld_read( kt, 1, sf_dta )      !==   read data at kt time step   ==! 
    184195         ! 
    185196         IF( ln_sco ) THEN                   !==   s- or mixed s-zps-coordinate   ==! 
     
    190201            ENDIF 
    191202            ! 
    192             DO jn = 1, ntra 
    193203               DO jj = 1, jpj                         ! vertical interpolation of T & S 
    194204                  DO ji = 1, jpi 
     
    196206                        zl = fsdept_0(ji,jj,jk) 
    197207                        IF(     zl < gdept_0(1  ) ) THEN          ! above the first level of data 
    198                            ztp(jk) =  ptrc(ji,jj,1    ,jn) 
     208                           ztp(jk) =  sf_dta(1)%fnow(ji,jj,1) 
    199209                        ELSEIF( zl > gdept_0(jpk) ) THEN          ! below the last level of data 
    200                            ztp(jk) =  ptrc(ji,jj,jpkm1,jn) 
     210                           ztp(jk) =  sf_dta(1)%fnow(ji,jj,jpkm1) 
    201211                        ELSE                                      ! inbetween : vertical interpolation between jkk & jkk+1 
    202212                           DO jkk = 1, jpkm1                                  ! when  gdept(jkk) < zl < gdept(jkk+1) 
    203213                              IF( (zl-gdept_0(jkk)) * (zl-gdept_0(jkk+1)) <= 0._wp ) THEN 
    204214                                 zi = ( zl - gdept_0(jkk) ) / (gdept_0(jkk+1)-gdept_0(jkk)) 
    205                                  ztp(jk) = ptrc(ji,jj,jkk,jn) + ( ptrc(ji,jj,jkk+1,jn) - ptrc(ji,jj,jkk,jn) ) * zi  
     215                                 ztp(jk) = sf_dta(1)%fnow(ji,jj,jkk) + ( sf_dta(1)%fnow(ji,jj,jkk+1) - & 
     216                                           sf_dta(1)%fnow(ji,jj,jkk) ) * zi  
    206217                              ENDIF 
    207218                           END DO 
     
    209220                     END DO 
    210221                     DO jk = 1, jpkm1 
    211                         ptrc(ji,jj,jk,jn) = ztp(jk) * tmask(ji,jj,jk)     ! mask required for mixed zps-s-coord 
     222                        sf_dta(1)%fnow(ji,jj,jk) = ztp(jk) * tmask(ji,jj,jk)     ! mask required for mixed zps-s-coord 
    212223                     END DO 
    213                      ptrc(ji,jj,jpk,jn) = 0._wp 
     224                     sf_dta(1)%fnow(ji,jj,jpk) = 0._wp 
    214225                  END DO 
    215226               END DO 
    216             ENDDO  
    217227            !  
    218228         ELSE                                !==   z- or zps- coordinate   ==! 
    219229            !                              
    220             DO jn = 1, ntra 
    221                ptrc(:,:,:,jn) = ptrc(:,:,:,jn) * tmask(:,:,:)    ! Mask 
     230               sf_dta(1)%fnow(:,:,:) = sf_dta(1)%fnow(:,:,:) * tmask(:,:,:)    ! Mask 
    222231               ! 
    223232               IF( ln_zps ) THEN                      ! zps-coordinate (partial steps) interpolation at the last ocean level 
     
    227236                        IF( ik > 1 ) THEN 
    228237                           zl = ( gdept_0(ik) - fsdept_0(ji,jj,ik) ) / ( gdept_0(ik) - gdept_0(ik-1) ) 
    229                            ptrc(ji,jj,ik,jn) = (1.-zl) * ptrc(ji,jj,ik,jn) + zl * ptrc(ji,jj,ik-1,jn) 
     238                           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) 
    230239                        ENDIF 
    231240                     END DO 
    232241                  END DO 
    233242               ENDIF 
    234             ENDDO  
    235243            ! 
    236244         ENDIF 
    237245         ! 
    238          DO jn = 1, ntra 
    239             ptrc(:,:,:,jn) = ptrc(:,:,:,jn) * rf_trfac(jn)   !  multiplicative factor 
    240          ENDDO  
     246         sf_dta(1)%fnow(:,:,:) = sf_dta(1)%fnow(:,:,:) * zrf_trfac   !  multiplicative factor 
    241247         ! 
    242248         IF( lwp .AND. kt == nit000 ) THEN 
    243             DO jn = 1, ntra 
    244                clndta = TRIM( sf_trcdta(jn)%clvar )  
     249               clndta = TRIM( sf_dta(1)%clvar )  
    245250               WRITE(numout,*) ''//clndta//' data ' 
    246251               WRITE(numout,*) 
    247252               WRITE(numout,*)'  level = 1' 
    248                CALL prihre( ptrc(:,:,1    ,jn), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout ) 
     253               CALL prihre( sf_dta(1)%fnow(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout ) 
    249254               WRITE(numout,*)'  level = ', jpk/2 
    250                CALL prihre( ptrc(:,:,jpk/2,jn), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout ) 
     255               CALL prihre( sf_dta(1)%fnow(:,:,jpk/2), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout ) 
    251256               WRITE(numout,*)'  level = ', jpkm1 
    252                CALL prihre( ptrc(:,:,jpkm1,jn), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout ) 
     257               CALL prihre( sf_dta(1)%fnow(:,:,jpkm1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout ) 
    253258               WRITE(numout,*) 
    254             ENDDO 
    255          ENDIF 
    256           
    257          IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN      !==   deallocate data structure   ==!  
    258             !                                              (data used only for initialisation) 
    259             IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only use to initialize the run' 
    260             DO jn = 1, ntra 
    261                                              DEALLOCATE( sf_trcdta(jn)%fnow )     !  arrays in the structure 
    262                IF( sf_trcdta(jn)%ln_tint )   DEALLOCATE( sf_trcdta(jn)%fdta ) 
    263             ENDDO 
    264                                              DEALLOCATE( sf_trcdta          )     ! the structure itself 
    265             ! 
    266          ENDIF 
    267          ! 
    268       ENDIF 
    269       !  
     259         ENDIF 
     260      ENDIF 
     261      ! 
    270262      IF( nn_timing == 1 )  CALL timing_stop('trc_dta') 
    271263      ! 
     
    276268   !!---------------------------------------------------------------------- 
    277269CONTAINS 
    278    SUBROUTINE trc_dta( kt )        ! Empty routine 
     270   SUBROUTINE trc_dta( kt, sf_dta, zrf_trfac )        ! Empty routine 
    279271      WRITE(*,*) 'trc_dta: You should not have seen this print! error?', kt 
    280272   END SUBROUTINE trc_dta 
Note: See TracChangeset for help on using the changeset viewer.