I'm having an affair from my Mac and playing with Windows. Windows 10 Pro / Education can be used with Ubuntu on Windows, Docker for Windows, and Hyper-V, but it can be done, but you have to use or teach using Windows in the training room without administrator privileges. I think there are times.
The official Python installer can also be installed without administrator privileges, but Conda is convenient when trying to do numpy etc. I used Miniconda Python-3.6 64-bit to conda install jupyter, but I think it would be easier to install Anaconda. numpy contains f2py, but it wasn't ready to use.
Since I am not good at DOS commands below, I am using PowerShell, which has an alias, and bash of git for windows, which I installed later.
I thought about installing mingw-w64, but since it was prepared by Mr. Conda, I decided to install it.
conda install m2w64-gcc-fortran
Since the path does not pass just by installing it,
C: \ Users \ username \ Miniconda3 \ Library \ mingw-w64 \ bin
(In the case of Anaconda, ʻAnaconda3 instead of
Miniconda3`, the path to Conda is omitted below) is added to the path. When you ask Cortana "environment variables", it opens a control panel for setting environment variables. You should be able to edit the Path of the user environment variable at the top.
Conda's f2py is in Scripts \ f2py.py
. Create a batch file Scripts \ f2py.bat` so that it can be executed.
f2py.bat
python %~dp0/f2py.py %*
If you use PowerShell, you can write the function in $ profile
.
function f2py () {python \ Users \ username \ Miniconda3 \ Scripts \ f2py.py $ args}
I can now run f2py, but when I give it the source I get the error ValueError: Unknown MS Compiler version 1900
. A little source modification is needed.
Lib \ distutils \ cygwinccompiler.py
comment out lines 157 and 318 so that pass
does nothing. Add pass #
.
cygwinccompiler.py
pass#self.dll_libraries = get_msvcr()
Lib \ site-packages \ numpy \ distutils \ mingw32ccompiler.py
comment out lines 96-104 with#
.
mingw32ccompiler.py
# Check for custom msvc runtime library on Windows. Build if it doesn't exist.
#msvcr_success = build_msvcr_library()
#msvcr_dbg_success = build_msvcr_library(debug=True)
#if msvcr_success or msvcr_dbg_success:
# add preprocessor statement for using customized msvcr lib
# self.define_macro('NPY_MINGW_USE_CUSTOM_MSVCR')
# Define the MSVC version as hint for MinGW
#msvcr_version = '0x%03i0' % int(msvc_runtime_library().lstrip('msvcr'))
#self.define_macro('__MSVCRT_VERSION__', msvcr_version)
hello
Try immediately.
foo.f90
subroutine hello()
print *, "Hello"
end subroutine hello
f2py -c --fcompiler=gnu95 --compiler=mingw32 -m foo .\foo.f90
PS C:\Users\User name\Development\foo> python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>> foo.hello()
Hello from Fortran90!!!
>>>
At first I was worried about UnicodeDecodeError, but when I switched the shell to English, it worked. It is a mystery because the error cannot be reproduced even if it is returned to Japanese.
chcp 437
Lowtran
Try it with lowtran. git is also included in conda, but I installed git for Windows which also comes with GUI and bash.
I didn't have pandas, so I added it with conda.
git clone https://github.com/scivision/lowtran
cd lowtran
setup.py develop
conda install pandas
python DemoLowtran.py -a 0 12.5 25
I love the different colors.
Recommended Posts