Index: codes/icosagcm/devel/src/unstructured/data_unstructured.F90
===================================================================
--- codes/icosagcm/devel/src/unstructured/data_unstructured.F90	(revision 683)
+++ codes/icosagcm/devel/src/unstructured/data_unstructured.F90	(revision 688)
@@ -5,13 +5,5 @@
   SAVE
 
-#define BINDC_(thename) BIND(C, name=#thename)
-#define BINDC(thename) BINDC_(dynamico_ ## thename)
-
-#define DBL REAL(C_DOUBLE)
-#define DOUBLE1(m) DBL, DIMENSION(m)
-#define DOUBLE2(m,n) DBL, DIMENSION(m,n)
-#define DOUBLE3(m,n,p) DBL, DIMENSION(m,n,p)
-#define DOUBLE4(m,n,p,q) DBL, DIMENSION(m,n,p,q)
-#define INDEX INTEGER(C_INT)
+  #include "unstructured.h90"
 
   INTEGER, PARAMETER :: eta_mass=1, eta_lag=2, &
@@ -34,11 +26,11 @@
   ! circulation is positive when going from down to up
 
-  DBL, BIND(C) :: elapsed, g, ptop, cpp, cppv, Rd, Rv, preff, Treff, &
-       pbot, Phi_bot, rho_bot
-  DBL :: kappa
-  DOUBLE1(max_nb_stage), BIND(C)              :: tauj       ! diagonal of fast Butcher tableau
-  DOUBLE2(max_nb_stage,max_nb_stage), BIND(C) :: cslj, cflj ! slow and fast modified Butcher tableaus
-  DOUBLE1(:), ALLOCATABLE            :: le_de, fv, Av, Ai
-  DOUBLE2(:,:), ALLOCATABLE          :: Riv2, wee, ap,bp, mass_bl, mass_dak, mass_dbk
+  TIME, BIND(C) :: elapsed
+  NUM, BIND(C) :: g, ptop, cpp, cppv, Rd, Rv, preff, Treff, pbot, Phi_bot, rho_bot
+  NUM :: kappa
+  NUM1(max_nb_stage), BIND(C)              :: tauj       ! diagonal of fast Butcher tableau
+  NUM2(max_nb_stage,max_nb_stage), BIND(C) :: cslj, cflj ! slow and fast modified Butcher tableaus
+  NUM1(:), ALLOCATABLE            :: le_de, fv, Av, Ai
+  NUM2(:,:), ALLOCATABLE          :: Riv2, wee, ap,bp, mass_bl, mass_dak, mass_dbk
 
   INTEGER(C_INT), BIND(C) :: comm_icosa
@@ -47,5 +39,5 @@
        id_pvort_only=3, id_slow_hydro=4, id_fast=5, id_coriolis=6, id_theta=7, id_geopot=8, id_vert=9, &
        id_solver=10, id_slow_NH=11, id_NH_geopot=12, id_vert_NH=13, id_update=14, nb_routines=14 
-  DBL, PRIVATE :: start_time, time_spent(nb_routines) ! time spent in each kernel
+  TIME, PRIVATE :: start_time, time_spent(nb_routines) ! time spent in each kernel
   INTEGER, PRIVATE :: current_id, nb_calls(nb_routines)
   INTEGER(KIND=8), PRIVATE :: bytes(nb_routines) ! bytes read or written by each kernel
@@ -61,5 +53,5 @@
           num(:), & ! number of cells to send to / receive from other MPI ranks
           cells(:) ! local indices of cells to send/receive
-     DBL, ALLOCATABLE :: buf2(:,:)
+     NUM, ALLOCATABLE :: buf2(:,:)
   END TYPE Halo_transfer
   TYPE(Halo_transfer), TARGET :: send_info(transfer_max), recv_info(transfer_max)
@@ -79,5 +71,5 @@
   SUBROUTINE print_trace()
     INTEGER :: id
-    DBL :: total_spent
+    TIME :: total_spent
     !$OMP MASTER
     total_spent=SUM(time_spent)
@@ -106,5 +98,5 @@
 
   SUBROUTINE exit_trace()
-    DBL :: elapsed
+    TIME :: elapsed
     !$OMP MASTER
     elapsed = OMP_GET_WTIME()-start_time
@@ -180,10 +172,11 @@
   END SUBROUTINE init_mesh
 
+  ! Input arrays to init_metric and init_hybrid are declared DBL
+  ! => always float64 on the Python side
+  ! They are copied to Fortran arrays of type NUM (float or double)
+
   SUBROUTINE init_metric(Ai_, Av_, fv_, le_de_, Riv2_, wee_) BINDC(init_metric)
-    DOUBLE1(primal_num) :: Ai_
-    DOUBLE1(dual_num)   :: Av_, fv_
-    DOUBLE1(edge_num)   :: le_de_
-    DOUBLE2(max_dual_deg,dual_num) :: Riv2_
-    DOUBLE2(max_trisk_deg,edge_num) :: wee_
+    DBL :: Ai_(primal_num), Av_(dual_num), fv_(dual_num), le_de_(edge_num), &
+         Riv2_(max_dual_deg,dual_num), wee_(max_trisk_deg,edge_num)
     PRINT *, 'init_metric ...'
     ALLOC1(Ai,primal_num)
@@ -235,6 +228,6 @@
   !
   SUBROUTINE init_hybrid(bl,dak,dbk) BINDC(init_hybrid)
-    DOUBLE2(llm+1, primal_num) :: bl
-    DOUBLE2(llm, primal_num) :: dak,dbk
+    DBL :: bl(llm+1, primal_num), &
+         dak(llm, primal_num), dbk(llm, primal_num)
     PRINT *, 'Setting hybrid coefficients ...'
     ALLOC2(mass_bl, llm+1, primal_num)
