Index: /branches/DEV_r1879_FCM/NEMOGCM/ARCH/arch-SX8_MERCURE.fcm
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/ARCH/arch-SX8_MERCURE.fcm	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/ARCH/arch-SX8_MERCURE.fcm	(revision 2292)
@@ -15,15 +15,15 @@
 
 
-%NCDF_INC        -I/usr/local/SX8/soft/netcdf/include
-%NCDF_LIB        -L/usr/local/SX8/soft/netcdf/lib -lnetcdf
+%NCDF_INC        -I/ccc/applications/sx8/netcdf-3.6.1/include
+%NCDF_LIB        -L/ccc/applications/sx8/netcdf-3.6.1/lib -lnetcdf
 %FC              sxmpif90
-%FCFLAGS         -f2003 nocbind -P stack -dW -Wf,-pvctl res=whole,-A idbl4,-ptr byte -EP -R5 -float0 -size_t64 -dw -Wf,"-pvctl loopcnt=999999 fullmsg noassume"  -Wf"-init heap=zero"
+%FCFLAGS         -f2003 nocbind -size_t64 -dW -Wf,"-A idbl4", -sx8 -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 shape=10000000 -L transform
 %FFLAGS          %FCFLAGS
 %LD              sxmpif90
-%LDFLAGS
+%LDFLAGS         -size_t64
 %FPPFLAGS        -P -C -traditional
 %AR              sxar
 %ARFLAGS         rs
-%MK              gmake
+%MK              sxgmake
 %USER_INC        %NCDF_INC
 %USER_LIB        %NCDF_LIB
Index: /branches/DEV_r1879_FCM/NEMOGCM/CONFIG/makenemo
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/CONFIG/makenemo	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/CONFIG/makenemo	(revision 2292)
@@ -57,5 +57,5 @@
 # ::
 #
-#  $ ./makenemo -t ifort_osx - j3 -n ORCA2_LIM
+#  $ ./makenemo -m ifort_osx - j3 -n ORCA2_LIM
 #
 #
@@ -79,5 +79,5 @@
 #- Local variables ---
 b_n=$(basename ${0})
-export MAIN_DIR=${PWD%/NEMOGCM*}/NEMOGCM
+export MAIN_DIR=${PWD%/CONFIG*}
 export CONFIG_DIR=${MAIN_DIR}/CONFIG
 export TOOLS_DIR=${MAIN_DIR}/TOOLS
@@ -85,4 +85,5 @@
 export NEMO_DIR=${MAIN_DIR}/NEMO
 export AGRIFUSE=10
+
 declare -a TAB
 #-
