Index: trunk/NEMO/OPA_SRC/DTA/dtatem.F90
===================================================================
--- trunk/NEMO/OPA_SRC/DTA/dtatem.F90	(revision 440)
+++ trunk/NEMO/OPA_SRC/DTA/dtatem.F90	(revision 459)
@@ -83,5 +83,8 @@
       INTEGER, PARAMETER ::   &
          jpmois = 12                    ! number of month
-      INTEGER ::   ji, jj, jl           ! dummy loop indicies
+      INTEGER ::   ji, jj, jk, jl, jkk  ! dummy loop indicies
+      REAL(wp), DIMENSION(jpk,2) ::   &
+         ztemdta            ! auxiliary array for interpolation
+
       INTEGER ::   &
          imois, iman, itime, ik ,    &  ! temporary integers
@@ -98,188 +101,219 @@
       !!----------------------------------------------------------------------
 
-      ! 0. Initialization
-      ! -----------------
-
-      iman  = jpmois
-      i15   = nday / 16
-      imois = nmonth + i15 - 1
-      IF( imois == 0 )   imois = iman
-
-      itime = jpmois
-      ipi = jpiglo
-      ipj = jpjglo
-      ipk = jpk
-
-      ! 1. First call kt=nit000
-      ! -----------------------
-
-      IF( kt == nit000 .AND. nlecte == 0 ) THEN
-         ntem1 = 0
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' dtatem : Levitus monthly fields'
-         IF(lwp) WRITE(numout,*) ' ~~~~~~'
-         IF(lwp) WRITE(numout,*) '             NetCDF FORMAT'
-         IF(lwp) WRITE(numout,*)
-         
-         ! open file
-
-         cl_tdata = 'data_1m_potential_temperature_nomask '
+     ! 0. Initialization
+     ! -----------------
+
+     iman  = jpmois
+     i15   = nday / 16
+     imois = nmonth + i15 - 1
+     IF( imois == 0 )   imois = iman
+
+     itime = jpmois
+     ipi = jpiglo
+     ipj = jpjglo
+     ipk = jpk
+
+     ! 1. First call kt=nit000
+     ! -----------------------
+
+     IF( kt == nit000 .AND. nlecte == 0 ) THEN
+	ntem1 = 0
+	IF(lwp) WRITE(numout,*)
+	IF(lwp) WRITE(numout,*) ' dtatem : Levitus monthly fields'
+	IF(lwp) WRITE(numout,*) ' ~~~~~~'
+	IF(lwp) WRITE(numout,*) '             NetCDF FORMAT'
+	IF(lwp) WRITE(numout,*)
+
+	! open file
+
+	cl_tdata = 'data_1m_potential_temperature_nomask '
 #if defined key_agrif
