source: IOIPSL/trunk/makeioipsl_fcm

Last change on this file was 5010, checked in by aclsce, 20 months ago
  • IOIPSL : modified to be coherent in the name of flio_rbld used in rebuild and created within fcm.


  • Property svn:executable set to *
File size: 4.3 KB
Line 
1#!/bin/bash
2export ROOT=$PWD
3export PATH=$ROOT/tools/FCM_V1.2/bin:${PATH}
4
5compil_mode="prod"
6
7job=1
8full_defined="FALSE"
9arch_defined="FALSE"
10arch_path="arch"
11arch_default_path="arch"
12arch_path_defined="FALSE"
13CPP_KEY="CPP_NONE" 
14
15while (($# > 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
26Usage:
27
28./makeioipsl_fcm -arch XXX [Options]
29
30
31Mandatory 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
37Main 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
44Options 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
52end_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
64done
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
71rm -f .void_file
72echo > .void_file
73rm -rf .void_dir
74mkdir .void_dir
75
76if [[ "$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
105else
106  echo "You must define the architecture files using makeioipsl_fcm -arch XXX"
107  echo "Show help using: ./makeioipsl_fcm -h"
108  exit 1
109fi
110LD_FLAGS="%BASE_LD"
111
112if [[ "$compil_mode" == "prod" ]] ; then
113  COMPIL_FFLAGS="%PROD_FFLAGS"
114elif [[ "$compil_mode" == "dev" ]] ; then
115  COMPIL_FFLAGS="%DEV_FFLAGS"
116elif [[ "$compil_mode" == "debug" ]] ; then
117  COMPIL_FFLAGS="%DEBUG_FFLAGS"
118fi
119
120
121IOIPSL_LIB="$NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
122
123rm -f config.fcm
124
125echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm
126echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
127echo "%CPP_KEY $CPP_KEY" >> config.fcm
128echo "%LIB $IOIPSL_LIB">> config.fcm
129
130if [[ "$full_defined" == "TRUE" ]] ; then
131  ./build.sh --job $job --full
132else
133  ./build.sh --job $job
134fi
135err=$?
136
137# Check error message from fcm build
138if [ $err != 0 ] ; then
139  # Error found
140  echo makeioipsl_fcm: Error in compiling IOIPSL : $err 
141  exit 1
142fi
143
144## Link folders created during compilation to the base directory
145rm -rf bin lib inc
146ln -s build/lib lib
147ln -s build/inc inc
148mkdir bin ; ln -s ../build/bin/rebuild bin/rebuild ; ln -s ../build/bin/flio_rbld.exe bin/flio_rbld
Note: See TracBrowser for help on using the repository browser.