#!/bin/csh -f # $Header: /users/lmdz/cvsroot/LMDZ.3.3/makegcm,v 1.21 2001/07/04 08:41:44 lmdz Exp $ #set verbose echo ######################################################################## # options par defaut pour la commande make ######################################################################## set dim="64x48x32" set physique=mars set phys="PHYS=$physique" set include='-I$(LIBF)/grid -I$(LIBF)/bibio -I. -I$(LIBF)/aeronomars' set ntrac = 1 set filtre=filtrez set grille=reg set dyntype="dyn" set scatterers="1" ######################################################################## # path a changer contenant les sources et les objets du modele ######################################################################## #### If you want you can set environment variables here (instead of #### relying on the C-shell environment variables) # default LMDGCM to where makegcm script is located: #setenv LMDGCM "`dirname $0`" # You may set LIBOGCM to something else; otherwise we default to: #setenv LIBOGCM $LMDGCM/libo ## NetCDF Libraries: what follows is OK for LMD 32 and 64bit Linux Machines #if ( `uname -m` == "x86_64" ) then # 64 bit machines # setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_gfortran/lib # setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_gfortran/include #else # setenv NCDFLIB /donnees/emlmd/netcdf-4.0.1_gfortran/lib # setenv NCDFINC /donnees/emlmd/netcdf-4.0.1_gfortran/include #endif #### 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" 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 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 ( ! $?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 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 ) 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 echo Vous travaillez sur une machine non prevue par le reglement exit endif # create $libo directory if it doesn't exist 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 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 optim90="-Wp'-P' -DCRAY "'-p$(LIBO) -eiv ' set oplink="-Wl'-DSTACK=128 -f indef' -L$NCDFLIB -lnetcdf " set mod_loc_dir=" " set mod_suffix=" " else if $SUN then set optim90=" -fast" set optimtru90=" -fast -free" set opt_link="-L$NCDFLIB -lnetcdf" set mod_loc_dir=$localdir set mod_suffix=mod else if $HP then else if $IBM then else if $VPP then set optim90="$optim -X9 -w" if $COUPLE then set opt_link="-Wg,-c $IOIPSLDIR/liboasis2.4_mpi2.a /usr/lang/mpi2/lib64/libmpi.a /usr/lang/mpi2/lib64/libmp.a /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl" set oplink="-Wl,-t,-P,-dy " else set opt_link="-Wg,-c /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl" set oplink="-Wl,-t,-dy " endif set mod_loc_dir=$IOIPSLDIR set mod_suffix=mod else if $DEC then else if $LINUX then # Ehouarn 'gfortran' compiler set optim="-O3 -funroll-loops " set optim90="-O3 -funroll-loops " set optimtru90="-O3 -funroll-loops " # set opt_link=" -L$NCDFLIB -lnetcdf " set mod_loc_dir=$localdir 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 opt_link=" -C hopt -float0 -ew -P static -L$IOIPSLDIR -lioipsl -L/u/rech/psl/rpsl003/IOIPSL -lnetcdf_i8r8_v " set opt_link=" -C hopt -float0 -ew -P static -L/SX/usr/local/lib -lnetcdf_i8r8 " set mod_loc_dir="." set mod_suffix="mod" else if $XNEC then set optim90=' -clear -R5 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "' set optimtru90=' -clear -R5 -f4 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "' if $MODIPSL then if $COUPLE then set opt_link="-L$IOIPSLDIR -lsxioipsl -loasis2.4_mpi2 -float0 -ew -P static -I$NCDFINC $NCDFLIB " else set opt_link="-L$IOIPSLDIR -lsxioipsl -float0 -ew -P static -I$NCDFINC $NCDFLIB " endif set mod_loc_dir="./" else #### set opt_link=" -C hopt -float0 -ew -P static -L$IOIPSLDIR -lsxioipsl -L /u/rech/psl/rpsl003/IOIPSL -lnetcdf_i8r8_v -I$NCDFINC -L/SX/usr/local/lib -lnetcdf_i8r8" set opt_link=" -C hopt -float0 -ew -P static -I$NCDFINC -L/SX/usr/local/lib -lnetcdf_i8r8" set mod_loc_dir="." endif set mod_suffix="mod" endif # Ehouarn: add 'g9fortran' string to pathname set nomlib=${machine}_gfortran # Impose distinct name for 64 bit Linux machines (to avoid mixing 32 and 64) if (`uname` == Linux && `uname -m` == "x86_64") then set nomlib=${machine}64_gfortran endif ######################################################################## # 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 # dimension echo "dimension avant sed $dim" 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 || $XNEC ) 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'` set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'` endif # build final name of libraries directory: if ( "$dyntype" == "olddyn" ) then set nomlib=${nomlib}_${dim_}_t${ntrac}_s${scatterers}_${grille}_olddyn else set nomlib=${nomlib}_${dim_}_t${ntrac}_s${scatterers}_${grille} endif # Append 'physique' type, if it is not mars, to nomlib if ( "$physique" != "mars" ) then set nomlib=${nomlib}_${physique} endif ## M-A-F nomlib trop long sur CRAY pour ar if ( $CRAY ) then set nomlib=F90_${dim_}_t${ntrac} endif if ( $NEC || $XNEC ) 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 if ( "$dyntype" == "olddyn" ) then set include="$include "'-I$(LIBF)/olddyn3d ' else set include="$include "'-I$(LIBF)/dyn3d ' endif set dimh=`echo $dim | awk ' { print $1 "." $2 } '` endif echo "dimc is $dimc" ######################################################################## # path pour les #include ######################################################################## set include="$include -I$NCDFINC " 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 "WARNING: you are probably already compiling the model (perhaps" echo " elsewhere). Wait until the first compilation ends before " echo " compiling a different configuration." echo "If you are sure that you are not already compiling, then you" echo " may continue this compilation by answering yes." echo "Do you want to continue?" if ( $< == "yes" ) then #remove old dimensions.h file \rm -f $libf/grid/dimensions.h #remove old scatterers.h file \rm -f $libf/phymars/scatterers.h else exit endif endif # Build the appropriate 'dimensions.h' file cd dimension ./makdim $ntrac $dim # echo contents of dimensions.h to standard output cat $libf/grid/dimensions.h cd $libf/phymars/scatterers # Build the appropriate 'scatterers.h' file ./make_scatterers $scatterers # echo contents of scatterers.h to standard output cat $libf/phymars/scatterers.h cd $LMDGCM # set path to objects directory set libo=$libo/$nomlib # create objects directory, if it doesn't exist if ( ! -d $libo ) then mkdir $libo cd $model endif ######################################################################## # Differentes dynamiques (3d, 2d, 1d) ######################################################################## set dimension=`echo $dim | wc -w` echo dimension $dimension dim $dim 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 $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. ###################################################################### # set filtre to 'oldfiltrez' if using -olddyn option if ( "$dyntype" == "olddyn" ) then set filtre="oldfiltrez" endif if ( `expr $dimc \> 2` == 1 ) then set filtre="FILTRE=$filtre" else set filtre="FILTRE= L_FILTRE= " endif echo "MACRO FILTRE $filtre" echo "dimc $dimc" ######################################################################## # 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" if ("$dyntype" == "olddyn") then ./create_make_gcm olddyn3d grid bibio aeronomars phy$physique >! tmp else ./create_make_gcm dyn3d grid bibio aeronomars phy$physique >! tmp endif \mv tmp makefile echo "Nouveau makefile cree." endif ######################################################################## # Execution de la comande make ######################################################################## echo PHYSIQUE $phys echo dynamique $dyn $dimension echo OPTIM90="$optim90" $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 else if $CRAY then set f77=f90 set f90=f90 else if $LINUX then # set f77=pgf90 # set f90=pgf90 set f77=gfortran set f90=gfortran else if $SUN then set f77=f90 set f90=f90 else if $NEC then set f77=f90 set f90=f90 else if $XNEC then set f77=sxmpif90 set f90=sxmpif90 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="/usr/local/bin/gmake RANLIB=ls" set make="/usr/freeware/bin/gmake RANLIB=ls" else set make="make RANLIB=ranlib" endif set include="$include"" -I$libf/phy$physique" ################################################################# # Execution de la comande make... ENFIN! ################################################################# if $VPP then set optim90=" $optim90 -Am -M$libo" set optimtru90="$optim90" else if $SUN then set optim90=" $optim90 -M$libo" set optimtru90=" $optimtru90 " 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 $LINUX then # Ehouarn : adapt to gfortran set optim="$optim -I${libo}" set optim90="$optim90 -I${libo}" set optimtru90="$optimtru90 -ffree-form -I${libo}" # Ehouarn: remove set mod_loc_dir def below; mod_loc_dir=$localdir (set above) # set mod_loc_dir=$libo endif set link="$f90 $optim90" set ar=ar if $XNEC then set link="sxld $opt_link" set link="$f90 " # set ar=sxar endif cd $localdir echo $make -f $LMDGCM/makefile \ OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \ OPTIM="$optim" \ OPTIM90="$optim90" \ OPTIMTRU90="$optimtru90" \ INCLUDE="$include" \ $filtre \ LIBO=$libo \ $dyn \ $phys \ DIM=$dimc \ DYNTYPE="$dyntype" \ 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" \ OPTIM="$optim" \ OPTIM90="$optim90" \ OPTIMTRU90="$optimtru90" \ INCLUDE="$include" \ $filtre \ LIBO=$libo \ $dyn \ $phys \ DIM=$dimc \ DYNTYPE="$dyntype" \ 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 # cleanup, remove dimensions.h and scatterers.h \rm -f $libf/grid/dimensions.h \rm -f $libf/phymars/scatterers.h