New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
fait_config in trunk/UTIL – NEMO

source: trunk/UTIL/fait_config @ 1271

Last change on this file since 1271 was 1159, checked in by rblod, 16 years ago

Update BB_*, see ticket #208

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