Index: codes/icosagcm/trunk/src/base/field.f90
===================================================================
--- codes/icosagcm/trunk/src/base/field.f90	(revision 962)
+++ codes/icosagcm/trunk/src/base/field.f90	(revision 963)
@@ -13,7 +13,7 @@
   TYPE t_field
     CHARACTER(30)      :: name
-    REAL(rstd),POINTER :: rval2d(:) => null()
-    REAL(rstd),POINTER :: rval3d(:,:) => null()
-    REAL(rstd),POINTER :: rval4d(:,:,:) => null()
+    REAL(rstd),POINTER, CONTIGUOUS :: rval2d(:) => null()
+    REAL(rstd),POINTER, CONTIGUOUS :: rval3d(:,:) => null()
+    REAL(rstd),POINTER, CONTIGUOUS :: rval4d(:,:,:) => null()
 
     INTEGER,POINTER :: ival2d(:)
@@ -274,79 +274,78 @@
        IF (field(ind)%ndim==4) THEN
           IF (data_type==type_integer) THEN
+             IF (field(ind)%ondevice) THEN
+                !$acc exit data delete(field(ind)%ival4d(:,:,:))
+                CONTINUE
+             END IF
              DEALLOCATE(field(ind)%ival4d)
-             IF (field(ind)%ondevice) THEN
-                !$acc exit data delete(field(ind)%ival4d)
-                CONTINUE
-             END IF
           END IF
 
           IF (data_type==type_real) THEN
+             IF (field(ind)%ondevice) THEN
+                !$acc exit data delete(field(ind)%rval4d(:,:,:))
+                CONTINUE
+             END IF
              DEALLOCATE(field(ind)%rval4d)
-             IF (field(ind)%ondevice) THEN
-                !$acc exit data delete(field(ind)%rval4d)
-                CONTINUE
-             END IF
           END IF
 
           IF (data_type==type_logical) THEN
+             IF (field(ind)%ondevice) THEN
+                !$acc exit data delete(field(ind)%lval4d(:,:,:))
+                CONTINUE
+             END IF
              DEALLOCATE(field(ind)%lval4d)
-             IF (field(ind)%ondevice) THEN
-                !$acc exit data delete(field(ind)%lval4d)
-                CONTINUE
-             END IF
           END IF
 
        ELSE IF (field(ind)%ndim==3) THEN
           IF (data_type==type_integer) THEN
+             IF (field(ind)%ondevice) THEN
+                !$acc exit data delete(field(ind)%ival3d(:,:))
+                CONTINUE
+             END IF
              DEALLOCATE(field(ind)%ival3d)
-             IF (field(ind)%ondevice) THEN
-                !$acc exit data delete(field(ind)%ival3d)
-                CONTINUE
-             END IF
           END IF
 
           IF (data_type==type_real) THEN
+             IF (field(ind)%ondevice) THEN
+                !$acc exit data delete(field(ind)%rval3d(:,:))
+                CONTINUE
+             END IF
              DEALLOCATE(field(ind)%rval3d)
-             IF (field(ind)%ondevice) THEN
-                !$acc exit data delete(field(ind)%rval3d)
-                CONTINUE
-             END IF
           END IF
 
           IF (data_type==type_logical) THEN
+             IF (field(ind)%ondevice) THEN
+                !$acc exit data delete(field(ind)%lval3d(:,:))
+                CONTINUE
+             END IF
              DEALLOCATE(field(ind)%lval3d)
-             IF (field(ind)%ondevice) THEN
-                !$acc exit data delete(field(ind)%lval3d)
-                CONTINUE
-             END IF
           END IF
 
        ELSE IF (field(ind)%ndim==2) THEN
           IF (data_type==type_integer) THEN
+             IF (field(ind)%ondevice) THEN
+                !$acc exit data delete(field(ind)%ival2d(:))
+                CONTINUE
+             END IF
              DEALLOCATE(field(ind)%ival2d)
