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 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 | |
---|
35 | LIST="ORCA2_LIM \nGYRE" |
---|
36 | set -A DIR_ORCA2_LIM OPA_SRC LIM_SRC C1D_SRC NST_SRC |
---|
37 | set -A DIR_GYRE OPA_SRC LIM_SRC C1D_SRC |
---|
38 | |
---|
39 | ################################### |
---|
40 | # # |
---|
41 | # End of user modifications # |
---|
42 | # # |
---|
43 | ################################### |
---|
44 | |
---|
45 | |
---|
46 | #- Some tests --- |
---|
47 | d_n=$(dirname $0); b_n=$(basename $0); |
---|
48 | |
---|
49 | if [ ${#} -gt 1 ]; then |
---|
50 | echo 'Only one configuration can be specified in:' 1>&2; |
---|
51 | echo $LIST 1>&2; |
---|
52 | exit 3; |
---|
53 | elif [ ${#} -eq 1 ]; then |
---|
54 | m_n="${1}" |
---|
55 | elif [ ${#} -eq 0 ]; then |
---|
56 | echo 'You must specify one configuration in :' 1>&2; |
---|
57 | echo $LIST 1>&2; |
---|
58 | echo 'You can also complete fait_config to add a new one' |
---|
59 | exit 3; |
---|
60 | fi |
---|
61 | |
---|
62 | #- Create the WORK -- |
---|
63 | d_m=`find ${d_n}/.. -name NEMO` ; |
---|
64 | [ -d ${d_m}/WORK ] || mkdir ${d_m}/WORK; |
---|
65 | cd ${d_m}/WORK |
---|
66 | |
---|
67 | #- Clean links and librairies |
---|
68 | [ -f Makefile ] && gmake clean |
---|
69 | [ -n "`\ls`" ] && \rm -rf * |
---|
70 | |
---|
71 | #- Find the number of directories --- |
---|
72 | eval NDIR=\${#DIR_${m_n}[*]} |
---|
73 | |
---|
74 | #- Build a working array TAB containing the directories --- |
---|
75 | i=0 |
---|
76 | while [ i -lt $NDIR ] |
---|
77 | do |
---|
78 | eval TAB[i]=\${DIR_${m_n}[i]} |
---|
79 | let i=i+1 |
---|
80 | done |
---|
81 | |
---|
82 | #- Creating the good links, at first on OPA_SRC --- |
---|
83 | if [ ${#TAB[*]} -ne 0 ] ; then |
---|
84 | echo " Creating NEMO/WORK = ${TAB[*]} for ${m_n}" |
---|
85 | |
---|
86 | i=0 |
---|
87 | while [ i -lt $NDIR ] |
---|
88 | do |
---|
89 | [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../OPA_SRC/*.[Ffh]90 . |
---|
90 | [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../OPA_SRC/*/*.[Ffh]90 . && break |
---|
91 | let i=$i+1 |
---|
92 | done |
---|
93 | |
---|
94 | i=0 |
---|
95 | while [ i -lt $NDIR ] |
---|
96 | do |
---|
97 | if [ "${TAB[i]}" = "LIM_SRC" ]; then |
---|
98 | ln -sf ../LIM_SRC/*.[Ffh]90 . |
---|
99 | |
---|
100 | elif [ "${TAB[i]}" = "C1D_SRC" ]; then |
---|
101 | ln -sf ../C1D_SRC/*.[Ffh]90 . |
---|
102 | |
---|
103 | elif [ "${TAB[i]}" = "TOP_SRC" ]; then |
---|
104 | [ -f trcstp.F90 ] && \rm trcstp.F90 |
---|
105 | [ -f sms.F90 ] && \rm sms.F90 |
---|
106 | [ -f initrc.F90 ] && \rm initrc.F90 |
---|
107 | ln -sf ../TOP_SRC/*.[Ffh]90 . |
---|
108 | ln -sf ../TOP_SRC/SMS/*.[Ffh] . |
---|
109 | ln -sf ../TOP_SRC/SMS/*.[Ffh]90 . |
---|
110 | ln -sf ../TOP_SRC/TRP/*.[Ffh]90 . |
---|
111 | |
---|
112 | elif [ "${TAB[i]}" = "NST_SRC" ]; then |
---|
113 | [ -f agrif_opa_interp.F90 ] && \rm agrif_opa_interp.F90 |
---|
114 | [ -f agrif_opa_sponge.F90 ] && \rm agrif_opa_sponge.F90 |
---|
115 | [ -f agrif_opa_update.F90 ] && \rm agrif_opa_update.F90 |
---|
116 | ln -sf ../NST_SRC/*.[Ffh]90 . |
---|
117 | |
---|
118 | elif [ "${TAB[i]}" = "OFF_SRC" ]; then |
---|
119 | ln -sf ../OFF_SRC/*.[Ffh]90 . |
---|
120 | ln -sf ../OFF_SRC/*/*.[Ffh]90 . |
---|
121 | fi |
---|
122 | let i=$i+1 |
---|
123 | done |
---|
124 | |
---|
125 | [ ! -d ../../../config/${m_n} ] && \cp -R ../../../config/ORCA2_LIM ../../../config/${m_n} |
---|
126 | ln -sf ../../../*/${m_n}/scripts/BB_make AA_make ; |
---|
127 | ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ; |
---|
128 | |
---|
129 | else |
---|
130 | |
---|
131 | echo "Configuration "${m_n}" not supported" 1>&2 |
---|
132 | echo 'Make your choice in :' 1>&2 |
---|
133 | echo $LIST 1>&2 |
---|
134 | echo 'You can also complete fait_config to add a new one' |
---|
135 | exit 1 |
---|
136 | |
---|
137 | fi |
---|
138 | |
---|
139 | #- Building the standard list of source files --- |
---|
140 | cat >.patron <<"EOF" |
---|
141 | CVS |
---|
142 | SRC_PARAM |
---|
143 | SRC_FILE_LIST |
---|
144 | tmplist |
---|
145 | AA_make |
---|
146 | KEY_CPP |
---|
147 | Makefile |
---|
148 | *?.o |
---|
149 | i.?* |
---|
150 | *?.L |
---|
151 | .patron |
---|
152 | bloc.com |
---|
153 | para.com |
---|
154 | defcst.f |
---|
155 | fontbc.f |
---|
156 | icdyna.f |
---|
157 | thersf.f |
---|
158 | OPAFILES |
---|
159 | EOF |
---|
160 | ls -1 | fgrep -v -f .patron >SRC_FILE_LIST ; cp SRC_FILE_LIST SRC_FILE_LIST.temp ; |
---|
161 | |
---|
162 | #- Writing KEY_CPP file --- |
---|
163 | sed -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > KEY_CPP; |
---|
164 | |
---|
165 | #- Save new configuration an d directories names --- |
---|
166 | print ${m_n} ${TAB[*]} >.config |
---|
167 | |
---|
168 | exit 0; |
---|