#!/bin/csh -f # # $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake.dec,v 1.2 1998/04/23 21:00:52 cnh Exp $ # # Makefile generator for MITgcm UV codes # # Generate make files for Digital UNIX system set mfile = ( Makefile.dec ) set mach = ( 'Digital Unix/Alpha' ) # *************************************************************************************************** # Directories for source, includes, binaries and executables # *************************************************************************************************** # Note # o If you prefer/need everything under a single directory # copy everything in ../eesupp/src, ../model/src, # ../eesupp/inc and model/inc into a directory and then # edit the paths below to read # set EESUPP_SDIR = ( ) # set MODEL_SDIR = ( ) # set EESUPP_IDIR = ( ) # set MODEL_IDIR = ( ) # set TDIR = ( ) # set BDIR = ( ) # set EDIR = ( ) set EESUPP_SDIR = ( ../eesupp/src/ ) set MODEL_SDIR = ( ../model/src/ ) set EESUPP_IDIR = ( ../eesupp/inc/ ) set MODEL_IDIR = ( ../model/inc/ ) set TDIR = ( ../tools/ ) set BDIR = ( ../bin/ ) set EDIR = ( ../exe/ ) set EXE = ( barrier ) # *************************************************************************************************** # Pathnames and arguments for the commands used on this platform # FCOMP1p is used for routines where we want kapf90 directed parallelisation. # FCOMP1s is used for routines where we want kapf90 serial optimisation. Sometimes # it is better to use -O5 and no KAP serial optimisation. # *************************************************************************************************** set CPP = ( '/usr/bin/cpp -P $(INCLUDES) -DTARGET_DEC' ) set FCOMP1p = ( 'kapf90 -scan=132 -noconc -cmp=' ) set FCOMP1s = ( 'cat >' ) set FCOMP2 = ( 'f90 $(INCLUDES) -r8 -extend_source -u -O5 -fast -tune host -automatic -call_shared -c -notransform_loops -align dcommons -p1 -g1 -inline all' ) set FCOMP20 = ( 'f90 $(INCLUDES) -extend_source -u -g -c -automatic -align dcommons -r8 -p1 -g1' ) set LINK1 = ( 'f77 -O5 -fast -tune host -automatic -call_shared -align dcommons -p1 -g1' ) set LINK2 = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' ) set INCLUDES = ( '-I. -I$(EESUPP_IDIR) -I$(MODEL_IDIR)' ) set MAKEDEPEND = ( /usr/bin/X11/makedepend ) # *************************************************************************************************** # Write Makefile.xxx header # *************************************************************************************************** echo "Creating make file ${mfile} " echo "#" > ${mfile} echo "# Multithreaded + multi-processing makefile for $mach " >> ${mfile} echo "# This make file was generated automatically by the command" >> ${mfile} echo "# " \"${0}\" >> ${mfile} echo "# on `hostname`:`pwd` " >> ${mfile} echo "# " `date` >> ${mfile} echo "# by $user" >> ${mfile} echo "# Notes " >> ${mfile} echo "# ===== " >> ${mfile} echo "# Digital UNIX parallel threads are controlled by" >> ${mfile} echo "# setenv PARALLEL " >> ${mfile} echo "# The variable KMP_STACKSIZE is also with threaded code" >> ${mfile} echo "# setenv KMP_STACKSIZE 10000000" >> ${mfile} echo "# sets the stack to 10MB. The default size (1MB) is " >> ${mfile} echo "# usually too small. " >> ${mfile} echo "# " >> ${mfile} cat >> ${mfile} <> ${mfile} echo 'CPP =' ${CPP} >> ${mfile} echo "# Fortran compiler " >> ${mfile} echo 'FCOMP1p = '${FCOMP1p} >> ${mfile} echo 'FCOMP1s = '${FCOMP1s} >> ${mfile} echo 'FCOMP2 = '${FCOMP2} >> ${mfile} echo 'FCOMP20 = '${FCOMP20} >> ${mfile} echo "# Link editor " >> ${mfile} echo 'LINK1 = '${LINK1} >> ${mfile} echo 'LINK2 = '${LINK2} >> ${mfile} echo "# Header dependency" >> ${mfile} echo 'MAKEDEPEND = '${MAKEDEPEND} >> ${mfile} echo " " >> ${mfile} # *************************************************************************************************** # Generate build commands for individual .F files # *************************************************************************************************** # Execution environment code if ( ${EESUPP_SDIR} != ${MODEL_SDIR} ) then set sdir = ( ${EESUPP_SDIR} ) set sdir_pref = ( '$(EESUPP_SDIR)' ) set rp = rp1 goto make-mf-entries rp1: set eesupp_files = ( $files ) set eesupp_slist = ( $slist ) set eesupp_olist = ( $olist ) endif # "Model" code set sdir = ( ${MODEL_SDIR} ) set sdir_pref = ( '$(MODEL_SDIR)' ) set rp = rp2 goto make-mf-entries rp2: set model_files = ( $files ) set model_slist = ( $slist ) set model_olist = ( $olist ) # *************************************************************************************************** # Generate file lists for various mmake utilities # *************************************************************************************************** echo " " >> ${mfile} echo "# =========== " >> ${mfile} echo "# File lists " >> ${mfile} echo "# =========== " >> ${mfile} set flist = ( ${eesupp_olist} ); set fpref = ( ); set vnam = ( eesupp_objs ) set rp = rp3 goto make-mf-list rp3: set flist = ( ${eesupp_slist} ); set fpref = ( '$(EESUPP_SDIR)' ); set vnam = ( eesupp_srcs ) set rp = rp4 goto make-mf-list rp4: set flist = ( ${eesupp_slist} ); set fpref = ( ); set vnam = ( eesupp_sfil ) set rp = rp5 goto make-mf-list rp5: set flist = ( ${model_olist} ); set fpref = ( ); set vnam = ( model_objs ) set rp = rp6 goto make-mf-list rp6: set flist = ( ${model_slist} ); set fpref = ( '$(MODEL_SDIR)' ); set vnam = ( model_srcs ) set rp = rp7 goto make-mf-list rp7: set flist = ( ${model_slist} ); set fpref = ( ); set vnam = ( model_sfil ) set rp = rp8 goto make-mf-list rp8: echo 'objs = $(eesupp_objs) $(model_objs)' >> ${mfile} echo 'srcs = $(eesupp_srcs) $(model_srcs)' >> ${mfile} echo 'sfil = $(eesupp_sfil) $(model_sfil)' >> ${mfile} echo " " >> ${mfile} # *************************************************************************************************** # Write top-level rules for building the executable, # generating dependencies etc... # *************************************************************************************************** echo "# =========== " >> ${mfile} echo "# Begin rules " >> ${mfile} echo "# =========== " >> ${mfile} echo " " >> ${mfile} echo '$(EXE): $(objs) ' >> ${mfile} echo ' $(LINK1) -o $(EXE) $(objs) $(LINK2)' >> ${mfile} echo " " >> ${mfile} echo 'clean: ' >> ${mfile} echo ' rm *.o *.f *.out *.cmp ' >> ${mfile} echo " " >> ${mfile} echo 'depend: ' >> ${mfile} echo ' @-ln -s $(srcs) . ;$(MAKEDEPEND) -o .p.f -f $(TDIR)'${mfile}' $(INCLUDES) $(sfil) ' >> ${mfile} echo " " >> ${mfile} # *************************************************************************************************** # Add per file dependencies # *************************************************************************************************** cat ${mfile}.$$ >> ${mfile} \rm ${mfile}.$$ # *************************************************************************************************** # THE END # *************************************************************************************************** exit # *************************************************************************************************** # This block generates the commands to turn a .F file into a .o file. # It may need to be customised for different platforms. # *************************************************************************************************** make-mf-entries: set files = ( ); set slist = ( ); set olist = ( ); set flist = `ls -1 ${sdir} | grep '.*\.F'` if ( "${flist}" != "" ) then foreach f ( $flist ) set fname = ( ${f:t} ) set pf = ( ${fname:r}.p.f ) set kf = ( ${fname:r}.f ) set of = ( ${fname:r}.o ) echo ${pf}: "${sdir_pref}"${fname} >> ${mfile}.$$ echo ' @echo Preprocessing '"${sdir_pref}"${fname} >> ${mfile}.$$ echo ' @ $(CPP) '"${sdir_pref}"${fname}' > '$pf >> ${mfile}.$$ if ( "$fname" == "main.F" ) then echo ${kf}: ${pf} >> ${mfile}.$$ echo ' @echo KAP '${pf} >> ${mfile}.$$ echo ' @ $(FCOMP1p)'$kf ${pf} >> ${mfile}.$$ else echo ${kf}: ${pf} >> ${mfile}.$$ echo ' @echo KAP '${pf} >> ${mfile}.$$ echo ' @ $(FCOMP1s)'$kf ${pf} >> ${mfile}.$$ endif if ( "$fname" == "barrier.F" ) then echo ${of}: ${kf} >> ${mfile}.$$ echo ' @echo Compiling '${kf} >> ${mfile}.$$ echo ' @ $(FCOMP20)' ${kf} >> ${mfile}.$$ else echo ${of}: ${kf} >> ${mfile}.$$ echo ' @echo Compiling '${kf} >> ${mfile}.$$ echo ' @ $(FCOMP2)' ${kf} >> ${mfile}.$$ endif set files = ( ${files} ${fname} ) set slist = ( ${slist} ${f} ) set olist = ( ${olist} ${of} ) end endif goto ${rp} make-mf-list: if ( $#flist == 0 ) then echo ${vnam} = >> ${mfile} else if ( $#flist == 1 ) then echo ${vnam} = "${fpref}"${flist} >> ${mfile} else echo ${vnam} = "${fpref}"$flist[1] '\' >> ${mfile} set count = 2 while ( $count < $#flist ) echo ' '"${fpref}"$flist[$count] '\' >> ${mfile} @ count = $count + 1 end echo ' '"${fpref}"$flist[$#flist] >> ${mfile} endif echo " " >> ${mfile} goto $rp # $ Id: $