source: trunk/UTIL/fait_config @ 1612

Last change on this file since 1612 was 1612, checked in by ctlod, 12 years ago

update scripts following the ticket #522, see ticket: #522

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