source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 2054

Last change on this file since 2054 was 2037, checked in by aslmd, 6 years ago

bug fix on makemeso introduced in commits for generic coupling

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