Index: trunk/NEMO/OPA_SRC/restart_dimg.h90
===================================================================
--- trunk/NEMO/OPA_SRC/restart_dimg.h90	(revision 311)
+++ trunk/NEMO/OPA_SRC/restart_dimg.h90	(revision 359)
@@ -2,4 +2,8 @@
    !!                     ***  restart_dimg.h90  *** 
    !!---------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
 
    SUBROUTINE rst_write(kt)
@@ -24,4 +28,5 @@
      !!        !  99-11  (M. Imbard)  NetCDF FORMAT with ioipsl
      !!   8.5  !  03-06  (J.M. Molines)  F90: Free form, mpp support
+     !!   9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
      !!----------------------------------------------------------------------
      !! * Arguments 
@@ -40,8 +45,4 @@
 
      REAL(wp), DIMENSION( 1) ::   zfice, zfblk   ! used only in case of ice & bulk
-     !!----------------------------------------------------------------------
-     !!  OPA 9.0 , LOCEAN-IPSL (2005) 
-     !! $Header$ 
-     !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
      !!----------------------------------------------------------------------
 
@@ -88,5 +89,5 @@
        IF ( lk_ice_lim                           )   ios1 = 1
        IF ( l_bulk                               )   ios2 = 1
-       IF ( lk_dynspg_fsc .OR. lk_dynspg_fsc_tsk )   ios3 = 1
+       IF ( lk_dynspg_flt                        )   ios3 = 1
        IF ( lk_cpl                               )   ios4 = 1
 
@@ -102,103 +103,70 @@
 
        ! 'before' fields
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) ub(:,:,jk)
-          irec = irec +1
-       END DO
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) vb(:,:,jk)
-          irec = irec +1
-       END DO
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) tb(:,:,jk)
-          irec = irec +1
-       END DO
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) sb(:,:,jk)
-          irec = irec +1
-       END DO
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) rotb(:,:,jk)
-          irec = irec +1
-       END DO
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) hdivb(:,:,jk)
-          irec = irec +1
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) ub(:,:,jk)   ;    irec = irec +1
+       END DO
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) vb(:,:,jk)   ;    irec = irec +1
+       END DO
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) tb(:,:,jk)   ;    irec = irec +1
+       END DO
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) sb(:,:,jk)   ;    irec = irec +1
+       END DO
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) rotb(:,:,jk)   ;    irec = irec +1
+       END DO
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) hdivb(:,:,jk)   ;    irec = irec +1
        END DO
 
        ! 'now' fields
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) un(:,:,jk)
-          irec = irec +1
-       END DO
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) vn(:,:,jk)
-          irec = irec +1
-       END DO
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) tn(:,:,jk)
-          irec = irec +1
-       END DO
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) sn(:,:,jk)
-          irec = irec +1
-       END DO
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) rotn(:,:,jk)
-          irec = irec +1
-       END DO
-
-       DO jk = 1, jpk
-          WRITE(inum,REC=irec) hdivn(:,:,jk)
-          irec = irec +1
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) un(:,:,jk)   ;   irec = irec +1
+       END DO
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) vn(:,:,jk)   ;   irec = irec +1
+       END DO
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) tn(:,:,jk)   ;   irec = irec +1
+       END DO
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) sn(:,:,jk)   ;   irec = irec +1
+       END DO
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) rotn(:,:,jk)   ;   irec = irec +1
+       END DO
+       DO jk = 1, jpk
+          WRITE(inum,REC=irec) hdivn(:,:,jk)   ;   irec = irec +1
        END DO
 
        ! elliptic solver arrays
-       WRITE(inum,REC=irec ) gcx(1:jpi,1:jpj)
-       irec = irec +1
-
-       WRITE(inum,REC=irec ) gcxb(1:jpi,1:jpj)
-       irec = irec +1
-
-#if defined key_dynspg_fsc
-
+       WRITE(inum,REC=irec ) gcx(1:jpi,1:jpj)   ;   irec = irec +1
+       WRITE(inum,REC=irec ) gcxb(1:jpi,1:jpj)   ;   irec = irec +1
+#if defined key_dynspg_rl
+       ! Rigid-lid formulation (bsf)
+       WRITE(inum,REC=irec ) bsfb(:,:)   ;   irec = irec +1
+       WRITE(inum,REC=irec ) bsfn(:,:)   ;   irec = irec +1
+       WRITE(inum,REC=irec ) bsfd(:,:)   ;   irec = irec +1
+# else
        ! free surface formulation (ssh)
