source: XIOS/trunk/make_xios @ 984

Last change on this file since 984 was 984, checked in by ymipsl, 7 years ago

Add --arch_path option for make_xios.

YM

  • Property svn:executable set to *
File size: 6.8 KB
RevLine 
[248]1#!/bin/bash
2
3install_dir=$PWD
[287]4compil_full="false"
5use_oasis="false"
[475]6oasis="oasis3_mct"
[402]7use_memtrack="false"
[313]8job="1"
[381]9netcdf_lib="netcdf4_par"
10compil_mode="prod"
[984]11arch_path="arch"
12arch_default_path="arch"
13arch_defined="FALSE"
14arch_path_defined="FALSE"
[248]15
16# Traitement de la ligne de commande
17while (($# > 0))
18   do
19      case $1 in
[383]20         "-h"|"--help"|"-help")
[374]21            echo "make_xios - installs XIOS on your architecture"
22            echo "make_xios [options]"
23            echo "options :"
[381]24            echo "       [--prod] : compilation in production mode (default)"
[374]25            echo "       [--dev] : compilation in development mode"
26            echo "       [--debug] : compilation in debug mode"
27            echo "       --arch arch : to choose target architecture"
28            echo "       [--avail] : to know available target architectures "
29            echo "       [--full] : to generate dependencies and recompile from scratch"
[475]30            echo "       [--use_oasis 'oasis3' 'oasis3_mct' : default oasis3_mct] : to use Oasis coupler"
[374]31            echo "       [--doc] : to generate Doxygen documentation (not available yet)"
32            echo "       [--job ntasks] : to use parallel compilation with ntasks"
[410]33            echo "       [--netcdf_lib 'netcdf4_par'/'netcdf4_seq'/'netcdf4_internal' : default netcdf4_par] : choice of netcdf library"
[402]34            echo "       [--memtrack] : tracking memory leak - developper only"
[374]35            echo "Example : ./make_xios --prod --arch PW6_VARGAS"
36            echo "Example : ./make_xios --avail"
[248]37            exit;;
38         "--prod")  compil_mode="prod"  ; shift ;;
39         "--dev")   compil_mode="dev"   ; shift ;;
40         "--debug") compil_mode="debug" ; shift ;;
[984]41         "--arch")  arch=$2     ; arch_defined="TRUE"; shift ; shift ;;
42         "--arch_path")  arch_path=$2     ; arch_path_defined="TRUE"; shift ; shift ;;
[383]43         "--avail") ls arch/*.fcm | cut -d"-" -f2 | cut -d"." -f1 ; exit ;;
[313]44         "--full")  compil_full="true"  ; shift ;;
[475]45         "--use_oasis")  use_oasis="true" oasis=$2 ; shift ; shift  ;;
[248]46         "--doc")   doc="true"          ; shift ;;
[313]47         "--job")   job=$2              ; shift ; shift ;;
[381]48         "--netcdf_lib")   netcdf_lib=$2 ; shift ; shift ;;
[402]49         "--memtrack")   use_memtrack="true" ; shift ;;
[248]50         *)         code="$1"           ; shift ;;
51      esac
52   done
53
[374]54# Installation des sources
[377]55nb_files_gz=`ls $install_dir/tools/archive | grep tar.gz | wc -l`
56if [ ${nb_files_gz} -ne 0 ]               
[376]57then
[377]58    echo -e "- uncompress archives ..."         
[376]59    for tarname in `ls $install_dir/tools/archive/*.tar.gz` ; do
60        gunzip -f "$tarname"
61        tar -xf ${tarname%.gz}
62    done
63fi
[374]64
[248]65# Vérification de la présence d'un identifiant d'architecture.
66
[281]67###############################################################
[374]68# lecture des chemins propres a l'architecture de la machine #
[281]69#           et configuration de l'environnement              #
70###############################################################
71
72rm -f .void_file
73echo > .void_file
74rm -rf .void_dir
75mkdir .void_dir
76
[984]77if [[ "$arch_defined" == "TRUE" ]]
78then
79  rm -f arch.path
80  rm -f arch.fcm
81  rm -f arch.env
[281]82
[984]83  if test -f $arch_path/arch-${arch}.path
84  then
85    ln -s $arch_path/arch-${arch}.path arch.path
86  elif test -f $arch_default_path/arch-${arch}.path
87  then
88    ln -s $arch_default_path/arch-${arch}.path arch.path
89  fi
90       
91  if test -f $arch_path/arch-${arch}.fcm
92  then
93    ln -s $arch_path/arch-${arch}.fcm arch.fcm
94  elif test -f $arch_default_path/arch-${arch}.fcm
95  then
96    ln -s $arch_default_path/arch-${arch}.fcm arch.fcm
97  fi
[281]98
[984]99  if test -f $arch_path/arch-${arch}.env
100  then
101    ln -s $arch_path/arch-${arch}.env arch.env
102  elif test -f $arch_default_path/arch-${arch}.env
103  then
104    ln -s $arch_default_path/arch-${arch}.env arch.env
[281]105  else
[984]106    ln -s .void_file arch.env
107  fi
108  source arch.env
109  source arch.path
110else
[381]111      echo "Please choose a target achitecture --> list all available architecture using make_xios --avail!"
[248]112      exit 1
113fi
114
115# Vérification de la présence d'un mode de compilation.
116
117if [[ "$compil_mode" == "prod" ]]
118   then
119      COMPIL_CFLAGS="%PROD_CFLAGS"
120      COMPIL_FFLAGS="%PROD_FFLAGS"
121elif [[ "$compil_mode" == "dev" ]]
122   then
123      COMPIL_CFLAGS="%DEV_CFLAGS"
124      COMPIL_FFLAGS="%DEV_FFLAGS"
125elif [[ "$compil_mode" == "debug" ]]
126   then
127      COMPIL_CFLAGS="%DEBUG_CFLAGS"
128      COMPIL_FFLAGS="%DEBUG_FFLAGS"
129fi
130
[410]131rm -r $PWD/extern/netcdf4
132
[381]133if [[ "$netcdf_lib" == "netcdf4_par" ]]
134   then
[410]135     ln -s $PWD/.void_dir $PWD/extern/netcdf4
[591]136     XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR"
[381]137elif [[ "$netcdf_lib" == "netcdf4_seq" ]]
138  then
[410]139    ln -s $PWD/.void_dir $PWD/extern/netcdf4
140elif [[ "$netcdf_lib" == "netcdf4_internal" ]]
141  then
142    ln -s $PWD/extern/src_netcdf4 $PWD/extern/netcdf4
[591]143    XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR USING_NETCDF_INTERNAL"
[410]144    export NETCDF_INCDIR="-I${PWD}/extern/netcdf4"
145    export NETCDF_LIBDIR=""
146    export NETCDF_LIB=""
[381]147else
[410]148   echo "Bad choice for --netcdf_lib argument : choose between 'netcdf4_par','netcdf4_seq' or 'netcdf4_internal'"
[381]149   exit
150fi
151
[287]152if [[ "$use_oasis" == "true" ]]
153   then
[475]154    if [[ "$oasis" == "oasis3_mct" ]]
155    then
[591]156        XIOS_CPPKEY="$XIOS_CPPKEY USE_OMCT"
[475]157    elif [[ "$oasis" == "oasis3"  ]]
158    then
[591]159        XIOS_CPPKEY="$XIOS_CPPKEY USE_OASIS"
[475]160        OASIS_INCDIR="-I$PWD/../../prism/X64/build/lib/psmile.MPI1"
161        OASIS_LIBDIR="-L$PWD/../../prism/X64/lib"
162        OASIS_LIB="-lpsmile.MPI1 -lmpp_io"
163    else
164        echo "Bad choice for --use_oasis argument : choose between 'oasis3','oasis3_mct'"
165        exit
166    fi
167    NETCDF_LIB="-lnetcdff -lnetcdf"
[591]168    XIOS_FINCDIR="$OASIS_INCDIR $XIOS_FINCDIR"
169    XIOS_LIB="$OASIS_LIBDIR $OASIS_LIB $XIOS_LIB"
[287]170fi
[362]171
[402]172if [[ "$use_memtrack" == "true" ]]
173   then
[591]174   XIOS_LIB="$ADDR2LINE_LIBDIR $ADDR2LINE_LIB $XIOS_LIB"
175   XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK"
[402]176fi
177
[591]178XIOS_CINCDIR="$NETCDF_INCDIR $HDF5_INCDIR $MPI_INCDIR"
[660]179XIOS_FINCDIR="$NETCDF_INCDIR $XIOS_FINCDIR $MPI_INCDIR"
[248]180
[591]181XIOS_LIB="$XIOS_LIB $NETCDF_LIBDIR $HDF5_LIBDIR $MPI_LIBDIR $NETCDF_LIB $HDF5_LIB $MPI_LIB"
[248]182
183rm -f config.fcm
184echo "%COMPIL_CFLAGS $COMPIL_CFLAGS" >> config.fcm
185echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
[591]186echo "%CPP_KEY       $XIOS_CPPKEY"   >> config.fcm
[248]187
[591]188echo "%CBASE_INC     $XIOS_CINCDIR" >> config.fcm     
189echo "%FBASE_INC     $XIOS_FINCDIR" >> config.fcm
190echo "%ARCH_LD       $XIOS_LIB"     >> config.fcm
[248]191
[381]192echo "=> Using "$compil_mode" mode for compiling under architecture \""$arch"\" !"
[248]193
194# Création de la documentation doxygen.
195if [[ !(-z $doc) ]]
196   then
[381]197      echo -e "- Create Doxygen documentation (disabled)..."
[248]198      #doxygen -s
199fi
200
201make_dir=$PWD
202
203export PATH=$PWD/tools/FCM/bin:$PATH
204
[287]205if [[ "$compil_full" == "true" ]]
206   then
[395]207   fcm build --clean --ignore-lock
208   fcm build -f --ignore-lock -j $job
[287]209else
[395]210  fcm build --ignore-lock -j $job
[287]211fi
[248]212
[601]213build_exit_status=$?
[287]214
[601]215if [[ $build_exit_status == 0 ]]
[287]216  then
[366]217  set nothing
[591]218#    cd $WORKDIR/XIOS_NEMO_COUPLE/modeles/NEMO/WORK
219#    cd $WORKDIR/XIOS_NEMO/modeles/NEMO/WORK
[301]220#    make
[287]221fi
[601]222
223exit $build_exit_status
Note: See TracBrowser for help on using the repository browser.