source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1354

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

MESOSCALE. adapted scripts and manual for free vertical levels.

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