#!/bin/bash 
## g.e. # foudre # prepare_compilation.bash /home/lluis/etudes/WRF_LMDZ/src /home/lluis/bin/gcc_netcdf/4.3.0 /home/lluis/DATA/WRF/WRFV3.3/phylmd/serial/WRFV3
## g.e. # acuna #  prepare_compilation.bash /d4/lflmd/DATA/WRF/WRFV3.3/lmdz_phylmd/serial/WRFV3 /u/lflmd/bin/gcc_netcdf-4.3.0 /d4/lflmd/DATA/WRF/WRFV3.3/lmdz_phylmd/serial/WRFV3 
if test $1 = '-h'; then
  echo "*********************************"
  echo "*** preparing the compilation ***"
  echo "***      of LMDZ and WRF      ***"
  echo "*********************************"
  echo "prepare_compilation.bash [WRF_LMDZsrc] [NETCDFhome] [place]"
  echo "  [WRF_LMDZsrc]: source of the WRF + LMDZ coupling"
  echo "  [NETCDFhome]: home of the netCDF libraries"
  echo "  [place]: place where to compile)"

else
  rootsh=`pwd`
  WRFsrc=$1
  NETCDFhome=$2
  place=$3

  WRF2LMDZ='share/module_model_constants.mod:frame/module_domain_type.mod:frame/module_domain.mod'
  LMDZ2WRF='control_mod.mod:indice_sol_mod.mod:surface_data.mod:mod_grid_phy_lmdz.mod:noread_limit_sub_variables.mod:wrf_lmdz_mod.mod:lmdz_wrf_variables_mod.mod:output_lmdz_nomodule.mod'
  NETCDF2LMDZ='typesizes.mod:netcdf.mod:netcdf.inc'

####### ###### ##### #### ### ## #

  WLfiles=`echo ${WRF2LMDZ} | tr ':' ' '`
  LWfiles=`echo ${LMDZ2WRF} | tr ':' ' '` 
  NLfiles=`echo ${NETCDF2LMDZ} | tr ':' ' '`
  
  for file in ${WLfiles}; do
    cp $place/${file} ${place}/lmdz
  done

# NOT necessary
#  for file in ${LWfiles}; do
#    cp $place/lmdz/${file} ${place}/phys
#  done

  for file in ${NLfiles}; do
    cp $NETCDFhome/include/${file} $place/lmdz
  done

fi
