#! /bin/csh -f #this variable controls which compiler will be used set compiler = pg # set compiler = intel set M3LIB = /home/aqm/models.linux/CMAQ_v4.2.2/lib set M3MODEL = /home/aqm/models.linux/CMAQ_v4.2.2/models if ( ! -e $M3MODEL || ! -e $M3LIB ) then echo " $M3MODEL or $M3LIB directory not found" exit 1 endif echo " Model archive path: $M3MODEL" echo " library path: $M3LIB" set BLD_OS = `uname -s` if ($BLD_OS != 'Linux') then echo " $BLD_OS -> wrong makit script for host!" exit 1 endif set echo #:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:# #> user choices: cvs archives set Project = $M3MODEL/CCTM set GlobInc = $M3MODEL/include/release #> user choices: base directory set Base = $cwd set VLEV = 06 if ($compiler == 'intel') then set APPL = v422_cb4_mebi_36k_${VLEV}L_mpi_intel else set APPL = v422_cb4_mebi_36k_${VLEV}L_mpi_pg endif set CFG = cfg.$APPL set MODEL = CCTM_$APPL #> user choices: m3bld command #set Opt = compile_all # force compile, even if object files are current #set Opt = clean_up # remove all source files upon successful completion #set Opt = no_compile # do everything except compile #set Opt = no_link # do everything except link #set Opt = one_step # compile and link in one step #set Opt = parse_only # checks config file syntax #set Opt = show_only # show requested commands but doesn't execute them set Opt = verbose # show requested commands as they are executed set MakeOpt # builds a Makefile to make the model #> user choices: single or multiple processors set ParOpt # multiple PE's #> user choices: various modules set Revision = release # release = latest CVS revision #set Revision = '"STA2_1"' # monocode (>="REL1_4") #set Revision = '"REL1_3"' # last release before monocode #> NOTE: m3bld will try to compile with existing code; it will not retrieve #> new (different release) code. So if your "BLD" directory contains #> code from a release different than the one you have specified above, #> m3bld will tell you, but will merrily compile the original code. #> The workaround is to remove your "BLD" directory and start fresh. set ModDriver = ( module ctm $Revision; ) if ( $?ParOpt ) then set ModPar = ( module par $Revision; ) else set ModPar = ( module par_noop $Revision; ) endif set ModInit = ( module init $Revision; ) #set ModAdjc = ( module adjcon_noop $Revision; ) set ModAdjc = ( module denrate $Revision; ) set ModCpl = ( module gencoor $Revision; ) #set ModHadv = ( module hadv_noop $Revision; ) #set ModHadv = ( module hbot $Revision; ) set ModHadv = ( module hppm $Revision; ) #set ModVadv = ( module vadv_noop $Revision; ) #set ModVadv = ( module vbot $Revision; ) set ModVadv = ( module vppm $Revision; ) #set ModHdiff = ( module hdiff_noop $Revision; ) #set ModHdiff = ( module unif $Revision; ) set ModHdiff = ( module multiscale $Revision; ) #set ModVdiff = ( module vdiff_noop $Revision; ) set ModVdiff = ( module eddy $Revision; ) #set ModPhot = ( module phot_noop $Revision; ) set ModPhot = ( module phot $Revision; ) set ModPing = ( module ping_noop $Revision; ) #set ModPing = ( module ping_qssa $Revision; ) #set ModPing = ( module ping_smvgear $Revision; ) #set ModPing = ( module ping_mebi_cb4 $Revision; ) #set ModChem = ( module chem_noop $Revision; ) #set ModChem = ( module qssa $Revision; ) #set ModChem = ( module smvgear $Revision; ) set ModChem = ( module mebi_cb4 $Revision; ) #set ModChem = ( module mebi_radm2_cis4 $Revision; ) #set ModChem = ( module mebi_saprc99 $Revision; ) #set ModChem = ( module qssa $Revision; ) # "f_flags '-g -e -C -fnonstd';" \ # /project/work/yoj/xdev/vqssa.F ) #set ModAero = ( module aero_noop $Revision; ) #set ModAero = ( module aero2 $Revision; ) set ModAero = ( module aero3 $Revision; ) #set ModAdepv = ( module aero_depv_noop $Revision; ) #set ModAdepv = ( module aero_depv1 $Revision; ) set ModAdepv = ( module aero_depv2 $Revision; ) #set ModCloud = ( module cloud_noop $Revision; ) set ModCloud = ( module cloud_radm $Revision; ) set ModPa = ( module pa $Revision; ) set ModUtil = ( module util $Revision; ) #set ModMisc = ( misc; \ # $Base/file1.F \ # $Base/file2.F \ # $Base/file3.F ) #> user choices: emissions processing in chem or vdiff (default) ... #set Cemis #> user choices: vertical layers and mechanism #set Layers = 21 set Layers = ${VLEV} #set Mechanism = radm2_ci4_ae3_aq set Mechanism = cb4_ae3_aq #set Mechanism = saprc99_ae3_aq set Tracer = trac0 # default: no tracer species #> user choices: set process analysis linkages set PABase = $GlobInc set PAOpt = pa_noop #set PABase = /project/cmaq/yoj/saprc #set PAOpt = #> other user choices set below are: #> name of the "BLD" directory #> compiler/link flags #> library paths #:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:# set Bld = $Base/BLD_${APPL} #unset echo if ( ! -e "$Bld" ) then mkdir $Bld else if ( ! -d "$Bld" ) then echo " *** target exists, but not a directory ***" exit 1 endif endif #set echo cd $Bld #:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:# if ($compiler == 'intel') then set MODLOC = ${M3LIB}/stenex/intel/${BLD_OS} else set MODLOC = ${M3LIB}/stenex/pg/${BLD_OS} endif if ( $?ParOpt ) then # set Mpich = /usr/local/mpich-1.2.4 # compiled for Portland Group # set Mpich = /share/linux/bin/mpich-ch_p4 # compiled for Intel if ($compiler == 'intel') then set Mpich = /home/aqm/models.linux/mpich-1.2.5/intel else set Mpich = /home/aqm/models.linux/mpich-1.2.5/pg endif set seL = sef90 if ($compiler == 'intel') then set LIB2 = "-L${M3LIB}/pario/intel/${BLD_OS} -lpario" set LIB3 = "-L${M3LIB}/dynmem/intel/${BLD_OS} -ldynmem" else set LIB2 = "-L${M3LIB}/pario/pg/${BLD_OS} -lpario" set LIB3 = "-L${M3LIB}/dynmem/pg/${BLD_OS} -ldynmem" endif set LIB4 = "-L${Mpich}/lib -lmpich" set Str1 = (// Parallel / Include message passing definitions) set Str2 = (include SUBST_MPICH ${Mpich}/include/mpif.h;) #> kludge for intel compiler v.6.0 # echo "work.pc" >! work.pcl # echo "${MODLOC}/work.pc" >> work.pcl else set Mpich = set seL = sef90_noop set LIB2 = set LIB3 = set LIB4 = set Str1 = set Str2 = #> kludge for intel compiler v.6.0 # echo "work.pc" >! work.pcl # echo "${MODLOC}/work_noop.pc" >> work.pcl endif set LIB1 = "-L${MODLOC} -l${seL}" if ($compiler == 'intel') then set LIB5 = "-L${M3LIB}/ioapi_22/intel/${BLD_OS}2_x86ifc -lioapi" else set LIB5 = "-L${M3LIB}/ioapi_22/pg/${BLD_OS}2_x86pg -lioapi" endif set LIB6 = "-L${M3LIB}/netCDF/pg/${BLD_OS} -lnetcdf" set LIBS = "$LIB1 $LIB2 $LIB3 $LIB4 $LIB5 $LIB6" if ($compiler == 'intel') then set FC = /opt/intel/compiler70/ia32/bin/ifc set FSTD = "-FI -extend_source -w" set F_FLAGS = "${FSTD} -O2 -I. -I${MODLOC}" set LINK_FLAGS = "-Vaxlib" # necessary for ioapi_2.2 else set FC = /usr/local/pgi/linux86/bin/pgf90 set FSTD = "-Mfixed -Mextend -Mlfs" set F_FLAGS = "${FSTD} -O2 -module ${MODLOC} -I." set LINK_FLAGS = "" endif set FP = $FC set CPP_FLAGS = "-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" set C_FLAGS = "-v -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I${Mpich}/include" if ($compiler == 'intel') then set Blder = $M3LIB/build/intel/$BLD_OS/m3bld else set Blder = $M3LIB/build/pg/$BLD_OS/m3bld endif set ICL_PAR = $GlobInc set ICL_CONST = $GlobInc set ICL_FILES = $GlobInc set ICL_EMCTL = $GlobInc if ($compiler == 'intel') then set ICL_IOAPI = ${M3LIB}/ioapi_22/intel/fixed_src else set ICL_IOAPI = ${M3LIB}/ioapi_22/pg/fixed_src endif set ICL_VCRD = $GlobInc/vcoord set ICL_MECH = $GlobInc/$Mechanism set ICL_TRAC = $GlobInc/$Tracer set ICL_PA = $PABase/$PAOpt if ( $?Cemis ) then set CV = -Demis_chem else set CV = endif #> NOTE: To run parallel in a Scyld Beowulf cluster, e.g., remove the #> "-Dcluster\" below. if ( $?ParOpt ) then # split to avoid line > 256 char set PAR = ( -Dparallel\ -Dcluster\ -DINTERPB=PINTERPB\ -DM3ERR=PM3ERR\ -DM3EXIT=PM3EXIT\ -DM3WARN=PM3WARN\ -DSHUT3=PSHUT3\ -DWRITE3=PWRITE3 ) set Popt = SE else echo " Not Parallel; set Serial (no-op) flags" set PAR = "-DINTERPB=INTERP3" set Popt = NOOP endif set STX1 = ( -DSUBST_MODULES=${Popt}_MODULES\ -DSUBST_BARRIER=${Popt}_BARRIER ) set STX2 = ( -DSUBST_GLOBAL_MAX=${Popt}_GLOBAL_MAX\ -DSUBST_GLOBAL_MIN=${Popt}_GLOBAL_MIN\ -DSUBST_GLOBAL_MIN_DATA=${Popt}_GLOBAL_MIN_DATA\ -DSUBST_GLOBAL_TO_LOCAL_COORD=${Popt}_GLOBAL_TO_LOCAL_COORD\ -DSUBST_GLOBAL_SUM=${Popt}_GLOBAL_SUM\ -DSUBST_GLOBAL_LOGICAL=${Popt}_GLOBAL_LOGICAL\ -DSUBST_LOOP_INDEX=${Popt}_LOOP_INDEX\ -DSUBST_SUBGRID_INDEX=${Popt}_SUBGRID_INDEX ) set STX3 = ( -DSUBST_HI_LO_BND_PE=${Popt}_HI_LO_BND_PE\ -DSUBST_SUM_CHK=${Popt}_SUM_CHK\ -DSUBST_INIT_ARRAY=${Popt}_INIT_ARRAY\ -DSUBST_COMM=${Popt}_COMM\ -DSUBST_MY_REGION=${Popt}_MY_REGION\ -DSUBST_SLICE=${Popt}_SLICE\ -DSUBST_GATHER=${Popt}_GATHER\ -DSUBST_DATA_COPY=${Popt}_DATA_COPY\ -DSUBST_IN_SYN=${Popt}_IN_SYN ) setenv CVSROOT $Project #> make the config file set Cfile = ${CFG}.bld set quote = '"' echo > $Cfile echo "model $MODEL;" >> $Cfile echo >> $Cfile echo "FPP $FP;" >> $Cfile echo >> $Cfile set text = "$quote$CPP_FLAGS $CV $PAR $STX1 $STX2 $STX3$quote;" echo "cpp_flags $text" >> $Cfile echo >> $Cfile echo "f_compiler $FC;" >> $Cfile echo >> $Cfile echo "f_flags $quote$F_FLAGS$quote;" >> $Cfile echo >> $Cfile echo "c_flags $quote$C_FLAGS$quote;" >> $Cfile echo >> $Cfile echo "link_flags $quote$LINK_FLAGS$quote;" >> $Cfile echo >> $Cfile echo "libraries $quote$LIBS$quote;" >> $Cfile echo >> $Cfile echo "global $Opt;" >> $Cfile echo >> $Cfile set text="// layers, mechanism and tracer:" echo "$text ${Layers}, ${Mechanism}, ${Tracer}" >> $Cfile echo "// project archive: ${Project}" >> $Cfile echo >> $Cfile echo "include SUBST_PE_COMM $ICL_PAR/PE_COMM.EXT;" >> $Cfile echo "include SUBST_CONST $ICL_CONST/CONST.EXT;" >> $Cfile echo "include SUBST_FILES_ID $ICL_FILES/FILES_CTM.EXT;" >> $Cfile echo "include SUBST_EMPR_VD $ICL_EMCTL/EMISPRM.vdif.EXT;" >> $Cfile echo "include SUBST_EMPR_CH $ICL_EMCTL/EMISPRM.chem.EXT;" >> $Cfile echo "include SUBST_IOPARMS $ICL_IOAPI/PARMS3.EXT;" >> $Cfile echo "include SUBST_IOFDESC $ICL_IOAPI/FDESC3.EXT;" >> $Cfile echo "include SUBST_IODECL $ICL_IOAPI/IODECL3.EXT;" >> $Cfile echo "include SUBST_COORD_ID $ICL_VCRD/COORD_${Layers}L.EXT;" >> $Cfile echo "include SUBST_VGRD_ID $ICL_VCRD/VGRD_${Layers}.EXT;" >> $Cfile echo "include SUBST_RXCMMN $ICL_MECH/RXCM.EXT;" >> $Cfile echo "include SUBST_RXDATA $ICL_MECH/RXDT.EXT;" >> $Cfile echo "include SUBST_GC_SPC $ICL_MECH/GC_SPC.EXT;" >> $Cfile echo "include SUBST_GC_EMIS $ICL_MECH/GC_EMIS.EXT;" >> $Cfile echo "include SUBST_GC_ICBC $ICL_MECH/GC_ICBC.EXT;" >> $Cfile echo "include SUBST_GC_DIFF $ICL_MECH/GC_DIFF.EXT;" >> $Cfile echo "include SUBST_GC_DDEP $ICL_MECH/GC_DDEP.EXT;" >> $Cfile echo "include SUBST_GC_DEPV $ICL_MECH/GC_DEPV.EXT;" >> $Cfile echo "include SUBST_GC_ADV $ICL_MECH/GC_ADV.EXT;" >> $Cfile echo "include SUBST_GC_CONC $ICL_MECH/GC_CONC.EXT;" >> $Cfile echo "include SUBST_GC_G2AE $ICL_MECH/GC_G2AE.EXT;" >> $Cfile echo "include SUBST_GC_G2AQ $ICL_MECH/GC_G2AQ.EXT;" >> $Cfile echo "include SUBST_GC_SCAV $ICL_MECH/GC_SCAV.EXT;" >> $Cfile echo "include SUBST_GC_WDEP $ICL_MECH/GC_WDEP.EXT;" >> $Cfile echo "include SUBST_AE_SPC $ICL_MECH/AE_SPC.EXT;" >> $Cfile echo "include SUBST_AE_EMIS $ICL_MECH/AE_EMIS.EXT;" >> $Cfile echo "include SUBST_AE_ICBC $ICL_MECH/AE_ICBC.EXT;" >> $Cfile echo "include SUBST_AE_DIFF $ICL_MECH/AE_DIFF.EXT;" >> $Cfile echo "include SUBST_AE_DDEP $ICL_MECH/AE_DDEP.EXT;" >> $Cfile echo "include SUBST_AE_DEPV $ICL_MECH/AE_DEPV.EXT;" >> $Cfile echo "include SUBST_AE_ADV $ICL_MECH/AE_ADV.EXT;" >> $Cfile echo "include SUBST_AE_CONC $ICL_MECH/AE_CONC.EXT;" >> $Cfile echo "include SUBST_AE_A2AQ $ICL_MECH/AE_A2AQ.EXT;" >> $Cfile echo "include SUBST_AE_SCAV $ICL_MECH/AE_SCAV.EXT;" >> $Cfile echo "include SUBST_AE_WDEP $ICL_MECH/AE_WDEP.EXT;" >> $Cfile echo "include SUBST_NR_SPC $ICL_MECH/NR_SPC.EXT;" >> $Cfile echo "include SUBST_NR_EMIS $ICL_MECH/NR_EMIS.EXT;" >> $Cfile echo "include SUBST_NR_ICBC $ICL_MECH/NR_ICBC.EXT;" >> $Cfile echo "include SUBST_NR_DIFF $ICL_MECH/NR_DIFF.EXT;" >> $Cfile echo "include SUBST_NR_DDEP $ICL_MECH/NR_DDEP.EXT;" >> $Cfile echo "include SUBST_NR_DEPV $ICL_MECH/NR_DEPV.EXT;" >> $Cfile echo "include SUBST_NR_ADV $ICL_MECH/NR_ADV.EXT;" >> $Cfile echo "include SUBST_NR_N2AE $ICL_MECH/NR_N2AE.EXT;" >> $Cfile echo "include SUBST_NR_N2AQ $ICL_MECH/NR_N2AQ.EXT;" >> $Cfile echo "include SUBST_NR_SCAV $ICL_MECH/NR_SCAV.EXT;" >> $Cfile echo "include SUBST_NR_WDEP $ICL_MECH/NR_WDEP.EXT;" >> $Cfile echo "include SUBST_TR_SPC $ICL_TRAC/TR_SPC.EXT;" >> $Cfile echo "include SUBST_TR_EMIS $ICL_TRAC/TR_EMIS.EXT;" >> $Cfile echo "include SUBST_TR_ICBC $ICL_TRAC/TR_ICBC.EXT;" >> $Cfile echo "include SUBST_TR_DIFF $ICL_TRAC/TR_DIFF.EXT;" >> $Cfile echo "include SUBST_TR_DDEP $ICL_TRAC/TR_DDEP.EXT;" >> $Cfile echo "include SUBST_TR_DEPV $ICL_TRAC/TR_DEPV.EXT;" >> $Cfile echo "include SUBST_TR_ADV $ICL_TRAC/TR_ADV.EXT;" >> $Cfile echo "include SUBST_TR_T2AQ $ICL_TRAC/TR_T2AQ.EXT;" >> $Cfile echo "include SUBST_TR_SCAV $ICL_TRAC/TR_SCAV.EXT;" >> $Cfile echo "include SUBST_TR_WDEP $ICL_TRAC/TR_WDEP.EXT;" >> $Cfile echo >> $Cfile set text = "// Process Analysis / Integrated Reaction Rates processing" echo $text >> $Cfile #echo "include SUBST_PACTL_ID $ICL_PA/PA_CTL_no_irr.EXT;" >> $Cfile echo "include SUBST_PACTL_ID $ICL_PA/PA_CTL.EXT;" >> $Cfile echo "include SUBST_PACMN_ID $ICL_PA/PA_CMN.EXT;" >> $Cfile echo "include SUBST_PADAT_ID $ICL_PA/PA_DAT.EXT;" >> $Cfile echo >> $Cfile echo "$Str1" >> $Cfile echo "$Str2" >> $Cfile echo >> $Cfile echo "$ModDriver" >> $Cfile echo >> $Cfile echo "$ModPar" >> $Cfile echo >> $Cfile echo "$ModInit" >> $Cfile echo >> $Cfile set text = "denrate and adjcon_noop" echo "// options are" $text >> $Cfile echo "$ModAdjc" >> $Cfile echo >> $Cfile echo "$ModCpl" >> $Cfile echo >> $Cfile set text = "hbot, hppm and hadv_noop" echo "// options are" $text >> $Cfile echo "$ModHadv" >> $Cfile echo >> $Cfile set text = "vbot, vppm and vadv_noop" echo "// options are" $text >> $Cfile echo "$ModVadv" >> $Cfile echo >> $Cfile set text = "unif, multi_scale and hdiff_noop" echo "// options are" $text >> $Cfile echo "$ModHdiff" >> $Cfile echo >> $Cfile set text = "eddy and vdiff_noop" echo "// options are" $text >> $Cfile echo "$ModVdiff" >> $Cfile echo >> $Cfile set text = "phot and phot_noop" echo "// options are" $text >> $Cfile echo "$ModPhot" >> $Cfile echo >> $Cfile set text = "ping_qssa, ping_smvgear, ping_mebi_cb4_1 and ping_noop" echo "// options are" $text >> $Cfile echo "$ModPing" >> $Cfile echo >> $Cfile set text = "qssa, smvgear, mebi_cb4_1 and chem_noop" echo "// options are" $text >> $Cfile echo "$ModChem" >> $Cfile echo >> $Cfile set text = "aero1, aero2 and aero_noop" echo "// options are" $text >> $Cfile echo "$ModAero" >> $Cfile echo >> $Cfile set text = "aero_depv1, aero_depv2 and aero_depv_noop" echo "// options are" $text >> $Cfile echo "$ModAdepv" >> $Cfile echo >> $Cfile set text = "cloud_radm and cloud_noop" echo "// options are" $text >> $Cfile echo "$ModCloud" >> $Cfile echo >> $Cfile set text = "pa and pa_noop, which requires the" echo "// options are" $text "replacement of the three" >> $Cfile set text = "// global include files with their pa_noop counterparts" echo $text >> $Cfile echo "$ModPa" >> $Cfile echo >> $Cfile echo "$ModUtil" >> $Cfile echo >> $Cfile if ( $?ModMisc ) then echo "$ModMisc" >> $Cfile echo >> $Cfile endif #> make the makefile or the model executable if ( $?MakeOpt ) then $Blder -make $Cfile # $Cfile = ${CFG}.bld else set NoMake $Blder $Cfile endif if ( $status != 0 ) then echo " *** failure in $Blder ***" exit 1 endif set flist = (\ ${Bld}/aero_driver.F \ ${Bld}/cldproc.F \ ${Bld}/opconc.F \ ${Bld}/pa_output.F \ ${Bld}/par_term.F \ ${Bld}/setup_logdev.F \ ${Bld}/vdiffim.F \ ${Bld}/wr_aconc.F \ ${Bld}/wr_conc.F ) if ($compiler == 'pg') then foreach file ( $flist ) perl -i -ple 's/^#(include)(.*)#(.*)/ $1$2\!$3/' $file end endif if ( -e "$Base/${CFG}" ) then echo " >>> previous ${CFG} exists, re-naming to ${CFG}.old <<<" unalias mv mv $Base/${CFG} $Base/${CFG}.old endif cp ${CFG}.bld $Base/${CFG} if ( ( $Opt != no_compile ) && \ ( $Opt != no_link ) && \ ( $Opt != parse_only ) && \ ( $Opt != show_only ) && \ $?NoMake ) then mv $MODEL $Base endif exit