Index: trunk/NEMO/LIM_SRC/limdia.F90
===================================================================
--- trunk/NEMO/LIM_SRC/limdia.F90	(revision 623)
+++ trunk/NEMO/LIM_SRC/limdia.F90	(revision 624)
@@ -241,6 +241,6 @@
        ! opening  "ice_evolu" file
        irecl = ( jpchinf + 1 ) * nvinfo 
-       OPEN( numevo_ice, file='ice.evolu', status='unknown', RECL = irecl)
-       OPEN( numevo_ice, file='ice.evolu', status='unknown')
+       CALL ctlopn( numevo_ice, 'ice_evolu', 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
+          &           irecl, numout, .TRUE., 1 )
 
        !- ecriture de 2 lignes d''entete :
Index: trunk/NEMO/OPA_SRC/IOM/in_out_manager.F90
===================================================================
--- trunk/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 623)
+++ trunk/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 624)
@@ -56,17 +56,16 @@
    !!                        logical units
    !!----------------------------------------------------------------------
-   INTEGER            ::   numstp     =  1        !: logical unit for time step
-   INTEGER            ::   numout     =  2        !: logical unit for output print
-   INTEGER            ::   numid                  !: logical unit for debug print
-   INTEGER            ::   numnam     =  3        !: logical unit for namelist
-   INTEGER            ::   numnam_ice =  4        !: logical unit for ice namelist
-   INTEGER            ::   numevo_ice = 17        !: logical unit for ice variables (temp. evolution)
-   INTEGER            ::   numsol     = 25        !: logical unit for solver statistics
-   INTEGER            ::   numwri     = 40        !: logical unit for output write
-   INTEGER            ::   numisp     = 41        !: logical unit for island statistics
-   INTEGER            ::   numgap     = 45        !: logical unit for differences diagnostic
-   INTEGER            ::   numbol     = 67        !: logical unit for "bol" diagnostics
-   INTEGER            ::   numptr     = 68        !: logical unit for Poleward TRansports
-   INTEGER            ::   numflo     = 69        !: logical unit for drifting floats
+   INTEGER            ::   numstp                 !: logical unit for time step
+   INTEGER            ::   numout                 !: logical unit for output print
+   INTEGER            ::   numnam                 !: logical unit for namelist
+   INTEGER            ::   numnam_ice             !: logical unit for ice namelist
+   INTEGER            ::   numevo_ice             !: logical unit for ice variables (temp. evolution)
+   INTEGER            ::   numsol                 !: logical unit for solver statistics
+   INTEGER            ::   numwri                 !: logical unit for output write
+   INTEGER            ::   numisp                 !: logical unit for island statistics
+   INTEGER            ::   numgap                 !: logical unit for differences diagnostic
+   INTEGER            ::   numbol                 !: logical unit for "bol" diagnostics
+   INTEGER            ::   numptr                 !: logical unit for Poleward TRansports
+   INTEGER            ::   numflo                 !: logical unit for drifting floats
 
    !!----------------------------------------------------------------------
@@ -158,5 +157,5 @@
      LOGICAL :: llopn 
      !---------------------------------------------------------------------
-     getunit = 50   ! choose a unit that is big enough then it is
+     getunit = 15   ! choose a unit that is big enough then it is
                     !  not already used in OPA
      llopn = .TRUE.
Index: trunk/NEMO/OPA_SRC/ctlopn.F90
===================================================================
--- trunk/NEMO/OPA_SRC/ctlopn.F90	(revision 623)
+++ trunk/NEMO/OPA_SRC/ctlopn.F90	(revision 624)
@@ -15,16 +15,14 @@
       USE Agrif_Util
 #endif
+      USE in_out_manager
       IMPLICIT NONE
 
+      INTEGER, INTENT( out ) ::   &
+         knum      ! logical unit to open
       INTEGER, INTENT( in ) ::   &
-#if !defined key_agrif
-         knum,     & ! logical unit to open
-#endif
          krequ,    & ! =1 file required (stop if not exist)
          !           ! =0 file not required (create the file if does not exist)
          kout,     & ! number of logical units for write
          klengh      ! record length
-
-      INTEGER ::   iost
       CHARACTER (len=* ), INTENT( in ) ::   &
          cdacce,   & ! access specifier
