<p><b>duda</b> 2012-10-03 11:05:43 -0600 (Wed, 03 Oct 2012)</p><p>BRANCH COMMIT<br>
<br>
Add a cpp macro, MPAS_IO_DEBUG, to control debugging write statements in MPAS I/O layer.<br>
<br>
<br>
M    src/framework/mpas_io_streams.F<br>
M    src/framework/mpas_io.F<br>
</p><hr noshade><pre><font color="gray">Modified: branches/asd_io_work/src/framework/mpas_io.F
===================================================================
--- branches/asd_io_work/src/framework/mpas_io.F        2012-10-03 16:17:14 UTC (rev 2174)
+++ branches/asd_io_work/src/framework/mpas_io.F        2012-10-03 17:05:43 UTC (rev 2175)
@@ -1,3 +1,5 @@
+#define MPAS_IO_DEBUG !
+
 module mpas_io
 
    use mpas_dmpar_types
@@ -193,12 +195,12 @@
       integer, intent(in) :: io_task_stride
       integer, intent(out), optional :: ierr
 
-!      write(0,*) 'Called MPAS_io_init()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_init()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       local_dminfo = dminfo
 
-!write(0,*) 'MGD PIO_init'
+MPAS_IO_DEBUG write(0,*) 'MGD PIO_init'
       call PIO_init(local_dminfo % my_proc_id, &amp;     ! comp_rank
                     local_dminfo % comm,       &amp;     ! comp_comm
                     io_task_count,             &amp;     ! num_iotasks
@@ -224,7 +226,7 @@
       integer :: pio_iotype
       integer :: pio_ierr
 
-!      write(0,*) 'Called MPAS_io_open()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_open()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
 
@@ -255,10 +257,10 @@
       end if
 
       if (mode == MPAS_IO_WRITE) then
-!write(0,*) 'MGD PIO_createfile'
+MPAS_IO_DEBUG write(0,*) 'MGD PIO_createfile'
          pio_ierr = PIO_createfile(pio_iosystem, MPAS_io_open % pio_file, pio_iotype, trim(filename), PIO_64BIT_OFFSET)
       else
-!write(0,*) 'MGD PIO_openfile'
+MPAS_IO_DEBUG write(0,*) 'MGD PIO_openfile'
          pio_ierr = PIO_openfile(pio_iosystem, MPAS_io_open % pio_file, pio_iotype, trim(filename), PIO_nowrite)
       endif
       if (pio_ierr /= PIO_noerr) then
@@ -269,7 +271,7 @@
       if (mode == MPAS_IO_READ) then
 !MPAS_io_open % pio_unlimited_dimid = 44
          pio_ierr = PIO_inquire(MPAS_io_open % pio_file, unlimitedDimID=MPAS_io_open % pio_unlimited_dimid)
-!write(0,*) 'Found unlimited dim ', MPAS_io_open % pio_unlimited_dimid
+MPAS_IO_DEBUG write(0,*) 'Found unlimited dim ', MPAS_io_open % pio_unlimited_dimid
          if (pio_ierr /= PIO_noerr) then
             if (present(ierr)) ierr = MPAS_IO_ERR_PIO
             return
@@ -293,7 +295,7 @@
 
       integer :: pio_ierr
 
-!      write(0,*) 'Called MPAS_io_inq_unlimited_dim()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_inq_unlimited_dim()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -329,7 +331,7 @@
       type (dimlist_type), pointer :: dim_cursor
       integer :: pio_ierr
 
-!      write(0,*) 'Called MPAS_io_inq_dim()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_inq_dim()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -410,7 +412,7 @@
       type (dimlist_type), pointer :: new_dimlist_node
       type (dimlist_type), pointer :: dim_cursor
 
-!      write(0,*) 'Called MPAS_io_def_dim()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_def_dim()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -474,15 +476,15 @@
       ! Keep dimension information
       if (.not. associated(handle % dimlist_head)) then
          handle % dimlist_head =&gt; new_dimlist_node
-!write(0,*) 'Assigning head for '//trim(dimname)
+MPAS_IO_DEBUG write(0,*) 'Assigning head for '//trim(dimname)
       end if
       if (.not. associated(handle % dimlist_tail)) then
          handle % dimlist_tail =&gt; new_dimlist_node
-!write(0,*) 'Assigning tail for '//trim(dimname)
+MPAS_IO_DEBUG write(0,*) 'Assigning tail for '//trim(dimname)
       else
          handle % dimlist_tail % next =&gt; new_dimlist_node
          handle % dimlist_tail =&gt; handle % dimlist_tail % next
-!write(0,*) 'Extending tail for '//trim(dimname)
+MPAS_IO_DEBUG write(0,*) 'Extending tail for '//trim(dimname)
       end if
 
    end subroutine MPAS_io_def_dim
@@ -509,7 +511,7 @@
       logical :: found
       integer :: pio_ierr
 
-!      write(0,*) 'Called MPAS_io_inq_var()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_inq_var()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -526,7 +528,7 @@
       field_cursor =&gt; handle % fieldlist_head
       do while (associated(field_cursor))
          if (trim(fieldname) == trim(field_cursor % fieldhandle % fieldname)) then
-!write(0,*) 'Already found variable in fieldlist'
+MPAS_IO_DEBUG write(0,*) 'Already found variable in fieldlist'
             found = .true.
             exit
          end if
@@ -553,7 +555,7 @@
             deallocate(new_fieldlist_node)
             return
          end if
-!write(0,*) 'Inquired about variable ID', new_fieldlist_node % fieldhandle % fieldid
+MPAS_IO_DEBUG write(0,*) 'Inquired about variable ID', new_fieldlist_node % fieldhandle % fieldid
 
          ! Get field type
          pio_ierr = PIO_inq_vartype(handle % pio_file, new_fieldlist_node % fieldhandle % fieldid, new_fieldlist_node % fieldhandle % field_type)
@@ -563,7 +565,7 @@
             deallocate(new_fieldlist_node)
             return
          end if
-!write(0,*) 'Inquired about variable type', new_fieldlist_node % fieldhandle % field_type
+MPAS_IO_DEBUG write(0,*) 'Inquired about variable type', new_fieldlist_node % fieldhandle % field_type
 
          ! Convert to MPAS type
          if (new_fieldlist_node % fieldhandle % field_type == PIO_double) then
@@ -585,7 +587,7 @@
             deallocate(new_fieldlist_node)
             return
          end if
-!write(0,*) 'Inquired about number of dimensions ', new_fieldlist_node % fieldhandle % ndims
+MPAS_IO_DEBUG write(0,*) 'Inquired about number of dimensions ', new_fieldlist_node % fieldhandle % ndims
 
          allocate(dimids(new_fieldlist_node % fieldhandle % ndims))
 
@@ -599,7 +601,7 @@
                deallocate(dimids)
                return
             end if
-!write(0,*) 'Inquired about dimension IDs ', dimids
+MPAS_IO_DEBUG write(0,*) 'Inquired about dimension IDs ', dimids
          end if
 
          allocate(new_fieldlist_node % fieldhandle % dims(new_fieldlist_node % fieldhandle % ndims))
@@ -620,7 +622,7 @@
                deallocate(dimids)
                return
             end if
-!write(0,*) 'Inquired about dimension size ', new_fieldlist_node % fieldhandle % dims(i) % dimsize
+MPAS_IO_DEBUG write(0,*) 'Inquired about dimension size ', new_fieldlist_node % fieldhandle % dims(i) % dimsize
 
             pio_ierr = PIO_inq_dimname(handle % pio_file, dimids(i), new_fieldlist_node % fieldhandle % dims(i) % dimname)
             if (pio_ierr /= PIO_noerr) then
@@ -630,7 +632,7 @@
                deallocate(dimids)
                return
             end if
-!write(0,*) 'Inquired about dimension name ', trim(new_fieldlist_node % fieldhandle % dims(i) % dimname)
+MPAS_IO_DEBUG write(0,*) 'Inquired about dimension name ', trim(new_fieldlist_node % fieldhandle % dims(i) % dimname)
 
          end do
 
@@ -639,15 +641,15 @@
          ! Keep variable information for future reference
          if (.not. associated(handle % fieldlist_head)) then
             handle % fieldlist_head =&gt; new_fieldlist_node
-!write(0,*) 'Assigning head for '//trim(fieldname)
+MPAS_IO_DEBUG write(0,*) 'Assigning head for '//trim(fieldname)
          end if
          if (.not. associated(handle % fieldlist_tail)) then
             handle % fieldlist_tail =&gt; new_fieldlist_node
-!write(0,*) 'Assigning tail for '//trim(fieldname)
+MPAS_IO_DEBUG write(0,*) 'Assigning tail for '//trim(fieldname)
          else
             handle % fieldlist_tail % next =&gt; new_fieldlist_node
             handle % fieldlist_tail =&gt; handle % fieldlist_tail % next
-!write(0,*) 'Extending tail for '//trim(fieldname)
+MPAS_IO_DEBUG write(0,*) 'Extending tail for '//trim(fieldname)
          end if
 
          ! Keep dimension information for any new dimensions that were encountered
@@ -656,7 +658,7 @@
             dim_cursor =&gt; handle % dimlist_head
             do while (associated(dim_cursor))
                if (trim(dim_cursor % dimhandle % dimname) == trim(new_fieldlist_node % fieldhandle % dims(i) % dimname)) then
-!write(0,*) 'Already have dimension '//trim(new_fieldlist_node % fieldhandle % dims(i) % dimname)//' in our list...'
+MPAS_IO_DEBUG write(0,*) 'Already have dimension '//trim(new_fieldlist_node % fieldhandle % dims(i) % dimname)//' in our list...'
                   found = .true.
                   exit
                end if
@@ -670,15 +672,15 @@
                new_dimlist_node % dimhandle = new_fieldlist_node % fieldhandle % dims(i)
                if (.not. associated(handle % dimlist_head)) then
                   handle % dimlist_head =&gt; new_dimlist_node
-!write(0,*) 'Assigning head for '//trim(new_dimlist_node % dimhandle % dimname)
+MPAS_IO_DEBUG write(0,*) 'Assigning head for '//trim(new_dimlist_node % dimhandle % dimname)
                end if
                if (.not. associated(handle % dimlist_tail)) then
                   handle % dimlist_tail =&gt; new_dimlist_node
-!write(0,*) 'Assigning tail for '//trim(new_dimlist_node % dimhandle % dimname)
+MPAS_IO_DEBUG write(0,*) 'Assigning tail for '//trim(new_dimlist_node % dimhandle % dimname)
                else
                   handle % dimlist_tail % next =&gt; new_dimlist_node
                   handle % dimlist_tail =&gt; handle % dimlist_tail % next
-!write(0,*) 'Extending tail for '//trim(new_dimlist_node % dimhandle % dimname)
+MPAS_IO_DEBUG write(0,*) 'Extending tail for '//trim(new_dimlist_node % dimhandle % dimname)
                end if
             end if
          end do
@@ -726,7 +728,7 @@
       type (dimlist_type), pointer :: dim_cursor
       integer, dimension(:), pointer :: dimids
 
-!      write(0,*) 'Called MPAS_io_def_var()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_def_var()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -748,19 +750,19 @@
       ! Check whether this field has already been defined
       !
       ndims = size(dimnames)
-!write(0,*) 'Defining variable with ',ndims,' dimensions'
+MPAS_IO_DEBUG write(0,*) 'Defining variable with ',ndims,' dimensions'
       field_cursor =&gt; handle % fieldlist_head
       do while (associated(field_cursor))
          if (trim(fieldname) == trim(field_cursor % fieldhandle % fieldname)) then
             if (ndims /= field_cursor % fieldhandle % ndims) then
                if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_VAR
-!               write(0,*) 'Error: Field '//trim(fieldname)//' previously defined with conflicting number of dimensions: ', &amp;
-!                           ndims, field_cursor % fieldhandle % ndims
+MPAS_IO_DEBUG                write(0,*) 'Error: Field '//trim(fieldname)//' previously defined with conflicting number of dimensions: ', &amp;
+MPAS_IO_DEBUG                            ndims, field_cursor % fieldhandle % ndims
             end if
             if (fieldtype /= field_cursor % fieldhandle % field_type) then
                if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_VAR
-!               write(0,*) 'Error: Field '//trim(fieldname)//' previously defined with conflicting type: ', &amp;
-!                           fieldtype, field_cursor % fieldhandle % field_type
+MPAS_IO_DEBUG                write(0,*) 'Error: Field '//trim(fieldname)//' previously defined with conflicting type: ', &amp;
+MPAS_IO_DEBUG                            fieldtype, field_cursor % fieldhandle % field_type
             end if
             return
          end if
@@ -792,7 +794,7 @@
             dimids(i) = dim_cursor % dimhandle % dimid
             if (dim_cursor % dimhandle % is_unlimited_dim) new_fieldlist_node % fieldhandle % has_unlimited_dim = .true.
             new_fieldlist_node % fieldhandle % dims(i) = dim_cursor % dimhandle
-!write(0,*) 'Found dimension '//trim(new_fieldlist_node % fieldhandle % dims(i) % dimname)//' for field '//trim(fieldname)
+MPAS_IO_DEBUG write(0,*) 'Found dimension '//trim(new_fieldlist_node % fieldhandle % dims(i) % dimname)//' for field '//trim(fieldname)
          else
             if (present(ierr)) ierr = MPAS_IO_ERR_UNDEFINED_DIM
             deallocate(new_fieldlist_node % fieldhandle % dims)
@@ -800,7 +802,7 @@
             deallocate(new_fieldlist_node)
             deallocate(dimids)
             return
-!            write(0,*) 'Error finding dimension '//trim(dimnames(i))//' for field '//trim(fieldname)
+MPAS_IO_DEBUG             write(0,*) 'Error finding dimension '//trim(dimnames(i))//' for field '//trim(fieldname)
          end if
       end do
 
@@ -838,15 +840,15 @@
       ! Keep variable information for future use
       if (.not. associated(handle % fieldlist_head)) then
          handle % fieldlist_head =&gt; new_fieldlist_node
-!write(0,*) 'Assigning head for '//trim(fieldname)
+MPAS_IO_DEBUG write(0,*) 'Assigning head for '//trim(fieldname)
       end if
       if (.not. associated(handle % fieldlist_tail)) then
          handle % fieldlist_tail =&gt; new_fieldlist_node
-!write(0,*) 'Assigning tail for '//trim(fieldname)
+MPAS_IO_DEBUG write(0,*) 'Assigning tail for '//trim(fieldname)
       else
          handle % fieldlist_tail % next =&gt; new_fieldlist_node
          handle % fieldlist_tail =&gt; handle % fieldlist_tail % next
-!write(0,*) 'Extending tail for '//trim(fieldname)
+MPAS_IO_DEBUG write(0,*) 'Extending tail for '//trim(fieldname)
       end if
 
    end subroutine MPAS_io_def_var
@@ -863,7 +865,7 @@
 
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_indices()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_indices()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -887,7 +889,7 @@
          if (present(ierr)) ierr = MPAS_IO_ERR_UNDEFINED_VAR
          return
       end if
-!write(0,*) trim(fieldname), ' has been defined'
+MPAS_IO_DEBUG write(0,*) trim(fieldname), ' has been defined'
 
       if (.not. associated(field_cursor % fieldhandle % decomp)) then
          if (present(ierr)) ierr = MPAS_IO_ERR_NO_DECOMP
@@ -916,7 +918,7 @@
       integer, dimension(:), pointer :: dimlist, compdof
       type (decomplist_type), pointer :: decomp_cursor, new_decomp
 
-!      write(0,*) 'Called MPAS_io_set_var_indices()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_set_var_indices()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -925,7 +927,7 @@
          return 
       end if
 
-!      write(0,*) 'Assigning ', size(indices), ' indices for ', trim(fieldname)
+MPAS_IO_DEBUG       write(0,*) 'Assigning ', size(indices), ' indices for ', trim(fieldname)
 
 
       !  
@@ -942,7 +944,7 @@
          if (present(ierr)) ierr = MPAS_IO_ERR_UNDEFINED_VAR
          return
       end if
-!write(0,*) trim(fieldname), ' has been defined'
+MPAS_IO_DEBUG write(0,*) trim(fieldname), ' has been defined'
 
       !
       ! If this is a scalar field, just return
@@ -950,7 +952,7 @@
       if (field_cursor % fieldhandle % ndims == 0 .or. &amp;
           (field_cursor % fieldhandle % ndims == 1 .and. field_cursor % fieldhandle % has_unlimited_dim) .or. &amp;
           field_cursor % fieldhandle % field_type == MPAS_IO_CHAR) then
-!write(0,*) 'No need to create a decomposition for a 0d field...'
+MPAS_IO_DEBUG write(0,*) 'No need to create a decomposition for a 0d field...'
          return
       end if
 
@@ -959,13 +961,13 @@
       ! Check whether a suitable decomposition already exists
       !
       decomp_cursor =&gt; decomp_list
-!if (.not. associated(decomp_cursor)) write(0,*) 'No existing decompositions to check...'
+MPAS_IO_DEBUG if (.not. associated(decomp_cursor)) write(0,*) 'No existing decompositions to check...'
       DECOMP_LOOP: do while (associated(decomp_cursor))
          if (decomp_cursor % decomphandle % field_type == field_cursor % fieldhandle % field_type) then
          if (size(decomp_cursor % decomphandle % dims) == field_cursor % fieldhandle % ndims) then
-!write(0,*) 'Number of dimensions matches...'
+MPAS_IO_DEBUG write(0,*) 'Number of dimensions matches...'
             do i=1,field_cursor % fieldhandle % ndims
-!write(0,*) 'Checking dimension ', decomp_cursor % decomphandle % dims(i), field_cursor % fieldhandle % dims(i) % dimsize
+MPAS_IO_DEBUG write(0,*) 'Checking dimension ', decomp_cursor % decomphandle % dims(i), field_cursor % fieldhandle % dims(i) % dimsize
                if (decomp_cursor % decomphandle % dims(i) /= field_cursor % fieldhandle % dims(i) % dimsize) then
                   decomp_cursor =&gt; decomp_cursor % next
                   cycle DECOMP_LOOP
@@ -973,14 +975,14 @@
             end do
 
             if (size(decomp_cursor % decomphandle % indices) /= size(indices)) then
-!write(0,*) 'We do not have the same number of indices in this decomposition...'
+MPAS_IO_DEBUG write(0,*) 'We do not have the same number of indices in this decomposition...'
                decomp_cursor =&gt; decomp_cursor % next
                cycle DECOMP_LOOP
             end if
 
             do i=1,size(decomp_cursor % decomphandle % indices)
                if (indices(i) /= decomp_cursor % decomphandle % indices(i)) then
-!write(0,*) 'One of the indices does not match... ', i
+MPAS_IO_DEBUG write(0,*) 'One of the indices does not match... ', i
                   decomp_cursor =&gt; decomp_cursor % next
                   cycle DECOMP_LOOP
                end if
@@ -988,15 +990,15 @@
             
             ! OK, we have a match... just use this decomposition for the field and return
             field_cursor % fieldhandle % decomp =&gt; decomp_cursor % decomphandle 
-!write(0,*) 'Found a matching decomposition that we can use'
+MPAS_IO_DEBUG write(0,*) 'Found a matching decomposition that we can use'
             return
          else if ((size(decomp_cursor % decomphandle % dims) == field_cursor % fieldhandle % ndims - 1)  &amp;
                   .and. field_cursor % fieldhandle % has_unlimited_dim  &amp;
                  ) then
-!write(0,*) 'Number of non-record dimensions matches...'
+MPAS_IO_DEBUG write(0,*) 'Number of non-record dimensions matches...'
             do i=1,field_cursor % fieldhandle % ndims
                if (field_cursor % fieldhandle % dims(i) % is_unlimited_dim) cycle
-!write(0,*) 'Checking dimension ', decomp_cursor % decomphandle % dims(i), field_cursor % fieldhandle % dims(i) % dimsize
+MPAS_IO_DEBUG write(0,*) 'Checking dimension ', decomp_cursor % decomphandle % dims(i), field_cursor % fieldhandle % dims(i) % dimsize
                if (decomp_cursor % decomphandle % dims(i) /= field_cursor % fieldhandle % dims(i) % dimsize) then
                   decomp_cursor =&gt; decomp_cursor % next
                   cycle DECOMP_LOOP
@@ -1007,14 +1009,14 @@
             
             ! OK, we have a match... just use this decomposition for the field and return
             field_cursor % fieldhandle % decomp =&gt; decomp_cursor % decomphandle 
-!write(0,*) 'Found a matching decomposition that we can use (aside from record dimension)'
+MPAS_IO_DEBUG write(0,*) 'Found a matching decomposition that we can use (aside from record dimension)'
             return
          end if
          end if
          decomp_cursor =&gt; decomp_cursor % next
       end do DECOMP_LOOP
 
-!write(0,*) 'Creating a new decomposition'
+MPAS_IO_DEBUG write(0,*) 'Creating a new decomposition'
 
 
       !
@@ -1120,19 +1122,19 @@
       ! Add new decomposition to the list
       if (.not. associated(decomp_list)) then
          decomp_list =&gt; new_decomp
-!write(0,*) 'Adding first item to the decomp_list'
+MPAS_IO_DEBUG write(0,*) 'Adding first item to the decomp_list'
       else
          new_decomp % next =&gt; decomp_list
          decomp_list =&gt; new_decomp
-!write(0,*) 'Adding new decomp to the head of the list'
+MPAS_IO_DEBUG write(0,*) 'Adding new decomp to the head of the list'
       end if
 
-!write(0,*) 'Setting decomp in fieldhandle'
+MPAS_IO_DEBUG write(0,*) 'Setting decomp in fieldhandle'
       field_cursor % fieldhandle % decomp =&gt; new_decomp % decomphandle
 
       deallocate(compdof)
       deallocate(dimlist)
-!write(0,*) 'All finished.'
+MPAS_IO_DEBUG write(0,*) 'All finished.'
 
    end subroutine MPAS_io_set_var_indices
 
@@ -1172,12 +1174,12 @@
          return 
       end if
 
-!      write(0,*) 'Reading ', trim(fieldname)
+MPAS_IO_DEBUG       write(0,*) 'Reading ', trim(fieldname)
 
       !
       ! Check whether the field has been defined
       !
-!      write(0,*) 'Checking if field is define'
+MPAS_IO_DEBUG       write(0,*) 'Checking if field is define'
       field_cursor =&gt; handle % fieldlist_head
       do while (associated(field_cursor))
          if (trim(fieldname) == trim(field_cursor % fieldhandle % fieldname)) then
@@ -1194,7 +1196,7 @@
       !
       ! Check that we have a decomposition for this field
       !
-!      write(0,*) 'Checking for decomposition'
+MPAS_IO_DEBUG       write(0,*) 'Checking for decomposition'
       if (.not.present(intVal) .and. .not.present(realVal) .and. .not.present(charVal)) then
          if (.not. associated(field_cursor % fieldhandle % decomp)) then
             if (present(ierr)) ierr = MPAS_IO_ERR_NO_DECOMP
@@ -1204,7 +1206,7 @@
 
 !!!! Assume array was already allocated by the user
 
-!      write(0,*) 'Checking for unlimited dim'
+MPAS_IO_DEBUG       write(0,*) 'Checking for unlimited dim'
       if (field_cursor % fieldhandle % has_unlimited_dim) then
          call PIO_setframe(field_cursor % fieldhandle % field_desc, handle % frame_number)
          start1(1) = handle % frame_number
@@ -1215,7 +1217,7 @@
          count2(2) = 1
       end if
 
-!      write(0,*) 'Checking for real, int, char, etc'
+MPAS_IO_DEBUG       write(0,*) 'Checking for real, int, char, etc'
       if (present(realVal)) then
 !         write (0,*) '  value is real'
          if (field_cursor % fieldhandle % has_unlimited_dim) then
@@ -1295,7 +1297,7 @@
       integer, dimension(1) :: start
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_int0d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_int0d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, intVal=val, ierr=ierr)
@@ -1315,7 +1317,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_int1d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_int1d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, intArray1d=array, ierr=ierr)
@@ -1335,7 +1337,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_int2d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_int2d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, intArray2d=array, ierr=ierr)
@@ -1355,7 +1357,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_int3d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_int3d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, intArray3d=array, ierr=ierr)
@@ -1375,7 +1377,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_int4d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_int4d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, intArray4d=array, ierr=ierr)
@@ -1396,7 +1398,7 @@
       integer, dimension(1) :: start
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_real0d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_real0d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, realVal=val, ierr=ierr)
@@ -1416,7 +1418,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_real1d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_real1d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, realArray1d=array, ierr=ierr)
@@ -1436,7 +1438,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_real2d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_real2d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, realArray2d=array, ierr=ierr)
@@ -1456,7 +1458,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_real3d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_real3d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, realArray3d=array, ierr=ierr)
@@ -1476,7 +1478,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_real4d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_real4d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, realArray4d=array, ierr=ierr)
@@ -1496,7 +1498,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_get_var_char0d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_var_char0d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_get_var_generic(handle, fieldname, charVal=val, ierr=ierr)
@@ -1548,7 +1550,7 @@
          end if
       end if
 
