Index: utils/tools/SIREN/src/boundary.f90
===================================================================
--- utils/tools/SIREN/src/boundary.f90	(revision 9621)
+++ utils/tools/SIREN/src/boundary.f90	(revision 12080)
@@ -2,6 +2,4 @@
 ! NEMO system team, System and Interface for oceanic RElocable Nesting
 !----------------------------------------------------------------------
-!
-! MODULE: boundary
 !
 ! DESCRIPTION:
@@ -106,5 +104,5 @@
 !>
 !> @author J.Paul
-! REVISION HISTORY:
+!>
 !> @date November, 2013 - Initial Version
 !> @date September, 2014 
@@ -119,7 +117,8 @@
 !> @todo add schematic to boundary structure description
 !> 
-!> @note Software governed by the CeCILL licence     (./LICENSE)
+!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
 !----------------------------------------------------------------------
 MODULE boundary
+
    USE netcdf                          ! nf90 library                           
    USE global                          ! global parameter
@@ -131,4 +130,5 @@
 
    IMPLICIT NONE
+
    ! NOTE_avoid_public_variables_if_possible
 
@@ -220,4 +220,7 @@
 
 CONTAINS
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   FUNCTION boundary__copy_arr(td_bdy) &
+         & RESULT (tf_bdy)
    !-------------------------------------------------------------------
    !> @brief
@@ -240,10 +243,12 @@
    !> @return copy of input array of boundary structure 
    !-------------------------------------------------------------------
-   FUNCTION boundary__copy_arr( td_bdy )
+
       IMPLICIT NONE
+
       ! Argument
-      TYPE(TBDY), DIMENSION(:), INTENT(IN)  :: td_bdy
+      TYPE(TBDY), DIMENSION(:)   , INTENT(IN) :: td_bdy
+
       ! function
-      TYPE(TBDY), DIMENSION(SIZE(td_bdy(:))) :: boundary__copy_arr
+      TYPE(TBDY), DIMENSION(SIZE(td_bdy(:)))  :: tf_bdy
 
       ! local variable
@@ -253,8 +258,11 @@
 
       DO jk=1,SIZE(td_bdy(:))
-         boundary__copy_arr(jk)=boundary_copy(td_bdy(jk))
+         tf_bdy(jk)=boundary_copy(td_bdy(jk))
       ENDDO
 
    END FUNCTION boundary__copy_arr
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   FUNCTION boundary__copy_unit(td_bdy) &
+         & RESULT (tf_bdy)
    !-------------------------------------------------------------------
    !> @brief
@@ -277,10 +285,12 @@
    !> @return copy of input boundary structure
    !-------------------------------------------------------------------
-   FUNCTION boundary__copy_unit( td_bdy )
+
       IMPLICIT NONE
+
       ! Argument
       TYPE(TBDY), INTENT(IN)  :: td_bdy
+
       ! function
-      TYPE(TBDY) :: boundary__copy_unit
+      TYPE(TBDY)              :: tf_bdy
 
       ! local variable
@@ -290,21 +300,23 @@
 
       ! copy variable name, id, ..
-      boundary__copy_unit%c_card     = TRIM(td_bdy%c_card)
-      boundary__copy_unit%i_nseg     = td_bdy%i_nseg
-      boundary__copy_unit%l_use      = td_bdy%l_use
+      tf_bdy%c_card     = TRIM(td_bdy%c_card)
+      tf_bdy%i_nseg     = td_bdy%i_nseg
+      tf_bdy%l_use      = td_bdy%l_use
 
       ! copy segment
-      IF( ASSOCIATED(boundary__copy_unit%t_seg) )THEN
-         CALL seg__clean(boundary__copy_unit%t_seg(:))
-         DEALLOCATE(boundary__copy_unit%t_seg)
+      IF( ASSOCIATED(tf_bdy%t_seg) )THEN
+         CALL seg__clean(tf_bdy%t_seg(:))
+         DEALLOCATE(tf_bdy%t_seg)
       ENDIF
