Index: branches/DEV_r2006_merge_TRA_TRC/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90
===================================================================
--- branches/DEV_r2006_merge_TRA_TRC/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90	(revision 2023)
+++ branches/DEV_r2006_merge_TRA_TRC/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90	(revision 2038)
@@ -20,4 +20,6 @@
    USE oce_trc         ! ocean variables
    USE trc
+   USE lbclnk 
+   USE lib_mpp 
 
    IMPLICIT NONE
@@ -46,8 +48,11 @@
       !!----------------------------------------------------------------------
 
+      !  Control consitency
+      CALL trc_ctl_lobster
+
+
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) ' trc_ini_lobster :   LOBSTER biochemical model initialisation'
       IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~~'
-
 
       ! initialization of fields for optical model
@@ -118,5 +123,5 @@
       ! Coastal mask 
       ! ------------   
-      cmask = 0.e0
+      cmask(:,:) = 0.e0
       DO ji = 2, jpi-1
          DO jj = 2, jpj-1
@@ -128,18 +133,16 @@
       END DO
 
-      cmask( 1 ,:) = cmask(jpi-1,:)
-      cmask(jpi,:) = cmask( 2   ,:)
-
-      !!gm BUG !!!!!   not valid in mpp and also not valid for north fold   !!!!!
+      CALL lbc_lnk( cmask, 'T', 1. )
 
       ! Coastal surface
       ! ---------------
       areacot = 0.e0
-      DO ji = 2, jpi-1
-         DO jj = 2, jpj-1
+      DO ji = 1, jpi
+         DO jj = 1, jpj
             areacot = areacot + e1t(ji,jj) * e2t(ji,jj) * cmask(ji,jj)
          END DO
       END DO
       !
+      IF( lk_mpp ) CALL mpp_sum( areacot )   ! sum over the global domain
 
       ! Initialization of tracer concentration in case of  no restart 
@@ -153,73 +156,73 @@
          
          DO jk = 1, 7