-!      write(0,*) 'Writing ', trim(fieldname)
+MPAS_IO_DEBUG       write(0,*) 'Writing ', trim(fieldname)
 
 
       !
@@ -1655,7 +1657,7 @@
       integer, dimension(1) :: start
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_int0d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_int0d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, intVal=val, ierr=ierr)
@@ -1675,7 +1677,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_int1d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_int1d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, intArray1d=array, ierr=ierr)
@@ -1695,7 +1697,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_int2d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_int2d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, intArray2d=array, ierr=ierr)
@@ -1715,7 +1717,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_int3d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_int3d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, intArray3d=array, ierr=ierr)
@@ -1735,7 +1737,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_int4d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_int4d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, intArray4d=array, ierr=ierr)
@@ -1756,7 +1758,7 @@
       integer, dimension(1) :: start
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_real0d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_real0d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, realVal=val, ierr=ierr)
@@ -1776,7 +1778,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_real1d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_real1d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, realArray1d=array, ierr=ierr)
@@ -1796,7 +1798,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_real2d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_real2d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, realArray2d=array, ierr=ierr)
@@ -1816,7 +1818,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_real3d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_real3d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, realArray3d=array, ierr=ierr)
@@ -1836,7 +1838,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_real4d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_real4d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, realArray4d=array, ierr=ierr)
@@ -1856,7 +1858,7 @@
       integer :: pio_ierr
       type (fieldlist_type), pointer :: field_cursor
 
