source: trunk/UTIL/PYTHON/mcd/fmcd_g95.sh @ 793

Last change on this file since 793 was 639, checked in by aslmd, 13 years ago

UTIL PYTHON : Interfacing MCD with python. (Also a toy web server in proto; for the moment, do not use nor modify).

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#! /bin/bash
2
3###
4### fmcd_g95.sh
5###
6### ---> This should be used to make MCD fortran stuff directly accessible in python
7### ---> This script is for g95, but it is easy to adapt to your other compilers
8### ---> A file fmcd.so should be created
9### ---> See mcd.py for use in python. Very easy!
10###
11### AS. 17/04/2012.
12###
13
14### LINKS
15NETCDF=/home/aymeric/Science/MODELES/MESOSCALE_DEV/NETCDF/netcdf64-4.0.1_gfortran/
16wheremcd=/home/aymeric/Science/MCD_v4.3/mcd/
17
18### LOG FILE
19touch fmcd.log
20\rm fmcd.log
21
22### COPY/PREPARE SOURCES
23### perform changes that makes f2py not to fail
24sed s/"\!\!'"/"'"/g $wheremcd/call_mcd.F         | sed s/"\!'"/"'"/g | sed s/"\!"/"\n\!"/g > tmp.call_mcd.F
25sed s/"\!\!'"/"'"/g $wheremcd/julian.F           | sed s/"\!'"/"'"/g | sed s/"\!"/"\n\!"/g > tmp.julian.F
26sed s/"\!\!'"/"'"/g $wheremcd/heights.F          | sed s/"\!'"/"'"/g | sed s/"\!"/"\n\!"/g > tmp.heights.F
27sed s/"\!\!'"/"'"/g $wheremcd/constants_mcd.inc  | sed s/"\!'"/"'"/g | sed s/"\!"/"\n\!"/g > constants_mcd.inc
28
29### BUILD THROUGH f2py WHAT IS NECESSARY TO CREATE THE PYTHON FUNCTIONS
30touch fmcd.pyf
31\rm fmcd.pyf
32f2py -h fmcd.pyf -m fmcd tmp.call_mcd.F tmp.julian.F tmp.heights.F > fmcd.log 2>&1
33
34### IMPORTANT: we teach f2py about variables in the call_mcd subroutines which are intended to be out
35sed s/"real :: pres"/"real, intent(out) :: pres"/g fmcd.pyf | \
36sed s/"real :: dens"/"real, intent(out) :: dens"/g | \
37sed s/"real :: temp"/"real, intent(out) :: temp"/g | \
38sed s/"real :: zonwind"/"real, intent(out) :: zonwind"/g | \
39sed s/"real :: merwind"/"real, intent(out) :: merwind"/g | \
40sed s/"real dimension(5) :: meanvar"/"real dimension(5),intent(out) :: meanvar"/g | \
41sed s/"real dimension(100) :: extvar"/"real dimension(100),intent(out) :: extvar"/g | \
42sed s/"real :: seedout"/"real, intent(out) :: seedout"/g | \
43sed s/"integer :: ier"/"integer, intent(out) :: ier"/g > fmcd.pyf.modif
44mv fmcd.pyf.modif fmcd.pyf
45
46### BUILD
47f2py -c fmcd.pyf tmp.call_mcd.F tmp.julian.F tmp.heights.F --fcompiler=g95 \
48  -L$NETCDF/lib -lnetcdf \
49  -lm -I$NETCDF/include \
50  --f90flags="-Wall -Wno=112,141,137,155,110 -fno-second-underscore" \
51  --verbose \
52  > fmcd.log 2>&1
53#  --include-paths $NETCDF/include:$NETCDF/lib \ ---> makes it fail
54
55### CLEAN THE PLACE
56\rm tmp.call_mcd.F tmp.julian.F tmp.heights.F constants_mcd.inc
Note: See TracBrowser for help on using the repository browser.