Index: codes/icosagcm/trunk/src/field.f90
===================================================================
--- codes/icosagcm/trunk/src/field.f90	(revision 12)
+++ codes/icosagcm/trunk/src/field.f90	(revision 26)
@@ -26,4 +26,6 @@
     INTEGER :: field_type
     INTEGER :: data_type 
+    INTEGER :: dim3
+    INTEGER :: dim4
   END TYPE t_field   
 
@@ -59,6 +61,8 @@
       IF (PRESENT(dim2)) THEN
         field(ind)%ndim=4 
+        field(ind)%dim4=dim2 
       ELSE IF (PRESENT(dim1)) THEN
         field(ind)%ndim=3
+        field(ind)%dim3=dim1
       ELSE
         field(ind)%ndim=2
@@ -96,5 +100,121 @@
    
   END SUBROUTINE allocate_field
-  
+
+  SUBROUTINE allocate_field_glo(field,field_type,data_type,dim1,dim2)
+  USE domain_mod
+  IMPLICIT NONE
+    TYPE(t_field),POINTER :: field(:)
+    INTEGER,INTENT(IN) :: field_type
+    INTEGER,INTENT(IN) :: data_type
+    INTEGER,OPTIONAL :: dim1,dim2
+    INTEGER :: ind
+    INTEGER :: ii_size,jj_size
+
+    ALLOCATE(field(ndomain_glo))    
+
+    DO ind=1,ndomain_glo
+  
+      IF (PRESENT(dim2)) THEN
+        field(ind)%ndim=4 
+        field(ind)%dim4=dim2 
+      ELSE IF (PRESENT(dim1)) THEN
+        field(ind)%ndim=3
+        field(ind)%dim3=dim1 
+      ELSE
+        field(ind)%ndim=2
+      ENDIF
+    
+    
+      field(ind)%data_type=data_type
+      field(ind)%field_type=field_type
+    
+      IF (field_type==field_T) THEN 
+        jj_size=domain_glo(ind)%jjm
+      ELSE IF (field_type==field_U) THEN 
+        jj_size=3*domain_glo(ind)%jjm
+      ELSE IF (field_type==field_Z) THEN 
+        jj_size=2*domain_glo(ind)%jjm
+      ENDIF
+      
+      ii_size=domain_glo(ind)%iim
+        
+      IF (field(ind)%ndim==4) THEN
+        IF (data_type==type_integer) ALLOCATE(field(ind)%ival4d(ii_size*jj_size,dim1,dim2))
+        IF (data_type==type_real)    ALLOCATE(field(ind)%rval4d(ii_size*jj_size,dim1,dim2))
+        IF (data_type==type_logical) ALLOCATE(field(ind)%lval4d(ii_size*jj_size,dim1,dim2))
+      ELSE IF (field(ind)%ndim==3) THEN
+        IF (data_type==type_integer) ALLOCATE(field(ind)%ival3d(ii_size*jj_size,dim1))
+        IF (data_type==type_real)    ALLOCATE(field(ind)%rval3d(ii_size*jj_size,dim1))
+        IF (data_type==type_logical) ALLOCATE(field(ind)%lval3d(ii_size*jj_size,dim1))
+      ELSE IF (field(ind)%ndim==2) THEN
+        IF (data_type==type_integer) ALLOCATE(field(ind)%ival2d(ii_size*jj_size))
+        IF (data_type==type_real)    ALLOCATE(field(ind)%rval2d(ii_size*jj_size))
+        IF (data_type==type_logical) ALLOCATE(field(ind)%lval2d(ii_size*jj_size))
+      ENDIF
+      
+   ENDDO
+  
+  END SUBROUTINE allocate_field_glo
+
+  SUBROUTINE deallocate_field(field)
+  USE domain_mod
+  IMPLICIT NONE
+    TYPE(t_field),POINTER :: field(:)
+    INTEGER :: data_type
+    INTEGER :: ind
+
+    DO ind=1,ndomain
+
+      data_type=field(ind)%data_type
+        
+      IF (field(ind)%ndim==4) THEN
+        IF (data_type==type_integer) DEALLOCATE(field(ind)%ival4d)
+        IF (data_type==type_real)    DEALLOCATE(field(ind)%rval4d)
+        IF (data_type==type_logical) DEALLOCATE(field(ind)%lval4d)
+      ELSE IF (field(ind)%ndim==3) THEN
+        IF (data_type==type_integer) DEALLOCATE(field(ind)%ival3d)
+        IF (data_type==type_real)    DEALLOCATE(field(ind)%rval3d)
+        IF (data_type==type_logical) DEALLOCATE(field(ind)%lval3d)
+      ELSE IF (field(ind)%ndim==2) THEN
+        IF (data_type==type_integer) DEALLOCATE(field(ind)%ival2d)
+        IF (data_type==type_real)    DEALLOCATE(field(ind)%rval2d)
+        IF (data_type==type_logical) DEALLOCATE(field(ind)%lval2d)
+      ENDIF
+      
+   ENDDO
+   DEALLOCATE(field)
+       
+  END SUBROUTINE deallocate_field
+
+  SUBROUTINE deallocate_field_glo(field)
+  USE domain_mod
+  IMPLICIT NONE
+    TYPE(t_field),POINTER :: field(:)
+    INTEGER :: data_type
+    INTEGER :: ind
+
+    DO ind=1,ndomain_glo
+
+      data_type=field(ind)%data_type
+        
+      IF (field(ind)%ndim==4) THEN
+        IF (data_type==type_integer) DEALLOCATE(field(ind)%ival4d)
+        IF (data_type==type_real)    DEALLOCATE(field(ind)%rval4d)
+        IF (data_type==type_logical) DEALLOCATE(field(ind)%lval4d)
+      ELSE IF (field(ind)%ndim==3) THEN
+        IF (data_type==type_integer) DEALLOCATE(field(ind)%ival3d)
+        IF (data_type==type_real)    DEALLOCATE(field(ind)%rval3d)
+        IF (data_type==type_logical) DEALLOCATE(field(ind)%lval3d)
+      ELSE IF (field(ind)%ndim==2) THEN
+        IF (data_type==type_integer) DEALLOCATE(field(ind)%ival2d)
+        IF (data_type==type_real)    DEALLOCATE(field(ind)%rval2d)
+        IF (data_type==type_logical) DEALLOCATE(field(ind)%lval2d)
+      ENDIF
+      
+   ENDDO
+   DEALLOCATE(field)
+       
+  END SUBROUTINE deallocate_field_glo
+    
   SUBROUTINE getval_r2d(field_pt,field)
   IMPLICIT NONE  
