Index: /codes/icosagcm/trunk/src/icosa_gcm.f90
===================================================================
--- /codes/icosagcm/trunk/src/icosa_gcm.f90	(revision 81)
+++ /codes/icosagcm/trunk/src/icosa_gcm.f90	(revision 82)
@@ -23,4 +23,5 @@
   CALL compute_domain
   CALL init_transfert
+  CALL init_writefield
 !  CALL allocate_field(sum_ne,field_T,type_real)
 !  CALL allocate_field_glo(sum_ne_glo,field_T,type_real)
@@ -78,7 +79,9 @@
 !  CALL WriteField("sum_ne",sum_ne)
   CALL write_apbp
+  CALL create_time_counter_header
   CALL timeloop
 
   CALL close_files
+  CALL close_time_counter
   CALL finalize_mpipara
   
Index: /codes/icosagcm/trunk/src/icosa_mod.f90
===================================================================
--- /codes/icosagcm/trunk/src/icosa_mod.f90	(revision 81)
+++ /codes/icosagcm/trunk/src/icosa_mod.f90	(revision 82)
@@ -14,4 +14,5 @@
   USE write_field
   USE transfert_mod
+  USE time_mod
   
   ! Variables defined by run.def
Index: /codes/icosagcm/trunk/src/time.f90
===================================================================
--- /codes/icosagcm/trunk/src/time.f90	(revision 82)
+++ /codes/icosagcm/trunk/src/time.f90	(revision 82)
@@ -0,0 +1,61 @@
+MODULE time_mod
+
+  PRIVATE
+
+  INTEGER,SAVE :: ncid
+  INTEGER,SAVE :: time_counter_id
+  INTEGER,SAVE :: it
+
+  PUBLIC create_time_counter_header, update_time_counter, close_time_counter
+
+
+
+CONTAINS
+
+  SUBROUTINE create_time_counter_header
+  USE netcdf_mod
+  USE prec
+  USE ioipsl
+  IMPLICIT NONE
+  INTEGER :: status
+  INTEGER :: timeid, dtid
+  REAL(rstd) :: dt
+    status = NF90_CREATE('time_counter.nc', NF90_CLOBBER, ncid)
+    status = NF90_DEF_DIM(ncid,'time_counter',NF90_UNLIMITED,timeid)
+    status = NF90_DEF_VAR(ncid,'time_counter',NF90_DOUBLE,(/ timeid /),time_counter_id)
+    status = NF90_PUT_ATT(ncid,time_counter_id,"long_name","time")
+    status = NF90_PUT_ATT(ncid,time_counter_id,"units","seconds since 2000-01-01 00:00:00")
+    status = NF90_PUT_ATT(ncid,time_counter_id,"calendar","noleap")
+    status = NF90_DEF_VAR(ncid,'mdt',NF90_DOUBLE,varid=dtid)
+    status = NF90_ENDDEF(ncid) 
+
+    CALL getin("dt",dt)
+    status=NF90_PUT_VAR(ncid,dtid, dt)
+    it=0
+
+  END SUBROUTINE create_time_counter_header
+  
+  SUBROUTINE update_time_counter(time)
+  USE netcdf_mod
+  USE prec
+  IMPLICIT NONE
+  REAL(rstd),INTENT(IN) ::time
+  INTEGER :: status
+  REAL(rstd) ::time_array(1)
+    time_array(1)=time
+  
+    it=it+1
+    status=NF90_PUT_VAR(ncid,time_counter_id,time_array,start=(/ it /),count=(/ 1 /))
+    status=NF90_SYNC(ncid)
+  END SUBROUTINE update_time_counter    
+  
+  SUBROUTINE close_time_counter
+  USE netcdf_mod
+  IMPLICIT NONE
+    INTEGER :: status
+    
+    status=NF90_CLOSE(ncid)
+    
+  END SUBROUTINE  close_time_counter 
+
+END MODULE time_mod
Index: /codes/icosagcm/trunk/src/write_field.f90
===================================================================
--- /codes/icosagcm/trunk/src/write_field.f90	(revision 81)
+++ /codes/icosagcm/trunk/src/write_field.f90	(revision 82)
@@ -2,5 +2,7 @@
 USE genmod
 implicit none
-
+  
+  INTEGER,SAVE :: ncprec
+  
   TYPE ncvar
     INTEGER :: size
@@ -19,4 +21,24 @@
   contains
   
+    SUBROUTINE init_writeField
+    USE ioipsl
+    use netcdf_mod
+    IMPLICIT NONE
+      CHARACTER(LEN=255) :: netcdf_prec
+      
+      netcdf_prec='float'
+      CALL getin("netcdf_prec",netcdf_prec)
+      
+      SELECT CASE(TRIM(netcdf_prec))
+        CASE('float')
+          ncprec=NF90_FLOAT
+        CASE('double')
+          ncprec=NF90_DOUBLE
+        CASE default
+        PRINT*,'Bad selector for variable netcdf_prec : <', TRIM(netcdf_prec),"> options are <float>, <double>" 
+        STOP   
+      END SELECT
+    END SUBROUTINE init_writeField
+    
     function GetFieldIndex(name)
     implicit none