-             IF (field(ind)%ondevice) THEN
-                !$acc exit data delete(field(ind)%ival2d)
-                CONTINUE
-             END IF
           END IF
 
           IF (data_type==type_real) THEN
+             IF (field(ind)%ondevice) THEN
+                !$acc exit data delete(field(ind)%rval2d(:))
+                CONTINUE
+             END IF
              DEALLOCATE(field(ind)%rval2d)
-             IF (field(ind)%ondevice) THEN
-                !$acc exit data delete(field(ind)%rval2d)
-                CONTINUE
-             END IF
           END IF
 
           IF (data_type==type_logical) THEN
+             IF (field(ind)%ondevice) THEN
+                !$acc exit data delete(field(ind)%lval2d(:))
+                CONTINUE
+             END IF
              DEALLOCATE(field(ind)%lval2d)
-             IF (field(ind)%ondevice) THEN
-                !$acc exit data delete(field(ind)%lval2d)
-                CONTINUE
-             END IF
           END IF
 
        ENDIF
-
     ENDDO
   END SUBROUTINE deallocate_field_
@@ -555,15 +554,15 @@
       IF (field(ind)%ndim==4) THEN
          IF (field(ind)%data_type==type_integer) THEN
-            !$acc update device(field(ind)%ival4d(:,:,:))
+            !$acc update device(field(ind)%ival4d(:,:,:)) async
             CONTINUE
          END IF
 
          IF (field(ind)%data_type==type_real) THEN
-            !$acc update device(field(ind)%rval4d(:,:,:))
+            !$acc update device(field(ind)%rval4d(:,:,:)) async
             CONTINUE
          END IF
 
          IF (field(ind)%data_type==type_logical) THEN
-            !$acc update device(field(ind)%lval4d(:,:,:))
+            !$acc update device(field(ind)%lval4d(:,:,:)) async
             CONTINUE
          END IF
@@ -571,15 +570,15 @@
       ELSE IF (field(ind)%ndim==3) THEN
          IF (field(ind)%data_type==type_integer) THEN
-            !$acc update device(field(ind)%ival3d(:,:))
+            !$acc update device(field(ind)%ival3d(:,:)) async
             CONTINUE
          END IF
 
          IF (field(ind)%data_type==type_real) THEN
-            !$acc update device(field(ind)%rval3d(:,:))
+            !$acc update device(field(ind)%rval3d(:,:)) async
             CONTINUE
          END IF
 
          IF (field(ind)%data_type==type_logical) THEN
-            !$acc update device(field(ind)%lval3d(:,:))
+            !$acc update device(field(ind)%lval3d(:,:)) async
             CONTINUE
          END IF
@@ -587,15 +586,15 @@
       ELSE IF (field(ind)%ndim==2) THEN
          IF (field(ind)%data_type==type_integer) THEN
-            !$acc update device(field(ind)%ival2d(:))
+            !$acc update device(field(ind)%ival2d(:)) async
             CONTINUE
          END IF
 
          IF (field(ind)%data_type==type_real) THEN
-            !$acc update device(field(ind)%rval2d(:))
+            !$acc update device(field(ind)%rval2d(:)) async
             CONTINUE
          END IF
 
          IF (field(ind)%data_type==type_logical) THEN
-            !$acc update device(field(ind)%lval2d(:))
+            !$acc update device(field(ind)%lval2d(:)) async
             CONTINUE
          END IF
@@ -616,34 +615,34 @@
 
       IF (field(ind)%ondevice) THEN
-        
+
          IF (field(ind)%ndim==4) THEN
             IF (field(ind)%data_type==type_integer) THEN
-               !$acc update host(field(ind)%ival4d(:,:,:)) wait
+               !$acc update host(field(ind)%ival4d(:,:,:)) async
                CONTINUE
             END IF
 
             IF (field(ind)%data_type==type_real) THEN
