We're now ready to take what we've learned about PnetCDF and see how to put it all together in a few example programs.

The starting point of the exercise is example-single-write.c. In this program, rank 0 gathers chunks of data from the rest of the ranks and writes a netCDF file. This example illustrates the use of various functions in the PnetCDF API. However, it leaves open some important questions:

Can we write the file in parallel? What is the performance difference?

You can experiment with this example, along with the rest of the codes provided, to answer these questions.

Follow the steps below to compile and run the codes. The Makefile and job.sh have been tested on TACC's Stampede3 and Frontera systems, as well as SDSC's Comet and Expanse supercomputers.

  1. cat ReadMe.txt - gives you instructions on how to load modules or install software to ensure that the required packages are available (as discussed in Setup earlier).
  2. make all - builds the required executable as directed by Makefile (be sure to execute the command mv Makefile.txt Makefile to remove the .txt extension). Note that there is a dependency on the PnetCDF library; again, please be sure that you have either loaded the proper module or installed the software as directed in step 1.
  3. sbatch job.sh - runs the executables and produces output files under the $SCRATCH directory. You should check the batch script first and edit it as necessary (for instance, to add your allocation ID). At the end of the job, the script deletes the output files. If you intend to keep the output files for further inspection or testing, please comment out rm -rf $WORKDIR on the last line. You can then use netCDF's ncdump utility (for example) to view the output files directly: ncdump $SCRATCH/pnetcdf/output.collective | less

Exercise files:

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Inclusivity Statement