Index: branches/2016/dev_CNRS_MERCATOR_2016/NEMOGCM/TOOLS/SIREN/src/variable.f90
===================================================================
--- branches/2016/dev_CNRS_MERCATOR_2016/NEMOGCM/TOOLS/SIREN/src/variable.f90	(revision 7389)
+++ branches/2016/dev_CNRS_MERCATOR_2016/NEMOGCM/TOOLS/SIREN/src/variable.f90	(revision 7390)
@@ -34,5 +34,5 @@
 !>    Note:<br/>
 !>       - others optionals arguments could be added, see var_init.
-!>       - to put variable 0D, use td_dim with all dimension unused
+!>       - to put scalar variable (OD), use td_dim with all dimension unused
 !> (td_dim(:)%l_use=.FALSE.)
 !>    
@@ -267,4 +267,9 @@
 !>    - cd_varinfo is variable information from namelist
 !>
+!>    to clean global array of variable structure:<br/>
+!>@code
+!>    CALL var_clean_extra( )
+!>@endcode
+!>
 !>    to check variable dimension expected, as defined in file 'variable.cfg':<br/>
 !>@code
@@ -287,5 +292,8 @@
 !> @date Spetember, 2015
 !> - manage useless (dummy) variable
-!
+!> @date October, 2016
+!> - add subroutine to clean global array of extra information.
+!> - define logical for variable to be used
+!>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
 !----------------------------------------------------------------------
@@ -337,4 +345,5 @@
    PUBLIC :: var_def_extra     !< read variable configuration file, and save extra information.
    PUBLIC :: var_chg_extra     !< read variable namelist information, and modify extra information.
+   PUBLIC :: var_clean_extra   !< clean gloabl array of extra information.
    PUBLIC :: var_check_dim     !< check variable dimension expected
    PUBLIC :: var_get_dummy     !< fill dummy variable array
@@ -416,5 +425,6 @@
       TYPE(TDIM), DIMENSION(ip_maxdim)  :: t_dim           !< variable dimension
  
-      LOGICAL           :: l_file = .FALSE.  !< variable read in a file
+      LOGICAL           :: l_file = .FALSE. !< variable read in a file
+      LOGICAL           :: l_use  = .TRUE.  !< variable to be used
 
       ! highlight some attributes
@@ -451,5 +461,5 @@
                                                         !< fill when running var_def_extra() 
 
-   CHARACTER(LEN=lc), DIMENSION(ip_maxdum), SAVE :: cm_dumvar !< dummy variable
+   CHARACTER(LEN=lc), DIMENSION(ip_maxdumcfg), SAVE :: cm_dumvar !< dummy variable
 
    INTERFACE var_init
@@ -593,4 +603,7 @@
          CALL att_clean(tl_att)
       ENDIF
+
+      var__copy_unit%l_file     = td_var%l_file
+      var__copy_unit%l_use      = td_var%l_use
 
       ! copy highlight attribute
@@ -1126,4 +1139,6 @@
    !> @date July, 2015
    !> - add unit factor (to change unit)
+   !> @date November, 2016
+   !> - allow to add scalar value
    !>
    !> @param[in] cd_name         variable name
@@ -1279,6 +1294,13 @@
          dl_value(1,1,1,:) = dd_value(:)
       ELSE
