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.
Changeset 212 for trunk/UTIL – NEMO

Changeset 212 for trunk/UTIL


Ignore:
Timestamp:
2005-03-10T15:29:16+01:00 (19 years ago)
Author:
opalod
Message:

RB :UPDATE148: change fait_config to :

  • create automatically the links when adding a new configuration
  • create the config/NAME directory if needed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/fait_config

    r210 r212  
    11#!/bin/ksh 
    2  
    32###################################################### 
    43# Author : Rachid benshila for ESOPA 
     
    1110###################################################### 
    1211 
     12################################### 
     13#                                 # 
     14# Beginning of user modifications # 
     15#                                 # 
     16################################### 
    1317#- Config name --- 
    14 # Add in LIST the name of a new configuration  
     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 
    1530LIST="NEMO_ORCA2_LIM \nGYRE" 
     31set -A DIR_NEMO_ORCA2_LIM OCE_SRC ICE_SRC 
     32set -A DIR_GYRE OCE_SRC ICE_SRC 
     33 
     34################################### 
     35#                                 # 
     36#    End of user modifications    # 
     37#                                 # 
     38################################### 
     39 
    1640 
    1741#- Some tests --- 
     
    1943 
    2044if   [ ${#} -gt 1 ]; then 
    21   echo 'Only one configuration can be specified in:' 1>&2; 
    22   echo $LIST 1>&2; 
    23   exit 3; 
     45    echo 'Only one configuration can be specified in:' 1>&2; 
     46    echo $LIST 1>&2; 
     47    exit 3; 
    2448elif [ ${#} -eq 1 ]; then 
    25    m_n="${1}" 
     49     m_n="${1}" 
    2650elif [ ${#} -eq 0 ]; then 
    27   echo 'You must specify one configuration in :' 1>&2; 
    28   echo $LIST 1>&2; 
    29   echo 'You can also complete fait_config to add a new one' 
    30   exit 3; 
     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; 
    3155fi 
    3256 
    33 #- Create the WORK 
     57#- Create the WORK -- 
    3458d_m=`find ${d_n}/.. -name OPA`  ; 
    3559[ -d ${d_m}/WORK ] || mkdir ${d_m}/WORK; 
    3660cd ${d_m}/WORK 
     61 
     62#- Clean links and librairies 
    3763[ -f Makefile ] && gmake clean  
    3864[ -n "`\ls`" ] && \rm *  
    3965 
    40 #- Create the good links 
    41 # Add your configuration in the case loop below 
    42 # 1 .Name 
    43 # 2. Directories needed 
    44 # 3. Links you want to create 
    45 # Example to add a GYRE_TRC config 
    46 # Guess the is a directory modipsl/config/GYRE_TRC/scripts 
    47 # with a BB_make inside 
    48 # Insert : 
    49 # ( GYRE_TRC ) 
    50 #         echo " Creating OPA/WORK = OCE_SRC + ICE_SRC + TRC_SRC for GYRE_TRC" 
    51 #         DIR="OCE_SRC ICE_SRC TRC_SRC" 
    52 #         ln -sf ../OCE_SRC/*.[Ffh]90          .  
    53 #         ln -sf ../OCE_SRC/DYN/*.[Ffh]90      .  
    54 #         ln -sf ../OCE_SRC/TRA/*.[Ffh]90      .  
    55 #         ln -sf ../OCE_SRC/TRD/*.[Ffh]90      .  
    56 #         ln -sf ../OCE_SRC/DIA/*.[Ffh]90      .  
    57 #         ln -sf ../OCE_SRC/DOM/*.[Ffh]90      .  
    58 #         ln -sf ../OCE_SRC/OBC/*.[Ffh]90      .  
    59 #         ln -sf ../OCE_SRC/FLO/*.[Ffh]90      .  
    60 #         ln -sf ../OCE_SRC/LDF/*.[Ffh]90      .  
    61 #         ln -sf ../OCE_SRC/ZDF/*.[Ffh]90      .  
    62 #         ln -sf ../OCE_SRC/SOL/*.[Ffh]90      .  
    63 #         ln -sf ../OCE_SRC/DTA/*.[Ffh]90      .  
    64 #         ln -sf ../OCE_SRC/SBC/*.[Ffh]90      . 
    65 #         ln -sf ../ICE_SRC/*.[Ffh]90          .   
    66 #         \$(RM) *.passivetrc.h                  
    67 #         \$(RM) trcstp.F90                     
    68 #         \$(RM) trc_oce.F90                     
    69 #         ln -sf ../TRC_SRC/*.[Ffh]            .  
    70 #         ln -sf ../TRC_SRC/*.[Ffh]90          .  
    71 #         ln -sf ../TRC_SRC/SMS/*.[Ffh]        .  
    72 #         ln -sf ../TRC_SRC/SMS/*.[Ffh]90      .   
    73 #         ln -sf ../TRC_SRC/TRP/*.[Ffh]90      . ;;  
     66#- Find the number of directories --- 
     67eval NDIR=\${#DIR_${m_n}[*]} 
    7468 
     69#- Build a working array TAB containing the directories --- 
     70i=0 
     71while [ i -lt $NDIR ] 
     72do 
     73    eval  TAB[i]=\${DIR_${m_n}[i]} 
     74    let i=i+1 
     75done 
    7576 
    76 case ${m_n} in 
     77#- Creating the good links, at first on OCE_TRC --- 
     78if [ ${#TAB[*]} -ne 0 ] ; then 
     79    echo " Creating OPA/WORK = ${TAB[*]} for ${m_n}" 
    7780 
    78 ( NEMO_ORCA2_LIM ) 
    79          echo " Creating OPA/WORK = OCE_SRC + ICE_SRC for NEMO_ORCA2_LIM" 
    80          DIR="OCE_SRC ICE_SRC" 
    81          ln -sf ../OCE_SRC/*.[Ffh]90          .  
    82          ln -sf ../OCE_SRC/DYN/*.[Ffh]90      .  
    83          ln -sf ../OCE_SRC/TRA/*.[Ffh]90      .  
    84          ln -sf ../OCE_SRC/TRD/*.[Ffh]90      .  
    85          ln -sf ../OCE_SRC/DIA/*.[Ffh]90      .  
    86          ln -sf ../OCE_SRC/DOM/*.[Ffh]90      .  
    87          ln -sf ../OCE_SRC/OBC/*.[Ffh]90      .  
    88          ln -sf ../OCE_SRC/FLO/*.[Ffh]90      .  
    89          ln -sf ../OCE_SRC/LDF/*.[Ffh]90      .  
    90          ln -sf ../OCE_SRC/ZDF/*.[Ffh]90      .  
    91          ln -sf ../OCE_SRC/SOL/*.[Ffh]90      .  
    92          ln -sf ../OCE_SRC/DTA/*.[Ffh]90      .  
    93          ln -sf ../OCE_SRC/SBC/*.[Ffh]90      . 
    94          ln -sf ../ICE_SRC/*.[Ffh]90          .  ;; 
    95 ( GYRE )           
    96          echo " Creating OPA/WORK = OCE_SRC + ICE_SRC for GYRE" 
    97          DIR="OCE_SRC ICE_SRC" 
    98          ln -sf ../OCE_SRC/*.[Ffh]90          .  
    99          ln -sf ../OCE_SRC/DYN/*.[Ffh]90      .  
    100          ln -sf ../OCE_SRC/TRA/*.[Ffh]90      .  
    101          ln -sf ../OCE_SRC/TRD/*.[Ffh]90      .  
    102          ln -sf ../OCE_SRC/DIA/*.[Ffh]90      .  
    103          ln -sf ../OCE_SRC/DOM/*.[Ffh]90      .  
    104          ln -sf ../OCE_SRC/OBC/*.[Ffh]90      .  
    105          ln -sf ../OCE_SRC/FLO/*.[Ffh]90      .  
    106          ln -sf ../OCE_SRC/LDF/*.[Ffh]90      .  
    107          ln -sf ../OCE_SRC/ZDF/*.[Ffh]90      .  
    108          ln -sf ../OCE_SRC/SOL/*.[Ffh]90      .  
    109          ln -sf ../OCE_SRC/DTA/*.[Ffh]90      .  
    110          ln -sf ../OCE_SRC/SBC/*.[Ffh]90      . 
    111          ln -sf ../ICE_SRC/*.[Ffh]90          .  ;; 
    112 (*) 
    113          echo "Configuration "${m_n}" not supported" 1>&2; 
    114          echo 'Make your choice in :' 1>&2; 
    115          echo $LIST 1>&2; 
    116          echo 'You can also complete fait_config to add a new one' 
    117             exit 1;; 
    118 esac 
     81    i=0 
     82    while [ i -lt $NDIR ] 
     83    do 
     84   [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OCE_SRC" ] && ln -sf ../${TAB[i]}/*.[Ffh]90 . 
     85   [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OCE_SRC" ] && ln -sf ../${TAB[i]}/*/*.[Ffh]90 . && break 
     86   let i=$i+1 
     87    done 
     88 
     89    i=0 
     90    while [ i -lt $NDIR ] 
     91    do 
     92   [ "${TAB[i]}" = "TRC_SRC" ] &&  \rm trcstp.F90                     
     93   [ "${TAB[i]}" = "TRC_SRC" ] &&  \rm sms.F90                     
     94   [  ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" != "OCE_SRC" ] && ln -sf ../${TAB[i]}/*.[Ffh]90 . 
     95   [  ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" != "OCE_SRC" ] && [ "${TAB[i]}" != "ICE_SRC" ] && ln -sf ../${TAB[i]}/*/*.[Ffh]90 .   
     96   let i=$i+1 
     97    done 
     98 
     99    [ ! -d ../../../config/${m_n} ] && \cp -R ../../../config/NEMO_ORCA2_LIM ../../../config/${m_n}  
    119100    ln -sf ../../../*/${m_n}/scripts/BB_make AA_make ;  
    120101    ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ; 
    121102 
    122 # Building the standard list of source files 
    123      cat >.patron <<"EOF"  
     103else 
     104 
     105    echo "Configuration "${m_n}" not supported" 1>&2 
     106    echo 'Make your choice in :' 1>&2 
     107    echo $LIST 1>&2 
     108    echo 'You can also complete fait_config to add a new one' 
     109    exit 1 
     110 
     111fi  
     112 
     113#- Building the standard list of source files --- 
     114cat >.patron <<"EOF"  
    124115CVS 
    125116SRC_PARAM 
     
    140131thersf.f 
    141132EOF 
    142      ls -1 | fgrep -v -f .patron  >SRC_FILE_LIST ; cp SRC_FILE_LIST SRC_FILE_LIST.temp ; 
    143 # 
    144      KEY=$(grep P_P AA_make.ldef); 
    145      [ -f "KEY_CPP" ] || echo $KEY > KEY_CPP; 
    146    
    147    echo ${m_n} ${DIR} >.config  
     133ls -1 | fgrep -v -f .patron  >SRC_FILE_LIST ; cp SRC_FILE_LIST SRC_FILE_LIST.temp ; 
     134 
     135#- Writing KEY_CPP file --- 
     136sed -e "s/#-Q- sxnec *//" -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > KEY_CPP;     
     137 
     138#- Save new configuration an d directories names --- 
     139print ${m_n} ${TAB[*]} >.config  
    148140 
    149141exit 0; 
Note: See TracChangeset for help on using the changeset viewer.