-
-       WRITE(inum,REC=irec ) sshb(:,:)
-       irec = irec +1
-
-       WRITE(inum,REC=irec ) sshn(:,:)
-       irec = irec +1
-#else
-
-       ! Rigid-lid formulation (bsf)
-
-       WRITE(inum,REC=irec ) bsfb(:,:)
-       irec = irec +1
-
-       WRITE(inum,REC=irec ) bsfn(:,:)
-       irec = irec +1
-
-       WRITE(inum,REC=irec ) bsfd(:,:)
-       irec = irec +1
-
+       WRITE(inum,REC=irec ) sshb(:,:)   ;   irec = irec +1
+       WRITE(inum,REC=irec ) sshn(:,:)   ;   irec = irec +1
+# if defined key_dynspg_ts
+       ! free surface formulation issued from barotropic loop
+       WRITE(inum,REC=irec ) sshb_b(:,:)   ;   irec = irec +1
+       WRITE(inum,REC=irec ) sshn_b(:,:)   ;   irec = irec +1
+
+       ! horizontal transports issued from barotropic loop
+       WRITE(inum,REC=irec) un_b(:,:)   ;   irec = irec +1
+       WRITE(inum,REC=irec) vn_b(:,:)   ;   irec = irec +1
+# endif
 #endif
 
        ! TKE arrays
-
 #if defined key_zdftke
          DO jk = 1, jpk
-            WRITE(inum,REC=irec) en(:,:,jk) ; irec = irec + 1 
+            WRITE(inum,REC=irec) en(:,:,jk)   ;   irec = irec + 1 
          END DO
 #endif
@@ -206,17 +174,17 @@
 #if defined key_ice_lim
           zfice(1) = FLOAT( nfice )                                      ! Louvain La Neuve Sea Ice Model
-          WRITE(inum,REC=irec) zfice(:)     ; irec = irec + 1
-          WRITE(inum,REC=irec) sst_io(:,:)  ; irec = irec + 1
-          WRITE(inum,REC=irec) sss_io(:,:)  ; irec = irec + 1
-          WRITE(inum,REC=irec) u_io  (:,:)  ; irec = irec + 1
-          WRITE(inum,REC=irec) v_io  (:,:)  ; irec = irec + 1
+          WRITE(inum,REC=irec) zfice(:)      ;   irec = irec + 1
+          WRITE(inum,REC=irec) sst_io(:,:)   ;   irec = irec + 1
+          WRITE(inum,REC=irec) sss_io(:,:)   ;   irec = irec + 1
+          WRITE(inum,REC=irec) u_io  (:,:)   ;   irec = irec + 1
+          WRITE(inum,REC=irec) v_io  (:,:)   ;   irec = irec + 1
 #    if defined key_coupled
-          WRITE(inum,REC=irec) alb_ice(:,:)  ; irec = irec + 1
+          WRITE(inum,REC=irec) alb_ice(:,:)  ;   irec = irec + 1
 #    endif
 #endif
 # if defined key_flx_bulk_monthly || defined key_flx_bulk_daily
           zfblk(1) = FLOAT( nfbulk )                                 ! Bulk
-          WRITE(inum,REC=irec) zfblk(:)   ; irec = irec + 1
-          WRITE(inum,REC=irec) gsst(:,:)  ; irec = irec + 1
+          WRITE(inum,REC=irec) zfblk(:)   ;   irec = irec + 1
+          WRITE(inum,REC=irec) gsst(:,:)  ;   irec = irec + 1
 # endif
 
@@ -225,14 +193,13 @@
 
   END SUBROUTINE rst_write
+
 
   SUBROUTINE rst_read
     !!---------------------------------------------------------------------
-    !!                       ROUTINE rst_read
-    !!                     ******************
+    !!                  ***  ROUTINE rst_read  ***
     !! ** Purpose :
     !!        Read restart fields in direct access format, one per process
     !!
-    !! ** Method :
-    !!        Just does the oposit than rst_wri
+    !! ** Method :   Just does the opposit than rst_wri
     !!
     !! History :
@@ -245,7 +212,5 @@
     !!        !  99-11  (M. Imbard)  NetCDF FORMAT with ioipsl
     !!   8.5  !  03-06  (J.M. Molines)  F90: Free form, mpp support
-    !!----------------------------------------------------------------------
-
-
+    !!   9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
     !!----------------------------------------------------------------------
     USE lib_mpp
@@ -264,8 +229,5 @@
     LOGICAL   :: lstop
 
