Index: codes/icosagcm/devel/src/dissip/guided_mod.f90
===================================================================
--- codes/icosagcm/devel/src/dissip/guided_mod.f90	(revision 714)
+++ codes/icosagcm/devel/src/dissip/guided_mod.f90	(revision 818)
@@ -7,8 +7,10 @@
 
 
-  SUBROUTINE init_guided
-  USE icosa
-  USE guided_ncar_mod, ONLY : init_guided_ncar => init_guided
-  IMPLICIT NONE
+  SUBROUTINE init_guided(f_u)
+    USE icosa
+    USE guided_ncar_mod, ONLY : init_guided_ncar => init_guided
+    USE nudging_mod, ONLY : init_guided_nudging => init_guided
+    IMPLICIT NONE
+    TYPE(t_field),POINTER :: f_u(:)
     
     guided_type='none'
@@ -21,6 +23,9 @@
         CALL init_guided_ncar
         
+      CASE ('nudging')
+        CALL init_guided_nudging(f_u)
+        
       CASE DEFAULT
-         PRINT*,"Bad selector for varaible guided_type >",TRIM(guided_type),"> option are <none>, <dcmip1>"
+         PRINT*,"Bad selector for varaible guided_type >",TRIM(guided_type),"> option are <none>, <dcmip1>, <nudging>"
          STOP
     END SELECT 
@@ -28,9 +33,9 @@
   END SUBROUTINE init_guided
 
-  
   SUBROUTINE guided(tt, f_ps, f_theta_rhodz, f_u, f_q)
-  USE icosa
-  USE guided_ncar_mod, ONLY : guided_ncar => guided
-  IMPLICIT NONE
+    USE icosa
+    USE guided_ncar_mod, ONLY : guided_ncar => guided
+    USE nudging_mod, ONLY : guided_nudging => guided
+    IMPLICIT NONE
     REAL(rstd), INTENT(IN):: tt
     TYPE(t_field),POINTER :: f_ps(:)
@@ -44,4 +49,7 @@
       CASE ('dcmip1')
         CALL guided_ncar(tt, f_ps, f_theta_rhodz, f_u, f_q)
+      CASE ('nudging')
+!         PRINT *, 'Nudging !', tt
+        CALL guided_nudging(tt, f_ps, f_theta_rhodz, f_u, f_q)
       CASE DEFAULT
          PRINT*,"Bad selector for varaible guided_type >",TRIM(guided_type),"> option are <none>, <dcmip1>"
