source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1852

Last change on this file since 1852 was 1846, checked in by mlefevre, 8 years ago

MESOSCALE. -C option causes problem on some environment, got rid of in the makefiles and in configure.wrf (via makemeso)

  • Property svn:executable set to *
File size: 38.2 KB
Line 
1#! /bin/bash
2
3
4##################################
5# makemeso allows you to compile #
6# WRF with modified LMD physics  #
7##################################
8
9##############################
10# Author: A. Spiga           #
11# New version : October 2008 #
12# Last update : January 2009 #
13#               November  09 #
14#               January   11 #
15##############################
16
17###############################
18#### Type makemeso -h for help
19###############################
20
21
22
23##############################################################################################
24##############################################################################################
25##############################################################################################
26##############################################################################################
27
28donotcompile=0
29donotallow=0
30config='real'
31donotcompilephys=0
32justphys=0
33debug=0
34fresh_start=0
35phys="mars_lmd"
36scenario=""
37from_scratch=0
38
39while getopts "drc:njhgp:fs:xe" options; do
40  case $options in
41   d ) donotcompile=1;;       ## just to check the compile folder
42   r ) donotallow=1;;         ## allow only known config (useful with 'makemeso < last')
43   c ) config="${OPTARG}";;   ## idealized cases
44   n ) donotcompilephys=1;;   ## do not recompile physics
45   j ) justphys=1;;           ## just compile LMD physics
46   g ) debug=1;;              ## debug mode
47   p ) phys="${OPTARG}";;     ## choose physics
48   f ) fresh_start=1;;        ## a fresh start
49   e ) from_scratch=1;;       ## a fresh start with a completely new folder
50   s ) scenario="${OPTARG}";; ## a specific scenario (with precompiling flags)
51   x ) donotcompile=1;phys="void_lmd_new";donotcompilephys=1;; ## a case with no LMD physics included
52   h ) echo "
53# Use:   
54#
55# makemeso                   ## basic use (real-case configuration)
56#
57# makemeso -d                ## no compilation, just check the name of the compile folder
58#
59# makemeso -c ideal          ## idealized mode (convective cell, mountain wave, etc...)
60# makemeso -c les            ## large-eddy simulations mode based on WRFV3
61#
62# makemeso -n                ## do not recompile LMD physics (must have been compiled before)
63#
64# makemeso < last            ## basic use + skip questions [! script must have been executed at least once]
65# makemeso -r < last         ## basic use + skip questions + only known config
66# makemeso -nr < last        ## basic use + skip questions + only known config + no LMD phys recompile
67#
68# makemeso -j                ## just compile the LMD physics
69#
70# makemeso -g                ## debug mode
71#
72# makemeso -h                ## display options
73#
74# makemeso -p mars_lmd_new   ## choose physics
75#             venus_lmd_new
76#
77# makemeso -f                ## fresh start [clean -a]
78#
79# makemeso -e                ## a completely new recompile with erasing the WHOLE compiling folder
80#
81# makemeso -s DUSTSTORM      ## a specific scenario (with precompiling flags)
82#
83# makemeso -x                ## a case with no LMD physics included
84" ; exit ;;
85  esac
86done   
87
88#--------------
89# talk w/ user
90#--------------
91  echo '****************************************'
92  echo ' LMD Mesoscale Model Compiler. Welcome.'
93  echo '****************************************'
94  if [[ "${phys}" == *"new"* ]]
95  then
96    echo '*********** PHYSICS: ' ${phys}
97    echo '****************************************'
98  fi
99  # computer
100  uname -a | grep x86_64 > /dev/null
101  if [[ "$?" == 0 ]]
102  then
103    machine='64'
104  else
105    machine='32'
106  fi
107  # compiler
108  echo "Supported compiler options are "
109  echo "       <1> pgf90"
110  echo "       <2> g95"
111  echo "       <3> pgf90 + mpi"
112  echo "       <4> ifort"
113  echo "       <5> ifort + mpi"
114  echo "       <7> xlf + mpi (IBM AIX)"
115  echo "Your choice ?" ; read reply
116  case ${reply} in
117    1) compilo='pgf' ; numproc=1 ;;
118    2) compilo='g95' ; numproc=1 ;;
119    3) compilo='mpi'
120       if [[ "${WHERE_MPI}" = "" ]]
121       then
122         echo Please initialize the variable WHERE_MPI in your environnement
123         exit
124       fi ;;
125    4) compilo='ifort' ; numproc=1 ;;
126    5) compilo='mpifort' ;;
127    7) compilo='mpixlf' ;;
128    ### for tests
129   99) compilo='gnu' ; numproc=1 ;;
130    *) echo not supported by this script ; exit ;;
131  esac
132  # number of processors
133  if [[ "${phys}" == *"new"* ]]
134  then
135   numproc=999
136  else
137   case ${reply} in
138    3) echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
139    5) echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
140    7) echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
141   esac
142  fi
143
144  # dimensions
145  if [ ${donotcompile} -eq 0 ]
146  then   
147  # ngrid: now dynamically set in newphys 03/2014
148   if [[ "${phys}" == *"new"* ]]
149   then
150      lon=999
151      lat=999
152      level=999
153   else
154      echo Grid points in longitude ? ; read lon
155      echo Grid points in latitude ? ; read lat
156      echo Number of vertical levels ? ; read level
157   fi
158  fi
159  echo Number of domains ? ; read dom
160
161###PB lecture dom si < last
162
163    case ${dom} in
164       1) single='_single' ;;
165       *) single='_nest' ;;
166    esac
167      if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
168      then
169           single=''
170      fi
171
172testflag=''
173####
174#testflag='_test'
175####
176
177    conf_wrf="${phys}_${config}${scenario}_${compilo}_${machine}${single}${testflag}"
178
179    if [ ${debug} -eq 1 ]
180    then
181     conf_wrf="debug_${conf_wrf}"
182    fi
183
184    \rm what_folder 2> /dev/null
185    echo ${conf_wrf} > what_folder
186         if [ ${donotcompile} -eq 0 ]
187         then
188            ##\rm what_folder 2> /dev/null
189            ##echo '**********************'
190            ##echo '*** Your folder is ...'
191            ##echo '**********************'
192            ##echo ${conf_wrf} | tee what_folder
193            ##cat what_folder
194            ##echo ${conf_wrf} > what_folder
195            ##echo ${reply} > what_compilo
196            ##echo ${numproc} > what_numproc
197            #if [[ "${phys}" != "nophys_" ]]
198            #then
199            #  exit
200            #fi
201         #else
202            # tracers: now dynamically set in newphys 09/2013
203            if [[ "${phys}" == *"new"* ]]
204            then
205              tra=999
206            else
207              echo Number of tracers ? ; read tra
208              if [ ${tra} -eq 0 ]
209              then
210                tra=1   
211              fi
212            fi
213         fi
214  # 'from scratch' case
215  if [ ${from_scratch} -eq 1 ]
216  then
217      echo "***** I ERASE THE FOLDER "${conf_wrf}
218      \rm -rf ${conf_wrf}
219  fi
220  # folder
221
222  mkdir ${conf_wrf} 2> /dev/null
223  if [[ "$?" == 0 ]]
224  then
225    echo new folder ... link sources
226    ###############################################
227     echo ${phys}
228     ./SRC/SCRIPTS/copy_model -p ${phys} -c ${config}
229     mv zeWRFV2 ${conf_wrf}/WRFV2
230    ###############################################
231     if [[ "${phys}" == *"new"* ]]
232     then
233      cd ${conf_wrf}/WRFV2
234        if [[ "${config}" != "les" ]]
235        then
236           cp ../../SRC/WRFV2/Registry/Registry.EM.newphys Registry/Registry.EM
237        else
238           cp -L ../../SRC/LES/WRFV2/Registry/Registry.EM.newphys Registry/Registry.EM
239        fi
240      cd phys
241      ln -sf module_lmd_driver.F.new module_lmd_driver.F
242      cd ..
243
244     else
245      cd ${conf_wrf}/WRFV2
246      cd Registry ; ./Registry.bash ; cd ..
247     fi
248          #### sparadrap consequent a l'utilisation de copy_model pour les liens
249          #### -- car alors il manque fftpack
250          if [[ "${config}" == "les" ]]
251          then
252            cp ../../SRC/LES/correcfft ./
253            ./correcfft
254            \rm correcfft
255          fi
256  else
257    cd ${conf_wrf}/WRFV2
258    if [ ${fresh_start} -eq 1 ]
259    then
260      echo '*** FRESH START, I clean everything'
261      ### clean the whole place 
262      clean -a > /dev/null 2> /dev/null
263      ### get a possibly modified registry !
264      if [[ "${phys}" == *"new"* ]]
265      then
266          cp ../../SRC/WRFV2/Registry/Registry.EM.newphys Registry/Registry.EM
267      else
268          cp ../../SRC/WRFV2/Registry/Registry.EM Registry/
269      fi
270      if [[ "${config}" == "les" ]]
271      then
272        cp ../../SRC/LES/WRFV2/Registry/Registry.EM Registry/
273      fi
274      ### ensure the model will be recompiled from scratch with correct registry
275      cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd ..
276#     answer='y' ## a voir... pas si sur
277#    else
278#            if [[ "${phys}" != "nophys_" ]]
279#            then
280#      echo Did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer
281#      case ${answer} in
282#        y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;;
283#        *) answer='no' ;;
284#      esac
285#            fi
286    fi
287  fi
288
289  # summary
290  echo '**********************'
291  echo '*** Your folder is ...'
292  echo '**********************'
293  echo ${conf_wrf}
294  echo '**********************'
295  echo '****************************************'
296  echo so ...
297  echo your computer is ${machine} bits
298  echo ${compilo} is your compiler
299       if [[ "${compilo}" = "mpi" ]]
300       then
301         echo MPICH is in ${WHERE_MPI}
302       fi
303  echo you have ${dom} domains
304  if [[ "${phys}" == *"new"* ]]
305  then
306   echo number of processors can be changed without recompiling
307   echo x points can be changed without recompiling
308   echo y points can be changed without recompiling
309   echo z points can be changed without recompiling
310   echo number of tracers can be changed without recompiling
311  else
312   echo you will use ${numproc} processors
313   echo you have ${lon} x points
314   echo '         '${lat} y points
315   echo '         '${level} z points
316   echo '         '${tra} tracers
317  fi
318  echo '****************************************'
319  # save answer
320  \rm last 2> /dev/null
321  touch last
322  echo ${reply} >> last
323  if [[ "${phys}" != *"new"* ]]
324  then
325    if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
326    then
327     echo ${numproc} >> last
328    fi
329    echo ${lon} >> last
330    echo ${lat} >> last
331    echo ${level} >> last
332  fi
333  echo ${dom} >> last
334  if [[ "${phys}" != **"new"* ]]
335  then
336   echo ${tra} >> last
337  fi
338
339#------------
340# log files
341#------------
342  \rm log_compile 2> /dev/null
343  \rm log_error 2> /dev/null
344
345#-----------------
346# configure WRF
347#-----------------
348  mv configure.wrf configure.wrf.bak 2> /dev/null
349  ########################
350  conf_wrf_forall="${compilo}_${machine}${single}${testflag}"
351
352         #### in this case options are different because for LES, WRFV3 is used
353         if [[ "${config}" == "les" ]]
354         then
355         conf_wrf_forall="${config}${compilo}_${machine}${single}${testflag}"
356         fi
357
358  case ${conf_wrf_forall} in
359
360     #######LES-specific (WRFV3-based) -- previously in 'makeles'
361     #######
362
363     lesmpi_64)        ## MPI (dm) 64 bits [PS: remplacer 3 par 4 pour openMP]
364                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 3 >> conf ; echo 1 >> conf
365                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
366                       sed s+"-lnetcdf"+"-lnetcdf -L../$phys/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
367                       if [[ "$(hostname)" == "ciclad1.ipsl.jussieu.fr" ]]
368                       then
369            echo "SPECIFIC CHANGES FOR CICLAD CLUSTER. EDIT makemeso IF YOU ENCOUNTER PROBLEMS."
370            #sed s+"mpif90 -f90=$(SFC)"+"/usr/lib64/openmpi/1.4.2-pgf/bin/mpif90"+g                      configure.wrf > yeah ; mv -f yeah configure.wrf
371            #sed s+"mpicc -cc=$(SCC)"+"/usr/lib64/openmpi/1.4.2-gfortran/bin/mpicc -DMPI2_SUPPORT"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
372            sed s+"mpif90 -f90=\$(SFC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpif90"+g                   configure.wrf > yeah ; mv -f yeah configure.wrf
373            sed s+"mpicc -cc=\$(SCC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpicc -DMPI2_SUPPORT"+g       configure.wrf > yeah ; mv -f yeah configure.wrf
374                       else
375            #sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
376            #sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
377            #### OPENMPI
378            sed s+"mpif90 -f90=\$(SFC)"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
379            sed s+"mpicc -cc=\$(SCC)"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
380                       fi
381                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
382                          ### pas forcement necessaire ici mais OK
383                          sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
384                       \rm conf > /dev/null ;;
385
386     lesmpifort_64)    ## MPI (dm) 64 bits IFORT
387                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 7 >> conf ; echo 1 >> conf
388                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
389                       if [[ "${phys}" != *"void"* ]]
390                       then
391                         sed s+"-lnetcdf"+"-lnetcdf -L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
392                       else
393                         sed s+"-lnetcdf"+"-lnetcdf $NETCDF/lib/libnetcdf.a"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
394                       fi
395                       sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
396                       sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
397                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
398                       sed s+"O3"+"O3 -mcmodel=large -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
399                       #sed s+"-lnetcdf -lnetcdff"+"-lnetcdf -lnetcdff -L../mars_lmd/libo -llmd"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
400                       if [ ${debug} -ne 0 ]   # not working for xlf!
401                             then
402                             echo 'DEBUG DEBUG DEBUG DEBUG'
403                             sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
404                             mv -f yeah configure.wrf
405                       fi
406                       \rm conf > /dev/null ;;
407
408     #######
409     #######LES-specific (WRFV3-based) -- previously in 'makeles'   
410
411#######TEST TEST
412                     # GFORTRAN, 64 bits, no nesting     
413     gnu_64_single)    cd arch ; ln -sf ../configure.defaults.gfortran64 configure.defaults ; cd ..
414                       echo 15 | configure > log_compile 2> log_error
415                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf 
416                       sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf ;;
417#######TEST TEST
418                     # PGF90, 32 bits, no nesting
419     pgf_32_single)    echo 1 | configure > log_compile 2> log_error
420                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
421                     # PGF90, 32 bits, nesting
422     pgf_32_nest)      echo 2 | configure > log_compile 2> log_error
423                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
424                     # PGF90, 64 bits, no nesting
425     pgf_64_single)    echo 1 | configure > log_compile 2> log_error
426                       #### the following line is necessary because readtesassim has a line "use netcdf" in it!
427                       #sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
428                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
429                     # PGF90, 64 bits, nesting
430     pgf_64_nest)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
431                       echo 4 | configure > log_compile 2> log_error
432                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
433                     # G95, 32 bits, no nesting
434     g95_32_single)    echo 13 | configure > log_compile 2> log_error
435                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
436                     # G95, 64 bits, no nesting  ### we modify configure.defaults to add x86_64 next to g95 in the header comment
437     g95_64_single)    cd arch ; sed s/"PC Linux i486 i586 i686, g95 compiler"/"PC Linux i486 i586 i686 x86_64, g95 compiler"/g configure.defaults > yeahyeahyeah ; rm configure.defaults ; mv yeahyeahyeah configure.defaults ; cd ..
438                       echo 14 | configure > log_compile 2> log_error
439                         ##### marche pas ....
440                         #sed s+"-fno-second-underscore"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
441                         #sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
442                         #sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf ;;
443                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
444                       #sed s+"=       g95"+"=       /home/physastro/aspiga/mysoft/g95/g95-install/bin/x86_64-unknown-linux-gnu-g95"+g configure.wrf > yeah ; mv -f yeah configure.wrf;;
445                     # IFORT, 64 bits, no nesting
446     ifort_64_single)  echo 5 | configure > log_compile 2> log_error
447                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
448                       if [ ${debug} -ne 0 ]   # not working for xlf!
449                             then
450                             echo 'DEBUG DEBUG DEBUG DEBUG'
451                             sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
452                             mv -f yeah configure.wrf
453                       fi
454                         ## !!! NETCDF must be defined
455                         sed s+"lio_grib_share"+"lio_grib_share -L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
456                         mv -f yeah configure.wrf ;;
457     mpifort_64)     # MPI+IFORT, 64 bits, no nesting / nesting
458                       echo 9 | ./configure > log_compile 2> log_error
459                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
460                       sed s+"-f90=ifort"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
461                       sed s+"-cc=icc"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
462                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
463                       sed s+"-O1"+"-O1 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
464                       sed s+"-O2"+"-O2 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
465                       sed s+"-O3"+"-O3 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
466                       if [ ${debug} -ne 0 ]   # not working for xlf!
467                             then
468                             echo 'DEBUG DEBUG DEBUG DEBUG'
469                             sed s+"#-g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
470                             mv -f yeah configure.wrf
471                       fi
472                       sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf
473                                        #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf  ### pour compilation rapide
474                                        #-w -ftz -align all -fno-alias -fp-model precise >>> options indiquees dans WRF3
475                                        #http://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-wrf-with-the-intel-compilers/
476                            #### NB: RSL is replaced by RSL_LITE, better memory capacity, less seg fault
477                            sed s+"../external/RSL/RSL"+"../external/RSL_LITE"+g configure.wrf > yeah ; mv -f yeah configure.wrf
478                            sed s+"-DWRF_RSL_IO"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
479                            sed s+"-DRSL"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
480                            sed s+"librsl.a"+"librsl_lite.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
481                            sed s+"../external/RSL/gen"+"../external/RSL_LITE/gen"+g configure.wrf > yeah ; mv -f yeah configure.wrf
482                            sed s+"../external/RSL/module"+"../external/RSL_LITE/module"+g configure.wrf > yeah ; mv -f yeah configure.wrf
483                            sed s+"-lrsl"+"-lrsl_lite"+g configure.wrf > yeah ; mv -f yeah configure.wrf
484                            sed s+"linux"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
485                         ### necessary even if mpi-selector is used (no need in makegcm though)
486                         sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g > yeah ; mv -f yeah configure.wrf
487                         sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf
488                         ## !!! NETCDF must be defined
489                         if [[ "${phys}" != *"void"* ]]
490                         then
491                           sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
492                         else
493                           sed s+"-lesmf_time"+"-lesmf_time $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
494                         fi
495                         mv -f yeah configure.wrf
496                         #### POUR LE TRAITEMENT PARTICULIERS des NESTS sur iDATAPLEX [cf. module_lmd_driver]
497                         sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DSPECIAL_NEST_SAVE "+g configure.wrf > yeah
498                         mv -f yeah configure.wrf ;;
499                     # MPICH, 64 bits, no nesting / nesting
500     mpi_64)           cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
501                       echo 3 | configure > log_compile 2> log_error
502                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
503                       ### the following line is necessary because readtesassim has a line "use netcdf" in it!
504                       sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
505                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
506                       #sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT -w -O3"+g > yeah
507                                #| sed s+"fastsse"+"fast"+g > yeah
508                       mv -f yeah configure.wrf ;;
509                       #    #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
510                       #    ##sed s+"-fastsse"+"-O2 -fpic"+g configure.wrf > yeah ## marche pas, ILM problem
511                       #    ##sed s+"-fastsse"+"-mcmodel=medium -Mlarge_arrays"+g configure.wrf > yeah ## marche pas, ILM problem
512                       #sed s+"-fastsse"+"-O3 -tp=nehalem-64 -fastsse -Mscalarsse -Mvect=sse -Mipa=fast"+g configure.wrf > yeah
513                       #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
514                       #sed s+"-fastsse"+""+g configure.wrf > yeah
515                       #sed s+"-fastsse"+"-fast"+g configure.wrf > yeah
516                       #sed s+"-fastsse"+"-Mvect=noaltcode -Msmartalloc -Mprefetch=distance:8 -Mfprelaxed"+g configure.wrf > yeah
517                       #mv -f yeah configure.wrf ;;
518                     # MPICH, 64 bits, OK with periodic BC but no positive definite
519     mpi_64_test)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
520                       echo 2 | configure > log_compile 2> log_error
521                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
522                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
523                       mv -f yeah configure.wrf ;;
524                     # XLF+MPICH on AIX machine (64 bits) with nesting, NB: the 32bits notice is not to be considered
525     mpixlf_32)        cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
526                       echo 3 | configure > log_compile 2> log_error
527                       sed -f physics.sed configure.wrf > yeah
528                       mv -f yeah configure.wrf ;;
529                     # ANYTHING ELSE
530     *)                echo NO PRESETS ...
531                       if [ ${donotallow} -eq 0 ] 
532                       then
533                         configure
534                       else
535                         # problem when an input file is used
536                         echo 'please cd to '$PWD' and type ./configure' 
537                         exit   
538                       fi ;;
539  esac
540  ########################
541
542
543  ### here a case structure would be great
544
545  if [[ "${phys}" == *"new"* ]]
546  then
547     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
548     then
549       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNEWPHYS "+g configure.wrf > yeah
550     else
551       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNEWPHYS "+g configure.wrf > yeah
552     fi
553     mv -f yeah configure.wrf
554  fi
555
556        ### SCENARIO SCENARIO SCENARIO
557        if [[ ! ("${scenario}" == "") ]]   ### not supported with LES for the moment?
558        then
559          # precompiling flag in WRF part
560          sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -D${scenario} "+g configure.wrf > yeah
561          mv -f yeah configure.wrf
562          # precompiling flag in LMD part
563          cd $phys
564          cp -Lrf makegcm_${compilo} yeah
565          \rm makegcm_${compilo}
566          sed s+"-DMESOSCALE"+"-D${scenario} -DMESOSCALE"+ yeah > makegcm_${compilo}
567          chmod 755 makegcm_${compilo}
568          \rm yeah
569          cd ..
570        fi
571
572  ################
573  #if [[ "${phys}" == "nophys_" ]]
574  #then
575  #   if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
576  #   then
577  #     sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
578  #     sed s+"-L../$phys/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
579  #   else
580  #     ### not tested yet but should be working 
581  #     echo CAUTION CAUTION CAUTION NOT FULLY TESTED
582  #     sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
583  #     sed s+"-L../$phys/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
584  #   fi
585  #fi
586  ################
587
588  if [[ "${phys}" == *"venus"* ]]
589  then
590    sed s+"LIB_BUNDLED     = "+"LIB_BUNDLED     =    /usr/lib64/liblapack.so  \ "+g configure.wrf > yeah ; mv -f yeah configure.wrf
591  fi
592
593  if [ ${debug} -ne 0 ]   # not working for xlf!
594  then
595    echo 'DEBUG DEBUG DEBUG DEBUG'
596    sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
597    #sed s+"# -g"+"-g -Ktrap=fp -Mbounds"+g configure.wrf > yeah
598    #sed s+"# -g"+"-g"+g configure.wrf > yeah
599    mv -f yeah configure.wrf
600  fi
601
602  if [[ "${phys}" == *"prescribed"* ]]
603  then
604     donotcompilephys=1
605  fi
606
607  # some compiler and environment mess things up when using -C
608  sed s+"-C"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf   
609
610#exit
611##################################################
612# compile physics
613##################################################
614if [ ${donotcompilephys} -eq 0 ] #|| [[ "${phys}" != *"prescribed"* ]]
615then
616
617 cd $phys/
618
619 if [[ "${phys}" == *"new"* ]]
620 then
621  divx=1
622  divy=1
623 else
624  # required size
625  #----------------
626  case ${numproc} in
627      1) divx=1 ; divy=1  ;;
628      2) divx=1 ; divy=2  ;;
629      4) divx=2 ; divy=2  ;;
630      6) divx=2 ; divy=3  ;;
631      8) divx=2 ; divy=4  ;;
632     12) divx=3 ; divy=4  ;;
633     16) divx=4 ; divy=4  ;;
634     20) divx=4 ; divy=5  ;;
635     24) divx=4 ; divy=6  ;;
636     32) divx=4 ; divy=8  ;;
637     64) divx=8 ; divy=8  ;;
638    128) divx=8 ; divy=16 ;;
639      *) echo not yet supported ; exit ;;
640  esac
641 fi
642  physx=$(expr ${lon} - 1)
643  restex=$(expr ${physx} \% ${divx})   
644  physy=$(expr ${lat} - 1)
645  restey=$(expr ${physy} \% ${divy})
646  if [[ ${restex} != 0 || ${restey} != 0 ]]
647  then
648     echo nx-1 shall be divided by ${divx}
649     echo ny-1 shall be divided by ${divy}
650     exit
651  fi
652  physx=$(expr ${physx} \/ ${divx})
653  physy=$(expr ${physy} \/ ${divy})
654  physz=$(expr ${level} - 1)
655
656  # change this if you change num_soil_layers in WRF
657  # -- default is 10
658  if [[ "${phys}" == *"new"* ]]
659  then
660     soilsize=18 ## nouvelle physique. ne sert a rien ici. voir comsoil.
661  else
662     soilsize=10
663  fi
664
665  # GCM environment variables
666  #--------------------------
667  export LMDGCM=$PWD
668  export LIBOGCM=$PWD/libo
669
670  # generate the appropriate dimphys
671  #---------------------------------
672  if [[ "${phys}" == *"mars"* ]]
673  then
674    cd libf/phymars
675  elif [[ "${phys}" == *"venus"* ]]
676  then
677    cd libf/phyvenus
678  fi
679  \rm dimphys.h 2> /dev/null
680#  if [[ "${phys}" == "newphys_" ]]
681#  then
682#    ln -sf ../../meso_dimphys.h_ref . ## ne sert plus !!
683#  else
684  if [[ "${phys}" == "mars_lmd" ]]
685  then
686    physize=$(expr ${physx} \* ${physy})
687    sed s/--xsize--/${physx}/g meso_dimphys.h_ref | sed s/--ysize--/${physy}/g | sed s/--physize--/${physize}/g | sed s/--zsize--/${physz}/g | sed s/--soilsize--/${soilsize}/g > dimphys.h
688    head -15 dimphys.h
689  fi
690     #### TEST new new phys
691     #if [[ "${phys}" == "newphys_" ]]
692     #then
693     #  touch gr_fi_dyn.F.lien
694     #    ln -sf ../dyn3d/gr_fi_dyn.F .  ## dommage, a corriger
695     ################################
696     ################################
697     ################################
698     #fi
699     ####
700     ####
701  cd ../..
702
703  # prepare for nesting
704  #---------------------
705  cd libf
706  duplicate${dom} 2> /dev/null
707  cd ..
708
709  # compile physics
710  #--------------------------
711  \rm libf/grid/dimensions.h 2> /dev/null
712  \rm -rf libo/* 2> /dev/null
713  echo 1. compiling LMD physics ...
714  echo compilation info in:
715  echo $PWD/libo/log_compile_phys
716
717  if [ ${debug} -ne 0 ] 
718  then
719    if [[ "${phys}" == *"mars"* ]]
720    then
721      echo 'DEBUG DEBUG DEBUG DEBUG'
722      nohup makegcm_${compilo} -debug -full -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
723    elif [[ "${phys}" == *"venus"* ]]
724    then
725      echo 'DEBUG DEBUG DEBUG DEBUG'
726      nohup ./makelmdz -debug -full -p venus -d 51 rcm1d -arch linux-ifort -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys # on /u/ and /planeto/
727      nohup ./makelmdz --debug p venus -d 51 rcm1d -arch linux-ifort -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
728    fi
729  else
730  if [[ "${phys}" == *"mars"* ]]
731    then
732      nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
733    elif [[ "${phys}" == *"venus"* ]]
734    then
735      nohup ./makelmdz -full -p venus -d 51 rcm1d -arch linux-ifort_meso -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys # on /u/ and /planeto/
736      nohup ./makelmdz -p venus -d 51 rcm1d -arch linux-ifort_meso -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
737      #nohup ./makelmdz -full -p venus -d 51 rcm1d -arch CICLADifort -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys # on CICLAD
738      #nohup ./makelmdz -p venus -d 51 rcm1d -arch CICLADifort -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
739      #nohup ./makelmdz -full -p venus -d 51 rcm1d -arch X64_MESU -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys #on MESU
740      #nohup ./makelmdz -p venus -d 51 rcm1d -arch X64_MESU -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
741      #nohup makelmdz -full -p venus -d 51 rcm1d -arch X64_OCCIGEN -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys #on OCCIGEN
742      #nohup makelmdz -p venus -d 51 rcm1d -arch X64_OCCIGEN -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
743    fi
744  fi
745  echo ... done
746        # clean the duplicate routines
747        cd libf
748        duplicate1 2> /dev/null
749        cd ..
750
751  # merge LMD executables in one lib
752  #--------------------------------------
753  cd libo
754  mkdir temp
755  if [[ "${phys}" == *"mars"* ]]
756  then
757    cp -f LINUX*/*.a temp
758  else #VENUS
759    cp -f linux*/*.a temp/ # on /u/ and /planeto/
760    #cp -f /home/mlefevre/modipsl/lib/libioipsl.a temp/ #on CICLAD
761    #cp -f X64*/*.a temp #on MESU and OCCIGEN
762    cp -f ../ioipsl/libioipsl.a temp/
763  fi
764  cd temp
765  if [[ "${phys}" == *"mars"* ]]
766   then   
767   ar x libbibio.a
768   ar x libphymars.a
769   ar x libaeronomars.a
770  else
771   ar x libphyvenus.a
772   ar x libmisc.a
773   ar x libphy_common.a
774   ar x libioipsl.a
775  fi
776  \rm *.a
777  ar r liblmd.a *
778  cp -f liblmd.a ..
779  cd ..
780  \rm -r temp
781  nm liblmd.a > liblmd_content
782  # finish merge
783  cd ..
784  if [[ "${phys}" == *"new"* ]]
785  then
786    if [[ "${phys}" == *"mars"* ]]
787    then
788      # include modules for interfacing
789      mv  *.mod ../inc/
790    elif [[ "${phys}" == *"venus"* ]] 
791    then
792      mv  ./libo/linux*/*.mod ../inc/ # on /u/ and /planeto/
793      #mv  ./libo/CICLAD*/*.mod ../inc/ # on CICLAD
794      #mv  ./libo/X64*/*.mod ../inc/ # on MESU and OCCIGEN
795      cp -f ./ioipsl/*.mod ../inc/
796    fi
797  fi
798
799
800  # save a copy
801  #--------------
802  cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra}
803  echo '****************************************'
804
805  # ok
806  #----
807  cd ..
808
809  # manage nest includes in module_lmd_driver.F
810  #----
811  cp call_meso_inifis$dom.inc call_meso_inifis.inc
812  cp call_meso_physiq$dom.inc call_meso_physiq.inc
813
814
815fi
816##################################################
817# END compile physics
818##################################################
819
820#------------------
821# compile WRF
822#------------------
823if [ ${justphys} -eq 0 ]
824then
825
826  echo 2. compiling WRF dynamical core ...
827
828  #if [[ "${phys}" == "nophys_" ]]
829  #then
830  # echo 'NO LMD PHYSICS included'
831  #else
832  # if [[ ! ( -f "call_meso_physiq.inc" ) ]]
833  # then
834  #  echo 'did you compile the physics ? no call_meso_physiq.inc !'
835  #  exit
836  # fi
837  #fi
838
839  # be sure to compile with the most recent physics
840  touch phys/module_lmd_driver.F
841
842  # talk to user
843  echo '>>> compiling ... this may be long ... <<<'
844  echo check progress in:
845  echo $PWD/log_compile
846  echo check possible errors in:
847  echo $PWD/log_error
848 
849  # compile ...
850  echo '>>> YOUR CONFIG IS : '${config}
851  case ${config} in
852    'real')         ./compile em_real > log_compile 2> log_error
853                    # save executables 
854                    cd main
855                      if [[ -f real.exe ]]
856                      then
857                        echo 'Looks good ! real.exe is here...'
858                      fi
859                      if [[ -f wrf.exe ]]
860                      then
861                        echo 'Looks good ! wrf.exe is here...'
862                      fi
863                    cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
864                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
865                    cd ..  ;;
866    'ideal')        #mkdir 'test/em_quarter_ss' 2> /dev/null
867                    #echo '>>> YOUR CONFIG IS : '${config}
868                    ./compile em_quarter_ss > log_compile 2> log_error
869                    # save executables 
870                    cd main
871                      if [[ -f ideal.exe ]]
872                      then
873                        echo 'Looks good ! ideal.exe is here...'
874                      fi
875                      if [[ -f wrf.exe ]]
876                      then
877                        echo 'Looks good ! wrf.exe is here...'
878                      fi
879                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
880                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
881                    cd ..  ;;
882    'les')          #echo '>>> YOUR CONFIG IS : '${config}
883                    mkdir 'test/em_les' 2> /dev/null                   
884                    ./compile em_les > log_compile 2> log_error
885                    # save executables 
886                    cd main
887                      if [[ -f ideal.exe ]]
888                      then
889                        echo 'Looks good ! ideal.exe is here...'
890                      fi
891                      if [[ -f wrf.exe ]]
892                      then
893                        echo 'Looks good ! wrf.exe is here...'
894                      fi
895                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
896                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
897                    cd ..  ;;
898    *)              echo not supported... please use ; echo ideal les ; exit ;;
899  esac
900  echo '*******last lines from log_error*********'
901  tail -n 20 log_error
902fi
903
904  # the end
905  echo '****************************************'
906  echo 'done.'
907  echo '****************************************'
908  cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}
909  mv last ../../
910  svn info ../../ > ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.svn.info
911
912
913
914  # link latest compiled folder as LATEST
915  cd ../../
916  rm -rf LATEST
917  ln -sf ${conf_wrf} LATEST
918
919  # add here specific messages
920  if [[ "${dom}" != "1" ]]
921  then
922  nest=$(expr ${lon} + 4)
923  echo NB: in namelist.input, please set:
924  echo '
925  max_dom = '$dom'
926  s_we    = 1,1,
927  e_we    = '$lon','$nest',
928  s_sn    = 1,1,
929  e_sn    = '$lat','$nest',
930  s_vert  = 1,1,
931  e_vert  = '$level','$level','
932  fi
933
934
Note: See TracBrowser for help on using the repository browser.