Index: trunk/NEMOGCM/NEMO/TOP_SRC/trcnam.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/trcnam.F90	(revision 6140)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/trcnam.F90	(revision 7646)
@@ -20,8 +20,4 @@
    USE oce_trc           ! shared variables between ocean and passive tracers
    USE trc               ! passive tracers common variables
-   USE trcnam_pisces     ! PISCES namelist
-   USE trcnam_cfc        ! CFC SMS namelist
-   USE trcnam_c14b       ! C14 SMS namelist
-   USE trcnam_my_trc     ! MY_TRC SMS namelist
    USE trd_oce       
    USE trdtrc_oce
@@ -34,4 +30,6 @@
    PUBLIC trc_nam      ! called in trcini
 
+   TYPE(PTRACER), DIMENSION(jpmaxtrc), PUBLIC  :: sn_tracer  ! type of tracer for saving if not key_iomput
+
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -52,30 +50,13 @@
       !!---------------------------------------------------------------------
       INTEGER  ::   jn                  ! dummy loop indice
-      !                                  
-      IF( .NOT.lk_offline )   CALL trc_nam_run     ! Parameters of the run 
+      !
+      IF( .NOT.l_offline )   CALL trc_nam_run     ! Parameters of the run                                  
       !               
-                              CALL trc_nam_trc     ! passive tracer informations
+      CALL trc_nam_trc     ! passive tracer informations
       !                                        
-                              CALL trc_nam_dia     ! Parameters of additional diagnostics
-      !                                      
-      !
       IF( ln_rsttr                     )   ln_trcdta     = .FALSE.   ! restart : no need of clim data
       !
       IF( ln_trcdmp .OR. ln_trcdmp_clo )   ln_trcdta     = .TRUE.   ! damping : need to have clim data
       !
-      IF( .NOT.ln_trcdta               )   ln_trc_ini(:) = .FALSE.
-
-      IF(lwp) THEN                   ! control print
-         WRITE(numout,*)
-         WRITE(numout,*) ' Namelist : namtrc'
-         WRITE(numout,*) '   Read inputs data from file (y/n)             ln_trcdta     = ', ln_trcdta
-         WRITE(numout,*) '   Damping of passive tracer (y/n)              ln_trcdmp     = ', ln_trcdmp
-         WRITE(numout,*) '   Restoring of tracer on closed seas           ln_trcdmp_clo = ', ln_trcdmp_clo
-         WRITE(numout,*) ' '
-         DO jn = 1, jptra
-            WRITE(numout,*) '  tracer nb : ', jn, '    short name : ', ctrcnm(jn)
-         END DO
-         WRITE(numout,*) ' '
-      ENDIF
 
       IF(lwp) THEN                   ! control print
@@ -96,64 +77,14 @@
          ENDIF
       ENDIF
-
-      
-      rdttrc = rdt * FLOAT( nn_dttrc )   ! passive tracer time-step
-  
-      IF(lwp) THEN                   ! control print
+      !
+      rdttrc = rdt * FLOAT( nn_dttrc )          ! passive tracer time-step
+      ! 
+      IF(lwp) THEN                              ! control print
         WRITE(numout,*) 
         WRITE(numout,*) '    Passive Tracer  time step    rdttrc  = ', rdttrc
         WRITE(numout,*) 
       ENDIF
