Index: trunk/LMDZ.COMMON/libf/dynphy_lonlat/calfis_p.F
===================================================================
--- trunk/LMDZ.COMMON/libf/dynphy_lonlat/calfis_p.F	(revision 1543)
+++ trunk/LMDZ.COMMON/libf/dynphy_lonlat/calfis_p.F	(revision 1549)
@@ -36,5 +36,7 @@
 #endif
 #ifdef CPP_PARA
-      USE parallel_lmdz, ONLY : omp_chunk, using_mpi, AllGather_Field
+      USE parallel_lmdz, ONLY: omp_chunk, using_mpi, AllGather_Field,
+     &                         jjb_u,jje_u,jjb_v,jje_v,
+     &                         jj_begin_dyn=>jj_begin,jj_end_dyn=>jj_end
       USE Write_Field
       Use Write_field_p
@@ -49,4 +51,7 @@
       USE comconst_mod, ONLY: daysec,dtvr,dtphys,kappa,cpp,g,rad,pi
       USE logic_mod, ONLY: moyzon_ch,moyzon_mu
+#ifdef CPP_PHYS
+      USE callphysiq_mod, ONLY: call_physiq
+#endif 
 
       IMPLICIT NONE
@@ -159,4 +164,6 @@
       REAL,ALLOCATABLE,SAVE :: zphi(:,:),zphis(:)
 
+!      REAL zrot(iip1,jjb_v:jje_v,llm) ! AdlC May 2014
+      REAL :: zrot(iip1,jjm,llm)
       REAL,ALLOCATABLE,SAVE :: zufi(:,:), zvfi(:,:)
       REAL,ALLOCATABLE,SAVE :: ztfi(:,:),zqfi(:,:,:)
@@ -170,5 +177,5 @@
 !      REAL,ALLOCATABLE,SAVE :: pcvgt(:,:), pcvgq(:,:,:)
 c
-      REAL,ALLOCATABLE,SAVE :: zdufi(:,:),zdvfi(:,:)
+      REAL,ALLOCATABLE,SAVE :: zdufi(:,:),zdvfi(:,:), zrfi(:,:)
       REAL,ALLOCATABLE,SAVE :: zdtfi(:,:),zdqfi(:,:,:)
       REAL,ALLOCATABLE,SAVE :: zdpsrf(:)
@@ -183,4 +190,5 @@
       REAL,ALLOCATABLE,SAVE :: zufi_omp(:,:) 
       REAL,ALLOCATABLE,SAVE :: zvfi_omp(:,:)
+      REAL,ALLOCATABLE,SAVE :: zrfi_omp(:,:)
       REAL,ALLOCATABLE,SAVE :: ztfi_omp(:,:)
       REAL,ALLOCATABLE,SAVE :: zqfi_omp(:,:,:)
@@ -216,5 +224,5 @@
 c$OMP THREADPRIVATE(zplev_omp,zplay_omp,zpk_omp,zphi_omp,zphis_omp,
 c$OMP+                 presnivs_omp,zufi_omp,zvfi_omp,ztfi_omp,
-c$OMP+                 zqfi_omp,zdufi_omp,zdvfi_omp,
+c$OMP+                 zrfi_omp,zqfi_omp,zdufi_omp,zdvfi_omp,
 c$OMP+                 zdtfi_omp,zdqfi_omp,zdpsrf_omp,flxwfi_omp,
 c$OMP+                 zdufic_omp,zdvfic_omp,zdtfic_omp,zdqfic_omp)       
@@ -244,4 +252,5 @@
       integer :: k,kstart,kend
       INTEGER :: offset  
+      INTEGER :: jjb,jje
 
       LOGICAL tracerdyn ! for generic/mars physics call ; possibly to get rid of
@@ -294,5 +303,5 @@
 !      ALLOCATE(pcvgu(klon,llm), pcvgv(klon,llm))
 !      ALLOCATE(pcvgt(klon,llm), pcvgq(klon,llm,2))
-      ALLOCATE(zdufi(klon,llm),zdvfi(klon,llm))
+      ALLOCATE(zdufi(klon,llm),zdvfi(klon,llm),zrfi(klon,llm))
       ALLOCATE(zdtfi(klon,llm),zdqfi(klon,llm,nqtot))
       ALLOCATE(zdpsrf(klon))
