1 | #!/bin/bash |
---|
2 | export ROOT=$PWD |
---|
3 | export PATH=$ROOT/tools/FCM_V1.2/bin:${PATH} |
---|
4 | |
---|
5 | compil_mode="prod" |
---|
6 | |
---|
7 | job=1 |
---|
8 | full_defined="FALSE" |
---|
9 | arch_defined="FALSE" |
---|
10 | arch_path="arch" |
---|
11 | arch_default_path="arch" |
---|
12 | arch_path_defined="FALSE" |
---|
13 | CPP_KEY="CPP_NONE" |
---|
14 | |
---|
15 | while (($# > 0)) ; do |
---|
16 | case $1 in |
---|
17 | "-h") cat <<end_help |
---|
18 | ######################################################################## |
---|
19 | # Usage of the script makeioipsl_fcm |
---|
20 | # |
---|
21 | # makeioipsl_fcm compiles IOIPSL using the Fcm software developed |
---|
22 | # by the Hadley Centre. Fcm is stored in tools directory. |
---|
23 | # Platform specific compile options are found in the arch directory. |
---|
24 | ######################################################################## |
---|
25 | |
---|
26 | Usage: |
---|
27 | |
---|
28 | ./makeioipsl_fcm -arch XXX [Options] |
---|
29 | |
---|
30 | |
---|
31 | Mandatory argument: |
---|
32 | |
---|
33 | -arch XXX : name of the archicture file containg platform dependent compile options. |
---|
34 | The files arch/arch-XXX.fcm and arch/arch-XXX.path must exist. If the |
---|
35 | file arch/arch-XXX.env exist, it'll be sourced before compilation starts. |
---|
36 | |
---|
37 | Main options: |
---|
38 | [-h] : show this help |
---|
39 | [ -full ] : activate full recompiling |
---|
40 | [ -arch_path XXX ] : directory of the archicture file containg platform dependent compile options. |
---|
41 | Default is ./arch directory. If the files are not found in the folder given by arch_path, |
---|
42 | the default ./arch folder will be used. |
---|
43 | |
---|
44 | Options for optimization, choose only one of the following |
---|
45 | [ -prod ] : compilation for production (all optimization) |
---|
46 | [ -dev ] : compilation for development (low optimization and -g) |
---|
47 | [ -debug ] : compilation for debugging (no optmization and all debug options) |
---|
48 | |
---|
49 | [ -job x ] : activate parallel compiling on x task, default is 1 task |
---|
50 | |
---|
51 | |
---|
52 | end_help |
---|
53 | exit;; |
---|
54 | "-prod") compil_mode="prod" ; shift ;; |
---|
55 | "-dev") compil_mode="dev" ; shift ;; |
---|
56 | "-debug") compil_mode="debug" ; shift ;; |
---|
57 | "-arch") arch=$2 ; arch_defined="TRUE"; shift ; shift ;; |
---|
58 | "-arch_path") arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
59 | "-job") job=$2 ; shift ; shift;; |
---|
60 | "-full") full_defined="TRUE" ; shift ;; |
---|
61 | *) |
---|
62 | code="$1" ; shift ;; |
---|
63 | esac |
---|
64 | done |
---|
65 | |
---|
66 | # Create module defprec.90 using def.prec |
---|
67 | # Double precision is used (default mode) |
---|
68 | ./ins_m_prec |
---|
69 | |
---|
70 | # Define arch files |
---|
71 | rm -f .void_file |
---|
72 | echo > .void_file |
---|
73 | rm -rf .void_dir |
---|
74 | mkdir .void_dir |
---|
75 | |
---|
76 | if [[ "$arch_defined" == "TRUE" ]] ; then |
---|
77 | rm -f arch.path |
---|
78 | rm -f arch.fcm |
---|
79 | rm -f arch.env |
---|
80 | |
---|
81 | if [ -f $arch_path/arch-${arch}.path ] ; then |
---|
82 | ln -s $arch_path/arch-${arch}.path arch.path |
---|
83 | elif [ -f $arch_default_path/arch-${arch}.path ] ; then |
---|
84 | ln -s $arch_default_path/arch-${arch}.path arch.path |
---|
85 | else |
---|
86 | echo No arch.path is found. Exit now. |
---|
87 | exit 1 |
---|
88 | fi |
---|
89 | |
---|
90 | if [ -f $arch_path/arch-${arch}.fcm ] ; then |
---|
91 | ln -s $arch_path/arch-${arch}.fcm arch.fcm |
---|
92 | elif [ -f $arch_default_path/arch-${arch}.fcm ] ; then |
---|
93 | ln -s $arch_default_path/arch-${arch}.fcm arch.fcm |
---|
94 | fi |
---|
95 | |
---|
96 | if [ -f $arch_path/arch-${arch}.env ] ; then |
---|
97 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
98 | elif [ -f $arch_default_path/arch-${arch}.env ] ; then |
---|
99 | ln -s $arch_default_path/arch-${arch}.env arch.env |
---|
100 | else |
---|
101 | ln -s .void_file arch.env |
---|
102 | fi |
---|
103 | source arch.env |
---|
104 | source arch.path |
---|
105 | else |
---|
106 | echo "You must define the architecture files using makeioipsl_fcm -arch XXX" |
---|
107 | echo "Show help using: ./makeioipsl_fcm -h" |
---|
108 | exit 1 |
---|
109 | fi |
---|
110 | LD_FLAGS="%BASE_LD" |
---|
111 | |
---|
112 | if [[ "$compil_mode" == "prod" ]] ; then |
---|
113 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
114 | elif [[ "$compil_mode" == "dev" ]] ; then |
---|
115 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
116 | elif [[ "$compil_mode" == "debug" ]] ; then |
---|
117 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
118 | fi |
---|
119 | |
---|
120 | |
---|
121 | IOIPSL_LIB="$NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB" |
---|
122 | |
---|
123 | rm -f config.fcm |
---|
124 | |
---|
125 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm |
---|
126 | echo "%LD_FLAGS $LD_FLAGS" >> config.fcm |
---|
127 | echo "%CPP_KEY $CPP_KEY" >> config.fcm |
---|
128 | echo "%LIB $IOIPSL_LIB">> config.fcm |
---|
129 | |
---|
130 | if [[ "$full_defined" == "TRUE" ]] ; then |
---|
131 | ./build.sh --job $job --full |
---|
132 | else |
---|
133 | ./build.sh --job $job |
---|
134 | fi |
---|
135 | err=$? |
---|
136 | |
---|
137 | # Check error message from fcm build |
---|
138 | if [ $err != 0 ] ; then |
---|
139 | # Error found |
---|
140 | echo makeioipsl_fcm: Error in compiling IOIPSL : $err |
---|
141 | exit 1 |
---|
142 | fi |
---|
143 | |
---|
144 | ## Link folders created during compilation to the base directory |
---|
145 | rm -rf bin lib inc |
---|
146 | ln -s build/lib lib |
---|
147 | ln -s build/inc inc |
---|
148 | mkdir bin ; ln -s ../build/bin/rebuild bin/rebuild ; ln -s ../build/bin/flio_rbld.exe bin/flio_rbld |
---|