-
-
-#if defined key_trdmxl_trc || defined key_trdtrc
-
-         REWIND( numnat_ref )              ! Namelist namtrc_trd in reference namelist : Passive tracer trends
-         READ  ( numnat_ref, namtrc_trd, IOSTAT = ios, ERR = 905)
-905      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_trd in reference namelist', lwp )
-
-         REWIND( numnat_cfg )              ! Namelist namtrc_trd in configuration namelist : Passive tracer trends
-         READ  ( numnat_cfg, namtrc_trd, IOSTAT = ios, ERR = 906 )
-906      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_trd in configuration namelist', lwp )
-         IF(lwm) WRITE ( numont, namtrc_trd )
-
-         IF(lwp) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) ' trd_mxl_trc_init : read namelist namtrc_trd                    '
-            WRITE(numout,*) ' ~~~~~~~~~~~~~~~~                                               '
-            WRITE(numout,*) '   * frequency of trends diagnostics   nn_trd_trc             = ', nn_trd_trc
-            WRITE(numout,*) '   * control surface type              nn_ctls_trc            = ', nn_ctls_trc
-            WRITE(numout,*) '   * restart for ML diagnostics        ln_trdmxl_trc_restart  = ', ln_trdmxl_trc_restart
-            WRITE(numout,*) '   * flag to diagnose trends of                                 '
-            WRITE(numout,*) '     instantantaneous or mean ML T/S   ln_trdmxl_trc_instant  = ', ln_trdmxl_trc_instant
-            WRITE(numout,*) '   * unit conversion factor            rn_ucf_trc             = ', rn_ucf_trc
-            DO jn = 1, jptra
-               IF( ln_trdtrc(jn) ) WRITE(numout,*) '    compute ML trends for tracer number :', jn
-            END DO
-         ENDIF
-#endif
-
-
-      ! Call the ice module for tracers
-      ! -------------------------------
-                                  CALL trc_nam_ice
-
-      ! namelist of SMS
-      ! ---------------      
-      IF( lk_pisces  ) THEN   ;   CALL trc_nam_pisces      ! PISCES  bio-model
-      ELSE                    ;   IF(lwp) WRITE(numout,*) '          PISCES not used'
-      ENDIF
-
-      IF( lk_cfc     ) THEN   ;   CALL trc_nam_cfc         ! CFC     tracers
-      ELSE                    ;   IF(lwp) WRITE(numout,*) '          CFC not used'
-      ENDIF
-
-      IF( lk_c14b     ) THEN   ;   CALL trc_nam_c14b         ! C14 bomb     tracers
-      ELSE                    ;   IF(lwp) WRITE(numout,*) '          C14 not used'
-      ENDIF
-
-      IF( lk_my_trc  ) THEN   ;   CALL trc_nam_my_trc      ! MY_TRC  tracers
-      ELSE                    ;   IF(lwp) WRITE(numout,*) '          MY_TRC not used'
-      ENDIF
+      !
+      IF( l_trdtrc )        CALL trc_nam_trd    ! Passive tracer trends
       !
    END SUBROUTINE trc_nam
@@ -167,5 +98,5 @@
       !!
       !!---------------------------------------------------------------------
-      NAMELIST/namtrc_run/ nn_dttrc, nn_writetrc, ln_rsttr, nn_rsttr, ln_top_euler, &
+      NAMELIST/namtrc_run/ nn_dttrc, ln_rsttr, nn_rsttr, ln_top_euler, &
         &                  cn_trcrst_indir, cn_trcrst_outdir, cn_trcrst_in, cn_trcrst_out
       !
@@ -199,5 +130,4 @@
          WRITE(numout,*) '   control of time step for passive tracer      nn_rsttr      = ', nn_rsttr
          WRITE(numout,*) '   first time step for pass. trac.              nittrc000     = ', nittrc000
-         WRITE(numout,*) '   frequency of outputs for passive tracers     nn_writetrc   = ', nn_writetrc 
          WRITE(numout,*) '   Use euler integration for TRC (y/n)          ln_top_euler  = ', ln_top_euler
          WRITE(numout,*) ' '
@@ -206,57 +136,4 @@
     END SUBROUTINE trc_nam_run
 
-
-   SUBROUTINE trc_nam_ice
-      !!---------------------------------------------------------------------
-      !!                     ***  ROUTINE trc_nam_ice ***
-      !!
-      !! ** Purpose :   Read the namelist for the ice effect on tracers
-      !!
-      !! ** Method  : -
-      !!
-      !!---------------------------------------------------------------------
-      INTEGER :: jn      ! dummy loop indices
-      INTEGER :: ios     ! Local integer output status for namelist read
-      !
-      TYPE(TRC_I_NML), DIMENSION(jptra) :: sn_tri_tracer
-      !!
-      NAMELIST/namtrc_ice/ nn_ice_tr, sn_tri_tracer
-      !!---------------------------------------------------------------------
-      !
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'trc_nam_ice : Read the namelist for trc_ice'
-         WRITE(numout,*) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
-      ENDIF
-
-      IF( nn_timing == 1 )  CALL timing_start('trc_nam_ice')
-
-      !
-      REWIND( numnat_ref )              ! Namelist namtrc_ice in reference namelist : Passive tracer input data
-      READ  ( numnat_ref, namtrc_ice, IOSTAT = ios, ERR = 901)
- 901  IF( ios /= 0 ) CALL ctl_nam ( ios , ' namtrc_ice in reference namelist ', lwp )
-
-      REWIND( numnat_cfg )              ! Namelist namtrc_ice in configuration namelist : Pisces external sources of nutrients
-      READ  ( numnat_cfg, namtrc_ice, IOSTAT = ios, ERR = 902 )
- 902  IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_ice in configuration namelist', lwp )
-
-      IF( lwp ) THEN
-         WRITE(numout,*) ' '
-         WRITE(numout,*) ' Sea ice tracers option (nn_ice_tr) : ', nn_ice_tr
-         WRITE(numout,*) ' '
-      ENDIF
-
-      ! Assign namelist stuff
-      DO jn = 1, jptra
-         trc_ice_ratio(jn)  = sn_tri_tracer(jn)%trc_ratio
-         trc_ice_prescr(jn) = sn_tri_tracer(jn)%trc_prescr
-         cn_trc_o      (jn) = sn_tri_tracer(jn)%ctrc_o
-      END DO
-
-      IF( nn_timing == 1 )   CALL timing_stop('trc_nam_ice')
-      !
-   END SUBROUTINE trc_nam_ice
-
-
    SUBROUTINE trc_nam_trc
       !!---------------------------------------------------------------------