Index: /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_mpi_buffer_client.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_mpi_buffer_client.F90	(revision 2292)
+++ /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_mpi_buffer_client.F90	(revision 2292)
@@ -0,0 +1,207 @@
+MODULE mod_mpi_buffer_client
+  USE mod_mpi_buffer_parameters
+#if defined key_mpp_mpi
+  USE mpi, ONLY : status_size=>MPI_STATUS_SIZE
+#else
+  INTEGER, PARAMETER :: status_size = 1
+#endif
+
+  
+  INTEGER(KIND=8),POINTER :: MPI_Buffer(:)
+  
+  TYPE mpi_requests
+    INTEGER :: request
+    INTEGER :: status(status_size)
+    INTEGER :: Pos
+  END TYPE mpi_requests
+  
+  TYPE(mpi_requests),DIMENSION(max_request) :: pending_request
+  
+  INTEGER :: Buffer_pos
+  INTEGER :: request_pos
+  INTEGER :: buffer_begin
+  INTEGER :: request_begin
+  INTEGER :: nb_request_pending
+  INTEGER,SAVE :: start_pos
+  LOGICAL,SAVE :: ok_new_request
+  LOGICAL,SAVE :: is_last_request
+
+  INTEGER,SAVE      :: mpi_buffer_size
+  INTEGER,SAVE      :: aggregated_request
+
+CONTAINS
+
+  SUBROUTINE Init_mpi_buffer
+  USE mod_global_memory
+  USE mod_pack
+  USE mod_ioclient_para
+  IMPLICIT NONE
+
+  INTEGER  :: nb_client
+  
+    nb_client=iosize-1  
+    mpi_buffer_size=global_mpi_buffer_size/nb_client
+    
+    CALL allocate_global_memory(mpi_buffer_size,MPI_Buffer)
+    buffer_begin=1
+    request_begin=1
+    Buffer_pos=1
+    nb_request_pending=0
+    Request_pos=1
+    ok_new_request=.TRUE.
+    is_last_request=.FALSE.
+    aggregated_request=0
+    
+    CALL set_pack_buffer(MPI_Buffer,buffer_begin)
+    
+  END SUBROUTINE Init_mpi_buffer
+  
+
+  SUBROUTINE create_request(request_id)
+  USE mod_pack
+  USE mod_ioclient_para
+  USE mpitrace
+  USE mpi_mod
+  IMPLICIT NONE
+    INTEGER :: request_id
+    
+    CALL VTb(VTprocess_event)
+    IF (ok_new_request) THEN  
+      Pending_request(Request_pos)%Pos = pack_pos
+      ok_new_request=.FALSE.
+    ENDIF
+    start_pos=pack_pos
+    pack_pos=pack_pos+1
+!    PRINT *,"Pos in Buffer",Pending_request(Request_pos)%Pos,"pack_pos",pack_pos
+    CALL pack(request_id)
+  END SUBROUTINE create_request
+  
+  
+  SUBROUTINE Finalize_request
+  USE mod_pack
+  USE mod_ioclient_para
+  USE mpitrace
+  use mod_wait
+  USE mpi_mod
+  IMPLICIT NONE
+    INTEGER :: ierr
+    INTEGER :: message_size
+    INTEGER(KIND=8) :: request_size
+    INTEGER :: buffer_free
+    LOGICAL :: ok_out
+    LOGICAL :: is_Buffer_full
+    request_size=pack_pos-start_pos    
+    pack_buffer(start_pos)=request_size
+    message_size=pack_pos-Pending_request(Request_pos)%Pos
+    aggregated_request=aggregated_request+1
+
+
+!! ICI verifier que le buffer ne se recouvre pas ainsi que les requetes
+    
+    ok_out=.FALSE.
+    is_buffer_full=.FALSE.
+    DO WHILE (.NOT. ok_out)
+      CALL check_request
+    
+      IF ( buffer_begin <= pack_pos) THEN
+        Buffer_free=mpi_buffer_size-pack_pos+1
+      ELSE
+        Buffer_free=buffer_begin-pack_pos
+      ENDIF
+      
+!      Print *,"message_size",message_size,"buffer_free",buffer_free
+!      PRINT *,"Request_pos",request_pos
+!      PRINT *,"Pos in Buffer",Pending_request(Request_pos)%Pos,"pack_pos",pack_pos
+      IF ( nb_request_pending==1 .AND. ( (buffer_free < MPI_buffer_size * 0.4) .OR. is_last_request .OR.  &
+                                         (aggregated_request>=max_request/2) )) THEN
+        ok_out=.FALSE.
+        CALL Wait_us(10)
+        IF (.NOT. is_buffer_full) THEN
+          CALL VTb(VTbuffer_full)
+        ENDIF      
+        is_Buffer_full=.TRUE.
+        
+      ELSE
+        ok_out=.TRUE.
+        IF (is_buffer_full) THEN
+          CALL VTe(VTbuffer_full)
+        ENDIF
+        is_buffer_full=.FALSE.
+      
+      ENDIF
+      
+   ENDDO
+   
+   IF (nb_request_pending==0 .OR. (buffer_free < MPI_buffer_size* 0.4 ) .OR. (aggregated_request> max_request/2) ) THEN
+      
+     CALL MPI_ISSEND(MPI_Buffer(Pending_request(Request_pos)%Pos),message_size,MPI_INTEGER8,     &
+                    server_rank,tag_iocomm,iocomm,Pending_request(Request_pos)%request,ierr )
+    
+!    PRINT *,"Requete envoy�e !!!!" 
+!    PRINT *,"Message : ",MPI_Buffer(Pending_request(Request_pos)%Pos:Pending_request(Request_pos)%Pos+message_size-1)              
+      IF ( Pack_Pos > MPI_buffer_size*0.6 ) THEN
+        Pack_Pos=1
+      ENDIF
+    
+      IF (Request_Pos==max_request) THEN
+        Request_Pos=1
+      ELSE 
+        Request_Pos=Request_Pos+1
+      ENDIF
+      nb_request_pending=nb_request_pending+1
+    
+      ok_new_request=.TRUE.
+      aggregated_request=0
+    ENDIF
+    CALL VTe(VTprocess_event)    
+  END SUBROUTINE Finalize_request
+
+
+  SUBROUTINE Check_request
+  USE mpi_mod
+  IMPLICIT NONE
+  LOGICAL :: ok_out
+  LOGICAL :: OK_complete
+  INTEGER :: ierr
+  
+!    PRINT *, 'on entre dans Check_request'
+!    PRINT *, 'nb_request_pending',nb_request_pending
+    
+    IF (nb_request_pending>0) THEN
+      ok_out=.FALSE.
+    ELSE
+      ok_out=.TRUE.
+    ENDIF
+    
+    DO WHILE (.NOT. ok_out)
+    
+!      PRINT *,'Testing_request...'
+!      PRINT *,'request_begin',request_begin
+      CALL MPI_TEST(Pending_request(request_begin)%request,ok_complete,Pending_request(request_begin)%status,ierr)
+!      PRINT *,'Request has been tested...'
+      IF (ok_complete) THEN
+!        PRINT *,"Request_completed"
+        IF (Request_begin==max_request) THEN
+          Request_begin=1
+        ELSE
+          request_begin=request_begin+1
+        ENDIF
+        
+        buffer_begin=Pending_request(request_begin)%Pos
+        
+        nb_request_pending=nb_request_pending-1
+        
+        IF (nb_request_pending==0) THEN 
+          ok_out=.TRUE.
+        ELSE
+          ok_out=.FALSE.
+        ENDIF
+      ELSE
+        ok_out=.TRUE.
+      ENDIF
+    
+    ENDDO
+!    PRINT *, 'on sort de Check_request'  
+  END SUBROUTINE Check_Request
+
+END MODULE mod_mpi_buffer_client
Index: anches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_mpi_buffer_client.f90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_mpi_buffer_client.f90	(revision 2291)
+++ 	(revision )
@@ -1,202 +1,0 @@
-MODULE mod_mpi_buffer_client
-  USE mod_mpi_buffer_parameters
-  USE mpi, ONLY : status_size=>MPI_STATUS_SIZE
-  
-  INTEGER(KIND=8),POINTER :: MPI_Buffer(:)
-  
-  TYPE mpi_requests
-    INTEGER :: request
-    INTEGER :: status(status_size)
-    INTEGER :: Pos
-  END TYPE mpi_requests
-  
-  TYPE(mpi_requests),DIMENSION(max_request) :: pending_request
-  
-  INTEGER :: Buffer_pos
-  INTEGER :: request_pos
-  INTEGER :: buffer_begin
-  INTEGER :: request_begin
-  INTEGER :: nb_request_pending
-  INTEGER,SAVE :: start_pos
-  LOGICAL,SAVE :: ok_new_request
-  LOGICAL,SAVE :: is_last_request
-
-  INTEGER,SAVE      :: mpi_buffer_size
-  INTEGER,SAVE      :: aggregated_request
-
-CONTAINS
-
-  SUBROUTINE Init_mpi_buffer
-  USE mod_global_memory
-  USE mod_pack
-  USE mod_ioclient_para
-  IMPLICIT NONE
-
-  INTEGER  :: nb_client
-  
-    nb_client=iosize-1  
-    mpi_buffer_size=global_mpi_buffer_size/nb_client
-    
-    CALL allocate_global_memory(mpi_buffer_size,MPI_Buffer)
-    buffer_begin=1
-    request_begin=1
-    Buffer_pos=1
-    nb_request_pending=0
-    Request_pos=1
-    ok_new_request=.TRUE.
-    is_last_request=.FALSE.
-    aggregated_request=0
-    
-    CALL set_pack_buffer(MPI_Buffer,buffer_begin)
-    
-  END SUBROUTINE Init_mpi_buffer
-  
-
-  SUBROUTINE create_request(request_id)
-  USE mod_pack
-  USE mod_ioclient_para
-  USE mpitrace
-  USE mpi_mod
-  IMPLICIT NONE
-    INTEGER :: request_id
-    
-    CALL VTb(VTprocess_event)
-    IF (ok_new_request) THEN  
-      Pending_request(Request_pos)%Pos = pack_pos
-      ok_new_request=.FALSE.
-    ENDIF
-    start_pos=pack_pos
-    pack_pos=pack_pos+1
-!    PRINT *,"Pos in Buffer",Pending_request(Request_pos)%Pos,"pack_pos",pack_pos
-    CALL pack(request_id)
-  END SUBROUTINE create_request
-  
-  
-  SUBROUTINE Finalize_request
-  USE mod_pack
-  USE mod_ioclient_para
-  USE mpitrace
-  use mod_wait
-  USE mpi_mod
-  IMPLICIT NONE
-    INTEGER :: ierr
-    INTEGER :: message_size
-    INTEGER(KIND=8) :: request_size
-    INTEGER :: buffer_free
-    LOGICAL :: ok_out
-    LOGICAL :: is_Buffer_full
-    request_size=pack_pos-start_pos    
-    pack_buffer(start_pos)=request_size
-    message_size=pack_pos-Pending_request(Request_pos)%Pos
-    aggregated_request=aggregated_request+1
-
-
-!! ICI verifier que le buffer ne se recouvre pas ainsi que les requetes
-    
-    ok_out=.FALSE.
-    is_buffer_full=.FALSE.
-    DO WHILE (.NOT. ok_out)
-      CALL check_request
-    
-      IF ( buffer_begin <= pack_pos) THEN
-        Buffer_free=mpi_buffer_size-pack_pos+1
-      ELSE
-        Buffer_free=buffer_begin-pack_pos
-      ENDIF
-      
-!      Print *,"message_size",message_size,"buffer_free",buffer_free
-!      PRINT *,"Request_pos",request_pos
-!      PRINT *,"Pos in Buffer",Pending_request(Request_pos)%Pos,"pack_pos",pack_pos
-      IF ( nb_request_pending==1 .AND. ( (buffer_free < MPI_buffer_size * 0.4) .OR. is_last_request .OR.  &
-                                         (aggregated_request>=max_request/2) )) THEN
-        ok_out=.FALSE.
-        CALL Wait_us(10)
-        IF (.NOT. is_buffer_full) THEN
-          CALL VTb(VTbuffer_full)
-        ENDIF      
-        is_Buffer_full=.TRUE.
-        
-      ELSE
-        ok_out=.TRUE.
-        IF (is_buffer_full) THEN
-          CALL VTe(VTbuffer_full)
-        ENDIF
-        is_buffer_full=.FALSE.
-      
-      ENDIF
-      
-   ENDDO
-   
-   IF (nb_request_pending==0 .OR. (buffer_free < MPI_buffer_size* 0.4 ) .OR. (aggregated_request> max_request/2) ) THEN
-      
-     CALL MPI_ISSEND(MPI_Buffer(Pending_request(Request_pos)%Pos),message_size,MPI_INTEGER8,     &
-                    server_rank,tag_iocomm,iocomm,Pending_request(Request_pos)%request,ierr )
-    
-!    PRINT *,"Requete envoy�e !!!!" 
-!    PRINT *,"Message : ",MPI_Buffer(Pending_request(Request_pos)%Pos:Pending_request(Request_pos)%Pos+message_size-1)              
-      IF ( Pack_Pos > MPI_buffer_size*0.6 ) THEN
-        Pack_Pos=1
-      ENDIF
-    
-      IF (Request_Pos==max_request) THEN
-        Request_Pos=1
-      ELSE 
-        Request_Pos=Request_Pos+1
-      ENDIF
-      nb_request_pending=nb_request_pending+1
-    
-      ok_new_request=.TRUE.
-      aggregated_request=0
-    ENDIF
-    CALL VTe(VTprocess_event)    
-  END SUBROUTINE Finalize_request
-
-
-  SUBROUTINE Check_request
-  USE mpi_mod
-  IMPLICIT NONE
-  LOGICAL :: ok_out
-  LOGICAL :: OK_complete
-  INTEGER :: ierr
-  
-!    PRINT *, 'on entre dans Check_request'
-!    PRINT *, 'nb_request_pending',nb_request_pending
-    
-    IF (nb_request_pending>0) THEN
-      ok_out=.FALSE.
-    ELSE
-      ok_out=.TRUE.
-    ENDIF
-    
-    DO WHILE (.NOT. ok_out)
-    
-!      PRINT *,'Testing_request...'
-!      PRINT *,'request_begin',request_begin
-      CALL MPI_TEST(Pending_request(request_begin)%request,ok_complete,Pending_request(request_begin)%status,ierr)
-!      PRINT *,'Request has been tested...'
-      IF (ok_complete) THEN
-!        PRINT *,"Request_completed"
-        IF (Request_begin==max_request) THEN
-          Request_begin=1
-        ELSE
-          request_begin=request_begin+1
-        ENDIF
-        
-        buffer_begin=Pending_request(request_begin)%Pos
-        
-        nb_request_pending=nb_request_pending-1
-        
-        IF (nb_request_pending==0) THEN 
-          ok_out=.TRUE.
-        ELSE
-          ok_out=.FALSE.
-        ENDIF
-      ELSE
-        ok_out=.TRUE.
-      ENDIF
-    
-    ENDDO
-!    PRINT *, 'on sort de Check_request'  
-  END SUBROUTINE Check_Request
-
-END MODULE mod_mpi_buffer_client
Index: /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_mpi_buffer_server.f90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_mpi_buffer_server.f90	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_mpi_buffer_server.f90	(revision 2292)
@@ -157,5 +157,5 @@
   
   SUBROUTINE Fill_request(n,pos,message_size)
