source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 2087

Last change on this file since 2087 was 2058, checked in by jleconte, 7 years ago

on our way to compile mesoscale+generic with gfortran

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