-            trn(:,:,jk,jpdet) = 0.016 * tmask(:,:,jk)
-            trn(:,:,jk,jpzoo) = 0.018 * tmask(:,:,jk)
-            trn(:,:,jk,jpphy) = 0.036 * tmask(:,:,jk) 
-            trn(:,:,jk,jpno3) = 1.e-5 * tmask(:,:,jk)
-            trn(:,:,jk,jpnh4) = 5.e-4 * tmask(:,:,jk)
-            trn(:,:,jk,jpdom) = 0.017 * tmask(:,:,jk)
-         END DO
-         
-         trn(:,:, 8,jpdet) = 0.020   * tmask(:,:, 8)
-         trn(:,:, 8,jpzoo) = 0.027   * tmask(:,:, 8)
-         trn(:,:, 8,jpphy) = 0.041   * tmask(:,:, 8)
-         trn(:,:, 8,jpno3) = 0.00022 * tmask(:,:, 8)
-         trn(:,:, 8,jpnh4) = 0.0033  * tmask(:,:, 8)
-         trn(:,:, 8,jpdom) = 0.021   * tmask(:,:, 8)
-         
-         trn(:,:, 9,jpdet) = 0.0556  * tmask(:,:, 9)
-         trn(:,:, 9,jpzoo) = 0.123   * tmask(:,:, 9)
-         trn(:,:, 9,jpphy) = 0.122   * tmask(:,:, 9)
-         trn(:,:, 9,jpno3) = 0.028   * tmask(:,:, 9)
-         trn(:,:, 9,jpnh4) = 0.024   * tmask(:,:, 9)
-         trn(:,:, 9,jpdom) = 0.06    * tmask(:,:, 9)
-         
-         trn(:,:,10,jpdet) = 0.025   * tmask(:,:,10)
-         trn(:,:,10,jpzoo) = 0.016   * tmask(:,:,10)
-         trn(:,:,10,jpphy) = 0.029   * tmask(:,:,10)
-         trn(:,:,10,jpno3) = 2.462   * tmask(:,:,10)
-         trn(:,:,10,jpnh4) = 0.04    * tmask(:,:,10)
-         trn(:,:,10,jpdom) = 0.022   * tmask(:,:,10)
-         
-         trn(:,:,11,jpdet) = 0.0057  * tmask(:,:,11)
-         trn(:,:,11,jpzoo) = 0.0005  * tmask(:,:,11)
-         trn(:,:,11,jpphy) = 0.0006  * tmask(:,:,11)
-         trn(:,:,11,jpno3) = 3.336   * tmask(:,:,11)
-         trn(:,:,11,jpnh4) = 0.005   * tmask(:,:,11)
-         trn(:,:,11,jpdom) = 0.004   * tmask(:,:,11)
-         
-         trn(:,:,12,jpdet) = 0.002   * tmask(:,:,12)
-         trn(:,:,12,jpzoo) = 1.e-6   * tmask(:,:,12)
-         trn(:,:,12,jpphy) = 5.e-6   * tmask(:,:,12)
-         trn(:,:,12,jpno3) = 4.24    * tmask(:,:,12)
-         trn(:,:,12,jpnh4) = 0.001   * tmask(:,:,12)
-         trn(:,:,12,jpdom) = 3.e-5   * tmask(:,:,12)
+            trn(:,:,jk,jp_lob_det) = 0.016 * tmask(:,:,jk)
+            trn(:,:,jk,jp_lob_zoo) = 0.018 * tmask(:,:,jk)
+            trn(:,:,jk,jp_lob_phy) = 0.036 * tmask(:,:,jk) 
+            trn(:,:,jk,jp_lob_no3) = 1.e-5 * tmask(:,:,jk)
+            trn(:,:,jk,jp_lob_nh4) = 5.e-4 * tmask(:,:,jk)
+            trn(:,:,jk,jp_lob_dom) = 0.017 * tmask(:,:,jk)
+         END DO
+         
+         trn(:,:, 8,jp_lob_det) = 0.020   * tmask(:,:, 8)
+         trn(:,:, 8,jp_lob_zoo) = 0.027   * tmask(:,:, 8)
+         trn(:,:, 8,jp_lob_phy) = 0.041   * tmask(:,:, 8)
+         trn(:,:, 8,jp_lob_no3) = 0.00022 * tmask(:,:, 8)
+         trn(:,:, 8,jp_lob_nh4) = 0.0033  * tmask(:,:, 8)
+         trn(:,:, 8,jp_lob_dom) = 0.021   * tmask(:,:, 8)
+         
+         trn(:,:, 9,jp_lob_det) = 0.0556  * tmask(:,:, 9)
+         trn(:,:, 9,jp_lob_zoo) = 0.123   * tmask(:,:, 9)
+         trn(:,:, 9,jp_lob_phy) = 0.122   * tmask(:,:, 9)
+         trn(:,:, 9,jp_lob_no3) = 0.028   * tmask(:,:, 9)
+         trn(:,:, 9,jp_lob_nh4) = 0.024   * tmask(:,:, 9)
+         trn(:,:, 9,jp_lob_dom) = 0.06    * tmask(:,:, 9)
+         
+         trn(:,:,10,jp_lob_det) = 0.025   * tmask(:,:,10)
+         trn(:,:,10,jp_lob_zoo) = 0.016   * tmask(:,:,10)
+         trn(:,:,10,jp_lob_phy) = 0.029   * tmask(:,:,10)
+         trn(:,:,10,jp_lob_no3) = 2.462   * tmask(:,:,10)
+         trn(:,:,10,jp_lob_nh4) = 0.04    * tmask(:,:,10)
+         trn(:,:,10,jp_lob_dom) = 0.022   * tmask(:,:,10)
+         
+         trn(:,:,11,jp_lob_det) = 0.0057  * tmask(:,:,11)
+         trn(:,:,11,jp_lob_zoo) = 0.0005  * tmask(:,:,11)
+         trn(:,:,11,jp_lob_phy) = 0.0006  * tmask(:,:,11)
+         trn(:,:,11,jp_lob_no3) = 3.336   * tmask(:,:,11)
+         trn(:,:,11,jp_lob_nh4) = 0.005   * tmask(:,:,11)
+         trn(:,:,11,jp_lob_dom) = 0.004   * tmask(:,:,11)
+         
+         trn(:,:,12,jp_lob_det) = 0.002   * tmask(:,:,12)
+         trn(:,:,12,jp_lob_zoo) = 1.e-6   * tmask(:,:,12)
+         trn(:,:,12,jp_lob_phy) = 5.e-6   * tmask(:,:,12)
+         trn(:,:,12,jp_lob_no3) = 4.24    * tmask(:,:,12)
+         trn(:,:,12,jp_lob_nh4) = 0.001   * tmask(:,:,12)
+         trn(:,:,12,jp_lob_dom) = 3.e-5   * tmask(:,:,12)
          
          DO jk=13,jpk