-  USE mpi
+  USE mpi_mod
   IMPLICIT NONE
     INTEGER :: n
Index: /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/server.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/server.F90	(revision 2292)
+++ /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/server.F90	(revision 2292)
@@ -0,0 +1,48 @@
+PROGRAM server
+  USE mod_ioserver_para
+  USE mod_mpi_buffer_server
+  USE mod_wait
+  USE mod_global_memory
+  USE ioipsl
+  USE iomanager
+  USE mod_interface_ioipsl
+  USE mod_ioserver_namelist
+  
+  IMPLICIT NONE
+#if defined key_mpp_mpi
+  INCLUDE 'mpif.h'
+  
+  INTEGER :: i,j,ierr
+  LOGICAL :: is_terminated
+  
+!  CALL SLEEP(60)
+  PRINT *,'je suis un serveur'
+  CALL read_namelist
+  CALL init_parallel
+  CALL init_mpi_buffer
+  CALL init_wait
+  CALL init_interface_ioipsl
+  
+  CALL iom__init(nb_client,mpi_size,mpi_rank)
+  PRINT *,'je suis un serveur'
+  
+
+!  CALL MPI_BARRIER(iocomm,ierr)
+  
+  is_terminated=.FALSE.
+  
+  DO WHILE (.NOT. is_terminated)
+    CALL Check_buffer
+    CALL process_request(is_terminated)
+!    CALL wait_us(10)
+  ENDDO
+
+!  CALL MPI_BARRIER(MPI_COMM_WORLD,ierr)
+  CALL histclo
+  
+  CALL Finalize_parallel
+
+  PRINT *,"THAT'S ALL FOLK"
+#endif
+  
+END PROGRAM server
Index: anches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/server.f90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/server.f90	(revision 2291)
+++ 	(revision )
@@ -1,46 +1,0 @@
-PROGRAM server
-  USE mod_ioserver_para
-  USE mod_mpi_buffer_server
-  USE mod_wait
-  USE mod_global_memory
-  USE ioipsl
-  USE iomanager
-  USE mod_interface_ioipsl
-  USE mod_ioserver_namelist
-  
-  IMPLICIT NONE
-  INCLUDE 'mpif.h'
-  
-  INTEGER :: i,j,ierr
-  LOGICAL :: is_terminated
-  
-!  CALL SLEEP(60)
-  PRINT *,'je suis un serveur'
-  CALL read_namelist
-  CALL init_parallel
-  CALL init_mpi_buffer
-  CALL init_wait
-  CALL init_interface_ioipsl
-  
-  CALL iom__init(nb_client,mpi_size,mpi_rank)
-  PRINT *,'je suis un serveur'
-  
-
-!  CALL MPI_BARRIER(iocomm,ierr)
-  
-  is_terminated=.FALSE.
-  
-  DO WHILE (.NOT. is_terminated)
-    CALL Check_buffer
-    CALL process_request(is_terminated)
-!    CALL wait_us(10)
-  ENDDO
-
-!  CALL MPI_BARRIER(MPI_COMM_WORLD,ierr)
-  CALL histclo
-  
-  CALL Finalize_parallel
-
-  PRINT *,"THAT'S ALL FOLK"
-  
-END PROGRAM server
Index: /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/DOM/phycst.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/DOM/phycst.F90	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/DOM/phycst.F90	(revision 2292)
@@ -48,5 +48,5 @@
 #endif
 
