# Talent

### Site Tools

june_1-2_2014_detailed_installation_steps_for_parallel_vh-1_and_required_libraries

# Differences

This shows you the differences between two versions of the page.

 june_1-2_2014_detailed_installation_steps_for_parallel_vh-1_and_required_libraries [2014/06/02 23:46]willcox created june_1-2_2014_detailed_installation_steps_for_parallel_vh-1_and_required_libraries [2014/06/03 00:27] (current)willcox 2014/06/03 00:27 willcox 2014/06/03 00:26 willcox 2014/06/03 00:26 willcox 2014/06/03 00:24 willcox 2014/06/03 00:21 willcox 2014/06/03 00:20 willcox 2014/06/03 00:19 willcox 2014/06/03 00:10 willcox 2014/06/03 00:03 willcox 2014/06/02 23:59 willcox 2014/06/02 23:58 willcox 2014/06/02 23:57 willcox 2014/06/02 23:56 willcox 2014/06/02 23:51 willcox 2014/06/02 23:46 willcox created Next revision Previous revision 2014/06/03 00:27 willcox 2014/06/03 00:26 willcox 2014/06/03 00:26 willcox 2014/06/03 00:24 willcox 2014/06/03 00:21 willcox 2014/06/03 00:20 willcox 2014/06/03 00:19 willcox 2014/06/03 00:10 willcox 2014/06/03 00:03 willcox 2014/06/02 23:59 willcox 2014/06/02 23:58 willcox 2014/06/02 23:57 willcox 2014/06/02 23:56 willcox 2014/06/02 23:51 willcox 2014/06/02 23:46 willcox created Line 1: Line 1: + Back to WGV Group Logbook: [[wgv|Welcome to the WGV Group Logbook]] + + ---- + ====== Setting up Parallel VH-1 with NetCDF ====== + ===== Getting the NetCDF Libraries (v4.2) ===== + ==== Setting Up NetCDF From Source ==== + ===== Modifying the Parallel VH-1 Files ===== + ---- + + June 1-2, 2014: Donald Willcox + + ---- + ====== Setting up Parallel VH-1 with NetCDF ====== ====== Setting up Parallel VH-1 with NetCDF ====== The parallel version of VH-1 uses netcdf, and configuring mpich and netcdf and compiling the parallel version requires installing the following libraries. On Fedora, I installed all of these via ''​yum install <​library>''​ and they are likely available via ''​apt-get''​ if your Linux distribution uses Synaptic. The parallel version of VH-1 uses netcdf, and configuring mpich and netcdf and compiling the parallel version requires installing the following libraries. On Fedora, I installed all of these via ''​yum install <​library>''​ and they are likely available via ''​apt-get''​ if your Linux distribution uses Synaptic. Line 12: Line 25: You can get the source for v.4.2 of the NetCDF Library from Unidata'​s links as follows: You can get the source for v.4.2 of the NetCDF Library from Unidata'​s links as follows: - [[http://​www.unidata.ucar.edu/​downloads/​netcdf/​ftp/​netcdf-4.2.tar.gz]] + * [[http://​www.unidata.ucar.edu/​downloads/​netcdf/​ftp/​netcdf-4.2.tar.gz]] - [[ftp://​ftp.unidata.ucar.edu/​pub/​netcdf/​netcdf-fortran-4.2.tar.gz]] + ​* ​[[ftp://​ftp.unidata.ucar.edu/​pub/​netcdf/​netcdf-fortran-4.2.tar.gz]] - [[https://​github.com/​Unidata/​netcdf-cxx4/​archive/​v4.2.1.tar.gz]] + ​* ​[[https://​github.com/​Unidata/​netcdf-cxx4/​archive/​v4.2.1.tar.gz]] It depends on hdf5, szip, and zlib libraries, which you can get from: It depends on hdf5, szip, and zlib libraries, which you can get from: - [[http://​www.hdfgroup.org/​ftp/​lib-external/​szip/​2.1/​src/​szip-2.1.tar.gz]] + * [[http://​www.hdfgroup.org/​ftp/​lib-external/​szip/​2.1/​src/​szip-2.1.tar.gz]] - [[http://​zlib.net/​zlib-1.2.8.tar.gz]] + ​* ​[[http://​zlib.net/​zlib-1.2.8.tar.gz]] - [[http://​www.hdfgroup.org/​ftp/​HDF5/​releases/​hdf5-1.8.12/​src/​hdf5-1.8.12.tar.gz]] + ​* ​[[http://​www.hdfgroup.org/​ftp/​HDF5/​releases/​hdf5-1.8.12/​src/​hdf5-1.8.12.tar.gz]] First, build/​install zlib, szip, and hdf5 in that order. Then build/​install netcdf-4.2, netcdf-cxx4,​ and netcdf-fortran-4.2 in that order and you should be good to go. You'll have to set environment variables along the way such as CFLAGS, CPPFLAGS and LDFLAGS to point to the include and lib directories containing the library files you install so that building the library that depends on the previous one can find the appropriate files. First, build/​install zlib, szip, and hdf5 in that order. Then build/​install netcdf-4.2, netcdf-cxx4,​ and netcdf-fortran-4.2 in that order and you should be good to go. You'll have to set environment variables along the way such as CFLAGS, CPPFLAGS and LDFLAGS to point to the include and lib directories containing the library files you install so that building the library that depends on the previous one can find the appropriate files. Line 30: Line 43: I extract the .tar.gz files and then... I extract the .tar.gz files and then... - I used ''​./​configure --prefix=/​home/​dwillcox/​local'' ​for szip and zlib (and then ''​make'',​ ''​make check'',​ ''​make install''​) ​so then I set the flags as follows: + For szip and zlib, I used: + + ''​./​configure --prefix=/​home/​dwillcox/​local''​ (and then ''​make'',​ ''​make check'',​ ''​make install''​) ​ + + Then I set the flags as follows: ''​export CFLAGS=-I/​home/​dwillcox/​local/​include''​ ''​export CFLAGS=-I/​home/​dwillcox/​local/​include''​ + ''​export CPPFLAGS=-I/​home/​dwillcox/​local/​include''​ ''​export CPPFLAGS=-I/​home/​dwillcox/​local/​include''​ + ''​export LDFLAGS=-L/​home/​dwillcox/​local/​lib''​ ''​export LDFLAGS=-L/​home/​dwillcox/​local/​lib''​ That lets hdf5 find those libraries. So in the hdf5 directory I used: That lets hdf5 find those libraries. So in the hdf5 directory I used: + ''​./​configure --enable-fortran --prefix=/​home/​dwillcox/​local/​hdf5''​ ''​./​configure --enable-fortran --prefix=/​home/​dwillcox/​local/​hdf5''​ + and then ran ''​make'',​ ''​make check'',​ and then ''​make install''​. I recommend running ''​make check''​ before ''​make install''​ because if something is configured improperly, it will fail tests. This happened to me several times before I finally got everything right so it's a nice sanity check. and then ran ''​make'',​ ''​make check'',​ and then ''​make install''​. I recommend running ''​make check''​ before ''​make install''​ because if something is configured improperly, it will fail tests. This happened to me several times before I finally got everything right so it's a nice sanity check. Then I added the hdf5 location to the flags as follows: Then I added the hdf5 location to the flags as follows: + ''​export CFLAGS=-I/​home/​dwillcox/​local/​include -I/​home/​dwillcox/​local/​hdf5/​include''​ ''​export CFLAGS=-I/​home/​dwillcox/​local/​include -I/​home/​dwillcox/​local/​hdf5/​include''​ + ''​export CPPFLAGS=-I/​home/​dwillcox/​local/​include -I/​home/​dwillcox/​local/​hdf5/​include''​ ''​export CPPFLAGS=-I/​home/​dwillcox/​local/​include -I/​home/​dwillcox/​local/​hdf5/​include''​ + ''​export LDFLAGS=-L/​home/​dwillcox/​local/​lib -L/​home/​dwillcox/​local/​hdf5/​lib''​ ''​export LDFLAGS=-L/​home/​dwillcox/​local/​lib -L/​home/​dwillcox/​local/​hdf5/​lib''​ Now you can build the netcdf-4.2 library. I used: Now you can build the netcdf-4.2 library. I used: + ''​./​configure --prefix=/​home/​dwillcox/​local/​netcdf --disable-dap''​ ''​./​configure --prefix=/​home/​dwillcox/​local/​netcdf --disable-dap''​ + The ''​--disable-dap''​ was important because the first time I built and ran ''​make check'',​ it failed a test due to this feature not working properly. The ''​--disable-dap''​ was important because the first time I built and ran ''​make check'',​ it failed a test due to this feature not working properly. + Then I did ''​make'',​ ''​make check'',​ and ''​make install''​ as usual. Then I did ''​make'',​ ''​make check'',​ and ''​make install''​ as usual. Adding the netcdf locations to the flags is necessary for installing the cxx and fortran versions of netcdf: Adding the netcdf locations to the flags is necessary for installing the cxx and fortran versions of netcdf: + ''​export CFLAGS=-I/​home/​dwillcox/​local/​include -I/​home/​dwillcox/​local/​hdf5/​include -I/​home/​dwillcox/​local/​netcdf/​include''​ ''​export CFLAGS=-I/​home/​dwillcox/​local/​include -I/​home/​dwillcox/​local/​hdf5/​include -I/​home/​dwillcox/​local/​netcdf/​include''​ + ''​export CPPFLAGS=-I/​home/​dwillcox/​local/​include -I/​home/​dwillcox/​local/​hdf5/​include -I/​home/​dwillcox/​local/​netcdf/​include''​ ''​export CPPFLAGS=-I/​home/​dwillcox/​local/​include -I/​home/​dwillcox/​local/​hdf5/​include -I/​home/​dwillcox/​local/​netcdf/​include''​ + ''​export LDFLAGS=-L/​home/​dwillcox/​local/​lib -L/​home/​dwillcox/​local/​hdf5/​lib -L/​home/​dwillcox/​local/​netcdf/​lib''​ ''​export LDFLAGS=-L/​home/​dwillcox/​local/​lib -L/​home/​dwillcox/​local/​hdf5/​lib -L/​home/​dwillcox/​local/​netcdf/​lib''​ - With this done, I did ''​./​configure --prefix=/​home/​dwillcox/​local/​netcdf'',​ ''​make'',​ ''​make check'',​ and ''​make install'' ​for the netcdf-cxx and netcdf-fortran libraries. Then I did: + With this done, I went to the netcdf-cxx and netcdf-fortran directories and did the following for each of them: + + ''​./​configure --prefix=/​home/​dwillcox/​local/​netcdf'', ​then ''​make'',​ ''​make check'',​ and ''​make install''​ + + Finally, ​I set the following environment variable so building ScientificPython would go smoothly in the "​Configuring YT" section! ''​export NETCDF_PREFIX=/​home/​dwillcox/​local/​netcdf''​ ''​export NETCDF_PREFIX=/​home/​dwillcox/​local/​netcdf''​ - so that building ScientificPython would go smoothly in the "​Configuring YT" section! + ===== Modifying the Parallel VH-1 Files ===== ===== Modifying the Parallel VH-1 Files ===== - The next step is to modify the Makefile in VH1/​src/​Parallel because it expects to be compiled with Intel'​s ​''​ifort'' ​and I'm using ''​gfortran'' ​and also because I need to compile mergeslabs.f90,​ which takes the multiple netcdf files output per timestep and merges them into one. The first modification is to set these flags as follows: + The next step is to modify the Makefile in VH1/​src/​Parallel because it expects to be compiled with Intel'​s ifort and I'm using gfortran and also because I need to compile mergeslabs.f90,​ which takes the multiple netcdf files output per timestep and merges them into one. The first modification is to set these flags as follows: ''​F90 = mpif90''​ ''​F90 = mpif90''​ + ''​FFLAGS = -c -O3 -Wall -I/​usr/​include -I/​usr/​lib64/​gfortran/​modules''​ ''​FFLAGS = -c -O3 -Wall -I/​usr/​include -I/​usr/​lib64/​gfortran/​modules''​ + ''​LDR= mpif90''​ ''​LDR= mpif90''​ + ''​LDRFLAGS=''​ ''​LDRFLAGS=''​ + ''​LIBS= -L/​usr/​lib64/​mpich/​lib -lnetcdff -lnetcdf''​ ''​LIBS= -L/​usr/​lib64/​mpich/​lib -lnetcdff -lnetcdf''​ Line 71: Line 111: ''​MERGEOBJS = mergeslabs.o''​ ''​MERGEOBJS = mergeslabs.o''​ - Now, right before the line declaring the ''​clean:'' ​target, I declare a target mlabs-mpi which is the binary file I generate by compiling mergeslabs.f90:​ + Now, right before the line declaring the clean: target, I declare a target mlabs-mpi which is the binary file I generate by compiling mergeslabs.f90:​ ''​mlabs-mpi: ​     $(MERGEOBJS) ''​mlabs-mpi: ​$(MERGEOBJS) + ​ $(LDR)$(LDRFLAGS) -o mlabs-mpi $(MERGEOBJS)$(LIBS); mv mlabs-mpi ../​../​output/​.''​ $(LDR)$(LDRFLAGS) -o mlabs-mpi $(MERGEOBJS)$(LIBS); mv mlabs-mpi ../​../​output/​.''​ Line 80: Line 121: ''​mergeslabs.o:​ mergeslabs.f90''​ ''​mergeslabs.o:​ mergeslabs.f90''​ - Now, running the Sod shock tube problem requires setting up the geometry and mpi settings. In the Parallel version, the grid geometry specification and initialization is done in ''​init.f90''​, while specifying how many grid zones to use and how to allocate this to MPI is done in ''​zonemod.f90''​. So in ''​zonemod.f90'' ​I set ''​imax=10,​ jmax=10, kmax=10''​ for a 10x10x10 3D cartesian grid (specified in ''​init.f90''​). Then I set 2 MPI tasks for the y-dimension (pey=2) and 2 MPI tasks for the z-dimension (pez=2). This means I must run on 2*2=4 processes. + Now, running the Sod shock tube problem requires setting up the geometry and mpi settings. In the Parallel version, the grid geometry specification and initialization is done in init.f90, while specifying how many grid zones to use and how to allocate this to MPI is done in zonemod.f90. So in zonemod.f90 I set ''​imax=10,​ jmax=10, kmax=10''​ for a 10x10x10 3D cartesian grid (specified in init.f90). Then I set 2 MPI tasks for the y-dimension (pey=2) and 2 MPI tasks for the z-dimension (pez=2). This means I must run on 2*2=4 processes. Now ''​make''​ will put the executable vh1-mpi in the VH1 directory and ''​make mlabs-mpi''​ will put the executable mlabs-mpi in the VH1/output directory. Run vh1-mpi using ''​mpiexec -np 4 ./​vh1-mpi''​ and then go to VH1/output and run mlabs-mpi. Voila, I've got output for the default 3D Sod shock tube problem and now comes visualizing the data... Now ''​make''​ will put the executable vh1-mpi in the VH1 directory and ''​make mlabs-mpi''​ will put the executable mlabs-mpi in the VH1/output directory. Run vh1-mpi using ''​mpiexec -np 4 ./​vh1-mpi''​ and then go to VH1/output and run mlabs-mpi. Voila, I've got output for the default 3D Sod shock tube problem and now comes visualizing the data... - - ======= Visualizing NetCDF Files with Python ======= - Once you've installed netcdf, you can access data in netcdf files from Python by installing numpy and ScientificPython. You should be able to get these by searching your package manager of choice or visiting their project sites: - - * [[http://​www.numpy.org/​]] - * [[https://​sourcesup.renater.fr/​projects/​scientific-py/​]] - - I go into more detail on building and installing ScientificPython in the following section for adding it to yt if you're interested in using yt to plot your data. Otherwise you can use python to access the netcdf files by referencing the NetCDF/​python documentation here: - - * [[http://​gfesuite.noaa.gov/​developer/​netCDFPythonInterface.html]] - - To load the necessary modules in your python script, use the following: - ''​import Scientific.IO.NetCDF - from numpy import * - from Scientific.IO.NetCDF import *''​ - - ====== Configuring YT for NetCDF Files ====== - yt is great for visualizing large multidimensional datasets from astrophysics codes such as FLASH, and it can be obtained from [[yt-project.org]]. yt returned errors in interpreting the netcdf files output by VH-1 when I tried opening them using its ''​load''​ function, so here's how I added NetCDF support to my yt distribution. First, make sure you've set the ''​NETCDF_PREFIX''​ environment variable as in the section on configuring NetCDF. - - I have installed yt to the following location: ''/​home/​dwillcox/​codes/​local/​yt-x86_64''​ - - To use NetCDF, yt needs numpy and ScientificPython installed, and it already comes with numpy. So the only thing to do is download ScientificPython:​ [[https://​sourcesup.renater.fr/​frs/​download.php/​4411/​ScientificPython-2.8.1.tar.gz]] - - Extract the tarball and ''​cd''​ into its directory. Activate the yt package by executing: - ''​source /​home/​dwillcox/​codes/​local/​yt-x86_64/​bin/​activate''​ - - Now execute the following: - ''​python setup.py build''​ - ''​python setup.py install''​ - - And ScientificPython should be added to your yt distribution! - - For a sample script using NetCDF with yt, see plotnc.py in my github repo: - [[https://​github.com/​dwillcox/​VH1-solarwind/​blob/​master/​scripts/​plotnc.py]] - - - - - - - -