[248] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | install_dir=$PWD |
---|
[287] | 4 | compil_full="false" |
---|
| 5 | use_oasis="false" |
---|
[313] | 6 | job="1" |
---|
[248] | 7 | |
---|
| 8 | # Traitement de la ligne de commande |
---|
| 9 | while (($# > 0)) |
---|
| 10 | do |
---|
| 11 | case $1 in |
---|
| 12 | "-h") |
---|
[374] | 13 | echo "make_xios - installs XIOS on your architecture" |
---|
| 14 | echo "make_xios [options]" |
---|
| 15 | echo "options :" |
---|
| 16 | echo " [--prod] : compilation in production mode" |
---|
| 17 | echo " [--dev] : compilation in development mode" |
---|
| 18 | echo " [--debug] : compilation in debug mode" |
---|
| 19 | echo " --arch arch : to choose target architecture" |
---|
| 20 | echo " [--avail] : to know available target architectures " |
---|
| 21 | echo " [--full] : to generate dependencies and recompile from scratch" |
---|
| 22 | echo " [--use_oasis] : to use Oasis coupler" |
---|
| 23 | echo " [--doc] : to generate Doxygen documentation (not available yet)" |
---|
| 24 | echo " [--job ntasks] : to use parallel compilation with ntasks" |
---|
| 25 | echo "Example : ./make_xios --prod --arch PW6_VARGAS" |
---|
| 26 | echo "Example : ./make_xios --avail" |
---|
[248] | 27 | exit;; |
---|
| 28 | "--prod") compil_mode="prod" ; shift ;; |
---|
| 29 | "--dev") compil_mode="dev" ; shift ;; |
---|
| 30 | "--debug") compil_mode="debug" ; shift ;; |
---|
| 31 | "--arch") arch=$2 ; shift ; shift ;; |
---|
[377] | 32 | "--avail") ls arch/*.fcm | cut -d"-" -f2 | cut -d"." -f1 ; exit ;; |
---|
[313] | 33 | "--full") compil_full="true" ; shift ;; |
---|
[301] | 34 | "--use_oasis") use_oasis="true" ; shift ;; |
---|
[248] | 35 | "--doc") doc="true" ; shift ;; |
---|
[313] | 36 | "--job") job=$2 ; shift ; shift ;; |
---|
[248] | 37 | *) code="$1" ; shift ;; |
---|
| 38 | esac |
---|
| 39 | done |
---|
| 40 | |
---|
[374] | 41 | # Installation des sources |
---|
[377] | 42 | nb_files_gz=`ls $install_dir/tools/archive | grep tar.gz | wc -l` |
---|
| 43 | if [ ${nb_files_gz} -ne 0 ] |
---|
[376] | 44 | then |
---|
[377] | 45 | echo -e "- uncompress archives ..." |
---|
[376] | 46 | for tarname in `ls $install_dir/tools/archive/*.tar.gz` ; do |
---|
| 47 | gunzip -f "$tarname" |
---|
| 48 | tar -xf ${tarname%.gz} |
---|
| 49 | done |
---|
| 50 | fi |
---|
[374] | 51 | |
---|
[248] | 52 | # Vérification de la présence d'un identifiant d'architecture. |
---|
| 53 | |
---|
[281] | 54 | ############################################################### |
---|
[374] | 55 | # lecture des chemins propres a l'architecture de la machine # |
---|
[281] | 56 | # et configuration de l'environnement # |
---|
| 57 | ############################################################### |
---|
| 58 | |
---|
| 59 | rm -f .void_file |
---|
| 60 | echo > .void_file |
---|
| 61 | rm -rf .void_dir |
---|
| 62 | mkdir .void_dir |
---|
| 63 | |
---|
[248] | 64 | if [[ !(-z $arch) ]] |
---|
| 65 | then |
---|
| 66 | rm -f $install_dir/arch.path |
---|
| 67 | rm -f $install_dir/arch.fcm |
---|
[281] | 68 | rm -f $install_dir/arch.env |
---|
[248] | 69 | ln -s $install_dir/arch/arch-${arch}.path $install_dir/arch.path |
---|
| 70 | ln -s $install_dir/arch/arch-${arch}.fcm $install_dir/arch.fcm |
---|
[281] | 71 | |
---|
| 72 | if test -f $install_dir/arch/arch-${arch}.env |
---|
| 73 | then |
---|
| 74 | ln -s $install_dir/arch/arch-${arch}.env arch.env |
---|
| 75 | else |
---|
| 76 | ln -s $install_dir/.void_file arch.env |
---|
| 77 | fi |
---|
| 78 | |
---|
| 79 | source $install_dir/arch.env |
---|
[248] | 80 | source $install_dir/arch.path |
---|
[281] | 81 | else |
---|
[248] | 82 | echo "Veuillez definir une architecture cible !" |
---|
| 83 | exit 1 |
---|
| 84 | fi |
---|
| 85 | |
---|
| 86 | # Vérification de la présence d'un mode de compilation. |
---|
| 87 | |
---|
| 88 | if [[ "$compil_mode" == "prod" ]] |
---|
| 89 | then |
---|
| 90 | COMPIL_CFLAGS="%PROD_CFLAGS" |
---|
| 91 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
| 92 | elif [[ "$compil_mode" == "dev" ]] |
---|
| 93 | then |
---|
| 94 | COMPIL_CFLAGS="%DEV_CFLAGS" |
---|
| 95 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
| 96 | elif [[ "$compil_mode" == "debug" ]] |
---|
| 97 | then |
---|
| 98 | COMPIL_CFLAGS="%DEBUG_CFLAGS" |
---|
| 99 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
| 100 | else |
---|
| 101 | echo "Veuillez definir un mode de compilation [debug|dev|prod] !" |
---|
| 102 | exit 1 |
---|
| 103 | fi |
---|
| 104 | |
---|
[287] | 105 | if [[ "$use_oasis" == "true" ]] |
---|
| 106 | then |
---|
| 107 | XMLIO_FINCDIR="$OASIS_INCDIR $XMLIO_FINCDIR" |
---|
| 108 | XMLIO_LIB="$OASIS_LIBDIR $OASIS_LIB $XMLIO_LIB" |
---|
| 109 | XMLIO_CPPKEY="$XMLIO_CPPKEY USE_OASIS" |
---|
| 110 | fi |
---|
[362] | 111 | |
---|
[248] | 112 | XMLIO_CINCDIR="$NETCDF_INCDIR $HDF5_INCDIR $MPI_INCDIR" |
---|
[287] | 113 | XMLIO_FINCDIR="$XMLIO_FINCDIR $MPI_INCDIR" |
---|
[248] | 114 | |
---|
[287] | 115 | XMLIO_LIB="$XMLIO_LIB $NETCDF_LIBDIR $HDF5_LIBDIR $MPI_LIBDIR $NETCDF_LIB $HDF5_LIB $MPI_LIB" |
---|
[248] | 116 | |
---|
| 117 | rm -f config.fcm |
---|
| 118 | echo "%COMPIL_CFLAGS $COMPIL_CFLAGS" >> config.fcm |
---|
| 119 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm |
---|
[287] | 120 | echo "%CPP_KEY $XMLIO_CPPKEY" >> config.fcm |
---|
[248] | 121 | |
---|
| 122 | echo "%CBASE_INC $XMLIO_CINCDIR" >> config.fcm |
---|
| 123 | echo "%FBASE_INC $XMLIO_FINCDIR" >> config.fcm |
---|
| 124 | echo "%ARCH_LD $XMLIO_LIB" >> config.fcm |
---|
| 125 | |
---|
| 126 | echo "=> Activation du mode "$compil_mode" pour la distribution sous l'architecture \""$arch"\" !" |
---|
| 127 | |
---|
| 128 | # Création de la documentation doxygen. |
---|
| 129 | if [[ !(-z $doc) ]] |
---|
| 130 | then |
---|
| 131 | echo -e "- Création de la documentation de code doxygen (désactivée)..." |
---|
| 132 | #doxygen -s |
---|
| 133 | fi |
---|
| 134 | |
---|
| 135 | make_dir=$PWD |
---|
| 136 | |
---|
| 137 | export PATH=$PWD/tools/FCM/bin:$PATH |
---|
| 138 | |
---|
[274] | 139 | #$make_dir/tools/preprocess_cpp $make_dir/src/xmlio/iface/interface.cpp $make_dir/src/xmlio/iface/interface.cpp.in |
---|
| 140 | #$make_dir/tools/preprocess_f03 $make_dir/src/xmlio/fortran/ixmlioserver.f90 $make_dir/src/xmlio/fortran/ixmlioserver.f03.in |
---|
[248] | 141 | |
---|
[287] | 142 | if [[ "$compil_full" == "true" ]] |
---|
| 143 | then |
---|
[313] | 144 | fcm build -f -j $job |
---|
[287] | 145 | else |
---|
[313] | 146 | fcm build -j $job |
---|
[287] | 147 | fi |
---|
[248] | 148 | |
---|
[287] | 149 | |
---|
| 150 | if [[ $? == 0 ]] |
---|
| 151 | then |
---|
[366] | 152 | set nothing |
---|
[287] | 153 | # cd $WORKDIR/XMLIO_NEMO_COUPLE/modeles/NEMO/WORK |
---|
[362] | 154 | # cd $WORKDIR/XMLIO_NEMO/modeles/NEMO/WORK |
---|
[301] | 155 | # make |
---|
[287] | 156 | fi |
---|