From cff1c0e956f3f603aaa5f823c3a9f3fcf0084a42 Mon Sep 17 00:00:00 2001 From: Bill Ladwig Date: Mon, 22 Jan 2018 14:54:05 -0700 Subject: [PATCH] Updated build scripts, manifest, requirements, install docs --- MANIFEST.in | 2 + build_scripts/gnu_omp.sh | 2 +- build_scripts/win_mingw_no_omp.bat | 12 ++--- build_scripts/win_mingw_omp.bat | 12 ++--- build_scripts/win_msvc_mingw_no_omp.bat | 12 ++--- build_scripts/win_msvc_mingw_omp.bat | 12 ++--- doc/source/installation.rst | 58 +++++++++++++++++++++---- requirements.txt | 3 +- src/wrf/__init__.py | 9 ++-- 9 files changed, 83 insertions(+), 39 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index d83672c..6654fc5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,6 +4,8 @@ include requirements.txt include fortran/*.f90 include fortran/*.pyf +include build_scripts/*.sh +include build_scripts/*.bat include setup.py recursive-include doc/source * diff --git a/build_scripts/gnu_omp.sh b/build_scripts/gnu_omp.sh index cf66f27..a9901b6 100755 --- a/build_scripts/gnu_omp.sh +++ b/build_scripts/gnu_omp.sh @@ -2,7 +2,7 @@ cd ../fortran gfortran -E ompgen.F90 -fopenmp -cpp -o omp.f90 -f2py *.f90 -m _wrffortran -h wrffortran.pyf --overwrite-signature --no-wrap-functions +f2py *.f90 -m _wrffortran -h wrffortran.pyf --overwrite-signature cd .. python setup.py clean --all python setup.py config_fc --f90flags="-mtune=generic -fopenmp" build_ext --libraries="gomp" build diff --git a/build_scripts/win_mingw_no_omp.bat b/build_scripts/win_mingw_no_omp.bat index aa5037f..e254eec 100644 --- a/build_scripts/win_mingw_no_omp.bat +++ b/build_scripts/win_mingw_no_omp.bat @@ -1,13 +1,13 @@ cd ../fortran -gfortran -E ompgen.F90 -cpp -o omp.f90 +CALL gfortran -E ompgen.F90 -cpp -o omp.f90 REM Wildcards not working on Windows for some reason -f2py -m _wrffortran -h wrffortran.pyf --overwrite-signature wrf_constants.f90 wrf_testfunc.f90 wrf_user.f90 rip_cape.f90 wrf_cloud_fracf.f90 wrf_fctt.f90 wrf_user_dbz.f90 wrf_relhl.f90 calc_uh.f90 wrf_user_latlon_routines.f90 wrf_pvo.f90 eqthecalc.f90 wrf_rip_phys_routines.f90 wrf_pw.f90 wrf_vinterp.f90 wrf_wind.f90 omp.f90 +CALL f2py -m _wrffortran -h wrffortran.pyf --overwrite-signature wrf_constants.f90 wrf_testfunc.f90 wrf_user.f90 rip_cape.f90 wrf_cloud_fracf.f90 wrf_fctt.f90 wrf_user_dbz.f90 wrf_relhl.f90 calc_uh.f90 wrf_user_latlon_routines.f90 wrf_pvo.f90 eqthecalc.f90 wrf_rip_phys_routines.f90 wrf_pw.f90 wrf_vinterp.f90 wrf_wind.f90 omp.f90 cd .. -python setup.py clean --all +CALL python setup.py clean --all %PROCESSOR_ARCHITECTURE% == AMD64 ( - python setup.py config_fc --f90flags="-O2 -mtune=generic -mfpmath=sse -msse2" build --compiler=mingw32 --fcompiler=gnu95 + CALL python setup.py config_fc --f90flags="-O2 -mtune=generic -mfpmath=sse -msse2" build --compiler=mingw32 --fcompiler=gnu95 ) else ( - python setup.py config_fc --f90flags="-O2 -mtune=generic -mfpmath=sse -msse2 -mincoming-stack-boundary=2" build --compiler=mingw32 --fcompiler=gnu95 + CALL python setup.py config_fc --f90flags="-O2 -mtune=generic -mfpmath=sse -msse2 -mincoming-stack-boundary=2" build --compiler=mingw32 --fcompiler=gnu95 ) -python setup.py install --single-version-externally-managed --record=record.txt +CALL python setup.py install --single-version-externally-managed --record=record.txt diff --git a/build_scripts/win_mingw_omp.bat b/build_scripts/win_mingw_omp.bat index 59af2c0..e9809e3 100644 --- a/build_scripts/win_mingw_omp.bat +++ b/build_scripts/win_mingw_omp.bat @@ -1,13 +1,13 @@ cd ../fortran -gfortran -E ompgen.F90 -cpp -fopenmp -o omp.f90 +CALL gfortran -E ompgen.F90 -cpp -fopenmp -o omp.f90 REM Wildcards not working on Windows for some reason -f2py -m _wrffortran -h wrffortran.pyf --overwrite-signature wrf_constants.f90 wrf_testfunc.f90 wrf_user.f90 rip_cape.f90 wrf_cloud_fracf.f90 wrf_fctt.f90 wrf_user_dbz.f90 wrf_relhl.f90 calc_uh.f90 wrf_user_latlon_routines.f90 wrf_pvo.f90 eqthecalc.f90 wrf_rip_phys_routines.f90 wrf_pw.f90 wrf_vinterp.f90 wrf_wind.f90 omp.f90 +CALLf2py -m _wrffortran -h wrffortran.pyf --overwrite-signature wrf_constants.f90 wrf_testfunc.f90 wrf_user.f90 rip_cape.f90 wrf_cloud_fracf.f90 wrf_fctt.f90 wrf_user_dbz.f90 wrf_relhl.f90 calc_uh.f90 wrf_user_latlon_routines.f90 wrf_pvo.f90 eqthecalc.f90 wrf_rip_phys_routines.f90 wrf_pw.f90 wrf_vinterp.f90 wrf_wind.f90 omp.f90 cd .. -python setup.py clean --all +CALL python setup.py clean --all %PROCESSOR_ARCHITECTURE% == AMD64 ( - python setup.py config_fc --f90flags="-O2 -mtune=generic -fopenmp" build_ext --libraries="gomp" build --compiler=mingw32 --fcompiler=gnu95 + CALL python setup.py config_fc --f90flags="-O2 -mtune=generic -fopenmp" build_ext --libraries="gomp" build --compiler=mingw32 --fcompiler=gnu95 ) else ( - python setup.py config_fc --f90flags="-O2 -mtune=generic -fopenmp -mincoming-stack-boundary=2" build_ext --libraries="gomp" build --compiler=mingw32 --fcompiler=gnu95 + CALL python setup.py config_fc --f90flags="-O2 -mtune=generic -fopenmp -mincoming-stack-boundary=2" build_ext --libraries="gomp" build --compiler=mingw32 --fcompiler=gnu95 ) -python setup.py install --single-version-externally-managed --record=record.txt +CALL python setup.py install --single-version-externally-managed --record=record.txt diff --git a/build_scripts/win_msvc_mingw_no_omp.bat b/build_scripts/win_msvc_mingw_no_omp.bat index b480f4f..3b0d008 100644 --- a/build_scripts/win_msvc_mingw_no_omp.bat +++ b/build_scripts/win_msvc_mingw_no_omp.bat @@ -1,13 +1,13 @@ cd ../fortran -gfortran -E ompgen.F90 -cpp -o omp.f90 +CALL gfortran -E ompgen.F90 -cpp -o omp.f90 REM Wildcards not working on Windows for some reason -f2py -m _wrffortran -h wrffortran.pyf --overwrite-signature wrf_constants.f90 wrf_testfunc.f90 wrf_user.f90 rip_cape.f90 wrf_cloud_fracf.f90 wrf_fctt.f90 wrf_user_dbz.f90 wrf_relhl.f90 calc_uh.f90 wrf_user_latlon_routines.f90 wrf_pvo.f90 eqthecalc.f90 wrf_rip_phys_routines.f90 wrf_pw.f90 wrf_vinterp.f90 wrf_wind.f90 omp.f90 +CALL f2py -m _wrffortran -h wrffortran.pyf --overwrite-signature wrf_constants.f90 wrf_testfunc.f90 wrf_user.f90 rip_cape.f90 wrf_cloud_fracf.f90 wrf_fctt.f90 wrf_user_dbz.f90 wrf_relhl.f90 calc_uh.f90 wrf_user_latlon_routines.f90 wrf_pvo.f90 eqthecalc.f90 wrf_rip_phys_routines.f90 wrf_pw.f90 wrf_vinterp.f90 wrf_wind.f90 omp.f90 cd .. -python setup.py clean --all +CALL python setup.py clean --all %PROCESSOR_ARCHITECTURE% == AMD64 - python setup.py config_fc --f90flags="-O2 -mtune=generic -mfpmath=sse -msse2" build --compiler=msvc --fcompiler=gnu95 + CALL python setup.py config_fc --f90flags="-O2 -mtune=generic -mfpmath=sse -msse2" build --compiler=msvc --fcompiler=gnu95 ) else ( - python setup.py config_fc --f90flags="-O2 -mtune=generic -mfpmath=sse -msse2 -mincoming-stack-boundary=2" build --compiler=msvc --fcompiler=gnu95 + CALL python setup.py config_fc --f90flags="-O2 -mtune=generic -mfpmath=sse -msse2 -mincoming-stack-boundary=2" build --compiler=msvc --fcompiler=gnu95 ) -python setup.py install --single-version-externally-managed --record=record.txt \ No newline at end of file +CALL python setup.py install --single-version-externally-managed --record=record.txt \ No newline at end of file diff --git a/build_scripts/win_msvc_mingw_omp.bat b/build_scripts/win_msvc_mingw_omp.bat index d16d0ab..40062d0 100644 --- a/build_scripts/win_msvc_mingw_omp.bat +++ b/build_scripts/win_msvc_mingw_omp.bat @@ -1,13 +1,13 @@ cd ../fortran -gfortran -E ompgen.F90 -cpp -fopenmp -o omp.f90 +CALL gfortran -E ompgen.F90 -cpp -fopenmp -o omp.f90 REM Wildcards not working on Windows for some reason -f2py -m _wrffortran -h wrffortran.pyf --overwrite-signature wrf_constants.f90 wrf_testfunc.f90 wrf_user.f90 rip_cape.f90 wrf_cloud_fracf.f90 wrf_fctt.f90 wrf_user_dbz.f90 wrf_relhl.f90 calc_uh.f90 wrf_user_latlon_routines.f90 wrf_pvo.f90 eqthecalc.f90 wrf_rip_phys_routines.f90 wrf_pw.f90 wrf_vinterp.f90 wrf_wind.f90 omp.f90 +CALL f2py -m _wrffortran -h wrffortran.pyf --overwrite-signature wrf_constants.f90 wrf_testfunc.f90 wrf_user.f90 rip_cape.f90 wrf_cloud_fracf.f90 wrf_fctt.f90 wrf_user_dbz.f90 wrf_relhl.f90 calc_uh.f90 wrf_user_latlon_routines.f90 wrf_pvo.f90 eqthecalc.f90 wrf_rip_phys_routines.f90 wrf_pw.f90 wrf_vinterp.f90 wrf_wind.f90 omp.f90 cd .. -python setup.py clean --all +CALL python setup.py clean --all %PROCESSOR_ARCHITECTURE% == AMD64 ( - python setup.py config_fc --f90flags="-O2 -mtune=generic -fopenmp" build_ext --libraries="gomp" build --compiler=msvc --fcompiler=gnu95 + CALL python setup.py config_fc --f90flags="-O2 -mtune=generic -fopenmp" build_ext --libraries="gomp" build --compiler=msvc --fcompiler=gnu95 ) else ( - python setup.py config_fc --f90flags="-O2 -mtune=generic -fopenmp -mincoming-stack-boundary=2" build_ext --libraries="gomp" build --compiler=msvc --fcompiler=gnu95 + CALL python setup.py config_fc --f90flags="-O2 -mtune=generic -fopenmp -mincoming-stack-boundary=2" build_ext --libraries="gomp" build --compiler=msvc --fcompiler=gnu95 ) -python setup.py install --single-version-externally-managed --record=record.txt +CALL python setup.py install --single-version-externally-managed --record=record.txt diff --git a/doc/source/installation.rst b/doc/source/installation.rst index 15b0cc4..bd5cb18 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -4,9 +4,10 @@ Installation Required Dependencies ---------------------- - - Python 2.7, 3.4, or 3.5 - - numpy (1.9 or later) + - Python 2.7, 3.4, or 3.5+ + - numpy (1.11 or later; 1.14 required to build on Windows) - wrapt (1.10 or later) + - setuptools (38.0 or later) Highly Recommended Packages @@ -81,13 +82,52 @@ The source code is available via github: https://github.com/NCAR/wrf-python -To install, change to the wrf-python directory and run:: +Or PyPI: + +https://pypi.python.org/pypi/wrf-python + +To install, if you do not need OpenMP support, change your working directory +to the wrf-python source directory and run:: $ pip install . + +Beginning with wrf-python 1.1, OpenMP is supported, but preprocessing the +ompgen.F90 file is required, which also requires running f2py to +build the .pyf file. To simplify this process, you can use the build scripts in +the *build_scripts* directory as a guide, or just call the script directly. + +Below is a sample from a build script for GNU compiler with OpenMP enabled: + +.. code-block:: none + + cd ../fortran + + gfortran -E ompgen.F90 -fopenmp -cpp -o omp.f90 + + f2py *.f90 -m _wrffortran -h wrffortran.pyf --overwrite-signature + + cd .. + + python setup.py clean --all + + python setup.py config_fc --f90flags="-mtune=generic -fopenmp" build_ext --libraries="gomp" build + + pip install . + +Beginning with numpy 1.14, f2py extensions can now be built using the MSVC +compiler and mingw gfortran compiler. Numpy 1.14 is required to build +wrf-python for Python 3.5+. + +.. note:: + + If you are building on a supercomputer and receiving linker related + errors (e.g. missing symbols, undefined references, etc), you probably + need to unset the LDFLAGS environment variable. System administrators on + supercomputing systems often define LDFLAGS for you so that you don't need + to worry about where libraries like NetCDF are installed. Unfortunately, + this can cause problems with the numpy.distutils build system. To fix, + using the build command from above:: + + $ unset LDFLAGS python setup.py config_fc --f90flags="-mtune=generic -fopenmp" build_ext --libraries="gomp" build + -Note that building on Win64 with Python 3.5+ and the mingw-64 compiler -is very difficult, due to incompatibilities with the runtime libraries and -lack of support from numpy's distutils. Improved support for these -configurations, along with numpy distutils support, should take place this -year. But for now, visual studio and the intel compiler may be required. -Otherwise, Python 2.7 or Python 3.4 is recommended. diff --git a/requirements.txt b/requirements.txt index 83c125c..b044c9f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ -numpy>=1.10 +numpy>=1.11 wrapt>=1.10 +setuptools>=38.0 diff --git a/src/wrf/__init__.py b/src/wrf/__init__.py index 2365ac4..25f0762 100755 --- a/src/wrf/__init__.py +++ b/src/wrf/__init__.py @@ -4,12 +4,13 @@ import os import pkg_resources # For gfortran+msvc combination, extra shared libraries may exist (stored by numpy.distutils) -if os.name == 'nt': +if os.name == "nt": try: - req = pkg_resources.Requirement.parse('wrf-python') - extra_dll_dir = pkg_resources.resource_filename(req, 'wrf-python/extra-dll') + req = pkg_resources.Requirement.parse("wrf-python") + extra_dll_dir = pkg_resources.resource_filename(req, + "wrf-python/.libs") if os.path.isdir(extra_dll_dir): - os.environ['PATH'] += os.pathsep + extra_dll_dir + os.environ["PATH"] += os.pathsep + extra_dll_dir except ImportError: pass