-         if ( .NOT. Agrif_Root() ) then
-            cl_tdata = TRIM(Agrif_CFixed())//'_'//TRIM(cl_tdata)
-         endif
-#endif         
-         CALL flinopen( TRIM(cl_tdata), mig(1), nlci , mjg(1),  nlcj   &
-            &          , .false.     , ipi   , ipj  , ipk   , zlon     &
-            &          , zlat        , zlev  , itime, istep , zdate0   &
-            &          , rdt         , numtdt                        )
-
-         ! title, dimensions and tests
-
-         IF( itime /= jpmois ) THEN
-            IF(lwp) THEN
-               WRITE(numout,*)
-               WRITE(numout,*) 'problem with time coordinates'
-               WRITE(numout,*) ' itime ',itime,' jpmois ',jpmois
-            ENDIF
-            STOP 'dtatem'
-         ENDIF
-         IF( ipi /= jpidta .OR. ipj /= jpjdta .OR. ipk /= jpk ) THEN
-            IF(lwp) THEN
-               WRITE(numout,*)
-               WRITE(numout,*) 'problem with dimensions'
-               WRITE(numout,*) ' ipi ',ipi,' jpidta ',jpidta
-               WRITE(numout,*) ' ipj ',ipj,' jpjdta ',jpjdta
-               WRITE(numout,*) ' ipk ',ipk,' jpk ',jpk
-            ENDIF
-            STOP 'dtatem'
-         ENDIF
-         IF(lwp) WRITE(numout,*) itime,istep,zdate0,rdt,numtdt
-
-      ENDIF
-
-
-      ! 2. Read monthly file
-      ! -------------------
-
-      IF( ( kt == nit000 .AND. nlecte == 0 ) .OR. imois /= ntem1 ) THEN
-         nlecte = 1
-
-         ! Calendar computation
-         
-         ntem1 = imois        ! first file record used 
-         ntem2 = ntem1 + 1    ! last  file record used
-         ntem1 = MOD( ntem1, iman )
-         IF( ntem1 == 0 )   ntem1 = iman
-         ntem2 = MOD( ntem2, iman )
-         IF( ntem2 == 0 )   ntem2 = iman
-         IF(lwp) WRITE(numout,*) 'first record file used ntem1 ', ntem1
-         IF(lwp) WRITE(numout,*) 'last  record file used ntem2 ', ntem2
-         
-         ! Read monthly temperature data Levitus 
-         
-         CALL flinget( numtdt, 'votemper', jpidta, jpjdta, jpk   &
-                     , jpmois, ntem1     , ntem1 , mig(1), nlci   &
-                     , mjg(1), nlcj      , temdta(1:nlci,1:nlcj,1:jpk,1)     )
-         CALL flinget( numtdt, 'votemper', jpidta, jpjdta, jpk   &
-                     , jpmois, ntem2     , ntem2 , mig(1), nlci   &
-                     , mjg(1), nlcj      , temdta(1:nlci,1:nlcj,1:jpk,2)     )
-
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' read Levitus temperature ok'
-         IF(lwp) WRITE(numout,*)
-         
+	if ( .NOT. Agrif_Root() ) then
+	   cl_tdata = TRIM(Agrif_CFixed())//'_'//TRIM(cl_tdata)
+	endif
+#endif            
+	CALL flinopen( TRIM(cl_tdata), mig(1), nlci , mjg(1),  nlcj   &
+	   &          , .false.     , ipi   , ipj  , ipk   , zlon     &
+	   &          , zlat        , zlev  , itime, istep , zdate0   &
+	   &          , rdt         , numtdt                        )
+
+	! title, dimensions and tests
+
+	IF( itime /= jpmois ) THEN
+	   IF(lwp) THEN
+	      WRITE(numout,*)
+	      WRITE(numout,*) 'problem with time coordinates'
+	      WRITE(numout,*) ' itime ',itime,' jpmois ',jpmois
+	   ENDIF
+	   STOP 'dtatem'
+	ENDIF
+	IF( ipi /= jpidta .OR. ipj /= jpjdta .OR. ipk /= jpk ) THEN
+	   IF(lwp) THEN
+	      WRITE(numout,*)
+	      WRITE(numout,*) 'problem with dimensions'
+	      WRITE(numout,*) ' ipi ',ipi,' jpidta ',jpidta
+	      WRITE(numout,*) ' ipj ',ipj,' jpjdta ',jpjdta
+	      WRITE(numout,*) ' ipk ',ipk,' jpk ',jpk
+	   ENDIF
+	   STOP 'dtatem'
+	ENDIF
+	IF(lwp) WRITE(numout,*) itime,istep,zdate0,rdt,numtdt
+
+     ENDIF
+
+
+     ! 2. Read monthly file
+     ! -------------------
+
+     IF( ( kt == nit000 .AND. nlecte == 0 ) .OR. imois /= ntem1 ) THEN
+	nlecte = 1
+
+	! Calendar computation
+
+	ntem1 = imois        ! first file record used 
+	ntem2 = ntem1 + 1    ! last  file record used
+	ntem1 = MOD( ntem1, iman )
+	IF( ntem1 == 0 )   ntem1 = iman
+	ntem2 = MOD( ntem2, iman )
+	IF( ntem2 == 0 )   ntem2 = iman
+	IF(lwp) WRITE(numout,*) 'first record file used ntem1 ', ntem1
+	IF(lwp) WRITE(numout,*) 'last  record file used ntem2 ', ntem2
+
+	! Read monthly temperature data Levitus 
+
+	CALL flinget( numtdt, 'votemper', jpidta, jpjdta, jpk   &
+		    , jpmois, ntem1     , ntem1 , mig(1), nlci   &
+		    , mjg(1), nlcj      , temdta(1:nlci,1:nlcj,1:jpk,1)     )
+	CALL flinget( numtdt, 'votemper', jpidta, jpjdta, jpk   &
+		    , jpmois, ntem2     , ntem2 , mig(1), nlci   &
+		    , mjg(1), nlcj      , temdta(1:nlci,1:nlcj,1:jpk,2)     )
+
+	IF(lwp) WRITE(numout,*)
+	IF(lwp) WRITE(numout,*) ' read Levitus temperature ok'
+	IF(lwp) WRITE(numout,*)
+
 #if defined key_tradmp