-!      write(0,*) 'Called MPAS_io_put_var_char0d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_var_char0d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       call MPAS_io_put_var_generic(handle, fieldname, charVal=val, ierr=ierr)
@@ -1880,7 +1882,7 @@
       type (fieldlist_type), pointer :: field_cursor
       type (attlist_type), pointer :: att_cursor, new_att_node
 
-!      write(0,*) 'Called MPAS_io_get_att_int0d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_att_int0d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -1912,7 +1914,7 @@
          do while (associated(att_cursor))
             if (trim(att_cursor % atthandle % attName) == trim(attName)) then
                if (att_cursor % atthandle % attType == ATT_INT) then
-!write(0,*) 'Using cached attribute'
+MPAS_IO_DEBUG write(0,*) 'Using cached attribute'
                   attValue = att_cursor % atthandle % attValueInt
                else
                   if (present(ierr)) ierr=MPAS_IO_ERR_WRONG_ATT_TYPE
@@ -1929,7 +1931,7 @@
          do while (associated(att_cursor))
             if (trim(att_cursor % atthandle % attName) == trim(attName)) then
                if (att_cursor % atthandle % attType == ATT_INT) then
-!write(0,*) 'Using cached attribute'
+MPAS_IO_DEBUG write(0,*) 'Using cached attribute'
                   attValue = att_cursor % atthandle % attValueInt
                else
                   if (present(ierr)) ierr=MPAS_IO_ERR_WRONG_ATT_TYPE
@@ -1970,28 +1972,28 @@
       if (present(fieldname)) then
          if (.not. associated(field_cursor % fieldhandle % attlist_head)) then
             field_cursor % fieldhandle % attlist_head =&gt; new_att_node
-!write(0,*) 'Assigning att head for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attName)
          end if
          if (.not. associated(field_cursor % fieldhandle % attlist_tail)) then
             field_cursor % fieldhandle % attlist_tail =&gt; new_att_node
-!write(0,*) 'Assigning att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attName)
          else
             field_cursor % fieldhandle % attlist_tail % next =&gt; new_att_node
             field_cursor % fieldhandle % attlist_tail =&gt; field_cursor % fieldhandle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attName)
          end if
       else
          if (.not. associated(handle % attlist_head)) then
             handle % attlist_head =&gt; new_att_node
-!write(0,*) 'Assigning att head for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attName)
          end if
          if (.not. associated(handle % attlist_tail)) then
             handle % attlist_tail =&gt; new_att_node
-!write(0,*) 'Assigning att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attName)
          else
             handle % attlist_tail % next =&gt; new_att_node
             handle % attlist_tail =&gt; handle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attName)
          end if
       end if
 
@@ -2014,7 +2016,7 @@
       type (fieldlist_type), pointer :: field_cursor
       type (attlist_type), pointer :: att_cursor, new_att_node
 
-!      write(0,*) 'Called MPAS_io_get_att_int1d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_att_int1d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -2046,7 +2048,7 @@
          do while (associated(att_cursor))
             if (trim(att_cursor % atthandle % attName) == trim(attName)) then
                if (att_cursor % atthandle % attType == ATT_INTA) then
-!write(0,*) 'Using cached attribute'
+MPAS_IO_DEBUG write(0,*) 'Using cached attribute'
                   allocate(attValue(size(att_cursor % atthandle % attValueIntA)))
                   attValue = att_cursor % atthandle % attValueIntA
                else
@@ -2064,7 +2066,7 @@
          do while (associated(att_cursor))
             if (trim(att_cursor % atthandle % attName) == trim(attName)) then
                if (att_cursor % atthandle % attType == ATT_INTA) then
-!write(0,*) 'Using cached attribute'
+MPAS_IO_DEBUG write(0,*) 'Using cached attribute'
                   allocate(attValue(size(att_cursor % atthandle % attValueIntA)))
                   attValue = att_cursor % atthandle % attValueIntA
                else
