Index: trunk/NEMOGCM/NEMO/TOP_SRC/SED/sed.F90
===================================================================
--- trunk/NEMOGCM/NEMO/TOP_SRC/SED/sed.F90	(revision 2528)
+++ trunk/NEMOGCM/NEMO/TOP_SRC/SED/sed.F90	(revision 2761)
@@ -9,208 +9,178 @@
    !!----------------------------------------------------------------------
    USE par_sed
-
    USE in_out_manager
 
-   USE dom_oce , ONLY :       &
-      nidom    =>   nidom  ,  & !:
-      glamt    =>   glamt  ,  & !: longitude of t-point (degre)
-      gphit    =>   gphit  ,  & !: latitude  of t-point (degre)
-      e3t_0    =>   e3t_0  ,  & !: reference depth of t-points (m)
-      mbkt     =>   mbkt   ,  & !: vertical index of the bottom last T- ocean level
-      tmask    =>   tmask  ,  & !: land/ocean mask at t-points
-      rdt      =>   rdt         !: time step for the dynamics
+   IMPLICIT NONE
+   PUBLIC
 
-      nyear     =>   nyear    ,   & !: Current year
-      nmonth    =>   nmonth   ,   & !: Current month
-      nday      =>   nday     ,   & !: Current day
-      ndastp    =>   ndastp   ,   & !: time step date in year/month/day aammjj
-      nday_year =>   nday_year,   & !: curent day counted from jan 1st of the current year
-      adatrj    =>   adatrj         !: number of elapsed days since the begining of the run
+   PUBLIC sed_alloc   
+
+   USE dom_oce , ONLY :   nidom     =>   nidom          !:
+   USE dom_oce , ONLY :   glamt     =>   glamt          !: longitude of t-point (degre)
+   USE dom_oce , ONLY :   gphit     =>   gphit          !: latitude  of t-point (degre)
+   USE dom_oce , ONLY :   e3t_0     =>   e3t_0          !: reference depth of t-points (m)
+   USE dom_oce , ONLY :   mbkt      =>   mbkt           !: vertical index of the bottom last T- ocean level
+   USE dom_oce , ONLY :   tmask     =>   tmask          !: land/ocean mask at t-points
+   USE dom_oce , ONLY :   rdt       =>   rdt            !: time step for the dynamics
+   USE dom_oce , ONLY :   nyear     =>   nyear          !: Current year
+   USE dom_oce , ONLY :   nmonth    =>   nmonth         !: Current month
+   USE dom_oce , ONLY :   nday      =>   nday           !: Current day
+   USE dom_oce , ONLY :   ndastp    =>   ndastp         !: time step date in year/month/day aammjj
+   USE dom_oce , ONLY :   nday_year =>   nday_year      !: curent day counted from jan 1st of the current year
+   USE dom_oce , ONLY :   adatrj    =>   adatrj         !: number of elapsed days since the begining of the run
    !                                !: it is the accumulated duration of previous runs
    !                                !: that may have been run with different time steps.
 
-
 #if ! defined key_sed_off
 
-   USE oce , ONLY :            &
-      tsn      =>    tsn       & !: pot. temperature (celsius) and salinity (psu)
+   USE oce     , ONLY :  tsn        =>   tsn             !: pot. temperature (celsius) and salinity (psu)
 
-   USE trc, ONLY :  &
-      trn        , & !: tracer 
-      nwritetrc      !: outputs frequency of tracer model
+   USE trc     , ONLY :  trn        =>   trc             !: tracer 
+   USE trc     , ONLY :  nwritetrc  =>   nwritetrc       !: outputs frequency of tracer model
 
-   USE p4zsink, ONLY :  &
-      sinking  ,     & !: sinking flux for POC
+   USE p4zsink , ONLY :  sinking    =>   sinking         !: sinking flux for POC
 #if ! defined key_kriest
-      sinking2 ,     & !: sinking flux for GOC
+   USE p4zsink , ONLY :  sinking2   =>   sinking2        !: sinking flux for GOC
 #endif
-      sinkcal ,      & !: sinking flux for calcite 
-      sinksil          !: sinking flux for opal ( dsi )
+   USE p4zsink , ONLY :  sinkcal    =>   sinkcal         !: sinking flux for calcite
+   USE p4zsink , ONLY :  sinksil    =>   sinksil         !: sinking flux for opal ( dsi )
 
