Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Use $NETCDF_HOME instead of harcoded paths on linux #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ Compile PyCLES::

$ CC=mpicc python setup.py build_ext --inplace

.. note::
setup.py looks for netCDF4 libraries at the location specified at `$NETCDF_HOME`. Make sure that `$NETCDF_HOME` is set before building,
otherwise it will use the default of `/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a`

.. note::
In the above command, mpicc should be replaced by the name of your MPI C compiler.

Expand Down
28 changes: 23 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,18 @@ def get_netcdf_prefix():
extra_compile_args+=['-std=c99', '-O3', '-march=native', '-Wno-unused',
'-Wno-#warnings', '-Wno-maybe-uninitialized', '-Wno-cpp', '-Wno-array-bounds','-fPIC']
extra_objects=['./RRTMG/rrtmg_build/rrtmg_combined.o']
netcdf_include = '/central/software/netcdf-c/4.6.1/include'
netcdf_lib = '/central/software/netcdf-c/4.6.1/lib'
# Comment the above two lines and uncomment below to use Fram@Caltech)

# Look for $NETCDF_HOME variable
try:
netcdf_dir = os.environ['NETCDF_HOME']
print("Using netCDF4 path of", netcdf_dir)
netcdf_include = netcdf_dir + '/include'
netcdf_lib = netcdf_dir + '/lib'
except KeyError as err:
print("$NETCDF_HOME not assigned, using default directory of \'/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a\'")
netcdf_include = '/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a/include'
netcdf_lib = '/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a/lib'
# Comment the above lines and uncomment below to use Fram@Caltech)
#netcdf_include = '/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a/include'
#netcdf_lib = '/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a/lib'
f_compiler = 'gfortran'
Expand All @@ -76,8 +85,17 @@ def get_netcdf_prefix():
extra_compile_args+=['-std=c99', '-O3', '-march=native', '-Wno-unused',
'-Wno-#warnings', '-Wno-maybe-uninitialized', '-Wno-cpp', '-Wno-array-bounds','-fPIC']
extra_objects=['./RRTMG/rrtmg_build/rrtmg_combined.o']
netcdf_include = '/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a/include'
netcdf_lib = '/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a/lib'

# Look for $NETCDF_HOME variable
try:
netcdf_dir = os.environ['NETCDF_HOME']
print("Using netCDF4 path of", netcdf_dir)
netcdf_include = netcdf_dir + '/include'
netcdf_lib = netcdf_dir + '/lib'
except KeyError as err:
print("$NETCDF_HOME not assigned, using default directory of \'/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a\'")
netcdf_include = '/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a/include'
netcdf_lib = '/share/apps/software/rhel6/software/netCDF/4.4.0-foss-2016a/lib'
f_compiler = 'gfortran'

else:
Expand Down