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.
Fcheck_archfile.sh in trunk/NEMOGCM/TOOLS/COMPILE – NEMO

source: trunk/NEMOGCM/TOOLS/COMPILE/Fcheck_archfile.sh @ 3922

Last change on this file since 3922 was 3922, checked in by smasson, 11 years ago

trunk:compilation enhancements, see ticket #1117

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1#!/bin/bash
2#set -x
3set -o posix
4#set -u
5#set -e
6#+
7#
8# ==================
9# Fcheck_archfile.sh
10# ==================
11#
12# --------------------------
13# Check the compilation file
14# --------------------------
15#
16# SYNOPSIS
17# ========
18#
19# ::
20#
21#  $ Fcheck_archfile.sh
22#
23#
24# DESCRIPTION
25# ===========
26#
27#
28# Check the choice of the compiler.
29# Three cases : 
30#
31# - There was a previous choice
32# - A new one has be specified, we use this one
33# - No information, exit
34#
35# We use TOOLS/COMPILE/arch.fcm to see if something was chosen.
36#
37# EXAMPLES
38# ========
39#
40# ::
41#
42#  $ ./Fcheck_archfile.sh ARCHFILE COMPILER
43#
44#
45# TODO
46# ====
47#
48# option debug
49#
50#
51# EVOLUTIONS
52# ==========
53#
54# $Id$
55#
56#
57#
58#   * creation
59#
60#-
61cpeval () 
62{
63    cat > $2 << EOF
64
65#==========================================================
66#    Automatically generated by Fcheck_archfile.sh from
67#    $1
68#==========================================================
69
70EOF
71    while read line 
72    do 
73   eval "echo \"$line\" >> $2"
74    done < $1
75}
76# cleaning related to the old version
77myarch=$( find ${MAIN_DIR}/ARCH -type l -name arch-${3}.fcm -print )
78[ ${#myarch} -ne 0 ] && rm -f $myarch
79#
80if [ ${#3} -eq 0 ]; then # arch not specified
81    if [ ! -f ${COMPIL_DIR}/arch.history ]; then
82   echo "Warning !!!"
83   echo "NO compiler chosen"
84   echo "Try makenemo -h for help"
85   echo "EXITING..."
86   exit 1
87    else # use the arch file defined in arch.history
88   myarch=$( cat ${COMPIL_DIR}/arch.history )   
89   if [ ! -f $myarch ]; then
90       echo "Warning !!!"
91       echo "previously used arch file no more found:"
92       echo $myarch
93       echo "EXITING..."
94       exit 1
95   else
96       if [ -f ${COMPIL_DIR}/$1 ]; then
97      myarchdir=$( dirname ${myarch} )
98      myarchname=$( basename ${myarch} )
99      # have the cpp keys been updated since we copy the arch file in ${COMPIL_DIR}?
100      mycpp=$( find -L ${COMPIL_DIR} -cnewer ${COMPIL_DIR}/$1 -name $2 -print )
101      [ ${#mycpp} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
102      # has myarch been updated since we copy it in ${COMPIL_DIR}?
103      myarch=$( find -L $myarchdir -cnewer ${COMPIL_DIR}/$1 -name $myarchname -print )
104      [ ${#myarch} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
105       else
106      cpeval ${myarch} ${COMPIL_DIR}/$1
107       fi
108   fi
109    fi
110else
111    myarch=$( find ${MAIN_DIR}/ARCH -name arch-${3}.fcm -print )
112    if [ ${#myarch} -gt 0 ]; then # the arch file specified by the use exists
113   # we were already using this arch file
114   if [ "$myarch" == "$( cat ${COMPIL_DIR}/arch.history )" ]; then
115       if [ -f ${COMPIL_DIR}/$1 ]; then
116         # have the cpp keys been updated since we copy the arch file in ${COMPIL_DIR}?
117      mycpp=$( find -L ${COMPIL_DIR} -cnewer ${COMPIL_DIR}/$1 -name $2 -print )
118      [ ${#mycpp} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
119      # has myarch been updated since we copy it in ${COMPIL_DIR}?
120      myarch=$( find -L ${MAIN_DIR}/ARCH -cnewer ${COMPIL_DIR}/$1 -name arch-${3}.fcm -print )
121      [ ${#myarch} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
122       else
123      cpeval ${myarch} ${COMPIL_DIR}/$1
124       fi
125   else
126       echo ${myarch} > ${COMPIL_DIR}/arch.history
127       cpeval ${myarch} ${COMPIL_DIR}/$1
128   fi
129    else
130   echo "Warning !!!"
131   echo "Compiler not existing"
132   echo "Try makenemo -h for help"
133   echo "EXITING..."
134   exit 1       
135    fi   
136fi
137
138#- do we need xios library?
139use_iom=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$2 | grep -c key_iomput )
140have_lxios=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$1 | grep -c "\-lxios" )
141if [[ ( $use_iom -eq 0 ) && ( $have_lxios -ge 1 ) ]]
142then
143    sed -e "s/-lxios//g" ${COMPIL_DIR}/$1 > ${COMPIL_DIR}/tmp$$
144    mv -f ${COMPIL_DIR}/tmp$$ ${COMPIL_DIR}/$1
145fi
146
147#- do we need oasis libraries?
148use_oasis=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$2 | grep -c key_oasis3 )
149for liboa in psmile.MPI1 mct mpeu scrip mpp_io
150do
151    have_liboa=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$1 | grep -c "\-l${liboa}" )
152    if [[ ( $use_oasis -eq 0 ) && ( $have_liboa -ge 1 ) ]]
153    then
154   sed -e "s/-l${liboa}//g" ${COMPIL_DIR}/$1 > ${COMPIL_DIR}/tmp$$
155   mv -f ${COMPIL_DIR}/tmp$$ ${COMPIL_DIR}/$1
156    fi
157done
158
Note: See TracBrowser for help on using the repository browser.