-      REAL(wp), DIMENSION( 1) ::   zfice, zfblk   ! used only in case of ice & bulk
-
-    !!----------------------------------------------------------------------
-    !!  OPA 8.5, LODYC-IPSL (2002)
+    REAL(wp), DIMENSION( 1) ::   zfice, zfblk   ! used only in case of ice & bulk
     !!----------------------------------------------------------------------
 
@@ -316,8 +278,7 @@
     ! --------------
 
-
-    READ(inum,REC=1) irecl8, ino1, it1, isor1, ipcg1, itke1, &
-     &  iice1, ibulk1, ios1, ios2, ios3, ios4, &
-     &  idast1, adatrj0,  ipi,ipj,ipk,ipni,ipnj,ipnij,iarea
+    READ(inum,REC=1) irecl8, ino1, it1, isor1, ipcg1, itke1,   &
+       &             iice1, ibulk1, ios1, ios2, ios3, ios4,    &
+       &             idast1, adatrj0,  ipi,ipj,ipk,ipni,ipnj,ipnij,iarea
 
     ! Performs checks on the file
@@ -393,105 +354,70 @@
 
     ! 'before' fields
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) ub(:,:,jk)
-       irec = irec +1
-    END DO
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) vb(:,:,jk)
-       irec = irec +1
-    END DO
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) tb(:,:,jk)
-       irec = irec +1
-    END DO
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) sb(:,:,jk)
-       irec = irec +1
-    END DO
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) rotb(:,:,jk)
-       irec = irec +1
-    END DO
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) hdivb(:,:,jk)
-       irec = irec +1
+    DO jk = 1, jpk
+       READ(inum,REC=irec) ub(:,:,jk)   ;   irec = irec +1
+    END DO
+    DO jk = 1, jpk
+       READ(inum,REC=irec) vb(:,:,jk)   ;   irec = irec +1
+    END DO
+    DO jk = 1, jpk
+       READ(inum,REC=irec) tb(:,:,jk)   ;   irec = irec +1
+    END DO
+    DO jk = 1, jpk
+       READ(inum,REC=irec) sb(:,:,jk)   ;   irec = irec +1
+    END DO
+    DO jk = 1, jpk
+       READ(inum,REC=irec) rotb(:,:,jk)   ;   irec = irec +1
+    END DO
+    DO jk = 1, jpk
+       READ(inum,REC=irec) hdivb(:,:,jk)   ;   irec = irec +1
     END DO
 
     ! 'now' fields
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) un(:,:,jk)
-       irec = irec +1
-    END DO
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) vn(:,:,jk)
-       irec = irec +1
-    END DO
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) tn(:,:,jk)
-       irec = irec +1
-    END DO
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) sn(:,:,jk)
-       irec = irec +1
-    END DO
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) rotn(:,:,jk)
-       irec = irec +1
-    END DO
-
-    DO jk = 1, jpk
-       READ(inum,REC=irec) hdivn(:,:,jk)
-       irec = irec +1
+    DO jk = 1, jpk
+       READ(inum,REC=irec) un(:,:,jk)   ;   irec = irec +1
+    END DO
+    DO jk = 1, jpk
+       READ(inum,REC=irec) vn(:,:,jk)   ;   irec = irec +1
+    END DO
+    DO jk = 1, jpk
+       READ(inum,REC=irec) tn(:,:,jk)   ;   irec = irec +1
+    END DO
+    DO jk = 1, jpk
+       READ(inum,REC=irec) sn(:,:,jk)   ;   irec = irec +1
+    END DO
+    DO jk = 1, jpk
+       READ(inum,REC=irec) rotn(:,:,jk)   ;   irec = irec +1
+    END DO
+    DO jk = 1, jpk
+       READ(inum,REC=irec) hdivn(:,:,jk)   ;   irec = irec +1
     END DO
 
     ! elliptic solver arrays
-    READ(inum,REC=irec ) gcx(1:jpi,1:jpj)
-    irec = irec +1
-
-    READ(inum,REC=irec ) gcxb(1:jpi,1:jpj)
-    irec = irec +1
-
-#if defined key_dynspg_fsc
-
+    READ(inum,REC=irec ) gcx(1:jpi,1:jpj)   ;   irec = irec +1
+    READ(inum,REC=irec ) gcxb(1:jpi,1:jpj)   ;   irec = irec +1
+#if defined key_dynspg_rl
+    ! Rigid-lid formulation (bsf)
+    READ(inum,REC=irec ) bsfb(:,:)   ;   irec = irec +1
+    READ(inum,REC=irec ) bsfn(:,:)   ;   irec = irec +1
+    READ(inum,REC=irec ) bsfd(:,:)   ;   irec = irec +1
+#else
     ! free surface formulation (eta)
