Changeset 2238


Ignore:
Timestamp:
Mar 20, 2015, 11:54:59 AM (9 years ago)
Author:
Ehouarn Millour
Message:

Update of "makelmdz" and "create_make_gcm" scripts so that only required directories are scanned when building the makefile.
EM

Location:
LMDZ5/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • LMDZ5/trunk/create_make_gcm

    r2085 r2238  
    55#set -xv
    66
     7# arguments given to create_make_gcm are the directories to scan
     8src_dirs=$*
    79
    810machine=`hostname`
     
    121123cd $libf >/dev/null 2>&1
    122124
    123 for diri in ` ls ` ; do
     125for diri in $src_dirs ; do
    124126
    125127   if [ -d $diri ] ; then
    126    if [ "`ls $diri/*.F $diri/*/*.F`" != "" ] || [ "`ls $diri/*.[fF]90 $diri/*/*.[fF]90`" != "" ]  ; then
     128   if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.[fF]90`" != "" ]  ; then
    127129#      cd $diri >/dev/null 2>&1
    128130      echo
    129131      listlib=""
    130132# Liste des fichiers .F et .F90 n'etant pas des programmes principaux
    131       for fili in `ls $diri/*.[fF] $diri/*/*.[fF]` ; do
    132          test=` (  head $fili | grep '      PROGRAM' ) `
     133      for fili in `ls $diri/*.[fF]` ; do
     134         # Check if file is a routine or main program
     135         # i.e: look for the "program" keword preceeded by leading spaces
     136         test=` (  head $fili | grep -i '^ *program' ) `
     137         # if it is not a main program, add it to the list
    133138         if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi
    134139      done
    135       for fili in `ls $diri/*.[fF]90 $diri/*/*.[fF]90` ; do
    136          test=` (  head $fili | grep 'PROGRAM' ) `
     140      for fili in `ls $diri/*.[fF]90` ; do
     141         # Check if file is a routine or main program
     142         # i.e. look for "program" keyword (with possibly some leading spaces)
     143         test=` (  head $fili | grep -i '^ \{0,\}program' ) `
     144         # if it is not a main program, add it to the list
    137145         if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi
    138146      done
     
    140148      echo $listlib >> $logfile
    141149      echo
     150      # topdiri contains main dir name (without trailing "/blabla" for subdirs)
     151      topdiri=${diri%/*}
    142152      echo "#=================================================================="
    143153      echo "# Contenu de la bibliotheque correspondant au Directory "$diri
     
    146156      for trufile in $listlib ; do
    147157         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
    148          echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)"
     158         echo '$(LIBO)/lib'$topdiri".a : " '$(LIBO)/lib'$topdiri".a("$fili".o)"
    149159         echo
    150160      done
    151       echo '.PRECIOUS   : $(LIBO)/lib'$diri'.a'
    152       echo
    153       echo
    154       echo "# Compilation des membres de la bibliotheque lib"$diri".a"
     161      echo '.PRECIOUS   : $(LIBO)/lib'$topdiri'.a'
     162      echo
     163      echo
     164      echo "# Compilation of elements in $diri of library lib"$topdiri".a"
    155165      echo
    156166      for trufile in $listlib ; do
     
    159169                 egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1
    160170                 egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1
    161          str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$trufile
     171         str1='$(LIBO)/lib'$topdiri'.a('$fili'.o) : $(LIBF)/'$trufile
    162172         [ "$fili" = "$diri/chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F
    163173
     
    175185            strj=`echo $stri | tr [A-Z] [a-z]`
    176186            str2=""
    177             for dirinc in filtrez bibio dyn3d_common grid dyn3d phydev $diri $diri/*/ ; do
     187            for dirinc in $src_dirs ; do
    178188# Recherche dans l'ordre hierarchique inverse car seule la derniere
    179189# ligne est conservee
    180                if [ $dirinc = phydev ] ; then
    181                    dirstr='$(PHYS)'
    182                    libstr='phy$(PHYS)'
    183                else
     190#               if [ $dirinc = phydev ] ; then
     191#                   dirstr='$(PHYS)'
     192#                   libstr='phy$(PHYS)'
     193#               else
    184194                   dirstr=$dirinc
    185195                   libstr=$dirinc
    186                fi
     196#               fi
    187197               echo dirinc $dirinc >> $logfile
    188198               if [ -f $dirinc/$stri ] ; then
     
    214224         # object from library
    215225         echo ' cd $(LIBO); \'
    216          echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \'
     226         echo ' $(AR) d $(LIBO)/lib'$topdiri'.a '$fili'.o ; \'
    217227         if [ "$F90" -eq '0' ] ; then
    218228         ## Fixed Form Fortran 77
     
    228238         fi
    229239         # Put generated object in library
    230          echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \'
     240         echo ' $(AR) r $(LIBO)/lib'$topdiri'.a '$fili'.o ; $(RM) '$fili'.o ; \'
    231241         echo
    232242      done
  • LMDZ5/trunk/makelmdz

    r2202 r2238  
    8484PARA_LD=""
    8585EXT_SRC=""
    86 
     86#src_dirs: directories containing source files
     87src_dirs="grid bibio"
    8788########################################################################
    8889# lecture des options
     
    106107          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
    107108[-chimie INCA/false]       : with INCA chemistry model or without (default: false)
     109[-cosp true/false]    : compile with/without cosp package (default: false)
     110[-sisvat true/false]  : compile with/without sisvat package (default: false)
     111[-rrtm true/false]    : compile with/without rrtm package (default: false)
    108112[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
    109113[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
     
    186190
    187191      "-ext_src")
    188           EXT_SRC=$2 ; shift ; shift ;;
     192          EXT_SRC=$2 ; src_dirs="$src_dirs $EXT_SRC" ; shift ; shift ;;
    189193
    190194      "-arch")
     
    283287then
    284288   #We'll use some physics
     289   src_dirs="$src_dirs phy$physique"
    285290   CPP_KEY="$CPP_KEY CPP_PHYS"
    286291   if [[ "${physique:0:3}" == "lmd" ]]
     
    316321      echo "You should use option \"-mem\"."
    317322      exit 1
    318   fi     
     323  fi
    319324fi
    320325
     
    413418   CPP_KEY="$CPP_KEY CPP_COSP"
    414419   COSP_PATH="$LIBFGCM/cosp"
     420   src_dirs="$src_dirs cosp"
    415421#   LIB="${LIB} -l${LIBPREFIX}cosp"
    416422   opt_dep="$opt_dep cosp"
     
    422428then
    423429   CPP_KEY="$CPP_KEY CPP_SISVAT"
     430   src_dirs="$src_dirs phy${physique}/sisvat"
    424431fi
    425432
     
    427434then
    428435   CPP_KEY="$CPP_KEY CPP_RRTM"
     436   src_dirs="$src_dirs phy${physique}/rrtm"
    429437fi
    430438
     
    489497
    490498if (( $dimc == 3 )) ; then
     499   src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}"
    491500   cd $LIBFGCM/grid
    492501   \rm fxyprim.h
     
    498507   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
    499508elif (( $dimc == 1 )) ; then
     509   src_dirs="$src_dirs dyn3d dyn3d_common filtrez"
    500510   CPP_KEY="$CPP_KEY CPP_1D"
    501511   filtre="L_DYN= DYN= FILTRE= L_FILTRE= DIRMAIN=phy$physique "
     
    539549cd $LMDGCM
    540550
    541 find libf -name '*.[Fh]' -print > tmp77
    542 find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90
    543 find libf -name '*.F90' -print >> tmp90
    544 
    545 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 ]]
     551find libf -name '*.[Fh]' -print | sort > tmp77
     552#find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90
     553find libf -name '*.F90' -print | sort > tmp90
     554
     555if [[ -r .makelmdz ]]
     556then
     557old_lmdz_configuration=$(cat .makelmdz )
     558else
     559old_lmdz_configuration=""
     560fi
     561lmdz_configuration="$src_dirs"
     562if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]]
     563then
     564  configuration_change="true"
     565else
     566  configuration_change="false"
     567fi
     568
     569if [[ $configuration_change == "true" || ! ( -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 ]]
    546570then
    547571  echo "les fichiers suivants ont ete crees ou detruits"
     
    551575  \cp -f tmp77 liste_des_sources_f77
    552576  \cp -f tmp90 liste_des_sources_f90
    553   echo "on recree le makefile"
    554   ./create_make_gcm > tmp
     577  echo "Recreating the makefile"
     578  echo "src_dirs: $src_dirs"
     579  ./create_make_gcm $src_dirs > tmp
    555580  \mv -f tmp makefile
    556   echo "Nouveau makefile cree"
    557 fi
     581  echo "New makefile created"
     582fi
     583
     584#Create a .makelmdz file containing main compilation option for later comparisons
     585echo "$lmdz_configuration" > .makelmdz
    558586
    559587#################################################################
  • LMDZ5/trunk/makelmdz_fcm

    r2202 r2238  
    7878          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
    7979[-chimie INCA/false]       : with INCA chemistry model or without (default: false)
     80[-cosp true/false]    : compile with/without cosp package (default: false)
     81[-sisvat true/false]  : compile with/without sisvat package (default: false)
     82[-rrtm true/false]    : compile with/without rrtm package (default: false)
    8083[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
    8184[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
Note: See TracChangeset for help on using the changeset viewer.