@@ -1198,12 +1220,12 @@
 
         IF (Field(ind_b)%ndim==2) THEN
-          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),NF90_DOUBLE,(/ ncellId,timeId /),FieldVarId(NbField)%nc_id(1))
+          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId,timeId /),FieldVarId(NbField)%nc_id(1))
           status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(1),"coordinates","lon_i lat_i")
         ELSE IF (Field(ind_b)%ndim==3) THEN
-          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),NF90_DOUBLE,(/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(1))
+          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(1))
           status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(1),"coordinates","lon_i lat_i")
         ELSE IF (Field(ind_b)%ndim==4) THEN
           DO i=1,FieldVarId(NbField)%size
-            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name))//int2str(i),NF90_DOUBLE,(/ ncellId,dim3id,timeId /),  &
+            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name))//int2str(i),ncprec,(/ ncellId,dim3id,timeId /),  &
                                   FieldVarId(NbField)%nc_id(i))
             status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(i),"coordinates","lon_i lat_i")
@@ -1309,12 +1331,12 @@
 
         IF (Field(ind_b)%ndim==2) THEN
-          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),NF90_DOUBLE,(/ ncellId,timeId /),FieldVarId(NbField)%nc_id(1))
+          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId,timeId /),FieldVarId(NbField)%nc_id(1))
           status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(1),"coordinates","lon_v lat_v")
         ELSE IF (Field(ind_b)%ndim==3) THEN
-          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),NF90_DOUBLE,(/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(1))
+          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(1))
           status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(1),"coordinates","lon_v lat_v")
         ELSE IF (Field(ind_b)%ndim==4) THEN
           DO q=1,FieldVarId(NbField)%size
-            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)//int2str(q)),NF90_DOUBLE,             &
+            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)//int2str(q)),ncprec,             &
                                   (/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(q))
             status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(q),"coordinates","lon_v lat_v")
@@ -1517,9 +1539,9 @@
 
         IF (Field(ind_b)%ndim==2) THEN
-          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),NF90_DOUBLE,(/ ncellId,timeId /),FieldVarId(NbField)%nc_id(1))
+          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId,timeId /),FieldVarId(NbField)%nc_id(1))
           status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(1),"coordinates","lon lat")
           status = NF90_DEF_VAR_CHUNKING(ncid, FieldVarId(NbField)%nc_id(1), NF90_CHUNKED, (/ncell_tot,1/))
         ELSE IF (Field(ind_b)%ndim==3) THEN
-          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),NF90_DOUBLE,(/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(1))
+          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(1))
           status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(1),"coordinates","lon lat")
           status = NF90_DEF_VAR_CHUNKING(ncid, FieldVarId(NbField)%nc_id(1), NF90_CHUNKED,   &
@@ -1527,5 +1549,5 @@
         ELSE IF (Field(ind_b)%ndim==4) THEN
           DO i=1,FieldVarId(NbField)%size
-            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name))//int2str(i),NF90_DOUBLE,(/ ncellId,dim3id,timeId /),  &
+            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name))//int2str(i),ncprec,(/ ncellId,dim3id,timeId /),  &
                                   FieldVarId(NbField)%nc_id(i))
             status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(i),"coordinates","lon lat")
@@ -1640,9 +1662,9 @@
 
         IF (Field(ind_b)%ndim==2) THEN
-          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),NF90_DOUBLE,(/ ncellId,timeId /),FieldVarId(NbField)%nc_id(1))
+          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId,timeId /),FieldVarId(NbField)%nc_id(1))
           status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(1),"coordinates","lon lat")
           status = NF90_DEF_VAR_CHUNKING(ncid, FieldVarId(NbField)%nc_id(1), NF90_CHUNKED, (/ncell_tot,1/))
         ELSE IF (Field(ind_b)%ndim==3) THEN
-          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),NF90_DOUBLE,(/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(1))
+          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(1))
           status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(1),"coordinates","lon lat")
           status = NF90_DEF_VAR_CHUNKING(ncid, FieldVarId(NbField)%nc_id(1), NF90_CHUNKED,   &
@@ -1650,5 +1672,5 @@
         ELSE IF (Field(ind_b)%ndim==4) THEN
           DO q=1,FieldVarId(NbField)%size
-            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)//int2str(q)),NF90_DOUBLE,             &
+            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)//int2str(q)),ncprec,             &
                                   (/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(q))
             status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(q),"coordinates","lon lat")