@@ -610,5 +619,29 @@
 c$OMP END DO NOWAIT
 
-c   46.champ v:
+c
+C  Alvaro de la Camara (May 2014)
+C  46.1 Calcul de la vorticite et passage sur la grille physique
+C  --------------------------------------------------------------
+
+      jjb=jj_begin_dyn-1
+      jje=jj_end_dyn+1
+      if (is_north_pole) jjb=1
+      if (is_south_pole) jje=jjm
+
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+
+      DO l=1,llm
+        do i=1,iim
+          do j=jjb,jje
+            zrot(i,j,l) = (pvcov(i+1,j,l) - pvcov(i,j,l)
+     $                   + pucov(i,j+1,l) - pucov(i,j,l))
+     $                   / (cu(i,j)+cu(i,j+1))
+     $                   / (cv(i+1,j)+cv(i,j)) *4
+          enddo
+        enddo
+      ENDDO
+
+
+c   46.2champ v:
 c   -----------
 
@@ -623,4 +656,17 @@
      $                       + pvcov(i,j,l)/cv(i,j) )
     
+          if (j==1 .OR. j==jjp1) then !  AdlC MAY 2014
+            zrfi(ig0,l) = 0 !  AdlC MAY 2014
+          else
+            if(i==1)then
+            zrfi(ig0,l)= 0.25 *(zrot(iim,j-1,l)+zrot(iim,j,l)
+     $                   +zrot(1,j-1,l)+zrot(1,j,l))   !  AdlC MAY 2014
+            else
+            zrfi(ig0,l)= 0.25 *(zrot(i-1,j-1,l)+zrot(i-1,j,l)
+     $                   +zrot(i,j-1,l)+zrot(i,j,l))   !  AdlC MAY 2014
+            endif
+          endif
+
+
          ENDDO
       ENDDO
@@ -648,4 +694,5 @@
            zufi(1,l)  = SSUM(iim,zcos,1)/pi
            zvfi(1,l)  = SSUM(iim,zsin,1)/pi
+           zrfi(1,l)  = 0.
   
         ENDDO
@@ -675,4 +722,5 @@
            zufi(klon,l)  = SSUM(iim,zcos,1)/pi
            zvfi(klon,l)  = SSUM(iim,zsin,1)/pi
+           zrfi(klon,l)  = 0.
         ENDDO
 c$OMP END DO NOWAIT       
@@ -706,4 +754,5 @@
         allocate(zufi_omp(klon,llm))
         allocate(zvfi_omp(klon,llm))
+        allocate(zrfi_omp(klon,llm))  ! LG Ari 2014
         allocate(ztfi_omp(klon,llm))
         allocate(zqfi_omp(klon,llm,nqtot))
@@ -775,4 +824,11 @@
       do l=1,llm
         do i=1,klon
+	  zrfi_omp(i,l)=zrfi(offset+i,l)
+	enddo 
+      enddo
+	
+	
+      do l=1,llm
+        do i=1,klon
 	  ztfi_omp(i,l)=ztfi(offset+i,l)
 	enddo 
@@ -880,115 +936,125 @@
          lafin_split=lafin.and.isplit==nsplit_phys
 
