source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1248

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

MESOSCALE. Adapted the mesoscale model to previous commit to LMD GCM physics where number of scatterers is no longer set at compiling time.

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