Ignore:
Timestamp:
Mar 31, 2015, 3:49:07 PM (10 years ago)
Author:
emillour
Message:

All models: Reorganizing the physics/dynamics interface.

  • makelmdz and makelmdz_fcm scripts adapted to handle the new directory settings
  • misc: (replaces what was the "bibio" directory)
  • Should only contain extremely generic (and non physics or dynamics-specific) routines
  • Therefore moved initdynav.F90, initfluxsto.F, inithist.F, writedynav.F90, write_field.F90, writehist.F to "dyn3d_common"
  • dynlonlat_phylonlat: (new interface directory)
  • This directory contains routines relevent to physics/dynamics grid interactions, e.g. routines gr_dyn_fi or gr_fi_dyn and calfis
  • Moreover the dynlonlat_phylonlat contains directories "phy*" corresponding to each physics package "phy*" to be used. These subdirectories should only contain specific interfaces (e.g. iniphysiq) or main programs (e.g. newstart)
  • phy*/dyn1d: this subdirectory contains the 1D model using physics from phy*

EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/makelmdz

    r1391 r1403  
    7979
    8080CPP_KEY=""
    81 INCLUDE='-I$(LIBF)/grid -I$(LIBF)/bibio -I$(LIBF)/filtrez -I. '
     81INCLUDE='-I$(LIBF)/grid -I$(LIBF)/misc -I$(LIBF)/filtrez -I. '
    8282LIB=""
    8383adjnt=""
     
    8686PARA_LD=""
    8787EXT_SRC=""
     88#src_dirs: directories containing source files
     89src_dirs="grid misc"
    8890ccompiler=""
    8991OPTIMC=""
     
    116118[-chimie INCA/false]       : (Earth) with INCA chemistry model or without (default: false)
    117119[-cosp cosp/false]         : (Earth) add the cosp model (default: false)
     120[-sisvat true/false]  : (Earth) compile with/without sisvat package (default: false)
     121[-rrtm true/false]    : (Earth) compile with/without rrtm package (default: false)
    118122[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
    119123[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
     
    292296for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done
    293297
     298phys_root=$physique
     299if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi
     300if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi
     301if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi
     302if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi
     303if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi
     304if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi
     305if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi
     306
    294307if [[ "$physique" != "nophys" ]]
    295308then
     309   #We'll use some physics
     310   src_dirs="$src_dirs phy$physique"
     311   LIBPHY='$(LIBO)/libphy'"$physique"'.a'
     312   lib_phy='-lphy'"$physique"
    296313   CPP_KEY="$CPP_KEY CPP_PHYS"
    297 fi
    298 
    299 if [[ "$physique" == "lmd" ]]
    300 then
    301    #Default planet type is Earth
     314   if [[ "${phys_root}" == "lmd" ]]
     315   then
     316   #For lmd physics, default planet type is Earth
    302317   CPP_KEY="$CPP_KEY CPP_EARTH"
     318   fi
    303319fi
    304320
     
    309325   LIB="$LIB -l${LIBPREFIX}chim$physique"
    310326   opt_dep="$opt_dep chim$physique"
     327   src_dirs="$src_dirs chim$physique"
    311328# get C compiler name and optim from arch.fcm file
    312329   archfileline=$( grep -i '^%C_COMPILER' arch.fcm )
     
    322339if [[ -d ${LIBFGCM}/aerono${physique} ]]
    323340then
     341   src_dirs="$src_dirs aerono$physique"
    324342   INCLUDE="$INCLUDE -I${LIBFGCM}/aerono${physique}"
    325343   LIB="$LIB -l${LIBPREFIX}aerono$physique"
     
    442460   CPP_KEY="$CPP_KEY CPP_COSP"
    443461   COSP_PATH="$LIBFGCM/cosp"
     462   src_dirs="$src_dirs cosp"
    444463#   LIB="${LIB} -l${LIBPREFIX}cosp"
    445464   opt_dep="$opt_dep cosp"
     
    451470then
    452471   CPP_KEY="$CPP_KEY CPP_SISVAT"
     472   src_dirs="$src_dirs phy${physique}/sisvat"
    453473fi
    454474
     
    456476then
    457477   CPP_KEY="$CPP_KEY CPP_RRTM"
     478   src_dirs="$src_dirs phy${physique}/rrtm"
    458479fi
    459480
     
    507528cd $LIBFGCM/grid/dimension
    508529./makdim $dim
     530if (($? != 0))
     531then
     532    exit 1
     533fi
     534
    509535cat $LIBFGCM/grid/dimensions.h
    510536cd $LMDGCM
     
    534560########################################################################
    535561
    536 dimension=`echo $dim | wc -w`
    537 echo dimension $dimension
    538 
    539 if (( $dimension == 3 )) ; then
     562if (( $dimc == 3 )) ; then
     563   src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}"
     564   if [[ $physique != "nophys" ]] ; then
     565     src_dirs="$src_dirs dynlonlat_phylonlat dynlonlat_phylonlat/phy${phys_root}"
     566     libdyn_phy="-ldynlonlat_phylonlat"
     567     LIBDYN_PHYS='$(LIBO)/libdynlonlat_phylonlat.a'
     568     INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat'
     569     INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat/'"${phys_root}"
     570   fi
    540571  cd $LIBFGCM/grid
    541572  \rm fxyprim.h
     
    543574  filtre="FILTRE=$filtre"
    544575  INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
    545 elif (( $dimension == 2 )) ; then
     576elif (( $dimc == 2 )) ; then
     577   src_dirs="$src_dirs dyn2d"
    546578   filtre="FILTRE= L_FILTRE= "
    547579   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
    548 elif (( $dimension == 1 )) ; then
     580elif (( $dimc == 1 )) ; then
    549581   echo pas de dynamique
     582   src_dirs="$src_dirs phy${physique}/dyn1d"
    550583   CPP_KEY="$CPP_KEY CPP_1D"
    551    filtre="L_DYN= DYN= FILTRE= L_FILTRE= DIRMAIN=phy$physique "
    552    INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
     584   filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
     585   #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
     586   INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d'
    553587else
    554588   echo Dimension dimc=$dimc pas prevu ; exit
     
    588622########################################################################
    589623cd $LMDGCM
    590 find libf -name '*.[Fh]' -print | sort > tmp77
    591 find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print | sort > tmp90
    592 find libf -name '*.F90' -print | sort >> tmp90
     624
     625
     626if [[ -r .makelmdz ]]
     627then
     628old_lmdz_configuration=$(cat .makelmdz )
     629else
     630old_lmdz_configuration=""
     631fi
     632lmdz_configuration="$src_dirs"
     633if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]]
     634then
     635  configuration_change="true"
     636else
     637  configuration_change="false"
     638fi
     639
     640mkdir -p make_dir
     641suf_make=`echo $src_dirs | sed -e 's/\//_/g' -e 's/ /_/g'`
     642echo suf_make $suf_make
     643
     644\rm tmp77 tmp90
     645for dir in $src_dirs ; do
     646find libf/$dir -name '*.[Fh]' -print | sort >> tmp77
     647find libf/$dir -name '*.F90' -print | sort >> tmp90
    593648######### CAS PARTICULIER CHIMIE TITAN
    594649if [[ "$physique" == "titan" ]]
     
    597652fi
    598653#########
    599 
    600 if [[ ! ( -r makefile ) || ! ( -r liste_des_sources_f90 ) || ! ( -r liste_des_sources_f77 ) || ` diff tmp77 liste_des_sources_f77 | wc -w ` -ne 0 || ` diff tmp90 liste_des_sources_f90 | wc -w ` -ne 0 ]]
     654done
     655
     656liste77=make_dir/liste_des_sources_f77_$suf_make
     657liste90=make_dir/liste_des_sources_f90_$suf_make
     658if [[ "$physique" == "titan" ]] ; then
     659listeC=make_dir/liste_des_sources_C_$suf_make
     660fi
     661makefile=make_dir/makefile_$suf_make
     662
     663if [[ $configuration_change == "true" || ! ( -r makefile ) || ! ( -r $liste_90 ) || ! ( -r $liste_77 ) || ` diff tmp77 $liste_77 | wc -w ` -ne 0 || ` diff tmp90 $liste_90 | wc -w ` -ne 0 ]]
    601664then
    602665  echo "les fichiers suivants ont ete crees ou detruits"
    603666  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
    604   diff liste_des_sources_f77 tmp77
    605   diff liste_des_sources_f90 tmp90
    606   \cp -f tmp77 liste_des_sources_f77
    607   \cp -f tmp90 liste_des_sources_f90
     667  diff $liste77 tmp77
     668  diff $liste90 tmp90
     669  \cp -f tmp77 $liste77
     670  \cp -f tmp90 $liste90
    608671######### CAS PARTICULIER CHIMIE TITAN
    609672  if [[ "$physique" == "titan" ]]
    610673  then
    611   diff liste_des_sources_C tmpC
    612   \cp -f tmpC liste_des_sources_C
     674  diff $listeC tmpC
     675  \cp -f tmpC $listeC
    613676  fi
    614677#########
    615   echo "on recree le makefile"
    616   ./create_make_gcm > tmp
    617   \mv -f tmp makefile
    618   echo "Nouveau makefile cree"
     678  echo "Recreating the makefile"
     679  echo "src_dirs: $src_dirs"
     680  ./create_make_gcm $src_dirs > tmp
     681  \mv -f tmp $makefile
     682  echo "New makefile created"
    619683######### CAS PARTICULIER CHIMIE TITAN
    620684else if [[ "$physique" == "titan" ]]
    621685 then
    622    if [[ ! ( -r liste_des_sources_C ) || ` diff tmpC liste_des_sources_C | wc -w ` -ne 0 ]]
     686   if [[ ! ( -r $listeC ) || ` diff tmpC $listeC | wc -w ` -ne 0 ]]
    623687   then
    624      diff liste_des_sources_C tmpC
    625      \cp -f tmpC liste_des_sources_C
     688     diff $listeC tmpC
     689     \cp -f tmpC $listeC
    626690     echo "on recree le makefile"
    627      ./create_make_gcm > tmp
    628      \mv -f tmp makefile
     691     ./create_make_gcm $src_dirs > tmp
     692     \mv -f tmp $makefile
    629693     echo "Nouveau makefile cree"
    630694   fi
     
    633697fi
    634698
     699ln -sf $makefile makefile
     700
     701#Create a .makelmdz file containing main compilation option for later comparisons
     702echo "$lmdz_configuration" > .makelmdz
     703
    635704#################################################################
    636705# Preparation de l'execution de la commande make
     
    641710then
    642711  source_code=${code}.F
    643   code_dir=dyn${dimc}d${FLAG_PARA}
     712  dirmain=dyn${dimc}d${FLAG_PARA}
    644713else
    645714  if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
    646715  then
    647716    source_code=${code}.F90
    648     code_dir=dyn${dimc}d${FLAG_PARA}
     717    dirmain=dyn${dimc}d${FLAG_PARA}
    649718  else
    650719    if [[ -r $LMDGCM/libf/phy${physique}/${code}.F ]]
    651720    then
    652721      source_code=${code}.F
    653       code_dir=phy${physique}
     722      dirmain=phy${physique}
    654723    else
    655       # last possibility:
    656724      if [[ -r $LMDGCM/libf/phy${physique}/${code}.F90 ]]
    657725      then
    658726        source_code=${code}.F90
    659         code_dir=phy${physique}
     727        dirmain=phy${physique}
    660728      else
    661         echo "Error: cannot find ${code}.F[90]"
    662         echo " neither in dyn${dimc}d${FLAG_PARA} nor in phy${physique}"
    663         exit
     729        if [[ -r $LMDGCM/libf/dynlonlat_phylonlat/phy$phys_root/${code}.F ]]
     730        then
     731          source_code=${code}.F
     732          dirmain="dynlonlat_phylonlat/phy${phys_root}"
     733        else
     734          if [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F ]]
     735          then
     736            source_code=${code}.F
     737            dirmain=phy$physique/dyn1d
     738          else
     739            echo "Error: cannot find ${code}.F[90]"
     740            echo " neither in dyn${dimc}d${FLAG_PARA} nor in phy${physique}"
     741            exit
     742          fi
     743        fi
    664744      fi
    665745    fi
     
    684764then
    685765  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
    686   phys="PHYS=$physique"
    687 else
    688   # trick to avoid having a physics-related library in the makefile
    689   phys="L_PHY= LIBPHY="
    690 fi
    691 if (( $dimension == 1 ))
    692 then
    693  INCLUDE="$INCLUDE"' -I$(LIBF)/dyn3d -I'${LIBOGCM}/${nomlib}
    694 else
    695  INCLUDE="$INCLUDE"' -I$(LIBF)/dyn'${dimc}'d'$FLAG_PARA' -I'${LIBOGCM}/${nomlib}
    696 fi
     766#  phys="PHYS=$physique"
     767#else
     768#  # trick to avoid having a physics-related library in the makefile
     769#  phys="L_PHY= LIBPHY="
     770fi
     771INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib}
     772#if (( $dimension == 1 ))
     773#then
     774# INCLUDE="$INCLUDE"' -I$(LIBF)/dyn3d -I'${LIBOGCM}/${nomlib}
     775#else
     776#INCLUDE="$INCLUDE"' -I$(LIBF)/dyn'${dimc}'d'$FLAG_PARA' -I'${LIBOGCM}/${nomlib}
     777#fi
    697778
    698779# ranlib utility (check it exists or else default to ls)
     
    727808$filtre \
    728809LIBO=${LIBOGCM}/${nomlib} \
    729 $phys \
     810"PHYS=$physique" \
     811LIBPHY=${LIBPHY} \
     812LIBDYN_PHYS=${LIBDYN_PHYS} \
    730813DIM=$dimc \
    731814FLAG_PARA=$FLAG_PARA \
     815L_PHY="$lib_phy" \
     816L_DYN_PHY="$libdyn_phy" \
    732817L_ADJNT=$adjnt \
    733818L_COSP="$lcosp" \
     
    744829MOD_SUFFIX="mod" \
    745830AR=$arcommand \
    746 DIRMAIN=$code_dir \
     831DIRMAIN=$dirmain \
    747832SOURCE=$source_code \
    748833PROG=$code
     
    758843$filtre \
    759844LIBO=${LIBOGCM}/${nomlib} \
    760 $phys \
     845"PHYS=$physique" \
     846LIBPHY=${LIBPHY} \
     847LIBDYN_PHYS=${LIBDYN_PHYS} \
    761848DIM=$dimc \
    762849FLAG_PARA=$FLAG_PARA \
     850L_PHY="$lib_phy" \
     851L_DYN_PHY="$libdyn_phy" \
    763852L_ADJNT="$adjnt" \
    764853L_COSP="$lcosp" \
     
    775864MOD_SUFFIX="mod" \
    776865AR=$arcommand \
    777 DIRMAIN=$code_dir \
     866DIRMAIN=$dirmain \
    778867SOURCE=$source_code \
    779868PROG=$code
Note: See TracChangeset for help on using the changeset viewer.