@@ -266,11 +143,13 @@
       !!
       !!---------------------------------------------------------------------
-      INTEGER  ::   ios                 ! Local integer output status for namelist read
-      INTEGER  ::   jn                  ! dummy loop indice
-      !
-      TYPE(PTRACER), DIMENSION(jptra) :: sn_tracer  ! type of tracer for saving if not key_iomput
-      !!
-      NAMELIST/namtrc/ sn_tracer, ln_trcdta, ln_trcdmp, ln_trcdmp_clo
-      !!---------------------------------------------------------------------
+      INTEGER  ::   ios, ierr, icfc       ! Local integer output status for namelist read
+      !!
+      NAMELIST/namtrc/jp_bgc, ln_pisces, ln_my_trc, ln_age, ln_cfc11, ln_cfc12, ln_sf6, ln_c14, &
+         &            sn_tracer, ln_trcdta, ln_trcdmp, ln_trcdmp_clo, jp_dia3d, jp_dia2d
+      !!---------------------------------------------------------------------
+      ! Dummy settings to fill tracers data structure
+      !                  !   name   !   title   !   unit   !   init  !   sbc   !   cbc   !   obc  !
+      sn_tracer = PTRACER( 'NONAME' , 'NOTITLE' , 'NOUNIT' , .false. , .false. , .false. , .false.)
+      !
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) 'trc_nam_trc : read the passive tracer namelists'
@@ -286,21 +165,78 @@
       IF(lwm) WRITE ( numont, namtrc )
 
