source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1486

Last change on this file since 1486 was 1448, checked in by aslmd, 9 years ago

MESOSCALE. include version of code. changed link to LATEST.

  • 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
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                       if [ ${debug} -ne 0 ]   # not working for xlf!
433                             then
434                             echo 'DEBUG DEBUG DEBUG DEBUG'
435                             sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
436                             mv -f yeah configure.wrf
437                       fi
438                       \rm conf > /dev/null ;;
439
440     #######
441     #######LES-specific (WRFV3-based) -- previously in 'makeles'   
442
443#######TEST TEST
444                     # GFORTRAN, 64 bits, no nesting     
445     gnu_64_single)    cd arch ; ln -sf ../configure.defaults.gfortran64 configure.defaults ; cd ..
446                       echo 15 | configure > log_compile 2> log_error
447                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf 
448                       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 ;;
449#######TEST TEST
450                     # PGF90, 32 bits, no nesting
451     pgf_32_single)    echo 1 | configure > log_compile 2> log_error
452                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
453                     # PGF90, 32 bits, nesting
454     pgf_32_nest)      echo 2 | configure > log_compile 2> log_error
455                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
456                     # PGF90, 64 bits, no nesting
457     pgf_64_single)    echo 1 | configure > log_compile 2> log_error
458                       #### the following line is necessary because readtesassim has a line "use netcdf" in it!
459                       #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
460                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
461                     # PGF90, 64 bits, nesting
462     pgf_64_nest)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
463                       echo 4 | configure > log_compile 2> log_error
464                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
465                     # G95, 32 bits, no nesting
466     g95_32_single)    echo 13 | configure > log_compile 2> log_error
467                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
468                     # G95, 64 bits, no nesting  ### we modify configure.defaults to add x86_64 next to g95 in the header comment
469     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 ..
470                       echo 14 | configure > log_compile 2> log_error
471                         ##### marche pas ....
472                         #sed s+"-fno-second-underscore"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
473                         #sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
474                         #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 ;;
475                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
476                       #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;;
477                     # IFORT, 64 bits, no nesting
478     ifort_64_single)  echo 5 | configure > log_compile 2> log_error
479                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
480                       if [ ${debug} -ne 0 ]   # not working for xlf!
481                             then
482                             echo 'DEBUG DEBUG DEBUG DEBUG'
483                             sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
484                             mv -f yeah configure.wrf
485                       fi
486                         ## !!! NETCDF must be defined
487                         sed s+"lio_grib_share"+"lio_grib_share -L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
488                         mv -f yeah configure.wrf ;;
489     mpifort_64)     # MPI+IFORT, 64 bits, no nesting / nesting
490                       echo 9 | configure > log_compile 2> log_error
491                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
492                       sed s+"-f90=ifort"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
493                       sed s+"-cc=icc"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
494                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
495                       sed s+"-O1"+"-O1 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
496                       sed s+"-O2"+"-O2 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
497                       sed s+"-O3"+"-O3 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
498                       if [ ${debug} -ne 0 ]   # not working for xlf!
499                             then
500                             echo 'DEBUG DEBUG DEBUG DEBUG'
501                             sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
502                             mv -f yeah configure.wrf
503                       fi
504                       sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf
505                                        #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf  ### pour compilation rapide
506                                        #-w -ftz -align all -fno-alias -fp-model precise >>> options indiquees dans WRF3
507                                        #http://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-wrf-with-the-intel-compilers/
508                            #### NB: RSL is replaced by RSL_LITE, better memory capacity, less seg fault
509                            sed s+"../external/RSL/RSL"+"../external/RSL_LITE"+g configure.wrf > yeah ; mv -f yeah configure.wrf
510                            sed s+"-DWRF_RSL_IO"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
511                            sed s+"-DRSL"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
512                            sed s+"librsl.a"+"librsl_lite.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
513                            sed s+"../external/RSL/gen"+"../external/RSL_LITE/gen"+g configure.wrf > yeah ; mv -f yeah configure.wrf
514                            sed s+"../external/RSL/module"+"../external/RSL_LITE/module"+g configure.wrf > yeah ; mv -f yeah configure.wrf
515                            sed s+"-lrsl"+"-lrsl_lite"+g configure.wrf > yeah ; mv -f yeah configure.wrf
516                            sed s+"linux"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
517                         ### necessary even if mpi-selector is used (no need in makegcm though)
518                         sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g > yeah ; mv -f yeah configure.wrf
519                         sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf
520                         ## !!! NETCDF must be defined
521                         sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
522                         mv -f yeah configure.wrf
523                         #### POUR LE TRAITEMENT PARTICULIERS des NESTS sur iDATAPLEX [cf. module_lmd_driver]
524                         sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DSPECIAL_NEST_SAVE "+g configure.wrf > yeah
525                         mv -f yeah configure.wrf ;;
526                     # MPICH, 64 bits, no nesting / nesting
527     mpi_64)           cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
528                       echo 3 | configure > log_compile 2> log_error
529                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
530                       ### the following line is necessary because readtesassim has a line "use netcdf" in it!
531                       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
532                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
533                       #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
534                                #| sed s+"fastsse"+"fast"+g > yeah
535                       mv -f yeah configure.wrf ;;
536                       #    #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
537                       #    ##sed s+"-fastsse"+"-O2 -fpic"+g configure.wrf > yeah ## marche pas, ILM problem
538                       #    ##sed s+"-fastsse"+"-mcmodel=medium -Mlarge_arrays"+g configure.wrf > yeah ## marche pas, ILM problem
539                       #sed s+"-fastsse"+"-O3 -tp=nehalem-64 -fastsse -Mscalarsse -Mvect=sse -Mipa=fast"+g configure.wrf > yeah
540                       #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
541                       #sed s+"-fastsse"+""+g configure.wrf > yeah
542                       #sed s+"-fastsse"+"-fast"+g configure.wrf > yeah
543                       #sed s+"-fastsse"+"-Mvect=noaltcode -Msmartalloc -Mprefetch=distance:8 -Mfprelaxed"+g configure.wrf > yeah
544                       #mv -f yeah configure.wrf ;;
545                     # MPICH, 64 bits, OK with periodic BC but no positive definite
546     mpi_64_test)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
547                       echo 2 | configure > log_compile 2> log_error
548                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
549                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
550                       mv -f yeah configure.wrf ;;
551                     # XLF+MPICH on AIX machine (64 bits) with nesting, NB: the 32bits notice is not to be considered
552     mpixlf_32)        cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
553                       echo 3 | configure > log_compile 2> log_error
554                       sed -f mars.sed configure.wrf > yeah
555                       mv -f yeah configure.wrf ;;
556                     # ANYTHING ELSE
557     *)                echo NO PRESETS ...
558                       if [ ${donotallow} -eq 0 ] 
559                       then
560                         configure
561                       else
562                         # problem when an input file is used
563                         echo 'please cd to '$PWD' and type ./configure' 
564                         exit   
565                       fi ;;
566  esac
567  ########################
568
569
570  ### here a case structure would be great
571
572  if [[ "${phys}" == "newphys_" ]]
573  then
574     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
575     then
576       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNEWPHYS "+g configure.wrf > yeah
577     else
578       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNEWPHYS "+g configure.wrf > yeah
579     fi
580     mv -f yeah configure.wrf
581  fi
582
583        ### SCENARIO SCENARIO SCENARIO
584        if [[ ! ("${scenario}" == "") ]]   ### not supported with LES for the moment?
585        then
586          # precompiling flag in WRF part
587          sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -D${scenario} "+g configure.wrf > yeah
588          mv -f yeah configure.wrf
589          # precompiling flag in LMD part
590          cd mars_lmd
591          cp -Lrf makegcm_${compilo} yeah
592          \rm makegcm_${compilo}
593          sed s+"-DMESOSCALE"+"-D${scenario} -DMESOSCALE"+ yeah > makegcm_${compilo}
594          chmod 755 makegcm_${compilo}
595          \rm yeah
596          cd ..
597        fi
598
599  ################
600  if [[ "${phys}" == "nophys_" ]]
601  then
602     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
603     then
604       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
605       sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
606     else
607       ### not tested yet but should be working 
608       echo CAUTION CAUTION CAUTION NOT FULLY TESTED
609       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
610       sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
611     fi
612  fi
613  ################
614
615  if [ ${debug} -ne 0 ]   # not working for xlf!
616  then
617    echo 'DEBUG DEBUG DEBUG DEBUG'
618    sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
619    #sed s+"# -g"+"-g -Ktrap=fp -Mbounds"+g configure.wrf > yeah
620    #sed s+"# -g"+"-g"+g configure.wrf > yeah
621    mv -f yeah configure.wrf
622  fi
623
624
625##################################################
626# compile physics
627##################################################
628if [ ${donotcompilephys} -eq 0 ]
629then
630
631  cd mars_lmd/
632
633 if [[ "${phys}" == "newphys_" ]]
634 then
635  divx=1
636  divy=1
637 else
638  # required size
639  #----------------
640  case ${numproc} in
641      1) divx=1 ; divy=1  ;;
642      2) divx=1 ; divy=2  ;;
643      4) divx=2 ; divy=2  ;;
644      6) divx=2 ; divy=3  ;;
645      8) divx=2 ; divy=4  ;;
646     12) divx=3 ; divy=4  ;;
647     16) divx=4 ; divy=4  ;;
648     20) divx=4 ; divy=5  ;;
649     24) divx=4 ; divy=6  ;;
650     32) divx=4 ; divy=8  ;;
651     64) divx=8 ; divy=8  ;;
652    128) divx=8 ; divy=16 ;;
653      *) echo not yet supported ; exit ;;
654  esac
655 fi
656  physx=$(expr ${lon} - 1)
657  restex=$(expr ${physx} \% ${divx})   
658  physy=$(expr ${lat} - 1)
659  restey=$(expr ${physy} \% ${divy})
660  if [[ ${restex} != 0 || ${restey} != 0 ]]
661  then
662     echo nx-1 shall be divided by ${divx}
663     echo ny-1 shall be divided by ${divy}
664     exit
665  fi
666  physx=$(expr ${physx} \/ ${divx})
667  physy=$(expr ${physy} \/ ${divy})
668  physz=$(expr ${level} - 1)
669
670  # change this if you change num_soil_layers in WRF
671  # -- default is 10
672  if [[ "${phys}" == "newphys_" ]]
673  then
674     soilsize=18 ## nouvelle physique. ne sert a rien ici. voir comsoil.
675  else
676     soilsize=10
677  fi
678
679  # GCM environment variables
680  #--------------------------
681  export LMDGCM=$PWD
682  export LIBOGCM=$PWD/libo
683
684  # generate the appropriate dimphys
685  #---------------------------------
686  cd libf/phymars
687  \rm dimphys.h 2> /dev/null
688  if [[ "${phys}" == "newphys_" ]]
689  then
690    ln -sf ../../meso_dimphys.h_ref . ## ne sert plus !!
691  else
692    physize=$(expr ${physx} \* ${physy})
693    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
694    head -15 dimphys.h
695  fi
696     ### TEST new new phys
697     if [[ "${phys}" == "newphys_" ]]
698     then
699       touch gr_fi_dyn.F.lien
700         ln -sf ../dyn3d/gr_fi_dyn.F .  ## dommage, a corriger
701     ###############################
702     ###############################
703     ###############################
704     fi
705     ###
706     ###
707  cd ../..
708
709  # prepare for nesting
710  #---------------------
711  cd libf
712  duplicate${dom} 2> /dev/null
713  cd ..
714
715  # compile physics
716  #--------------------------
717  \rm libf/grid/dimensions.h 2> /dev/null
718  \rm -rf libo/* 2> /dev/null
719  echo 1. compiling LMD physics ...
720  echo compilation info in:
721  echo $PWD/libo/log_compile_phys
722
723  if [ ${debug} -ne 0 ]
724  then
725    echo 'DEBUG DEBUG DEBUG DEBUG'
726    nohup makegcm_${compilo} -debug -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
727  else
728    nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
729  fi
730  echo ... done
731        # clean the duplicate routines
732        cd libf
733        duplicate1 2> /dev/null
734        cd ..
735
736  # merge LMD executables in one lib
737  #--------------------------------------
738  cd libo
739  mkdir temp
740  #cp -f LINUXfastI._${physz}_t${tra}_reg/*.a temp
741  cp -f LINUX*/*.a temp/
742  cd temp
743  ar x libbibio.a
744  ar x libphymars.a
745  ar x libaeronomars.a
746  \rm *.a
747  ar r liblmd.a *
748  cp -f liblmd.a ..
749  cd ..
750  \rm -r temp
751  nm liblmd.a > liblmd_content
752  # finish merge
753  cd ..
754
755  if [[ "${phys}" == "newphys_" ]]
756  then
757    # include modules for interfacing
758    mv *.mod ../inc/
759  fi
760
761  # save a copy
762  #--------------
763  cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra}
764  echo '****************************************'
765
766  # ok
767  #----
768  cd ..
769
770  # manage nest includes in module_lmd_driver.F
771  #----
772  cp call_meso_inifis$dom.inc call_meso_inifis.inc
773  cp call_meso_physiq$dom.inc call_meso_physiq.inc
774
775
776fi
777##################################################
778# END compile physics
779##################################################
780
781#------------------
782# compile WRF
783#------------------
784if [ ${justphys} -eq 0 ]
785then
786
787  echo 2. compiling WRF dynamical core ...
788
789  if [[ "${phys}" == "nophys_" ]]
790  then
791   echo 'NO LMD PHYSICS included'
792  else
793   if [[ ! ( -f "call_meso_physiq.inc" ) ]]
794   then
795    echo 'did you compile the physics ? no call_meso_physiq.inc !'
796    exit
797   fi
798  fi
799
800  # be sure to compile with the most recent physics
801  touch phys/module_lmd_driver.F
802
803  # talk to user
804  echo '>>> compiling ... this may be long ... <<<'
805  echo check progress in:
806  echo $PWD/log_compile
807  echo check possible errors in:
808  echo $PWD/log_error
809 
810  # compile ...
811  case ${config} in
812    '')         ./compile em_real > log_compile 2> log_error
813                    # save executables 
814                    cd main
815                      if [[ -f real.exe ]]
816                      then
817                        echo 'Looks good ! real.exe is here...'
818                      fi
819                      if [[ -f wrf.exe ]]
820                      then
821                        echo 'Looks good ! wrf.exe is here...'
822                      fi
823                    cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
824                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
825                    cd ..  ;;
826    'ideal')        #mkdir 'test/em_quarter_ss' 2> /dev/null
827                    echo '>>> YOUR CONFIG IS : '${config}
828                    ./compile em_quarter_ss > log_compile 2> log_error
829                    # save executables 
830                    cd main
831                      if [[ -f ideal.exe ]]
832                      then
833                        echo 'Looks good ! ideal.exe is here...'
834                      fi
835                      if [[ -f wrf.exe ]]
836                      then
837                        echo 'Looks good ! wrf.exe is here...'
838                      fi
839                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
840                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
841                    cd ..  ;;
842    'les')          echo '>>> YOUR CONFIG IS : '${config}
843                    mkdir 'test/em_les' 2> /dev/null                   
844                    ./compile em_les > log_compile 2> log_error
845                    # save executables 
846                    cd main
847                      if [[ -f ideal.exe ]]
848                      then
849                        echo 'Looks good ! ideal.exe is here...'
850                      fi
851                      if [[ -f wrf.exe ]]
852                      then
853                        echo 'Looks good ! wrf.exe is here...'
854                      fi
855                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
856                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
857                    cd ..  ;;
858    *)              echo not supported... please use ; echo ideal les ; exit ;;
859  esac
860  echo '*******last lines from log_error*********'
861  tail -n 20 log_error
862fi
863
864  # the end
865  echo '****************************************'
866  echo 'done.'
867  echo '****************************************'
868  cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}
869  mv last ../../
870  svn info ../../ > ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.svn.info
871
872
873
874  # link latest compiled folder as LATEST
875  cd ../../
876  rm -rf LATEST
877  ln -sf ${conf_wrf} LATEST
878
879  # add here specific messages
880  if [[ "${dom}" != "1" ]]
881  then
882  nest=$(expr ${lon} + 4)
883  echo NB: in namelist.input, please set:
884  echo '
885  max_dom = '$dom'
886  s_we    = 1,1,
887  e_we    = '$lon','$nest',
888  s_sn    = 1,1,
889  e_sn    = '$lat','$nest',
890  s_vert  = 1,1,
891  e_vert  = '$level','$level','
892  fi
893
Note: See TracBrowser for help on using the repository browser.