Index: codes/icosagcm/trunk/src/write_field.f90
===================================================================
--- codes/icosagcm/trunk/src/write_field.f90	(revision 118)
+++ codes/icosagcm/trunk/src/write_field.f90	(revision 119)
@@ -72,7 +72,14 @@
       INTEGER,OPTIONAL,INTENT(IN) :: nind
       LOGICAL,OPTIONAL,INTENT(IN) :: once
+      LOGICAL                     :: once_
       
       TYPE(t_field),POINTER :: field_glo(:)
       
+      IF(PRESENT(once)) THEN
+         once_=once
+      ELSE
+         once_=.FALSE.
+      END IF
+
       IF (field(1)%ndim==2) THEN
         CALL allocate_field_glo(field_glo,field(1)%field_type,field(1)%data_type)
@@ -87,7 +94,7 @@
       IF (mpi_rank==0) THEN
         IF (PRESENT(nind)) THEN
-         CALL writefield_gen(name_in,field_glo,domain_glo,nind,once=once)
+         CALL writefield_gen(name_in,field_glo,domain_glo,nind,once=once_)
         ELSE
-         CALL writefield_gen(name_in,field_glo,domain_glo,1,ndomain_glo,once=once)
+         CALL writefield_gen(name_in,field_glo,domain_glo,1,ndomain_glo,once=once_)
         ENDIF
       ENDIF
@@ -337,5 +344,5 @@
       REAL(r8),ALLOCATABLE :: field_val3d(:,:)
       REAL(r8),ALLOCATABLE :: field_val4d(:,:,:)
-      LOGICAL,OPTIONAL, INTENT(IN) :: once
+      LOGICAL, INTENT(IN) :: once
       TYPE(t_domain),POINTER :: d
       INTEGER :: Index
@@ -348,5 +355,4 @@
       INTEGER :: halo_size
       LOGICAL :: single
-      
       
       name=TRIM(ADJUSTL(name_in))
@@ -412,5 +418,5 @@
           ENDDO
 
-          IF (PRESENT(once) .AND. once) THEN 
+          IF (once) THEN 
             status=NF90_PUT_VAR(FieldId(Index),FieldVarId(index)%nc_id(1),Field_val2d,  &
                                start=(/ 1 /),count=(/ncell /))
@@ -437,5 +443,5 @@
           ENDDO
            
-          IF (PRESENT(once) .AND. once) THEN 
+          IF (once) THEN 
             status=NF90_PUT_VAR(FieldId(Index),FieldVarId(index)%nc_id(1),Field_val3d,start=(/ 1,1 /),   &
                                  count=(/ncell,size(field(1)%rval3d,2) /))
@@ -465,5 +471,5 @@
             ENDDO
             
-            IF (PRESENT(once) .AND. once) THEN 
+            IF (once) THEN 
               status=NF90_PUT_VAR(FieldId(Index),FieldVarId(index)%nc_id(q),Field_val3d,start=(/ 1,1 /),   &
                                  count=(/ncell,size(field(1)%rval4d,2),1 /))
@@ -524,5 +530,5 @@
           ENDDO
           
-          IF (PRESENT(once) .AND. once) THEN 
+          IF (once) THEN 
             status=NF90_PUT_VAR(FieldId(Index),FieldVarId(index)%nc_id(1),                       &
                                 Field_val2d,start=(/ 1 /),count=(/ncell /))
@@ -555,5 +561,5 @@
           ENDDO
           
-          IF (PRESENT(once) .AND. once) THEN 
+          IF (once) THEN 
             status=NF90_PUT_VAR(FieldId(Index),FieldVarId(index)%nc_id(1),Field_val3d,start=(/ 1,1 /),   &
                                 count=(/ncell,size(field(1)%rval3d,2) /))
@@ -588,5 +594,5 @@
             ENDDO
 
-            IF (PRESENT(once) .AND. once) THEN 
+            IF (once) THEN 
               status=NF90_PUT_VAR(FieldId(Index),FieldVarId(index)%nc_id(q),Field_val3d,start=(/ 1,1,1 /),   &
                                   count=(/ncell,size(field(1)%rval4d,2) /))
@@ -1161,5 +1167,5 @@
       INTEGER,OPTIONAL,INTENT(IN) :: ind_b_in
       INTEGER,OPTIONAL,INTENT(IN) :: ind_e_in
-      LOGICAL,OPTIONAL,INTENT(IN) :: once
+      LOGICAL,INTENT(IN) :: once
       
       INTEGER :: ncell
@@ -1258,5 +1264,5 @@
 
         IF (Field(ind_b)%ndim==2) THEN
-          IF (PRESENT(once) .AND. once) THEN 
+          IF (once) THEN 
             status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId /),FieldVarId(NbField)%nc_id(1))
           ELSE
@@ -1265,5 +1271,5 @@
           status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(1),"coordinates","lon_i lat_i")
         ELSE IF (Field(ind_b)%ndim==3) THEN
-          IF (PRESENT(once) .AND. once) THEN 
+          IF (once) THEN 
             status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId,dim3id /),FieldVarId(NbField)%nc_id(1))
           ELSE
@@ -1273,5 +1279,5 @@
         ELSE IF (Field(ind_b)%ndim==4) THEN
           DO i=1,FieldVarId(NbField)%size
-            IF (PRESENT(once) .AND. once) THEN 
+            IF (once) THEN 
               status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name))//int2str(i),ncprec,(/ ncellId,dim3id /),  &
                                     FieldVarId(NbField)%nc_id(i))
@@ -1382,5 +1388,5 @@
 
         IF (Field(ind_b)%ndim==2) THEN
-          IF (PRESENT(once) .AND. once) THEN 
+          IF (once) THEN 
             status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId /),FieldVarId(NbField)%nc_id(1))
           ELSE
@@ -1389,5 +1395,5 @@
           status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(1),"coordinates","lon_v lat_v")
         ELSE IF (Field(ind_b)%ndim==3) THEN
-          IF (PRESENT(once) .AND. once) THEN 
+          IF (once) THEN 
             status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)),ncprec,(/ ncellId,dim3id /),FieldVarId(NbField)%nc_id(1))
           ELSE
@@ -1397,5 +1403,5 @@
         ELSE IF (Field(ind_b)%ndim==4) THEN
           DO q=1,FieldVarId(NbField)%size
-            IF (PRESENT(once) .AND. once) THEN 
+            IF (once) THEN 
               status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(name)//int2str(q)),ncprec,             &
                                     (/ ncellId,dim3id /),FieldVarId(NbField)%nc_id(q))
@@ -1510,4 +1516,5 @@
     IMPLICIT NONE
       CHARACTER(LEN=*) :: name
+      CHARACTER(LEN=LEN_TRIM(ADJUSTL(name))) :: name_adj
       TYPE(t_field),POINTER :: field(:)
       INTEGER,OPTIONAL,INTENT(IN) :: nind
@@ -1530,5 +1537,6 @@
           
       NbField=NbField+1
-      FieldName(NbField)=TRIM(ADJUSTL(name))
+      name_adj=TRIM(ADJUSTL(name))  ! work around ICE with pgf90
+      FieldName(NbField)=name_adj
       FieldIndex(NbField)=1
       
@@ -1736,5 +1744,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)),ncprec,             &
+            status = NF90_DEF_VAR(ncid,name_adj//int2str(q),ncprec,             &
                                   (/ ncellId,dim3id,timeId /),FieldVarId(NbField)%nc_id(q))
             status = NF90_PUT_ATT(ncid,FieldVarId(NbField)%nc_id(q),"coordinates","lon lat")
