[210] | 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 | # and to link in the WORK the BB_make and BB_make.ldef |
---|
| 8 | # associated to a chosen configuration |
---|
| 9 | # |
---|
| 10 | ###################################################### |
---|
| 11 | |
---|
[212] | 12 | ################################### |
---|
| 13 | # # |
---|
| 14 | # Beginning of user modifications # |
---|
| 15 | # # |
---|
| 16 | ################################### |
---|
[210] | 17 | #- Config name --- |
---|
[212] | 18 | # To add a new configuration called NAME you have to change this script |
---|
| 19 | # 1. Add your configuration in LIST |
---|
| 20 | # 2. Add the directories needed for this config : set -A DIR_NAME DIR1 DIR2 ... |
---|
| 21 | # 3. Run fait_config NAME |
---|
| 22 | # If there is no directory config/NAME/scripts, and in this no BB_make.ldef, |
---|
| 23 | # the config/NEMO_ORCA2_LIM directory is copied under NAME |
---|
| 24 | # |
---|
| 25 | # Example : in order to create a GYRE_TRC configuration : |
---|
| 26 | # 1. In this script, change LIST to LIST="NEMO_ORCA2_LIM \nGYRE \nGYRE_TRC" |
---|
| 27 | # 2. In this script, add set -A DIR_GYRE_TRC OCE_SRC ICE_SRC TRC_SRC, take care of the syntax |
---|
| 28 | # 3. Run fait_config GYRE_TRC |
---|
| 29 | |
---|
[210] | 30 | LIST="NEMO_ORCA2_LIM \nGYRE" |
---|
[212] | 31 | set -A DIR_NEMO_ORCA2_LIM OCE_SRC ICE_SRC |
---|
| 32 | set -A DIR_GYRE OCE_SRC ICE_SRC |
---|
[210] | 33 | |
---|
[212] | 34 | ################################### |
---|
| 35 | # # |
---|
| 36 | # End of user modifications # |
---|
| 37 | # # |
---|
| 38 | ################################### |
---|
| 39 | |
---|
| 40 | |
---|
[210] | 41 | #- Some tests --- |
---|
| 42 | d_n=$(dirname $0); b_n=$(basename $0); |
---|
| 43 | |
---|
| 44 | if [ ${#} -gt 1 ]; then |
---|
[212] | 45 | echo 'Only one configuration can be specified in:' 1>&2; |
---|
| 46 | echo $LIST 1>&2; |
---|
| 47 | exit 3; |
---|
[210] | 48 | elif [ ${#} -eq 1 ]; then |
---|
[212] | 49 | m_n="${1}" |
---|
[210] | 50 | elif [ ${#} -eq 0 ]; then |
---|
[212] | 51 | echo 'You must specify one configuration in :' 1>&2; |
---|
| 52 | echo $LIST 1>&2; |
---|
| 53 | echo 'You can also complete fait_config to add a new one' |
---|
| 54 | exit 3; |
---|
[210] | 55 | fi |
---|
| 56 | |
---|
[212] | 57 | #- Create the WORK -- |
---|
[210] | 58 | d_m=`find ${d_n}/.. -name OPA` ; |
---|
| 59 | [ -d ${d_m}/WORK ] || mkdir ${d_m}/WORK; |
---|
| 60 | cd ${d_m}/WORK |
---|
[212] | 61 | |
---|
| 62 | #- Clean links and librairies |
---|
[210] | 63 | [ -f Makefile ] && gmake clean |
---|
| 64 | [ -n "`\ls`" ] && \rm * |
---|
| 65 | |
---|
[212] | 66 | #- Find the number of directories --- |
---|
| 67 | eval NDIR=\${#DIR_${m_n}[*]} |
---|
[210] | 68 | |
---|
[212] | 69 | #- Build a working array TAB containing the directories --- |
---|
| 70 | i=0 |
---|
| 71 | while [ i -lt $NDIR ] |
---|
| 72 | do |
---|
| 73 | eval TAB[i]=\${DIR_${m_n}[i]} |
---|
| 74 | let i=i+1 |
---|
| 75 | done |
---|
[210] | 76 | |
---|
[212] | 77 | #- Creating the good links, at first on OCE_TRC --- |
---|
| 78 | if [ ${#TAB[*]} -ne 0 ] ; then |
---|
| 79 | echo " Creating OPA/WORK = ${TAB[*]} for ${m_n}" |
---|
[210] | 80 | |
---|
[212] | 81 | i=0 |
---|
| 82 | while [ i -lt $NDIR ] |
---|
| 83 | do |
---|
[214] | 84 | [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OCE_SRC" ] && ln -sf ../OCE_SRC/*.[Ffh]90 . |
---|
| 85 | [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OCE_SRC" ] && ln -sf ../OCE_SRC/*/*.[Ffh]90 . && break |
---|
[212] | 86 | let i=$i+1 |
---|
| 87 | done |
---|
| 88 | |
---|
| 89 | i=0 |
---|
| 90 | while [ i -lt $NDIR ] |
---|
| 91 | do |
---|
[214] | 92 | if [ "${TAB[i]}" = "ICE_SRC" ]; then |
---|
| 93 | ln -sf ../ICE_SRC/*.[Ffh]90 . |
---|
| 94 | |
---|
| 95 | elif [ "${TAB[i]}" = "TRC_SRC" ]; then |
---|
| 96 | \rm trcstp.F90 |
---|
| 97 | \rm sms.F90 |
---|
| 98 | ln -sf ../TRC_SRC/*.[Ffh] . |
---|
| 99 | ln -sf ../TRC_SRC/*.[Ffh]90 . |
---|
| 100 | ln -sf ../TRC_SRC/SMS/*.[Ffh] . |
---|
| 101 | ln -sf ../TRC_SRC/SMS/*.[Ffh]90 . |
---|
| 102 | ln -sf ../TRC_SRC/TRP/*.[Ffh]90 . |
---|
| 103 | |
---|
| 104 | elif [ "${TAB[i]}" = "SRC_OFFLINE_TRC" ]; then |
---|
| 105 | ln -sf ../TRC_SRC/*.[Ffh] . |
---|
| 106 | ln -sf ../TRC_SRC/SMS/*.[Ffh] . |
---|
| 107 | ln -sf ../SRC_OFFLINE_TRC/*.[Ffh] . |
---|
| 108 | fi |
---|
| 109 | let i=$i+1 |
---|
[212] | 110 | done |
---|
| 111 | |
---|
| 112 | [ ! -d ../../../config/${m_n} ] && \cp -R ../../../config/NEMO_ORCA2_LIM ../../../config/${m_n} |
---|
[210] | 113 | ln -sf ../../../*/${m_n}/scripts/BB_make AA_make ; |
---|
| 114 | ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ; |
---|
| 115 | |
---|
[212] | 116 | else |
---|
| 117 | |
---|
| 118 | echo "Configuration "${m_n}" not supported" 1>&2 |
---|
| 119 | echo 'Make your choice in :' 1>&2 |
---|
| 120 | echo $LIST 1>&2 |
---|
| 121 | echo 'You can also complete fait_config to add a new one' |
---|
| 122 | exit 1 |
---|
| 123 | |
---|
| 124 | fi |
---|
| 125 | |
---|
| 126 | #- Building the standard list of source files --- |
---|
| 127 | cat >.patron <<"EOF" |
---|
[210] | 128 | CVS |
---|
| 129 | SRC_PARAM |
---|
| 130 | SRC_FILE_LIST |
---|
| 131 | tmplist |
---|
| 132 | AA_make |
---|
| 133 | KEY_CPP |
---|
| 134 | Makefile |
---|
| 135 | *?.o |
---|
| 136 | i.?* |
---|
| 137 | *?.L |
---|
| 138 | .patron |
---|
| 139 | bloc.com |
---|
| 140 | para.com |
---|
| 141 | defcst.f |
---|
| 142 | fontbc.f |
---|
| 143 | icdyna.f |
---|
| 144 | thersf.f |
---|
| 145 | EOF |
---|
[212] | 146 | ls -1 | fgrep -v -f .patron >SRC_FILE_LIST ; cp SRC_FILE_LIST SRC_FILE_LIST.temp ; |
---|
[210] | 147 | |
---|
[212] | 148 | #- Writing KEY_CPP file --- |
---|
| 149 | sed -e "s/#-Q- sxnec *//" -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > KEY_CPP; |
---|
| 150 | |
---|
| 151 | #- Save new configuration an d directories names --- |
---|
| 152 | print ${m_n} ${TAB[*]} >.config |
---|
| 153 | |
---|
[210] | 154 | exit 0; |
---|