diff --git a/sources/io.F90 b/sources/io.F90
index 07f2233..6b65af3 100644
--- a/sources/io.F90
+++ b/sources/io.F90
@@ -107,9 +107,11 @@ module io
 !
   logical           , save :: precise_snapshots = .false.
 
+#ifdef HDF5
 ! a flag to determine if XDMF files should be generated
 !
   logical           , save :: with_xdmf   = .false.
+#endif /* HDF5 */
 
 ! the compression format and level of the XML+binary files
 !
@@ -186,7 +188,9 @@ module io
     use compression, only : set_compression, get_compression
     use hash       , only : hash_info
     use helpers    , only : print_message
+#ifdef HDF5
     use mpitools   , only : nproc
+#endif /* HDF5 */
     use parameters , only : get_parameter
 
     implicit none
@@ -1080,7 +1084,10 @@ module io
 
     logical            :: test
     character(len=255) :: dname, fname, line, sname, svalue
-    integer            :: il, iu, nl, nx, nm, nd, nv, i, j, k, l, n, p, nu, nr
+    integer            :: il, iu, nl, nx, nm, nd, nv, i, j, l, n, p, nu, nr
+#if NDIMS == 3
+    integer            :: k
+#endif /* NDIMS == 3 */
     integer(kind=4)    :: lndims, lnprocs, lnproc, lmblocks, lnleafs, llast_id
     integer(kind=4)    :: ldblocks, lncells, lnghosts, lnseeds, lnmodes
     real(kind=8)       :: deinj