JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for COMP-FORTRAN-90 Archives


COMP-FORTRAN-90 Archives

COMP-FORTRAN-90 Archives


COMP-FORTRAN-90@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Monospaced Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  1998

COMP-FORTRAN-90 1998

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Compilation of modules

From:

Jack Scheible <[log in to unmask]>

Reply-To:

Jack Scheible <[log in to unmask]>

Date:

Tue, 19 May 1998 09:49:36 -0400 (EDT)

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (326 lines)

This is what we are using. We call it makedepf90. It works for
NAGware on Linux and IRIX 5.3, for SGI F90 on IRIX 6.2, and Sun f90 on
Solaris 2.x. For Sun f90, we generate dummy .kmo files for each
module, and do dependency checks on those, rather than trying to track
which module is in which .o file.

-jack

#!/bin/sh
#
# makedepf90 - Jack Scheible, Jr.
# copyright Sparta, Inc., Apr., 1997
#
##########################################################################
#
# This program is a single-level makedepend for Fortran90 programs.
#
# Nota bene: This program does not yet scan included files for
# include files.
#
# Calling syntax:
# makedepf90 [-Iincludedir] [-fmakefile] [-oobjsuffix]
# [-pobjprefix] sourcefile ...
# This program takes the following arguments:
# -Iincludedir = Search path for include files and modules
# ( default is -I. to which user input is appended )
# -fmakefile = File to which dependency info is written
# ( defaults to makefile, then Makefile )
# -oobjsuffix = suffix of object files ( default is .o )
# -pobjprefix = prefix of object files ( no default )
#
# The arguments may be in any order.
#
##########################################################################

# Set default values
OBJPREFIX=
OBJSUFFIX=.o
OBJDIR=.
INCLUDEDIRS=.
DSTRING="# DO NOT DELETE"
MAKEFILE=makefile

# Determine current operating system

OS=`uname`
if [ "$OS" = "IRIX" ]
then
    VERSION=`uname -r`
    OS=$OS\_$VERSION
fi

# Determine compiler, based on OS.

if [ "$OS" = "IRIX64" -o "$OS" = "IRIX_6.2" ]
then
    COMPILER="SGI"
elif [ "$OS" = "IRIX_5.3" -o "$VERSION" = "Linux" ]
then
    COMPILER="NAG"
elif [ "$OS" = "SunOS" ]
then
    COMPILER="Sun"
else
    echo "Unknown operating system: " $OS
    exit
fi

# Set module extension based on compiler

if [ "$COMPILER" = "SGI" -o "$COMPILER" = "Sun" ]
then
    MODSUFFIX=".kmo"
elif [ "$COMPILER" = "NAG" ]
then
    MODSUFFIX=".mod"
fi

# Find existing makefile
if [ ! -f $MAKEFILE ]
then
    MAKEFILE=Makefile
fi

# loop through command parameters
for arg in $*
do
    case $arg in
# module directories
-M*) MODULEDIRS=$MODULEDIRS\ `expr "$arg" : "..\(.*\)"` ;;

# includedir
-I*) INCLUDEDIRS=$INCLUDEDIRS\ `expr "$arg" : "..\(.*\)"` ;;

# makefile
        -f*) MAKEFILE=`expr "$arg" : "..\(.*\)"` ;;

# Object Suffix
-o*) OBJSUFFIX=`expr "$arg" : "..\(.*\)"` ;;

# Object directory
-p*) OBJDIR=`expr "$arg" : "..\(.*\)"` ;;

# Anything else is a sourcefile
*) SOURCES="$SOURCES $arg" ;;
    esac
done
# end loop

# Only SUN has MODULEDIRS, others use INCLUDEDIRS
if [ "$COMPILER" != "Sun" ]
then
    MODULEDIRS=$INCLUDEDIRS
fi

# If makefile exists
if [ -f $MAKEFILE ]
then
    # search for STRING,
    # delete from there to end,
    # and put in temporary file
    sedcmd=/$DSTRING/,\$d
    sed "$sedcmd" $MAKEFILE > tmp$$
# else
else
    # Create temporary file
    touch tmp$$
fi
#endif

# Write STRING
echo $DSTRING >> tmp$$

############################################################################
#
# Search source files for module definitions
#
############################################################################

# Loop through all source files
for FILE in $SOURCES
do
    #--------------------------------------------#
    # Build list of targets in this source files #
    #--------------------------------------------#

    # Determine object file name and make it first target
    outfile=`echo $FILE | sed 's/\.[^.]*$//'`
    outfile=$OBJDIR$outfile$OBJSUFFIX
    TARGETS=$outfile

    # Search files for module definitions and append to list of targets
    MODDEFS=`grep -i "^ *module " $FILE | awk '{ print $2 }'`
    SunModFile=
    MODFILES=
    for MODULE in $MODDEFS
    do
# If compiler is SGI, the module file name is all uppercase
if [ "$COMPILER" = "SGI" ]
then
MODFILE=`echo $MODULE | tr '[a-z]' '[A-Z]'`$MODSUFFIX
TARGETS=`echo $TARGETS $OBJDIR$MODFILE`

# If compiler is NAG, the module file name is all lowercase
elif [ "$COMPILER" = "NAG" ]
then
MODFILE=`echo $MODULE | tr '[A-Z]' '[a-z]'`$MODSUFFIX
TARGETS=`echo $TARGETS $OBJDIR$MODFILE`