-               !$acc update host(field(ind)%rval4d(:,:,:)) wait
+               !$acc update host(field(ind)%rval4d(:,:,:)) async
                CONTINUE
             END IF
 
             IF (field(ind)%data_type==type_logical) THEN
-               !$acc update host(field(ind)%lval4d(:,:,:)) wait
-               CONTINUE
-            END IF
-         
+               !$acc update host(field(ind)%lval4d(:,:,:)) async
+               CONTINUE
+            END IF
+
          ELSE IF (field(ind)%ndim==3) THEN
             IF (field(ind)%data_type==type_integer) THEN
-               !$acc update host(field(ind)%ival3d(:,:)) wait
+               !$acc update host(field(ind)%ival3d(:,:)) async
                CONTINUE
             END IF
 
             IF (field(ind)%data_type==type_real) THEN
-               !$acc update host(field(ind)%rval3d(:,:)) wait
+               !$acc update host(field(ind)%rval3d(:,:)) async
                CONTINUE
             END IF
 
             IF (field(ind)%data_type==type_logical) THEN
-               !$acc update host(field(ind)%lval3d(:,:)) wait
+               !$acc update host(field(ind)%lval3d(:,:)) async
                CONTINUE
             END IF
@@ -651,15 +650,15 @@
          ELSE IF (field(ind)%ndim==2) THEN
             IF (field(ind)%data_type==type_integer) THEN
-               !$acc update host(field(ind)%ival2d(:)) wait
+               !$acc update host(field(ind)%ival2d(:)) async
                CONTINUE
             END IF
 
             IF (field(ind)%data_type==type_real) THEN
-               !$acc update host(field(ind)%rval2d(:)) wait
+               !$acc update host(field(ind)%rval2d(:)) async
                CONTINUE
             END IF
 
             IF (field(ind)%data_type==type_logical) THEN
-               !$acc update host(field(ind)%lval2d(:)) wait
+               !$acc update host(field(ind)%lval2d(:)) async
                CONTINUE
             END IF
@@ -667,4 +666,5 @@
       END IF
    ENDDO
+   !$acc wait
    !$OMP BARRIER
  END SUBROUTINE update_host_field
@@ -679,39 +679,39 @@
     IF (field%ndim==4) THEN
        IF (field%data_type==type_integer) THEN
-          !$acc enter data create(field%ival4d(:,:,:))
+          !$acc enter data create(field%ival4d(:,:,:)) async
        END IF
 
        IF (field%data_type==type_real) THEN
-          !$acc enter data create(field%rval4d(:,:,:))
+          !$acc enter data create(field%rval4d(:,:,:)) async
        END IF
 
        IF (field%data_type==type_logical) THEN
-          !$acc enter data create(field%lval4d(:,:,:))
+          !$acc enter data create(field%lval4d(:,:,:)) async
        END IF
 
     ELSE IF (field%ndim==3) THEN
        IF (field%data_type==type_integer) THEN
-          !$acc enter data create(field%ival3d(:,:))
+          !$acc enter data create(field%ival3d(:,:)) async
        END IF
 
        IF (field%data_type==type_real) THEN
-          !$acc enter data create(field%rval3d(:,:))
+          !$acc enter data create(field%rval3d(:,:)) async
        END IF
 
        IF (field%data_type==type_logical) THEN
-          !$acc enter data create(field%lval3d(:,:))
+          !$acc enter data create(field%lval3d(:,:)) async
        END IF
 
     ELSE IF (field%ndim==2) THEN
        IF (field%data_type==type_integer) THEN
-          !$acc enter data create(field%ival2d(:))
+          !$acc enter data create(field%ival2d(:)) async
        END IF
 
        IF (field%data_type==type_real) THEN
-          !$acc enter data create(field%rval2d(:))
+          !$acc enter data create(field%rval2d(:)) async
        END IF
 
        IF (field%data_type==type_logical) THEN
-          !$acc enter data create(field%lval2d(:))
+          !$acc enter data create(field%lval2d(:)) async
        END IF
     ENDIF