-   REAL(wp), PUBLIC ::   rau0     = 1020._wp      !: reference volumic mass (density)  (kg/m3)
+   REAL(wp), PUBLIC ::   rau0     = 1035._wp      !: reference volumic mass (density)  (kg/m3)
    REAL(wp), PUBLIC ::   rau0r                    !: reference specific volume         (m3/kg)
    REAL(wp), PUBLIC ::   rcp      =    4.e+3_wp   !: ocean specific heat
Index: /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/OBC/obcfla.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/OBC/obcfla.F90	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/OBC/obcfla.F90	(revision 2292)
@@ -87,6 +87,4 @@
                &            - sshfoe(jj) )  ) * uemsk(jj,1)
          END DO
-      END DO
-      DO ji = nie0p1, nie1p1
          DO jj = 1, jpj
             sshfoe_b(ji,jj) = sshfoe_b(ji,jj) + sqrt( grav*hur(ji,jj) )     &
@@ -156,6 +154,4 @@
                &                - sshfon(ji) ) ) * vnmsk(ji,1)
          END DO
-      END DO
-      DO jj = njn0p1, njn1p1
          DO ji = 1, jpi
             sshfon_b(ji,jj) = sshfon_b(ji,jj) + sqrt( grav * hvr(ji,jj) )  &
Index: /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/OBC/obcini.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/OBC/obcini.F90	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/OBC/obcini.F90	(revision 2292)
@@ -70,5 +70,4 @@
 
       ! convert DOCTOR namelist name into the OLD names
-      nbobc    = 0
       nobc_dta = nn_obcdta
       cffile   = cn_obcdta
@@ -430,4 +429,5 @@
          END DO
       END IF
+
       IF( lp_obc_west ) THEN ! ... West open boundary lateral surface
          DO ji = niw0, niw1
@@ -437,4 +437,5 @@
          END DO
       END IF
+
       IF( lp_obc_north ) THEN ! ... North open boundary lateral surface
          DO jj = njn0, njn1
Index: /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 2292)
@@ -29,4 +29,5 @@
    USE mod_prism_put_proto          ! OASIS3 prism module for snding
    USE mod_prism_get_proto          ! OASIS3 prism module for receiving
+   USE mod_comprism_proto           ! OASIS3 prism module to get coupling frequency
    USE par_oce                      ! ocean parameters
    USE dom_oce                      ! ocean space and time domain
@@ -61,4 +62,5 @@
    PUBLIC cpl_prism_snd
    PUBLIC cpl_prism_rcv
+   PUBLIC cpl_prism_freq
    PUBLIC cpl_prism_finalize
 
@@ -210,5 +212,5 @@
       !! * Arguments
       !!
-      INTEGER,                      INTENT( IN    )   :: kid       ! variable intex in the array
+      INTEGER,                      INTENT( IN    )   :: kid       ! variable index in the array
       INTEGER,                      INTENT(   OUT )   :: kinfo     ! OASIS3 info argument
       INTEGER,                      INTENT( IN    )   :: kstep     ! ocean time-step in seconds
@@ -247,5 +249,5 @@
       !!      like stresses and fluxes from the coupler or remote application.
       !!----------------------------------------------------------------------
-      INTEGER,                      INTENT( IN    )   :: kid       ! variable intex in the array
+      INTEGER,                      INTENT( IN    )   :: kid       ! variable index in the array
       INTEGER,                      INTENT( IN    )   :: kstep     ! ocean time-step in seconds
       REAL(wp), DIMENSION(jpi,jpj), INTENT( INOUT )   :: pdata     ! IN to keep the value if nothing is done
@@ -293,4 +295,18 @@
 
 
+   FUNCTION cpl_prism_freq( kid )  
+
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE cpl_prism_freq  ***
+      !!
+      !! ** Purpose : - send back the coupling frequency for a particular field
+      !!----------------------------------------------------------------------
+      INTEGER,INTENT( IN )   :: kid              ! variable index 
+      INTEGER                :: cpl_prism_freq   ! coupling frequency
+      cpl_prism_freq = ig_def_freq( kid )
+
+   END FUNCTION cpl_prism_freq
+
+
    SUBROUTINE cpl_prism_finalize
 
Index: /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 2292)
@@ -26,4 +26,5 @@
    USE fldread         ! read input fields
    USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbcdcy          ! surface boundary condition: diurnal cycle
    USE iom             ! I/O manager library
    USE in_out_manager  ! I/O manager
@@ -61,4 +62,5 @@
    REAL(wp), PARAMETER ::   Stef =    5.67e-8     ! Stefan Boltzmann constant
    REAL(wp), PARAMETER ::   Cice =    1.63e-3     ! transfer coefficient over ice
+   REAL(wp), PARAMETER ::   albo =    0.066       ! ocean albedo assumed to be contant
 
    !                                !!* Namelist namsbc_core : CORE bulk parameters
@@ -146,6 +148,13 @@
          REWIND( numnam )                    ! ... read in namlist namsbc_core
          READ  ( numnam, namsbc_core )
-         !
-         ! store namelist information in an array
+         !                                         ! check: do we plan to use ln_dm2dc with non-daily forcing?
+         IF( ln_dm2dc .AND. sn_qsr%nfreqh /= 24 )   & 
+            &   CALL ctl_stop( 'sbc_blk_core: ln_dm2dc can be activated only with daily short-wave forcing' ) 
+         IF( ln_dm2dc .AND. sn_qsr%ln_tint ) THEN
+            CALL ctl_warn( 'sbc_blk_core: ln_dm2dc is taking care of the temporal interpolation of daily qsr',   &
+                 &         '              ==> We force time interpolation = .false. for qsr' )
+            sn_qsr%ln_tint = .false.
+         ENDIF
+         !                                         ! store namelist information in an array
          slf_i(jp_wndi) = sn_wndi   ;   slf_i(jp_wndj) = sn_wndj
          slf_i(jp_qsr ) = sn_qsr    ;   slf_i(jp_qlw ) = sn_qlw
@@ -260,7 +269,9 @@
       ! ----------------------------------------------------------------------------- !
     
-      ! ocean albedo assumed to be 0.066
-!CDIR COLLAPSE
-      qsr (:,:) = ( 1. - 0.066 ) * sf(jp_qsr)%fnow(:,:) * tmask(:,:,1)                                 ! Short Wave
+      ! ocean albedo assumed to be constant + modify now Qsr to include the diurnal cycle                  ! Short Wave
+      zztmp = 1. - albo
+      IF( ln_dm2dc ) THEN   ;   qsr(:,:) = zztmp * sbc_dcy( sf(jp_qsr)%fnow(:,:) ) * tmask(:,:,1)
+      ELSE                  ;   qsr(:,:) = zztmp *          sf(jp_qsr)%fnow(:,:)   * tmask(:,:,1)
+      ENDIF
 !CDIR COLLAPSE
       zqlw(:,:) = (  sf(jp_qlw)%fnow(:,:) - Stef * zst(:,:)*zst(:,:)*zst(:,:)*zst(:,:)  ) * tmask(:,:,1)   ! Long  Wave
