| 12 |
# The set of module files includes all the source files except |
# The set of module files includes all the source files except |
| 13 |
# main.f and a small number of runtime library files. |
# main.f and a small number of runtime library files. |
| 14 |
# The module file set is then placed within a module of a given name. |
# The module file set is then placed within a module of a given name. |
| 15 |
# |
# A single argument to the script is used to create a module prefix |
| 16 |
|
# allowing the same source tree to be used for multiple modules with |
| 17 |
|
# differing names and dirrent sized static data objects. |
| 18 |
# |
# |
| 19 |
# |
# |
| 20 |
# Set module prefix |
# Set module prefix |
| 25 |
endif |
endif |
| 26 |
set mpref_l = ( mitgcm_org_${mpref_s} ) |
set mpref_l = ( mitgcm_org_${mpref_s} ) |
| 27 |
|
|
| 28 |
# Set output directory |
# Set output directory - this is the directory where the compile and link objects |
| 29 |
|
# that other builds (ESMF drivers etc..) use |
| 30 |
set outdir = ( mmout ) |
set outdir = ( mmout ) |
| 31 |
|
|
| 32 |
|
# Get the genmake generated Makefile to create the .f files |
| 33 |
echo "Creating small f files" |
echo "Creating small f files" |
| 34 |
make small_f |
make small_f |
| 35 |
|
|
| 56 |
echo "Removing comments and blank lines" |
echo "Removing comments and blank lines" |
| 57 |
cat ${mpref_l}_mod.Ftmp | grep -v '^ *$' | grep -v '^[a-zA-Z]' > ${mpref_l}_mod2.Ftmp |
cat ${mpref_l}_mod.Ftmp | grep -v '^ *$' | grep -v '^[a-zA-Z]' > ${mpref_l}_mod2.Ftmp |
| 58 |
|
|
| 59 |
echo "Putting END SUBROUTINE at end of subroutines" |
echo "Creating top lines for module source" |
|
cat ${mpref_l}_mod2.Ftmp | awk -f print_sub.awk > ${mpref_l}_mod3.Ftmp |
|
| 60 |
cat <<EOF > ${mpref_l}_mod.Ftmp |
cat <<EOF > ${mpref_l}_mod.Ftmp |
| 61 |
MODULE ${mpref_l} |
MODULE ${mpref_l} |
| 62 |
USE ESMF_MOD |
USE ESMF_MOD |
| 66 |
PUBLIC GET_DOMAIN_SIZE |
PUBLIC GET_DOMAIN_SIZE |
| 67 |
CONTAINS |
CONTAINS |
| 68 |
EOF |
EOF |
| 69 |
|
|
| 70 |
|
echo "Putting END SUBROUTINE at end of subroutines" |
| 71 |
|
cat ${mpref_l}_mod2.Ftmp | awk -f print_sub.awk > ${mpref_l}_mod3.Ftmp |
| 72 |
cat ${mpref_l}_mod3.Ftmp >> ${mpref_l}_mod.Ftmp |
cat ${mpref_l}_mod3.Ftmp >> ${mpref_l}_mod.Ftmp |
| 73 |
|
|
| 74 |
# Remove EXTERNAL refs for functions |
# Remove EXTERNAL refs for functions (some compilers say it is an error to have EXTERNAL ) |
| 75 |
|
# ( on these if they are in a module ) |
| 76 |
echo "Removing EXTERNAL refs for functions that are within the module" |
echo "Removing EXTERNAL refs for functions that are within the module" |
| 77 |
set extDel = ( DIFFERENT_MULTIPLE IFNBLNK ILNBLNK TIMER_INDEX \ |
set extDel = ( DIFFERENT_MULTIPLE IFNBLNK ILNBLNK TIMER_INDEX \ |
| 78 |
IO_ERRCOUNT MDS_RECLEN PORT_RAND SBO_RHO NLATBND \ |
IO_ERRCOUNT MDS_RECLEN PORT_RAND SBO_RHO NLATBND \ |
| 82 |
cp f1.Ftmp ${mpref_l}_mod.Ftmp |
cp f1.Ftmp ${mpref_l}_mod.Ftmp |
| 83 |
end |
end |
| 84 |
|
|
| 85 |
# Remove type declaarations for functions |
# Remove type declaarations for functions (some compilers say it is an error to have TYPE in ) |
| 86 |
|
# (a routine for these if they are in a module ) |
| 87 |
echo "Removing type declarations for functions that are within the module" |
echo "Removing type declarations for functions that are within the module" |
| 88 |
cat ${mpref_l}_mod.Ftmp | grep -iv ' *LOGICAL *DIFFERENT_MULTIPLE' > f1.Ftmp |
cat ${mpref_l}_mod.Ftmp | grep -iv ' *LOGICAL *DIFFERENT_MULTIPLE' > f1.Ftmp |
| 89 |
cp f1.Ftmp ${mpref_l}_mod.Ftmp |
cp f1.Ftmp ${mpref_l}_mod.Ftmp |
| 114 |
cat ${mpref_l}_mod2.Ftmp | awk -f print_func.awk > ${mpref_l}_mod4.Ftmp |
cat ${mpref_l}_mod2.Ftmp | awk -f print_func.awk > ${mpref_l}_mod4.Ftmp |
| 115 |
cat ${mpref_l}_mod4.Ftmp >> ${mpref_l}_mod.Ftmp |
cat ${mpref_l}_mod4.Ftmp >> ${mpref_l}_mod.Ftmp |
| 116 |
|
|
| 117 |
|
echo "Write the end of the module" |
| 118 |
|
cat ${mpref_l}_mod2.Ftmp | awk -f print_func.awk > ${mpref_l}_mod4.Ftmp |
| 119 |
cat <<EOF >> ${mpref_l}_mod.Ftmp |
cat <<EOF >> ${mpref_l}_mod.Ftmp |
| 120 |
END MODULE ${mpref_l} |
END MODULE ${mpref_l} |
| 121 |
EOF |
EOF |
| 122 |
# Change all the common block names in the module |
|
| 123 |
|
# Change all the common block names in the module to use the module prefix |
| 124 |
# cat ${mpref_l}_mod.Ftmp | sed s'z\( *COMMON *[^/]*/ *\)\([^ ]*\)\( */.*\)z\1COMPOCEAN_\2\3z' >f1.Ftmp |
# cat ${mpref_l}_mod.Ftmp | sed s'z\( *COMMON *[^/]*/ *\)\([^ ]*\)\( */.*\)z\1COMPOCEAN_\2\3z' >f1.Ftmp |
| 125 |
cat ${mpref_l}_mod.Ftmp | sed s'z\( *COMMON[^/]*\)/\(.*\)/\([^/]*\)z COMMON/C_'${mpref_s}'_\2/\3z' > f1.Ftmp |
cat ${mpref_l}_mod.Ftmp | sed s'z\( *COMMON[^/]*\)/\(.*\)/\([^/]*\)z COMMON/C_'${mpref_s}'_\2/\3z' > f1.Ftmp |
| 126 |
cp f1.Ftmp ${mpref_l}_mod.Ftmp |
cp f1.Ftmp ${mpref_l}_mod.Ftmp |