-      IF( ASSOCIATED(td_bdy%t_seg) .AND. boundary__copy_unit%i_nseg > 0 )THEN
-         ALLOCATE( boundary__copy_unit%t_seg(boundary__copy_unit%i_nseg) )
-         DO ji=1,boundary__copy_unit%i_nseg
-            boundary__copy_unit%t_seg(ji)=td_bdy%t_seg(ji)
+      IF( ASSOCIATED(td_bdy%t_seg) .AND. tf_bdy%i_nseg > 0 )THEN
+         ALLOCATE( tf_bdy%t_seg(tf_bdy%i_nseg) )
+         DO ji=1,tf_bdy%i_nseg
+            tf_bdy%t_seg(ji)=td_bdy%t_seg(ji)
          ENDDO
       ENDIF
 
    END FUNCTION boundary__copy_unit
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary__clean_unit(td_bdy)
    !-------------------------------------------------------------------
    !> @brief This subroutine clean boundary structure
@@ -312,9 +324,12 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date January, 2019
+   !> - nullify segment structure inside boundary structure 
    !
    !> @param[inout] td_bdy boundary strucutre
    !-------------------------------------------------------------------
-   SUBROUTINE boundary__clean_unit( td_bdy )
+
       IMPLICIT NONE
+
       ! Argument
       TYPE(TBDY), INTENT(INOUT) :: td_bdy
@@ -334,4 +349,5 @@
          CALL seg__clean(td_bdy%t_seg(:) )
          DEALLOCATE( td_bdy%t_seg )
+         NULLIFY(td_bdy%t_seg)
       ENDIF
 
@@ -340,4 +356,6 @@
 
    END SUBROUTINE boundary__clean_unit
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary__clean_arr(td_bdy)
    !-------------------------------------------------------------------
    !> @brief This subroutine clean array of boundary structure
@@ -348,6 +366,7 @@
    !> @param[inout] td_bdy boundary strucutre
    !-------------------------------------------------------------------
-   SUBROUTINE boundary__clean_arr( td_bdy )
+
       IMPLICIT NONE
+
       ! Argument
       TYPE(TBDY), DIMENSION(:), INTENT(INOUT) :: td_bdy
@@ -363,4 +382,7 @@
 
    END SUBROUTINE boundary__clean_arr
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   FUNCTION boundary_set_filename(cd_file, cd_card, id_seg, cd_date) &
+         &  RESULT (cf_file)
    !------------------------------------------------------------------- 
    !> @brief This function put cardinal name and date inside file name.
@@ -389,6 +411,7 @@
    !> @return file name with cardinal name inside
    !------------------------------------------------------------------- 
-   FUNCTION boundary_set_filename(cd_file, cd_card, id_seg, cd_date) 
+
       IMPLICIT NONE 
+
       ! Argument
       CHARACTER(LEN=*), INTENT(IN) :: cd_file
@@ -398,5 +421,5 @@
 
       ! function 
-      CHARACTER(LEN=lc) :: boundary_set_filename
+      CHARACTER(LEN=lc)            :: cf_file
 
       ! local variable 
@@ -415,5 +438,5 @@
       !---------------------------------------------------------------- 
       ! init
-      boundary_set_filename=''
+      cf_file=''
 
       IF( TRIM(cd_file) /= '' .AND. TRIM(cd_card) /= '' )THEN
@@ -455,5 +478,5 @@
          ENDIF
 
