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