@@ -34,15 +32,12 @@
       CHARACTER (len=* ), INTENT( in ) ::   &
          cdfile      ! file name to open
-#endif
-
-      LOGICAL ::  ldwp   ! boolean term for print
-
-#if defined key_agrif
-      LOGICAL :: op
-      INTEGER, INTENT( inout ) ::   &
-         knum      ! logical unit to open
+#else
       CHARACTER (len=* ), INTENT( inout ) ::   &
          cdfile      ! file name to open
 #endif
+
+      INTEGER ::   iost
+      LOGICAL ::  ldwp   ! boolean term for print
+
       !!----------------------------------------------------------------------
       !!  OPA 9.0 , LOCEAN-IPSL (2005) 
@@ -55,8 +50,7 @@
          cdfile= TRIM(Agrif_CFixed())//'_'//TRIM(cdfile)
       endif
-      INQUIRE(UNIT=knum,OPENED=op)
-      IF (op) THEN
         knum=Agrif_Get_Unit()
-      ENDIF
+#else
+        knum=getunit()
 #endif
 
Index: trunk/NEMO/OPA_SRC/mppini.F90
===================================================================
--- trunk/NEMO/OPA_SRC/mppini.F90	(revision 623)
+++ trunk/NEMO/OPA_SRC/mppini.F90	(revision 624)
@@ -345,7 +345,6 @@
      ! Save processor layout in layout.dat file 
        IF (lwp) THEN
-        inum = 11    
-
-        OPEN(inum,FILE='layout.dat')
+        CALL ctlopn( inum, 'layout.dat', 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
+           &         1, numout, .FALSE., 1 )
         WRITE(inum,'(a)') '   jpnij     jpi     jpj     jpk  jpiglo  jpjglo'
         WRITE(inum,'(6i8)') jpnij,jpi,jpj,jpk,jpiglo,jpjglo
Index: trunk/NEMO/OPA_SRC/mppini_2.h90
===================================================================
--- trunk/NEMO/OPA_SRC/mppini_2.h90	(revision 623)
+++ trunk/NEMO/OPA_SRC/mppini_2.h90	(revision 624)
@@ -466,6 +466,6 @@
       ! Save processor layout in ascii file
       IF (lwp) THEN
-         inum = 11 ! how do we know that 11 is ok???
-         OPEN(inum,FILE='layout.dat')
+         CALL ctlopn( inum, 'layout.dat', 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
+            &         1, numout, .FALSE., 1 )
          WRITE(inum,'(6i8)') jpnij,jpi,jpj,jpk,jpiglo,jpjglo
          WRITE(inum,'(a)') 'NAREA nlci nlcj nldi nldj nlei nlej nimpp njmpp'
Index: trunk/NEMO/OPA_SRC/opa.F90
===================================================================
--- trunk/NEMO/OPA_SRC/opa.F90	(revision 623)
+++ trunk/NEMO/OPA_SRC/opa.F90	(revision 624)
@@ -190,8 +190,6 @@
       
       ! open listing and namelist units
-      IF ( numout /= 0 .AND. numout /= 6 ) THEN 
-         CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
-            &         'SEQUENTIAL', 1, numout, .FALSE., 1 )
-      ENDIF
+      CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
+         &         'SEQUENTIAL', 1, numout, .FALSE., 1 )
 
       WRITE(numout,*)
Index: trunk/NEMO/OPA_SRC/prtctl.F90
===================================================================
--- trunk/NEMO/OPA_SRC/prtctl.F90	(revision 623)
+++ trunk/NEMO/OPA_SRC/prtctl.F90	(revision 624)
@@ -12,4 +12,5 @@
 
    !! * Module declaration
+   INTEGER, DIMENSION(:), ALLOCATABLE :: numid
    INTEGER, DIMENSION(:), ALLOCATABLE, SAVE ::   &  !:
       nlditl , nldjtl ,   &  !: first, last indoor index for each i-domain
@@ -91,5 +92,5 @@
 
       !! * Local declarations
-      INTEGER :: overlap, numid, jn, sind, eind, kdir
+      INTEGER :: overlap, jn, sind, eind, kdir,j_id
       CHARACTER (len=15) :: cl2
       REAL(wp) :: zsum1, zsum2, zvctl1, zvctl2
