source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1524

Last change on this file since 1524 was 1489, checked in by aslmd, 9 years ago

corrected a strange cyclic sed in makemeso when compiling LES on ifort

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