-            trn(:,:,jk,jpdet) = 0.e0
-            trn(:,:,jk,jpzoo) = 0.e0
-            trn(:,:,jk,jpphy) = 0.e0
-            trn(:,:,jk,jpnh4) = 0.e0
-            trn(:,:,jk,jpdom) = 0.e0
-         END DO
-         
-         trn(:,:,13,jpno3) = 5.31  * tmask(:,:,13)
-         trn(:,:,14,jpno3) = 6.73  * tmask(:,:,14)
-         trn(:,:,15,jpno3) = 8.32  * tmask(:,:,15)
-         trn(:,:,16,jpno3) = 10.13 * tmask(:,:,16)
-         trn(:,:,17,jpno3) = 11.95 * tmask(:,:,17)
-         trn(:,:,18,jpno3) = 13.57 * tmask(:,:,18)
-         trn(:,:,19,jpno3) = 15.08 * tmask(:,:,19)
-         trn(:,:,20,jpno3) = 16.41 * tmask(:,:,20)
-         trn(:,:,21,jpno3) = 17.47 * tmask(:,:,21)
-         trn(:,:,22,jpno3) = 18.29 * tmask(:,:,22)
-         trn(:,:,23,jpno3) = 18.88 * tmask(:,:,23)
-         trn(:,:,24,jpno3) = 19.30 * tmask(:,:,24)
-         trn(:,:,25,jpno3) = 19.68 * tmask(:,:,25)
-         trn(:,:,26,jpno3) = 19.91 * tmask(:,:,26)
-         trn(:,:,27,jpno3) = 19.99 * tmask(:,:,27)
-         trn(:,:,28,jpno3) = 20.01 * tmask(:,:,28)
-         trn(:,:,29,jpno3) = 20.01 * tmask(:,:,29)
-         trn(:,:,30,jpno3) = 20.01 * tmask(:,:,30)
+            trn(:,:,jk,jp_lob_det) = 0.e0
+            trn(:,:,jk,jp_lob_zoo) = 0.e0
+            trn(:,:,jk,jp_lob_phy) = 0.e0
+            trn(:,:,jk,jp_lob_nh4) = 0.e0
+            trn(:,:,jk,jp_lob_dom) = 0.e0
+         END DO
+         
+         trn(:,:,13,jp_lob_no3) = 5.31  * tmask(:,:,13)
+         trn(:,:,14,jp_lob_no3) = 6.73  * tmask(:,:,14)
+         trn(:,:,15,jp_lob_no3) = 8.32  * tmask(:,:,15)
+         trn(:,:,16,jp_lob_no3) = 10.13 * tmask(:,:,16)
+         trn(:,:,17,jp_lob_no3) = 11.95 * tmask(:,:,17)
+         trn(:,:,18,jp_lob_no3) = 13.57 * tmask(:,:,18)
+         trn(:,:,19,jp_lob_no3) = 15.08 * tmask(:,:,19)
+         trn(:,:,20,jp_lob_no3) = 16.41 * tmask(:,:,20)
+         trn(:,:,21,jp_lob_no3) = 17.47 * tmask(:,:,21)
+         trn(:,:,22,jp_lob_no3) = 18.29 * tmask(:,:,22)
+         trn(:,:,23,jp_lob_no3) = 18.88 * tmask(:,:,23)
+         trn(:,:,24,jp_lob_no3) = 19.30 * tmask(:,:,24)
+         trn(:,:,25,jp_lob_no3) = 19.68 * tmask(:,:,25)
+         trn(:,:,26,jp_lob_no3) = 19.91 * tmask(:,:,26)
+         trn(:,:,27,jp_lob_no3) = 19.99 * tmask(:,:,27)
+         trn(:,:,28,jp_lob_no3) = 20.01 * tmask(:,:,28)
+         trn(:,:,29,jp_lob_no3) = 20.01 * tmask(:,:,29)
+         trn(:,:,30,jp_lob_no3) = 20.01 * tmask(:,:,30)
 
 # elif defined key_gyre
@@ -227,16 +230,16 @@
          ! ----------------------
          ! here:  init NO3=f(density) by asklod AS Kremeur 2005-07
-         trn(:,:,:,jpdet) = 0.1 * tmask(:,:,:)
-         trn(:,:,:,jpzoo) = 0.1 * tmask(:,:,:)
-         trn(:,:,:,jpnh4) = 0.1 * tmask(:,:,:)
-         trn(:,:,:,jpphy) = 0.1 * tmask(:,:,:)
-         trn(:,:,:,jpdom) = 1.0 * tmask(:,:,:)
+         trn(:,:,:,jp_lob_det) = 0.1 * tmask(:,:,:)
+         trn(:,:,:,jp_lob_zoo) = 0.1 * tmask(:,:,:)
+         trn(:,:,:,jp_lob_nh4) = 0.1 * tmask(:,:,:)
+         trn(:,:,:,jp_lob_phy) = 0.1 * tmask(:,:,:)
+         trn(:,:,:,jp_lob_dom) = 1.0 * tmask(:,:,:)
          DO jk = 1, jpk
             DO jj = 1, jpj
                DO ji = 1, jpi
                   IF( rhd(ji,jj,jk) <= 24.5e-3 ) THEN
