/[MITgcm]/MITgcm_contrib/ESMF/mytools/mkmod.sh
ViewVC logotype

Diff of /MITgcm_contrib/ESMF/mytools/mkmod.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2 by cnh, Mon Feb 16 03:12:18 2004 UTC revision 1.3 by cnh, Mon Feb 16 15:39:22 2004 UTC
# Line 12  Line 12 
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
# Line 23  set mpref_s = ( atm ) Line 25  set mpref_s = ( atm )
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    
# Line 52  echo " " Line 56  echo " "
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
# Line 63  cat <<EOF > ${mpref_l}_mod.Ftmp Line 66  cat <<EOF > ${mpref_l}_mod.Ftmp
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 \
# Line 75  cat ${mpref_l}_mod.Ftmp | grep -iv " Line 82  cat ${mpref_l}_mod.Ftmp | grep -iv "
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
# Line 106  echo "Putting END FUNCTION at end of fun Line 114  echo "Putting END FUNCTION at end of fun
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

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.22