-
-      if (planet_type=="earth") then
-        CALL physiq (klon,
-     .             llm,
-     .             debut_split,
-     .             lafin_split,
-     .             jD_cur,
-     .             jH_cur_split,
-     .             zdt_split,
-     .             zplev_omp,
-     .             zplay_omp,
-     .             zphi_omp,
-     .             zphis_omp,
-     .             presnivs_omp,
-     .             zufi_omp,
-     .             zvfi_omp,
-     .             ztfi_omp,
-     .             zqfi_omp,
-     .             flxwfi_omp,
-     .             zdufi_omp,
-     .             zdvfi_omp,
-     .             zdtfi_omp,
-     .             zdqfi_omp,
-     .             zdpsrf_omp,
-     .             pducov)
-
-      else if ( planet_type=="generic" ) then
-
-      CALL physiq (klon,     !! ngrid
-     .             llm,            !! nlayer
-     .             nqtot,          !! nq
-     .             tname,          !! tracer names from dynamical core (given in infotrac)
-     .             debut_split,    !! firstcall 
-     .             lafin_split,    !! lastcall
-     .             jD_cur,         !! pday. see leapfrog_p 
-     .             jH_cur_split,   !! ptime "fraction of day"
-     .             zdt_split,      !! ptimestep
-     .             zplev_omp,  !! pplev
-     .             zplay_omp,  !! pplay
-     .             zphi_omp,   !! pphi
-     .             zufi_omp,   !! pu
-     .             zvfi_omp,   !! pv
-     .             ztfi_omp,   !! pt
-     .             zqfi_omp,   !! pq
-     .             flxwfi_omp, !! pw !! or 0. anyway this is for diagnostic. not used in physiq.
-     .             zdufi_omp,  !! pdu
-     .             zdvfi_omp,  !! pdv
-     .             zdtfi_omp,  !! pdt
-     .             zdqfi_omp,  !! pdq
-     .             zdpsrf_omp, !! pdpsrf
-     .             tracerdyn)      !! tracerdyn <-- utilite ???
-
-      else if ( planet_type=="mars" ) then
-
-        CALL physiq (klon,       ! ngrid
-     .             llm,          ! nlayer
-     .             nqtot,        ! nq
-     .             debut_split,  ! firstcall
-     .             lafin_split,  ! lastcall
-     .             jD_cur,       ! pday
-     .             jH_cur_split, ! ptime
-     .             zdt_split,    ! ptimestep
-     .             zplev_omp,    ! pplev
-     .             zplay_omp,    ! pplay
-     .             zphi_omp,     ! pphi
-     .             zufi_omp,     ! pu
-     .             zvfi_omp,     ! pv
-     .             ztfi_omp,     ! pt
-     .             zqfi_omp,     ! pq
-     .             flxwfi_omp,   ! pw
-     .             zdufi_omp,    ! pdu
-     .             zdvfi_omp,    ! pdv
-     .             zdtfi_omp,    ! pdt
-     .             zdqfi_omp,    ! pdq
-     .             zdpsrf_omp,   ! pdpsrf
-     .             tracerdyn)    ! tracerdyn (somewhat obsolete)
-
-      else if ((planet_type=="titan").or.(planet_type=="venus")) then
-
-        CALL physiq (klon,
-     .             llm,
-     .             nqtot,
-     .             debut_split,
-     .             lafin_split,
-     .             jD_cur,
-     .             jH_cur_split,
-     .             zdt_split,
-     .             zplev_omp,
-     .             zplay_omp,
-     .             zpk_omp,
-     .             zphi_omp,
-     .             zphis_omp,
-     .             presnivs_omp,
-     .             zufi_omp,
-     .             zvfi_omp,
-     .             ztfi_omp,
-     .             zqfi_omp,
-     .             flxwfi_omp,
-     .             zdufi_omp,
-     .             zdvfi_omp,
-     .             zdtfi_omp,
-     .             zdqfi_omp,
-     .             zdpsrf_omp)
-
-      else ! unknown "planet_type"
-
-        write(lunout,*) "calfis_p: error, unknown planet_type: ",
-     &                  trim(planet_type)
-        stop
-
-      endif ! planet_type
+        CALL call_physiq(klon,llm,nqtot,tname,
+     &                   debut_split,lafin_split,
+     &                   jD_cur,jH_cur_split,zdt_split,
+     &                   zplev_omp,zplay_omp,
+     &                   zpk_omp,zphi_omp,zphis_omp,
+     &                   presnivs_omp,
+     &                   zufi_omp,zvfi_omp,zrfi_omp,ztfi_omp,zqfi_omp,
+     &                   flxwfi_omp,pducov,
+     &                   zdufi_omp,zdvfi_omp,zdtfi_omp,zdqfi_omp,
+     &                   zdpsrf_omp,tracerdyn)
+
+!      if (planet_type=="earth") then
+!        CALL physiq (klon,
+!     .             llm,
+!     .             debut_split,
+!     .             lafin_split,
+!     .             jD_cur,
+!     .             jH_cur_split,
+!     .             zdt_split,
+!     .             zplev_omp,
+!     .             zplay_omp,
+!     .             zphi_omp,
+!     .             zphis_omp,
+!     .             presnivs_omp,
+!     .             zufi_omp,
+!     .             zvfi_omp,
+!     .             ztfi_omp,
+!     .             zqfi_omp,
+!     .             flxwfi_omp,
+!     .             zdufi_omp,
+!     .             zdvfi_omp,
+!     .             zdtfi_omp,
+!     .             zdqfi_omp,
+!     .             zdpsrf_omp,
+!     .             pducov)
+!
+!      else if ( planet_type=="generic" ) then
+!
+!      CALL physiq (klon,     !! ngrid
+!     .             llm,            !! nlayer
+!     .             nqtot,          !! nq
+!     .             tname,          !! tracer names from dynamical core (given in infotrac)
+!     .             debut_split,    !! firstcall 
+!     .             lafin_split,    !! lastcall
+!     .             jD_cur,         !! pday. see leapfrog_p 
+!     .             jH_cur_split,   !! ptime "fraction of day"
+!     .             zdt_split,      !! ptimestep
+!     .             zplev_omp,  !! pplev
+!     .             zplay_omp,  !! pplay
+!     .             zphi_omp,   !! pphi
+!     .             zufi_omp,   !! pu
+!     .             zvfi_omp,   !! pv
+!     .             ztfi_omp,   !! pt
+!     .             zqfi_omp,   !! pq
+!     .             flxwfi_omp, !! pw !! or 0. anyway this is for diagnostic. not used in physiq.
+!     .             zdufi_omp,  !! pdu
+!     .             zdvfi_omp,  !! pdv
+!     .             zdtfi_omp,  !! pdt
+!     .             zdqfi_omp,  !! pdq
+!     .             zdpsrf_omp, !! pdpsrf
+!     .             tracerdyn)      !! tracerdyn <-- utilite ???
+!
+!      else if ( planet_type=="mars" ) then
+!
+!        CALL physiq (klon,       ! ngrid
+!     .             llm,          ! nlayer
+!     .             nqtot,        ! nq
+!     .             debut_split,  ! firstcall
+!     .             lafin_split,  ! lastcall
+!     .             jD_cur,       ! pday
+!     .             jH_cur_split, ! ptime
+!     .             zdt_split,    ! ptimestep
+!     .             zplev_omp,    ! pplev
+!     .             zplay_omp,    ! pplay
+!     .             zphi_omp,     ! pphi
+!     .             zufi_omp,     ! pu
+!     .             zvfi_omp,     ! pv
+!     .             ztfi_omp,     ! pt
+!     .             zqfi_omp,     ! pq
+!     .             flxwfi_omp,   ! pw
+!     .             zdufi_omp,    ! pdu
+!     .             zdvfi_omp,    ! pdv
+!     .             zdtfi_omp,    ! pdt
+!     .             zdqfi_omp,    ! pdq
+!     .             zdpsrf_omp,   ! pdpsrf
+!     .             tracerdyn)    ! tracerdyn (somewhat obsolete)
+!
+!      else if ((planet_type=="titan").or.(planet_type=="venus")) then
+!
+!        CALL physiq (klon,
+!     .             llm,
+!     .             nqtot,
+!     .             debut_split,
+!     .             lafin_split,
+!     .             jD_cur,
+!     .             jH_cur_split,
+!     .             zdt_split,
+!     .             zplev_omp,
+!     .             zplay_omp,
+!     .             zpk_omp,
+!     .             zphi_omp,
+!     .             zphis_omp,
+!     .             presnivs_omp,
+!     .             zufi_omp,
+!     .             zvfi_omp,
+!     .             ztfi_omp,
+!     .             zqfi_omp,
+!     .             flxwfi_omp,
+!     .             zdufi_omp,
+!     .             zdvfi_omp,
+!     .             zdtfi_omp,
+!     .             zdqfi_omp,
+!     .             zdpsrf_omp)
+!
+!      else ! unknown "planet_type"
+!
+!        write(lunout,*) "calfis_p: error, unknown planet_type: ",
+!     &                  trim(planet_type)
+!        stop
+!
+!      endif ! planet_type
          zufi_omp(:,:)=zufi_omp(:,:)+zdufi_omp(:,:)*zdt_split
          zvfi_omp(:,:)=zvfi_omp(:,:)+zdvfi_omp(:,:)*zdt_split