@@ -2115,28 +2117,28 @@
       if (present(fieldname)) then
          if (.not. associated(field_cursor % fieldhandle % attlist_head)) then
             field_cursor % fieldhandle % attlist_head =&gt; new_att_node
-!write(0,*) 'Assigning att head for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attName)
          end if
          if (.not. associated(field_cursor % fieldhandle % attlist_tail)) then
             field_cursor % fieldhandle % attlist_tail =&gt; new_att_node
-!write(0,*) 'Assigning att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attName)
          else
             field_cursor % fieldhandle % attlist_tail % next =&gt; new_att_node
             field_cursor % fieldhandle % attlist_tail =&gt; field_cursor % fieldhandle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attName)
          end if
       else
          if (.not. associated(handle % attlist_head)) then
             handle % attlist_head =&gt; new_att_node
-!write(0,*) 'Assigning att head for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attName)
          end if
          if (.not. associated(handle % attlist_tail)) then
             handle % attlist_tail =&gt; new_att_node
-!write(0,*) 'Assigning att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attName)
          else
             handle % attlist_tail % next =&gt; new_att_node
             handle % attlist_tail =&gt; handle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attName)
          end if
       end if
 
@@ -2159,7 +2161,7 @@
       type (fieldlist_type), pointer :: field_cursor
       type (attlist_type), pointer :: att_cursor, new_att_node
 
-!      write(0,*) 'Called MPAS_io_get_att_real0d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_att_real0d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -2191,7 +2193,7 @@
          do while (associated(att_cursor))
             if (trim(att_cursor % atthandle % attName) == trim(attName)) then
                if (att_cursor % atthandle % attType == ATT_REAL) then
-!write(0,*) 'Using cached attribute'
+MPAS_IO_DEBUG write(0,*) 'Using cached attribute'
                   attValue = att_cursor % atthandle % attValueReal
                else
                   if (present(ierr)) ierr=MPAS_IO_ERR_WRONG_ATT_TYPE
@@ -2208,7 +2210,7 @@
          do while (associated(att_cursor))
             if (trim(att_cursor % atthandle % attName) == trim(attName)) then
                if (att_cursor % atthandle % attType == ATT_REAL) then
-!write(0,*) 'Using cached attribute'
+MPAS_IO_DEBUG write(0,*) 'Using cached attribute'
                   attValue = att_cursor % atthandle % attValueReal
                else
                   if (present(ierr)) ierr=MPAS_IO_ERR_WRONG_ATT_TYPE
@@ -2249,28 +2251,28 @@
       if (present(fieldname)) then
          if (.not. associated(field_cursor % fieldhandle % attlist_head)) then
             field_cursor % fieldhandle % attlist_head =&gt; new_att_node
-!write(0,*) 'Assigning att head for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attName)
          end if
          if (.not. associated(field_cursor % fieldhandle % attlist_tail)) then
             field_cursor % fieldhandle % attlist_tail =&gt; new_att_node
-!write(0,*) 'Assigning att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attName)
          else
             field_cursor % fieldhandle % attlist_tail % next =&gt; new_att_node
             field_cursor % fieldhandle % attlist_tail =&gt; field_cursor % fieldhandle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attName)
          end if
       else
          if (.not. associated(handle % attlist_head)) then
             handle % attlist_head =&gt; new_att_node
-!write(0,*) 'Assigning att head for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attName)
          end if
          if (.not. associated(handle % attlist_tail)) then
             handle % attlist_tail =&gt; new_att_node
-!write(0,*) 'Assigning att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attName)
          else
             handle % attlist_tail % next =&gt; new_att_node
             handle % attlist_tail =&gt; handle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attName)
          end if
       end if
 
@@ -2293,7 +2295,7 @@
       type (fieldlist_type), pointer :: field_cursor
       type (attlist_type), pointer :: att_cursor, new_att_node
 
-!      write(0,*) 'Called MPAS_io_get_att_real1d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_att_real1d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -2325,7 +2327,7 @@
          do while (associated(att_cursor))
             if (trim(att_cursor % atthandle % attName) == trim(attName)) then
                if (att_cursor % atthandle % attType == ATT_REALA) then
-!write(0,*) 'Using cached attribute'
+MPAS_IO_DEBUG write(0,*) 'Using cached attribute'
                   allocate(attValue(size(att_cursor % atthandle % attValueRealA)))
                   attValue = att_cursor % atthandle % attValueRealA
                else
@@ -2343,7 +2345,7 @@
          do while (associated(att_cursor))
             if (trim(att_cursor % atthandle % attName) == trim(attName)) then
                if (att_cursor % atthandle % attType == ATT_REALA) then
-!write(0,*) 'Using cached attribute'
+MPAS_IO_DEBUG write(0,*) 'Using cached attribute'
                   allocate(attValue(size(att_cursor % atthandle % attValueRealA)))
                   attValue = att_cursor % atthandle % attValueRealA
                else
@@ -2394,28 +2396,28 @@
       if (present(fieldname)) then
          if (.not. associated(field_cursor % fieldhandle % attlist_head)) then
             field_cursor % fieldhandle % attlist_head =&gt; new_att_node
-!write(0,*) 'Assigning att head for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attName)
          end if
          if (.not. associated(field_cursor % fieldhandle % attlist_tail)) then
             field_cursor % fieldhandle % attlist_tail =&gt; new_att_node
-!write(0,*) 'Assigning att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attName)
          else
             field_cursor % fieldhandle % attlist_tail % next =&gt; new_att_node
             field_cursor % fieldhandle % attlist_tail =&gt; field_cursor % fieldhandle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attName)
          end if
       else
          if (.not. associated(handle % attlist_head)) then
             handle % attlist_head =&gt; new_att_node
-!write(0,*) 'Assigning att head for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attName)
          end if
          if (.not. associated(handle % attlist_tail)) then
             handle % attlist_tail =&gt; new_att_node
-!write(0,*) 'Assigning att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attName)
          else
             handle % attlist_tail % next =&gt; new_att_node
             handle % attlist_tail =&gt; handle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attName)
          end if
       end if
 
@@ -2438,7 +2440,7 @@
       type (fieldlist_type), pointer :: field_cursor
       type (attlist_type), pointer :: att_cursor, new_att_node
 
-!      write(0,*) 'Called MPAS_io_get_att_text()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_get_att_text()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -2470,7 +2472,7 @@
          do while (associated(att_cursor))
             if (trim(att_cursor % atthandle % attName) == trim(attName)) then
                if (att_cursor % atthandle % attType == ATT_TEXT) then
-!write(0,*) 'Using cached attribute'
+MPAS_IO_DEBUG write(0,*) 'Using cached attribute'
                   attValue = att_cursor % atthandle % attValueText
                else
                   if (present(ierr)) ierr=MPAS_IO_ERR_WRONG_ATT_TYPE
@@ -2487,7 +2489,7 @@
          do while (associated(att_cursor))
             if (trim(att_cursor % atthandle % attName) == trim(attName)) then
                if (att_cursor % atthandle % attType == ATT_TEXT) then
-!write(0,*) 'Using cached attribute'
+MPAS_IO_DEBUG write(0,*) 'Using cached attribute'
                   attValue = att_cursor % atthandle % attValueText
                else
                   if (present(ierr)) ierr=MPAS_IO_ERR_WRONG_ATT_TYPE
@@ -2528,28 +2530,28 @@
       if (present(fieldname)) then
          if (.not. associated(field_cursor % fieldhandle % attlist_head)) then
             field_cursor % fieldhandle % attlist_head =&gt; new_att_node
-!write(0,*) 'Assigning att head for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attName)
          end if
          if (.not. associated(field_cursor % fieldhandle % attlist_tail)) then
             field_cursor % fieldhandle % attlist_tail =&gt; new_att_node
-!write(0,*) 'Assigning att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attName)
          else
             field_cursor % fieldhandle % attlist_tail % next =&gt; new_att_node
             field_cursor % fieldhandle % attlist_tail =&gt; field_cursor % fieldhandle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attName)
          end if
       else
          if (.not. associated(handle % attlist_head)) then
             handle % attlist_head =&gt; new_att_node
-!write(0,*) 'Assigning att head for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attName)
          end if
          if (.not. associated(handle % attlist_tail)) then
             handle % attlist_tail =&gt; new_att_node
-!write(0,*) 'Assigning att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attName)
          else
             handle % attlist_tail % next =&gt; new_att_node
             handle % attlist_tail =&gt; handle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attName)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attName)
          end if
       end if
 
@@ -2571,7 +2573,7 @@
       type (fieldlist_type), pointer :: field_cursor
       type (attlist_type), pointer :: attlist_cursor, new_attlist_node
 
-!      write(0,*) 'Called MPAS_io_put_att_int0d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_att_int0d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -2609,7 +2611,7 @@
                attlist_cursor =&gt; field_cursor % fieldhandle % attlist_head
                do while (associated(attlist_cursor))
                   if (trim(attName) == trim(attlist_cursor % atthandle % attName)) then
-!write(0,*) 'Attribute already defined'
+MPAS_IO_DEBUG write(0,*) 'Attribute already defined'
                      if (attlist_cursor % atthandle % attType /= ATT_INT .or. &amp;
                          attlist_cursor % atthandle % attValueInt /= attValue) then
                         if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_ATT
@@ -2636,15 +2638,15 @@
          ! Add attribute to field attribute list
          if (.not. associated(field_cursor % fieldhandle % attlist_head)) then
             field_cursor % fieldhandle % attlist_head =&gt; new_attlist_node
-!write(0,*) 'Assigning att head for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attname)
          end if
          if (.not. associated(field_cursor % fieldhandle % attlist_tail)) then
             field_cursor % fieldhandle % attlist_tail =&gt; new_attlist_node
-!write(0,*) 'Assigning att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attname)
          else
             field_cursor % fieldhandle % attlist_tail % next =&gt; new_attlist_node
             field_cursor % fieldhandle % attlist_tail =&gt; field_cursor % fieldhandle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attname)
          end if
 
       else
@@ -2653,7 +2655,7 @@
          attlist_cursor =&gt; handle % attlist_head
          do while (associated(attlist_cursor))
             if (trim(attName) == trim(attlist_cursor % atthandle % attName)) then