-                     trn(ji,jj,jk,jpno3) = 2. * tmask(ji,jj,jk)
+                     trn(ji,jj,jk,jp_lob_no3) = 2. * tmask(ji,jj,jk)
                   ELSE
-                     trn(ji,jj,jk,jpno3) = ( 15.55 * ( rhd(ji,jj,jk) * 1000. ) - 380.11 ) * tmask(ji,jj,jk)
+                     trn(ji,jj,jk,jp_lob_no3) = ( 15.55 * ( rhd(ji,jj,jk) * 1000. ) - 380.11 ) * tmask(ji,jj,jk)
                   ENDIF
                END DO
@@ -259,4 +262,78 @@
    END SUBROUTINE trc_ini_lobster
 
+   SUBROUTINE trc_ctl_lobster
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ctl_lobster  ***
+      !!
+      !! ** Purpose :   control the cpp options, namelist and files 
+      !!----------------------------------------------------------------------
+      INTEGER :: jl, jn
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' use LOBSTER biological model '
+
+      ! Check number of tracers
+      ! -----------------------
+      IF (jp_lobster /= 6) THEN
+          IF (lwp) THEN
+              WRITE (numout,*) ' ===>>>> : w a r n i n g '
+              WRITE (numout,*) ' =======   ============= '
+              WRITE (numout,*)                             &
+              &   ' STOP, change jp_lobster to 6 in '           &
+              &   ,'par_lobster.F90 '
+          END IF
+          STOP 'TRC_CTL'
+      END IF
+      ! Check tracer names
+      ! ------------------
+      IF(   ctrcnm(jp_lob_det) /= 'DET' .OR. ctrcnm(jp_lob_zoo) /= 'ZOO' .OR.   &
+         &  ctrcnm(jp_lob_phy) /= 'PHY' .OR. ctrcnm(jp_lob_no3) /= 'NO3' .OR.   &
+         &  ctrcnm(jp_lob_nh4) /= 'NH4' .OR. ctrcnm(jp_lob_dom) /= 'DOM' .OR.   &
+         &  ctrcnl(jp_lob_det) /= 'Detritus'                        .OR.   &
+         &  ctrcnl(jp_lob_zoo) /= 'Zooplankton concentration'       .OR.   &
+         &  ctrcnl(jp_lob_phy) /= 'Phytoplankton concentration'     .OR.   &
+         &  ctrcnl(jp_lob_no3) /= 'Nitrate concentration'           .OR.   &
+         &  ctrcnl(jp_lob_nh4) /= 'Ammonium concentration'          .OR.   &
+         &  ctrcnl(jp_lob_dom) /= 'Dissolved organic matter' ) THEN
+         ctrcnm(jp_lob_det)='DET'
+         ctrcnl(jp_lob_det)='Detritus'
+         ctrcnm(jp_lob_zoo)='ZOO'
+         ctrcnl(jp_lob_zoo)='Zooplankton concentration'
+         ctrcnm(jp_lob_phy)='PHY'
+         ctrcnl(jp_lob_phy)='Phytoplankton concentration'
+         ctrcnm(jp_lob_no3)='NO3'
+         ctrcnl(jp_lob_no3)='Nitrate concentration'
+         ctrcnm(jp_lob_nh4)='NH4'
+         ctrcnl(jp_lob_nh4)='Ammonium concentration'
+         ctrcnm(jp_lob_dom)='DOM'
+         ctrcnl(jp_lob_dom)='Dissolved organic matter'
+         IF(lwp) THEN
+            WRITE (numout,*) ' ===>>>> : w a r n i n g '
+            WRITE (numout,*) ' =======   ============= '
+            WRITE (numout,*) ' we force tracer names'
+            DO jl = 1, jp_lobster
+               jn = jp_lob0 + jl - 1
+               WRITE(numout,*) ' tracer nb: ',jn,' name = ',ctrcnm(jn), ctrcnl(jn)
+            END DO
+            WRITE(numout,*) ' '
+         ENDIF
+      ENDIF
+
+      ! Check tracer units
+      DO jl = 1, jp_lobster
+         jn = jp_lob0 + jl - 1
+         IF( ctrcun(jn) /= 'mmole-N/m3') THEN
+            ctrcun(jn) = 'mmole-N/m3'
+            IF(lwp) THEN
+               WRITE (numout,*) ' ===>>>> : w a r n i n g '
+               WRITE (numout,*) ' =======   ============= '
+               WRITE (numout,*) ' we force tracer unit'
+               WRITE(numout,*) ' tracer  ',ctrcnm(jn), 'UNIT= ',ctrcun(jn)
+            ENDIF
+         ENDIF
+      END DO
+
+   END SUBROUTINE trc_ctl_lobster
+
 #else
    !!----------------------------------------------------------------------