# If OS is SunOS, the module file name is the source file name with a
# .M extension. Since SunOS compiler puts all module info for one
# source file, source.f90, into one module file, source.M, we cannot
# know the name of the module file from the name of the module. Thus,
# for each module, we will create a corresponding empty .kmo file (all
# lowercase letters).
elif [ "$COMPILER" = "Sun" ]
then
if [ "$SunModFile" = "" ]
then
SunModFile=`echo $FILE | sed -e 's/90$//' -e 's/\.f$//`.M
fi
MODFILE=`echo $MODULE | tr '[A-Z]' '[a-z]'`$MODSUFFIX
TARGETS=`echo $TARGETS $OBJDIR$MODFILE`
else
echo "Unknown compiler " $COMPILER
exit
fi
        MODFILES=`echo $MODFILES $MODFILE`
    done

    # If there is a SunModFile, add it to the list of targets.
    if [ "$SunModFile" != "" ]
    then
TARGETS=$TARGETS\ $SunModFile
    fi

    #--------------------------------------------------#
    # Build list of dependencies for this source files #
    #--------------------------------------------------#

    # Initialize list of dependencies
    DEPENDS=$FILE

    #-------------------------------------#
    # get list of files included in $FILE #
    #-------------------------------------#

    includes=`grep -i "^ *include" $FILE | \
    sed -e 's/^[^"]*"//' -e 's/".*//' -e "s/^[^']*'//" -e "s/'.*//" | \
    sort -u`


    # loop though all included file names
    for include in $includes
    do
found=no
# search each include directory for file
for dir in $INCLUDEDIRS
do
if [ "$found" = "no" ]
then
# If include file is in this directory
if [ -f $dir/$include ]
then
# Append to dependency list
DEPENDS=`echo $DEPENDS $dir/$include`
found=yes
fi
fi
done
# end loop of include directories

# If not found, write error message
if [ "$found" = "no" ]
then
echo Error: cannot find file $include included in $FILE
fi
    done
    # End loop of included files

    #------------------------------#
    # Get list of all modules used #
    #------------------------------#

    MODS_USED=`grep -i "^ *use " $FILE | sed 's/,/ /g' | awk '{ print $2 }' | \
tr '[A-Z]' '[a-z]' | sort -u`

    # Loop through modules
    for MOD in $MODS_USED
    do
# Construct module file name
if [ "$COMPILER" = "SGI" ]
then
MOD=`echo $MOD | tr '[a-z]' '[A-Z]'`
MODFILENAME=$MOD$MODSUFFIX
elif [ "$COMPILER" = "NAG" -o "$COMPILER" = "Sun" ]
then
MOD=`echo $MOD | tr '[A-Z]' '[a-z]'`
MODFILENAME=$MOD$MODSUFFIX
else
echo "Unknown compiler: " $COMPILER
exit
fi

# loop through include directories to search for module
found=no
for dir in $MODULEDIRS
do
if [ "$found" = "no" ]
then
# If include file is in this directory
if [ -f $dir/$MODFILENAME ]
then
# Write dependency to temp file
DEPENDS=`echo $DEPENDS $dir/$MODFILENAME`
found=yes
fi
fi
done
# end loop of include directories

# If not found, assume it will be built into the object directory
if [ "$found" = "no" ]
then
DEPENDS=`echo $DEPENDS $OBJDIR$MODFILENAME`
fi
    done

    # Write targets and dependencies
    echo $TARGETS: $DEPENDS >> tmp$$

    # If there are modules for targets, we need to write the compilation command
    if [ "$MODDEFS" != "" ]
    then
# Write compilation command depending on source file type
suffix=`echo $FILE | sed 's/^.*\.//'`
if [ "$suffix" = "for" ]
then
echo " \$(COMPILE.for) \$(FFLAGS) -o $outfile \$(IPATH) $FILE" >>tmp$$
elif [ "$suffix" = "f90" ]
then
echo " \$(COMPILE.f90) \$(FFLAGS) -o $outfile \$(IPATH) $FILE" >>tmp$$
else
echo "Unrecognized file type: " $FILE
fi

# For SunOS, we need to move the real module file to $OBJDIR, and
# create fake ones for SunOS so we can do dependency checking with MAKE.
if [ "$OS" = "SunOS" ]
then
echo " touch $MODFILES" >> tmp$$
echo " mv $SunModFile $OBJDIR" >> tmp$$
fi

# Move module files to $OBJDIR
echo " mv $MODFILES $OBJDIR" >> tmp$$
    fi
done
# End loop of source files

# Move temp file to desired output file
mv -f tmp$$ $MAKEFILE


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
February 2023
November 2022
September 2022
February 2022
January 2022
June 2021
November 2020
September 2020
June 2020
May 2020
April 2020
December 2019
October 2019
September 2019
March 2019
February 2019
January 2019
November 2018
October 2018
September 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
April 2015
March 2015
January 2015
December 2014
November 2014
October 2014
August 2014
July 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
July 2013
June 2013
May 2013
April 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
August 2010
July 2010
June 2010
March 2010
February 2010
January 2010
December 2009
October 2009
August 2009
July 2009
June 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager