Ignore:
Timestamp:
Jul 20, 2024, 11:17:09 PM (4 months ago)
Author:
abarral
Message:

Move lmdz_netcdf_format.F90 -> lmdz_cppkeys_wrapper.F90 to handle other CPP keys
Replace all (except wrapper) use of CPP_PHYS by fortran logical
Refactor makelmdz_fcm (put blocks into functions, use modern bash)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Amaury_dev/makelmdz_fcm

    r5089 r5091  
    5050  arch_default_path="arch"
    5151
    52   LMDGCM=$(/bin/pwd)
     52  LMDGCM=$(pwd)
    5353  LIBOGCM=$LMDGCM/libo
    5454  LIBFGCM=$LMDGCM/libf
     
    278278  mkdir .void_dir
    279279
    280   if [[ "$arch_defined" == "TRUE" ]]; then
     280  if [[ "$arch_defined" = "TRUE" ]]; then
    281281    local i
    282282    for i in "path" "fcm" "env"; do
     
    300300}
    301301
    302 init_vars
    303 read_cmdline_options "$@"
    304 init_arch
    305 
    306302function cpp_keys_and_include_mod_path() {
    307303  ########################################################################
     
    336332  fi
    337333
    338   if [[ "$filtre" = "filtrez" ]]; then
     334  if [[ $filtre = "filtrez" ]]; then
    339335     FILTRE_PATH=${LIBFGCM}/$filtre
    340336  fi
    341337
    342   if [[ "$chimie" = "INCA" ]]; then
     338  if [[ $chimie = "INCA" ]]; then
    343339     CPP_KEY="$CPP_KEY INCA"
    344340     INCLUDE="$INCLUDE ${INCA_INCDIR}"
     
    346342  fi
    347343
    348   if [[ "$isotopes" = "true" ]]; then
     344  if [[ $isotopes = "true" ]]; then
    349345     CPP_KEY="$CPP_KEY ISO"
    350346  fi
    351347
    352   if [[ "$isoverif" = "true" ]]; then
     348  if [[ $isoverif = "true" ]]; then
    353349     CPP_KEY="$CPP_KEY ISOVERIF"
    354350  fi
    355351
    356   if [[ "$diagiso" = "true" ]]; then
     352  if [[ $diagiso = "true" ]]; then
    357353     CPP_KEY="$CPP_KEY DIAGISO"
    358354  fi
    359355
    360   if [[ "$isotrac" = "true" ]]; then
     356  if [[ $isotrac = "true" ]]; then
    361357     CPP_KEY="$CPP_KEY ISOTRAC"
    362358  fi
    363359
    364   if [[ "$couple" != "false" ]]; then
    365       if [[ "$couple" = "MPI1" ]]; then
     360  if [[ $couple != "false" ]]; then
     361      if [[ $couple = "MPI1" ]]; then
    366362        CPP_KEY="$CPP_KEY CPP_COUPLE"
    367363        export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1
     
    376372  fi
    377373
    378   if [[ "$parallel" = "mpi" ]]; then
     374  if [[ $parallel = "mpi" ]]; then
    379375     CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
    380376     PARA_FFLAGS="%MPI_FFLAGS"
    381377     PARA_LD="%MPI_LD"
    382   elif [[ "$parallel" = "omp" ]]; then
     378  elif [[ $parallel = "omp" ]]; then
    383379     CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
    384380     PARA_FFLAGS="%OMP_FFLAGS"
    385381     PARA_LD="%OMP_LD"
    386   elif [[ "$parallel" = "mpi_omp" ]]; then
     382  elif [[ $parallel = "mpi_omp" ]]; then
    387383     CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
    388384     PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS"
     
    390386  fi
    391387
    392   if [[ ( "$parallel" = "omp" || "$parallel" = "mpi_omp" ) && "$compil_mod" = "debug" ]]; then
     388  if [[ ( $parallel = "omp" || $parallel = "mpi_omp" ) && $compil_mod = "debug" ]]; then
    393389      echo "Usually, parallelization with OpenMP requires some optimization."
    394390      echo "We suggest switching to \"-dev\"."
    395391  fi
    396392
    397 if [[ "$veget" = "true" || "$veget" = "orchidee1.9" || "$veget" = "orchidee2.0" \
    398    || "$veget" = "orchidee2.1" || "$veget" = "orchideetrunk" ]]; then
     393if [[ $veget = "true" || $veget = "orchidee1.9" || $veget = "orchidee2.0" \
     394   || $veget = "orchidee2.1" || $veget = "orchideetrunk" ]]; then
    399395        echo "doing orchidee"
    400396#NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6
     
    404400   CPP_KEY="$CPP_KEY CPP_VEGET"
    405401# temporary, for Orchidee versions 1.9.* (before openmp activation)
    406    if [[ "$veget" == "orchidee1.9" ]] ; then
     402   if [[ "$veget" = "orchidee1.9" ]]; then
    407403      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
    408404    fi
     
    421417    echo "orchidee lib"
    422418    echo "${LIB}"
    423   elif [[ "$veget" != "false" ]]; then
     419  elif [[ $veget != "false" ]]; then
    424420    echo "Option -v $veget does not exist"
    425421    echo "Use ./makelmdz_fcm -h for more information"
     
    427423  fi
    428424
    429   if [[ "$inlandsis" = "true" ]]; then
     425  if [[ $inlandsis = "true" ]]; then
    430426     CPP_KEY="$CPP_KEY CPP_INLANDSIS"
    431427     INLANDSIS_PATH="$LIBFGCM/phy${physique}/inlandsis"
    432428  fi
    433429
    434   if [[ "$rad" = "rrtm" ]]; then
     430  if [[ $rad = "rrtm" ]]; then
    435431     CPP_KEY="$CPP_KEY CPP_RRTM"
    436432     RAD_PATH="$LIBFGCM/phy${physique}/rrtm"
    437   fi
    438   if [[ "$rad" = "ecrad" ]]; then
     433  elif [[ $rad = "ecrad" ]]; then
    439434     CPP_KEY="$CPP_KEY CPP_ECRAD"
    440435     RAD_PATH="$LIBFGCM/phy${physique}/ecrad"
    441436  fi
    442437
    443   if [[ "$dust" = "true" ]]; then
     438  if [[ $dust = "true" ]]; then
    444439     CPP_KEY="$CPP_KEY CPP_Dust"
    445440     DUST_PATH="$LIBFGCM/phy${physique}/Dust"
    446441  fi
    447442
    448   if [[ "$strataer" = "true" ]]; then
     443  if [[ $strataer = "true" ]]; then
    449444     CPP_KEY="$CPP_KEY CPP_StratAer"
    450445     STRATAER_PATH="$LIBFGCM/phy${physique}/StratAer"
     
    454449  LIB="$LIB ${NETCDF95_LIBDIR} ${NETCDF95_LIB}"
    455450
    456   if [[ $io = ioipsl ]]; then
     451  if [[ $io = "ioipsl" ]]; then
    457452     CPP_KEY="$CPP_KEY CPP_IOIPSL"
    458453     INCLUDE="$INCLUDE ${IOIPSL_INCDIR}"
    459454     LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB}"
    460   elif [[ $io = mix ]]; then
    461      # For now, xios implies also using ioipsl
     455  elif [[ $io = "mix" ]]; then
    462456     CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
    463457     INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
    464458     LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}"
    465   elif [[ $io = xios ]]; then
    466      # For now, xios implies also using ioipsl
     459  elif [[ $io = "xios" ]]; then
    467460     CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
    468461     INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
     
    470463  fi
    471464
    472   if [[ "$cosp" = "true" ]]; then
     465  if [[ $cosp = "true" ]]; then
    473466     CPP_KEY="$CPP_KEY CPP_COSP"
    474467     COSP_PATH="$LIBFGCM/phylmd/cosp"
    475468  fi
    476469
    477   if [[ "$cosp2" = "true" ]]; then
     470  if [[ $cosp2 = "true" ]]; then
    478471     CPP_KEY="$CPP_KEY CPP_COSP2"
    479472     COSP_PATH="$LIBFGCM/phylmd/cosp2"
    480473  fi
    481474
    482   if [[ "$cospv2" = "true" ]]; then
     475  if [[ $cospv2 = "true" ]]; then
    483476     CPP_KEY="$CPP_KEY CPP_COSPV2"
    484477     COSP_PATH="$LIBFGCM/phylmd/cospv2"
    485478  fi
    486479
    487   if [[ "$cplocninca" = "TRUE" ]]; then
     480  if [[ $cplocninca = "TRUE" ]]; then
    488481      CPP_KEY="${CPP_KEY} CPP_CPLOCNINCA"
    489482  fi
     
    494487}
    495488
    496 cpp_keys_and_include_mod_path
    497 
    498 
    499 ########################################################################
    500 # calcul du nombre de dimensions
    501 ########################################################################
    502 
    503 
    504 dim_full=$dim
    505 dim=`echo $dim | sed -e 's/[^0-9]/ /g'`
    506 set $dim
    507 dimc=$#
    508 echo calcul de la dimension
    509 echo dim $dim
    510 echo dimc $dimc
    511 
    512 
    513 ########################################################################
    514 # Gestion des dimensions du modele.
    515 # on cree ou remplace le fichier des dimensions
    516 ########################################################################
    517 
    518 cd $LIBFGCM/grid
    519 if [[ -f dimensions.h ]]
    520 then
    521     if [[ $force_compile == true ]]
    522     then
    523         \rm -f $LIBFGCM/grid/dimensions.h
     489function handle_dimension() {
     490  ########################################################################
     491  # calcul du nombre de dimensions
     492  ########################################################################
     493
     494  dim_full=$dim
     495  dim=$(echo "$dim" | sed -e 's/[^0-9]/ /g')
     496  dimc=$(awk -F" " '{print NF}' <<< "$dim")
     497  echo "calcul de la dimension: dim=$dim, dimc=$dimc"
     498 
     499  ########################################################################
     500  # Gestion des dimensions du modele.
     501  # on cree ou remplace le fichier des dimensions
     502  ########################################################################
     503 
     504  cd "$LIBFGCM/grid"
     505  if [[ -f dimensions.h ]]; then
     506      if [[ $force_compile = "true" ]]; then
     507          rm -f "$LIBFGCM/grid/dimensions.h"
     508      else
     509          echo "WARNING: you are probably already compiling the model somewhere else."
     510          echo "Wait until the first compilation is finished before launching this one."
     511          echo "If you are sure that you are not compiling elsewhere, "
     512          echo "If you are sure that you are not compiling elsewhere, then"
     513          echo "rm -f \"$LIBFGCM/grid/dimensions.h\""
     514          echo "before reruning the compilation"
     515          echo "or run makelmdz_fcm with option -force_compile"
     516          exit 1
     517      fi
     518  fi
     519 
     520  cd "$LIBFGCM/grid/dimension"
     521  # shellcheck disable=SC2086
     522  ./makdim $dim
     523  cat "$LIBFGCM/grid/dimensions.h"
     524  cd "$LMDGCM"
     525}
     526
     527function different_dynamics() {
     528  ########################################################################
     529  # Differentes dynamiques (3d, 2d, 1d)
     530  ########################################################################
     531
     532  if [[ $dimc = 3 ]]; then
     533    cd "$LIBFGCM/grid"
     534    rm fxyprim.h
     535    cp -p "fxy_${grille}.h" fxyprim.h
     536  fi
     537
     538  if [[ $dimc = 1 ]]; then
     539    CPP_KEY="$CPP_KEY CPP_1D"
     540    ## no filtre in 1d:
     541    FILTRE_PATH="$LMDGCM/.void_dir"
     542    ## no need to compile all routines in dyn3d_common either:
     543    DYN_COMMON_PATH="$LMDGCM/.void_dir"
     544    ## no need to compile all routines in dynlmdz_phy...;
     545    ## (because key ones are included in 1D main program)
     546    DYN_PHYS_PATH="$LMDGCM/.void_dir"
     547    DYN_PHYS_SUB_PATH="$LMDGCM/.void_dir"
     548  fi
     549
     550  ######################################################################
     551  # Gestion du filtre qui n'existe qu'en 3d.
     552  ######################################################################
     553  if [[ $dimc -gt 2 ]]; then
     554     filtre="FILTRE=$filtre"
     555  else
     556     filtre="FILTRE= L_FILTRE= "
     557  fi
     558  echo "MACRO FILTRE $filtre (dimc=$dimc)"
     559}
     560
     561function create_config_suffix() {
     562  ######################################################################
     563  # Creation du suffixe de la configuration
     564  ######################################################################
     565
     566  SUFF_NAME=_${dim_full}
     567  SUFF_NAME=${SUFF_NAME}_phy${physique}_${rad}
     568
     569  if [[ $parallel != "none" ]]; then
     570    SUFF_NAME=${SUFF_NAME}_para
     571    DYN=dyn${dimc}d${paramem}
     572    if [[ $paramem = "mem" ]]; then
     573        SUFF_NAME=${SUFF_NAME}_${paramem}
    524574    else
    525         echo "WARNING: you are probably already compiling the model somewhere else."
    526         echo "Wait until the first compilation is finished before launching this one."
    527         echo "If you are sure that you are not compiling elsewhere, "
    528         echo "If you are sure that you are not compiling elsewhere, then"
    529         echo rm -f $LIBFGCM/grid/dimensions.h
    530         echo "before reruning the compilation"
    531         echo "or run makelmdz_fcm with option -force_compile"
     575        echo "The version of the dynamics in dyn3dpar is no longer updated."
     576        echo "You should use option \"-mem\"."
    532577        exit 1
    533578    fi
    534 fi
    535 
    536 
    537 
    538 cd $LIBFGCM/grid/dimension
    539 ./makdim $dim
    540 cat $LIBFGCM/grid/dimensions.h
    541 cd $LMDGCM
    542 
    543 
    544 ########################################################################
    545 # Differentes dynamiques (3d, 2d, 1d)
    546 ########################################################################
    547 
    548 dimension=`echo $dim | wc -w`
    549 echo dimension $dimension
    550 
    551 if (( $dimension == 3 ))
    552 then
    553   cd $LIBFGCM/grid
    554   \rm fxyprim.h
    555   cp -p fxy_${grille}.h fxyprim.h
    556 #else
    557 #  echo "Probleme dans les dimensions de la dynamique !!"
    558 #  echo "Non reactive pour l'instant !!!"
    559 fi
    560 
    561 if (( $dimension == 1 ))
    562 then
    563   CPP_KEY="$CPP_KEY CPP_1D"
    564 ## no filtre in 1d:
    565   FILTRE_PATH=$LMDGCM/.void_dir
    566 ## no need to compile all routines in dyn3d_common either:
    567   DYN_COMMON_PATH=$LMDGCM/.void_dir
    568 ## no need to compile all routines in dynlmdz_phy... ;
    569 ## (because key ones are included in 1D main program)
    570   DYN_PHYS_PATH=$LMDGCM/.void_dir
    571   DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
    572 fi
    573 
    574 ######################################################################
    575 #   Traitement special pour le nouveau rayonnement de Laurent Li.
    576 #   ---> YM desactive pour le traitemement en parallele
    577 ######################################################################
    578 
    579 #if [[ -f $libf/phy$physique/raddim.h ]]
    580 #then
    581 # if [[ -f $libf/phy$physique/raddim.$dimh.h ]]
    582 #then
    583 #  \rm -f $libf/phy$physique/raddim.h
    584 #  cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h
    585 #  echo $libf/phy$physique/raddim.$dimh.h
    586 #  cat $libf/phy$physique/raddim.h
    587 # else
    588 #  echo On peut diminuer la taille de l executable en creant
    589 #  echo le fichier $libf/phy$physique/raddim.$dimh.h
    590 #  \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h
    591 # fi
    592 #fi
    593 
    594 ######################################################################
    595 # Gestion du filtre qui n'existe qu'en 3d.
    596 ######################################################################
    597 
    598 if (( `expr $dimc \> 2` == 1 ))
    599 then
    600    filtre="FILTRE=$filtre"
    601 else
    602    filtre="FILTRE= L_FILTRE= "
    603 fi
    604 echo MACRO FILTRE $filtre
    605 
    606 echo $dimc
    607 
    608 
    609 
    610 ######################################################################
    611 # Creation du suffixe de la configuration
    612 ######################################################################
    613 
    614 
    615 SUFF_NAME=_${dim_full}
    616 SUFF_NAME=${SUFF_NAME}_phy${physique}_${rad}
    617 
    618 if [[ "$parallel" != "none" ]]
    619 then
    620   SUFF_NAME=${SUFF_NAME}_para
    621   DYN=dyn${dimc}d${paramem}
    622   if [[ "$paramem" == "mem" ]]
    623   then
    624       SUFF_NAME=${SUFF_NAME}_${paramem}
    625579  else
    626       echo "The version of the dynamics in dyn3dpar is no longer updated."
    627       echo "You should use option \"-mem\"."
    628       exit 1
    629   fi
    630 else
    631   SUFF_NAME=${SUFF_NAME}_seq
    632   if (( $dimension == 1 ))
    633   then
    634     # dynamics-related routines in"dyn1d" subdirectory of phy${physique}
    635     DYN=phy${physique}/dyn1d
     580    SUFF_NAME=${SUFF_NAME}_seq
     581    if [[ $dimc = 1 ]]; then
     582      # dynamics-related routines in"dyn1d" subdirectory of phy${physique}
     583      DYN=phy${physique}/dyn1d
     584    else
     585      DYN=dyn${dimc}d
     586    fi
     587  fi
     588
     589  if [[ $veget != "false" ]]; then
     590    SUFF_NAME=${SUFF_NAME}_orch
     591  fi
     592
     593  if [[ $dust = "true" ]]; then
     594    SUFF_NAME=${SUFF_NAME}_spla
     595  fi
     596
     597  if [[ $couple != "false" ]]; then
     598    SUFF_NAME=${SUFF_NAME}_couple
     599  fi
     600
     601  if [[ $chimie = "INCA" ]]; then
     602    SUFF_NAME=${SUFF_NAME}_inca
     603  fi
     604
     605  if [[ "$isotopes" = "true" ]]; then
     606    SUFF_NAME=${SUFF_NAME}_iso
     607  fi
     608  if [[ "$isoverif" = "true" ]]; then
     609    SUFF_NAME=${SUFF_NAME}_isoverif
     610  fi
     611  if [[ "$isotrac" = "true" ]]; then
     612    SUFF_NAME=${SUFF_NAME}_isotrac
     613  fi
     614  if [[ "$diagiso" = "true" ]]; then
     615    SUFF_NAME=${SUFF_NAME}_diagiso
     616  fi
     617
     618  if [[ $libphy = "true" ]]; then
     619    # special case where we compile only the physics
     620    DYN=$LMDGCM/.void_dir
     621    DYN_COMMON_PATH=$LMDGCM/.void_dir
     622    FILTRE_PATH=$LMDGCM/.void_dir
     623    DYN_PHYS_PATH=$LMDGCM/.void_dir
     624    DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
     625    #and there is no main program to generate
     626    code=""
     627    SUFF_NAME=""
    636628  else
    637     DYN=dyn${dimc}d
    638   fi
    639 fi
    640 
    641 if [[ $veget != "false" ]]
    642 then
    643   SUFF_NAME=${SUFF_NAME}_orch
    644 fi
    645 
    646 if [[ $dust == "true" ]]
    647 then
    648   SUFF_NAME=${SUFF_NAME}_spla
    649 fi
    650 
    651 if [[ $couple != "false" ]]
    652 then
    653   SUFF_NAME=${SUFF_NAME}_couple
    654 fi
    655 
    656 if [[ $chimie == "INCA" ]]
    657 then
    658   SUFF_NAME=${SUFF_NAME}_inca
    659 fi
    660 
    661 if [[ "$isotopes" == "true" ]]
    662 then
    663   SUFF_NAME=${SUFF_NAME}_iso
    664 fi
    665 if [[ "$isoverif" == "true" ]]
    666 then
    667   SUFF_NAME=${SUFF_NAME}_isoverif
    668 fi
    669 if [[ "$isotrac" == "true" ]]
    670 then
    671   SUFF_NAME=${SUFF_NAME}_isotrac
    672 fi
    673 if [[ "$diagiso" == "true" ]]
    674 then
    675   SUFF_NAME=${SUFF_NAME}_diagiso
    676 fi
    677 
    678 if [[ $libphy == "true" ]]
    679 then
    680   # special case where we compile only the physics
    681   DYN=$LMDGCM/.void_dir
    682   DYN_COMMON_PATH=$LMDGCM/.void_dir
    683   FILTRE_PATH=$LMDGCM/.void_dir
    684   DYN_PHYS_PATH=$LMDGCM/.void_dir
    685   DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
    686   #and there is no main program to generate
    687   code=""
    688   SUFF_NAME=""
    689 else
    690   SUFF_NAME=${SUFF_NAME}.e
    691 fi
    692 
    693 cd $LMDGCM
    694 config_fcm="config.fcm"
    695 rm -f $config_fcm
    696 touch $config_fcm
    697 rm -f bin/${code}${SUFF_NAME}.e
    698 rm -f arch.fcm
    699 rm -f arch.opt
    700 
    701 echo "%ARCH          $arch"          >> $config_fcm
    702 echo "%INCDIR        $INCLUDE"       >> $config_fcm
    703 echo "%LIB           $LIB"           >> $config_fcm
    704 echo "%ROOT_PATH     $PWD"           >> $config_fcm
    705 echo "%LIBF          $LIBFGCM"       >> $config_fcm
    706 echo "%LIBO          $LIBOGCM"       >> $config_fcm
    707 echo "%DYN           $DYN"           >> $config_fcm
    708 echo "%DYN_COMMON    $DYN_COMMON_PATH" >> $config_fcm
    709 echo "%PHY_COMMON    $PHY_COMMON_PATH" >> $config_fcm
    710 echo "%FILTRE        $FILTRE_PATH"   >> $config_fcm
    711 echo "%PHYS          phy${physique}" >> $config_fcm
    712 echo "%DYN_PHYS      $DYN_PHYS_PATH" >> $config_fcm
    713 echo "%DYN_PHYS_SUB  $DYN_PHYS_SUB_PATH" >> $config_fcm
    714 echo "%RAD           $RAD_PATH"     >> $config_fcm
    715 echo "%DUST          $DUST_PATH"     >> $config_fcm
    716 echo "%STRATAER      $STRATAER_PATH" >> $config_fcm
    717 echo "%INLANDSIS     $INLANDSIS_PATH" >> $config_fcm
    718 echo "%COSP          $COSP_PATH"     >> $config_fcm
    719 echo "%CPP_KEY       $CPP_KEY"       >> $config_fcm
    720 echo "%EXEC          $code"          >> $config_fcm
    721 echo "%SUFF_NAME     $SUFF_NAME"     >> $config_fcm
    722 echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm
    723 echo "%PARA_FFLAGS   $PARA_FFLAGS"   >> $config_fcm
    724 echo "%PARA_LD       $PARA_LD"       >> $config_fcm
    725 echo "%EXT_SRC       $EXT_SRC"       >> $config_fcm
    726 
    727 if [[ "$rad" == "ecrad" ]]
    728 then
    729 \cp bld.cfg.ecrad bld.cfg
    730 else
    731 \cp bld.cfg.rrtm bld.cfg
    732 fi
    733 
    734 ln -s arch/arch-${arch}.fcm arch.fcm
    735 if test -f arch/arch-${arch}.opt &&  [ $compil_mod = "prod" ]
    736   then
    737   ln -s arch/arch-${arch}.opt arch.opt
    738 else
    739   ln -s .void_file arch.opt
    740 fi
    741 
    742 set +e
    743 
    744 rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock
    745 ./build_gcm ${fcm_path} -j $job $full
    746 build_status=$?
    747 
    748 rm -rf tmp_src
    749 rm -rf config
    750 ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config
    751 ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/ppsrc tmp_src
    752 
    753 if [[ -r $LIBFGCM/grid/dimensions.h ]]
    754 then
    755   # Cleanup: remove dimension.h file
    756   \rm -f $LIBFGCM/grid/dimensions.h
    757 fi
    758 
    759 # build netcdf95 library necessary for the makelmdz script
    760 if [[ $build_status = 0 ]]
    761 then
    762   if [[ ! -d tools/netcdf95/include ]]
    763   then
    764       mkdir tools/netcdf95/include tools/netcdf95/lib
    765       cp config/inc/netcdf95.mod config/inc/nf95_*mod tools/netcdf95/include
    766       cp config/obj/netcdf95.o config/obj/nf95_*o config/obj/check_start_count_m.o tools/netcdf95/lib
    767       cd tools/netcdf95/lib; ar rv libnetcdf95.a *.o; ranlib libnetcdf95.a
    768       cd -
    769     fi
    770 fi
    771 
    772 exit $build_status
     629    SUFF_NAME=${SUFF_NAME}.e
     630  fi
     631}
     632
     633function create_fcm_conf() {
     634  cd "$LMDGCM"
     635  config_fcm="config.fcm"
     636  rm -f "bin/${code}${SUFF_NAME}.e"
     637  rm -f arch.fcm
     638  rm -f arch.opt
     639
     640  {
     641    echo "%ARCH          $arch"
     642    echo "%INCDIR        $INCLUDE"
     643    echo "%LIB           $LIB"
     644    echo "%ROOT_PATH     $PWD"
     645    echo "%LIBF          $LIBFGCM"
     646    echo "%LIBO          $LIBOGCM"
     647    echo "%DYN           $DYN"
     648    echo "%DYN_COMMON    $DYN_COMMON_PATH"
     649    echo "%PHY_COMMON    $PHY_COMMON_PATH"
     650    echo "%FILTRE        $FILTRE_PATH"
     651    echo "%PHYS          phy${physique}"
     652    echo "%DYN_PHYS      $DYN_PHYS_PATH"
     653    echo "%DYN_PHYS_SUB  $DYN_PHYS_SUB_PATH"
     654    echo "%RAD           $RAD_PATH"
     655    echo "%DUST          $DUST_PATH"
     656    echo "%STRATAER      $STRATAER_PATH"
     657    echo "%INLANDSIS     $INLANDSIS_PATH"
     658    echo "%COSP          $COSP_PATH"
     659    echo "%CPP_KEY       $CPP_KEY"
     660    echo "%EXEC          $code"
     661    echo "%SUFF_NAME     $SUFF_NAME"
     662    echo "%COMPIL_FFLAGS $COMPIL_FFLAGS"
     663    echo "%PARA_FFLAGS   $PARA_FFLAGS"
     664    echo "%PARA_LD       $PARA_LD"
     665    echo "%EXT_SRC       $EXT_SRC"
     666  } > $config_fcm
     667
     668  # ecrad conf
     669  if [[ $rad = "ecrad" ]]; then
     670    cp bld.cfg.ecrad bld.cfg
     671  else
     672    cp bld.cfg.rrtm bld.cfg
     673  fi
     674
     675  # arch.fcm and arch.opt
     676  ln -s "arch/arch-$arch.fcm" arch.fcm
     677  if [[ -f arch/arch-$arch.opt && $compil_mod = "prod" ]]; then
     678    ln -s "arch/arch-$arch.opt" arch.opt
     679  else
     680    ln -s .void_file arch.opt
     681  fi
     682}
     683
     684function build_gcm() {
     685  set +e
     686
     687  rm -f "$LIBOGCM/$arch$SUFF_NAME/.config/fcm.bld.lock"
     688  ./build_gcm "$fcm_path" -j "$job" $full
     689  build_status=$?
     690
     691  rm -rf tmp_src
     692  rm -rf config
     693  ln -s "$LIBOGCM/$arch$SUFF_NAME/.config" config
     694  ln -s "$LIBOGCM/$arch$SUFF_NAME/.config/ppsrc" tmp_src
     695
     696  if [[ -r $LIBFGCM/grid/dimensions.h ]]; then
     697    # Cleanup: remove dimension.h file
     698    rm -f "$LIBFGCM/grid/dimensions.h"
     699  fi
     700
     701  # build netcdf95 library necessary for the makelmdz script
     702  if [[ $build_status = 0 ]]; then
     703    if [[ ! -d tools/netcdf95/include ]]; then
     704        mkdir tools/netcdf95/include tools/netcdf95/lib
     705        cp config/inc/netcdf95.mod config/inc/nf95_*mod tools/netcdf95/include
     706        cp config/obj/netcdf95.o config/obj/nf95_*o config/obj/check_start_count_m.o tools/netcdf95/lib
     707        cd tools/netcdf95/lib; ar rv libnetcdf95.a -- *.o; ranlib libnetcdf95.a
     708        cd -
     709      fi
     710  fi
     711
     712  exit $build_status
     713}
     714
     715init_vars
     716read_cmdline_options "$@"
     717init_arch
     718cpp_keys_and_include_mod_path
     719handle_dimension
     720different_dynamics
     721create_config_suffix
     722create_fcm_conf
     723build_gcm
Note: See TracChangeset for help on using the changeset viewer.