source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 156

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

MESOSCALE: changements pour compiler / faire tourner le LES sans recours a la physique martienne [doit normalement egalement fonctionner avec modele mesoscale, non teste cependant]. principalement ajout d'un dossier LESnewphys_, d'une option -x dans makemeso et d'un flag NOPHYS dans module_lmd_driver ainsi que solve_em ou assimiles. l'objectif est de preparer la realisation de cas universels idealises, par exemple couche de nuages sur Venus.

  • Property svn:executable set to *
File size: 31.6 KB
RevLine 
[11]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 #
[29]14#               January   11 #
[11]15##############################
16
[68]17###############################
18#### Type makemeso -h for help
19###############################
[11]20
21
22
23##############################################################################################
24##############################################################################################
25##############################################################################################
26##############################################################################################
27
28donotcompile=0
29donotallow=0
[142]30config=''
[11]31donotcompilephys=0
32justphys=0
33debug=0
[54]34fresh_start=0
[29]35phys=""
[118]36scenario=""
[156]37while getopts "drc:njhgpfs:x" options; do
[11]38  case $options in
[118]39   d ) donotcompile=1;;       ## just to check the compile folder
40   r ) donotallow=1;;         ## allow only known config (useful with 'makemeso < last')
41   c ) config="${OPTARG}";;   ## idealized cases
42   n ) donotcompilephys=1;;   ## do not recompile physics
43   j ) justphys=1;;           ## just compile LMD physics
44   g ) debug=1;;              ## debug mode
45   p ) phys="newphys_";;      ## with new physics
46   f ) fresh_start=1;;        ## a fresh start
47   s ) scenario="${OPTARG}";; ## a specific scenario, you need a corresponding "mars_lmd_..."
[156]48   x ) phys="nophys_";donotcompilephys=1;; ## a case with no LMD physics included
[11]49   h ) echo "
50# Use:   
51#
[142]52# makemeso                   ## basic use (real-case configuration)
[11]53#
54# makemeso -d                ## no compilation, just check the name of the compile folder
55#
[68]56# makemeso -c ideal          ## idealized mode (convective cell, mountain wave, etc...)
[142]57# makemeso -c les            ## large-eddy simulations mode based on WRFV3
[11]58#
[70]59# makemeso -n                ## do not recompile LMD physics (must have been compiled before)
[68]60#
[11]61# makemeso < last            ## basic use + skip questions [! script must have been executed at least once]
62# makemeso -r < last         ## basic use + skip questions + only known config
63# makemeso -nr < last        ## basic use + skip questions + only known config + no LMD phys recompile
64#
65# makemeso -j                ## just compile the LMD physics
66#
67# makemeso -g                ## debug mode
68#
69# makemeso -h                ## display options
[29]70#
71# makemeso -p                ## with new LMD physics
[54]72#
73# makemeso -f                ## fresh start [clean -a]
[118]74#
75# makemeso -s storm          ## a specific scenario, you need a corresponding mars_lmd_... (only for newphys)
[156]76#
77# makemeso -x                ## a case with no LMD physics included
[11]78" ; exit ;;
79  esac
80done   
81
82#--------------
83# talk w/ user
84#--------------
85  echo '****************************************'
86  echo ' LMD Mesoscale Model Compiler. Welcome.'
87  echo '****************************************'
[29]88  if [[ "${phys}" == "newphys_" ]]
89  then
90    echo '***********with new physics*************'
91    echo '****************************************'
92  fi
[11]93  # computer
94  uname -a | grep x86_64 > /dev/null
95  if [[ "$?" == 0 ]]
96  then
97    machine='64'
98  else
99    machine='32'
100  fi
101  # compiler
102  echo "Supported compiler options are "
103  echo "       <1> pgf90"
104  echo "       <2> g95"
105  echo "       <3> pgf90 + mpi"
106  echo "       <4> ifort"
107  echo "       <5> ifort + mpi"
108  echo "       <7> xlf + mpi (IBM AIX)"
109  echo "Your choice ?" ; read reply
110  case ${reply} in
111    1) compilo='pgf' ; numproc=1 ;;
112    2) compilo='g95' ; numproc=1 ;;
113    3) compilo='mpi'
114       if [[ "${WHERE_MPI}" = "" ]]
115       then
116         echo Please initialize the variable WHERE_MPI in your environnement
117         exit
118       fi
[111]119       echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
[11]120    4) compilo='ifort' ; numproc=1 ;;
[111]121    5) compilo='mpifort' ; echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
122    7) compilo='mpixlf' ; echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
[11]123### for tests
12499) compilo='gnu' ; numproc=1 ;;
125    *) echo not supported by this script ; exit ;;
126  esac
127  # dimensions
128  if [ ${donotcompile} -eq 0 ]
129  then   
130  echo Grid points in longitude ? ; read lon
131  echo Grid points in latitude ? ; read lat
132  echo Number of vertical levels ? ; read level
133  fi
134  echo Number of domains ? ; read dom
135
136###PB lecture dom si < last
137
138    case ${dom} in
139       1) single='_single' ;;
140       *) single='_nest' ;;
141    esac
142      if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
143      then
144           single=''
145      fi
146
147testflag=''
148####
149#testflag='_test'
150####
151
[142]152    conf_wrf="${config}${scenario}${phys}${compilo}_${machine}${single}${testflag}"
[11]153    \rm what_folder 2> /dev/null
154    echo ${conf_wrf} > what_folder
155         if [ ${donotcompile} -eq 1 ]
156         then
157            #\rm what_folder 2> /dev/null
158            #echo '**********************'
159            #echo '*** Your folder is ...'
160            #echo '**********************'
161            #echo ${conf_wrf} | tee what_folder
162            #cat what_folder
163            #echo ${conf_wrf} > what_folder
164            #echo ${reply} > what_compilo
165            #echo ${numproc} > what_numproc
166            exit
167         fi
168  echo Number of tracers ? ; read tra
169         if [ ${tra} -eq 0 ]
170         then
171            tra=1       
172         fi
173  # folder
174  mkdir ${conf_wrf} 2> /dev/null
175  if [[ "$?" == 0 ]]
176  then
177    echo new folder ... link sources
[29]178    if [[ "${phys}" == "newphys_" ]]
179    then
[73]180     \rm copy_model_tmp > /dev/null
[118]181        if [[ "${scenario}" == "" ]]
182        then
183          sed s+"mars_lmd"+"mars_lmd_new"+g             copy_model > copy_model_tmp
184        else
[147]185          echo SCENARIO ${scenario} DID YOU INCLUDE THE SPECIFIC folder ? ; read dummy
[118]186          sed s+"mars_lmd"+"mars_lmd_new_${scenario}"+g copy_model > copy_model_tmp
[142]187             if [[ "${config}" == "les" ]]
188             then
189              echo "NOT SUPPORTED, check options"
[147]190              exit
[142]191             fi
[118]192        fi
[142]193        if [[ "${config}" == "les" ]]
194        then
195         sed s+"PWD/SRC/"+"PWD/SRC/LES/"+g copy_model_tmp > yeah
196         mv yeah copy_model_tmp
197        fi
[54]198     chmod 755 copy_model_tmp
199     ./copy_model_tmp
200     \rm copy_model_tmp
201     mv WRFV2 ${conf_wrf}/
202     cd ${conf_wrf}/WRFV2
[118]203        if [[ "${scenario}" == "" ]]
204        then
205          ln -sf mars_lmd_new             mars_lmd
206        else
207          ln -sf mars_lmd_new_${scenario} mars_lmd
208          cp ../../SRC/WRFV2/mars_lmd_new_${scenario}/Registry.EM mars_lmd_new_${scenario}/
209          cp ../../SRC/WRFV2/mars_lmd_new_${scenario}/*.inc mars_lmd_new_${scenario}/
210          cd Registry ; ln -sf ../mars_lmd_new_${scenario}/Registry.EM . ; cd ..
211        fi
[54]212     ln -sf meso_callkeys_newphys.h meso_callkeys.h
213     cd Registry ; Registry.bash ; cd ..
[29]214    else
[142]215     #./copy_model
216         if [[ "${config}" == "les" ]]
217         then
[156]218           ### NB: With physics: LES folder // Without physics : LESnophys_ folder
219           ### ---- because differences in 'modif' folder ----
220           sed s+"PWD/SRC/"+"PWD/SRC/LES$phys/"+g copy_model > copy_model_tmp
[142]221         else
222           cp copy_model copy_model_tmp
223         fi   
224     chmod 755 copy_model_tmp
225     ./copy_model_tmp
226     \rm copy_model_tmp
[54]227     mv WRFV2 ${conf_wrf}/
228     cd ${conf_wrf}/WRFV2
229     cd Registry ; Registry.bash ; cd ..
230     fi
[142]231          #### sparadrap consequent a l'utilisation de copy_model pour les liens
232          #### -- car alors il manque fftpack
233          if [[ "${config}" == "les" ]]
234          then
235            cp ../../SRC/LES/correcfft ./
236            ./correcfft
237            \rm correcfft
238          fi
[11]239  else
240    cd ${conf_wrf}/WRFV2
[54]241    if [ ${fresh_start} -eq 1 ]
242    then
243      echo '*** FRESH START, I clean everything'
244      clean -a > /dev/null 2> /dev/null
245      cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd ..
246      answer='y' ## a voir... pas si sur
247    else
248      echo Did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer
249      case ${answer} in
250        y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;;
251        *) answer='no' ;;
252      esac
253    fi
[11]254  fi
[153]255  if [[ "${phys}" == "newphys_" ]]
256  then
257     echo "How many scatterers are you using : 1,2,..." ; read scat
258  else
259     scat=1 ## dummy stuff
260  fi
261
[11]262  # summary
263  echo '**********************'
264  echo '*** Your folder is ...'
265  echo '**********************'
266  echo ${conf_wrf}
267  echo '**********************'
268  echo '****************************************'
269  echo so ...
270  echo your computer is ${machine} bits
271  echo ${compilo} is your compiler
272       if [[ "${compilo}" = "mpi" ]]
273       then
274         echo MPICH is in ${WHERE_MPI}
275       fi
276  echo you will use ${numproc} processors
277  echo you have ${lon} x points
278  echo '         '${lat} y points
279  echo '         '${level} z points
280  echo '         '${dom} domains
281  echo '         '${tra} tracers
[153]282  if [[ "${phys}" == "newphys_" ]]
283  then
284    echo '         '${scat} scatterers
285  fi
[11]286  echo '****************************************'
287  # save answer
288  \rm last 2> /dev/null
289  touch last
290  echo ${reply} >> last
291     if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
292     then
293     echo ${numproc} >> last
294     fi
295  echo ${lon} >> last
296  echo ${lat} >> last
297  echo ${level} >> last
298  echo ${dom} >> last
299  echo ${tra} >> last
300  echo ${answer} >> last
[153]301  echo ${scat} >> last
[11]302
303#------------
304# log files
305#------------
306  \rm log_compile 2> /dev/null
307  \rm log_error 2> /dev/null
308
309#-----------------
310# configure WRF
311#-----------------
312  mv configure.wrf configure.wrf.bak 2> /dev/null
313  ########################
[30]314  conf_wrf_forall="${compilo}_${machine}${single}${testflag}"
[142]315
316         #### in this case options are different because for LES, WRFV3 is used
317         if [[ "${config}" == "les" ]]
318         then
319         conf_wrf_forall="${config}${compilo}_${machine}${single}${testflag}"
320         fi
321
[30]322  case ${conf_wrf_forall} in
[142]323
324     #######LES-specific (WRFV3-based) -- previously in 'makeles'
325     #######
326
327     lesmpi_64)        ## MPI (dm) 64 bits [PS: remplacer 3 par 4 pour openMP]
328                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 3 >> conf ; echo 1 >> conf
329                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
330                       sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
331                       if [[ "$(hostname)" == "ciclad1.ipsl.jussieu.fr" ]]
332                       then
333            echo "SPECIFIC CHANGES FOR CICLAD CLUSTER. EDIT makemeso IF YOU ENCOUNTER PROBLEMS."
334            #sed s+"mpif90 -f90=$(SFC)"+"/usr/lib64/openmpi/1.4.2-pgf/bin/mpif90"+g                      configure.wrf > yeah ; mv -f yeah configure.wrf
335            #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
336            sed s+"mpif90 -f90=$(SFC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpif90"+g                   configure.wrf > yeah ; mv -f yeah configure.wrf
337            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
338                       else
339            sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
340            sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
341                       fi
342                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
343                          ### pas forcement necessaire ici mais OK
344                          sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
345                       \rm conf > /dev/null ;;
346
347     lesmpifort_64)    ## MPI (dm) 64 bits IFORT
348                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 7 >> conf ; echo 1 >> conf
349                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
350                       sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
351                       sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
352                       sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
353                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
354                       sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
355                       \rm conf > /dev/null ;;
356
357     #######
358     #######LES-specific (WRFV3-based) -- previously in 'makeles'   
359
[11]360#######TEST TEST
361                     # GFORTRAN, 64 bits, no nesting     
362     gnu_64_single)    cd arch ; ln -sf ../configure.defaults.gfortran64 configure.defaults ; cd ..
363                       echo 15 | configure > log_compile 2> log_error
364                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf 
365                       sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf ;;
366#######TEST TEST
367                     # PGF90, 32 bits, no nesting
368     pgf_32_single)    echo 1 | configure > log_compile 2> log_error
369                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
370                     # PGF90, 32 bits, nesting
371     pgf_32_nest)      echo 2 | configure > log_compile 2> log_error
372                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
373                     # PGF90, 64 bits, no nesting
374     pgf_64_single)    echo 1 | configure > log_compile 2> log_error
375                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
376                     # PGF90, 64 bits, nesting
377     pgf_64_nest)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
378                       echo 4 | configure > log_compile 2> log_error
379                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
380                     # G95, 32 bits, no nesting
381     g95_32_single)    echo 13 | configure > log_compile 2> log_error
382                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
[24]383                     # G95, 64 bits, no nesting  ### we modify configure.defaults to add x86_64 next to g95 in the header comment
384     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 ..
385                       echo 14 | configure > log_compile 2> log_error
386                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
387                       #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;;
[11]388                     # IFORT, 64 bits, no nesting
389     ifort_64_single)  echo 5 | configure > log_compile 2> log_error
390                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
391                         ## !!! NETCDF must be defined
392                         sed s+"lio_grib_share"+"lio_grib_share -L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
393                         mv -f yeah configure.wrf ;;
394     mpifort_64)     # MPI+IFORT, 64 bits, no nesting / nesting
395                       echo 9 | configure > log_compile 2> log_error
396                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
397                       sed s+"-f90=ifort"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
398                       sed s+"-cc=icc"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
399                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
400                       sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf
401                                        #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf  ### pour compilation rapide
402                                        #-w -ftz -align all -fno-alias -fp-model precise >>> options indiquees dans WRF3
403                                        #http://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-wrf-with-the-intel-compilers/
404                            #### NB: RSL is replaced by RSL_LITE, better memory capacity, less seg fault
405                            sed s+"../external/RSL/RSL"+"../external/RSL_LITE"+g configure.wrf > yeah ; mv -f yeah configure.wrf
406                            sed s+"-DWRF_RSL_IO"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
407                            sed s+"-DRSL"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
408                            sed s+"librsl.a"+"librsl_lite.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
409                            sed s+"../external/RSL/gen"+"../external/RSL_LITE/gen"+g configure.wrf > yeah ; mv -f yeah configure.wrf
410                            sed s+"../external/RSL/module"+"../external/RSL_LITE/module"+g configure.wrf > yeah ; mv -f yeah configure.wrf
411                            sed s+"-lrsl"+"-lrsl_lite"+g configure.wrf > yeah ; mv -f yeah configure.wrf
412                            sed s+"linux"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
413                         ### necessary even if mpi-selector is used (no need in makegcm though)
414                         sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g > yeah ; mv -f yeah configure.wrf
415                         sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf
416                         ## !!! NETCDF must be defined
417                         sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
[70]418                         mv -f yeah configure.wrf
419                         #### POUR LE TRAITEMENT PARTICULIERS des NESTS sur iDATAPLEX [cf. module_lmd_driver]
[71]420                         sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DSPECIAL_NEST_SAVE "+g configure.wrf > yeah
[11]421                         mv -f yeah configure.wrf ;;
422                     # MPICH, 64 bits, no nesting / nesting
423     mpi_64)           cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
424                       echo 3 | configure > log_compile 2> log_error
425                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
426                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
427                                #| sed s+"fastsse"+"fast"+g > yeah
[28]428                       mv -f yeah configure.wrf ;;
429                       #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
430                       ##sed s+"-fastsse"+"-O2 -fpic"+g configure.wrf > yeah ## marche pas, ILM problem
431                       ##sed s+"-fastsse"+"-mcmodel=medium -Mlarge_arrays"+g configure.wrf > yeah ## marche pas, ILM problem
432                       #mv -f yeah configure.wrf ;;
[11]433                     # MPICH, 64 bits, OK with periodic BC but no positive definite
434     mpi_64_test)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
435                       echo 2 | configure > log_compile 2> log_error
436                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
437                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
438                       mv -f yeah configure.wrf ;;
439                     # XLF+MPICH on AIX machine (64 bits) with nesting, NB: the 32bits notice is not to be considered
440     mpixlf_32)        cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
441                       echo 3 | configure > log_compile 2> log_error
442                       sed -f mars.sed configure.wrf > yeah
443                       mv -f yeah configure.wrf ;;
444                     # ANYTHING ELSE
445     *)                echo NO PRESETS ...
446                       if [ ${donotallow} -eq 0 ] 
447                       then
448                         configure
449                       else
450                         # problem when an input file is used
451                         echo 'please cd to '$PWD' and type ./configure' 
452                         exit   
453                       fi ;;
454  esac
455  ########################
456
[142]457
[156]458  ### here a case structure would be great
459
[29]460  if [[ "${phys}" == "newphys_" ]]
461  then
[142]462     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
463     then
464       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNEWPHYS "+g configure.wrf > yeah
465     else
466       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNEWPHYS "+g configure.wrf > yeah
467     fi
[29]468     mv -f yeah configure.wrf
469  fi
[11]470
[142]471        if [[ ! ("${scenario}" == "") ]]   ### not supported with LES for the moment
[118]472        then
473          sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -D${scenario} "+g configure.wrf > yeah
474          mv -f yeah configure.wrf
475        fi
476
[156]477  ################
478  if [[ "${phys}" == "nophys_" ]]
479  then
480     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
481     then
482       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
483       sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
484     else
485       ### not tested yet but should be working 
486       echo CAUTION CAUTION CAUTION NOT FULLY TESTED
487       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
488       sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
489     fi
490  fi
491  ################
492
[11]493  if [ ${debug} -ne 0 ]   # not working for xlf!
494  then
495    echo 'DEBUG DEBUG DEBUG DEBUG'
496    sed s+"#-g"+"-g"+g configure.wrf > yeah
497    mv -f yeah configure.wrf
498  fi
499
500
501##################################################
502# compile physics
503##################################################
504if [ ${donotcompilephys} -eq 0 ]
505then
506
507  cd mars_lmd/
508
509  # required size
510  #----------------
511  case ${numproc} in
512    1) physx=$(expr ${lon} - 1)
513       physy=$(expr ${lat} - 1)
514       physz=$(expr ${level} - 1) ;;
515    2) physx=$(expr ${lon} - 1)
516       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 2)
517       physz=$(expr ${level} - 1) ;;
518    4) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2)
519       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 2)
520       physz=$(expr ${level} - 1) ;;
521    6) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2)
522       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 3)
523       physz=$(expr ${level} - 1) ;;
524    8) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2)
525       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4)
526       physz=$(expr ${level} - 1) ;;
527    12) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 3)
528        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4)
529        physz=$(expr ${level} - 1) ;;
530    16) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4)
531        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4)
532        physz=$(expr ${level} - 1) ;;
[60]533    20) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4)
534        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 5)
535        physz=$(expr ${level} - 1) ;;
536    24) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4)
537        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 6)
538        physz=$(expr ${level} - 1) ;;
539    32) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4)
540        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 8)
541        physz=$(expr ${level} - 1) ;;
542    64) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 8)
543        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 8)
544        physz=$(expr ${level} - 1) ;;
[111]545    128) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 8)
546        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 16)
547        physz=$(expr ${level} - 1) ;;
[11]548    *) echo not supported ; exit
549  esac
550
551  # change this if you change num_soil_layers in WRF
552  # -- default is 10
[30]553  if [[ "${phys}" == "newphys_" ]]
554  then
555     soilsize=18 ## nouvelle physique
556  else
557     soilsize=10
558  fi
[11]559
560  # GCM environment variables
561  #--------------------------
562  export LMDGCM=$PWD
563  export LIBOGCM=$PWD/libo
564
565  # generate the appropriate dimphys
566  #---------------------------------
567  cd libf/phymars
568  \rm dimphys.h 2> /dev/null
569  physize=$(expr ${physx} \* ${physy})
570  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
571  head -15 dimphys.h
[42]572     ###
573     ### TEST new new phys
574     if [[ "${phys}" == "newphys_" ]]
575     then
[50]576       touch callkeys.h.meso 
[48]577         ln -sf meso_callkeys.h callkeys.h
[86]578       #touch dustlift.F.meso
579       #  ln -sf meso_dustlift.F dustlift.F  ## attention avec "ancienne nouvelle physique"
[50]580       touch readtesassim.F90.meso
[48]581         ln -sf meso_readtesassim.F90 readtesassim.F90  ## attention idem
[50]582       touch gr_fi_dyn.F.lien
[48]583         ln -sf ../dyn3d/gr_fi_dyn.F .  ## dommage, a corriger ## attention idem
[153]584     ###############################
585     ###############################
586\rm scatterers.h
587cat << EOF > scatterers.h
588!-----------------------------------------------------------------------
589!   INCLUDE 'scatterers.h'
590!
591! Number of kind of tracer radiative properties
592! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
593! (ex: naerkind=1 if you use one dust mode without ice ...)
594! (ex: naerkind=2 if you use one dust mode and active ice ...)
595!-----------------------------------------------------------------------
596
597      integer, parameter :: naerkind=${scat}
598
599!-----------------------------------------------------------------------
600EOF
601     ###############################
602     ###############################
[42]603     fi
604     ###
605     ###
[11]606  cd ../..
607
608  # prepare for nesting
609  #---------------------
610  cd libf
611  duplicate${dom} 2> /dev/null
612  cd ..
613
614  # compile physics
615  #--------------------------
616  \rm libf/grid/dimensions.h 2> /dev/null
617  \rm -rf libo/* 2> /dev/null
618  echo 1. compiling LMD physics ...
619  echo compilation info in:
620  echo $PWD/libo/log_compile_phys
621
622  if [ ${debug} -ne 0 ]
623  then
624    echo 'DEBUG DEBUG DEBUG DEBUG'
[86]625    nohup makegcm_${compilo} -debug -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
[11]626  else
[86]627    nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
[11]628  fi
629  echo ... done
630        # clean the duplicate routines
631        cd libf
632        duplicate1 2> /dev/null
633        cd ..
634
635  # merge LMD executables in one lib
636  #--------------------------------------
637  cd libo
638  mkdir temp
639  #cp -f LINUXfastI._${physz}_t${tra}_reg/*.a temp
640  cp -f LINUX*/*.a temp
641  cd temp
642  ar x libbibio.a
643  ar x libphymars.a
644  ar x libaeronomars.a
645  \rm *.a
646  ar r liblmd.a *
647  cp -f liblmd.a ..
648  cd ..
649  \rm -r temp
650  nm liblmd.a > liblmd_content
651  # finish merge
652  cd ..
653
654  # save a copy
655  #--------------
[153]656  cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra}_${scat}
[11]657  echo '****************************************'
658
659  # ok
660  #----
661  cd ..
662
663  # manage nest includes in module_lmd_driver.F
664  #----
665  cp call_meso_inifis$dom.inc call_meso_inifis.inc
666  cp call_meso_physiq$dom.inc call_meso_physiq.inc
667
668
669fi
670##################################################
671# END compile physics
672##################################################
673
674#------------------
675# compile WRF
676#------------------
677if [ ${justphys} -eq 0 ]
678then
679
680  echo 2. compiling WRF dynamical core ...
681
[156]682  if [[ "${phys}" == "nophys_" ]]
[11]683  then
[156]684   echo 'NO LMD PHYSICS included'
685  else
686   if [[ ! ( -f "call_meso_physiq.inc" ) ]]
687   then
688    echo 'did you compile the physics ? no call_meso_physiq.inc !'
689    exit
690   fi
[11]691  fi
692
693  # be sure to compile with the most recent physics
694  touch phys/module_lmd_driver.F
695
696  # talk to user
697  echo '>>> compiling ... this may be long ... <<<'
698  echo check progress in:
699  echo $PWD/log_compile
700  echo check possible errors in:
701  echo $PWD/log_error
702 
703  # compile ...
704  case ${config} in
[142]705    '')         compile em_real > log_compile 2> log_error
[11]706                    # save executables 
707                    cd main
[68]708                      if [[ -f real.exe ]]
709                      then
710                        echo 'Looks good ! real.exe is here...'
711                      fi
[11]712                      if [[ -f wrf.exe ]]
713                      then
714                        echo 'Looks good ! wrf.exe is here...'
715                      fi
[153]716                    cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
717                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
[11]718                    cd ..  ;;
[68]719    'ideal')        #mkdir 'test/em_quarter_ss' 2> /dev/null
[142]720                    echo '>>> YOUR CONFIG IS : '${config}
[11]721                    compile em_quarter_ss > log_compile 2> log_error
722                    # save executables 
723                    cd main
[68]724                      if [[ -f ideal.exe ]]
725                      then
726                        echo 'Looks good ! ideal.exe is here...'
727                      fi
[11]728                      if [[ -f wrf.exe ]]
729                      then
730                        echo 'Looks good ! wrf.exe is here...'
731                      fi
[153]732                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
733                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
[11]734                    cd ..  ;;
[142]735    'les')          echo '>>> YOUR CONFIG IS : '${config}
736                    mkdir 'test/em_les' 2> /dev/null                   
737                    compile em_les > log_compile 2> log_error
738                    # save executables 
739                    cd main
740                      if [[ -f ideal.exe ]]
741                      then
742                        echo 'Looks good ! ideal.exe is here...'
743                      fi
744                      if [[ -f wrf.exe ]]
745                      then
746                        echo 'Looks good ! wrf.exe is here...'
747                      fi
[153]748                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
749                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
[142]750                    cd ..  ;;
751    *)              echo not supported... please use ; echo ideal les ; exit ;;
[11]752  esac
753  echo '*******last lines from log_error*********'
754  tail -n 20 log_error
755fi
756
757  # the end
758  echo '****************************************'
759  echo 'done.'
760  echo '****************************************'
[153]761  cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}
[11]762  mv last ../../
763
764  # add here specific messages
765  if [[ "${dom}" != "1" ]]
766  then
767  nest=$(expr ${lon} + 4)
768  echo NB: in namelist.input, please set:
769  echo '
770  max_dom = '$dom'
771  s_we    = 1,1,
772  e_we    = '$lon','$nest',
773  s_sn    = 1,1,
774  e_sn    = '$lat','$nest',
775  s_vert  = 1,1,
776  e_vert  = '$level','$level','
777  fi
778
Note: See TracBrowser for help on using the repository browser.