source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1060

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

MESOSCALE. a modification of the makemeso script so that with newphys additional variables are output by default.

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