#!/bin/csh # # $Header$ # #set verbose echo ######################################################################## # options par defaut pour la commande make ######################################################################## set dim="96x71x19" set physique=lmd set phys="PHYS=$physique" set include='-I$(LIBF)/grid -I$(LIBF)/bibio -I. ' set ntrac = 4 set filtre=filtrez set grille=reg set couple=false set veget=true set psmile=false set OPT_STACK='-Wf,-init stack=nan' set OPT_STACK=' ' set OPTIMI='-C debug -eC ' set OPTIMI=' -ftrace ' set io=ioipsl ######################################################################## # path a changer contenant les sources et les objets du modele ######################################################################## ###### VERSION LMDZ.4 # set LMDGCM=$HOME/LMDZ.4 # setenv localdir "`pwd`" set MODIPSL=0 echo $localdir | grep modipsl >& /dev/null if ( ! $status ) then set MODIPSL=1 setenv LMDGCM $localdir cd ../.. setenv LIBOGCM "`pwd`/lib" setenv IOIPSLDIR $LIBOGCM setenv MODIPSLDIR $LIBOGCM cd $localdir if ( `hostname` == rhodes ) then set NCDFINC=`grep sxnec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"` set NCDFLIB=`grep sxnec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'` else if ( `hostname` == nymphea0 ) then set NCDFINC=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"` set NCDFLIB=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'` else if ( `hostname` == mercure ) then set NCDFINC=`grep sx6nec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"` set NCDFLIB=`grep sx6nec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'` else echo 'Probleme de definition des variables NCDFINC et NCDFLIB' endif endif else if ( ! $?LMDGCM ) then echo You must initialize the variable LMDGCM in your environnement echo for instance: "setenv LMDGCM /usr/myself/supergcm" in .cshrc exit endif if ( ! $?LIBOGCM ) then set LIBOGCM=$LMDGCM/libo endif if ( ! $?IOIPSLDIR ) then echo You must initialize the variable IOIPSLDIR in your environnement echo for instance: "setenv IOIPSLDIR /usr/myself/ioipsl" in .cshrc exit else setenv MODIPSLDIR $IOIPSLDIR endif if ( ! $?NCDFLIB ) then echo You must initialize the variable NCDFLIB in your environnement echo for instance: "setenv NCDFLIB /usr/myself/netcdf" in .cshrc exit endif if ( ! $?NCDFINC ) then echo You must initialize the variable NCDFINC in your environnement echo for instance: "setenv NCDFINC /usr/myself/netcdf" in .cshrc exit endif endif set model=$LMDGCM set libo=$LIBOGCM ######################################################################## # Les differentes platformes reconnues ######################################################################## set HP=0 set IBM=0 set SUN=0 set VPP=0 set CRAY=0 set DEC=0 set LINUX=0 set NEC=0 set XNEC=0 set X6NEC=0 if ( `uname` == HP-UX ) then set machine=HP set HP=1 else if (`uname` == UNIX_System_V ) then set machine=VPP set VPP=1 else if (`uname` == SunOS ) then set machine=SUN set SUN=1 else if ( `uname` == AIX ) then set machine=IBM set IBM=1 else if ( `uname` == OSF1 ) then set machine=ALPHA set DEC=1 else if ( `uname` == Linux && `hostname` != mercure ) then set machine=LINUX set LINUX=1 else if ( `hostname` == atlas || `hostname` == axis || `hostname` == etoile ) then set machine=CRAY set CRAY=1 else if ( `uname` == SUPER-UX ) then set machine=NEC set NEC=1 else if ( `hostname` == rhodes) then set machine=XNEC set XNEC=1 else if ( `hostname` == mercure) then set machine=X6NEC set X6NEC=1 else echo Vous travaillez sur une machine non prevue par le reglement exit endif if ( ! -d $libo ) then mkdir $libo endif if $VPP then set netcdf=netcdf_v else set netcdf=netcdf endif ######################################################################## # Quelques initialisations de variables du shell. ######################################################################## set dyn= set opt_link="" set adjnt="" set opt_dep="" set optim="" set optimbis="" set optim90="" set oplink="" ######################################################################## # Optimisations par defaut suivant les machines ######################################################################## echo "Optimisations par defaut suivant les machines" set libf=$model/libf #setenv localdir "LOCAL_DIR=`pwd`" #setenv localdir "`pwd`" cd $model ############# if $CRAY then ############# # set optim="-Wf'-ei' -dp -Wf'-a static'" set optimbis=" -DCRAY " set optim90="-Wp'-P' -DCRAY -p$IOIPSLDIR "'-p$(LIBO) -eiv ' set optim="$optim90" set oplink="-Wl'-DSTACK=128 -f indef' -L$IOIPSLDIR -lioipsl -L$NCDFLIB -lnetcdf " set mod_loc_dir=" " set mod_suffix=" " ################# else if $SUN then ################# set optim=" -fast " set optimbis=" " set optim90=" -fast -fixed " set optimtru90=" -fast -free " set opt_link="-lf77compat -L$MODIPSLDIR -lsechiba -lparameters -lstomate -lioipsl -L$NCDFLIB -lnetcdf " set mod_loc_dir=$localdir set mod_suffix=mod ################# else if $HP then ################# set optim=" +U77 -O +E1 " set optimbis=" " ################# else if $IBM then ################# set optim=" -O3 -qtune=pwr2 -qarch=pwr2" set optimbis=" " ################# else if $VPP then ################# # set optim="-Dasuxm -On, -g -Ad -Potilax -Eciplume -Si" # set optimbis=" -Wv,-m3 -Wp,-DVPP -Z $LMDGCM/listage" set optimbis=" -Wp,-DNC_DOUBLE -Ad -Z $LMDGCM/listage -X9" set optim90="$optim $optimbis -X9 -w" set mod_loc_dir=$MODIPSLDIR set mod_suffix=mod ################# else if $DEC then ################# set optim=" " set optimbis=" " ################# else if $LINUX then ################# set optim="-fast " set optim90=" -fast " # set optimtru90=" -fast -c -Mfree -module $MODIPSLDIR " set optimtru90=" -fast -c -Mfree " set opt_link=" -Mfree -L /usr/local/pgi/linux86/lib -lpgf90 -lpgftnrtl -lpghpf -lpghpf2 -L$MODIPSLDIR -lsechiba -lparameters -lstomate -L$NCDFLIB -lnetcdf -lioipsl -Wl,-Bstatic -L/usr/lib/gcc-lib/i386-linux/2.95.2/" set mod_loc_dir=$MODIPSLDIR set mod_suffix=mod ################# else if $NEC then ################# set optim90=' -clear -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "' set optimtru90=' -clear -f4 -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "' set optim="$optim90" set optimbis=" " set opt_link=" -C hopt -float0 -ew -P static -L$MODIPSLDIR -lioipsl $NCDFLIB -lnetcdf_i8r8_v " set mod_loc_dir="." set mod_suffix="mod" ################# else if $XNEC then ################# set optdbl='-dw -Wf\"-A dbl4\"' set optim90=' -clear -float0 -Ep -DNC_DOUBLE -dw -Wf\"-A dbl4\" -R5 -Wf,"-pvctl loopcnt=40000 fullmsg noassume "' set optimtru90=' -clear -f4 -float0 -Ep -DNC_DOUBLE -dw -Wf\"-A dbl4\" -R2 -R3 -R4 -R5 -Wf,"-pvctl loopcnt=40000 fullmsg noassume"' set optim="$optim90" set optimbis=" " set mod_suffix="mod" set mod_loc_dir="./" else if $X6NEC then set optdbl='-dw -Wf\"-A dbl4\"' set optim90=' -clear -float0 -size_t64 -Ep -DNC_DOUBLE -dw -Wf\"-A dbl4\" -R5 -Wf,"-pvctl loopcnt=40000 fullmsg noassume "' set optimtru90=' -clear -f4 -float0 -size_t64 -Ep -DNC_DOUBLE -dw -Wf\"-A dbl4\" -R2 -R3 -R4 -R5 -Wf,"-pvctl loopcnt=40000 fullmsg noassume"' set optim="$optim90" set optimbis=" " set mod_suffix="mod" set mod_loc_dir="./" else set optim="" set optimbis=" " endif set nomlib=$machine ######################################################################## # lecture des options de mymake ######################################################################## top: if ($#argv > 0) then switch ($1:q) case -h: ######################################################################## # Manuel en ligne ######################################################################## more <> tmp end set suf= foreach i ( `sort tmp | uniq ` ) set suf=$suf$i end if ( ! $IBM ) then set nomlib="$nomlib$suf" endif if ( $DEC ) then set nomlib=DEC endif if ( $IBM ) then set dim=`echo $dim | sed -en 's/[^0-9]/ /g'` set dim_=`echo $dim | sed -en 's/[^0-9]/_/g'` else if ( $SUN ) then set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'` else set dim=`echo $dim | sed -n -e 's/[^0-9]/ /gp'` set dim_=`echo $dim | sed -n -e 's/[^0-9]/_/gp'` endif set nomlib=${nomlib}${physique}_${dim_}_t${ntrac}_$grille ## M-A-F nomlib trop long sur CRAY pour ar if ( $CRAY ) then set nomlib=F90_${dim_}_t${ntrac} endif if ( $NEC || $XNEC || $X6NEC) then set nomlib=F90_${dim_}_t${ntrac} endif echo calcul de la dimension set dimc=`echo $dim | wc -w` if ( "$dimc" == "2" ) then set include="$include "'-I$(LIBF)/dyn2d ' set dimh=$dim else set include="$include "'-I$(LIBF)/dyn3d ' set dimh=`echo $dim | awk ' { print $1 "." $2 } '` endif echo $dimc ######################################################################## # path pour les #include ######################################################################## if ( $XNEC ) then set include="$include -I$NCDFINC -I$IOIPSLDIR" else set include="$include -I$NCDFINC -I$IOIPSLDIR" endif echo $include ######################################################################## # Gestion des dimensions du modele. # on cree ou remplace le fichier des dimensions/nombre de traceur ######################################################################## cd $libf/grid if ( -f dimensions.h ) then echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," echo vous pouvez continuer en repondant oui. echo "Voulez-vous vraiment continuer?" if ( $< == "oui" ) then \rm -f $libf/grid/dimensions.h else exit endif endif cd dimension ./makdim $ntrac $dim cat $libf/grid/dimensions.h cd $LMDGCM set libo=$libo/$nomlib if ( ! -d $libo ) then mkdir $libo cd $model endif ######################################################################## # Differentes dynamiques (3d, 2d, 1d) ######################################################################## set dimension=`echo $dim | wc -w` echo dimension $dimension if ( $dimension == 1 ) then echo pas de dynamique set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique " endif endif cd $model if ( $dimension == 3 ) then cd libf/grid \rm fxyprim.h cp -p fxy_${grille}.h fxyprim.h endif ###################################################################### # Traitement special pour le nouveau rayonnement de Laurent Li. ###################################################################### if ( -f $libf/phy$physique/raddim.h ) then if ( -f $libf/phy$physique/raddim.$dimh.h ) then \rm -f $libf/phy$physique/raddim.h cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h echo $libf/phy$physique/raddim.$dimh.h cat $libf/phy$physique/raddim.$dimh.h cat $libf/phy$physique/raddim.h else echo On peut diminuer la taille de l executable en creant echo le fichier $libf/phy$physique/raddim.$dimh.h \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h endif endif ###################################################################### # Gestion du filtre qui n'existe qu'en 3d. ###################################################################### if ( `expr $dimc \> 2` == 1 ) then set filtre="FILTRE=$filtre" else set filtre="FILTRE= L_FILTRE= " endif echo MACRO FILTRE $filtre echo $dimc ######################################################################## # utilisation des vraies routines de couplage si on est en couple ######################################################################## if ( $couple == 'true' ) then banner couple pwd if ( `diff $libf/phy$physique/oasis.F $libf/phy$physique/oasis.true | wc -w` ) then \cp $libf/phy$physique/oasis.F $libf/phy$physique/oasis.dummy \cp $libf/phy$physique/oasis.true $libf/phy$physique/oasis.F endif else if ( `diff $libf/phy$physique/oasis.F $libf/phy$physique/oasis.dummy | wc -w` ) then \cp $libf/phy$physique/oasis.F $libf/phy$physique/oasis.true \cp $libf/phy$physique/oasis.dummy $libf/phy$physique/oasis.F endif endif ######################################################################## # Avant de lancer le make, on recree le makefile si necessaire ######################################################################## # c'est a dire dans 3 cas: # 1. si la liste des fichiers .F et .h a ete modifiee depuis la # derniere creation du makefile # 2. si le fichier contenant cette liste "liste_des_sources" # n'existe pas. # 3. Si le makefile n'existe pas. ######################################################################## cd $model find libf -name '*.[Fh]' -print >! tmp77 find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print >! tmp90 find libf -name '*.[Fh]90' -print >> tmp90 if ( `diff tmp77 liste_des_sources_f77 | wc -w` \ || `diff tmp90 liste_des_sources_f90 | wc -w` \ || ! -f makefile \ || ! -f liste_des_sources_f90 \ || ! -f liste_des_sources_f77 ) then echo les fichiers suivants ont ete crees ou detruits echo ou les fichiers suivants sont passes ou ne sont plus en Fortran 90 diff liste_des_sources_f77 tmp77 diff liste_des_sources_f90 tmp90 \cp tmp77 liste_des_sources_f77 \cp tmp90 liste_des_sources_f90 echo On recree le makefile ./create_make_gcm >! tmp \mv tmp makefile echo Nouveau makefile cree. endif ######################################################################## # Execution de la comande make ######################################################################## echo PHYSIQUE $phys echo dynamique $dyn $dimension echo OPTIM="$optim" $filtre LIBO=$libo $dyn PHYS=$phys DIM=$dimc PROG=$code echo PATH pour les fichiers INCLUDE $include echo OPLINK="$oplink" ################# if $HP then ################# set f77='fort77 +OP' set f90='jensaisrien' set opt_link="$opt_link -lm" ################# else if $VPP then ################# set f77=frt set f90=$f77 if ($couple == true) then set opt_link="-Wg,-c $MODIPSLDIR/liboasis2.4_mpi2.a /usr/lang/mpi2/lib64/libmpi.a /usr/lang/mpi2/lib64/libmp.a -L$MODIPSLDIR -lioipsl /usr/local/lib/lib64/libnetcdf_cc_31.a" set oplink="-Wl,-t,-P,-dy " else set opt_link="-Wg,-c -L$MODIPSLDIR -lioipsl /usr/local/lib/lib64/libnetcdf_cc_31.a" set oplink="-Wl,-t,-dy " endif if ($veget == true) then set opt_link="$opt_link $link_veget -lioipsl /usr/local/lib/lib64/libnetcdf_cc_31.a" endif ################# else if $CRAY then ################# set f77=f90 set f90=f90 ################# else if $LINUX then ################# set f77=pgf90 set f90=pgf90 set opt_link=" -Mfree -L /usr/local/pgi/linux86/lib -lpgf90 -lpgftnrtl -lpghpf -lpghpf2 -L$MODIPSLDIR $link_veget -L$NCDFLIB -lnetcdf -lioipsl -Wl,-Bstatic -L/usr/lib/gcc-lib/i386-linux/2.95.2/" ################# else if $SUN then ################# set f77=f90 set f90=f90 set opt_link="-lf77compat -L$MODIPSLDIR $link_veget -lioipsl -L$NCDFLIB -lnetcdf " ################# else if $NEC then ################# set f77=f90 -ftrace set f90=f90 -ftrace set opt_link="-L$MODIPSLDIR" if ($veget == true) then set opt_link="$opt_link $link_veget" endif if ($couple == true) then set opt_link="$opt_link -lioipsl -loasis2.4_mpi2 -float0 -ew -P static $NCDFLIB " else set opt_link="$opt_link -L$MODIPSLDIR -lioipsl -float0 -ew -P static $NCDFLIB " endif set mod_loc_dir="./" ################# else if $XNEC then ################# set f77="sxmpif90 -ftrace" set f90="sxmpif90 -ftrace" if $MODIPSL then set opt_link="-L$MODIPSLDIR" if ($veget == true) then set opt_link="$opt_link $link_veget" endif if ($couple == true) then set opt_link="$opt_link -lsxioipsl -loasis2.4_mpi2 -float0 $optdbl -P static $NCDFLIB " if ($psmile == true) then endif else set opt_link="$opt_link -lsxioipsl -float0 $optdbl -P static $NCDFLIB " endif else if ($couple == true) then set opt_link="-L$MODIPSLDIR" set opt_link="$opt_link $link_veget -lsxioipsl -loasis2.4_mpi2 -float0 $optdbl -P static $NCDFLIB " else set opt_link=" -C hopt -float0 $optdbl -P static -L$MODIPSLDIR $link_veget -lsxioipsl $NCDFLIB " endif endif set mod_loc_dir="./" ################## else if $X6NEC then ################## set f77=sxmpif90 set f90=sxmpif90 if $MODIPSL then set opt_link="-L$MODIPSLDIR" if ($veget == true) then set opt_link="$opt_link -lsxsechiba -lsxparameters -lsxstomate" endif if ($couple == true) then set opt_link="$opt_link -lsxioipsl -loasis2.4_mpi2 -float0 -size_t64 $optdbl -P static $NCDFLIB " else set opt_link="$opt_link -lsxioipsl -float0 -size_t64 $optdbl -P static $NCDFLIB " endif else set opt_link=" -float0 -size_t64 $optdbl -P static -L$MODIPSLDIR -lsxsechiba -lsxparameters -lsxstomate -lsxioipsl $NCDFLIB " endif set mod_loc_dir="./" ################# else ################# set f77=f77 set f90=f90 endif cd $model if $VPP then set make="gmake RANLIB=ls" else if $CRAY then set make="make RANLIB=ls" else if $NEC then set make="make RANLIB=ls" else if $LINUX then set make="make -k RANLIB=ranlib" else if $XNEC then set make="gmake RANLIB=ls" else if $X6NEC then set make="gmake RANLIB=ls" else set make="make RANLIB=ranlib" endif # # les deux test suivants sont "temporaires" pour pallier des "faiblesses" du # compilateur fortran Sun: f90: SC4.0 11 Sep 1995 FORTRAN 90 1.1 # #if ($code == 'create_limit' && $SUN) then # set link=f77 # set opt_link="-L$NCDFLIB -lnetcdf" #endif #if ($code == 'create_etat0' && $SUN) then # if ( ! -f $libo/libdyn3d.a ) then # echo "Priere de compiler gcm en premier pour des raisons d'optimisation" # \rm $libf/grid/dimensions.h # exit # endif # set optim=" -dalign " # set optim90=" -dalign -fixed " # set opt_link="-L$IOIPSLDIR -lioipsl -L$NCDFLIB -lnetcdf" # set link="$f90 $optim90" # touch $LMDGCM/libf/dyn3d/startvar.F # touch $LMDGCM/libf/dyn3d/etat0_netcdf.F #endif # # etat0_netcdf a besoin d'info de la physique # A revoir set include="$include"' -I$(LIBF)/phy'"$physique" # # le programme principal create_limit a besoin de l'info du module # startvar: on met donc libo dans les include pour Nec set include="$include"' -I$(LIBO)' ################################################################# # Execution de la comande make... ENFIN! ################################################################# if $VPP then set optim90=" $optim90 -Am -M$libo" set optimtru90="$optim90" \cp $IOIPSLDIR/*.mod $libo else if $SUN then set optim90=" $optim90 -M$libo -M$MODIPSLDIR " set optimtru90=" $optimtru90 -M$libo -M$MODIPSLDIR " set optim="$optim90" \cp $IOIPSLDIR/*.mod $libo else if $NEC then set optim90=" $optim90 -I$libo " else if $XNEC then set optim90=" $optim90 -I$libo " set optimtru90=" $optimtru90 -I$libo " else if $X6NEC then set optim90=" $optim90 -I$libo " set optimtru90=" $optimtru90 -I$libo " else if $LINUX then set optimtru90=" $optimtru90 -module $libo " set optim90=" $optim90 -module $libo " set optim="$optim90" set mod_loc_dir=$libo \cp /d3/fairhead/sechiba/ioipsl/*.mod $libo \cp $IOIPSLDIR/*.mod $libo endif set link="$f90 $optim90" set ar=ar if $XNEC then set link="sxld $opt_link" set link="$f90 " # set ar=sxar else if $X6NEC then set link="sxld $opt_link" set link="$f90 " endif cd $localdir echo $make -f $LMDGCM/makefile \ OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \ OPTIM90="$optim90" \ OPTIMTRU90="$optimtru90" \ OPTIM="$optim$optimbis" \ INCLUDE="$include" \ $filtre \ LIBO=$libo \ $dyn \ $phys \ DIM=$dimc \ L_ADJNT="$adjnt" \ LOCAL_DIR="$localdir" \ F77="$f77" \ F90="$f90" \ OPLINK="$oplink" \ LINK="$link" \ GCM="$LMDGCM" \ MOD_LOC_DIR=$mod_loc_dir \ MOD_SUFFIX=$mod_suffix \ AR=$ar \ PROG=$code $make -f $LMDGCM/makefile \ OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \ OPTIM90="$optim90" \ OPTIMTRU90="$optimtru90" \ OPTIM="$optim$optimbis" \ INCLUDE="$include" \ $filtre \ LIBO=$libo \ $dyn \ $phys \ DIM=$dimc \ L_ADJNT="$adjnt" \ LOCAL_DIR="$localdir" \ F77="$f77" \ F90="$f90" \ OPLINK="$oplink" \ LINK="$link" \ GCM="$LMDGCM" \ MOD_LOC_DIR=$mod_loc_dir \ MOD_SUFFIX=$mod_suffix \ AR=$ar \ PROG=$code \rm -f $libf/grid/dimensions.h