1 |
cnh |
1.1 |
#!/bin/sh |
2 |
|
|
# |
3 |
|
|
# Shell script to manage module files built from directories of |
4 |
|
|
# code fragments, template code and expandable macros. |
5 |
|
|
# This script is |
6 |
|
|
# o used to perform overload expansions and to assemble F90 modules into a |
7 |
|
|
# single file (a requirement of the language) from multiple sources. |
8 |
|
|
# |
9 |
|
|
# o used to perform overload expansions and to assemble F90 modules into a |
10 |
|
|
# single file (a requirement of the language) from multiple sources. |
11 |
|
|
# |
12 |
|
|
# Usage: |
13 |
|
|
# mod_tool.sh build |
14 |
|
|
# mod_tool.sh clean |
15 |
|
|
# |
16 |
|
|
# Inputs: |
17 |
|
|
# module_name :: file containing name of module that will be created |
18 |
|
|
# |
19 |
|
|
# |
20 |
|
|
export PROG_NAME=$0 |
21 |
|
|
fc=`which $0` |
22 |
|
|
sroot=${fc%/*} |
23 |
|
|
. ${sroot}/mod_tool_funcs.sh |
24 |
|
|
|
25 |
|
|
# See which action was requested and exit with usage if it isn't |
26 |
|
|
# there or is an unrecognised string. |
27 |
|
|
action=$1 |
28 |
|
|
check_action $action |
29 |
|
|
|
30 |
|
|
# Set name of file standard output is written |
31 |
|
|
export STDOUT=build_mod.stdout |
32 |
|
|
export ERROUT=build_mod.stderr |
33 |
|
|
\rm -fr ${STDOUT} ${STDERR} |
34 |
|
|
touch ${STDOUT} ${STDERR} |
35 |
|
|
# Set name of file with module name |
36 |
|
|
export MOD_NAME_FILE=module_name |
37 |
|
|
# Set name of file with list of zero or more files containing interface |
38 |
|
|
# definitions |
39 |
|
|
export IF_FILE_LIST=iface_file_list |
40 |
|
|
export PROC_FILE_LIST=proc_file_list |
41 |
|
|
export PROCTEMPLATE_FILE_LIST=proctemplate_file_list |
42 |
|
|
export USE_FILE_LIST=use_file_list |
43 |
|
|
# Set name of file to which output will be written |
44 |
|
|
export F90_OUT_FILE=foo.F90 |
45 |
|
|
export F90_OUT_DIR=mod_tool_built_src |
46 |
|
|
export CONTAINS_IS_WRITTEN=0 |
47 |
|
|
|
48 |
|
|
# Read the module name from ${MOD_NAME_FILE} |
49 |
|
|
com='MODULE_NAME=`(grep -v '^#' ${MOD_NAME_FILE})`' |
50 |
|
|
if [ -r ${MOD_NAME_FILE} ]; then |
51 |
|
|
export MODULE_NAME=`(grep -v '^#' ${MOD_NAME_FILE}) 2> ${STDOUT}` |
52 |
|
|
rc=$? |
53 |
|
|
else |
54 |
|
|
rc=2 |
55 |
|
|
fi |
56 |
|
|
check_rc_exit $rc "$com" \ |
57 |
|
|
"Error reading name of module from file \"${MOD_NAME_FILE}\"" |
58 |
|
|
|
59 |
|
|
# Execute commands based on selected action. |
60 |
|
|
if [ "x$action" == "xbuild" ]; then |
61 |
|
|
mod_tool_build |
62 |
|
|
fi |
63 |
|
|
|
64 |
|
|
if [ "x$action" == "xclean" ]; then |
65 |
|
|
mod_tool_clean |
66 |
|
|
fi |