@@ -136,7 +137,6 @@
       ! Loop over each sub-domain, i.e. the total number of processors ijsplt
       DO jn = sind, eind
-
-         numid = 90 + jn
-
+         ! Set logical unit
+         j_id =jn - narea + 1
          ! Set indices for the SUM control
          IF( .NOT. lsp_area ) THEN
@@ -187,5 +187,5 @@
          ! Print the result
          IF( PRESENT(clinfo3) )   THEN
-            WRITE(numid,FMT='(a,D23.16,3x,a,D23.16)')clinfo1, zsum1-zvctl1, cl2, zsum2-zvctl2
+            WRITE(numid(j_id),FMT='(a,D23.16,3x,a,D23.16)')clinfo1, zsum1-zvctl1, cl2, zsum2-zvctl2
             SELECT CASE( clinfo3 )
             CASE ( 'tra-ta' ) 
@@ -199,7 +199,7 @@
             END SELECT
          ELSEIF ( PRESENT(clinfo2) .OR. PRESENT(tab2d_2) .OR. PRESENT(tab3d_2) )   THEN
-            WRITE(numid,FMT='(a,D23.16,3x,a,D23.16)')clinfo1, zsum1, cl2, zsum2
+            WRITE(numid(j_id),FMT='(a,D23.16,3x,a,D23.16)')clinfo1, zsum1, cl2, zsum2
          ELSE
-            WRITE(numid,FMT='(a,D23.16)')clinfo1, zsum1
+            WRITE(numid(j_id),FMT='(a,D23.16)')clinfo1, zsum1
          ENDIF
 
@@ -232,5 +232,5 @@
 
       !! * Local declarations
-      INTEGER ::  numid, jn, sind, eind, iltime
+      INTEGER :: jn, sind, eind, iltime, j_id
       !!----------------------------------------------------------------------
 
@@ -257,17 +257,18 @@
       ! Loop over each sub-domain, i.e. number of processors ijsplt
       DO jn = sind, eind
-
-         numid = 90 + jn
+         
+         ! Set logical unit
+         j_id = jn - narea +1
 
          IF( PRESENT(ivar1) .AND. PRESENT(clinfo2) .AND. PRESENT(ivar2) )   THEN
-            WRITE(numid,*)clinfo1, ivar1, clinfo2, ivar2
+            WRITE(numid(j_id),*)clinfo1, ivar1, clinfo2, ivar2
          ELSEIF ( PRESENT(ivar1) .AND. PRESENT(clinfo2) .AND. .NOT. PRESENT(ivar2) )   THEN
-            WRITE(numid,*)clinfo1, ivar1, clinfo2
+            WRITE(numid(j_id),*)clinfo1, ivar1, clinfo2
          ELSEIF ( PRESENT(ivar1) .AND. .NOT. PRESENT(clinfo2) .AND. PRESENT(ivar2) )   THEN
-            WRITE(numid,*)clinfo1, ivar1, ivar2
+            WRITE(numid(jn-narea+1),*)clinfo1, ivar1, ivar2
          ELSEIF ( PRESENT(ivar1) .AND. .NOT. PRESENT(clinfo2) .AND. .NOT. PRESENT(ivar2) )   THEN
-            WRITE(numid,*)clinfo1, ivar1
+            WRITE(numid(j_id),*)clinfo1, ivar1
          ELSE
-            WRITE(numid,*)clinfo1
+            WRITE(numid(j_id),*)clinfo1
          ENDIF
 
@@ -287,5 +288,5 @@
       !!----------------------------------------------------------------------
       !! * Local declarations
-      INTEGER ::   jn, numid, sind, eind
+      INTEGER ::   jn, sind, eind, j_id
       CHARACTER (len=28) :: clfile_out
       CHARACTER (len=23) :: clb_name
@@ -344,17 +345,20 @@
       ENDIF
 
+      ALLOCATE(numid(eind-sind+1))
+
       DO jn = sind, eind
-         numid = 90 + jn
          WRITE(clfile_out,FMT=clb_name) jn-1
