Changeset 1704 for BOL


Ignore:
Timestamp:
Dec 21, 2012, 3:43:16 PM (11 years ago)
Author:
Laurent Fairhead
Message:

Simplified version for svn >=1700
FH

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOL/script_install/instal1d.sh

    r1693 r1704  
    11#!/bin/ksh
     2
     3###############################################################################
     4# Script for installing a 1D version of LMDZ.
     5# LMDZ team. For questions : lmdz-svp@lmd.jussieu.fr
     6# valid for svn version from 21/12/2012 (end of the world) or svn 1700
    27#
    3 #   Script d'installation de LMDZ_1D, pour la version trunk
    4 # du 07 Octobre 2011 (=1575) et au-dela.
    5 #   ATTENTION : la prise en compte de l'heure de démarrage n'existe que dans les versions
    6 # postérieures au 3 Novembre 2011 (=1577).
    7 #   Le script est conçu pour fonctionner aussi avec des versions antérieures mais ce n'est
    8 # pas testé : Use at your own risk!
    9 #
    10 #Directory où est place le modele installé par install.sh
     8# 1) Modifies the directory LMDZ.../modipsl/modeles/LMDZ5/libf/phy1d
     9# which  contains the single column version of the model.
     10# 2) installs a series of test cases on LMDZ.../1dcases/
     11# 3) compile the lmdz1.F with vertical resolution L39 and L40
     12# 4) runs a subset of the cases
     13###############################################################################
    1114
     15modele=""
     16if [ "$modele" = "" ] ; then
     17   if [ -f install.sh ] ; then
     18      version=`sed -n "s/version=//p" install.sh | tail -1`
     19      echo $version
     20      modele=`pwd`/LMDZ${version}
     21   elif [ -d modipsl ] ; then
     22      modele=`pwd`
     23   else
     24      echo "You should run instal1d.sh either in the directory"
     25      echo "containing install.sh, or in that containing modipsl"
     26      echo "or specify the path of LMDZ. modele=LMDZ... in instal1d.sh"
     27      exit
     28   fi
     29fi
    1230
    13 version=`sed -n "s/version *=//p" install.sh`
    14 echo $version
    15 modele=`pwd`/LMDZ${version}
    16 #Les directories de simulation seront placés sous $modele/1dcases .
    17 #Le code physique sera place sous $modele/modipsl/modeles/LMDZ5/libf/.
    18 #
     31###############################################################################
     32# Paths of main directories
     33# Directories of simulations will be placed in
     34# $modele/1dcases
     35# Sources of physical routines in  $modele/modipsl/modeles/LMDZ5/libf/phy1d
     36###############################################################################
    1937cd $modele
    20 #
    2138LMDGCM=`pwd`
     39LMDlibf=$LMDGCM/modipsl/modeles/LMDZ5/libf/
    2240
     41###############################################################################
     42# Check if the svn version is more recent than 1700
     43# If not, an  older script must be used
     44###############################################################################
     45cd $LMDGCM/modipsl/modeles
     46new1d=`svn info LMDZ5 | grep Revision | awk ' { fl = 0 ; if ( $2 > 1699 )  fl=1 ; print fl } '`
     47echo new1d $new1d
     48if [ $new1d = 0 ] ; then
     49   echo Your model verison is too old for this instal1d.sh script
     50   echo You should use instead
     51   echo http://www.lmd.jussieu.fr/~lmdz/Distrib/install_old_archive/instal1d.sh
     52   exit
     53fi
    2354
     55###############################################################################
     56# Downloading modified source files and input files
     57###############################################################################
     58cd $LMDGCM
     59interne=no # can be modified once the files have been downloaded
     60           # in order to take them directly on your computer
     61if [ $interne = no ] ; then
     62   wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/lmdz1d_source_20121016.tar.gz
     63   tar xvfz lmdz1d_source_20121016.tar.gz
     64   rm -f lmdz1d_source_20121016.tar.gz
     65   source=${LMDGCM}/lmdz1d_source_20121016
     66else
     67   cp -a /home/jygz/LMDZ/SLMDZ/LMDZ5_source_20120112/lmdz1d_source_20120112 .
     68   source=${LMDGCM}/lmdz1d_source_20120112
     69fi
    2470
    25 ##########################################################################################
    26 # Recuperation des sources du modele 1D et des cas.
    27 
    28 cd $LMDGCM/modipsl/modeles/LMDZ5/libf/
    29 LMDlibf=`pwd`
    30 cd $LMDGCM
    31 # On va chercher les fichiers
    32 interne=no
    33 ###interne=yes
    34 if [ $interne = no ]
    35 then
    36  wget http://www.lmd.jussieu.fr/~lmdz/DistribG95/lmdz1d_source_20121016.tar.gz
    37  tar xvfz lmdz1d_source_20121016.tar.gz
    38  rm -f lmdz1d_source_20121016.tar.gz
    39  source=${LMDGCM}/lmdz1d_source_20121016
    40 else
    41  cp -a /home/jygz/LMDZ/SLMDZ/LMDZ5_source_20120112/lmdz1d_source_20120112 .
    42  source=${LMDGCM}/lmdz1d_source_20120112
    43 fi
    44 #
    45 
    46 ##########################################################################################
    47 # Creation des repertoires des cas.
    48 ##########################################################################################
    49 
    50 if [ -f 1dcases ]
    51 then
     71################################################################################
     72# Creating directory for 1d cases
     73################################################################################
     74if [ -f 1dcases ] ; then
    5275  echo '1dcases existe deja'
    5376  echo 'on continue'
     
    5881cd 1dcases
    5982
    60 
    6183for cas in ayotte eq_rd_cv case_e hapex92_init twpice toga rico arm_cu ; do
    62    if [ -f $cas ]
    63    then
     84   if [ -f $cas ] ; then
    6485      echo $cas existe deja
    6586      echo 'on continue, mais il  faudra verifier qu il ne manque rien dans '$cas
     
    7293
    7394
    74 ##########################################################################################
    75 # On teste si la version svn est plus recentes que la 1640 pour la gestion du 1D
    76 cd $LMDGCM/modipsl/modeles
    77 new1d=`svn info LMDZ5 | grep Revision | awk ' { fl = 0 ; if ( $2 > 1640 )  fl=1 ; print fl } '`
    7895
     96################################################################################
     97# Installing source files and compiling
     98################################################################################
     99cd $LMDlibf
     100chmod +x ../tools/install_1d_src.sh
     101../tools/install_1d_src.sh
    79102
    80 if [ $new1d = 1 ] ; then
    81 
    82 cd $LMDlibf
    83 wget http://lmdz.lmd.jussieu.fr/utilisateurs/outils/utilisation-de-lmdz/install_1d_src-sh
    84 chmod +x install_1d_src-sh
    85 ./install_1d_src-sh
    86 
    87 
    88 else
    89 ##########################################################################################
    90 # Ancienne gestion des sources 1D avec corrections.
    91 # Voir commemnt faire cohabiter une partie de cette facon de faire avec la nouvelle
    92 
    93 cd ${LMDlibf}
    94 if [ -d phy1d ]
    95 then
    96  echo 'phy1d existe deja'
    97  echo 'on continue'
    98  cd phy1d
    99  echo 'on cree le lien vers ../dyn3d/mod_const_para.F90 si necessaire'
    100  if [ ! -f mod_const_para.F90 ]
    101  then
    102   ln -s ../dyn3d/mod_const_para.F90  mod_const_para.F90
    103   ln -s ../dyn3d/infotrac.F90        infotrac.F90
    104   ln -s ../dyn3d/conf_gcm.F          conf_gcm.F
    105   ln -s ../dyn3d/pres2lev.F90        pres2lev.F90
    106   ln -s ../dyn3d/control_mod.F90     control_mod.F90
    107   ln -s ../dyn3d/q_sat.F             q_sat.F
    108  fi
    109 else
    110  \rm -rf phy1d
    111  echo 'creation du directory phy1d'
    112  mkdir phy1d
    113  echo copie de phylmd dans phy1d
    114  cp -a phylmd/* phy1d
    115  cp -a ${source}/phy1d_source/* phy1d
    116  cp -af ${source}/phy1d_source_upd/* phy1d
    117  cd phy1d
    118  ln -s ../dyn3d/mod_const_para.F90  mod_const_para.F90
    119  ln -s ../dyn3d/infotrac.F90        infotrac.F90
    120  ln -s ../dyn3d/conf_gcm.F          conf_gcm.F
    121  ln -s ../dyn3d/pres2lev.F90        pres2lev.F90
    122  ln -s ../dyn3d/control_mod.F90     control_mod.F90
    123  ln -s ../dyn3d/q_sat.F             q_sat.F
    124 #
    125  grep -i "subroutine *writelim" *.F *.F90 >/dev/null
    126  if [ "$?" = "0" ]
    127  then
    128   echo Use writelim free version of 1DUTILS.h
    129   mv 1DUTILS.h_no_writelim 1DUTILS.h
    130  else
    131   echo Use 1DUTILS.h version including subroutine writelim
    132   mv 1DUTILS.h_with_writelim 1DUTILS.h
    133   rm -f ttt
    134   sed -e "s/^ *call *writelim *( *1 *,/      call writelim (/" lmdz1d.F >ttt
    135   rm -f lmdz1d.F
    136   mv ttt lmdz1d.F
    137  fi
    138  rm -f 1DUTILS.h*writelim
    139 #
    140 ############################################################################
    141 #                                                                          #
    142 #               CORRECTIONS spécifiques au 1D                              #
    143 #                                                                          #
    144 ############################################################################
    145 #
    146  echo Update physiq.F and suppress lambda_th
    147  rm -f physiq.F
    148  sed -e "/add_phys_tend.*_vdf/s/add_phys_tend/add_pbl_tend/;" ../phylmd/physiq.F >physiq.F.ori
    149 #
    150  echo Update phys_output_mod.F90 and suppress lambda_th
    151  rm -f phys_output_mod.F90
    152 sed -e "/SUBROUTINE *convers_timesteps/,/END SUBROUTINE convers_timesteps/{
    153  /USE *phys_cal_mod/d
    154  /use *ioipsl/a\\
    155     USE phys_cal_mod
    156  s/ioget_mon_len(annee_ref,day_ref)/mth_len/
    157 };/SUBROUTINE *phys_output_open/,/end *subroutine *phys_output_open/{
    158  /USE *ioipsl/a\\
    159   USE phys_cal_mod, only : hour
    160  /ymds2ju.*annee_ref.*zjulian/c\\
    161 !!!      CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)       !jyg \\
    162 ! correction pour l heure initiale                               !jyg \\
    163 !                                                                !jyg \\
    164       CALL ymds2ju(annee_ref, 1, idayref, hour, zjulian)         !jyg
    165 }" ../phylmd/phys_output_mod.F90 >phys_output_mod.F90.ori
    166 #
    167  echo Update pbl_surface_mod.F90
    168  rm -f pbl_surface_mod.F90
    169  sed -e "/^ *INCLUDE *\"temps.h\"/{
    170  a\\
    171 !****************************************************************************************\\
    172 ! Declarations specifiques pour le 1D. A reprendre \\
    173     INCLUDE \"flux_arp.h\"
    174  }; /^.*REAL *::.*fsens *, *flat/d; /^.*LOGICAL *::.*ok_flux_surf/d; /^.*COMMON.*flux_arp.*/d " ../phylmd/pbl_surface_mod.F90 >pbl_surface_mod.F90.ori
    175 fi
    176 #
    177 ############################################################################
    178 #                                                                          #
    179 #               CORRECTIONS DE BUGS (corrections necessaires au            #
    180 #                                    fonctionnement du 1D pour le cas      #
    181 #                                    où une version trop vieille de LMDZ   #
    182 #                                    est utilisée)                         #
    183 #                                                                          #
    184 ############################################################################
    185 #
    186  echo Update coef_diff_turb_mod.F90
    187  rm -f coef_diff_turb_mod.F90
    188 sed -e "/zfr *= *(zq+ratqs\*zq-zqs) *\/ *(2.0\*ratqs\*zq)/{
    189 c\\
    190 !!jyg : pour eviter une division par 0                                   \\
    191 !!!!          zfr = (zq+ratqs*zq-zqs) / (2.0*ratqs*zq)                   \\
    192           zfr = (zq+ratqs*zq-zqs) / (2.0*ratqs*MAX(zq,zqs/(1.+ratqs)))
    193 }" ../phylmd/coef_diff_turb_mod.F90 >coef_diff_turb_mod.F90
    194 #
    195  echo Update physiq.F and suppress lambda_th
    196  rm -f physiq.F
    197  sed -e "/REAL/s/lambda_th(klon,klev),//;/lambda_th.*=/d" physiq.F.ori >physiq.F
    198 #
    199  echo Update phys_output_mod.F90 and suppress lambda_th
    200  rm -f phys_output_mod.F90
    201 sed -e "/save.*o_lambda_th/d;/CALL histdef3d(iff,clef_stations(iff),/{
    202 N;/o_lambda_th/d
    203 }" phys_output_mod.F90.ori >phys_output_mod.F90
    204 #
    205  echo Update phys_output_write.h and suppress lambda_th
    206  rm -f phys_output_write.h
    207 sed -e "/IF *( *o_lambda_th/,/ENDIF/d" ../phylmd/phys_output_write.h >phys_output_write.h
    208 #
    209  mv pbl_surface_mod.F90.ori pbl_surface_mod.F90
    210 #
    211 ############################################################################
    212 #                                                                          #
    213 #               CORRECTIONS pour version en developpement :                #
    214 #                  fabrication éventuelle de phy1dref et phy1d            #
    215 #                                                                          #
    216 #        Partie à effacer si on ne veut pas de ces corrections             #
    217 #        (par ex. si le 3D les contients dejà, ou s'il est trop ancien)    #
    218 #                                                                          #
    219 ############################################################################
    220 #
    221  
    222 #
    223 if [ -d ${source}/phy1d_source_new ]
    224 then
    225 #  D'abord on recopie la physique que l'on vient de construire dans phy1dref
    226 #
    227   echo Creation de phy1dref
    228   cd ..
    229   cp -a phy1d phy1dref
    230   echo Ajout des nouveaux codes-source
    231   cp -af ${source}/phy1d_source_new/* phy1d
    232   cd phy1d
    233 #
    234   echo Update physiq.F dans phy1d
    235   rm -f physiq.F
    236   sed -e "/if *(iflag_thermals\.gt\.1) *then/{
    237 N;/call *calltherm/s/(iflag_thermals\.gt\.1)/(iflag_thermals>=1)/
    238 };/if *(iflag_thermals>1) *then/{
    239 N;N;/d_t_lscth.*d_t_lscst/s/(iflag_thermals>1)/(iflag_thermals>=1)/
    240 }" ../phy1dref/physiq.F >physiq.F
    241 #
    242   echo Update phys_output_mod.F90 dans phy1d
    243   rm -f phys_output_mod.F90
    244   sed -e "/type(ctrl_out).*o_ovapinit/{
    245 a\\
    246   type(ctrl_out),save :: o_oliq         = ctrl_out((/ 2, 3, 4, 10, 10, 10 /),'oliq')
    247 };/CALL *histdef3d.*o_ovap%flag/{
    248 a\\
    249           CALL histdef3d(iff,clef_stations(iff),o_oliq%flag,o_oliq%name, \"Condensed water\", \"kg/kg\" )
    250 };/if *(iflag_thermals\.gt\.1) *THEN/,/endif *!iflag_thermals\.gt\.1/{
    251 /if *(iflag_thermals\.gt\.1)/{
    252 N;N;h;/dqlscth.*dqlscst/{
    253 s/(iflag_thermals\.gt\.1)/(iflag_thermals>=1)/
    254 }
    255 };/endif *!iflag_thermals\.gt\.1/{
    256 x;/dqlscth.*dqlscst/{
    257 x;s/iflag_thermals\.gt\.1/iflag_thermals>=1/
    258 }
    259 }
    260 }" ../phy1dref/phys_output_mod.F90 >phys_output_mod.F90
    261 #
    262   echo Update phys_output_write.h dans phy1d
    263   rm -f phys_output_write.h
    264   sed -e "/IF.*o_ovap%flag/,/ENDIF/{
    265 /ENDIF/{
    266 a\\
    267                                                                \\
    268        IF (o_oliq%flag(iff)<=lev_files(iff)) THEN              \\
    269       CALL histwrite_phy(nid_files(iff),clef_stations(iff),    \\
    270      $                   o_oliq%name,itau_w,ql_seri)            \\
    271        ENDIF
    272 }
    273 };/IF *(o_mc\%flag(iff)/,/ENDIF/s/(iflag_thermals\.gt\.1)/(iflag_thermals>=1)/;/if *(iflag_thermals>1) *then/,/endif *! *iflag_thermals>1/{
    274 /if *(iflag_thermals>1)/{
    275 N;N;N;h;/o_dtlscth\%flag(iff)/s/(iflag_thermals>1)/(iflag_thermals>=1)/
    276 };/endif *! *iflag_thermals>1/{
    277 x;/o_dtlscth\%flag(iff)/{
    278 x;s/iflag_thermals>1/iflag_thermals>=1/
    279 }
    280 }
    281 };/IF *(iflag_thermals\.gt\.1) *THEN/{
    282 N;N;/o_ftime_th%flag(iff)/s/(iflag_thermals\.gt\.1)/(iflag_thermals>=1)/
    283 }" ../phy1dref/phys_output_write.h >phys_output_write.h
    284 #
    285 fi
    286 #
    287 fi
    288 ############################################################################
    289 #                                                                          #
    290 #              FIN DES CORRECTIONS                                         #
    291 #                                                                          #
    292 ############################################################################
    293 #
    294103##   Nettoyage
    295104\rm -r ${source}
     
    297106cd ${LMDlibf}/..
    298107\rm -f makefile
    299 for i in 1ere 2eme 3eme ; do
    300    echo 1ere compilation : makegcm -d 39 -p 1d lmdz1d
    301    ./makegcm -d 39 -p 1d lmdz1d
    302 done
    303 if [ -f lmdz1d.e ]
    304 then
    305  echo Compilation réussie
    306  ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/ayotte
    307  ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/case_e
    308  ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/eq_rd_cv
    309  ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/hapex92_init
    310  ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/rico
    311  ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/toga
    312  ln -s `pwd`/lmdz1d.e ${LMDGCM}/1dcases/twpice
     108./makegcm -d 39 -p 1d lmdz1d
     109if [ -f lmdz1d.e ] ; then
     110   mv lmdz1d.e lmdz1d_L39.e
     111 echo Compilation successfull
     112 for rep in ayotte case_e eq_rd_cv hapex92_init rico toga twpice ; do
     113    ln -s `pwd`/lmdz1d_L39.e ${LMDGCM}/1dcases/$rep/lmdz1d.e
     114 done
    313115else
    314  echo La compilation a échoué
     116 echo Compilation aborted
    315117 stop
    316118fi
    317 #
    318 echo ========================
    319 echo '   Simulation test 1D'
    320 echo ========================
    321 ##echo Execution d un cas d equilibre radiatif-convectif
    322 ##cd ${LMDGCM}/1dcases/eq_rd_cv
    323 ##./xqt.x NPv3.1
    324 ##echo Si la derniere ligne avant \"SIMULATION FINISHED\" est \"Everything is cool!\", alors la simulation a reussi.
    325 echo Execution de case_e
     119
     120echo '#########################################################################'
     121echo '   1D test cases'
     122echo '#########################################################################'
     123
     124echo ====================================
     125echo TEST CASE : case_e
     126echo ====================================
    326127cd ${LMDGCM}/1dcases/case_e
    327128./xqt.x NPv3.1
    328 echo Si la derniere ligne avant \"SIMULATION FINISHED\" est \"Everything is cool!\", alors la simulation a reussi.
    329 ##echo Execution du cas Hapex92_init
    330 ##cd ${LMDGCM}/1dcases/hapex92_init
    331 ##./xqt.x NPv3.1
    332 ##echo Si la derniere ligne avant \"SIMULATION FINISHED\" est \"Everything is cool!\", alors la simulation a reussi.
    333 echo 'Execution d une partie de Toga (1mois)'
     129
     130echo ====================================
     131echo TEST CASE : toga' (1 month)'
     132echo ====================================
    334133cd ${LMDGCM}/1dcases/toga
    335134./xqt.x NPv3.1
    336 echo Si la derniere ligne avant \"SIMULATION FINISHED\" est \"Everything is cool!\", alors la simulation a reussi.
    337 echo Execution de arm_cu
    338135
     136armcu=1
     137if [ $armcu = 1 ] ; then
     138   echo ====================================
     139   echo TEST CASE : arm_cu
     140   echo ====================================
     141   cd ${LMDGCM}/1dcases/arm_cu
     142   ./compile.x
     143   ln -s lmdz1d_L40.e lmdz1d.e
     144   ./xqt.x NPv3.1
     145fi
    339146
    340 armcu=0
    341 if [ $armcu=1 ] ; then
    342 cd ${LMDGCM}/1dcases/arm_cu
    343 ./compile.x ; ./compile.x ; ./compile.x
    344 ln -s lmdz1d_L40.e lmdz1d.e
    345 ./xqt.x NPv3.1
    346 echo Si la derniere ligne avant \"SIMULATION FINISHED\" est \"Everything is cool!\", alors la simulation a reussi.
    347 fi
     147echo if the last line \"SIMULATION FINISHED\" is \"Everything is cool!\", the situation went to its end
    348148
    349149
Note: See TracChangeset for help on using the changeset viewer.