#!/bin/bash # $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/f90mkdepend,v 1.5 2010/05/01 17:48:17 jahn Exp $ # $Name: $ # # Generate some make file dependency entries for a Fortran 90 file that employs "use". # # For every "use" statement, generate a dependency on tolower(modulename).o # # Note: We assume that the name of a module and the same of source are the same. # The name of the source file should be all lower case (except for the extension). # don't complain if *.F90 doesn't match any files shopt -s nullglob cat /dev/null > f90mkdepend.log for filename in *.F90 *.F *.h; do # quick check for "use" to speed up processing if grep -i '^ *use ' $filename > /dev/null; then # extract module name in lower case modreflist=$(grep -i '^ *use ' $filename | awk '{sub(/,.*/,"",$2); print tolower($2)}') echo "$filename => $modreflist" >> f90mkdepend.log # change .F90 into .f90, .F into .f for target preprocessed=$(echo $filename | sed -e 's/\.F$/.f/' -e 's/\.F90$/.f90/') depline="$preprocessed:" for m in $modreflist; do # ignore modules that don't have an appropriately named source file if [ -f $m.F90 ] || [ -f $m.F ]; then depline="$depline $m.o" fi done echo $depline fi done