-   USE sms_pisces, ONLY :  &
-      akb3  ,     & 
-      ak13  ,     & 
-      ak23  ,     & 
-      akw3  ,     & 
-      aksp  ,     & 
-      borat 
+   USE sms_pisces, ONLY : akb3      =>   akb3            !: Chemical constants  
+   USE sms_pisces, ONLY : ak13      =>   ak13            !: Chemical constants  
+   USE sms_pisces, ONLY : ak23      =>   ak23            !: Chemical constants  
+   USE sms_pisces, ONLY : akw3      =>   akw3            !: Chemical constants  
+   USE sms_pisces, ONLY : aksp      =>   aksp            !: Chemical constants  
+   USE sms_pisces, ONLY : borat     =>   borat           !: Chemical constants ( borat ) 
 
 #endif   
 
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpdta) :: &
-      trc_data           !: tracer data to share with sediment model
 
-   INTEGER, PUBLIC :: &
-      nitsed000, nitsedend, nwrised, nfreq
+   !! Namelist
+   REAL(wp), PUBLIC, DIMENSION(5) ::  reac                !: reactivity rc in  [l.mol-1.s-1]
+   REAL(wp), PUBLIC               ::  reac_sil            !: reactivity of silicate in  [l.mol-1.s-1]
+   REAL(wp), PUBLIC               ::  reac_clay           !: reactivity of clay in  [l.mol-1.s-1]
+   REAL(wp), PUBLIC               ::  reac_poc            !: reactivity of poc in  [l.mol-1.s-1]
+   REAL(wp), PUBLIC               ::  reac_no3            !: reactivity of no3 in  [l.mol-1.s-1]
+   REAL(wp), PUBLIC               ::  reac_cal            !: reactivity of cal in  [l.mol-1.s-1]
+   REAL(wp), PUBLIC               ::  sat_sil             !: saturation concentration for silicate in [mol.l-1]
+   REAL(wp), PUBLIC               ::  sat_clay            !: saturation concentration for clay in [mol.l-1]
+   REAL(wp), PUBLIC               ::  so2ut 
+   REAL(wp), PUBLIC               ::  srno3 
+   REAL(wp), PUBLIC               ::  spo4r 
+   REAL(wp), PUBLIC               ::  srDnit 
+   REAL(wp), PUBLIC               ::  sthro2              !: threshold O2 concen. in [mol.l-1]
+   REAL(wp), PUBLIC               ::  pdb = 0.0112372     !: 13C/12C in PD Belemnite
+   REAL(wp), PUBLIC               ::  rc13P  = 0.980      !: 13C/12C in POC = rc13P*PDB
+   REAL(wp), PUBLIC               ::  rc13Ca = 1.001      !: 13C/12C in CaCO3 = rc13Ca*PDB
+   REAL(wp), PUBLIC               ::  dtsed               !: sedimentation time step
+   REAL(wp), PUBLIC               ::  db                  !: bioturb coefficient in [cm2.s-1]
 
-   REAL(wp), PUBLIC, DIMENSION(:,:,:) , ALLOCATABLE ::   &
-      pwcp  ,      &     !: pore water sediment data at given time-step
-      pwcp0              !: pore water sediment data at initial time
-
-   REAL(wp), PUBLIC, DIMENSION(:,:,:) , ALLOCATABLE ::   &
-      solcp ,      &     !: solid sediment data at given time-step
-      solcp0             !: solid sediment at initial time
+   INTEGER , PUBLIC               ::  nitsed000
+   INTEGER , PUBLIC               ::  nitsedend
+   INTEGER , PUBLIC               ::  nwrised
+   INTEGER , PUBLIC               ::  nfreq
+   REAL(wp), PUBLIC               ::  dens                !: density of solid material
+   !
+   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::  pwcp       !: pore water sediment data at given time-step
+   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::  pwcp0      !: pore water sediment data at initial time
+   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::  solcp      !: solid sediment data at given time-step
+   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::  solcp0     !: solid sediment data at initial time
 
    !! * Shared module variables
-   REAL(wp), PUBLIC, DIMENSION(:,:) , ALLOCATABLE ::   &
-      pwcp_dta           !: pore water data at given time-step
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  pwcp_dta   !: pore water data at given time-step
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  rainrm_dta !: rain data at at initial time
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  rainrm     !: rain data at given time-step
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  rainrg     !: rain of each solid component in [g/(cm**2.s)]
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  fromsed    !:
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  tosed      !:
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  rloss      !: 
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  tokbot        
+   !
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  temp       !: temperature
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  salt       !: salinity
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  press      !: pressure
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  raintg     !: total massic flux rained in each cell (sum of sol. comp.)
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  dzdep      !: total thickness of solid material rained [cm] in each cell
+   !
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  hipor      !: [h+] in mol/kg*densSW 
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  co3por     !: [co3--]solid sediment at initial time
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  dz3d       !:  ???
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  volw3d     !:  ???
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  vols3d     !:  ???
 