-
-    READ(inum,REC=irec ) sshb(:,:)
-    irec = irec +1
-
-    READ(inum,REC=irec ) sshn(:,:)
-    irec = irec +1
-#else
-
-    ! Rigid-lid formulation (bsf)
-
-    READ(inum,REC=irec ) bsfb(:,:)
-    irec = irec +1
-
-    READ(inum,REC=irec ) bsfn(:,:)
-    irec = irec +1
-
-    READ(inum,REC=irec ) bsfd(:,:)
-    irec = irec +1
-
+    READ(inum,REC=irec ) sshb(:,:)   ;   irec = irec +1
+    READ(inum,REC=irec ) sshn(:,:)   ;   irec = irec +1
+# if defined key_dynspg_ts
+    ! free surface formulation issued from barotropic loop
+    READ(inum,REC=irec ) sshb_b(:,:)   ;   irec = irec +1
+    READ(inum,REC=irec ) sshn_b(:,:)   ;   irec = irec +1
+    ! horizontal transports issued from barotropic loop
+    READ(inum,REC=irec) un_b(:,:)   ;   irec = irec +1
+    READ(inum,REC=irec) vn_b(:,:)   ;   irec = irec +1
+# endif
 #endif
 
     ! TKE arrays
-
 #if defined key_zdftke
     IF ( itke1 == 1 ) THEN
        DO jk = 1, jpk
-          READ(inum,REC=irec) en(:,:,jk)
-          irec = irec +1
+          READ(inum,REC=irec) en(:,:,jk)   ;   irec = irec +1
        END DO
     ELSE
@@ -507,12 +433,12 @@
     ! check if it was in the previous run
     IF ( ios1 == 1 ) THEN
-       READ(inum,REC=irec) zfice(:)    ; irec = irec + 1
-       READ(inum,REC=irec) sst_io(:,:) ; irec = irec + 1
-       READ(inum,REC=irec) sss_io(:,:) ; irec = irec + 1
-       READ(inum,REC=irec) u_io  (:,:) ; irec = irec + 1
-       READ(inum,REC=irec) v_io  (:,:) ; irec = irec + 1
-#  if defined key_coupled
-       READ(inum,REC=irec) alb_ice(:,:) ; irec = irec + 1
-#  endif
+       READ(inum,REC=irec) zfice(:)      ;   irec = irec + 1
+       READ(inum,REC=irec) sst_io(:,:)   ;   irec = irec + 1
+       READ(inum,REC=irec) sss_io(:,:)   ;   irec = irec + 1
+       READ(inum,REC=irec) u_io  (:,:)   ;   irec = irec + 1
+       READ(inum,REC=irec) v_io  (:,:)   ;   irec = irec + 1
+# if defined key_coupled
+       READ(inum,REC=irec) alb_ice(:,:)   ;   irec = irec + 1
+# endif
     ENDIF
     IF ( zfice(1) /= FLOAT(nfice) .OR. ios1 == 0 ) THEN
@@ -528,11 +454,10 @@
             END DO
          END DO
-#    if defined key_coupled
+# if defined key_coupled
          alb_ice(:,:) = 0.8 * tmask(:,:,1)
-#    endif
-    ENDIF
-  
-#endif
-# if defined key_flx_bulk_monthly || defined key_flx_bulk_daily
+# endif
+    ENDIF
+#endif
+#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily
       ! bulk forcing 
       IF( ios2 == 1 ) THEN
@@ -547,5 +472,5 @@
          gsst(:,:) = gsst(:,:) + ( nfbulk-1 )*( tn(:,:,1) + rt0 )
       ENDIF
-# endif
+#endif
     CLOSE(inum)
   ! In case of restart with neuler = 0 then put all before fields = to now fields
@@ -557,13 +482,10 @@
       rotb(:,:,:)=rotn(:,:,:)
       hdivb(:,:,:)=hdivn(:,:,:)
-#if defined key_dynspg_fsc
-    ! free surface formulation (eta)
-      sshb(:,:)=sshn(:,:)
+#if defined key_dynspg_rl
+      bsfb(:,:)=bsfn(:,:)      ! rigid lid
 #else
-    ! rigid lid
-      bsfb(:,:)=bsfn(:,:)
-#endif
-    ENDIF
-
+      sshb(:,:)=sshn(:,:)      ! free surface formulation (eta)
+#endif
+    ENDIF
 
   END SUBROUTINE rst_read
