Index: trunk/NEMO/OPA_SRC/prtctl.F90
===================================================================
--- trunk/NEMO/OPA_SRC/prtctl.F90	(revision 516)
+++ 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)
