Page tree

MESH - A Community Hydrology - Land Surface Model


Skip to end of metadata
Go to start of metadata

Python

Python is a useful scripting language that can be used with Fortran modules to improve flexibility with manipulating certain types of data. A fully-featured development environment can be installed to write and run new Python scripts. However, if the intent is to simply run an existing script, an alternate approach is to run Python from the Cygwin terminal.

Cygwin

Cygwin is a software package that can be used to compile Standalone MESH on Microsoft Windows.

Installing Python with Cygwin

Configuring Cygwin

  1. Download and run the Cygwin installer: setup-x86.exe for 32-bit or setup-x86_64.exe for 64-bit (source: http://cygwin.com/install.html).
  2. Search for and mark the following packages for installation:
    • \All\Devel\make
    • \All\Devel\gcc-core
    • \All\Devel\gcc-fortran
    • \All\Devel\gcc-g++
    • \All\Python\python2
    • \All\Python\python2-pip

Optionally, include python3 components.

To distinguish between python 2 or 3, include the version when calling python:
#!/bin/python2

Installing Python

  1. Run "Cygwin Terminal" (mintty.exe)
  2. Use 'pip' to install additional packages, as required:
    pip2 install --upgrade numpy
To install or update packages for python 3, replace 'pip2' with 'pip3'.

Running Python from the Cygwin terminal

  • To compile an existing Fortran module for Python:
    f2py -c -m NAME_OF_FILE NAME_OF_FILE.f90
  • To run an existing Python script:
    python NAME_OF_FILE.py input_arguments

  • No labels