source: codes/icosagcm/devel/make_python @ 954

Last change on this file since 954 was 941, checked in by dubos, 5 years ago

devel : split DySL from Python

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/bash
2
3function log()
4{
5    echo $*
6    $*
7}
8
9function cmd_clean() # cleanup, invoked by : './make_python clean'
10{
11    rm -rf lib/*.so lib/dynamico
12    cd $DYNAMICO_ROOT/Python/src
13    rm -rf *.o *.so build/
14}
15
16#------------------ Default action , invoked by : './make_python' --------------------
17
18function make_so()
19{
20    ARLIB=$1
21    SOLIB=$2
22
23    if [[ $ARLIB -nt $SOLIB ]]; then
24        echo $ARLIB is newer than $SOLIB
25        rm -f tmp.a
26        cp $ARLIB tmp.a
27        if [[ "$4" != "" ]] ; then ar vd tmp.a $4 ; fi
28        if [[ "$5" != "" ]] ; then ar vr tmp.a $5 ; fi
29        log $LINK $SOFLAGS $WHOLE_ARCHIVE tmp.a $NO_WHOLE_ARCHIVE $3 -o $SOLIB
30        rm -f tmp.a
31        $LDD $SOLIB
32    fi
33}
34
35
36function cmd_()
37{
38    echo "XIOS_ROOTDIR : $XIOS_ROOTDIR"
39    MISSING=""
40    for module in netCDF4 jinja2 mpi4py; do
41        echo "import $module"
42        python -c "import $module" || MISSING="$MISSING $module"
43    done
44    if [[ "$MISSING" == "" ]] ; then
45        echo "All required Python modules seem present."
46    else
47        echo "Missing/dysfunctional python modules : $MISSING"
48        echo "Please fix your Python configuration"
49        exit
50    fi
51
52    log mpicc -c -std=c99 -fPIC $PARMETIS_CFLAGS Python/src/partition.c -o obj/partition.o
53    make_so $XIOS_ROOTDIR/lib/libxios.a $LIBDIR/libxios.so "$NETCDF_LDFLAGS -lstdc++"
54    make_so $LIBDIR/libicosa.a $LIBDIR/libicosa.so "-L$LIBDIR -lxios $KERNELS_LDFLAGS" "physics_external_mod.o physics_mod.o timeloop_gcm_mod.o icosa_init_mod.o" obj/partition.o
55
56    # Cythonize Python modules
57    cd $DYNAMICO_ROOT/Python/src
58    NUMPY=$(python -c 'import numpy as np ; print np.get_include()')
59    CYTHONFLAGS="$SOFLAGS $LDFLAGS -L$LIBDIR -licosa $KERNELS_LDFLAGS"
60    LDSHARED="$LINK" CFLAGS="-fno-strict-aliasing -O2 -I$NUMPY" LDFLAGS="$CYTHONFLAGS" log python setup.py build_ext --inplace || exit
61
62    cp -fpr $DYNAMICO_ROOT/Python/dynamico $DYNAMICO_ROOT/lib
63    cp -fp *.so $DYNAMICO_ROOT/lib/dynamico/dev/
64    cd $DYNAMICO_ROOT
65
66    for module in dev.cxios dev.unstructured meshes dyn time_step DCMIP; do
67        echo "import dynamico.$module"
68        LD_PRELOAD=$PYTHON_PRELOAD python -c "import dynamico.$module"
69    done
70}
71
72#------------------------- script starts here ------------------------
73
74DYNAMICO_ROOT=$PWD
75LIBDIR=$DYNAMICO_ROOT/lib
76
77. arch.env
78. arch.path
79
80echo "Selected architecture : $CURRENT_ARCH"
81if [[ "$CURRENT_ARCH" == "" ]] ; then echo "Current architecture undefined or unsupported" ; exit ; fi
82
83cd arch
84. arch-${CURRENT_ARCH}.dev
85cd $DYNAMICO_ROOT
86
87time cmd_$1
Note: See TracBrowser for help on using the repository browser.