-         IF( cp_cfg == "orca"  .AND. jp_cfg == 2 ) THEN
-      
-            !                                        ! =======================
-            !                                        !  ORCA_R2 configuration
-            !                                        ! ======================= 
-
-            ij0 = 101   ;   ij1 = 109
-            ii0 = 141   ;   ii1 = 155
-            DO jj = mj0(ij0), mj1(ij1)                      ! Reduced temperature in the Alboran Sea
-               DO ji = mi0(ii0), mi1(ii1)
-                  temdta(ji,jj, 13:13 ,:) = temdta(ji,jj, 13:13 ,:) - 0.20
-                  temdta(ji,jj, 14:15 ,:) = temdta(ji,jj, 14:15 ,:) - 0.35
-                  temdta(ji,jj, 16:25 ,:) = temdta(ji,jj, 16:25 ,:) - 0.40
-               END DO
-            END DO
-         
-            IF( n_cla == 0 ) THEN 
-               !                                         ! Reduced temperature at Red Sea
-               ij0 =  87   ;   ij1 =  96
-               ii0 = 148   ;   ii1 = 160
-               temdta( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ,  4:10 , : ) = 7.0 
-               temdta( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 11:13 , : ) = 6.5 
-               temdta( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 , : ) = 6.0
-            ELSE
-               il0 = 138   ;   il1 = 138
-               ij0 = 101   ;   ij1 = 102
-               ii0 = 139   ;   ii1 = 139
-               DO jl = mi0(il0), mi1(il1)                ! New temperature profile at Gibraltar
-                  DO jj = mj0(ij0), mj1(ij1)
-                     DO ji = mi0(ii0), mi1(ii1)
-                        temdta(ji,jj,:,:) = temdta(jl,jj,:,:)
-                     END DO
-                  END DO
-               END DO
-               il0 = 164   ;   il1 = 164
-               ij0 =  88   ;   ij1 =  88
-               ii0 = 161   ;   ii1 = 163
-               DO jl = mi0(il0), mi1(il1)                ! New temperature profile at Bab el Mandeb
-                  DO jj = mj0(ij0), mj1(ij1)
-                     DO ji = mi0(ii0), mi1(ii1)
-                        temdta(ji,jj,:,:) = temdta(jl,jj,:,:)
-                     END DO
-                  END DO
-                  ij0 =  87   ;   ij1 =  87
-                  DO jj = mj0(ij0), mj1(ij1)
-                     DO ji = mi0(ii0), mi1(ii1)
-                        temdta(ji,jj,:,:) = temdta(jl,jj,:,:)
-                     END DO
-                  END DO
-               END DO
-            ENDIF
-
-         ENDIF
+	IF( cp_cfg == "orca"  .AND. jp_cfg == 2 ) THEN
+
+	   !                                        ! =======================
+	   !                                        !  ORCA_R2 configuration
+	   !                                        ! ======================= 
+
+	   ij0 = 101   ;   ij1 = 109
+	   ii0 = 141   ;   ii1 = 155
+	   DO jj = mj0(ij0), mj1(ij1)                      ! Reduced temperature in the Alboran Sea
+	      DO ji = mi0(ii0), mi1(ii1)
+		 temdta(ji,jj, 13:13 ,:) = temdta(ji,jj, 13:13 ,:) - 0.20
+		 temdta(ji,jj, 14:15 ,:) = temdta(ji,jj, 14:15 ,:) - 0.35
+		 temdta(ji,jj, 16:25 ,:) = temdta(ji,jj, 16:25 ,:) - 0.40
+	      END DO
+	   END DO
+
+	   IF( n_cla == 0 ) THEN 
+	      !                                         ! Reduced temperature at Red Sea
+	      ij0 =  87   ;   ij1 =  96
+	      ii0 = 148   ;   ii1 = 160
+	      temdta( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ,  4:10 , : ) = 7.0 
+	      temdta( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 11:13 , : ) = 6.5 
+	      temdta( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 , : ) = 6.0
+	   ELSE
+	      il0 = 138   ;   il1 = 138
+	      ij0 = 101   ;   ij1 = 102
+	      ii0 = 139   ;   ii1 = 139
+	      DO jl = mi0(il0), mi1(il1)                ! New temperature profile at Gibraltar
+		 DO jj = mj0(ij0), mj1(ij1)
+		    DO ji = mi0(ii0), mi1(ii1)
+		       temdta(ji,jj,:,:) = temdta(jl,jj,:,:)
+		    END DO
+		 END DO
+	      END DO
+	      il0 = 164   ;   il1 = 164
+	      ij0 =  88   ;   ij1 =  88
+	      ii0 = 161   ;   ii1 = 163
+	      DO jl = mi0(il0), mi1(il1)                ! New temperature profile at Bab el Mandeb
+		 DO jj = mj0(ij0), mj1(ij1)
+		    DO ji = mi0(ii0), mi1(ii1)
+		       temdta(ji,jj,:,:) = temdta(jl,jj,:,:)
+		    END DO
+		 END DO
+		 ij0 =  87   ;   ij1 =  87
+		 DO jj = mj0(ij0), mj1(ij1)
+		    DO ji = mi0(ii0), mi1(ii1)
+		       temdta(ji,jj,:,:) = temdta(jl,jj,:,:)
+		    END DO
+		 END DO
+	      END DO
+	   ENDIF
+
+	ENDIF
 #endif
 