-         boundary_set_filename=TRIM(cl_dirname)//"/"//TRIM(cl_name)
+         cf_file=TRIM(cl_dirname)//"/"//TRIM(cl_name)
       ELSE
          CALL logger_error("BOUNDARY SET FILENAME: file or cardinal name "//&
@@ -462,4 +485,10 @@
  
    END FUNCTION boundary_set_filename 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   FUNCTION boundary__init_wrapper(td_var,                               &
+         &                         ld_north, ld_south, ld_east, ld_west, &
+         &                         cd_north, cd_south, cd_east, cd_west, &
+         &                         ld_oneseg) &
+         &  RESULT (tf_bdy)
    !------------------------------------------------------------------- 
    !> @brief This function initialise a boundary structure.
@@ -503,9 +532,7 @@
    !> @return boundary structure
    !------------------------------------------------------------------- 
-   FUNCTION boundary__init_wrapper(td_var, &
-   &                               ld_north, ld_south, ld_east, ld_west, &
-   &                               cd_north, cd_south, cd_east, cd_west, &
-   &                               ld_oneseg ) 
+
       IMPLICIT NONE 
+
       ! Argument
       TYPE(TVAR)       , INTENT(IN) :: td_var
@@ -521,5 +548,5 @@
 
       ! function 
-      TYPE(TBDY), DIMENSION(ip_ncard) :: boundary__init_wrapper
+      TYPE(TBDY)       , DIMENSION(ip_ncard)  :: tf_bdy
 
       ! local variable 
@@ -532,5 +559,4 @@
       CHARACTER(LEN=lc), DIMENSION(ip_ncard) :: cl_card
 
-      TYPE(TBDY)       , DIMENSION(ip_ncard) :: tl_bdy
       TYPE(TBDY)                             :: tl_tmp
 
@@ -555,8 +581,8 @@
 
          ! init
-         tl_bdy(jp_north)=boundary__init('north',ld_north)
-         tl_bdy(jp_south)=boundary__init('south',ld_south)
-         tl_bdy(jp_east )=boundary__init('east ',ld_east )
-         tl_bdy(jp_west )=boundary__init('west ',ld_west )
+         tf_bdy(jp_north)=boundary__init('north',ld_north)
+         tf_bdy(jp_south)=boundary__init('south',ld_south)
+         tf_bdy(jp_east )=boundary__init('east ',ld_east )
+         tf_bdy(jp_west )=boundary__init('west ',ld_west )
 
          ! if EW cyclic no east west boundary and force to use one segment
@@ -564,6 +590,6 @@
             CALL logger_info("BOUNDARY INIT: cyclic domain, "//&
             &  "no East West boundary")
-            tl_bdy(jp_east )%l_use=.FALSE.
-            tl_bdy(jp_west )%l_use=.FALSE.
+            tf_bdy(jp_east )%l_use=.FALSE.
+            tf_bdy(jp_west )%l_use=.FALSE.
 
             CALL logger_info("BOUNDARY INIT: force to use one segment due"//&
@@ -618,5 +644,5 @@
             tl_seg=seg__init(il_index(jk),il_width,il_min(jk),il_max(jk))
 
-            IF( tl_bdy(jk)%l_use )THEN
+            IF( tf_bdy(jk)%l_use )THEN
 
                ! get namelist information
@@ -625,27 +651,27 @@
                ! get segments indices
                DO ji=1,tl_tmp%i_nseg
-                  CALL boundary__add_seg(tl_bdy(jk),tl_tmp%t_seg(ji))
+                  CALL boundary__add_seg(tf_bdy(jk),tl_tmp%t_seg(ji))
                ENDDO
                ! indices from namelist or not
-               tl_bdy(jk)%l_nam=tl_tmp%l_nam
+               tf_bdy(jk)%l_nam=tl_tmp%l_nam
 
                CALL boundary_clean(tl_tmp)
 
-               IF( tl_bdy(jk)%i_nseg == 0 )THEN
+               IF( tf_bdy(jk)%i_nseg == 0 )THEN
                   ! add default segment
-                  CALL boundary__add_seg(tl_bdy(jk),tl_seg)
+                  CALL boundary__add_seg(tf_bdy(jk),tl_seg)
                ELSE
                   ! fill undefined value
-                  WHERE( tl_bdy(jk)%t_seg(:)%i_index == 0 ) 
-                     tl_bdy(jk)%t_seg(:)%i_index = tl_seg%i_index
+                  WHERE( tf_bdy(jk)%t_seg(:)%i_index == 0 ) 
+                     tf_bdy(jk)%t_seg(:)%i_index = tl_seg%i_index
                   END WHERE               
-                  WHERE( tl_bdy(jk)%t_seg(:)%i_width == 0 ) 
-                     tl_bdy(jk)%t_seg(:)%i_width = tl_seg%i_width
+                  WHERE( tf_bdy(jk)%t_seg(:)%i_width == 0 ) 
+                     tf_bdy(jk)%t_seg(:)%i_width = tl_seg%i_width
                   END WHERE
-                  WHERE( tl_bdy(jk)%t_seg(:)%i_first == 0 ) 
-                     tl_bdy(jk)%t_seg(:)%i_first = tl_seg%i_first
+                  WHERE( tf_bdy(jk)%t_seg(:)%i_first == 0 ) 
+                     tf_bdy(jk)%t_seg(:)%i_first = tl_seg%i_first
                   END WHERE
-                  WHERE( tl_bdy(jk)%t_seg(:)%i_last == 0 ) 
-                     tl_bdy(jk)%t_seg(:)%i_last = tl_seg%i_last
+                  WHERE( tf_bdy(jk)%t_seg(:)%i_last == 0 ) 
+                     tf_bdy(jk)%t_seg(:)%i_last = tl_seg%i_last
                   END WHERE
                ENDIF
@@ -657,18 +683,14 @@
          ENDDO
 
-         CALL boundary_get_indices(tl_bdy(:), td_var, ll_oneseg)
-
-         CALL boundary_check(tl_bdy, td_var)
-
-         boundary__init_wrapper(:)=boundary_copy(tl_bdy(:))
-
-         ! clean
-         DO jk=1,ip_ncard
-            CALL boundary_clean(tl_bdy(jk))
-         ENDDO
+         CALL boundary_get_indices(tf_bdy(:), td_var, ll_oneseg)
+
+         CALL boundary_check(tf_bdy, td_var)
 
       ENDIF
  
    END FUNCTION boundary__init_wrapper 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   FUNCTION boundary__init(cd_card, ld_use, ld_nam, td_seg) &
+         &  RESULT (tf_bdy)
    !------------------------------------------------------------------- 
    !> @brief This function initialise basically a boundary structure with
@@ -687,6 +709,7 @@
    !> @return boundary structure
    !------------------------------------------------------------------- 
-   FUNCTION boundary__init( cd_card, ld_use, ld_nam, td_seg ) 
+
       IMPLICIT NONE 
+
       ! Argument
       CHARACTER(LEN=*), INTENT(IN) :: cd_card
@@ -696,8 +719,7 @@
 
       ! function 
-      TYPE(TBDY) :: boundary__init
+      TYPE(TBDY)                   :: tf_bdy
 
       ! local variable 
-      
       ! loop indices 
       !---------------------------------------------------------------- 
@@ -706,14 +728,14 @@
          CASE ('north','south','east','west')
          
-            boundary__init%c_card=TRIM(cd_card)
-
-            boundary__init%l_use=.TRUE.
-            IF( PRESENT(ld_use) ) boundary__init%l_use=ld_use
-
-            boundary__init%l_nam=.FALSE.
-            IF( PRESENT(ld_nam) ) boundary__init%l_nam=ld_nam
+            tf_bdy%c_card=TRIM(cd_card)
+
+            tf_bdy%l_use=.TRUE.
+            IF( PRESENT(ld_use) ) tf_bdy%l_use=ld_use
+
+            tf_bdy%l_nam=.FALSE.
+            IF( PRESENT(ld_nam) ) tf_bdy%l_nam=ld_nam
 
             IF( PRESENT(td_seg) )THEN
-               CALL boundary__add_seg(boundary__init, td_seg)
+               CALL boundary__add_seg(tf_bdy, td_seg)
             ENDIF
 
@@ -723,4 +745,6 @@
 
    END FUNCTION boundary__init
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary__add_seg(td_bdy, td_seg) 
    !------------------------------------------------------------------- 
    !> @brief This subroutine add one segment structure to a boundary structure 
@@ -734,6 +758,7 @@
    !> @param[in] td_seg    segment structure  
    !------------------------------------------------------------------- 
-   SUBROUTINE boundary__add_seg(td_bdy, td_seg) 
+
       IMPLICIT NONE 
+
       ! Argument 
       TYPE(TBDY), INTENT(INOUT) :: td_bdy
@@ -793,4 +818,6 @@
 
    END SUBROUTINE boundary__add_seg 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary__del_seg(td_bdy) 
    !------------------------------------------------------------------- 
    !> @brief This subroutine remove all segments of a boundary structure 
@@ -803,6 +830,7 @@
    !> @param[inout]  td_bdy   boundary structure
    !------------------------------------------------------------------- 
-   SUBROUTINE boundary__del_seg(td_bdy) 
+
       IMPLICIT NONE 
+
       ! Argument 
       TYPE(TBDY), INTENT(INOUT) :: td_bdy
@@ -820,4 +848,7 @@
 
    END SUBROUTINE boundary__del_seg 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   FUNCTION boundary__get_info(cd_card, id_jcard) &
+         & RESULT (tf_bdy)
    !------------------------------------------------------------------- 
    !> @brief This function get information about boundary from string character. 
@@ -839,6 +870,7 @@
    !> @return boundary structure
    !------------------------------------------------------------------- 
-   FUNCTION boundary__get_info(cd_card, id_jcard) 
+
       IMPLICIT NONE 
+
       ! Argument 
       CHARACTER(LEN=lc), INTENT(IN) :: cd_card
@@ -846,5 +878,5 @@
 
       ! function 
-      TYPE(TBDY) :: boundary__get_info
+      TYPE(TBDY)                    :: tf_bdy
 
       ! local variable 
@@ -876,5 +908,5 @@
          ! initialise boundary
          ! temporaty boundary, so it doesn't matter which caridnal is used
-         boundary__get_info=boundary__init('north',ld_nam=.TRUE.)
+         tf_bdy=boundary__init('north',ld_nam=.TRUE.)
 
          il_ind1=SCAN(fct_lower(cl_seg),'(')
@@ -953,5 +985,5 @@
          IF( (tl_seg%i_first == 0 .AND.  tl_seg%i_last == 0) .OR. &
          &   (tl_seg%i_first /= 0 .AND.  tl_seg%i_last /= 0) )THEN
-            CALL boundary__add_seg(boundary__get_info, tl_seg)
+            CALL boundary__add_seg(tf_bdy, tl_seg)
          ELSE
             CALL logger_error("BOUNDARY INIT: first or last segment indices "//&
@@ -967,4 +999,6 @@
 
    END FUNCTION boundary__get_info 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary_get_indices(td_bdy, td_var, ld_oneseg) 
    !------------------------------------------------------------------- 
    !> @brief This subroutine get indices of each semgent for each boundary.
@@ -989,6 +1023,7 @@
    !> @param[in] ld_onseg  use only one sgment for each boundary 
    !------------------------------------------------------------------- 
-   SUBROUTINE boundary_get_indices( td_bdy, td_var, ld_oneseg) 
+
       IMPLICIT NONE 
+
       ! Argument
       TYPE(TBDY) , DIMENSION(ip_ncard), INTENT(INOUT) :: td_bdy
@@ -1057,4 +1092,6 @@
 
    END SUBROUTINE boundary_get_indices 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary__get_seg_number(td_bdy, td_var) 
    !------------------------------------------------------------------- 
    !> @brief This subroutine compute the number of sea segment. 
@@ -1073,6 +1110,7 @@
    !> @param[in] td_var    variable structure 
    !------------------------------------------------------------------- 
-   SUBROUTINE boundary__get_seg_number( td_bdy, td_var) 
+
       IMPLICIT NONE 
+
       ! Argument
       TYPE(TBDY) , INTENT(INOUT) :: td_bdy
@@ -1155,4 +1193,7 @@
  
    END SUBROUTINE boundary__get_seg_number 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary__get_seg_indices(td_bdy, td_var, &
+         &                              id_index, id_width, id_first, id_last) 
    !------------------------------------------------------------------- 
    !> @brief This subroutine get segment indices for one boundary.
@@ -1170,7 +1211,7 @@
    !> @param[in] id_last   boundary last  indice
    !------------------------------------------------------------------- 
-   SUBROUTINE boundary__get_seg_indices( td_bdy, td_var, &
-   &                                     id_index, id_width, id_first, id_last) 
+
       IMPLICIT NONE 
+
       ! Argument
       TYPE(TBDY) , INTENT(INOUT) :: td_bdy
@@ -1305,4 +1346,6 @@
       
    END SUBROUTINE boundary__get_seg_indices 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary_check_corner(td_bdy, td_var)
    !------------------------------------------------------------------- 
    !> @brief This subroutine check if there is boundary at corner, and 
@@ -1322,6 +1365,7 @@
    !> @param[in] td_var    variable structure
    !------------------------------------------------------------------- 
-   SUBROUTINE boundary_check_corner( td_bdy, td_var )
+
       IMPLICIT NONE 
+
       ! Argument
       TYPE(TBDY) , DIMENSION(ip_ncard), INTENT(INOUT) :: td_bdy
@@ -1520,4 +1564,6 @@
 
    END SUBROUTINE boundary_check_corner 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary_check(td_bdy, td_var) 
    !------------------------------------------------------------------- 
    !> @brief This subroutine check boundary.
@@ -1536,6 +1582,7 @@
    !> @param[in] td_var    variable structure 
    !------------------------------------------------------------------- 
-   SUBROUTINE boundary_check(td_bdy, td_var) 
+
       IMPLICIT NONE 
+
       ! Argument
       TYPE(TBDY) , DIMENSION(ip_ncard), INTENT(INOUT) :: td_bdy
@@ -1594,4 +1641,6 @@
 
    END SUBROUTINE boundary_check
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary_swap(td_var, td_bdy)
    !-------------------------------------------------------------------
    !> @brief This subroutine swap array for east and north boundary.
@@ -1605,6 +1654,7 @@
    !> @param[in   ] td_bdy boundary strucutre
    !-------------------------------------------------------------------
-   SUBROUTINE boundary_swap( td_var, td_bdy )
+
       IMPLICIT NONE
+
       ! Argument
       TYPE(TVAR), INTENT(INOUT) :: td_var
@@ -1659,4 +1709,6 @@
       ENDIF
    END SUBROUTINE boundary_swap
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary__print_unit(td_bdy) 
    !------------------------------------------------------------------- 
    !> @brief This subroutine print information about one boundary. 
@@ -1667,8 +1719,10 @@
    !> @param[in] td_bdy boundary structure 
    !------------------------------------------------------------------- 
-   SUBROUTINE boundary__print_unit( td_bdy ) 
+
       IMPLICIT NONE 
+
       ! Argument
       TYPE(TBDY), INTENT(IN) :: td_bdy
+
       ! local variable 
       ! loop indices 
@@ -1688,4 +1742,6 @@
  
    END SUBROUTINE boundary__print_unit
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE boundary__print_arr(td_bdy) 
    !------------------------------------------------------------------- 
    !> @brief This subroutine print information about a array of boundary 
@@ -1698,8 +1754,10 @@
    !> @param[in] td_bdy boundary structure 
    !------------------------------------------------------------------- 
-   SUBROUTINE boundary__print_arr( td_bdy ) 
+
       IMPLICIT NONE 
+
       ! Argument
       TYPE(TBDY), DIMENSION(:), INTENT(IN) :: td_bdy
+
       ! local variable 
       ! loop indices 
@@ -1712,4 +1770,7 @@
  
    END SUBROUTINE boundary__print_arr
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   FUNCTION seg__copy_unit(td_seg) &
+         & RESULT (tf_seg)
    !-------------------------------------------------------------------
    !> @brief
@@ -1731,10 +1792,12 @@
    !> @return copy of input segment structure
    !-------------------------------------------------------------------
-   FUNCTION seg__copy_unit( td_seg )
+
       IMPLICIT NONE
+
       ! Argument
       TYPE(TSEG), INTENT(IN)  :: td_seg
+
       ! function
-      TYPE(TSEG) :: seg__copy_unit
+      TYPE(TSEG)              :: tf_seg
 
       ! local variable
@@ -1743,10 +1806,13 @@
 
       ! copy segment index, width, ..
-      seg__copy_unit%i_index    = td_seg%i_index
-      seg__copy_unit%i_width    = td_seg%i_width
-      seg__copy_unit%i_first    = td_seg%i_first
-      seg__copy_unit%i_last     = td_seg%i_last 
+      tf_seg%i_index    = td_seg%i_index
+      tf_seg%i_width    = td_seg%i_width
+      tf_seg%i_first    = td_seg%i_first
+      tf_seg%i_last     = td_seg%i_last 
 
    END FUNCTION seg__copy_unit
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   FUNCTION seg__copy_arr(td_seg) &
+         & RESULT (tf_seg)
    !-------------------------------------------------------------------
    !> @brief
@@ -1768,10 +1834,12 @@
    !> @return copy of input array of segment structure
    !-------------------------------------------------------------------
-   FUNCTION seg__copy_arr( td_seg )
+
       IMPLICIT NONE
+
       ! Argument
-      TYPE(TSEG), DIMENSION(:), INTENT(IN)  :: td_seg
+      TYPE(TSEG), DIMENSION(:), INTENT(IN)   :: td_seg
+
       ! function
-      TYPE(TSEG), DIMENSION(SIZE(td_seg(:))) :: seg__copy_arr
+      TYPE(TSEG), DIMENSION(SIZE(td_seg(:))) :: tf_seg
 
       ! local variable
@@ -1781,8 +1849,11 @@
 
       DO ji=1,SIZE(td_seg(:))
-         seg__copy_arr(ji)=seg__copy(td_seg(ji))
+         tf_seg(ji)=seg__copy(td_seg(ji))
       ENDDO
 
    END FUNCTION seg__copy_arr
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   FUNCTION seg__init(id_index, id_width, id_first, id_last) &
+         &  RESULT(tf_seg)
    !------------------------------------------------------------------- 
    !> @brief This function  initialise segment structure.
@@ -1801,6 +1872,7 @@
    !> @return segment structure
    !------------------------------------------------------------------- 
-   FUNCTION seg__init( id_index, id_width, id_first, id_last ) 
+
       IMPLICIT NONE 
+
       ! Argument
       INTEGER(i4), INTENT(IN) :: id_index
@@ -1810,5 +1882,5 @@
 
       ! function 
-      TYPE(TSEG) :: seg__init
+      TYPE(TSEG)              :: tf_seg
 
       ! local variable 
@@ -1817,11 +1889,13 @@
       !---------------------------------------------------------------- 
 
-      seg__init%i_index=id_index
-
-      IF( PRESENT(id_width) ) seg__init%i_width=id_width
-      IF( PRESENT(id_first) ) seg__init%i_first=id_first
-      IF( PRESENT(id_last ) ) seg__init%i_last =id_last
+      tf_seg%i_index=id_index
+
+      IF( PRESENT(id_width) ) tf_seg%i_width=id_width
+      IF( PRESENT(id_first) ) tf_seg%i_first=id_first
+      IF( PRESENT(id_last ) ) tf_seg%i_last =id_last
 
    END FUNCTION seg__init 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE seg__clean_unit(td_seg) 
    !------------------------------------------------------------------- 
    !> @brief This subroutine clean segment structure. 
@@ -1832,8 +1906,10 @@
    !> @param[inout] td_seg segment structure
    !------------------------------------------------------------------- 
-   SUBROUTINE seg__clean_unit(td_seg) 
+
       IMPLICIT NONE 
+
       ! Argument       
       TYPE(TSEG), INTENT(INOUT) :: td_seg
+
       ! local variable 
       TYPE(TSEG) :: tl_seg
@@ -1844,4 +1920,6 @@
  
    END SUBROUTINE seg__clean_unit
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   SUBROUTINE seg__clean_arr(td_seg) 
    !------------------------------------------------------------------- 
    !> @brief This subroutine clean segment structure. 
@@ -1852,8 +1930,10 @@
    !> @param[inout] td_seg array of segment structure
    !------------------------------------------------------------------- 
-   SUBROUTINE seg__clean_arr(td_seg) 
+
       IMPLICIT NONE 
+
       ! Argument       
       TYPE(TSEG), DIMENSION(:), INTENT(INOUT) :: td_seg
+
       ! local variable 
       ! loop indices 
@@ -1866,3 +1946,4 @@
  
    END SUBROUTINE seg__clean_arr 
+   !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 END MODULE boundary
