Index: branches/UKMO/dev_r5107_hadgem3_cplfld/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90
===================================================================
--- branches/UKMO/dev_r5107_hadgem3_cplfld/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90	(revision 5473)
+++ branches/UKMO/dev_r5107_hadgem3_cplfld/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90	(revision 5575)
@@ -140,4 +140,5 @@
       !!----------------------------------------------------------------------
       USE ldftra_oce, ONLY:   aht0
+      USE iom
       !
       LOGICAL, INTENT (in) ::   ld_print   ! If true, output arrays on numout
@@ -150,5 +151,5 @@
       CHARACTER (len=15) ::   clexp
       INTEGER,     POINTER, DIMENSION(:,:)  :: icof
-      INTEGER, ALLOCATABLE, DIMENSION(:,:)  :: idata
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ztemp2d  ! temporary array to read ahmcoef file
       !!----------------------------------------------------------------------
       !                                
@@ -232,45 +233,12 @@
          ! Read 2d integer array to specify western boundary increase in the
          ! ===================== equatorial strip (20N-20S) defined at t-points
-         
-         ALLOCATE( idata(jpidta,jpjdta), STAT=ierror )
-         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'ldf_dyn_c2d_orca: unable to allocate idata array' )
          !
-         CALL ctl_opn( inum, 'ahmcoef', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
-         READ(inum,9101) clexp, iim, ijm
-         READ(inum,'(/)')
-         ifreq = 40
-         il1 = 1
-         DO jn = 1, jpidta/ifreq+1
-            READ(inum,'(/)')
-            il2 = MIN( jpidta, il1+ifreq-1 )
-            READ(inum,9201) ( ii, ji = il1, il2, 5 )
-            READ(inum,'(/)')
-            DO jj = jpjdta, 1, -1
-               READ(inum,9202) ij, ( idata(ji,jj), ji = il1, il2 )
-            END DO
-            il1 = il1 + ifreq
-         END DO
-
-         DO jj = 1, nlcj
-            DO ji = 1, nlci
-               icof(ji,jj) = idata( mig(ji), mjg(jj) )
-            END DO
-         END DO
-         DO jj = nlcj+1, jpj
-            DO ji = 1, nlci
-               icof(ji,jj) = icof(ji,nlcj)
-            END DO
-         END DO
-         DO jj = 1, jpj
-            DO ji = nlci+1, jpi
-               icof(ji,jj) = icof(nlci,jj)
-            END DO
-         END DO
-
-9101     FORMAT(1x,a15,2i8)
-9201     FORMAT(3x,13(i3,12x))
-9202     FORMAT(i3,41i3)
-         
-         DEALLOCATE(idata)
+         ALLOCATE( ztemp2d(jpi,jpj) )
+         ztemp2d(:,:) = 0.
+         CALL iom_open ( 'ahmcoef.nc', inum )
+         CALL iom_get  ( inum, jpdom_data, 'icof', ztemp2d)
+         icof(:,:)  = NINT(ztemp2d(:,:))
+         CALL iom_close( inum )
+         DEALLOCATE(ztemp2d)
 
          ! Set ahm1 and ahm2  ( T- and F- points) (used for laplacian operator)
@@ -369,4 +337,5 @@
       !!----------------------------------------------------------------------
       USE ldftra_oce, ONLY:   aht0
+      USE iom
       !
       LOGICAL, INTENT (in) ::   ld_print   ! If true, output arrays on numout
@@ -380,10 +349,9 @@
       CHARACTER (len=15) ::   clexp
       INTEGER,     POINTER, DIMENSION(:,:)  :: icof
-      INTEGER, ALLOCATABLE, DIMENSION(:,:)  :: idata
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ztemp2d  ! temporary array to read ahmcoef file
       !!----------------------------------------------------------------------
       !                                
       CALL wrk_alloc( jpi   , jpj   , icof  )
       !                                
-
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) 'inildf: 2d eddy viscosity coefficient'
@@ -464,47 +432,11 @@
          ! Read 2d integer array to specify western boundary increase in the
          ! ===================== equatorial strip (20N-20S) defined at t-points
-         
-         ALLOCATE( idata(jpidta,jpjdta), STAT=ierror )
-         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'ldf_dyn_c2d_orca_R1: unable to allocate idata array' )
-         !
-         CALL ctl_opn( inum, 'ahmcoef', 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
-            &           1, numout, lwp )
-         REWIND inum
-         READ(inum,9101) clexp, iim, ijm
-         READ(inum,'(/)')
-         ifreq = 40
-         il1 = 1
-         DO jn = 1, jpidta/ifreq+1
-            READ(inum,'(/)')
-            il2 = MIN( jpidta, il1+ifreq-1 )
-            READ(inum,9201) ( ii, ji = il1, il2, 5 )
-            READ(inum,'(/)')
-            DO jj = jpjdta, 1, -1
-               READ(inum,9202) ij, ( idata(ji,jj), ji = il1, il2 )
-            END DO
-            il1 = il1 + ifreq
-         END DO
-
-         DO jj = 1, nlcj
-            DO ji = 1, nlci
-               icof(ji,jj) = idata( mig(ji), mjg(jj) )
-            END DO
-         END DO
-         DO jj = nlcj+1, jpj
-            DO ji = 1, nlci
-               icof(ji,jj) = icof(ji,nlcj)
-            END DO
-         END DO
-         DO jj = 1, jpj
-            DO ji = nlci+1, jpi
-               icof(ji,jj) = icof(nlci,jj)
-            END DO
-         END DO
-
-9101     FORMAT(1x,a15,2i8)
-9201     FORMAT(3x,13(i3,12x))
-9202     FORMAT(i3,41i3)
-         
-         DEALLOCATE(idata)
+         ALLOCATE( ztemp2d(jpi,jpj) )
+         ztemp2d(:,:) = 0.
+         CALL iom_open ( 'ahmcoef.nc', inum )
+         CALL iom_get  ( inum, jpdom_data, 'icof', ztemp2d)
+         icof(:,:)  = NINT(ztemp2d(:,:))
+         CALL iom_close( inum )
+         DEALLOCATE(ztemp2d)
 
          ! Set ahm1 and ahm2  ( T- and F- points) (used for laplacian operator)