-         OPEN ( UNIT=numid, FILE=TRIM(clfile_out),FORM='FORMATTED' )
-         WRITE(numid,*)
-         WRITE(numid,*) '                 L O D Y C - I P S L'
-         WRITE(numid,*) '                     O P A model'
-         WRITE(numid,*) '            Ocean General Circulation Model'
-         WRITE(numid,*) '               version OPA 9.0  (2005) '
-         WRITE(numid,*)
-         WRITE(numid,*) '                   PROC number: ', jn
-         WRITE(numid,*)
-         WRITE(numid,FMT="(19x,a20)")cl_run
+         j_id = jn -narea + 1
+         CALL ctlopn( numid(j_id), clfile_out, 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
+            &         1, numout, .FALSE., 1 )
+         WRITE(numid(j_id),*)
+         WRITE(numid(j_id),*) '                 L O D Y C - I P S L'
+         WRITE(numid(j_id),*) '                     O P A model'
+         WRITE(numid(j_id),*) '            Ocean General Circulation Model'
+         WRITE(numid(j_id),*) '               version OPA 9.0  (2005) '
+         WRITE(numid(j_id),*)
+         WRITE(numid(j_id),*) '                   PROC number: ', jn
+         WRITE(numid(j_id),*)
+         WRITE(numid(j_id),FMT="(19x,a20)")cl_run
 
          ! Print the SUM control indices
@@ -365,22 +369,22 @@
             njctle = njmpptl(jn) + nlejtl(jn) - 1
          ENDIF
-         WRITE(numid,*) 
-         WRITE(numid,*) 'prt_ctl :  Sum control indices'
-         WRITE(numid,*) '~~~~~~~'
-         WRITE(numid,*)
-         WRITE(numid,9000)'                                nlej   = ', nlejtl(jn), '              '
-         WRITE(numid,9000)'                  ------------- njctle = ', njctle, ' -------------'
-         WRITE(numid,9001)'                  |                                       |'
-         WRITE(numid,9001)'                  |                                       |'
-         WRITE(numid,9001)'                  |                                       |'
-         WRITE(numid,9002)'           nictls = ', nictls,  '                           nictle = ', nictle
-         WRITE(numid,9002)'           nldi   = ', nlditl(jn),  '                           nlei   = ', nleitl(jn)
-         WRITE(numid,9001)'                  |                                       |'
-         WRITE(numid,9001)'                  |                                       |'
-         WRITE(numid,9001)'                  |                                       |'
-         WRITE(numid,9004)'  njmpp  = ',njmpptl(jn),'   ------------- njctls = ', njctls, ' -------------'
-         WRITE(numid,9003)'           nimpp  = ', nimpptl(jn), '        nldj   = ', nldjtl(jn), '              '
-         WRITE(numid,*)
-         WRITE(numid,*)
+         WRITE(numid(j_id),*) 
+         WRITE(numid(j_id),*) 'prt_ctl :  Sum control indices'
+         WRITE(numid(j_id),*) '~~~~~~~'
+         WRITE(numid(j_id),*)
+         WRITE(numid(j_id),9000)'                                nlej   = ', nlejtl(jn), '              '
+         WRITE(numid(j_id),9000)'                  ------------- njctle = ', njctle, ' -------------'
+         WRITE(numid(j_id),9001)'                  |                                       |'
+         WRITE(numid(j_id),9001)'                  |                                       |'
+         WRITE(numid(j_id),9001)'                  |                                       |'
+         WRITE(numid(j_id),9002)'           nictls = ', nictls,  '                           nictle = ', nictle
+         WRITE(numid(j_id),9002)'           nldi   = ', nlditl(jn),  '                           nlei   = ', nleitl(jn)
+         WRITE(numid(j_id),9001)'                  |                                       |'
+         WRITE(numid(j_id),9001)'                  |                                       |'
+         WRITE(numid(j_id),9001)'                  |                                       |'
+         WRITE(numid(j_id),9004)'  njmpp  = ',njmpptl(jn),'   ------------- njctls = ', njctls, ' -------------'
+         WRITE(numid(j_id),9003)'           nimpp  = ', nimpptl(jn), '        nldj   = ', nldjtl(jn), '              '
+         WRITE(numid(j_id),*)
+         WRITE(numid(j_id),*)
 
 9000     FORMAT(a41,i4.4,a14)
