source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1234

Last change on this file since 1234 was 1234, checked in by aslmd, 12 years ago

MESOSCALE. A new formulation for module_lmd_driver (for newphys). We make use of modules from the LMD physics to fill arrays instead of using additional arguments. Also cleaned the place a bit. What remains to be done is handling nesting but the new formulation makes it hopefully easier than before -- without the need to duplicate/compile several times physical parameterizations for each nest. For now the model works with this new interface without nesting.

  • Property svn:executable set to *
File size: 36.2 KB
Line 
1#! /bin/bash
2
3
4##################################
5# makemeso allows you to compile #
6# WRF with modified LMD physics  #
7##################################
8
9##############################
10# Author: A. Spiga           #
11# New version : October 2008 #
12# Last update : January 2009 #
13#               November  09 #
14#               January   11 #
15##############################
16
17###############################
18#### Type makemeso -h for help
19###############################
20
21
22
23##############################################################################################
24##############################################################################################
25##############################################################################################
26##############################################################################################
27
28donotcompile=0
29donotallow=0
30config=''
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  # ngrid: now dynamically set in newphys 03/2014
137   if [[ "${phys}" == "newphys_" ]]
138   then
139      lon=999
140      lat=999
141      numproc=999
142   fi
143  echo Number of vertical levels ? ; read level
144  fi
145  echo Number of domains ? ; read dom
146
147###PB lecture dom si < last
148
149    case ${dom} in
150       1) single='_single' ;;
151       *) single='_nest' ;;
152    esac
153      if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
154      then
155           single=''
156      fi
157
158testflag=''
159####
160#testflag='_test'
161####
162
163    conf_wrf="${config}${scenario}${phys}${compilo}_${machine}${single}${testflag}"
164
165    if [ ${debug} -eq 1 ]
166    then
167     conf_wrf="debug_${conf_wrf}"
168    fi
169
170    \rm what_folder 2> /dev/null
171    echo ${conf_wrf} > what_folder
172         if [ ${donotcompile} -eq 1 ]
173         then
174            #\rm what_folder 2> /dev/null
175            #echo '**********************'
176            #echo '*** Your folder is ...'
177            #echo '**********************'
178            #echo ${conf_wrf} | tee what_folder
179            #cat what_folder
180            #echo ${conf_wrf} > what_folder
181            #echo ${reply} > what_compilo
182            #echo ${numproc} > what_numproc
183            if [[ "${phys}" != "nophys_" ]]
184            then
185              exit
186            fi
187         else
188            echo Number of tracers ? ; read tra
189            # tracers: now dynamically set in newphys 09/2013
190            if [[ "${phys}" == "newphys_" ]]
191            then
192              tra=999
193            else
194              if [ ${tra} -eq 0 ]
195              then
196                tra=1   
197              fi
198            fi
199            # scatterers: a specific stuff for newphys
200            if [[ "${phys}" == "newphys_" ]]
201            then
202              echo "How many types of scatterer are you using ? 1 [dust] or 2 [dust + water ice]" ; read scat
203            else
204              scat=1 ## dummy stuff
205            fi
206         fi
207  # 'from scratch' case
208  if [ ${from_scratch} -eq 1 ]
209  then
210      echo "***** I ERASE THE FOLDER "${conf_wrf}
211      \rm -rf ${conf_wrf}
212  fi
213  # folder
214  mkdir ${conf_wrf} 2> /dev/null
215  if [[ "$?" == 0 ]]
216  then
217    echo new folder ... link sources
218    if [[ "${phys}" == "newphys_" ]]
219    then
220     \rm copy_model_tmp > /dev/null 2> /dev/null
221        if [[ "${scenario}" == "" ]]
222        then
223          sed s+"mars_lmd"+"mars_lmd_new"+g             SRC/SCRIPTS/copy_model > copy_model_tmp
224        else
225          echo SCENARIO ${scenario} DID YOU INCLUDE THE SPECIFIC folder ? ; read dummy
226          sed s+"mars_lmd"+"mars_lmd_new_${scenario}"+g SRC/SCRIPTS/copy_model > copy_model_tmp
227             if [[ "${config}" == "les" ]]
228             then
229              echo "NOT SUPPORTED, check options"
230              exit
231             fi
232        fi
233        if [[ "${config}" == "les" ]]
234        then
235         sed s+"PWD/SRC/"+"PWD/SRC/LES/"+g copy_model_tmp > yeah
236         mv yeah copy_model_tmp
237        fi
238     chmod 755 copy_model_tmp
239     ./copy_model_tmp
240     \rm copy_model_tmp
241     mv zeWRFV2 ${conf_wrf}/WRFV2
242     cd ${conf_wrf}/WRFV2
243        if [[ "${scenario}" == "" ]]
244        then
245          ln -sf mars_lmd_new mars_lmd
246          if [[ "${phys}" == "newphys_" ]]
247          then
248              cp ../../SRC/WRFV2/Registry/Registry.EM.newphys Registry/Registry.EM
249          fi
250          cd phys
251          ln -sf module_lmd_driver.F.new module_lmd_driver.F
252          cd ..
253        else
254          ln -sf mars_lmd_new_${scenario} mars_lmd
255          cp ../../SRC/WRFV2/mars_lmd_new_${scenario}/Registry.EM mars_lmd_new_${scenario}/
256          cp ../../SRC/WRFV2/mars_lmd_new_${scenario}/*.inc mars_lmd_new_${scenario}/
257          cd Registry ; ln -sf ../mars_lmd_new_${scenario}/Registry.EM . ; cd ..
258        fi
259     #ln -sf meso_callkeys_newphys.h meso_callkeys.h
260     cd Registry ; Registry.bash ; cd ..
261
262     # remove files adapted to parallel GCM and useless for mesoscale
263     cd mars_lmd
264     cd libf/phymars
265     \rm tabfi* soil_settings* phyetat0* phyredem* iostart* writediagfi* mkstat* writediagsoil* eofdump* wstats* inistats* mod_*
266     \rm iniphysiq* init_phys_lmdz* comgeomphy* planetwide_mod*
267     mv ../dyn3d/control_mod.F90 .
268     cd ../..
269     cd ..
270
271    else
272         if [[ "${config}" == "les" ]]
273         then
274           ### NB: With physics: LES folder // Without physics : LESnophys_ folder
275           ### ---- because differences in 'modif' folder ----
276           sed s+"PWD/SRC/"+"PWD/SRC/LES$phys/"+g SRC/SCRIPTS/copy_model > copy_model_tmp
277         else
278           cp SRC/SCRIPTS/copy_model copy_model_tmp
279         fi   
280     chmod 755 copy_model_tmp
281     ./copy_model_tmp
282     \rm copy_model_tmp
283     mv zeWRFV2 ${conf_wrf}/WRFV2
284     cd ${conf_wrf}/WRFV2
285     cd Registry ; ./Registry.bash ; cd ..
286     fi
287          #### sparadrap consequent a l'utilisation de copy_model pour les liens
288          #### -- car alors il manque fftpack
289          if [[ "${config}" == "les" ]]
290          then
291            if [[ "${phys}" == "nophys_" ]]
292            then
293              ## voir ci-dessus pour le folder
294              cp ../../SRC/LES$phys/correcfft ./
295            else
296              cp ../../SRC/LES/correcfft ./
297            fi 
298            ./correcfft
299            \rm correcfft
300          fi
301  else
302    cd ${conf_wrf}/WRFV2
303    if [ ${fresh_start} -eq 1 ]
304    then
305      echo '*** FRESH START, I clean everything'
306      ### clean the whole place 
307      clean -a > /dev/null 2> /dev/null
308      ### get a possibly modified registry !
309      if [[ "${scenario}" == "" ]]
310      then
311        if [[ "${phys}" == "newphys_" ]]
312        then
313            cp ../../SRC/WRFV2/Registry/Registry.EM.newphys Registry/Registry.EM
314        else
315            cp ../../SRC/WRFV2/Registry/Registry.EM Registry/
316        fi
317      fi
318      if [[ "${config}" == "les" ]]
319      then
320        cp ../../SRC/LES/WRFV2/Registry/Registry.EM Registry/
321      fi
322      ### ensure the model will be recompiled from scratch with correct registry
323      cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd ..
324#     answer='y' ## a voir... pas si sur
325#    else
326#            if [[ "${phys}" != "nophys_" ]]
327#            then
328#      echo Did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer
329#      case ${answer} in
330#        y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;;
331#        *) answer='no' ;;
332#      esac
333#            fi
334    fi
335  fi
336
337  # summary
338  echo '**********************'
339  echo '*** Your folder is ...'
340  echo '**********************'
341  echo ${conf_wrf}
342  echo '**********************'
343  echo '****************************************'
344  echo so ...
345  echo your computer is ${machine} bits
346  echo ${compilo} is your compiler
347       if [[ "${compilo}" = "mpi" ]]
348       then
349         echo MPICH is in ${WHERE_MPI}
350       fi
351  echo you will use ${numproc} processors
352  echo you have ${lon} x points
353  echo '         '${lat} y points
354  echo '         '${level} z points
355  echo '         '${dom} domains
356  echo '         '${tra} tracers
357  if [[ "${phys}" == "newphys_" ]]
358  then
359    echo '         '${scat} scatterers
360  fi
361  echo '****************************************'
362  # save answer
363  \rm last 2> /dev/null
364  touch last
365  echo ${reply} >> last
366     if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
367     then
368     echo ${numproc} >> last
369     fi
370  echo ${lon} >> last
371  echo ${lat} >> last
372  echo ${level} >> last
373  echo ${dom} >> last
374  echo ${tra} >> last
375  echo ${scat} >> last
376  #echo ${answer} >> last
377
378#------------
379# log files
380#------------
381  \rm log_compile 2> /dev/null
382  \rm log_error 2> /dev/null
383
384#-----------------
385# configure WRF
386#-----------------
387  mv configure.wrf configure.wrf.bak 2> /dev/null
388  ########################
389  conf_wrf_forall="${compilo}_${machine}${single}${testflag}"
390
391         #### in this case options are different because for LES, WRFV3 is used
392         if [[ "${config}" == "les" ]]
393         then
394         conf_wrf_forall="${config}${compilo}_${machine}${single}${testflag}"
395         fi
396
397  case ${conf_wrf_forall} in
398
399     #######LES-specific (WRFV3-based) -- previously in 'makeles'
400     #######
401
402     lesmpi_64)        ## MPI (dm) 64 bits [PS: remplacer 3 par 4 pour openMP]
403                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 3 >> conf ; echo 1 >> conf
404                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
405                       sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
406                       if [[ "$(hostname)" == "ciclad1.ipsl.jussieu.fr" ]]
407                       then
408            echo "SPECIFIC CHANGES FOR CICLAD CLUSTER. EDIT makemeso IF YOU ENCOUNTER PROBLEMS."
409            #sed s+"mpif90 -f90=$(SFC)"+"/usr/lib64/openmpi/1.4.2-pgf/bin/mpif90"+g                      configure.wrf > yeah ; mv -f yeah configure.wrf
410            #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
411            sed s+"mpif90 -f90=\$(SFC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpif90"+g                   configure.wrf > yeah ; mv -f yeah configure.wrf
412            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
413                       else
414            #sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
415            #sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
416            #### OPENMPI
417            sed s+"mpif90 -f90=\$(SFC)"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
418            sed s+"mpicc -cc=\$(SCC)"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
419                       fi
420                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
421                          ### pas forcement necessaire ici mais OK
422                          sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
423                       \rm conf > /dev/null ;;
424
425     lesmpifort_64)    ## MPI (dm) 64 bits IFORT
426                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 7 >> conf ; echo 1 >> conf
427                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
428                       sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
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                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
432                       sed s+"O3"+"O3 -mcmodel=large -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
433                       sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
434                       if [ ${debug} -ne 0 ]   # not working for xlf!
435                             then
436                             echo 'DEBUG DEBUG DEBUG DEBUG'
437                             sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
438                             mv -f yeah configure.wrf
439                       fi
440                       \rm conf > /dev/null ;;
441
442     #######
443     #######LES-specific (WRFV3-based) -- previously in 'makeles'   
444
445#######TEST TEST
446                     # GFORTRAN, 64 bits, no nesting     
447     gnu_64_single)    cd arch ; ln -sf ../configure.defaults.gfortran64 configure.defaults ; cd ..
448                       echo 15 | configure > log_compile 2> log_error
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#######TEST TEST
452                     # PGF90, 32 bits, no nesting
453     pgf_32_single)    echo 1 | configure > log_compile 2> log_error
454                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
455                     # PGF90, 32 bits, nesting
456     pgf_32_nest)      echo 2 | configure > log_compile 2> log_error
457                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
458                     # PGF90, 64 bits, no nesting
459     pgf_64_single)    echo 1 | configure > log_compile 2> log_error
460                       #### the following line is necessary because readtesassim has a line "use netcdf" in it!
461                       #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
462                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
463                     # PGF90, 64 bits, nesting
464     pgf_64_nest)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
465                       echo 4 | configure > log_compile 2> log_error
466                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
467                     # G95, 32 bits, no nesting
468     g95_32_single)    echo 13 | configure > log_compile 2> log_error
469                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
470                     # G95, 64 bits, no nesting  ### we modify configure.defaults to add x86_64 next to g95 in the header comment
471     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 ..
472                       echo 14 | configure > log_compile 2> log_error
473                         ##### marche pas ....
474                         #sed s+"-fno-second-underscore"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
475                         #sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
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                       #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;;
479                     # IFORT, 64 bits, no nesting
480     ifort_64_single)  echo 5 | configure > log_compile 2> log_error
481                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
482                       if [ ${debug} -ne 0 ]   # not working for xlf!
483                             then
484                             echo 'DEBUG DEBUG DEBUG DEBUG'
485                             sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
486                             mv -f yeah configure.wrf
487                       fi
488                         ## !!! NETCDF must be defined
489                         sed s+"lio_grib_share"+"lio_grib_share -L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
490                         mv -f yeah configure.wrf ;;
491     mpifort_64)     # MPI+IFORT, 64 bits, no nesting / nesting
492                       echo 9 | configure > log_compile 2> log_error
493                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
494                       sed s+"-f90=ifort"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
495                       sed s+"-cc=icc"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
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                       sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf
504                                        #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf  ### pour compilation rapide
505                                        #-w -ftz -align all -fno-alias -fp-model precise >>> options indiquees dans WRF3
506                                        #http://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-wrf-with-the-intel-compilers/
507                            #### NB: RSL is replaced by RSL_LITE, better memory capacity, less seg fault
508                            sed s+"../external/RSL/RSL"+"../external/RSL_LITE"+g configure.wrf > yeah ; mv -f yeah configure.wrf
509                            sed s+"-DWRF_RSL_IO"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
510                            sed s+"-DRSL"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
511                            sed s+"librsl.a"+"librsl_lite.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
512                            sed s+"../external/RSL/gen"+"../external/RSL_LITE/gen"+g configure.wrf > yeah ; mv -f yeah configure.wrf
513                            sed s+"../external/RSL/module"+"../external/RSL_LITE/module"+g configure.wrf > yeah ; mv -f yeah configure.wrf
514                            sed s+"-lrsl"+"-lrsl_lite"+g configure.wrf > yeah ; mv -f yeah configure.wrf
515                            sed s+"linux"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
516                         ### necessary even if mpi-selector is used (no need in makegcm though)
517                         sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g > yeah ; mv -f yeah configure.wrf
518                         sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf
519                         ## !!! NETCDF must be defined
520                         sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
521                         mv -f yeah configure.wrf
522                         #### POUR LE TRAITEMENT PARTICULIERS des NESTS sur iDATAPLEX [cf. module_lmd_driver]
523                         sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DSPECIAL_NEST_SAVE "+g configure.wrf > yeah
524                         mv -f yeah configure.wrf ;;
525                     # MPICH, 64 bits, no nesting / nesting
526     mpi_64)           cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
527                       echo 3 | configure > log_compile 2> log_error
528                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
529                       ### the following line is necessary because readtesassim has a line "use netcdf" in it!
530                       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
531                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
532                       #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
533                                #| sed s+"fastsse"+"fast"+g > yeah
534                       mv -f yeah configure.wrf ;;
535                       #    #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
536                       #    ##sed s+"-fastsse"+"-O2 -fpic"+g configure.wrf > yeah ## marche pas, ILM problem
537                       #    ##sed s+"-fastsse"+"-mcmodel=medium -Mlarge_arrays"+g configure.wrf > yeah ## marche pas, ILM problem
538                       #sed s+"-fastsse"+"-O3 -tp=nehalem-64 -fastsse -Mscalarsse -Mvect=sse -Mipa=fast"+g configure.wrf > yeah
539                       #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
540                       #sed s+"-fastsse"+""+g configure.wrf > yeah
541                       #sed s+"-fastsse"+"-fast"+g configure.wrf > yeah
542                       #sed s+"-fastsse"+"-Mvect=noaltcode -Msmartalloc -Mprefetch=distance:8 -Mfprelaxed"+g configure.wrf > yeah
543                       #mv -f yeah configure.wrf ;;
544                     # MPICH, 64 bits, OK with periodic BC but no positive definite
545     mpi_64_test)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
546                       echo 2 | configure > log_compile 2> log_error
547                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
548                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
549                       mv -f yeah configure.wrf ;;
550                     # XLF+MPICH on AIX machine (64 bits) with nesting, NB: the 32bits notice is not to be considered
551     mpixlf_32)        cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
552                       echo 3 | configure > log_compile 2> log_error
553                       sed -f mars.sed configure.wrf > yeah
554                       mv -f yeah configure.wrf ;;
555                     # ANYTHING ELSE
556     *)                echo NO PRESETS ...
557                       if [ ${donotallow} -eq 0 ] 
558                       then
559                         configure
560                       else
561                         # problem when an input file is used
562                         echo 'please cd to '$PWD' and type ./configure' 
563                         exit   
564                       fi ;;
565  esac
566  ########################
567
568
569  ### here a case structure would be great
570
571  if [[ "${phys}" == "newphys_" ]]
572  then
573     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
574     then
575       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNEWPHYS "+g configure.wrf > yeah
576     else
577       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNEWPHYS "+g configure.wrf > yeah
578     fi
579     mv -f yeah configure.wrf
580  fi
581
582        if [[ ! ("${scenario}" == "") ]]   ### not supported with LES for the moment
583        then
584          sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -D${scenario} "+g configure.wrf > yeah
585          mv -f yeah configure.wrf
586        fi
587
588  ################
589  if [[ "${phys}" == "nophys_" ]]
590  then
591     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
592     then
593       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
594       sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
595     else
596       ### not tested yet but should be working 
597       echo CAUTION CAUTION CAUTION NOT FULLY TESTED
598       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
599       sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
600     fi
601  fi
602  ################
603
604  if [ ${debug} -ne 0 ]   # not working for xlf!
605  then
606    echo 'DEBUG DEBUG DEBUG DEBUG'
607    sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
608    #sed s+"# -g"+"-g -Ktrap=fp -Mbounds"+g configure.wrf > yeah
609    #sed s+"# -g"+"-g"+g configure.wrf > yeah
610    mv -f yeah configure.wrf
611  fi
612
613
614##################################################
615# compile physics
616##################################################
617if [ ${donotcompilephys} -eq 0 ]
618then
619
620  cd mars_lmd/
621
622 if [[ "${phys}" == "newphys_" ]]
623 then
624  divx=1
625  divy=1
626 else
627  # required size
628  #----------------
629  case ${numproc} in
630      1) divx=1 ; divy=1  ;;
631      2) divx=1 ; divy=2  ;;
632      4) divx=2 ; divy=2  ;;
633      6) divx=2 ; divy=3  ;;
634      8) divx=2 ; divy=4  ;;
635     12) divx=3 ; divy=4  ;;
636     16) divx=4 ; divy=4  ;;
637     20) divx=4 ; divy=5  ;;
638     24) divx=4 ; divy=6  ;;
639     32) divx=4 ; divy=8  ;;
640     64) divx=8 ; divy=8  ;;
641    128) divx=8 ; divy=16 ;;
642      *) echo not yet supported ; exit ;;
643  esac
644 fi
645  physx=$(expr ${lon} - 1)
646  restex=$(expr ${physx} \% ${divx})   
647  physy=$(expr ${lat} - 1)
648  restey=$(expr ${physy} \% ${divy})
649  if [[ ${restex} != 0 || ${restey} != 0 ]]
650  then
651     echo nx-1 shall be divided by ${divx}
652     echo ny-1 shall be divided by ${divy}
653     exit
654  fi
655  physx=$(expr ${physx} \/ ${divx})
656  physy=$(expr ${physy} \/ ${divy})
657  physz=$(expr ${level} - 1)
658
659  # change this if you change num_soil_layers in WRF
660  # -- default is 10
661  if [[ "${phys}" == "newphys_" ]]
662  then
663     soilsize=18 ## nouvelle physique. ne sert a rien ici. voir comsoil.
664  else
665     soilsize=10
666  fi
667
668  # GCM environment variables
669  #--------------------------
670  export LMDGCM=$PWD
671  export LIBOGCM=$PWD/libo
672
673  # generate the appropriate dimphys
674  #---------------------------------
675  cd libf/phymars
676  \rm dimphys.h 2> /dev/null
677  if [[ "${phys}" == "newphys_" ]]
678  then
679    ln -sf meso_inc/meso_dimphys.h_ref .
680  fi
681  physize=$(expr ${physx} \* ${physy})
682  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
683  head -15 dimphys.h
684     ### TEST new new phys
685     if [[ "${phys}" == "newphys_" ]]
686     then
687       touch gr_fi_dyn.F.lien
688         ln -sf ../dyn3d/gr_fi_dyn.F .  ## dommage, a corriger
689     ###############################
690\rm scatterers.h
691cat << EOF > scatterers.h
692!-----------------------------------------------------------------------
693!   INCLUDE 'scatterers.h'
694!
695! Number of kind of tracer radiative properties
696! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
697! (ex: naerkind=1 if you use one dust mode without ice ...)
698! (ex: naerkind=2 if you use one dust mode and active ice ...)
699!-----------------------------------------------------------------------
700
701      integer, parameter :: naerkind=${scat}
702
703!-----------------------------------------------------------------------
704EOF
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}_${scat}
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}_s${scat}.exe
827                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.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}_s${scat}.exe
843                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.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}_s${scat}.exe
859                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.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}_s${scat}
872  mv last ../../
873  svn info ../../ > ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.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.