-!write(0,*) 'Attribute already defined'
+MPAS_IO_DEBUG write(0,*) 'Attribute already defined'
                if (attlist_cursor % atthandle % attType /= ATT_INT .or. &amp;
                    attlist_cursor % atthandle % attValueInt /= attValue) then
                   if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_ATT
@@ -2670,15 +2672,15 @@
          ! Add attribute to global attribute list
          if (.not. associated(handle % attlist_head)) then
             handle % attlist_head =&gt; new_attlist_node
-!write(0,*) 'Assigning att head for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attname)
          end if
          if (.not. associated(handle % attlist_tail)) then
             handle % attlist_tail =&gt; new_attlist_node
-!write(0,*) 'Assigning att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attname)
          else
             handle % attlist_tail % next =&gt; new_attlist_node
             handle % attlist_tail =&gt; handle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attname)
          end if
       end if
 
@@ -2708,7 +2710,7 @@
       type (fieldlist_type), pointer :: field_cursor
       type (attlist_type), pointer :: attlist_cursor, new_attlist_node
 
-!      write(0,*) 'Called MPAS_io_put_att_int1d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_att_int1d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -2747,7 +2749,7 @@
                attlist_cursor =&gt; field_cursor % fieldhandle % attlist_head
                do while (associated(attlist_cursor))
                   if (trim(attName) == trim(attlist_cursor % atthandle % attName)) then
-!write(0,*) 'Attribute already defined'
+MPAS_IO_DEBUG write(0,*) 'Attribute already defined'
                      if (attlist_cursor % atthandle % attType /= ATT_INTA .or. &amp;
                          size(attlist_cursor % atthandle % attValueIntA) /= size(attValue)) then
                         if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_ATT
@@ -2778,15 +2780,15 @@
          ! Add attribute to field attribute list
          if (.not. associated(field_cursor % fieldhandle % attlist_head)) then
             field_cursor % fieldhandle % attlist_head =&gt; new_attlist_node
-!write(0,*) 'Assigning att head for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attname)
          end if
          if (.not. associated(field_cursor % fieldhandle % attlist_tail)) then
             field_cursor % fieldhandle % attlist_tail =&gt; new_attlist_node
-!write(0,*) 'Assigning att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attname)
          else
             field_cursor % fieldhandle % attlist_tail % next =&gt; new_attlist_node
             field_cursor % fieldhandle % attlist_tail =&gt; field_cursor % fieldhandle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attname)
          end if
 
       else
@@ -2795,7 +2797,7 @@
          attlist_cursor =&gt; handle % attlist_head
          do while (associated(attlist_cursor))
             if (trim(attName) == trim(attlist_cursor % atthandle % attName)) then
-!write(0,*) 'Attribute already defined'
+MPAS_IO_DEBUG write(0,*) 'Attribute already defined'
                if (attlist_cursor % atthandle % attType /= ATT_INTA .or. &amp;
                    size(attlist_cursor % atthandle % attValueIntA) /= size(attValue)) then
                   if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_ATT
@@ -2816,15 +2818,15 @@
          ! Add attribute to global attribute list
          if (.not. associated(handle % attlist_head)) then
             handle % attlist_head =&gt; new_attlist_node
-!write(0,*) 'Assigning att head for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attname)
          end if
          if (.not. associated(handle % attlist_tail)) then
             handle % attlist_tail =&gt; new_attlist_node
-!write(0,*) 'Assigning att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attname)
          else
             handle % attlist_tail % next =&gt; new_attlist_node
             handle % attlist_tail =&gt; handle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attname)
          end if
       end if
 
@@ -2854,7 +2856,7 @@
       type (fieldlist_type), pointer :: field_cursor
       type (attlist_type), pointer :: attlist_cursor, new_attlist_node
 
-!      write(0,*) 'Called MPAS_io_put_att_real0d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_att_real0d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -2892,7 +2894,7 @@
                attlist_cursor =&gt; field_cursor % fieldhandle % attlist_head
                do while (associated(attlist_cursor))
                   if (trim(attName) == trim(attlist_cursor % atthandle % attName)) then
-!write(0,*) 'Attribute already defined'
+MPAS_IO_DEBUG write(0,*) 'Attribute already defined'
                      if (attlist_cursor % atthandle % attType /= ATT_REAL .or. &amp;
                          attlist_cursor % atthandle % attValueReal /= attValue) then
                         if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_ATT
@@ -2919,15 +2921,15 @@
          ! Add attribute to field attribute list
          if (.not. associated(field_cursor % fieldhandle % attlist_head)) then
             field_cursor % fieldhandle % attlist_head =&gt; new_attlist_node
-!write(0,*) 'Assigning att head for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attname)
          end if
          if (.not. associated(field_cursor % fieldhandle % attlist_tail)) then
             field_cursor % fieldhandle % attlist_tail =&gt; new_attlist_node
-!write(0,*) 'Assigning att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attname)
          else
             field_cursor % fieldhandle % attlist_tail % next =&gt; new_attlist_node
             field_cursor % fieldhandle % attlist_tail =&gt; field_cursor % fieldhandle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attname)
          end if
 
       else
@@ -2936,7 +2938,7 @@
          attlist_cursor =&gt; handle % attlist_head
          do while (associated(attlist_cursor))
             if (trim(attName) == trim(attlist_cursor % atthandle % attName)) then
-!write(0,*) 'Attribute already defined'
+MPAS_IO_DEBUG write(0,*) 'Attribute already defined'
                if (attlist_cursor % atthandle % attType /= ATT_REAL .or. &amp;
                    attlist_cursor % atthandle % attValueReal /= attValue) then
                   if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_ATT
@@ -2953,15 +2955,15 @@
          ! Add attribute to global attribute list
          if (.not. associated(handle % attlist_head)) then
             handle % attlist_head =&gt; new_attlist_node
-!write(0,*) 'Assigning att head for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attname)
          end if
          if (.not. associated(handle % attlist_tail)) then
             handle % attlist_tail =&gt; new_attlist_node
-!write(0,*) 'Assigning att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attname)
          else
             handle % attlist_tail % next =&gt; new_attlist_node
             handle % attlist_tail =&gt; handle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attname)
          end if
       end if
 
@@ -2991,7 +2993,7 @@
       type (fieldlist_type), pointer :: field_cursor
       type (attlist_type), pointer :: attlist_cursor, new_attlist_node
 
-!      write(0,*) 'Called MPAS_io_put_att_real1d()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_att_real1d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -3030,7 +3032,7 @@
                attlist_cursor =&gt; field_cursor % fieldhandle % attlist_head
                do while (associated(attlist_cursor))
                   if (trim(attName) == trim(attlist_cursor % atthandle % attName)) then
-!write(0,*) 'Attribute already defined'
+MPAS_IO_DEBUG write(0,*) 'Attribute already defined'
                      if (attlist_cursor % atthandle % attType /= ATT_REALA .or. &amp;
                          size(attlist_cursor % atthandle % attValueRealA) /= size(attValue)) then
                         if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_ATT
@@ -3061,15 +3063,15 @@
          ! Add attribute to field attribute list
          if (.not. associated(field_cursor % fieldhandle % attlist_head)) then
             field_cursor % fieldhandle % attlist_head =&gt; new_attlist_node
-!write(0,*) 'Assigning att head for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attname)
          end if
          if (.not. associated(field_cursor % fieldhandle % attlist_tail)) then
             field_cursor % fieldhandle % attlist_tail =&gt; new_attlist_node
-!write(0,*) 'Assigning att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attname)
          else
             field_cursor % fieldhandle % attlist_tail % next =&gt; new_attlist_node
             field_cursor % fieldhandle % attlist_tail =&gt; field_cursor % fieldhandle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attname)
          end if
 
       else
@@ -3078,7 +3080,7 @@
          attlist_cursor =&gt; handle % attlist_head
          do while (associated(attlist_cursor))
             if (trim(attName) == trim(attlist_cursor % atthandle % attName)) then
-!write(0,*) 'Attribute already defined'
+MPAS_IO_DEBUG write(0,*) 'Attribute already defined'
                if (attlist_cursor % atthandle % attType /= ATT_REALA .or. &amp;
                    size(attlist_cursor % atthandle % attValueRealA) /= size(attValue)) then
                   if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_ATT
@@ -3099,15 +3101,15 @@
          ! Add attribute to global attribute list
          if (.not. associated(handle % attlist_head)) then
             handle % attlist_head =&gt; new_attlist_node
-!write(0,*) 'Assigning att head for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attname)
          end if
          if (.not. associated(handle % attlist_tail)) then
             handle % attlist_tail =&gt; new_attlist_node
-!write(0,*) 'Assigning att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attname)
          else
             handle % attlist_tail % next =&gt; new_attlist_node
             handle % attlist_tail =&gt; handle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attname)
          end if
       end if
 
@@ -3137,7 +3139,7 @@
       type (fieldlist_type), pointer :: field_cursor
       type (attlist_type), pointer :: attlist_cursor, new_attlist_node
 
-!      write(0,*) 'Called MPAS_io_put_att_text()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_put_att_text()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -3175,7 +3177,7 @@
                attlist_cursor =&gt; field_cursor % fieldhandle % attlist_head
                do while (associated(attlist_cursor))
                   if (trim(attName) == trim(attlist_cursor % atthandle % attName)) then
-!write(0,*) 'Attribute already defined'
+MPAS_IO_DEBUG write(0,*) 'Attribute already defined'
                      if (attlist_cursor % atthandle % attType /= ATT_TEXT .or. &amp;
                          trim(attlist_cursor % atthandle % attValueText) /= trim(attValue)) then
                         if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_ATT
@@ -3202,15 +3204,15 @@
          ! Add attribute to field attribute list
          if (.not. associated(field_cursor % fieldhandle % attlist_head)) then
             field_cursor % fieldhandle % attlist_head =&gt; new_attlist_node
-!write(0,*) 'Assigning att head for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attname)
          end if
          if (.not. associated(field_cursor % fieldhandle % attlist_tail)) then
             field_cursor % fieldhandle % attlist_tail =&gt; new_attlist_node
-!write(0,*) 'Assigning att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attname)
          else
             field_cursor % fieldhandle % attlist_tail % next =&gt; new_attlist_node
             field_cursor % fieldhandle % attlist_tail =&gt; field_cursor % fieldhandle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attname)
          end if
 
       else
