Skip to content

python wrapper to execute DISORT. Simplifies the radiative transfer calculations.

Notifications You must be signed in to change notification settings

SeregaOsipov/pyDISORT

Repository files navigation

Steps to build:

cd disort4.0.99
cat DISOTESTAUX.f DISORT.f BDREF.f DISOBRDF.f ERRPACK.f LINPAK.f LAPACK.f RDI1MACH.f > code_smart.f
# Inject "smart" f2py instructions into code_smart.f
f2py -m disort code_smart.f -h disort.pyf only: getmom disort prtfin

# Add the Line below to code_smart.f at 2173
CF2PY INTENT(IN)   :: DELTAMPLUS, DO_PSEUDO_SPHERE

# Edit disort.pyf and remove entire "block data chekdo" or move it to the end. Otherwise it breaks disort compilation.
# Further:
# 1. fix the UMU dimensions (should be 3d instead of 1d).
# 2. change umu intent from in to inplace to support USRANGLE == False
# 3. Add intent(in) for deltamplus, do_pseudo_sphere
    logical intent(in):: deltamplus
    logical intent(in):: do_pseudo_sphere
# The corrected version is available as disort.pyf.manual. Copy it as disort.pyf
f2py -c disort.pyf code_smart.f
# move disort.cpython-310-x86_64-linux-gnu.so to the project root or add it to the PYTHON_PATH
mv disort.cpython-310-x86_64-linux-gnu.so ../


NOTE: For better accuracy, compile disort in double (not in single) precision. In addition to Fortran autodoubling, have to tell f2py about real->double switch using the dedicated map
Compile like this:
f2py --f77flags='-fdefault-real-8 -fdefault-double-8' --f90flags='-O3 -g -fcheck=all -fdump-core -fbounds-check -Wall -fdefault-real-8 -fdefault-double-8' --f2cmap f2py_doubling_map.txt -c disort.pyf code_smart.f

It is important to specify f77 flags in addition to f90 and both fdefault-real-8 & fdefault-double-8

F2PY map f2py_doubling_map.txt should contain:
{'real':{'':'double'},'integer':{'':'long'},'real*8':{'':'double'}}


NOTE: for debuging, use --debug-capi f2py flag

About

python wrapper to execute DISORT. Simplifies the radiative transfer calculations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published