--- MITgcm_contrib/ESMF/mytools/mkmod.sh 2004/02/16 18:57:53 1.5 +++ MITgcm_contrib/ESMF/mytools/mkmod.sh 2004/02/27 17:09:09 1.11 @@ -1,6 +1,6 @@ -#!/usr/local/bin/tcsh -f +#! -f # -#$Id: mkmod.sh,v 1.5 2004/02/16 18:57:53 cnh Exp $ +#$Id: mkmod.sh,v 1.11 2004/02/27 17:09:09 cnh Exp $ #$Name: $ # # Script to create modules for an MITgcm production code instance @@ -25,8 +25,8 @@ endif set mpref_l = ( mitgcm_org_${mpref_s} ) -# Set output directory - this is the directory where the compile and link objects -# that other builds (ESMF drivers etc..) use +# 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 @@ -71,8 +71,8 @@ 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 (some compilers say it is an error to have EXTERNAL ) -# ( on these if they are in a module ) +# 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 \ @@ -82,10 +82,11 @@ cp f1.Ftmp ${mpref_l}_mod.Ftmp end -# 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 ) +# 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 +cat ${mpref_l}_mod.Ftmp | grep -iv ' *LOGICAL *DIFFERENT_MULTIPLE' \ + > f1.Ftmp cp f1.Ftmp ${mpref_l}_mod.Ftmp cat ${mpref_l}_mod.Ftmp | grep -iv ' *INTEGER *ILNBLNK' > f1.Ftmp cp f1.Ftmp ${mpref_l}_mod.Ftmp @@ -110,10 +111,12 @@ cat ${mpref_l}_mod.Ftmp | grep -iv ' *REAL\*8 *EXF_BULKRHN' > f1.Ftmp cp f1.Ftmp ${mpref_l}_mod.Ftmp +# echo "Putting END FUNCTION at end of functions" 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 @@ -121,33 +124,13 @@ EOF # 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 - -echo "Compiling code" -set comp = /s/local/1/cnh/usr/local/pkg/lammpi/lam-7.0.3/lahey/bin/mpif77 -set compopts = ( --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 ) -set complibs = ( -L/s/local/1/cnh/usr/local/src/ESMF_1_0_4_withlam/esmf/lib/libO/Linux.lahey.32.default -lesmf ) - -set comp = /usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/bin/mpif90 -set compopts = ( -r8 -Mfixed -Mextend -byteswapio ) -set complibs = ( ) - -set comp = /usr/local/pkg/mpi/mpich-1.2.5..10/lahey/bin/mpif90 -set compopts = ( --dbl --o2 --fix --lst --xref --wide --tp4 ) -#set compopts = ( --dbl --o0 --fix --lst --xref --wide --sav ) -set complibs = ( -L/usr/local/pkg/ESMF/ESMF_1_0_4/mpich-1.2.5..10/lahey/lib/libO/Linux.lahey.32.default -lesmf ) -set compinc = ( -I/usr/local/pkg/ESMF/ESMF_1_0_4/mpich-1.2.5..10/lahey/mod/modO/Linux.lahey.32.default ) -set compinc = ( ${compinc} -I${BUILDROOT}/esmf_top ) - -#set comp = xlf95 -#set compopts = ( -qfixed=132 -O3 -qarch=pwr4 -qtune=pwr4 -qcache=auto -qmaxmem=-1 -bmaxdata:0x80000000 -q64 ) -#set compopts = ( --dbl --o0 --fix --lst --xref --wide --sav ) -#set complibs = ( -L/fs/cgd/data0/erik/esmf/lib/libO/AIX.default.64.default -lesmf ) -#set compinc = ( -I/fs/cgd/data0/erik/esmf/mod/modO/AIX.default.64.default ) +cat ${mpref_l}_mod.Ftmp | sed s'/C_'${mpref_s}'_MPIPRIV/MPIPRIV/' > f1.Ftmp +cp f1.Ftmp ${mpref_l}_mod.Ftmp +echo "Compiling code" source ${BUILDROOT}/mytools/comp_profile.${COMP_PROF} set compinc = ( ${compinc} -I${BUILDROOT}/esmf_top ) @@ -162,10 +145,10 @@ echo " " | $comp $compopts -c ${f} set mitgcmrtlo = ( $mitgcmrtlo ${f:r}.o ) end -cc -q64 -c tim.c +${cccommand} ${ccopts} tim.c set mitgcmrtlo = ( $mitgcmrtlo tim.o ) \rm mmout/libmitgcmrtl.a -ar -X64 -s -rc mmout/libmitgcmrtl.a $mitgcmrtlo +${arcommand} ${aropts} mmout/libmitgcmrtl.a $mitgcmrtlo #ranlib mmout/libmitgcmrtl.a # Create component library archive @@ -175,17 +158,11 @@ echo " " | $comp $compopts -c ${mpref_l}_mod.F ${complibs} ${compinc} mv ${mpref_l}_mod.F ${mpref_l}_mod.Ftmp ./template_comp.sh ${mpref_s} -cc -q64 -c component_${mpref_s}_context.c +${cccommand} ${ccopts} component_${mpref_s}_context.c \rm mmout/lib${mpref_l}.a -ar -X64 -s -rc mmout/lib${mpref_l}.a ${mpref_l}_mod.o component_${mpref_s}_context.o +${arcommand} ${aropts} mmout/lib${mpref_l}.a ${mpref_l}_mod.o component_${mpref_s}_context.o #ranlib mmout/lib${mpref_l}.a -cp ${mpref_l}.mod mmout -\rm *mod - -# Lahey compiler command line -# /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 -# To run -# /s/local/1/cnh/usr/local/pkg/lammpi/lam-7.0.3/lahey/bin/mpirun -np 4 -t -v ../build/a.out -# To start lam daemon -# /s/local/1/cnh/usr/local/pkg/lammpi/lam-7.0.3/lahey/bin/lamboot -c /s/local/1/cnh/usr/local/pkg/lammpi/lam-7.0.3/lahey/etc/lam-conf.lamd -v -d -# NB - for starting daemon you need "lamd" in your search path +set modname = `echo ${mpref_l} | ${mkmodname}` +echo $modname +cp ${modname}.mod mmout +#\rm *mod