source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1596

Last change on this file since 1596 was 1590, checked in by aslmd, 8 years ago

moved interface for outputs from module_lmd_driver to update_outputs_physiq_mod. updated the nophysics case by adding a case dynphy_wrf_void_lmd_new which will serve as a template for a physiq interface

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