@@ -414,4 +425,5 @@
       REAL(wp) ::   zst2, zst3
       REAL(wp) ::   zcoef_wnorm, zcoef_wnorm2, zcoef_dqlw, zcoef_dqla, zcoef_dqsb
+      REAL(wp) ::   zztmp                                        ! temporary variable
       REAL(wp) ::   zcoef_frca                                   ! fractional cloud amount
       REAL(wp) ::   zwnorm_f, zwndi_f , zwndj_f                  ! relative wind module and components at F-point
@@ -501,4 +513,5 @@
       END SELECT
 
+      zztmp = 1. / ( 1. - albo )
       !                                     ! ========================== !
       DO jl = 1, ijpl                       !  Loop over ice categories  !
@@ -515,5 +528,5 @@
                zst3 = pst(ji,jj,jl) * zst2
                ! Short Wave (sw)
-               p_qsr(ji,jj,jl) = ( 1. - palb(ji,jj,jl) ) * sf(jp_qsr)%fnow(ji,jj) * tmask(ji,jj,1)
+               p_qsr(ji,jj,jl) = zztmp * ( 1. - palb(ji,jj,jl) ) * qsr(ji,jj)
                ! Long  Wave (lw)
                z_qlw(ji,jj,jl) = 0.95 * (  sf(jp_qlw)%fnow(ji,jj)       &                         
Index: /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 2292)
@@ -23,4 +23,5 @@
    USE sbc_oce         ! Surface boundary condition: ocean fields
    USE sbc_ice         ! Surface boundary condition: ice fields
+   USE sbcdcy          ! surface boundary condition: diurnal cycle
    USE phycst          ! physical constants
 #if defined key_lim3
@@ -527,4 +528,7 @@
       CALL cpl_prism_define(jprcv, jpsnd)            
       !
+      IF( ln_dm2dc .AND. ( cpl_prism_freq( jpr_qsroce ) + cpl_prism_freq( jpr_qsrmix ) /= 86400 ) )   &
+         &   CALL ctl_stop( 'sbc_cpl_init: diurnal cycle reconstruction (ln_dm2dc) needs daily couping for solar radiation' )
+
    END SUBROUTINE sbc_cpl_init
 
@@ -728,4 +732,5 @@
          IF( srcv(jpr_qsroce)%laction )   qsr(:,:) = frcv(:,:,jpr_qsroce) 
          IF( srcv(jpr_qsrmix)%laction )   qsr(:,:) = frcv(:,:,jpr_qsrmix)
+         IF( ln_dm2dc )   qsr(:,:) = sbc_dcy( qsr )                           ! modify qsr to include the diurnal cycle
          !
          !                                                       ! total freshwater fluxes over the ocean (emp, emps)
@@ -1159,4 +1164,8 @@
             &                     + palbi         (:,:,1) * zicefr(:,:,1) ) )
       END SELECT
+      IF( ln_dm2dc ) THEN   ! modify qsr to include the diurnal cycle
+         pqsr_tot(:,:  ) = sbc_dcy( pqsr_tot(:,:  ) )
+         pqsr_ice(:,:,1) = sbc_dcy( pqsr_ice(:,:,1) )
+      ENDIF
 
       SELECT CASE( TRIM( cn_rcv_dqnsdt ) )