-         !                                  ! Mask
-         DO jl = 1, 2
-            temdta(:,:,:,jl) = temdta(:,:,:,jl) * tmask(:,:,:)
-            temdta(:,:,jpk,jl) = 0.
-            IF( lk_zps ) THEN                ! z-coord. with partial steps
-               DO jj = 1, jpj                  ! interpolation of temperature at the last level
-                  DO ji = 1, jpi
-                     ik = mbathy(ji,jj) - 1
-                     IF( ik > 2 ) THEN
-                        zl = ( gdept(ik) - fsdept(ji,jj,ik) ) / ( gdept(ik) - gdept(ik-1) )
-                        temdta(ji,jj,ik,jl) = (1.-zl) * temdta(ji,jj,ik,jl) + zl * temdta(ji,jj,ik-1,jl) 
-                     ENDIF
-                  END DO
-               END DO
-            ENDIF
-         END DO
-
-         IF(lwp) THEN
-            WRITE(numout,*) ' temperature Levitus month ', ntem1, ntem2
-            WRITE(numout,*)
-            WRITE(numout,*) ' Levitus month = ', ntem1, '  level = 1'
-            CALL prihre( temdta(:,:,1,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
-            WRITE(numout,*) ' Levitus month = ', ntem1, '  level = ', jpk/2
-            CALL prihre( temdta(:,:,jpk/2,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
-            WRITE(numout,*) ' Levitus month = ',ntem1,'  level = ', jpkm1
-            CALL prihre( temdta(:,:,jpkm1,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
-         ENDIF
-      ENDIF
-
- 
-      ! 2. At every time step compute temperature data
-      ! ----------------------------------------------
-
-      zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
-      t_dta(:,:,:) = (1.-zxy) * temdta(:,:,:,1) + zxy * temdta(:,:,:,2)
-
+     IF( ln_sco ) THEN
+     DO jl = 1, 2
+	DO jj = 1, jpj                  ! interpolation of temperatures
+	   DO ji = 1, jpi
+	      DO jk = 1, jpk
+		  zl=fsdept(ji,jj,jk)
+		  IF(zl < gdept_0(1)) ztemdta(jk,jl) =  temdta(ji,jj,1,jl)
+		  IF(zl > gdept_0(jpk)) ztemdta(jk,jl) =  temdta(ji,jj,jpkm1,jl)
+		  DO jkk = 1, jpkm1
+		      IF((zl-gdept_0(jkk))*(zl-gdept_0(jkk+1)).le.0.0) THEN
+			  ztemdta(jk,jl) = temdta(ji,jj,jkk,jl)                                 &
+			     &           + (zl-gdept_0(jkk))/(gdept_0(jkk+1)-gdept_0(jkk))      &
+			     &                              *(temdta(ji,jj,jkk+1,jl) - temdta(ji,jj,jkk,jl))
+		      ENDIF
+		  END DO
+	      END DO
+	      DO jk = 1, jpkm1
+		       temdta(ji,jj,jk,jl) = ztemdta(jk,jl)
+	      END DO
+		       temdta(ji,jj,jpk,jl) = 0.0
+	   END DO
+	END DO
+     END DO
+
+     IF(lwp) WRITE(numout,*)
+     IF(lwp) WRITE(numout,*) ' Levitus temperature data interpolated to s-coordinate'
+     IF(lwp) WRITE(numout,*)
+
+     ELSE
+
+     !                                  ! Mask
+     DO jl = 1, 2
+	temdta(:,:,:,jl) = temdta(:,:,:,jl) * tmask(:,:,:)
+	temdta(:,:,jpk,jl) = 0.
+	IF( ln_zps ) THEN                ! z-coord. with partial steps
+	   DO jj = 1, jpj                  ! interpolation of temperature at the last level
+	      DO ji = 1, jpi
+		 ik = mbathy(ji,jj) - 1
+		 IF( ik > 2 ) THEN
+		    zl = ( gdept_0(ik) - fsdept(ji,jj,ik) ) / ( gdept_0(ik) - gdept_0(ik-1) )
+		    temdta(ji,jj,ik,jl) = (1.-zl) * temdta(ji,jj,ik,jl) + zl * temdta(ji,jj,ik-1,jl)
+		 ENDIF
+	      END DO
+	   END DO
+	ENDIF
+     END DO
+
+     ENDIF
+
+	IF(lwp) THEN
+	   WRITE(numout,*) ' temperature Levitus month ', ntem1, ntem2
+	   WRITE(numout,*)
+	   WRITE(numout,*) ' Levitus month = ', ntem1, '  level = 1'
+	   CALL prihre( temdta(:,:,1,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+	   WRITE(numout,*) ' Levitus month = ', ntem1, '  level = ', jpk/2
+	   CALL prihre( temdta(:,:,jpk/2,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+	   WRITE(numout,*) ' Levitus month = ',ntem1,'  level = ', jpkm1
+	   CALL prihre( temdta(:,:,jpkm1,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+	ENDIF
+     ENDIF
+
+
+     ! 2. At every time step compute temperature data
+     ! ----------------------------------------------
+
+     zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
+     t_dta(:,:,:) = (1.-zxy) * temdta(:,:,:,1) + zxy * temdta(:,:,:,2)
 
    END SUBROUTINE dta_tem
