source: dynamico_lmdz/aquaplanet/IOIPSL/makeioipsl_fcm @ 4140

Last change on this file since 4140 was 4138, checked in by jgipsl, 6 years ago

Add error handling in compilation

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