@@ -3219,7 +3221,7 @@
          attlist_cursor =&gt; handle % attlist_head
          do while (associated(attlist_cursor))
             if (trim(attName) == trim(attlist_cursor % atthandle % attName)) then
-!write(0,*) 'Attribute already defined'
+MPAS_IO_DEBUG write(0,*) 'Attribute already defined'
                if (attlist_cursor % atthandle % attType /= ATT_TEXT .or. &amp;
                    trim(attlist_cursor % atthandle % attValueText) /= trim(attValue)) then
                   if (present(ierr)) ierr = MPAS_IO_ERR_REDEF_ATT
@@ -3236,15 +3238,15 @@
          ! Add attribute to global attribute list
          if (.not. associated(handle % attlist_head)) then
             handle % attlist_head =&gt; new_attlist_node
-!write(0,*) 'Assigning att head for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att head for '//trim(attname)
          end if
          if (.not. associated(handle % attlist_tail)) then
             handle % attlist_tail =&gt; new_attlist_node
-!write(0,*) 'Assigning att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Assigning att tail for '//trim(attname)
          else
             handle % attlist_tail % next =&gt; new_attlist_node
             handle % attlist_tail =&gt; handle % attlist_tail % next
-!write(0,*) 'Extending att tail for '//trim(attname)
+MPAS_IO_DEBUG write(0,*) 'Extending att tail for '//trim(attname)
          end if
       end if
 
@@ -3267,7 +3269,7 @@
       integer, intent(in) :: frame
       integer, intent(out), optional :: ierr
 
-!      write(0,*) 'Called MPAS_io_set_frame()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_set_frame()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       handle % frame_number = frame
@@ -3282,7 +3284,7 @@
       type (MPAS_IO_Handle_type), intent(inout) :: handle
       integer, intent(out), optional :: ierr
 
-!      write(0,*) 'Called MPAS_io_advance_frame()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_advance_frame()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       handle % frame_number = handle % frame_number + 1
@@ -3297,7 +3299,7 @@
       type (MPAS_IO_Handle_type), intent(inout) :: handle
       integer, intent(out), optional :: ierr
 
-!      write(0,*) 'Called MPAS_io_sync()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_sync()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -3322,7 +3324,7 @@
       type (fieldlist_type), pointer :: fieldlist_ptr, fieldlist_del
       type (attlist_type), pointer :: attlist_ptr, attlist_del
 
-!      write(0,*) 'Called MPAS_io_close()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_close()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       ! Sanity checks
@@ -3377,7 +3379,7 @@
 
       handle % initialized = .false.
 
-!write(0,*) 'MGD PIO_closefile'
+MPAS_IO_DEBUG write(0,*) 'MGD PIO_closefile'
       call PIO_closefile(handle % pio_file)
 
    end subroutine MPAS_io_close
@@ -3392,15 +3394,15 @@
       integer :: pio_ierr
       type (decomplist_type), pointer :: decomp_cursor, decomp_del
 
-!      write(0,*) 'Called MPAS_io_finalize()'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_io_finalize()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
 
       decomp_cursor =&gt; decomp_list
       do while (associated(decomp_cursor))
          decomp_del =&gt; decomp_cursor
          decomp_cursor =&gt; decomp_cursor % next
-!write(0,*) 'Deallocating a decomposition...'
-!if (.not. associated(decomp_del % decomphandle)) write(0,*) 'OOPS... do not have decomphandle'
+MPAS_IO_DEBUG write(0,*) 'Deallocating a decomposition...'
+MPAS_IO_DEBUG if (.not. associated(decomp_del % decomphandle)) write(0,*) 'OOPS... do not have decomphandle'
          deallocate(decomp_del % decomphandle % dims)
          deallocate(decomp_del % decomphandle % indices)
          call PIO_freedecomp(pio_iosystem, decomp_del % decomphandle % pio_iodesc)
@@ -3408,7 +3410,7 @@
          deallocate(decomp_del)
       end do
 
-!write(0,*) 'MGD PIO_finalize'
+MPAS_IO_DEBUG write(0,*) 'MGD PIO_finalize'
       call PIO_finalize(pio_iosystem, pio_ierr)
       if (pio_ierr /= PIO_noerr) then
          if (present(ierr)) ierr = MPAS_IO_ERR_PIO

Modified: branches/asd_io_work/src/framework/mpas_io_streams.F
===================================================================
--- branches/asd_io_work/src/framework/mpas_io_streams.F        2012-10-03 16:17:14 UTC (rev 2174)
+++ branches/asd_io_work/src/framework/mpas_io_streams.F        2012-10-03 17:05:43 UTC (rev 2175)
@@ -1,3 +1,5 @@
+#define MPAS_IO_DEBUG !
+
 module mpas_io_streams
 
    use mpas_attlist
@@ -140,7 +142,7 @@
       type (MPAS_Time_type) :: sliceTime, startTime
       type (MPAS_TimeInterval_type) :: timeDiff, minTimeDiff
 
-!      write(0,*) 'Called MPAS_seekStream'
+MPAS_IO_DEBUG       write(0,*) 'Called MPAS_seekStream'
 
       !
       ! Initialize output arguments
@@ -163,7 +165,7 @@
          return
       end if
 
-!write(0,*) 'Found ', timeDim, ' times in file' 
+MPAS_IO_DEBUG write(0,*) 'Found ', timeDim, ' times in file' 
 
       call MPAS_io_inq_var(stream % fileHandle, 'xtime', ierr=io_err)
       if (io_err /= MPAS_IO_NOERR) then
@@ -171,14 +173,14 @@
          return
       end if
 
-!write(0,*) 'Found xtime variable'
+MPAS_IO_DEBUG write(0,*) 'Found xtime variable'
 
       allocate(xtimes(timeDim))
 
       do i=1,timeDim
          call MPAS_io_set_frame(stream % fileHandle, i, io_err)
          call MPAS_io_get_var(stream % fileHandle, 'xtime', xtimes(i), io_err)
-!write(0,*) '... just read in xtime='//xtimes(i)
+MPAS_IO_DEBUG write(0,*) '... just read in xtime='//xtimes(i)
       end do
 
       if (len(seekTime) &gt; 32) then
@@ -191,7 +193,7 @@
 
       do i=1,timeDim
          write(strTemp, '(a)') trim(xtimes(i)(1:32))
-!write(0,*) '... converted strTemp='//strTemp
+MPAS_IO_DEBUG write(0,*) '... converted strTemp='//strTemp
          call mpas_set_time(curr_time=sliceTime, dateTimeString=strTemp)
          if (seekPosition == MPAS_STREAM_EXACT_TIME) then
             if (sliceTime == startTime) then
@@ -272,11 +274,11 @@
          return
       end if
 
-!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+MPAS_IO_DEBUG write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
 
       ndims = 0
 
-!write(0,*) '... field has ', ndims, ' dimensions'
+MPAS_IO_DEBUG write(0,*) '... field has ', ndims, ' dimensions'
 
       ! 
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
@@ -314,7 +316,7 @@
       new_field_list_node % field_type = FIELD_0D_INT
       new_field_list_node % int0dField =&gt; field
 
-!write(0,*) '... done adding field'
+MPAS_IO_DEBUG write(0,*) '... done adding field'
 
    end subroutine MPAS_streamAddField_0dInteger
 
@@ -354,11 +356,11 @@
          return
       end if
 
-!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+MPAS_IO_DEBUG write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
 
       ndims = size(field % dimSizes)
 
-!write(0,*) '... field has ', ndims, ' dimensions'
+MPAS_IO_DEBUG write(0,*) '... field has ', ndims, ' dimensions'
 
       ! 
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
@@ -415,7 +417,7 @@
       new_field_list_node % int1dField =&gt; field
       new_field_list_node % isAvailable =&gt; isAvailable
 
-!write(0,*) '... done adding field'
+MPAS_IO_DEBUG write(0,*) '... done adding field'
 
    end subroutine MPAS_streamAddField_1dInteger
 
@@ -453,11 +455,11 @@
          return
       end if
 
-!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+MPAS_IO_DEBUG write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
 
       ndims = size(field % dimSizes)
 
-!write(0,*) '... field has ', ndims, ' dimensions'
+MPAS_IO_DEBUG write(0,*) '... field has ', ndims, ' dimensions'
 
       ! 
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
@@ -514,7 +516,7 @@
       new_field_list_node % int2dField =&gt; field
       new_field_list_node % isAvailable =&gt; isAvailable
 
-!write(0,*) '... done adding field'
+MPAS_IO_DEBUG write(0,*) '... done adding field'
 
    end subroutine MPAS_streamAddField_2dInteger
 
@@ -552,11 +554,11 @@
          return
       end if
 
-!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+MPAS_IO_DEBUG write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
 
       ndims = size(field % dimSizes)
 
-!write(0,*) '... field has ', ndims, ' dimensions'
+MPAS_IO_DEBUG write(0,*) '... field has ', ndims, ' dimensions'
 
       ! 
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
@@ -612,7 +614,7 @@
       new_field_list_node % int3dField =&gt; field
       new_field_list_node % isAvailable =&gt; isAvailable
 
-!write(0,*) '... done adding field'
+MPAS_IO_DEBUG write(0,*) '... done adding field'
 
    end subroutine MPAS_streamAddField_3dInteger
 
@@ -648,11 +650,11 @@
          return
       end if
 
-!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+MPAS_IO_DEBUG write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
 
       ndims = 0
 
-!write(0,*) '... field has ', ndims, ' dimensions'
+MPAS_IO_DEBUG write(0,*) '... field has ', ndims, ' dimensions'
 
       ! 
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
@@ -690,7 +692,7 @@
       new_field_list_node % field_type = FIELD_0D_REAL
       new_field_list_node % real0dField =&gt; field
 
-!write(0,*) '... done adding field'
+MPAS_IO_DEBUG write(0,*) '... done adding field'
 
    end subroutine MPAS_streamAddField_0dReal
 
@@ -730,11 +732,11 @@
          return
       end if
 
-!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+MPAS_IO_DEBUG write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
 
       ndims = size(field % dimSizes)
 
