source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 158

Last change on this file since 158 was 158, checked in by aslmd, 13 years ago

MESOSCALE: MAJ scripts compilation et execution.

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