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