-!write(0,*) '... field has ', ndims, ' dimensions'
+MPAS_IO_DEBUG write(0,*) '... field has ', ndims, ' dimensions'
 
       ! 
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
@@ -791,7 +793,7 @@
       new_field_list_node % real1dField =&gt; field
       new_field_list_node % isAvailable =&gt; isAvailable
 
-!write(0,*) '... done adding field'
+MPAS_IO_DEBUG write(0,*) '... done adding field'
 
    end subroutine MPAS_streamAddField_1dReal
 
@@ -829,11 +831,11 @@
          return
       end if
 
-!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+MPAS_IO_DEBUG write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
 
       ndims = size(field % dimSizes)
 
-!write(0,*) '... field has ', ndims, ' dimensions'
+MPAS_IO_DEBUG write(0,*) '... field has ', ndims, ' dimensions'
 
       ! 
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
@@ -890,7 +892,7 @@
       new_field_list_node % real2dField =&gt; field
       new_field_list_node % isAvailable =&gt; isAvailable
 
-!write(0,*) '... done adding field'
+MPAS_IO_DEBUG write(0,*) '... done adding field'
 
    end subroutine MPAS_streamAddField_2dReal
 
@@ -928,11 +930,11 @@
          return
       end if
 
-!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+MPAS_IO_DEBUG write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
 
       ndims = size(field % dimSizes)
 
-!write(0,*) '... field has ', ndims, ' dimensions'
+MPAS_IO_DEBUG write(0,*) '... field has ', ndims, ' dimensions'
 
       ! 
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
@@ -943,7 +945,7 @@
       
       any_success = .false.
       if (field % isSuperArray) then
-!write(0,*) '^^^^^^^^^^^^^^^^^^^^^^^^^^^ we are adding a super-array'
+MPAS_IO_DEBUG write(0,*) '^^^^^^^^^^^^^^^^^^^^^^^^^^^ we are adding a super-array'
          allocate(isAvailable(size(field % constituentNames)))
          isAvailable(:) = .false.
          do i=1,size(field % constituentNames)
@@ -990,8 +992,8 @@
       new_field_list_node % real3dField =&gt; field
       new_field_list_node % isAvailable =&gt; isAvailable
 
-!write(0,*) '... done adding field'
-!write(0,*) 'DEBUGGING : Finished adding 3d real field '//trim(field % fieldName)
+MPAS_IO_DEBUG write(0,*) '... done adding field'
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : Finished adding 3d real field '//trim(field % fieldName)
 
    end subroutine MPAS_streamAddField_3dReal
 
@@ -1028,11 +1030,11 @@
          return
       end if
 
-!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+MPAS_IO_DEBUG write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
 
       ndims = 1
 
-!write(0,*) '... field has ', ndims, ' dimensions'
+MPAS_IO_DEBUG write(0,*) '... field has ', ndims, ' dimensions'
 
       ! 
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
@@ -1085,7 +1087,7 @@
       new_field_list_node % field_type = FIELD_0D_CHAR
       new_field_list_node % char0dField =&gt; field
 
-!write(0,*) '... done adding field'
+MPAS_IO_DEBUG write(0,*) '... done adding field'
 
    end subroutine MPAS_streamAddField_0dChar
 
@@ -1122,19 +1124,19 @@
 
       ndims = size(dimNames)
 
-!write(0,*) '... field has ', ndims, ' dimensions'
+MPAS_IO_DEBUG write(0,*) '... field has ', ndims, ' dimensions'
 
       allocate(new_field_list_node)
       nullify(new_field_list_node % next)
 
       if (stream % ioDirection == MPAS_IO_WRITE) then
-!write(0,*) '... defining field'
+MPAS_IO_DEBUG write(0,*) '... defining field'
 
          !
          ! Define inner dimensions
          !
          do idim = 1, ndims-1
-!write(0,*) '... defining dimension ', trim(dimNames(idim)), dimSizes(idim)
+MPAS_IO_DEBUG write(0,*) '... defining dimension ', trim(dimNames(idim)), dimSizes(idim)
             write(dimNamesLocal(idim),'(a)') dimNames(idim)
             call MPAS_io_def_dim(stream % fileHandle, trim(dimNames(idim)), dimSizes(idim), io_err)
             call MPAS_io_err_mesg(io_err, .false.)
@@ -1160,7 +1162,7 @@
          new_field_list_node % isDecomposed = isDecomposed
   
          if (ndims &gt; 0) then
-!write(0,*) '... defining dimension ', trim(dimNames(idim)), globalDimSize
+MPAS_IO_DEBUG write(0,*) '... defining dimension ', trim(dimNames(idim)), globalDimSize
             call MPAS_io_def_dim(stream % fileHandle, trim(dimNames(idim)), globalDimSize, io_err)
             call MPAS_io_err_mesg(io_err, .false.)
             if (io_err /= MPAS_IO_NOERR) then
@@ -1174,7 +1176,7 @@
          ! Define time dimension if necessary
          !
          if (hasTimeDimension) then
-!write(0,*) '... defining Time dimension '
+MPAS_IO_DEBUG write(0,*) '... defining Time dimension '
             call MPAS_io_def_dim(stream % fileHandle, 'Time', MPAS_IO_UNLIMITED_DIM, io_err)
             call MPAS_io_err_mesg(io_err, .false.)
             if (io_err /= MPAS_IO_NOERR) then
@@ -1189,7 +1191,7 @@
          !
          ! Define variable to low-level interface
          !
-!write(0,*) '... defining var to low-level interface with ndims ', ndims
+MPAS_IO_DEBUG write(0,*) '... defining var to low-level interface with ndims ', ndims
 
          call MPAS_io_def_var(stream % fileHandle, trim(fieldName), fieldType, dimNamesLocal(1:ndims), io_err)
          call MPAS_io_err_mesg(io_err, .false.)
@@ -1200,7 +1202,7 @@
          end if
         
       else if (stream % ioDirection == MPAS_IO_READ) then
-!write(0,*) '... inquiring about'
+MPAS_IO_DEBUG write(0,*) '... inquiring about'
 
          call MPAS_io_inq_var(stream % fileHandle, trim(fieldName), dimnames=dimNamesInq, dimsizes=dimSizesInq, ierr=io_err)
          ! If the field does not exist in the input file, we should handle this situation gracefully at higher levels
@@ -1214,9 +1216,9 @@
 
 ! Here, we should probably do a check to make sure the file agrees with what MPAS expects for the field
          do i=1,ndims
-!write(0,*) 'Comparing '//trim(dimNames(i))//' '//trim(dimNamesInq(i))
+MPAS_IO_DEBUG write(0,*) 'Comparing '//trim(dimNames(i))//' '//trim(dimNamesInq(i))
             if (trim(dimNames(i)) /= trim(dimNamesInq(i))) then
-!write(0,*) 'Mismatched dimension name in field'
+MPAS_IO_DEBUG write(0,*) 'Mismatched dimension name in field'
                if (present(ierr)) ierr = MPAS_IO_ERR
                deallocate(new_field_list_node)
                deallocate(dimNamesInq)
@@ -1235,9 +1237,9 @@
                   dimTemp = dimSizes(i)
                end if
             end if
-!write(0,*) 'Comparing ', dimTemp, ' ', dimSizesInq(i)
+MPAS_IO_DEBUG write(0,*) 'Comparing ', dimTemp, ' ', dimSizesInq(i)
             if (dimTemp /= dimSizesInq(i)) then
-!write(0,*) 'Mismatched dimension size in field'
+MPAS_IO_DEBUG write(0,*) 'Mismatched dimension size in field'
                if (present(ierr)) ierr = MPAS_IO_ERR
                deallocate(new_field_list_node)
                deallocate(dimNamesInq)
@@ -1279,10 +1281,10 @@
       ! Add field pointer to the list
       !
       if (.not. associated(stream % fieldList)) then
-!write(0,*) 'Adding field to the head of the list'
+MPAS_IO_DEBUG write(0,*) 'Adding field to the head of the list'
          stream % fieldList =&gt; new_field_list_node
       else
-!write(0,*) 'Adding field to the tail of the list'
+MPAS_IO_DEBUG write(0,*) 'Adding field to the tail of the list'
          field_list_cursor =&gt; stream % fieldList
          do while (associated(field_list_cursor % next))
             field_list_cursor =&gt; field_list_cursor % next
@@ -1354,12 +1356,12 @@
       do while (associated(field_cursor))
          if (field_cursor % field_type == FIELD_0D_INT) then
 
-!write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % int0dField % fieldName)
-!write(0,*) 'Reading in field '//trim(field_cursor % int0dField % fieldName)
-!write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
-!write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % int0dField % fieldName)
+MPAS_IO_DEBUG write(0,*) 'Reading in field '//trim(field_cursor % int0dField % fieldName)
+MPAS_IO_DEBUG write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
+MPAS_IO_DEBUG write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
 
-!write(0,*) 'MGD calling MPAS_io_get_var now...'
+MPAS_IO_DEBUG write(0,*) 'MGD calling MPAS_io_get_var now...'
             call MPAS_io_get_var(stream % fileHandle, field_cursor % int0dField % fieldName, int0d_temp, io_err)
             call MPAS_io_err_mesg(io_err, .false.)
             if (io_err /= MPAS_IO_NOERR) then
@@ -1367,7 +1369,7 @@
                 return
             end if
 
-!write(0,*) 'Distributing and Copying field to other blocks'
+MPAS_IO_DEBUG write(0,*) 'Distributing and Copying field to other blocks'
 
             call mpas_dmpar_bcast_int(field_cursor % int0dField % block % domain % dminfo, int0d_temp)
             field_0dint_ptr =&gt; field_cursor % int0dField
@@ -1377,7 +1379,7 @@
             end do
 
          else if (field_cursor % field_type == FIELD_1D_INT) then
-!write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % int1dField % fieldName)
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % int1dField % fieldName)
 
             if (field_cursor % int1dField % isSuperArray) then
                ncons = size(field_cursor % int1dField % constituentNames)
@@ -1452,7 +1454,7 @@
 
          else if (field_cursor % field_type == FIELD_2D_INT) then
 
-!write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % int2dField % fieldName)
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % int2dField % fieldName)
             if (field_cursor % int2dField % isSuperArray) then
                ncons = size(field_cursor % int2dField % constituentNames)
                allocate(int1d_temp(field_cursor % totalDimSize))
