source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1421

Last change on this file since 1421 was 1411, checked in by aslmd, 10 years ago

MESOSCALE: a change in lmd_driver to get the right amount of dust in DUSTSTORM mode. changed makemeso to allow for a simple compilation with option -s DUSTSTORM

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