/[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.1 by cnh, Mon Feb 16 01:07:15 2004 UTC revision 1.6 by cnh, Fri Feb 20 16:21:41 2004 UTC
# Line 1  Line 1 
1  #!/usr/local/bin/tcsh -f  #!<TCSH_PATH> -f
2  #  #
3  #$Id$  #$Id$
4  #$Name$  #$Name$
# 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
# Line 137  set compinc  = ( ${compinc} -I${BUILDROO Line 148  set compinc  = ( ${compinc} -I${BUILDROO
148  #set compinc  = ( -I/fs/cgd/data0/erik/esmf/mod/modO/AIX.default.64.default         )  #set compinc  = ( -I/fs/cgd/data0/erik/esmf/mod/modO/AIX.default.64.default         )
149    
150    
151  source ${BUILDROOT}/tools/comp_profile  source ${BUILDROOT}/mytools/comp_profile.${COMP_PROF}
152    
153  set compinc  = ( ${compinc} -I${BUILDROOT}/esmf_top )  set compinc  = ( ${compinc} -I${BUILDROOT}/esmf_top )
154    
# Line 159  ar -X64 -s -rc mmout/libmitgcmrtl.a $mit Line 170  ar -X64 -s -rc mmout/libmitgcmrtl.a $mit
170    
171  # Create component library archive  # Create component library archive
172  mv ${mpref_l}_mod.Ftmp ${mpref_l}_mod.F  mv ${mpref_l}_mod.Ftmp ${mpref_l}_mod.F
173  source ${BUILDROOT}/tools/scommand  source ${BUILDROOT}/mytools/scommand
174  mv foo.F ${mpref_l}_mod.F  mv foo.F ${mpref_l}_mod.F
175  echo " " | $comp $compopts -c ${mpref_l}_mod.F ${complibs} ${compinc}  echo " " | $comp $compopts -c ${mpref_l}_mod.F ${complibs} ${compinc}
176  mv ${mpref_l}_mod.F ${mpref_l}_mod.Ftmp  mv ${mpref_l}_mod.F ${mpref_l}_mod.Ftmp
# Line 169  cc -q64 -c component_${mpref_s}_context. Line 180  cc -q64 -c component_${mpref_s}_context.
180  ar -X64 -s -rc mmout/lib${mpref_l}.a ${mpref_l}_mod.o component_${mpref_s}_context.o  ar -X64 -s -rc mmout/lib${mpref_l}.a ${mpref_l}_mod.o component_${mpref_s}_context.o
181  #ranlib mmout/lib${mpref_l}.a  #ranlib mmout/lib${mpref_l}.a
182  cp ${mpref_l}.mod mmout  cp ${mpref_l}.mod mmout
   
183  \rm *mod  \rm *mod
 mv main.f main.F90  
 #echo $comp $compopts main.F90 ${mpref_l}_mod.o $mitgcmrtlo tim.o $complibs  
 #echo " " | $comp $compopts main.F90 ${mpref_l}_mod.o $mitgcmrtlo $complibs  
 #echo $comp $compopts main.F90 -Immout -Lmmout -l${mpref_l} -lmitgcmrtl $complibs  
 #echo " " | $comp $compopts main.F90 -Immout -Lmmout -l${mpref_l} -lmitgcmrtl $complibs  
 mv main.F90 main.f  
184    
185  # Lahey compiler command line  # Lahey compiler command line
186  #  /usr/local/pkg/lammpi/lam-7.0.3/lahey/bin/mpif77  --dbl -O0 --fix --lst --xref --wide -I/s/local/1/cnh/usr/local/src/ESMF_1_0_4_withlam/esmf/mod/modO/Linux.lahey.32.default main.F90 ${mpref_l}_mod.o mdsio_byteswapr4.o mdsio_byteswapr8.o fool_the_compiler.o tim.o -L/home/cnh/src/ESMF_1_0_4_withlam/esmf/lib/libO/Linux.lahey.32.default -lesmf  #  /usr/local/pkg/lammpi/lam-7.0.3/lahey/bin/mpif77  --dbl -O0 --fix --lst --xref --wide -I/s/local/1/cnh/usr/local/src/ESMF_1_0_4_withlam/esmf/mod/modO/Linux.lahey.32.default main.F90 ${mpref_l}_mod.o mdsio_byteswapr4.o mdsio_byteswapr8.o fool_the_compiler.o tim.o -L/home/cnh/src/ESMF_1_0_4_withlam/esmf/lib/libO/Linux.lahey.32.default -lesmf

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.22