Index: codes/icosagcm/devel/src/dissip/nudging_mod.f90
===================================================================
--- codes/icosagcm/devel/src/dissip/nudging_mod.f90	(revision 818)
+++ codes/icosagcm/devel/src/dissip/nudging_mod.f90	(revision 818)
@@ -0,0 +1,142 @@
+MODULE nudging_mod
+  USE icosa, ONLY : rstd
+  USE grid_param, ONLY : llm
+  USE domain_mod, ONLY : ndomain, assigned_domain
+  USE dimensions, ONLY : swap_dimensions, u_right, u_lup, u_ldown
+  USE dimensions, ONLY : iim, jjm, ij_begin_ext, ij_end_ext
+  USE geometry, ONLY : swap_geometry
+  USE field_mod
+  IMPLICIT NONE
+  SAVE
+  PRIVATE
+  ! nudging will be active outside a disc of radius 'radius' centered at 'center_lon', 'center lat'.
+  REAL(rstd) :: center_lon, center_lat, nudging_radius, time
+
+  TYPE(t_field),POINTER :: f_relax_coef_e(:), f_target_ue(:)
+
+  PUBLIC :: init_guided, guided
+  
+CONTAINS
+
+  SUBROUTINE init_guided(f_ue)
+    USE getin_mod, ONLY : getin
+    USE math_const, ONLY : pi
+    USE earth_const, ONLY : scale_factor
+    TYPE(t_field),POINTER :: f_ue(:)! initial condition
+    REAL(rstd), POINTER :: ue(:,:), target_ue(:,:), coef_e(:) 
+    INTEGER :: ind
+    ! read DEF keys describing how to relax
+    center_lon=0.
+    CALL getin('nudging_center_lon', center_lon)
+    center_lat=0.
+    CALL getin('nudging_center_lat', center_lat)
+    nudging_radius=0.
+    CALL getin('nudging_radius', nudging_radius)
+    nudging_radius = nudging_radius / scale_factor
+!    time=0.
+!    CALL getin('nudging_time', time)
+
+    ! we should check that radius>0
+
+    CALL allocate_field(f_relax_coef_e, field_u, type_real, name='nudging_coef_e')
+    CALL allocate_field(f_target_ue, field_u, type_real, llm, name='nudging_target_e')
+
+    ! compute relax_coef and target_ue
+    center_lon = center_lon * pi/180.
+    center_lat = center_lat * pi/180.
+    DO ind = 1 , ndomain
+       IF (.NOT. assigned_domain(ind)) CYCLE
+       CALL swap_dimensions(ind)
+       CALL swap_geometry(ind) 
+       coef_e = f_relax_coef_e(ind)
+       target_ue = f_target_ue(ind)
+       ue = f_ue(ind)
+       CALL compute_relax_coef(coef_e)
+       CALL compute_target(ue, target_ue)
+    END DO
+  END SUBROUTINE init_guided
+  
+  SUBROUTINE compute_relax_coef(coef_e)
+    USE omp_para, ONLY : ll_begin, ll_end
+    USE geometry, ONLY : lon_e, lat_e, lon_i, lat_i
+    REAL(rstd), INTENT(OUT) :: coef_e(iim*3*jjm)
+    INTEGER :: l, ij
+    coef_e(:)=1.
+    DO ij=ij_begin_ext, ij_end_ext
+       coef_e(ij+u_right) = relax_coef(lon_e(ij+u_right), lat_e(ij+u_right) )
+       coef_e(ij+u_lup)   = relax_coef(lon_e(ij+u_lup),   lat_e(ij+u_lup)   )
+       coef_e(ij+u_ldown) = relax_coef(lon_e(ij+u_ldown), lat_e(ij+u_ldown) )
+    END DO
+  END SUBROUTINE compute_relax_coef
+  
+  FUNCTION relax_coef(lon,lat)
+    USE spherical_geom_mod, ONLY : dist_lonlat
+    REAL(rstd), INTENT(IN) :: lon,lat
+    REAL(rstd) :: relax_coef, dist, c
+    ! NB : dist is computed on unit sphere
+    CALL dist_lonlat(lon, lat, center_lon, center_lat, dist) 
+    c = tanh((1.-radius*dist/nudging_radius)*20.) ! 1 inside circle, -1 outside
+    !c = tanh((1.-radius*dist/nudging_radius)*10.) ! 1 inside circle, -1 outside
+    !c = tanh((1.-radius*dist/nudging_radius)*5.) ! 1 inside circle, -1 outside
+    relax_coef = .5*(1.+c) ! rescale to [0,1] range ; ! 1 inside circle, 0 outside
+    !relax_coef = 1. ! rescale to [0,1] range ; ! 1 inside circle, 0 outside
+    PRINT *, 'c,lat,dist,radius,nudging_radius,relax_coef',c,lat,dist,radius,nudging_radius,relax_coef
+  END FUNCTION relax_coef
+
+  SUBROUTINE compute_target(ue, target_ue)
+    USE omp_para, ONLY : ll_begin, ll_end
+    REAL(rstd), INTENT(OUT)  :: target_ue(iim*3*jjm,llm)
+    REAL(rstd), INTENT(IN) :: ue(iim*3*jjm,llm)
+    INTEGER :: l, ij
+    DO l = ll_begin, ll_end
+       DO ij=ij_begin_ext, ij_end_ext
+          target_ue(ij+u_right,l)=ue(ij+u_right,l)
+          target_ue(ij+u_lup,l)=ue(ij+u_lup,l)
+          target_ue(ij+u_ldown,l)=ue(ij+u_ldown,l)
+       END DO
+    END DO
+  END SUBROUTINE compute_target
+  
+  SUBROUTINE guided(tt, f_ps, f_theta_rhodz, f_u, f_q)
+    REAL(rstd), INTENT(IN):: tt
+    TYPE(t_field),POINTER :: f_ps(:)
+    TYPE(t_field),POINTER :: f_phis(:)
+    TYPE(t_field),POINTER :: f_theta_rhodz(:)
+    TYPE(t_field),POINTER :: f_u(:)  
+    TYPE(t_field),POINTER :: f_q(:)  
+    REAL(rstd), POINTER :: target_ue(:,:), ue(:,:), coef_e(:) 
+    INTEGER :: ind
+
+    DO ind = 1 , ndomain
+       IF (.NOT. assigned_domain(ind)) CYCLE
+       CALL swap_dimensions(ind)
+       CALL swap_geometry(ind) 
+       coef_e = f_relax_coef_e(ind)
+       PRINT *, 'max coeff', maxval(coef_e)
+       ! PRINT *, 'coeff', coef_e
+       target_ue = f_target_ue(ind)
+       ue = f_u(ind)
+       CALL compute_guided(coef_e, target_ue, ue)
+    END DO
+
+  END SUBROUTINE guided
+
+  SUBROUTINE compute_guided(coef_e, target_ue, ue)
+    USE omp_para, ONLY : ll_begin, ll_end
+    REAL(rstd), INTENT(IN) :: coef_e(iim*3*jjm)
+    REAL(rstd), INTENT(IN) :: target_ue(iim*3*jjm,llm)
+    REAL(rstd), INTENT(INOUT) :: ue(iim*3*jjm,llm)
+    INTEGER :: l, ij
+    DO l = ll_begin, ll_end
+       DO ij=ij_begin_ext, ij_end_ext
+          ue(ij+u_right,l) = ue(ij+u_right,l)*coef_e(ij+u_right) + &
+               target_ue(ij+u_right,l)*(1.-coef_e(ij+u_right))
+          ue(ij+u_lup,l) = ue(ij+u_lup,l)*coef_e(ij+u_lup) + &
+               target_ue(ij+u_lup,l)*(1.-coef_e(ij+u_lup))
+          ue(ij+u_ldown,l) = ue(ij+u_ldown,l)*coef_e(ij+u_ldown) + &
+               target_ue(ij+u_ldown,l)*(1.-coef_e(ij+u_ldown))
+       END DO
+    END DO
+  END SUBROUTINE compute_guided
+  
+END MODULE nudging_mod