-   REAL(wp), PUBLIC, DIMENSION(:,:) , ALLOCATABLE ::   &
-      rainrm_dta,  &     !: rain data at at initial time
-      rainrm    ,  &     !: rain data at given time-step
-      rainrg    ,  &     !: rain of each solid component in [g/(cm**2.s)]
-      fromsed   ,  &     !:
-      tosed     ,  &     !:
-      rloss              !: 
-
-   REAL(wp), PUBLIC, DIMENSION(:,:) , ALLOCATABLE  ::   &
-      tokbot             !: 
-
-   REAL(wp), PUBLIC, DIMENSION(:) , ALLOCATABLE  ::   & 
-      temp  ,      &     !: temperature
-      salt  ,      &     !: salinity
-      press ,      &     !: pressure
-      raintg,      &     !: total massic flux rained in each cell (sum of sol. comp.)
-      dzdep              !: total thickness of solid material rained [cm] in each cell
-
-   REAL(wp), PUBLIC, DIMENSION(:,:) , ALLOCATABLE  ::   &
-      hipor  ,     &     !: [h+] in mol/kg*densSW 
-      co3por             !: [co3--]solid sediment at initial time
-
-   REAL(wp), PUBLIC, DIMENSION(jpsol) ::   &
-      mol_wgt            !: molecular weight of solid sediment data
-
-   
-   !! Geometry
-   INTEGER, PUBLIC, SAVE :: &
-      jpoce ,  &             !: sediment points
-      indoce
-
-   INTEGER , PUBLIC, DIMENSION(:) , ALLOCATABLE  ::   &  !:
-      iarroce      !: ! Computation of 1D array of sediments points
-
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) :: &
-      epkbot             !: ocean bottom layer thickness
-
-   REAL(wp), PUBLIC, DIMENSION(:) , ALLOCATABLE  :: &
-      dzkbot             !: ocean bottom layer thickness in meters
-
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpksed) :: &
-      tmasksed           !: sediment mask
-
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) :: &
-      sbathy
- 
-   REAL(wp), PUBLIC, DIMENSION(jpksed) :: &
-      dz      ,    &     !: sediment layers thickness
-      por     ,    &     !: porosity profile     
-      por1    ,    &     !: 1 - por 
-      profsed ,    &     !: depth of middle of each layer
-      volw    ,    &     !: volume of pore water cell fraction
-      vols    ,    &     !: volume of solid cell fraction
-      diff    ,    &     !: diffusion ceofficient
-      rdtsed             !: 
-
-   REAL(wp), PUBLIC, DIMENSION(:,:) , ALLOCATABLE :: &
-      dz3d   ,     &     !: 
-      volw3d ,     &     !: 
-      vols3d             !: 
-
-   REAL(wp)  ::    &
-      dens               !: density of solid material
-
-   !! Namelist
-   REAL(wp), PUBLIC, DIMENSION(5) :: &   
-      reac               !: reactivity rc in  [l.mol-1.s-1]
-
-   REAL(wp), PUBLIC       :: &   
-      sat_sil,      &     !: saturation concentration for silicate in [mol.l-1]
-      sat_clay,     &     !:                              clay    
-      reac_sil,     &     !: reactivity rc in  [l.mol-1.s-1]
-      reac_clay,    &     
-      reac_poc,     &     
-      reac_no3,     &     
-      reac_cal         
-
-   REAL(wp), PUBLIC    :: &   
-      so2ut   ,     &     !:
-      srno3   ,     &     !: 
-      spo4r   ,     &     !:
-      srDnit  ,     &     !: 
-      sthro2              !: threshold O2 concen. in [mol.l-1]
-
-   REAL(wp), PUBLIC    :: &   
-      pdb    = 0.0112372, & !: 13C/12C in PD Belemnite
-      rc13P  = 0.980    , & !: 13C/12C in POC = rc13P*PDB
-      rc13Ca = 1.001        !: 13C/12C in CaCO3 = rc13Ca*PDB
-
-   REAL(wp) , PUBLIC ::   &
-      dtsed  ,     &     !: sedimentation time step
-      db                 !: bioturb coefficient in [cm2.s-1]
 
    !! Chemistry
