This Fortran program converts large binary files in parallel from/to single to/from double precision, using MPI-I/O. The code assumes that the each file contains only single- or double-precision floating-point numbers.
- build the Fortran program:
mpif90 -O3 -D_SINGLE_TO_DOUBLE convert_precision.F90 -o single2double # executable for single-to-double conversion
mpif90 -O3 -D_DOUBLE_TO_SINGLE convert_precision.F90 -o double2single # executable for double-to-single conversion
n.b.: by default, the compiled executable from mpif90 convert_precision.F90
will convert from double to single precision.
- list the files to be converted in a file
files.in
. For instance:
ls a.bin b.bin c.bin > files.in
- run the code, e.g.:
NUM_TASKS=16
mpirun -n $NUM_TASKS ./double2single
- done! the converted files are generated with the same name as the original file, with the extension
.converted
appended, i.e., for the example above:
$ ls *.converted
a.bin.converted b.bin.converted c.bin.converted