source: codes/icosagcm/trunk/make_icosa @ 279

Last change on this file since 279 was 279, checked in by dubos, 10 years ago

Let make_icosa write a ./rebuild script

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#!/bin/bash
2set -x
3export PATH=$PWD/tools/FCM/bin:$PATH
4
5echo ./make_icosa $* > rebuild
6chmod a+x rebuild
7
8compil_mode_defined="FALSE"
9compil_mode="prod"
10
11job=1
12full_defined="FALSE"
13with_xios_defined="FALSE"
14arch_defined="FALSE"
15parallel_defined="FALSE"
16arch=""
17parallel="none"
18CPP_KEY="CPP_NONE" 
19ICOSA_LIB=""
20
21while (($# > 0))
22  do
23  case $1 in
24      "-h") cat <<fin
25Usage :
26makegcm [options] -m arch exec
27[-h]                       : help
28[-prod / -dev / -debug]    : compilation en mode production (default) / developpement / debug .
29 -arch nom_arch            : nom de l\'architecture cible
30fin
31          exit;;
32
33      "-prod")
34          compil_mode="prod" ; shift ;;
35
36      "-dev")
37          compil_mode="dev" ; shift ;;
38
39      "-debug")
40          compil_mode="debug" ; shift ;;
41
42      "-arch")
43          arch=$2 ; arch_defined="TRUE"; shift ; shift ;;
44
45      "-parallel")
46          parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;;
47
48      "-job")
49          job=$2 ; shift ; shift;;
50
51      "-full")
52          full_defined="TRUE" ; shift ;;
53
54      "-with_xios")
55          with_xios_defined="TRUE" ; shift ;;
56
57      *)
58          code="$1" ; shift ;;
59  esac
60done
61
62rm -f .void_file
63echo > .void_file
64rm -rf .void_dir
65mkdir .void_dir
66
67if [[ "$arch_defined" == "TRUE" ]]
68then
69  rm -f arch.path
70  rm -f arch.fcm
71  rm -f arch.env
72  ln -s arch/arch-${arch}.path ./arch.path
73  ln -s arch/arch-${arch}.fcm  ./arch.fcm
74  if test -f arch/arch-${arch}.env
75    then
76      ln -s arch/arch-${arch}.env arch.env
77    else
78      ln -s .void_file arch.env
79    fi
80  source arch.env
81  source arch.path
82else
83  echo "Veuillez definir une architecture cible"
84  exit 1
85fi
86
87LD_FLAGS="%BASE_LD"
88
89if [[ "$compil_mode" == "prod" ]]
90then
91  COMPIL_FFLAGS="%PROD_FFLAGS"
92elif [[ "$compil_mode" == "dev" ]]
93then
94  COMPIL_FFLAGS="%DEV_FFLAGS"
95elif [[ "$compil_mode" == "debug" ]]
96then
97  COMPIL_FFLAGS="%DEBUG_FFLAGS"
98fi
99
100if [[ "$parallel" == "mpi" ]]
101then
102  CPP_KEY="$CPP_KEY CPP_USING_MPI"
103elif [[ "$parallel" == "omp" ]]
104then
105  CPP_KEY="$CPP_KEY CPP_USING_OMP"
106  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
107  LD_FLAGS="$LD_FLAGS %OMP_LD"
108elif [[ "$parallel" == "mpi_omp" ]]
109then
110  CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP"
111  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
112  LD_FLAGS="$LD_FLAGS %OMP_LD"
113elif [[ "$parallel" == "none" ]]
114then
115  parallel="none"
116else
117  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
118  exit 1
119fi
120
121if [[ "$with_xios_defined" == "TRUE" ]]
122then
123  CPP_KEY="$CPP_KEY CPP_USING_XIOS"
124  COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR"
125  ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB"
126fi 
127
128ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
129
130rm -f config.fcm
131
132echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm
133echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
134echo "%CPP_KEY $CPP_KEY" >> config.fcm
135echo "%LIB $ICOSA_LIB">> config.fcm
136
137if [[ "$full_defined" == "TRUE" ]]
138then
139  ./build --job $job --full
140else
141  ./build --job $job
142fi
Note: See TracBrowser for help on using the repository browser.