source: XIOS/dev/dev_ym/XIOS_COUPLING/make_xios @ 1956

Last change on this file since 1956 was 1875, checked in by ymipsl, 4 years ago

XIOS coupling branch
Some updates.

First coupling test is beginning to work...

YM

  • Property svn:executable set to *
File size: 9.8 KB
RevLine 
[248]1#!/bin/bash
2
3install_dir=$PWD
[287]4compil_full="false"
5use_oasis="false"
[475]6oasis="oasis3_mct"
[1497]7build_path="./"
8build_dir="./"
9build_suffixed="false"
[1449]10use_extern_boost="false"
[1453]11use_extern_blitz="false"
[402]12use_memtrack="false"
[1875]13use_tv="false"
[313]14job="1"
[381]15netcdf_lib="netcdf4_par"
16compil_mode="prod"
[1497]17arch_path=$PWD/"arch"
18arch_default_path=$PWD/"arch"
[1450]19arch_defined="FALSE"
20arch_path_defined="FALSE"
[248]21
22# Traitement de la ligne de commande
23while (($# > 0))
24   do
25      case $1 in
[383]26         "-h"|"--help"|"-help")
[374]27            echo "make_xios - installs XIOS on your architecture"
28            echo "make_xios [options]"
29            echo "options :"
[381]30            echo "       [--prod] : compilation in production mode (default)"
[374]31            echo "       [--dev] : compilation in development mode"
32            echo "       [--debug] : compilation in debug mode"
33            echo "       --arch arch : to choose target architecture"
34            echo "       [--avail] : to know available target architectures "
35            echo "       [--full] : to generate dependencies and recompile from scratch"
[1497]36            echo "       [--use_oasis 'oasis3' 'oasis3_mct' : default oasis3_mct] : to use Oasis coupler"
[1875]37        echo "       [--build_path] : absolute path to the build directory"
38        echo "       [--build_dir ]: name of the build directory"
39        echo "       [--build_suffixed ]: generate automatically suffixed name of the build directory (e.g. config_X64_CURIE_prod)"
40        echo "       [--use_extern_boost] : to use external boost library"
41        echo "       [--use_extern_blitz] : to use external blitz library"
42        echo "       [--use_tv] : to use totalview data type display"
[374]43            echo "       [--doc] : to generate Doxygen documentation (not available yet)"
44            echo "       [--job ntasks] : to use parallel compilation with ntasks"
[410]45            echo "       [--netcdf_lib 'netcdf4_par'/'netcdf4_seq'/'netcdf4_internal' : default netcdf4_par] : choice of netcdf library"
[402]46            echo "       [--memtrack] : tracking memory leak - developper only"
[374]47            echo "Example : ./make_xios --prod --arch PW6_VARGAS"
48            echo "Example : ./make_xios --avail"
[248]49            exit;;
50         "--prod")  compil_mode="prod"  ; shift ;;
51         "--dev")   compil_mode="dev"   ; shift ;;
52         "--debug") compil_mode="debug" ; shift ;;
[1450]53         "--arch")  arch=$2     ; arch_defined="TRUE"; shift ; shift ;;
54         "--arch_path")  arch_path=$2     ; arch_path_defined="TRUE"; shift ; shift ;;
[383]55         "--avail") ls arch/*.fcm | cut -d"-" -f2 | cut -d"." -f1 ; exit ;;
[313]56         "--full")  compil_full="true"  ; shift ;;
[475]57         "--use_oasis")  use_oasis="true" oasis=$2 ; shift ; shift  ;;
[1497]58         "--build_path")  build_path=$2     ; shift ; shift ;;
59         "--build_dir")  build_dir=$2     ; shift ; shift ;;
60         "--build_suffixed")  build_suffixed="true" ; shift  ;;
[1449]61         "--use_extern_boost")  use_extern_boost="true" ; shift  ;;
[1453]62         "--use_extern_blitz")  use_extern_blitz="true" ; shift  ;;
[1875]63         "--use_tv")  use_tv="true" ; shift  ;;
[248]64         "--doc")   doc="true"          ; shift ;;
[313]65         "--job")   job=$2              ; shift ; shift ;;
[381]66         "--netcdf_lib")   netcdf_lib=$2 ; shift ; shift ;;
[1450]67         "--memtrack")  use_memtrack="true" memtrack=$2  ; shift ; shift ;;
[248]68         *)         code="$1"           ; shift ;;
69      esac
70   done
71
[374]72# Installation des sources
[377]73nb_files_gz=`ls $install_dir/tools/archive | grep tar.gz | wc -l`
74if [ ${nb_files_gz} -ne 0 ]               
[376]75then
[377]76    echo -e "- uncompress archives ..."         
[376]77    for tarname in `ls $install_dir/tools/archive/*.tar.gz` ; do
[1458]78        if  ( [[ ${tarname} == "${install_dir}/tools/archive/boost.tar.gz" ]] && [[ "$use_extern_boost" == "true" ]] ) || ( [[ ${tarname} == "${install_dir}/tools/archive/blitz.tar.gz" ]] && [[ "$use_extern_blitz" == "true" ]] )
79        then
80                continue
81        fi
[376]82        gunzip -f "$tarname"
83        tar -xf ${tarname%.gz}
84    done
85fi
[374]86
[1498]87# Definition of the root directory of the build
88
89if [[ "$build_path" == "./" ]]; then
90  install_dir=$PWD
91else
92  install_dir=${build_path}
93fi
94
[1497]95if [[ "$build_suffixed" == "true" ]]; then
[1498]96    install_dir="${install_dir}/config_${arch}_${compil_mode}"
[1497]97else
[1498]98    install_dir="${install_dir}/${build_dir}"
[1497]99fi
[1498]100
[1497]101mkdir -p $install_dir
102
103rm -f ${PWD}/bld_dir.cfg
104echo "inc    ${install_dir}/arch.fcm" >> ${PWD}/bld_dir.cfg
105echo "inc    ${install_dir}/config.fcm" >> ${PWD}/bld_dir.cfg
106echo "dir::root  ${install_dir}"   >> ${PWD}/bld_dir.cfg
107
[248]108# Vérification de la présence d'un identifiant d'architecture.
109
[281]110###############################################################
[374]111# lecture des chemins propres a l'architecture de la machine #
[281]112#           et configuration de l'environnement              #
113###############################################################
114
115rm -f .void_file
116echo > .void_file
117rm -rf .void_dir
118mkdir .void_dir
119
[1450]120if [[ "$arch_defined" == "TRUE" ]]
121then
[1497]122  rm -f ${install_dir}/arch.path
123  rm -f ${install_dir}/arch.fcm
124  rm -f ${install_dir}/arch.env
[281]125
[1450]126  if test -f $arch_path/arch-${arch}.path
127  then
[1497]128    ln -s $arch_path/arch-${arch}.path ${install_dir}/arch.path
[1450]129  elif test -f $arch_default_path/arch-${arch}.path
130  then
[1497]131    ln -s $arch_default_path/arch-${arch}.path ${install_dir}/arch.path
[1450]132  fi
133       
134  if test -f $arch_path/arch-${arch}.fcm
135  then
[1497]136    ln -s $arch_path/arch-${arch}.fcm ${install_dir}/arch.fcm
[1450]137  elif test -f $arch_default_path/arch-${arch}.fcm
138  then
[1497]139    ln -s $arch_default_path/arch-${arch}.fcm ${install_dir}/arch.fcm
[1450]140  fi
[281]141
[1450]142  if test -f $arch_path/arch-${arch}.env
143  then
[1497]144    ln -s $arch_path/arch-${arch}.env ${install_dir}/arch.env
[1450]145  elif test -f $arch_default_path/arch-${arch}.env
146  then
[1497]147    ln -s $arch_default_path/arch-${arch}.env ${install_dir}/arch.env
[281]148  else
[1497]149    ln -s .void_file ${install_dir}/arch.env
[1450]150  fi
[1497]151  source ${install_dir}/arch.env
152  source ${install_dir}/arch.path
[1450]153else
[381]154      echo "Please choose a target achitecture --> list all available architecture using make_xios --avail!"
[248]155      exit 1
156fi
157
158# Vérification de la présence d'un mode de compilation.
159
160if [[ "$compil_mode" == "prod" ]]
161   then
162      COMPIL_CFLAGS="%PROD_CFLAGS"
163      COMPIL_FFLAGS="%PROD_FFLAGS"
164elif [[ "$compil_mode" == "dev" ]]
165   then
166      COMPIL_CFLAGS="%DEV_CFLAGS"
167      COMPIL_FFLAGS="%DEV_FFLAGS"
168elif [[ "$compil_mode" == "debug" ]]
169   then
170      COMPIL_CFLAGS="%DEBUG_CFLAGS"
171      COMPIL_FFLAGS="%DEBUG_FFLAGS"
172fi
173
[410]174rm -r $PWD/extern/netcdf4
175
[381]176if [[ "$netcdf_lib" == "netcdf4_par" ]]
177   then
[410]178     ln -s $PWD/.void_dir $PWD/extern/netcdf4
[591]179     XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR"
[381]180elif [[ "$netcdf_lib" == "netcdf4_seq" ]]
181  then
[410]182    ln -s $PWD/.void_dir $PWD/extern/netcdf4
183elif [[ "$netcdf_lib" == "netcdf4_internal" ]]
184  then
185    ln -s $PWD/extern/src_netcdf4 $PWD/extern/netcdf4
[591]186    XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR USING_NETCDF_INTERNAL"
[410]187    export NETCDF_INCDIR="-I${PWD}/extern/netcdf4"
188    export NETCDF_LIBDIR=""
189    export NETCDF_LIB=""
[381]190else
[410]191   echo "Bad choice for --netcdf_lib argument : choose between 'netcdf4_par','netcdf4_seq' or 'netcdf4_internal'"
[381]192   exit
193fi
194
[287]195if [[ "$use_oasis" == "true" ]]
196   then
[475]197    if [[ "$oasis" == "oasis3_mct" ]]
198    then
[591]199        XIOS_CPPKEY="$XIOS_CPPKEY USE_OMCT"
[475]200    elif [[ "$oasis" == "oasis3"  ]]
201    then
[591]202        XIOS_CPPKEY="$XIOS_CPPKEY USE_OASIS"
[475]203        OASIS_INCDIR="-I$PWD/../../prism/X64/build/lib/psmile.MPI1"
204        OASIS_LIBDIR="-L$PWD/../../prism/X64/lib"
205        OASIS_LIB="-lpsmile.MPI1 -lmpp_io"
206    else
207        echo "Bad choice for --use_oasis argument : choose between 'oasis3','oasis3_mct'"
208        exit
209    fi
210    NETCDF_LIB="-lnetcdff -lnetcdf"
[591]211    XIOS_FINCDIR="$OASIS_INCDIR $XIOS_FINCDIR"
212    XIOS_LIB="$OASIS_LIBDIR $OASIS_LIB $XIOS_LIB"
[1450]213fi 
[362]214
[1449]215# Setting path for boost
216if [[ "$use_extern_boost" == "true" ]]
217then
[1458]218   rm -r $PWD/extern/boost
[1449]219   ln -s $PWD/.void_dir $PWD/extern/boost
220else
221   export BOOST_INCDIR="-I${PWD}/extern/boost"
222   export BOOST_LIBDIR=""
223   export BOOST_LIB=""
224fi
225
[1453]226# Setting path for blitz
227if [[ "$use_extern_blitz" == "true" ]]
228then
[1458]229   rm -r $PWD/extern/blitz
[1453]230   ln -s $PWD/.void_dir $PWD/extern/blitz
231else
[1510]232   echo "src::blitz $PWD/extern/blitz/src" >> ${PWD}/bld_dir.cfg
[1453]233   export BLITZ_INCDIR="-I${PWD}/extern/blitz"
234   export BLITZ_LIBDIR=""
235   export BLITZ_LIB=""
236fi
237
[1875]238if [[ "$use_tv" == "true" ]]
239then
240   echo "src::tv_data_display $PWD/extern/tv_data_display" >> ${PWD}/bld_dir.cfg
241fi
[1453]242
[1875]243
[402]244if [[ "$use_memtrack" == "true" ]]
245   then
[591]246   XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK"
[1450]247
248    if [[ "$memtrack" == "light" ]]
249    then
250        XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK_LIGHT"
251    elif [[ "$memtrack" == "FULL"  ]]
252    then
253      XIOS_LIB="$ADDR2LINE_LIBDIR $ADDR2LINE_LIB $XIOS_LIB"
254      XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK_FULL"
255    else
256        echo "Bad choice for --memtrack argument : choose between 'light','full'"
257        exit
258    fi
[402]259fi
260
[1453]261XIOS_CINCDIR="$NETCDF_INCDIR $HDF5_INCDIR $MPI_INCDIR $BOOST_INCDIR $BLITZ_INCDIR"
262XIOS_FINCDIR="$NETCDF_INCDIR $XIOS_FINCDIR $MPI_INCDIR $BOOST_INCDIR $BLITZ_INCDIR"
[248]263
[591]264XIOS_LIB="$XIOS_LIB $NETCDF_LIBDIR $HDF5_LIBDIR $MPI_LIBDIR $NETCDF_LIB $HDF5_LIB $MPI_LIB"
[248]265
[1497]266rm -f ${install_dir}/config.fcm
267echo "%COMPIL_CFLAGS $COMPIL_CFLAGS" >> ${install_dir}/config.fcm
268echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> ${install_dir}/config.fcm
269echo "%CPP_KEY       $XIOS_CPPKEY"   >> ${install_dir}/config.fcm
[248]270
[1497]271echo "%CBASE_INC     $XIOS_CINCDIR" >> ${install_dir}/config.fcm     
272echo "%FBASE_INC     $XIOS_FINCDIR" >> ${install_dir}/config.fcm
273echo "%ARCH_LD       $XIOS_LIB"     >> ${install_dir}/config.fcm
[248]274
[381]275echo "=> Using "$compil_mode" mode for compiling under architecture \""$arch"\" !"
[248]276
277# Création de la documentation doxygen.
278if [[ !(-z $doc) ]]
279   then
[381]280      echo -e "- Create Doxygen documentation (disabled)..."
[248]281      #doxygen -s
282fi
283
284make_dir=$PWD
285
286export PATH=$PWD/tools/FCM/bin:$PATH
287
[287]288if [[ "$compil_full" == "true" ]]
289   then
[395]290   fcm build --clean --ignore-lock
291   fcm build -f --ignore-lock -j $job
[287]292else
[395]293  fcm build --ignore-lock -j $job
[287]294fi
[248]295
[601]296build_exit_status=$?
[287]297
[601]298if [[ $build_exit_status == 0 ]]
[287]299  then
[366]300  set nothing
[591]301#    cd $WORKDIR/XIOS_NEMO_COUPLE/modeles/NEMO/WORK
302#    cd $WORKDIR/XIOS_NEMO/modeles/NEMO/WORK
[301]303#    make
[287]304fi
[601]305
306exit $build_exit_status
Note: See TracBrowser for help on using the repository browser.