#!/bin/csh -f # # $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake.sun,v 1.2 1998/04/23 21:00:52 cnh Exp $ # # Makefile generator for MITgcm UV codes # # Generate make files for Sun SOLARIS system set mfile = ( Makefile.sun ) set mach = ( 'Sun/SOLARIS' ) # *************************************************************************************************** # 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 # *************************************************************************************************** set CPP = ( '/usr/ccs/lib/cpp -P $(INCLUDES) -DTARGET_SUN' ) set FCOMP = ( 'f77 -stackvar -O5 -explicitpar -vpara -loopinfo -c -e -u -noautopar' \ '$(INCLUDES)' ) set FCOMP0 = ( 'f77 -stackvar -g -O0 -c -e -u $(INCLUDES)' ) set LINK = ( 'f77 -O5 -explicitpar -vpara -loopinfo -e -u -noautopar' ) set LINKOPTS = ('-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread ' \ '-lsocket -lnsl -fast' ) set INCLUDES = ( '-I. -I$(EESUPP_IDIR) -I$(MODEL_IDIR) ' \ '-I/usr/local/mpi/include' ) set MAKEDEPEND = ( /usr/openwin/bin/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 "# o Solaris parallel threads are controlled by" >> ${mfile} echo "# setenv PARALLEL " >> ${mfile} echo "# o The -stackvar option is important for multi-threaded" >> ${mfile} echo "# execution. Without it local variables may be allocated to" >> ${mfile} echo "# global bss storage which means they are not private " >> ${mfile} echo "# per thread. " >> ${mfile} echo "# " >> ${mfile} cat >> ${mfile} <> ${mfile} echo 'CPP =' ${CPP} >> ${mfile} echo "# Fortran compiler " >> ${mfile} echo 'FCOMP = '${FCOMP} >> ${mfile} echo 'FCOMP0 = '${FCOMP0} >> ${mfile} echo "# Link editor " >> ${mfile} echo 'LINK = '${LINK} >> ${mfile} echo 'LINKOPTS = '${LINKOPTS} >> ${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 ' $(LINK) -o $(EXE) $(objs) $(LINKOPTS)' >> ${mfile} echo " " >> ${mfile} echo 'clean: ' >> ${mfile} echo ' rm *.o *.f *.out *.cmp ' >> ${mfile} echo " " >> ${mfile} echo 'depend: ' >> ${mfile} echo ' @-ln -s $(srcs) . ;$(MAKEDEPEND) -o .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}.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}.$$ echo ${of}: ${pf} >> ${mfile}.$$ echo ' @echo Compiling '${pf} >> ${mfile}.$$ # Compile fbar.F without optimisation. This file holds the barrier # routines which rely on shared variables which can be accessed # concurrently. Optimisation knows nothing about parallel access # it assumes sequential semantics and rearranges code on that # basis. This can be harmful here! if ( "${fname}" != "barrier.F" ) then echo ' @ $(FCOMP) '$pf >> ${mfile}.$$ else echo ' @ $(FCOMP0) '$pf >> ${mfile}.$$ endif set files = ( ${files} ${fname} ) set slist = ( ${slist} ${f} ) set olist = ( ${olist} ${of} ) end endif 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: $