-   REAL(wp), PUBLIC, DIMENSION(:) , ALLOCATABLE  :: &
-      densSW ,     &
-      borats ,     &
-      calcon2,     &
-      akbs   ,     &
-      ak1s   ,     &
-      ak2s   ,     &
-      akws   ,     &
-      ak12s  ,     &
-      ak1ps  ,     &
-      ak2ps  ,     &
-      ak3ps  ,     &
-      ak12ps ,     &
-      ak123ps,     &
-      aksis  ,     & 
-      aksps 
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  densSW 
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  borats 
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  calcon2
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  akbs  
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  ak1s 
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  ak2s   
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  akws  
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  ak12s  
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  ak1ps 
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  ak2ps  
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  ak3ps 
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  ak12ps 
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  ak123ps
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  aksis 
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  aksps 
 
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  mol_wgt    !: molecular weight of solid sediment data
+ 
+   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::  trc_data    !: tracer data to share with sediment model
+   !! Geometry
+   INTEGER , PUBLIC, SAVE                          ::  jpoce, indoce !: Ocean points ( number/indices )
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  iarroce       !: Computation of 1D array of sediments points
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  epkbot        !: ocean bottom layer thickness
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  dzkbot        !: ocean bottom layer thickness in meters
+   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::  tmasksed      !: sediment mask
+   REAL(wp), PUBLIC, DIMENSION(:,:  ), ALLOCATABLE ::  sbathy        !: bathymetry
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  dz            !: sediment layers thickness
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  por           !: porosity profile     
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  por1          !: 1-por 
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  profsed       !: depth of middle of each layer
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  volw          !: volume of pore water cell fraction
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  vols          !: volume of solid cell fraction
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  diff          !: diffusion ceofficient
+   REAL(wp), PUBLIC, DIMENSION(:    ), ALLOCATABLE ::  rdtsed        !:  sediment model time-step
+   REAL(wp)  ::   dens               !: density of solid material
    !! Inputs / Outputs
-   CHARACTER( len = 80 ), DIMENSION(jptrased) :: &
-      sedtrcl
-   CHARACTER( len = 20 ), DIMENSION(jptrased) :: &
-      sedtrcd , sedtrcu
+   CHARACTER( len = 80 ), DIMENSION(jptrased  ) ::  sedtrcl
+   CHARACTER( len = 20 ), DIMENSION(jptrased  ) ::  sedtrcd , sedtrcu
+   CHARACTER( len = 80 ), DIMENSION(jpdia3dsed) ::  seddia3l 
+   CHARACTER( len = 20 ), DIMENSION(jpdia3dsed) ::  seddia3d, seddia3u
+   CHARACTER( len = 80 ), DIMENSION(jpdia2dsed) ::  seddia2l 
+   CHARACTER( len = 20 ), DIMENSION(jpdia2dsed) ::  seddia2d, seddia2u
+   !
+   REAL(wp), PUBLIC, DIMENSION(:,:,:,:), ALLOCATABLE ::  trcsedi
+   REAL(wp), PUBLIC, DIMENSION(:,:,:,:), ALLOCATABLE ::  flxsedi3d
+   REAL(wp), PUBLIC, DIMENSION(:,:,:  ), ALLOCATABLE ::  flxsedi2d
 
-   CHARACTER( len = 80 ), DIMENSION(jpdia3dsed) :: &
-      seddia3l 
-   CHARACTER( len = 20 ), DIMENSION(jpdia3dsed) :: &
-      seddia3d , seddia3u
+   INTEGER, PUBLIC ::  numsed = 27    ! units
 
-   CHARACTER( len = 80 ), DIMENSION(jpdia2dsed) :: &
-      seddia2l 
-   CHARACTER( len = 20 ), DIMENSION(jpdia2dsed) :: &
-      seddia2d , seddia2u
+CONTAINS
 
-   REAL(wp), DIMENSION(jpi,jpj,jpksed,jptrased) :: &
-      trcsedi
-   REAL(wp), DIMENSION(jpi,jpj,jpksed,jpdia3dsed) :: &
-      flxsedi3d
-   REAL(wp), DIMENSION(jpi,jpj,jpdia2dsed) :: &
-      flxsedi2d
+   INTEGER FUNCTION sed_alloc()
+      !!-------------------------------------------------------------------
+      !!                    *** ROUTINE sed_alloc ***
+      !!-------------------------------------------------------------------
+      USE lib_mpp, ONLY: ctl_warn
+      !!-------------------------------------------------------------------
+      !
+      ALLOCATE( trc_dta(jpi,jpj,jdta)                                     ,   &
+         &      epkbot(jpi,jpj), sbathy(jpi,jpj)                          ,   &
+         &      tmasksed(jpi,jpj,jpksed)                                  ,   &
+         &      dz(jpksed)  , por(jpksed) , por1(jpksed), profsed(jpksed) ,   &
+         &      volw(jpksed), vols(jpksed), diff(jpksed), rdtsed(jpksed)  ,   &
+         &      trcsedi  (jpi,jpj,jpksed,jptrased)                        ,   &
+         &      flxsedi3d(jpi,jpj,jpksed,jpdia3dsed)                      ,   &
+         &      flxsedi2d(jpi,jpj,jpksed,jpdia2dsed)                      ,   &
+         &      mol_wgt(jpsol),                                           STAT=sed_alloc )
 
-   !! Units
-   INTEGER, PUBLIC :: &
-     numsed = 27
+      IF( sed_alloc /= 0 )   CALL ctl_warn('sed_alloc: failed to allocate arrays')
+      !
+   END FUNCTION sed_alloc
+
 #else
    !!======================================================================
