--- MITgcm_contrib/ESMF/mytools/mkmod.sh 2004/02/16 03:12:18 1.2 +++ MITgcm_contrib/ESMF/mytools/mkmod.sh 2004/02/16 15:39:22 1.3 @@ -1,6 +1,6 @@ #!/usr/local/bin/tcsh -f # -#$Id: mkmod.sh,v 1.2 2004/02/16 03:12:18 cnh Exp $ +#$Id: mkmod.sh,v 1.3 2004/02/16 15:39:22 cnh Exp $ #$Name: $ # # Script to create modules for an MITgcm production code instance @@ -12,7 +12,9 @@ # The set of module files includes all the source files except # main.f and a small number of runtime library files. # The module file set is then placed within a module of a given name. -# +# A single argument to the script is used to create a module prefix +# allowing the same source tree to be used for multiple modules with +# differing names and dirrent sized static data objects. # # # Set module prefix @@ -23,9 +25,11 @@ endif set mpref_l = ( mitgcm_org_${mpref_s} ) -# Set output directory +# Set output directory - this is the directory where the compile and link objects +# that other builds (ESMF drivers etc..) use set outdir = ( mmout ) +# Get the genmake generated Makefile to create the .f files echo "Creating small f files" make small_f @@ -52,8 +56,7 @@ echo "Removing comments and blank lines" cat ${mpref_l}_mod.Ftmp | grep -v '^ *$' | grep -v '^[a-zA-Z]' > ${mpref_l}_mod2.Ftmp -echo "Putting END SUBROUTINE at end of subroutines" -cat ${mpref_l}_mod2.Ftmp | awk -f print_sub.awk > ${mpref_l}_mod3.Ftmp +echo "Creating top lines for module source" cat < ${mpref_l}_mod.Ftmp MODULE ${mpref_l} USE ESMF_MOD @@ -63,9 +66,13 @@ PUBLIC GET_DOMAIN_SIZE CONTAINS EOF + +echo "Putting END SUBROUTINE at end of subroutines" +cat ${mpref_l}_mod2.Ftmp | awk -f print_sub.awk > ${mpref_l}_mod3.Ftmp cat ${mpref_l}_mod3.Ftmp >> ${mpref_l}_mod.Ftmp -# Remove EXTERNAL refs for functions +# Remove EXTERNAL refs for functions (some compilers say it is an error to have EXTERNAL ) +# ( on these if they are in a module ) echo "Removing EXTERNAL refs for functions that are within the module" set extDel = ( DIFFERENT_MULTIPLE IFNBLNK ILNBLNK TIMER_INDEX \ IO_ERRCOUNT MDS_RECLEN PORT_RAND SBO_RHO NLATBND \ @@ -75,7 +82,8 @@ cp f1.Ftmp ${mpref_l}_mod.Ftmp end -# Remove type declaarations for functions +# Remove type declaarations for functions (some compilers say it is an error to have TYPE in ) +# (a routine for these if they are in a module ) echo "Removing type declarations for functions that are within the module" cat ${mpref_l}_mod.Ftmp | grep -iv ' *LOGICAL *DIFFERENT_MULTIPLE' > f1.Ftmp cp f1.Ftmp ${mpref_l}_mod.Ftmp @@ -106,10 +114,13 @@ cat ${mpref_l}_mod2.Ftmp | awk -f print_func.awk > ${mpref_l}_mod4.Ftmp cat ${mpref_l}_mod4.Ftmp >> ${mpref_l}_mod.Ftmp +echo "Write the end of the module" +cat ${mpref_l}_mod2.Ftmp | awk -f print_func.awk > ${mpref_l}_mod4.Ftmp cat <> ${mpref_l}_mod.Ftmp END MODULE ${mpref_l} EOF -# Change all the common block names in the module + +# Change all the common block names in the module to use the module prefix # 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 COMMON/C_'${mpref_s}'_\2/\3z' > f1.Ftmp cp f1.Ftmp ${mpref_l}_mod.Ftmp