1 | #!/bin/ksh |
---|
2 | ###################################################### |
---|
3 | # Author : Rachid benshila for ESOPA |
---|
4 | # Contact : opatlod@lodyc.jussieu.fr |
---|
5 | # |
---|
6 | # This script aims to create the OPA/WORK directory |
---|
7 | # with links to target directories for the sources |
---|
8 | # and to link in the WORK the BB_make and BB_make.ldef |
---|
9 | # associated to a chosen configuration |
---|
10 | # |
---|
11 | ###################################################### |
---|
12 | |
---|
13 | ################################### |
---|
14 | # # |
---|
15 | # Beginning of user modifications # |
---|
16 | # # |
---|
17 | ################################### |
---|
18 | #- Config name --- |
---|
19 | # To add a new configuration called NAME you have to change this script |
---|
20 | # 1. Add your configuration in LIST |
---|
21 | # 2. Add the directories needed for this config : set -A DIR_NAME DIR1 DIR2 ... |
---|
22 | # 3. Run fait_config NAME |
---|
23 | # If there is no directory config/NAME/scripts, and in this no BB_make.ldef, |
---|
24 | # the config/ORCA2_LIM directory is copied under NAME |
---|
25 | # |
---|
26 | # Example 1 : in order to create a GYRE_TRC configuration : |
---|
27 | # 1. In this script, change LIST to LIST="ORCA2_LIM \nGYRE \nGYRE_TRC" |
---|
28 | # 2. In this script, add set -A DIR_GYRE_TRC OPA_SRC LIM_SRC_3 TOP_SRC C1D_SRC, take care of the syntax |
---|
29 | # 3. Run fait_config GYRE_TRC |
---|
30 | # Example 2 : in order to create an OFFLINE_TRC configuration : |
---|
31 | # 1. In this script, change LIST to LIST="ORCA2_LIM \nGYRE \nOFFLINE_TRC" |
---|
32 | # 2. In this script, add set -A DIR_OFFLINE_TRC OFF_SRC TOP_SRC, take care of the syntax |
---|
33 | # 3. Run fait_config OFFLINE_TRC |
---|
34 | # Example 2 : in order to use LIM3, just change LIM_SRC_2 in LIM_SRC_3 |
---|
35 | |
---|
36 | LIST="ORCA2_LIM \nGYRE \nGYRE_LOBSTER \nORCA2_LIM_PISCES \nORCA2_OFF_PISCES \nPOMME \nIPSLCM5 \nIPSLCM5_LOOP" |
---|
37 | set -A DIR_ORCA2_LIM OPA_SRC LIM_SRC_2 C1D_SRC NST_SRC |
---|
38 | set -A DIR_GYRE OPA_SRC LIM_SRC_2 C1D_SRC |
---|
39 | set -A DIR_GYRE_LOBSTER OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC |
---|
40 | set -A DIR_ORCA2_LIM_PISCES OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC NST_SRC |
---|
41 | set -A DIR_ORCA2_OFF_PISCES OFF_SRC TOP_SRC |
---|
42 | set -A DIR_POMME OPA_SRC LIM_SRC_2 C1D_SRC |
---|
43 | set -A DIR_IPSLCM5 OPA_SRC LIM_SRC_2 C1D_SRC |
---|
44 | set -A DIR_IPSLCM5_LOOP OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC |
---|
45 | set -A DIR_IPSL_ESM_v2 OPA_SRC LIM_SRC_2 C1D_SRC |
---|
46 | |
---|
47 | ################################### |
---|
48 | # # |
---|
49 | # End of user modifications # |
---|
50 | # # |
---|
51 | ################################### |
---|
52 | |
---|
53 | |
---|
54 | #- Some tests --- |
---|
55 | d_n=$(dirname $0); b_n=$(basename $0); |
---|
56 | |
---|
57 | if [ ${#} -gt 1 ]; then |
---|
58 | echo 'Only one configuration can be specified in:' 1>&2; |
---|
59 | echo $LIST 1>&2; |
---|
60 | exit 3; |
---|
61 | elif [ ${#} -eq 1 ]; then |
---|
62 | m_n="${1}" |
---|
63 | elif [ ${#} -eq 0 ]; then |
---|
64 | echo 'You must specify one configuration in :' 1>&2; |
---|
65 | echo $LIST 1>&2; |
---|
66 | echo 'You can also complete fait_config to add a new one' |
---|
67 | exit 3; |
---|
68 | fi |
---|
69 | |
---|
70 | #- Create the WORK -- |
---|
71 | d_m=`find ${d_n}/.. -name NEMO` ; |
---|
72 | [ -d ${d_m}/WORK ] || mkdir ${d_m}/WORK; |
---|
73 | cd ${d_m}/WORK |
---|
74 | |
---|
75 | #- Clean links and librairies |
---|
76 | [ -f Makefile ] && gmake clean |
---|
77 | [ -n "`\ls`" ] && \rm -rf * |
---|
78 | |
---|
79 | #- Find the number of directories --- |
---|
80 | eval NDIR=\${#DIR_${m_n}[*]} |
---|
81 | |
---|
82 | #- Build a working array TAB containing the directories --- |
---|
83 | i=0 |
---|
84 | while [ i -lt $NDIR ] |
---|
85 | do |
---|
86 | eval TAB[i]=\${DIR_${m_n}[i]} |
---|
87 | let i=i+1 |
---|
88 | done |
---|
89 | |
---|
90 | #- Creating the good links, at first on OPA_SRC --- |
---|
91 | if [ ${#TAB[*]} -ne 0 ] ; then |
---|
92 | echo " Creating NEMO/WORK = ${TAB[*]} for ${m_n}" |
---|
93 | |
---|
94 | i=0 |
---|
95 | while [ i -lt $NDIR ] |
---|
96 | do |
---|
97 | [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../OPA_SRC/*.[Ffh]90 . |
---|
98 | [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../OPA_SRC/*/*.[Ffh]90 . && break |
---|
99 | let i=$i+1 |
---|
100 | done |
---|
101 | |
---|
102 | i=0 |
---|
103 | while [ i -lt $NDIR ] |
---|
104 | do |
---|
105 | if [ "${TAB[i]}" = "LIM_SRC_3" ]; then |
---|
106 | ln -sf ../LIM_SRC_3/*.[Ffh]90 . |
---|
107 | |
---|
108 | elif [ "${TAB[i]}" = "LIM_SRC_2" ]; then |
---|
109 | ln -sf ../LIM_SRC_2/*.[Ffh]90 . |
---|
110 | |
---|
111 | elif [ "${TAB[i]}" = "C1D_SRC" ]; then |
---|
112 | ln -sf ../C1D_SRC/*.[Ffh]90 . |
---|
113 | |
---|
114 | elif [ "${TAB[i]}" = "TOP_SRC" ]; then |
---|
115 | ln -sf ../TOP_SRC/*.[Ffh]90 . |
---|
116 | ln -sf ../TOP_SRC/*/*.[Ffh]90 . |
---|
117 | |
---|
118 | elif [ "${TAB[i]}" = "NST_SRC" ]; then |
---|
119 | [ -f agrif_opa_interp.F90 ] && \rm agrif_opa_interp.F90 |
---|
120 | [ -f agrif_opa_sponge.F90 ] && \rm agrif_opa_sponge.F90 |
---|
121 | [ -f agrif_opa_update.F90 ] && \rm agrif_opa_update.F90 |
---|
122 | [ -f agrif_top_interp.F90 ] && \rm agrif_top_interp.F90 |
---|
123 | [ -f agrif_top_sponge.F90 ] && \rm agrif_top_sponge.F90 |
---|
124 | [ -f agrif_top_update.F90 ] && \rm agrif_top_update.F90 |
---|
125 | ln -sf ../NST_SRC/*.[Ffh]90 . |
---|
126 | |
---|
127 | elif [ "${TAB[i]}" = "OFF_SRC" ]; then |
---|
128 | ln -sf ../OFF_SRC/*.[Ffh]90 . |
---|
129 | ln -sf ../OFF_SRC/*/*.[Ffh]90 . |
---|
130 | fi |
---|
131 | let i=$i+1 |
---|
132 | done |
---|
133 | |
---|
134 | [ ! -d ../../../config/${m_n} ] && \cp -R ../../../config/ORCA2_LIM ../../../config/${m_n} |
---|
135 | ln -sf ../../../*/${m_n}/scripts/BB_make AA_make ; |
---|
136 | ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ; |
---|
137 | |
---|
138 | else |
---|
139 | |
---|
140 | echo "Configuration "${m_n}" not supported" 1>&2 |
---|
141 | echo 'Make your choice in :' 1>&2 |
---|
142 | echo $LIST 1>&2 |
---|
143 | echo 'You can also complete fait_config to add a new one' |
---|
144 | exit 1 |
---|
145 | |
---|
146 | fi |
---|
147 | |
---|
148 | #- Building the standard list of source files --- |
---|
149 | cat >.patron <<"EOF" |
---|
150 | CVS |
---|
151 | SRC_PARAM |
---|
152 | SRC_FILE_LIST |
---|
153 | tmplist |
---|
154 | AA_make |
---|
155 | KEY_CPP |
---|
156 | Makefile |
---|
157 | *?.o |
---|
158 | i.?* |
---|
159 | *?.L |
---|
160 | .patron |
---|
161 | OPAFILES |
---|
162 | EOF |
---|
163 | ls -1 | fgrep -v -f .patron >SRC_FILE_LIST ; cp SRC_FILE_LIST SRC_FILE_LIST.temp ; |
---|
164 | |
---|
165 | #- Writing KEY_CPP file --- |
---|
166 | sed -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > KEY_CPP; |
---|
167 | |
---|
168 | #- Save new configuration an d directories names --- |
---|
169 | print ${m_n} ${TAB[*]} >.config |
---|
170 | |
---|
171 | exit 0; |
---|