Index: /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcdcy.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcdcy.F90	(revision 2292)
+++ /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcdcy.F90	(revision 2292)
@@ -0,0 +1,211 @@
+MODULE sbcdcy
+   !!======================================================================
+   !!                    ***  MODULE  sbcdcy  ***
+   !! Ocean forcing:  compute the diurnal cycle
+   !!======================================================================
+   !! History : OPA  !  2005-02  (D. Bernie)  Original code
+   !!   NEMO    2.0  !  2006-02  (S. Masson, G. Madec)  adaptation to NEMO
+   !!           3.1  !  2009-07  (J.M. Molines)  adaptation to v3.1
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!  sbc_dcy : compute solar flux at kt from daily mean, taking 
+   !!            diurnal cycle into account
+   !!----------------------------------------------------------------------
+   USE oce              ! ocean dynamics and tracers
+   USE phycst           ! ocean physics
+   USE dom_oce          ! ocean space and time domain
+   USE sbc_oce          ! Surface boundary condition: ocean fields
+   USE in_out_manager   ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+   INTEGER, PUBLIC              ::   nday_qsr                    ! day when parameters were computed
+   REAL(wp), DIMENSION(jpi,jpj) ::   raa , rbb  , rcc  , rab     ! parameters used to compute the diurnal cycle
+   REAL(wp), DIMENSION(jpi,jpj) ::   rtmd, rdawn, rdusk, rscal   !     -       -         -           -      -
+  
+   PUBLIC   sbc_dcy     ! routine called by sbc
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO-consortium (2010) 
+   !! $Id: sbcdcy.F90 2287 2010-10-18 07:53:52Z smasson $ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+      FUNCTION sbc_dcy( pqsrin ) RESULT( zqsrout )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE sbc_dcy  ***
+      !!
+      !! ** Purpose : introduce a diurnal cycle of qsr from daily values
+      !!
+      !! ** Method  : see Appendix A of Bernie et al. 2007.
+      !!
+      !! ** Action  : redistribute daily QSR on each time step following the diurnal cycle
+      !!
+      !! reference  : Bernie, DJ, E Guilyardi, G Madec, JM Slingo, and SJ Woolnough, 2007
+      !!              Impact of resolving the diurnal cycle in an ocean--atmosphere GCM. 
+      !!              Part 1: a diurnally forced OGCM. Climate Dynamics 29:6, 575-590.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pqsrin    ! input daily QSR flux 
+      !!
+      INTEGER  ::   ji, jj                                       ! dummy loop indices
+      REAL(wp) ::   ztwopi, zinvtwopi, zconvrad 
+      REAL(wp) ::   zlo, zup, zlousd, zupusd
+      REAL(wp) ::   zdsws, zdecrad, ztx, zsin, zcos
+      REAL(wp) ::   ztmp, ztmp1, ztmp2, ztest
+      REAL(wp), DIMENSION(jpi,jpj) ::   zqsrout                  ! output QSR flux with diurnal cycle
+      !---------------------------statement functions------------------------
+      REAL(wp) ::   fintegral, pt1, pt2, paaa, pbbb, pccc        ! dummy statement function arguments
+      fintegral( pt1, pt2, paaa, pbbb, pccc ) =                         &
+         &   paaa * pt2 + zinvtwopi * pbbb * SIN(pccc + ztwopi * pt2)   &
+         & - paaa * pt1 - zinvtwopi * pbbb * SIN(pccc + ztwopi * pt1)
+      !!---------------------------------------------------------------------
+
+      ! Initialization
+      ! --------------
+      ztwopi    = 2. * rpi
+      zinvtwopi = 1. / ztwopi
+      zconvrad  = ztwopi / 360.
+
+      ! When are we during the day (from 0 to 1)
+      zlo = ( REAL(nsec_day, wp) - 0.5   * rdttra(1) ) / rday
+      zup = zlo + ( REAL(nn_fsbc, wp) * rdttra(1) ) / rday
+
+      !                                          
+      IF( nday_qsr == -1 ) THEN       ! first time step only               
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'sbc_dcy : introduce diurnal cycle from daily mean qsr'
+            WRITE(numout,*) '~~~~~~~'
+            WRITE(numout,*)
+         ENDIF
+         ! Compute rcc needed to compute the time integral of the diurnal cycle
+         rcc(:,:) = zconvrad * glamt(:,:) - rpi
+         ! time of midday
+         rtmd(:,:) = 0.5 - glamt(:,:) / 360.
+         rtmd(:,:) = MOD( (rtmd(:,:) + 1.), 1. )
+      ENDIF
+
+      ! If this is a new day, we have to update the dawn, dusk and scaling function  
+      !----------------------
+    
+      !     2.1 dawn and dusk  
+
+      ! nday is the number of days since the beginning of the current month 
+      IF( nday_qsr /= nday ) THEN 
+         ! save the day of the year and the daily mean of qsr
+         nday_qsr = nday 
+         ! number of days since the previous winter solstice (supposed to be always 21 December)         
+         zdsws = REAL(11 + nday_year, wp)
+         ! declination of the earths orbit
+         zdecrad = (-23.5 * zconvrad) * COS( zdsws * ztwopi / REAL(nyear_len(1),wp) )
+         ! Compute A and B needed to compute the time integral of the diurnal cycle
+        
+         zsin = SIN( zdecrad )   ;   zcos = COS( zdecrad )
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ztmp = zconvrad * gphit(ji,jj)
+               raa(ji,jj) = SIN( ztmp ) * zsin
+               rbb(ji,jj) = COS( ztmp ) * zcos
+            END DO  
+         END DO  
+
+         ! Compute the time of dawn and dusk
+
+         ! rab to test if the day time is equal to 0, less than 24h of full day        
+         rab(:,:) = -raa(:,:) / rbb(:,:)
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( ABS(rab(ji,jj)) < 1 ) THEN         ! day duration is less than 24h
+         ! When is it night?
+                  ztx = zinvtwopi * (ACOS(rab(ji,jj)) - rcc(ji,jj))
+                  ztest = -rbb(ji,jj) * SIN( rcc(ji,jj) + ztwopi * ztx )
+         ! is it dawn or dusk?
+                  IF ( ztest > 0 ) THEN
+                     rdawn(ji,jj) = ztx
+                     rdusk(ji,jj) = rtmd(ji,jj) + ( rtmd(ji,jj) - rdawn(ji,jj) )
+                  ELSE
+                     rdusk(ji,jj) = ztx
+                     rdawn(ji,jj) = rtmd(ji,jj) - ( rdusk(ji,jj) - rtmd(ji,jj) )
+                  ENDIF
+               ELSE
+                  rdawn(ji,jj) = rtmd(ji,jj) + 0.5
+                  rdusk(ji,jj) = rdawn(ji,jj)
+               ENDIF
+             END DO  
+         END DO  
+         rdawn(:,:) = MOD((rdawn(:,:) + 1.), 1.)
+         rdusk(:,:) = MOD((rdusk(:,:) + 1.), 1.)
+
+         !     2.2 Compute the scalling function:
+         !         S* = the inverse of the time integral of the diurnal cycle from dawm to dusk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( ABS(rab(ji,jj)) < 1 ) THEN         ! day duration is less than 24h
+                  IF ( rdawn(ji,jj) < rdusk(ji,jj) ) THEN      ! day time in one part
+                     rscal(ji,jj) = fintegral(rdawn(ji,jj), rdusk(ji,jj), raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
+                     rscal(ji,jj) = 1. / rscal(ji,jj)
+                  ELSE                                         ! day time in two parts
+                     rscal(ji,jj) = fintegral(0., rdusk(ji,jj), raa(ji,jj), rbb(ji,jj), rcc(ji,jj))   &
+                        &         + fintegral(rdawn(ji,jj), 1., raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
+                     rscal(ji,jj) = 1. / rscal(ji,jj)
+                  ENDIF
+               ELSE
+                  IF ( raa(ji,jj) > rbb(ji,jj) ) THEN         ! 24h day
+                     rscal(ji,jj) = fintegral(0., 1., raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
+                     rscal(ji,jj) = 1. / rscal(ji,jj)
+                  ELSE                                          ! No day
+                     rscal(ji,jj) = 0.e0
+                  ENDIF
+               ENDIF
+            END DO  
+         END DO  
+         !
+         ztmp = rday / ( rdttra(1) * REAL(nn_fsbc, wp) )
+         rscal(:,:) = rscal(:,:) * ztmp
+
+      ENDIF 
+
+         !     3. update qsr with the diurnal cycle
+         !     ------------------------------------
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( ABS(rab(ji,jj)) < 1 ) THEN         ! day duration is less than 24h
+               !
+               IF( rdawn(ji,jj) < rdusk(ji,jj) ) THEN       ! day time in one part
+                  zlousd = MAX(zlo, rdawn(ji,jj))
+                  zlousd = MIN(zlousd, zup)
+                  zupusd = MIN(zup, rdusk(ji,jj))
+                  zupusd = MAX(zupusd, zlo)
+                  ztmp = fintegral(zlousd, zupusd, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
+                  zqsrout(ji,jj) = pqsrin(ji,jj) * ztmp * rscal(ji,jj)
+                  !
+               ELSE                                         ! day time in two parts
+                  zlousd = MIN(zlo, rdusk(ji,jj))
+                  zupusd = MIN(zup, rdusk(ji,jj))
+                  ztmp1 = fintegral(zlousd, zupusd, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
+                  zlousd = MAX(zlo, rdawn(ji,jj))
+                  zupusd = MAX(zup, rdawn(ji,jj))
+                  ztmp2 = fintegral(zlousd, zupusd, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
+                  ztmp = ztmp1 + ztmp2
+                  zqsrout(ji,jj) = pqsrin(ji,jj) * ztmp * rscal(ji,jj)
+               ENDIF
+            ELSE                                   ! 24h light or 24h night
+               !
+               IF( raa(ji,jj) > rbb(ji,jj) ) THEN           ! 24h day
+                  ztmp = fintegral(zlo, zup, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
+                  zqsrout(ji,jj) = pqsrin(ji,jj) * ztmp * rscal(ji,jj)
+                  !
+               ELSE                                         ! No day
+                  zqsrout(ji,jj) = 0.e0
+               ENDIF
+            ENDIF
+         END DO  
+      END DO  
+      !
+   END FUNCTION sbc_dcy
+
+   !!======================================================================
+END MODULE sbcdcy
Index: /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90	(revision 2292)
@@ -27,5 +27,6 @@
    USE oce             ! ocean dynamics and tracers
    USE dom_oce         ! ocean space and time domain
-   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_oce         ! surface boundary condition: ocean fields
+   USE sbcdcy          ! surface boundary condition: diurnal cycle on qsr
    USE phycst          ! physical constants
    USE fldread         ! read input fields
@@ -114,6 +115,10 @@
          REWIND ( numnam )               ! ... read in namlist namflx
          READ   ( numnam, namsbc_flx ) 
-
-         ! store namelist information in an array
+         !
+         !                                         ! check: do we plan to use ln_dm2dc with non-daily forcing?
+         IF( ln_dm2dc .AND. sn_qsr%nfreqh /= 24 )   &
+            &   CALL ctl_stop( 'sbc_blk_core: ln_dm2dc can be activated only with daily short-wave forcing' ) 
+         !
+         !                                         ! store namelist information in an array
          slf_i(jp_utau) = sn_utau   ;   slf_i(jp_vtau) = sn_vtau
          slf_i(jp_qtot) = sn_qtot   ;   slf_i(jp_qsr ) = sn_qsr 
@@ -141,4 +146,7 @@
       IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
          !
+         IF( ln_dm2dc ) THEN   ;   qsr(:,:) = sbc_dcy( sf(jp_qsr)%fnow(:,:) )   ! modify now Qsr to include the diurnal cycle
+         ELSE                  ;   qsr(:,:) =          sf(jp_qsr)%fnow(:,:)
+         ENDIF
          ! set the ocean fluxes from read fields
 !CDIR COLLAPSE
@@ -148,5 +156,4 @@
                vtau(ji,jj) = sf(jp_vtau)%fnow(ji,jj)
                qns (ji,jj) = sf(jp_qtot)%fnow(ji,jj) - sf(jp_qsr)%fnow(ji,jj)
-               qsr (ji,jj) = sf(jp_qsr )%fnow(ji,jj)
                emp (ji,jj) = sf(jp_emp )%fnow(ji,jj)
             END DO
Index: /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 2292)
@@ -18,4 +18,5 @@
    USE sbc_oce         ! Surface boundary condition: ocean fields
    USE sbc_ice         ! Surface boundary condition: ice fields
+   USE sbcdcy          ! surface boundary condition: diurnal cycle
    USE sbcssm          ! surface boundary condition: sea-surface mean variables
    USE sbcana          ! surface boundary condition: analytical formulation
@@ -82,20 +83,15 @@
       READ  ( numnam, namsbc )
 
-      ! overwrite namelist parameter using CPP key information
-!!gm here no overwrite, test all option via namelist change: require more incore memory
-!!gm  IF( lk_sbc_cpl       ) THEN   ;   ln_cpl      = .TRUE.   ;   ELSE   ;   ln_cpl      = .FALSE.   ;   ENDIF
-
-      IF ( Agrif_Root() ) THEN
-        IF( lk_lim2 )            nn_ice      = 2
-        IF( lk_lim3 )            nn_ice      = 3
-      ENDIF
-      !
-      IF( cp_cfg == 'gyre' ) THEN
+      !                          ! overwrite namelist parameter using CPP key information
+      IF( Agrif_Root() ) THEN                ! AGRIF zoom
+        IF( lk_lim2 )   nn_ice      = 2
+        IF( lk_lim3 )   nn_ice      = 3
+      ENDIF
+      IF( cp_cfg == 'gyre' ) THEN            ! GYRE configuration
           ln_ana      = .TRUE.   
           nn_ice      =   0
       ENDIF
       
-      ! Control print
-      IF(lwp) THEN
+      IF(lwp) THEN               ! Control print
          WRITE(numout,*) '        Namelist namsbc (partly overwritten with CPP key setting)'
          WRITE(numout,*) '           frequency update of sbc (and ice)             nn_fsbc     = ', nn_fsbc
@@ -116,4 +112,5 @@
       ENDIF
 
+      !                          ! Checks:
       IF( .NOT. ln_rnf ) THEN                      ! no specific treatment in vicinity of river mouths 
          ln_rnf_mouth  = .false.                      
@@ -138,5 +135,13 @@
          &   CALL ctl_stop( 'sea-ice model requires a bulk formulation or coupled configuration' )
       
-      ! Choice of the Surface Boudary Condition (set nsbc)
+      IF( ln_dm2dc )   nday_qsr = -1   ! initialisation flag
+
+      IF( ln_dm2dc .AND. .NOT.( ln_flx .OR. ln_blk_core ) )   &
+         &   CALL ctl_stop( 'diurnal cycle into qsr field from daily values requires a flux or core-bulk formulation' )
+      
+      IF( ln_dm2dc .AND. ( ( NINT(rday) / ( nn_fsbc * NINT(rdt) ) )  < 8 ) )   &
+         &   CALL ctl_warn( 'diurnal cycle for qsr: the sampling of the diurnal cycle is too small...' )
+      
+      !                          ! Choice of the Surface Boudary Condition (set nsbc)
       icpt = 0
       IF( ln_ana          ) THEN   ;   nsbc =  1   ; icpt = icpt + 1   ;   ENDIF       ! analytical      formulation
@@ -147,5 +152,5 @@
       IF( cp_cfg == 'gyre') THEN   ;   nsbc =  0                       ;   ENDIF       ! GYRE analytical formulation
       IF( lk_esopa        )            nsbc = -1                                       ! esopa test, ALL formulations
-
+      !
       IF( icpt /= 1 .AND. .NOT.lk_esopa ) THEN
          WRITE(numout,*)
@@ -216,6 +221,4 @@
       ! Misc. Options
       ! -------------
-
-!!gm  IF( ln_dm2dc       )   CALL sbc_dcy( kt )                 ! Daily mean qsr distributed over the Diurnal Cycle
       
       SELECT CASE( nn_ice )                                     ! Update heat and freshwater fluxes over sea-ice areas
@@ -239,7 +242,7 @@
          CALL iom_put( "emp"    , emp       )                   ! upward water flux
          CALL iom_put( "emps"   , emps      )                   ! c/d water flux
-         CALL iom_put( "qns+qsr", qns + qsr )                   ! total heat flux   (caution if ln_dm2dc=true, to be 
-         CALL iom_put( "qns"    , qns       )                   ! solar heat flux    moved after the call to iom_setkt)
-         CALL iom_put( "qsr"    ,       qsr )                   ! solar heat flux    moved after the call to iom_setkt)
+         CALL iom_put( "qns+qsr", qns + qsr )                   ! total heat flux
+         CALL iom_put( "qns"    , qns       )                   ! solar heat flux
+         CALL iom_put( "qsr"    ,       qsr )                   ! solar heat flux
          IF(  nn_ice > 0 )   CALL iom_put( "ice_cover", fr_i )  ! ice fraction 
       ENDIF
Index: /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/COMPILE/Fgo_to_TOOLS.sh
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/COMPILE/Fgo_to_TOOLS.sh	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/COMPILE/Fgo_to_TOOLS.sh	(revision 2292)
@@ -53,4 +53,3 @@
 #-
 
-local MAIN_DIR=${PWD%/NEMOGCM/*}/NEMOGCM
 cd ${MAIN_DIR}/TOOLS
Index: /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/COMPILE/bld.cfg
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/COMPILE/bld.cfg	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/COMPILE/bld.cfg	(revision 2292)
@@ -75,4 +75,5 @@
 bld::excl_dep        use::mod_prism_get_proto
 bld::excl_dep        use::mod_prism_put_proto
+bld::excl_dep        use::mod_comprism_proto
 bld::excl_dep        use::mkl_dfti
 # Don't generate interface files
Index: /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/MISCELLANEOUS/chk_iomput.sh
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/MISCELLANEOUS/chk_iomput.sh	(revision 2292)
+++ /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/MISCELLANEOUS/chk_iomput.sh	(revision 2292)
@@ -0,0 +1,132 @@
+#!/bin/bash
+#------------------------------------------------
+#$Id: chk_iomput.sh 2280 2010-10-15 13:42:58Z smasson $
+#------------------------------------------------
+#
+set -u
+#
+# if not argument -> get the help
+[ $# -eq 0 ] && ./$0 --help && exit
+#
+inxml=0
+insrc=0
+while [ $# -gt 0 ]   # Until you run out of parameters . . . 
+do    
+    case "$1" in 
+	-h|--help)
+	    echo
+	    echo 'Description:'
+	    echo '      check that an xml file is coherant with the source code:'
+	    echo '         - all variable ids defined by "call iom_put" must have their counterpart'
+	    echo '           in the variable definition in xml file'
+	    echo '         - list variable ids defined in xml file without any corresponding call'
+	    echo '           to iom_put. This can be done but it is useless as iom will only ouput zeros'
+	    echo '         - all variable ids used in the files definition in xml file must have'
+	    echo '           their counterpart in the variable definition in xml file'
+	    echo 'Usage:'
+	    echo '      chk_iomput.sh [OPTION]'
+	    echo '  or  chk_iomput.sh [OPTION] xmlfile DIRECTORIES'
+	    echo '         with:'
+	    echo '           xmlfile:  the xml file to test'
+	    echo '           DIRECTORIES: a list of directories containing the source code'
+	    echo 'Options'
+	    echo ' -h, --help           to get this help'
+	    echo ' -v, --version        to get the version number'
+	    echo ' --inxml              only print all variable definitions found in the xml file'
+	    echo ' --insrc              only print all variable definitions found in the source code'
+	    echo 'Examples'
+	    echo '      chk_iomput.sh'
+	    echo '      chk_iomput.sh --help'
+	    echo '      chk_iomput.sh ../../CONFIG/ORCA2_LIM/EXP00/iodef.xml "../../NEMO/OPA_SRC/ ../../NEMO/LIM_SRC_2/"'
+	    echo
+	    exit ;;
+	-v|--version) grep "^#\$Id: chk_iomput.sh 2280 2010-10-15 13:42:58Z smasson $0 ; exit ;;
+        --inxml) inxml=1 ;;
+        --insrc) insrc=1 ;;
+	-*) echo ; echo "illegal option" ; ./$0 --help && exit ;;
+	*) [ $# -ne 2 ] && echo && echo "wrong number of arguments" && ./$0 --help && exit
+	    xmlfile=${1}
+	    srcdir=${2}
+	   shift
+    esac
+    shift       # Check next set of parameters. 
+done 
+#
+[ ! -f "$xmlfile" ] && echo "$xmlfile not found, we stop..." && exit
+for i in $srcdir 
+do
+    [ ! -d $i ] && echo "$i is not a directory, we stop..." && exit
+done
+#
+#------------------------------------------------
+#
+[ $inxml -eq 1 ] && grep "< *field * id *=" $xmlfile
+[ $insrc -eq 1 ] && find $srcdir -name "*.[Ffh]90" -exec grep -iH "^[^\!]*call  *iom_put *(" {} \;
+[ $(( $insrc + $inxml )) -ge 1 ] && exit
+#
+#------------------------------------------------
+#
+# list of file containing "CALL iom_put" in $srcdir
+#
+srclist=$( find $srcdir -name "*.[Ffh]90" -exec grep -il "^[^\!]*call  *iom_put *(" {} \; )
+#
+# list of variables used in "CALL iom_put"
+#
+varlistsrc=$( find $srcdir -name "*.[Ffh]90" -exec grep -i  "^[^\!]*call  *iom_put *(" {} \; | sed -e "s/.*iom_put *( *[\"\']\([^\"\']*\)[\"\'] *,.*/\1/" | sort -d )
+#
+# list of variables defined in the xml file
+#
+varlistxml=$( grep "< *field * id *=" $xmlfile  | sed -e "s/^.*< *field * id *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
+#
+# list of variables to be outputed in the xml file
+#
+varlistout=$( grep "< *field * ref *=" $xmlfile  | sed -e "s/^.*< *field * ref *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
+#
+echo "--------------------------------------------------"
+echo  check if all iom_put found in $srcdir
+echo  have a corresponding variable definition in $xmlfile
+echo "--------------------------------------------------"
+for var in $varlistsrc
+do
+    tst=$( echo " "$varlistxml" " | grep -c " $var " )
+    if [ $tst -ne 1 ] 
+    then
+	echo "problem with $var: $tst lines corresponding to its definition in $xmlfile, but defined in the code in"
+	for f in $srclist
+	do
+	    grep -iH "^[^\!]*call  *iom_put *( *[\"\']${var}[\"\'] *," $f
+	done
+	echo
+    fi
+done
+#
+echo "--------------------------------------------------"
+echo  check if all variables defined in $xmlfile
+echo  have a corresponding \"call iom_put\" in sources found in $srcdir
+echo "--------------------------------------------------"
+#
+for var in $varlistxml
+do
+    found=$( echo " "$varlistsrc" " | grep -c " $var " )
+    if [ $found -eq 0 ] 
+    then
+	echo \"call iom_put\" not found for variable $var
+	grep "< *field * id *= *[\"\']${var}[\"\']" $xmlfile
+	echo
+    fi
+done
+#
+echo "--------------------------------------------------"
+echo  ${xmlfile}: check if all variables to be outputed in files are really defined...
+echo "--------------------------------------------------"
+#
+# list of variables defined in the xml file
+for var in $varlistout
+do
+    found=$( echo " "$varlistxml" " | grep -c " $var " )
+    [ $found -eq 0 ] && echo variable to be outputed but not defined: $var 
+done
+
+
+
+exit
Index: /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/maketools
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/maketools	(revision 2291)
+++ /branches/DEV_r1879_FCM/NEMOGCM/TOOLS/maketools	(revision 2292)
@@ -74,5 +74,5 @@
 #- Local variables ---
 b_n=$(basename ${0})
-export MAIN_DIR=${PWD%/NEMOGCM*}/NEMOGCM
+export MAIN_DIR=${PWD%/TOOLS*}
 export TOOLS_DIR=${MAIN_DIR}/TOOLS
 export COMPIL_DIR=${MAIN_DIR}/TOOLS/COMPILE
