source: trunk/WRF.COMMON/WRFV2/compile @ 3026

Last change on this file since 3026 was 11, checked in by aslmd, 14 years ago

spiga@svn-planeto:ajoute le modele meso-echelle martien

  • Property svn:executable set to *
File size: 8.8 KB
Line 
1#!/bin/csh -f
2
3cont1:
4
5if ( !  -e configure.wrf  ) then
6   ./configure $1
7   set dontask
8endif
9
10
11#----------------------------------
12if ( ! $?WRF_KPP )   setenv WRF_KPP  0
13if ( $WRF_KPP == 1 ) then
14chem/KPP/compile_wkc
15endif
16
17
18
19
20#---------------------------------
21
22if ( ! $?dontask && $?prompt ) then
23  echo "This script assumes you have configured the code already."
24  echo "You only need to configure once."
25  echo "If you wish to reconfigure, type c at the prompt below"
26  echo " "
27  echo "Ready to compile? [ync]"
28  set resp=$<
29
30  if ( "$resp" == "c" ) then
31    ./configure
32    goto cont1
33  endif
34
35  if ( "$resp" == "n" ) then
36    exit 2
37  endif
38endif
39
40set arglist=""
41foreach a ( $argv )
42  if ( "$a" == "-h" ) then
43    goto hlp
44  else
45    if ( "$a" != "-d" ) then
46      set arglist = ( $arglist $a )
47    endif
48  endif
49end
50
51if ( $arglist == "" ) then
52  goto hlp
53else
54  unsetenv A2DCASE
55  setenv A2DCASE `echo $arglist | grep 2d`
56
57  if ( ! (   $?WRF_EM_CORE  || $?WRF_NMM_CORE \
58          ||  $?WRF_COAMPS_CORE || $?WRF_EXP_CORE )) then
59    echo 'None of WRF_EM_CORE, WRF_NMM_CORE, '
60#    echo '        WRF_COAMPS_CORE, or WRF_EXP_CORE '
61    echo '        specified in shell environment.... '
62    setenv WRF_EM_CORE 1
63    setenv WRF_NMM_CORE 0
64    setenv WRF_COAMPS_CORE 0
65    setenv WRF_EXP_CORE 0
66  endif
67
68# these settings get passed down through the environment in the
69# calls to Make
70  if ( ! $?WRF_EM_CORE )     setenv WRF_EM_CORE 0
71  if ( ! $?WRF_NMM_CORE )    setenv WRF_NMM_CORE 0
72  if ( ! $?WRF_NMM_NEST )    setenv WRF_NMM_NEST 0
73  if ( ! $?WRF_COAMPS_CORE ) setenv WRF_COAMPS_CORE 0
74  if ( ! $?WRF_EXP_CORE )    setenv WRF_EXP_CORE 0
75  if ( ! $?WRF_CHEM )        setenv WRF_CHEM 0
76  if ( ! $?WRF_CONVERT ) then
77     if ( "$arglist" == "convert_em" ) then
78       setenv WRF_CONVERT 1
79       setenv WRF_EM_CORE 0
80     else
81       setenv WRF_CONVERT 0
82     endif
83  endif
84
85  set overwrite=0
86  if ($WRF_NMM_CORE == 1 && $WRF_CHEM == 1 ) then
87    echo "Chemistry not yet supported in NMM core, set WRF_CHEM to 0 "
88    grep -q DM_PARALLEL configure.wrf
89    if ( $status == 1 ) then
90      echo NMM_CORE must be configured for DM parallel
91      echo Please rerun the configure script and chose a DM parallel option
92      exit 3
93    endif
94    if ( ! -f Registry/Registry ) then
95      echo Registry file does not exist
96      set overwrite=1
97    else
98      head -2 Registry/Registry | tail -1 | grep NMM_CHEM > /dev/null
99      if ( $status ) then
100        set overwrite=1
101      else
102        set nmm_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.NMM_CHEM' | grep -v 'Registry.NMM_CHEM.' | awk '{print $1}'`
103        set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
104        if ( $nmm_time > $rg_time ) set overwrite=1
105      endif
106    endif
107    if ( $overwrite ) then
108      echo copying Registry/Registry.NMM_CHEM to Registry/Registry
109      echo '## WARNING: this file is autogenerated from Registry/Registry.NMM_CHEM. Changes may be lost' > Registry/Registry
110      /bin/cat Registry/Registry.NMM_CHEM >> Registry/Registry
111    endif
112#   exit 2
113  endif
114
115
116  if ($WRF_EM_CORE == 1 && $WRF_NMM_CORE == 1 ) then
117    echo "Cannot compile both EM and NMM cores in same executable yet."
118    exit 2
119  endif
120  if ($WRF_EM_CORE == 0 && $WRF_NMM_CORE == 0 && ! $WRF_CONVERT == 1 ) then
121    echo "Cannot compile because both EM and NMM cores are set to 0."
122    exit 2
123  endif
124  if (($WRF_EM_CORE == 1)&&($WRF_CHEM == 0 )&&($WRF_CONVERT == 0))  then
125    if ( ! -f Registry/Registry ) then
126      set overwrite=1
127    else
128      head -2 Registry/Registry | tail -1 | grep EM > /dev/null
129      if ( $status ) then
130        set overwrite=1
131      else
132        set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM' | grep -v 'Registry.EM.' | awk '{print $1}'`
133        set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
134        if ( $em_time > $rg_time ) set overwrite=1
135      endif
136    endif
137    if ( $overwrite ) then
138      echo copying Registry/Registry.EM to Registry/Registry
139      echo '## WARNING: this file is autogenerated from Registry/Registry.EM. Changes may be lost' > Registry/Registry
140      /bin/cat Registry/Registry.EM >> Registry/Registry
141    endif
142  else if (($WRF_EM_CORE == 1)&&($WRF_CHEM == 1 ))  then
143    if ( ! -f Registry/Registry ) then
144      set overwrite=1
145    else
146      head -2 Registry/Registry | tail -1 | grep EM_CHEM > /dev/null
147      if ( $status ) then
148        set overwrite=1
149      else
150        set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CHEM' | grep -v 'Registry.EM_CHEM.' | awk '{print $1}'`
151        set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
152        if ( $em_time > $rg_time ) set overwrite=1
153      endif
154    endif
155    if ( $overwrite ) then
156      echo copying Registry/Registry.EM_CHEM to Registry/Registry
157      echo '## WARNING: this file is autogenerated from Registry/Registry.EM_CHEM. Changes may be lost' > Registry/Registry
158      /bin/cat Registry/Registry.EM_CHEM >> Registry/Registry
159    endif
160  else if (($WRF_EM_CORE == 0)&&($WRF_CONVERT == 1 ))  then
161    if ( ! -f Registry/Registry ) then
162      set overwrite=1
163    else
164      head -2 Registry/Registry | tail -1 | grep EM_CONVERT > /dev/null
165      if ( $status ) then
166        set overwrite=1
167      else
168        set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CONVERT' | grep -v 'Registry.EM_CONVERT.' | awk '{print $1}'`
169        set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
170        if ( $em_time > $rg_time ) set overwrite=1
171      endif
172    endif
173    if ( $overwrite ) then
174      echo copying Registry/Registry.CONVERT to Registry/Registry
175      echo '## WARNING: this file is autogenerated from Registry/Registry.CONVERT. Changes may be lost' > Registry/Registry
176      /bin/cat Registry/Registry.CONVERT >> Registry/Registry
177    endif
178
179
180  endif
181  if (($WRF_NMM_CORE == 1)&&($WRF_CHEM == 0 )) then
182    grep -q DM_PARALLEL configure.wrf
183    if ( $status == 1 ) then
184      echo NMM_CORE must be configured for DM parallel
185      echo Please rerun the configure script and chose a DM parallel option
186      exit 3
187    endif
188    if ( ! -f Registry/Registry ) then
189      set overwrite=1
190    else
191      head -2 Registry/Registry | tail -1 | grep NMM > /dev/null
192      if ( $status ) then
193        set overwrite=1
194      else
195        set nmm_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.NMM' | grep -v 'Registry.NMM.' | awk '{print $1}'`
196        set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
197        if ( $nmm_time > $rg_time ) set overwrite=1
198      endif
199    endif
200    if ( $overwrite ) then
201      if (($WRF_NMM_CORE == 1)&&($WRF_NMM_NEST == 1)) then
202        echo copying Registry/Registry.NMM_NEST to Registry/Registry
203        echo '## WARNING: this file is autogenerated from Registry/Registry.NMM_NEST. Changes may be lost' > Registry/Registry
204        /bin/cat Registry/Registry.NMM_NEST >> Registry/Registry
205      else
206        echo copying Registry/Registry.NMM to Registry/Registry
207        echo '## WARNING: this file is autogenerated from Registry/Registry.NMM. Changes may be lost' > Registry/Registry
208        /bin/cat Registry/Registry.NMM >> Registry/Registry
209      endif
210    endif
211# integrity check for a kludge where a hard coded value in the
212# registry must match the same value in arch/preamble
213    set registryvalue=`grep 'dimspec.* q ' Registry/Registry.NMM | sed -e 's/..*constant=//' -e 's/ ..*$//'`
214    set preamblevalue=`grep 'DNMM_MAX_DIM=.*' arch/preamble | sed -e 's/..*-DNMM_MAX_DIM=//' -e 's/ ..*$//'`
215    if ( $registryvalue != $preamblevalue ) then
216      echo "Harded coded value of dimspec q in Registry ($registryvalue) does not"
217      echo "equal the hard coded value of NMM_MAX_DIM in arch/preamble ($preamblevalue)"
218      echo "Please fix and try again."
219      exit 2
220    endif
221  endif
222
223  echo " "
224  echo -n "**** Compiling: "
225  if ( $WRF_EM_CORE ) echo -n "WRF_EM_CORE "
226  if ( $WRF_NMM_CORE ) echo -n "WRF_NMM_CORE "
227  if ( $WRF_COAMPS_CORE ) echo -n "WRF_COAMPS_CORE "
228  if ( $WRF_EXP_CORE ) echo -n "WRF_EXP_CORE "
229  echo "."
230  echo " "
231
232  # This incredible hackery due to OSF1 $(PWD) not changing during
233  # build via regtest.csh ... 
234  # Note that $WRF_SRC_ROOT_DIR is only used by the OSF1 build. 
235  if ( $?WRF_SRC_ROOT_DIR ) then
236    make $arglist A2DCASE="$A2DCASE" WRF_SRC_ROOT_DIR="$WRF_SRC_ROOT_DIR"
237  else
238    make $arglist A2DCASE="$A2DCASE" WRF_SRC_ROOT_DIR="$PWD"
239  endif
240
241endif
242
243exit 0
244
245hlp:
246
247echo ' '
248echo 'Usage:'
249echo ' '
250echo '   compile wrf           compile wrf in run dir (NOTE: no real.exe, ndown.exe, or ideal.exe generated)'
251echo ' '
252echo '   or choose a test case (see README_test_cases for details) :'
253foreach d ( `/bin/ls test` )
254  if ( "$d" != "CVS" ) then
255    echo "      compile $d"
256  endif
257end
258echo ' '
259echo '  compile -h                 help message'
260
261
Note: See TracBrowser for help on using the repository browser.