-         CALL logger_fatal("VAR INIT: can not add value from variable "//&
-         &  TRIM(cd_name)//". invalid dimension to be used")
+         IF( SIZE(dd_value(:)) > 1 )THEN
+            CALL logger_fatal("VAR INIT: can not add value from variable "//&
+            &  TRIM(cd_name)//". invalid dimension to be used")
+         ELSE
+            dl_value(1,1,1,1) = dd_value(1)
+            CALL logger_warn("VAR INIT: add scalar value for variable "//&
+            &  TRIM(cd_name))
+
+         ENDIF
       ENDIF
 
@@ -6669,4 +6691,5 @@
       ! check if variable is in array of variable structure
       DO ji=1,il_size
+
          ! look for variable name
          IF( fct_lower(td_var(ji)%c_name) == fct_lower(cd_name) )THEN
@@ -6683,4 +6706,5 @@
 
          ELSE IF( PRESENT(cd_stdname) )THEN 
+
             IF( fct_lower(td_var(ji)%c_stdname) == fct_lower(cd_stdname) .AND.&
             &    TRIM(fct_lower(td_var(ji)%c_stdname)) /= '' )THEN
@@ -6690,10 +6714,21 @@
             ENDIF
 
+         ENDIF
+
          ! look for variable longname
-         ELSE IF( fct_lower(td_var(ji)%c_longname) == fct_lower(cd_name) .AND.&
-         &    TRIM(fct_lower(td_var(ji)%c_longname)) /= '' )THEN
+         IF( fct_lower(td_var(ji)%c_longname) == fct_lower(cd_name) .AND.&
+         &   TRIM(fct_lower(td_var(ji)%c_longname)) /= '' )THEN
             
             var_get_index=ji
             EXIT
+
+         ELSE IF( PRESENT(cd_stdname) )THEN
+
+            IF( fct_lower(td_var(ji)%c_longname) == fct_lower(cd_stdname) .AND.&
+            &    TRIM(fct_lower(td_var(ji)%c_longname)) /= '' )THEN
+            
+               var_get_index=ji
+               EXIT
+            ENDIF
 
          ENDIF
@@ -6734,4 +6769,5 @@
       ! check if variable is in array of variable structure
       DO ji=1,il_size
+      
          ! look for variable name
          IF( fct_lower(td_var(ji)%c_name) == fct_lower(cd_name) )THEN
@@ -6747,12 +6783,6 @@
             EXIT
 
-         ! look for variable long name
-         ELSE IF( fct_lower(td_var(ji)%c_longname) == fct_lower(cd_name) .AND.&
-         &    TRIM(fct_lower(td_var(ji)%c_longname)) /= '' )THEN
-            
-            var_get_id=td_var(ji)%i_id
-            EXIT
-
-         ELSE IF( PRESENT(cd_stdname) )THEN 
+         ELSE IF( PRESENT(cd_stdname) )THEN
+
             IF( fct_lower(td_var(ji)%c_stdname) == fct_lower(cd_stdname) .AND.&
             &    TRIM(fct_lower(td_var(ji)%c_stdname)) /= '' )THEN
@@ -6761,4 +6791,23 @@
                EXIT
             ENDIF
+
+         ENDIF
+
+         ! look for variable long name
+         IF( fct_lower(td_var(ji)%c_longname) == fct_lower(cd_name) .AND.&
+         &    TRIM(fct_lower(td_var(ji)%c_longname)) /= '' )THEN
+            
+            var_get_id=td_var(ji)%i_id
+            EXIT
+
+         ELSE IF( PRESENT(cd_stdname) )THEN 
+
+            IF( fct_lower(td_var(ji)%c_longname) == fct_lower(cd_stdname) .AND.&
+            &    TRIM(fct_lower(td_var(ji)%c_longname)) /= '' )THEN
+            
+               var_get_id=td_var(ji)%i_id
+               EXIT
+            ENDIF
+
          ENDIF
 
@@ -7176,6 +7225,23 @@
    !-------------------------------------------------------------------
    !> @brief
+   !> This subroutine clean global array of variable structure 
+   !> with extra information: tg_varextra.
+   !> 
+   !> @author J.Paul
+   !> @date October, 2016 - Initial Version
+   !-------------------------------------------------------------------
+   SUBROUTINE var_clean_extra( )
+      IMPLICIT NONE
+      ! Argument
+      !----------------------------------------------------------------
+
+      CALL var_clean(tg_varextra(:))
+      DEALLOCATE(tg_varextra)
+
+   END SUBROUTINE var_clean_extra
+   !-------------------------------------------------------------------
+   !> @brief
    !> This subroutine read matrix value from character string in namelist
-   !> and fill variable strucutre value.
+   !> and fill variable structure value.
    !>
    !> @details
@@ -8463,7 +8529,7 @@
       ! loop indices
       ! namelist
-      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumvar
-      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumdim
-      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumatt
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdumcfg) :: cn_dumvar
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdumcfg) :: cn_dumdim
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdumcfg) :: cn_dumatt
 
       !----------------------------------------------------------------
@@ -8526,5 +8592,5 @@
 
       var_is_dummy=.FALSE.
-      DO ji=1,ip_maxdum
+      DO ji=1,ip_maxdumcfg
          IF( fct_lower(td_var%c_name) == fct_lower(cm_dumvar(ji)) )THEN
             var_is_dummy=.TRUE.