@@ -1532,7 +1534,7 @@
 
          else if (field_cursor % field_type == FIELD_3D_INT) then
 
-!write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % int3dField % fieldName)
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % int3dField % fieldName)
             if (field_cursor % int3dField % isSuperArray) then
                ncons = size(field_cursor % int3dField % constituentNames)
                allocate(int2d_temp(field_cursor % int3dField % dimSizes(2), &amp;
@@ -1614,12 +1616,12 @@
 
          else if (field_cursor % field_type == FIELD_0D_REAL) then
 
-!write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % real0dField % fieldName)
-!write(0,*) 'Reading in field '//trim(field_cursor % real0dField % fieldName)
-!write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
-!write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % real0dField % fieldName)
+MPAS_IO_DEBUG write(0,*) 'Reading in field '//trim(field_cursor % real0dField % fieldName)
+MPAS_IO_DEBUG write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
+MPAS_IO_DEBUG write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
 
-!write(0,*) 'MGD calling MPAS_io_get_var now...'
+MPAS_IO_DEBUG write(0,*) 'MGD calling MPAS_io_get_var now...'
             call MPAS_io_get_var(stream % fileHandle, field_cursor % real0dField % fieldName, real0d_temp, io_err)
             call MPAS_io_err_mesg(io_err, .false.)
             if (io_err /= MPAS_IO_NOERR) then
@@ -1627,7 +1629,7 @@
                 return
             end if
 
-!write(0,*) 'Distributing and Copying field to other blocks'
+MPAS_IO_DEBUG write(0,*) 'Distributing and Copying field to other blocks'
 
             call mpas_dmpar_bcast_real(field_cursor % real0dField % block % domain % dminfo, real0d_temp)
             field_0dreal_ptr =&gt; field_cursor % real0dField
@@ -1638,7 +1640,7 @@
 
          else if (field_cursor % field_type == FIELD_1D_REAL) then
 
-!write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % real1dField % fieldName)
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % real1dField % fieldName)
             if (field_cursor % real1dField % isSuperArray) then
                ncons = size(field_cursor % real1dField % constituentNames)
             else
@@ -1713,7 +1715,7 @@
 
          else if (field_cursor % field_type == FIELD_2D_REAL) then
 
-!write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % real2dField % fieldName)
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % real2dField % fieldName)
             if (field_cursor % real2dField % isSuperArray) then
                ncons = size(field_cursor % real2dField % constituentNames)
                allocate(real1d_temp(field_cursor % totalDimSize))
@@ -1793,10 +1795,10 @@
 
          else if (field_cursor % field_type == FIELD_3D_REAL) then
 
-!write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % real3dField % fieldName)
-!write(0,*) 'DEBUGGING : reading a 3d real array'
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % real3dField % fieldName)
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : reading a 3d real array'
             if (field_cursor % real3dField % isSuperArray) then
-!write(0,*) 'DEBUGGING : reading a 3d real super-array'
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : reading a 3d real super-array'
                ncons = size(field_cursor % real3dField % constituentNames)
                allocate(real2d_temp(field_cursor % real3dField % dimSizes(2), &amp;
                                     field_cursor % totalDimSize))
@@ -1810,7 +1812,7 @@
             do j=1,ncons
                if (field_cursor % real3dField % isSuperArray) then
                   if (.not. field_cursor % isAvailable(j)) cycle
-!write(0,*) 'DEBUGGING : calling get_var for a constitutent'
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : calling get_var for a constitutent'
                   call MPAS_io_get_var(stream % fileHandle, field_cursor % real3dField % constituentNames(j), real2d_temp, io_err)
                else
                   call MPAS_io_get_var(stream % fileHandle, field_cursor % real3dField % fieldName, real3d_temp, io_err)
@@ -1842,7 +1844,7 @@
                      end if
 
                      if (field_cursor % real3dField % isSuperArray) then
-!write(0,*) 'DEBUGGING : copying the temporary array'
+MPAS_IO_DEBUG write(0,*) 'DEBUGGING : copying the temporary array'
                         field_3dreal_ptr % array(j,:,1:ownedSize) = real2d_temp(:,i:i+ownedSize-1)
                      else
                         field_3dreal_ptr % array(:,:,1:ownedSize) = real3d_temp(:,:,i:i+ownedSize-1)
@@ -1879,11 +1881,11 @@
 
          else if (field_cursor % field_type == FIELD_0D_CHAR) then
 
-!write(0,*) 'Reading in field '//trim(field_cursor % char0dField % fieldName)
-!write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
-!write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
+MPAS_IO_DEBUG write(0,*) 'Reading in field '//trim(field_cursor % char0dField % fieldName)
+MPAS_IO_DEBUG write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
+MPAS_IO_DEBUG write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
 
-!write(0,*) 'MGD calling MPAS_io_get_var now...'
+MPAS_IO_DEBUG write(0,*) 'MGD calling MPAS_io_get_var now...'
             call MPAS_io_get_var(stream % fileHandle, field_cursor % char0dField % fieldName, field_cursor % char0dField % scalar, io_err)
             call MPAS_io_err_mesg(io_err, .false.)
             if (io_err /= MPAS_IO_NOERR) then
@@ -1891,7 +1893,7 @@
                 return
             end if
 
-!write(0,*) 'Distributing and Copying field to other blocks'
+MPAS_IO_DEBUG write(0,*) 'Distributing and Copying field to other blocks'
 
             call mpas_dmpar_bcast_char(field_cursor % char0dField % block % domain % dminfo, field_cursor % char0dField % scalar)
             field_0dchar_ptr =&gt; field_cursor % char0dField
@@ -1904,7 +1906,7 @@
          end if
          field_cursor =&gt; field_cursor % next
       end do
-!write(0,*) 'Finished fieldlist loop...'
+MPAS_IO_DEBUG write(0,*) 'Finished fieldlist loop...'
 
    end subroutine MPAS_readStream
 
@@ -1969,14 +1971,14 @@
 
          if (field_cursor % field_type == FIELD_0D_INT) then
 
-!write(0,*) 'Writing out field '//trim(field_cursor % int0dField % fieldName)
-!write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
-!write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
+MPAS_IO_DEBUG write(0,*) 'Writing out field '//trim(field_cursor % int0dField % fieldName)
+MPAS_IO_DEBUG write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
+MPAS_IO_DEBUG write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
 
-!write(0,*) 'Copying field from first block'
+MPAS_IO_DEBUG write(0,*) 'Copying field from first block'
             int0d_temp = field_cursor % int0dField % scalar
 
-!write(0,*) 'MGD calling MPAS_io_put_var now...'
+MPAS_IO_DEBUG write(0,*) 'MGD calling MPAS_io_put_var now...'
             call MPAS_io_put_var(stream % fileHandle, field_cursor % int0dField % fieldName, int0d_temp, io_err)
             call MPAS_io_err_mesg(io_err, .false.)
             if (io_err /= MPAS_IO_NOERR .and. present(ierr)) ierr = MPAS_IO_ERR
@@ -2156,14 +2158,14 @@
 
          else if (field_cursor % field_type == FIELD_0D_REAL) then
 
-!write(0,*) 'Writing out field '//trim(field_cursor % real0dField % fieldName)
-!write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
-!write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
+MPAS_IO_DEBUG write(0,*) 'Writing out field '//trim(field_cursor % real0dField % fieldName)
+MPAS_IO_DEBUG write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
+MPAS_IO_DEBUG write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
 
-!write(0,*) 'Copying field from first block'
+MPAS_IO_DEBUG write(0,*) 'Copying field from first block'
             real0d_temp = field_cursor % real0dField % scalar
 
-!write(0,*) 'MGD calling MPAS_io_put_var now...'
+MPAS_IO_DEBUG write(0,*) 'MGD calling MPAS_io_put_var now...'
             call MPAS_io_put_var(stream % fileHandle, field_cursor % real0dField % fieldName, real0d_temp, io_err)
             call MPAS_io_err_mesg(io_err, .false.)
             if (io_err /= MPAS_IO_NOERR .and. present(ierr)) ierr = MPAS_IO_ERR
@@ -2343,12 +2345,12 @@
 
          else if (field_cursor % field_type == FIELD_0D_CHAR) then
 
-!write(0,*) 'Writing out field '//trim(field_cursor % char0dField % fieldName)
-!write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
-!write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
+MPAS_IO_DEBUG write(0,*) 'Writing out field '//trim(field_cursor % char0dField % fieldName)
+MPAS_IO_DEBUG write(0,*) '   &gt; is the field decomposed? ', field_cursor % isDecomposed
+MPAS_IO_DEBUG write(0,*) '   &gt; outer dimension size ', field_cursor % totalDimSize
 
-!write(0,*) 'Copying field from first block'
-!write(0,*) 'MGD calling MPAS_io_put_var now...'
+MPAS_IO_DEBUG write(0,*) 'Copying field from first block'
+MPAS_IO_DEBUG write(0,*) 'MGD calling MPAS_io_put_var now...'
             call MPAS_io_put_var(stream % fileHandle, field_cursor % char0dField % fieldName, field_cursor % char0dField % scalar, io_err)
             call MPAS_io_err_mesg(io_err, .false.)
             if (io_err /= MPAS_IO_NOERR .and. present(ierr)) ierr = MPAS_IO_ERR
@@ -2671,15 +2673,15 @@
       call MPAS_io_err_mesg(io_err, .false.)
       if (io_err /= MPAS_IO_NOERR .and. present(ierr)) ierr = MPAS_IO_ERR
 
-!write(0,*) 'Deallocating global attribute list'
+MPAS_IO_DEBUG write(0,*) 'Deallocating global attribute list'
       call mpas_deallocate_attlist(stream % attList)
 
-!write(0,*) 'Deallocating field list'
+MPAS_IO_DEBUG write(0,*) 'Deallocating field list'
       field_cursor =&gt; stream % fieldList
       do while (associated(field_cursor))
          if (associated(field_cursor % isAvailable)) then
             deallocate(field_cursor % isAvailable)
-!write(0,*) 'Deallocating isAvailable array'
+MPAS_IO_DEBUG write(0,*) 'Deallocating isAvailable array'
          end if
          stream % fieldList =&gt; stream % fieldList % next
          deallocate(field_cursor)

</font>
</pre>