-      DO jn = 1, jptra
-         ctrcnm    (jn) = TRIM( sn_tracer(jn)%clsname )
-         ctrcln    (jn) = TRIM( sn_tracer(jn)%cllname )
-         ctrcun    (jn) = TRIM( sn_tracer(jn)%clunit  )
-         ln_trc_ini(jn) =       sn_tracer(jn)%llinit
-#if defined key_my_trc
-         ln_trc_sbc(jn) =       sn_tracer(jn)%llsbc
-         ln_trc_cbc(jn) =       sn_tracer(jn)%llcbc
-         ln_trc_obc(jn) =       sn_tracer(jn)%llobc
-#endif
-         ln_trc_wri(jn) =       sn_tracer(jn)%llsave
-      END DO
-      !
+      ! Control settings
+      IF( ln_pisces .AND. ln_my_trc )   CALL ctl_stop( 'Choose only ONE BGC model - PISCES or MY_TRC' )
+      IF( .NOT. ln_pisces .AND. .NOT. ln_my_trc )   jp_bgc = 0
+      ll_cfc = ln_cfc11 .OR. ln_cfc12 .OR. ln_sf6
+      !
+      jptra       =  0
+      jp_pisces   =  0    ;   jp_pcs0  =  0    ;   jp_pcs1  = 0
+      jp_my_trc   =  0    ;   jp_myt0  =  0    ;   jp_myt1  = 0
+      jp_cfc      =  0    ;   jp_cfc0  =  0    ;   jp_cfc1  = 0
+      jp_age      =  0    ;   jp_c14   =  0
+      !
+      IF( ln_pisces )  THEN
+         jp_pisces = jp_bgc
+         jp_pcs0   = 1
+         jp_pcs1   = jp_pisces
+      ENDIF
+      IF( ln_my_trc )  THEN
+          jp_my_trc = jp_bgc
+          jp_myt0   = 1
+          jp_myt1   = jp_my_trc
+      ENDIF
+      !
+      jptra  = jp_bgc
+      !
+      IF( ln_age )    THEN
+         jptra     = jptra + 1
+         jp_age    = jptra
+      ENDIF
+      IF( ln_cfc11 )  jp_cfc = jp_cfc + 1
+      IF( ln_cfc12 )  jp_cfc = jp_cfc + 1
+      IF( ln_sf6   )  jp_cfc = jp_cfc + 1
+      IF( ll_cfc )    THEN
+          jptra     = jptra + jp_cfc
+          jp_cfc0   = jptra - jp_cfc + 1
+          jp_cfc1   = jptra
+      ENDIF
+      IF( ln_c14 )    THEN
+           jptra     = jptra + 1
+           jp_c14    = jptra
+      ENDIF
+      !
+      IF( jptra == 0 )   CALL ctl_stop( 'All TOP tracers disabled: change namtrc setting or check if key_top is active' )
+      !
+      IF(lwp) THEN                   ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) ' Namelist : namtrc'
+         WRITE(numout,*) '   Total number of passive tracers              jptra         = ', jptra
+         WRITE(numout,*) '   Total number of BGC tracers                  jp_bgc        = ', jp_bgc
+         WRITE(numout,*) '   Simulating PISCES model                      ln_pisces     = ', ln_pisces
+         WRITE(numout,*) '   Simulating MY_TRC  model                     ln_my_trc     = ', ln_my_trc
+         WRITE(numout,*) '   Simulating water mass age                    ln_age        = ', ln_age
+         WRITE(numout,*) '   Simulating CFC11 passive tracer              ln_cfc11      = ', ln_cfc11
+         WRITE(numout,*) '   Simulating CFC12 passive tracer              ln_cfc12      = ', ln_cfc12
+         WRITE(numout,*) '   Simulating SF6 passive tracer                ln_sf6        = ', ln_sf6
+         WRITE(numout,*) '   Total number of CFCs tracers                 jp_cfc        = ', jp_cfc
+         WRITE(numout,*) '   Simulating C14   passive tracer              ln_c14        = ', ln_c14
+         WRITE(numout,*) '   Read inputs data from file (y/n)             ln_trcdta     = ', ln_trcdta
+         WRITE(numout,*) '   Damping of passive tracer (y/n)              ln_trcdmp     = ', ln_trcdmp
+         WRITE(numout,*) '   Restoring of tracer on closed seas           ln_trcdmp_clo = ', ln_trcdmp_clo
+         WRITE(numout,*) ' '
+         WRITE(numout,*) ' '
+      ENDIF
+      !
+      IF( ll_cfc .OR. ln_c14 ) THEN
+        !                             ! Open namelist files
+        CALL ctl_opn( numtrc_ref, 'namelist_trc_ref'   ,     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+        CALL ctl_opn( numtrc_cfg, 'namelist_trc_cfg'   ,     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+        IF(lwm) CALL ctl_opn( numonr, 'output.namelist.trc', 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+        !
+      ENDIF
+
    END SUBROUTINE trc_nam_trc
 
-
-   SUBROUTINE trc_nam_dia
+   SUBROUTINE trc_nam_trd
       !!---------------------------------------------------------------------
       !!                     ***  ROUTINE trc_nam_dia  ***
@@ -312,60 +248,47 @@
       !!                ( (PISCES, CFC, MY_TRC )
       !!---------------------------------------------------------------------
+
+#if defined key_trdmxl_trc  || defined key_trdtrc
       INTEGER  ::   ios                 ! Local integer output status for namelist read
       INTEGER ::  ierr
       !!
-#if defined key_trdmxl_trc  || defined key_trdtrc
       NAMELIST/namtrc_trd/ nn_trd_trc, nn_ctls_trc, rn_ucf_trc, &
          &                ln_trdmxl_trc_restart, ln_trdmxl_trc_instant, &
          &                cn_trdrst_trc_in, cn_trdrst_trc_out, ln_trdtrc
-#endif
-      NAMELIST/namtrc_dia/ ln_diatrc, ln_diabio, nn_writedia, nn_writebio
       !!---------------------------------------------------------------------
 
       IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'trc_nam_dia : read the passive tracer diagnostics options'
+      IF(lwp) WRITE(numout,*) 'trc_nam_trd : read the passive tracer diagnostics options'
       IF(lwp) WRITE(numout,*) '~~~~~~~'
 
-      REWIND( numnat_ref )              ! Namelist namtrc_dia in reference namelist : Passive tracer diagnostics
-      READ  ( numnat_ref, namtrc_dia, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dia in reference namelist', lwp )
-
-      REWIND( numnat_cfg )              ! Namelist namtrc_dia in configuration namelist : Passive tracer diagnostics
-      READ  ( numnat_cfg, namtrc_dia, IOSTAT = ios, ERR = 904 )
-904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dia in configuration namelist', lwp )
-      IF(lwm) WRITE ( numont, namtrc_dia )
+      !
+      ALLOCATE( ln_trdtrc(jptra) ) 
+      !
+      REWIND( numnat_ref )              ! Namelist namtrc_trd in reference namelist : Passive tracer trends
+      READ  ( numnat_ref, namtrc_trd, IOSTAT = ios, ERR = 905)
+905   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_trd in reference namelist', lwp )
+
+      REWIND( numnat_cfg )              ! Namelist namtrc_trd in configuration namelist : Passive tracer trends
+      READ  ( numnat_cfg, namtrc_trd, IOSTAT = ios, ERR = 906 )
+906   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_trd in configuration namelist', lwp )
+      IF(lwm) WRITE ( numont, namtrc_trd )
 
       IF(lwp) THEN
          WRITE(numout,*)
-         WRITE(numout,*)
-         WRITE(numout,*) ' Namelist : namtrc_dia'
-         WRITE(numout,*) '    save additionnal diagnostics arrays         ln_diatrc   = ', ln_diatrc
-         WRITE(numout,*) '    save additionnal biology diagnostics arrays ln_diabio   = ', ln_diabio
-         WRITE(numout,*) '    frequency of outputs for additional arrays  nn_writedia = ', nn_writedia
-         WRITE(numout,*) '    frequency of outputs for biological trends  nn_writebio = ', nn_writebio
-         WRITE(numout,*) ' '
-      ENDIF
-
-      IF( ln_diatrc .AND. .NOT. lk_iomput ) THEN 
-         ALLOCATE( trc2d(jpi,jpj,jpdia2d), trc3d(jpi,jpj,jpk,jpdia3d),  &
-           &       ctrc2d(jpdia2d), ctrc2l(jpdia2d), ctrc2u(jpdia2d) ,  & 
-           &       ctrc3d(jpdia3d), ctrc3l(jpdia3d), ctrc3u(jpdia3d) ,  STAT = ierr ) 
-         IF( ierr > 0 )   CALL ctl_stop( 'STOP', 'trcnam: unable to allocate add. diag. array' )
-         !
-         trc2d(:,:,:  ) = 0._wp  ;   ctrc2d(:) = ' '   ;   ctrc2l(:) = ' '    ;    ctrc2u(:) = ' ' 
-         trc3d(:,:,:,:) = 0._wp  ;   ctrc3d(:) = ' '   ;   ctrc3l(:) = ' '    ;    ctrc3u(:) = ' ' 
-         !
-      ENDIF
-
-      IF( ( ln_diabio .AND. .NOT. lk_iomput ) .OR. l_trdtrc ) THEN
-         ALLOCATE( trbio (jpi,jpj,jpk,jpdiabio) , &
-           &       ctrbio(jpdiabio), ctrbil(jpdiabio), ctrbiu(jpdiabio), STAT = ierr ) 
-         IF( ierr > 0 )   CALL ctl_stop( 'STOP', 'trcnam: unable to allocate bio. diag. array' )
-         !
-         trbio(:,:,:,:) = 0._wp  ;   ctrbio(:) = ' '   ;   ctrbil(:) = ' '    ;    ctrbiu(:) = ' ' 
-         !
-      ENDIF
-      !
-   END SUBROUTINE trc_nam_dia
+         WRITE(numout,*) ' trd_mxl_trc_init : read namelist namtrc_trd                    '
+         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~                                               '
+         WRITE(numout,*) '   * frequency of trends diagnostics   nn_trd_trc             = ', nn_trd_trc
+         WRITE(numout,*) '   * control surface type              nn_ctls_trc            = ', nn_ctls_trc
+         WRITE(numout,*) '   * restart for ML diagnostics        ln_trdmxl_trc_restart  = ', ln_trdmxl_trc_restart
+         WRITE(numout,*) '   * flag to diagnose trends of                                 '
+         WRITE(numout,*) '     instantantaneous or mean ML T/S   ln_trdmxl_trc_instant  = ', ln_trdmxl_trc_instant
+         WRITE(numout,*) '   * unit conversion factor            rn_ucf_trc             = ', rn_ucf_trc
+         DO jn = 1, jptra
+            IF( ln_trdtrc(jn) ) WRITE(numout,*) '    compute ML trends for tracer number :', jn
+         END DO
+      ENDIF
+#endif
+      !
+   END SUBROUTINE trc_nam_trd
 
 #else
