# Makefile for the Gryffin Gyrofluid Turbulence code (requires GNU's # gmake). This is portable and should work on T3E, J90, the # Princeton Origin2000, (may need work for ACL Origin2000), DEC Alphas, ... # # First do "module load netcdf ncar" (on Crays) or otherwise set up your # compilation/library environment. # # Then type: # # "make" to build an optimized version of Gryffin # "make debug=on" # # This uses the shell script ./test_os to figure out which platform # we are running on to set the right compiler switches and library # paths. Or type "make CPU=c90", or "setenv CPU c90" to compile for # Cray C90/J90. # # Platform-dependent logical links are done automatically, but to override # them (to use shmem on the t3e for example), do: # # "make t3e_shmem" (other link options listed at end of Makefile) # # Alternatively, the "debug" and/or "CPU" make options can be set as # environment variables, and then run make. For example: # # setenv CPU t3e ; setenv debug on ; make # # Or set defaults by uncommenting one of the following lines: # # CPU = t3e # debug = on # ######################################################################## # # environment variable CPU is used to set platform-dependent make variables. # # If CPU is undefined; use the test_os script to figure it out: ifeq ($(CPU),) CPU_tmp := $(shell ./test_os) ifeq ($(CPU_tmp),ALPHA) CPU := ALPHA # CPU := ALPHA_NAG else CPU := $(CPU_tmp) endif endif # (in gnu make, $$ translates to $, and shell then does variable substitution) # T3E options: ifeq ($(CPU),T3E) FC = f90 FLIBS_path = -L/usr/local/lib FLIBS_netcdf = $$NETCDF NAG_DP = PLATFORM_LINKS = t3e ifneq ($(debug),on) FFLAGS = -N80 -I/usr/local/include -M1110 -O vector3 F90FLAGS = -I/usr/local/include -M1110 -O vector3 FLIBS_itg = -L/usr/local/lib -lnag $$NETCDF FLIBS_postc = -L/usr/local/lib -lnag $$NETCDF $$NCAR # NCAR doesn't exist on T3E, so link to ncar_mod_stub.f90 below else FFLAGS = -N80 -I/usr/local/include -M1110 -g -R abcs -e i F90FLAGS = -I/usr/local/include -M1110 -g -R abcs -e i FLIBS_itg = -L/usr/local/lib -lnag $$NETCDF -lmalloc -Wl"-D preset=inf" # # -lapp FLIBS_postc = -L/usr/local/lib -lnag $$NETCDF -lmalloc -Wl"-D preset=inf"\ $$NCAR endif endif # Cray Fortran Compiler Options: # -Rabcs, run time checks for arguments, bounds, array conformance, strings # -N80 accepts 80 character lines # -g debug with no optimization # -eA (and link with -lapp) to use apprentice # -ei check for some kinds of uninitialized variables # -e0 initialize local stack vars to zero # -M1110 ignore warning messages about treating "double precision" as # "only" 64 bits # # when running with code linked with -lmalloc, do: # setenv MEMCHK 1 # check heap correctness after every memory utility call # setenv MEMINDEF 1 # initialize malloc memory to NAN and invalid pointers. # C90/J90 options: ifeq ($(CPU),C90) FC = f90 FLIBS_path = -L/usr/local/lib FLIBS_netcdf = $$NETCDF NAG_DP = PLATFORM_LINKS = c90 ifneq ($(debug),on) FFLAGS = -N80 -I/usr/local/include -M1110 -O vector3 F90FLAGS = -I/usr/local/include -M1110 -O vector3 FLIBS_itg = -L/usr/local/lib -lnag $$NETCDF FLIBS_postc = -L/usr/local/lib -lnag $$NETCDF $$NCAR else FFLAGS = -N80 -I/usr/local/include -M1110 -g -R abcs -e i F90FLAGS = -I/usr/local/include -M1110 -g -R abcs -e i FLIBS_itg = -L/usr/local/lib -lnag $$NETCDF \ -lmalloc -Wl"-D preset=inf" # # -lapp FLIBS_postc = -L/usr/local/lib -lnag $$NETCDF $$NCAR -lmalloc \ -lmalloc -Wl"-D preset=inf" endif endif # J90 options so that variables are private to each process (needed for MPI): # (I can't get this to work. So for now drop the "-a taskcommon" switch, # which restricts us to 1 processor on the J90.) # FFLAGS = -N80 -I/usr/local/include -M1110 -O vector3 -a taskcommon # F90FLAGS = -I/usr/local/include -M1110 -O vector3 -a taskcommon # FLIBS_itg = -L/usr/local/lib -lnag $$NETCDF # # debug options: # FFLAGS = -N80 -I/usr/local/include -M1110 -g -R abcs -e i # F90FLAGS = -I/usr/local/include -M1110 -g -R abcs -e i # FLIBS_itg = -L/usr/local/lib -lnag $$NETCDF -lmalloc -Wl"-D preset=inf" # # -lapp # SGI Origin-2000 options: ifeq ($(CPU),SGI) FC = f90 FLIBS_path = \ $(shell if [ -d /usr/pppl/lib ]; then echo "-L/usr/pppl/lib" ; \ else echo "-L/usr/local/lib64" ; fi ) FLIBS_itg = -lscs -lmpi $(FLIBS_path) -lnetcdf LIB_ncar = $(shell if [ -d /usr/local/packages/ncar_4.0.1/lib64 ]; \ then echo "-L/usr/local/packages/ncar_4.0.1/lib64" ; fi ) FLIBS_postc = $(FLIBS_path) -lnetcdf -lscs -lmpi \ $(LIB_ncar) -lncarg -lncarg_gks -lncarg_c -lX11 FLIBS_netcdf = -lnetcdf -lmpi NAG_DP = nag_sub.o elliptic_int.o fft_work.o PLATFORM_LINKS = origin ifneq ($(debug),on) FFLAGS = -col80 -64 -r8 -O -TARG:platform=ip27 F90FLAGS = -64 -r8 -O -TARG:platform=ip27 # Other options tried (no more than 15% speedup): # FFLAGS = -col80 -64 -r8 -Ofast=ip27 \ # -TARG:platform=ip27 -OPT:IEEE_arithmetic=3 -lfastm # F90FLAGS = -64 -r8 -Ofast=ip27 \ # -TARG:platform=ip27 -OPT:IEEE_arithmetic=3 -lfastm else FFLAGS = -col80 -64 -r8 -g \ -DEBUG:div_check=3:trap_uninitialized=on F90FLAGS = -64 -r8 -g \ -DEBUG:div_check=3:trap_uninitialized=on # -DEBUG:div_check=3:subscript_check=on:trap_uninitialized=on # should be the full debug options, but then the compiler bombs on some # of the routines (even the new beta version 7.3 of the compiler). endif endif # DEC alpha options: ifeq ($(CPU),ALPHA) FC = f95 FLIBS_itg = -L/usr/local/lib -lnagdx -lnetcdf -ldxml FLIBS_path = -L/usr/local/lib FLIBS_postc = -L/usr/local/lib -lnagdx -ldxml -lnetcdf \ -lncarg -lncarg_gks -lncarg_c -lX11 FLIBS_netcdf = -lnetcdf NAG_DP = nag_dp.o PLATFORM_LINKS = alpha ifeq ($(debug),on) FFLAGS = -extend_source -I/usr/local/include -r8 -g \ -assume dummy_aliases -check bounds -check overflow \ -warn argument_checking -warn truncated_source -align dcommons F90FLAGS = -I/usr/local/include -r8 -g \ -assume dummy_aliases -check bounds -check overflow \ -warn argument_checking -warn truncated_source -align dcommons else FFLAGS = -extend_source -I/usr/local/include -r8 -O -arch host \ -align dcommons -math_library fast F90FLAGS = -I/usr/local/include -r8 -O -arch host \ -align dcommons -math_library fast endif endif # options for NAG f95 on a DEC alpha ifeq ($(CPU),ALPHA_NAG) FC = /usr/local/bin/f95 FLIBS_itg = -L/usr/local/lib -lnag -lnetcdf FLIBS_netcdf = -lnetcdf NAG_DP = nag_dp.o PLATFORM_LINKS = alpha_nag ifeq ($(debug),on) FFLAGS = -132 -I/usr/local/include -r8 -g90 -dusty F90FLAGS = -I/usr/local/include -r8 -g90 -dusty else FFLAGS = -132 -I/usr/local/include -r8 -O -dusty F90FLAGS = -I/usr/local/include -r8 -O -dusty endif endif # options for Linux with NAG f95: ifeq ($(CPU),LINUX) FC = f95 FLIBS_itg = -L/usr/local/lib -lnag -lnetcdf FLIBS_netcdf = -lnetcdf NAG_DP = nag_dp.o PLATFORM_LINKS = linux ifeq ($(debug),on) FFLAGS = -132 -I/usr/local/include -r8 -g90 -dusty F90FLAGS = -I/usr/local/include -r8 -g90 -dusty else FFLAGS = -132 -I/usr/local/include -r8 -O -dusty F90FLAGS = -I/usr/local/include -r8 -O -dusty endif endif # # SUN or DEC alpha switches?: # -eA -g -dalign -I/usr/local/include # -ef #-Rabc -m0 ####################################################################### .SUFFIXES: .SUFFIXES: .f90 .f .f90.o: $(FC) $(F90FLAGS) -c $< .f.o: $(FC) $(FFLAGS) -c $< # search path where gnu make will look for files: # VPATH = ./src # some: itgc compare res2nc nc2res nc2nc all: itgc compare res2nc nc2res nc2nc postc # Cray compiler automatically searches for module *.o files in present # directory, but NAG compiler doesn't, so have to explicitly list them: FOBS_itg = aborter.o itg.o itgc.o \ diagnostics.o step.o convert.o linear.o nlps.o \ itg_data.o io_netcdf.o io_binary.o io_ascii.o io.o funnel.o \ bounds.o field_eq.o bounce_avg.o command_line.o \ fitpack_routines.o diagnostics_arrays.o fields.o fields_init.o \ gryffin_grid.o gryffin_layouts.o mp.o nonlinear.o fft_work.o \ redistribute.o gryffin_redist.o dmix.o netcdf_mod.o $(NAG_DP) # dependencies: # Several modules depend on this set of 5 modules: basic = itg_data.o gryffin_layouts.o gryffin_grid.o mp.o constants.o bounce_avg.o: $(basic) fields.o bounds.o: $(basic) gryffin_redist.o diagnostics.o: $(basic) linear.o bounce_avg.o fields.o \ diagnostics_arrays.o diagnostics_arrays.o: itg_data.o gryffin_layouts.o gryffin_grid.o dmix.o: $(basic) fields.o: itg_data.o gryffin_layouts.o gryffin_grid.o fields_init.o: $(basic) fields.o io.o gryffin_redist.o redistribute.o field_eq.o: $(basic) bounds.o linear.o funnel.o: itg_data.o gryffin_layouts.o mp.o gryffin_grid.o: gryffin_layouts.o mp.o gryffin_layouts.o: mp.o gryffin_redist.o: gryffin_layouts.o mp.o constants.o redistribute.o io.o: io_ascii.o io_binary.o io_netcdf.o io_ascii.o io_binary.o: $(basic) convert.o funnel.o \ fields.o diagnostics_arrays.o io_netcdf.o: $(basic) convert.o fields.o diagnostics_arrays.o netcdf_mod.o \ funnel.o itg.o: $(basic) linear.o nlps.o step.o diagnostics.o \ nonlinear.o bounce_avg.o field_eq.o \ fields.o dmix.o bounce_avg.o fields_init.o \ diagnostics_arrays.o itgc.o: itg_data.o io.o mp.o itg_data.o: gryffin_layouts.o gryffin_grid.o fitpack_routines.o \ command_line.o constants.o linear.o: $(basic) fft_work.o bounds.o gryffin_redist.o nlps.o: $(basic) fft_work.o gryffin_redist.o nonlinear.o: $(basic) linear.o nlps.o fields.o redistribute.o: mp.o step.o: $(basic) linear.o nonlinear.o bounds.o fields.o \ bounce_avg.o nlps.o FOBS_p = aborter.o command_line.o cplogp.o mnmx.o nsumavp.o timeavp.o \ io_binary.o io_ascii.o io_netcdf.o convert.o netcdf_mod.o \ funnel.o itg_data.o gryffin_grid.o gryffin_layouts.o mp.o \ diagnostics_arrays.o fields.o fitpack_routines.o plots.o \ graphics.o $(NAG_DP) ncar_mod.o postc.o nsumavp.o: gryffin_grid.o plots.o: itg_data.o graphics.o gryffin_grid.o postc.o : itg_data.o io.o plots.o graphics.o gryffin_layouts.o timeavp.o: itg_data.o diagnostics.o graphics.o: ncar_mod.o elliptic_int.o: elliptic_int.f $(FC) $(FFLAGS) -static -c elliptic_int.f FOBS_compare = compare.o command_line.o itgc: $(FOBS_itg) $(FC) $(F90FLAGS) -o itgc $(FOBS_itg) $(FLIBS_itg) postc: $(FOBS_p) $(FC) $(F90FLAGS) -o postc $(FOBS_p) $(FLIBS_postc) compare:$(FOBS_compare) $(FC) $(F90FLAGS) -o compare $(FOBS_compare) $(FLIBS_path) \ $(FLIBS_netcdf) clean: rm -f *.o *~ itgc postc compare res2nc nc2res nc2nc *.mod distclean: unlink clean ################### FOBS_res2nc = res2nc.o aborter.o command_line.o mp.o itg_data.o io.o \ io_netcdf.o io_binary.o io_ascii.o netcdf_mod.o \ funnel.o gryffin_grid.o gryffin_layouts.o fields.o convert.o \ diagnostics_arrays.o fitpack_routines.o # netcdf_dummy.o res2nc.o: itg_data.o io.o mp.o command_line.o res2nc: $(FOBS_res2nc) $(FC) $(F90FLAGS) -o res2nc $(FOBS_res2nc) $(FLIBS_path) \ $(FLIBS_netcdf) ################## FOBS_nc2res = nc2res.o aborter.o command_line.o mp.o itg_data.o io.o \ gryffin_grid.o gryffin_layouts.o fitpack_routines.o \ io_netcdf.o io_binary.o io_ascii.o netcdf_mod.o \ funnel.o diagnostics_arrays.o fields.o convert.o # netcdf_dummy.o nc2res.o: itg_data.o io.o mp.o command_line.o nc2res: $(FOBS_nc2res) $(FC) $(F90FLAGS) -o nc2res $(FOBS_nc2res) $(FLIBS_path) \ $(FLIBS_netcdf) ################## FOBS_nc2nc = nc2nc.o aborter.o command_line.o mp.o itg_data.o io.o \ gryffin_grid.o gryffin_layouts.o fitpack_routines.o \ io_netcdf.o netcdf_mod.o \ funnel.o diagnostics_arrays.o fields.o convert.o # netcdf_dummy.o nc2nc.o: itg_data.o io.o mp.o command_line.o nc2nc: $(FOBS_nc2nc) $(FC) $(F90FLAGS) -o nc2nc $(FOBS_nc2nc) $(FLIBS_path) \ $(FLIBS_netcdf) fft_test: fft_test.o fft_work.o $(FC) $(F90FLAGS) -o fft_test fft_test.o fft_work.o nag_dp.o \ $(FLIBS_path) -lnag ################## # If no other rules are found, use the defaults: %.o : %.f90 $(FC) $(F90FLAGS) -c $< %.o : %.f $(FC) $(FFLAGS) -c $< test_make: @echo FLIBS_path is $(FLIBS_path) @echo FC is $(FC) @echo FFLAGS is $(FFLAGS) @echo F90FLAGS is $(F90FLAGS) @echo debug is $(debug) @echo CPU is $(CPU) # If one of the platform-specific logical links doesn't exist, set them up: fft_work.f90 command_line.f90 mp.f90 redistribute.f90 xitgc nlps.f90 \ ncar_mod.f90: $(MAKE) $(PLATFORM_LINKS) ######################################################################## # # Platform-specific logical links: # c90: ln -sf fft_work_unicos.f90 fft_work.f90 ln -sf command_line_unix.f90 command_line.f90 ln -sf mp_stub.f90 mp.f90 ln -sf redistribute_mpi.f90 redistribute.f90 ln -sf xitgc.c90 xitgc ln -sf nlps_par.f90 nlps.f90 ln -sf ncar_mod_r8.f90 ncar_mod.f90 t3e_shmem: ln -sf fft_work_unicosmk.f90 fft_work.f90 ln -sf command_line_posix.f90 command_line.f90 ln -sf mp_mpi.f90 mp.f90 ln -sf redistribute_shmem.f90 redistribute.f90 ln -sf xitgc.t3e xitgc ln -sf nlps_par.f90 nlps.f90 ln -sf ncar_mod_stub.f90 ncar_mod.f90 t3e: ln -sf fft_work_unicosmk.f90 fft_work.f90 ln -sf command_line_posix.f90 command_line.f90 ln -sf mp_mpi.f90 mp.f90 ln -sf redistribute_mpi.f90 redistribute.f90 ln -sf xitgc.t3e xitgc ln -sf nlps_par.f90 nlps.f90 ln -sf ncar_mod_stub.f90 ncar_mod.f90 origin: ln -sf fft_work_origin.f90 fft_work.f90 ln -sf command_line_posix.f90 command_line.f90 # ln -sf mp_stub.f90 mp.f90 ln -sf mp_mpi_r8.f90 mp.f90 ln -sf redistribute_mpi.f90 redistribute.f90 ln -sf xitgc.t3e xitgc ln -sf nlps_par.f90 nlps.f90 ln -sf ncar_mod_r8.f90 ncar_mod.f90 if [ -f /usr/local/packages/netcdf-3.4/include/netcdf.inc ]; \ then ln -sf /usr/local/packages/netcdf-3.4/include/netcdf.inc \ netcdf.inc ; fi if [ -f /usr/pppl/include/netcdf.inc ]; \ then ln -sf /usr/pppl/include/netcdf.inc netcdf.inc ; fi linux: ln -sf fft_work_unicosmk.f90 fft_work.f90 ln -sf command_line_nag.f90 command_line.f90 ln -sf mp_stub.f90 mp.f90 ln -sf redistribute_mpi.f90 redistribute.f90 ln -sf xitgc.linux xitgc ln -sf nlps_par.f90 nlps.f90 ln -sf ncar_mod_r8.f90 ncar_mod.f90 alpha: ln -sf fft_work_nag.f90 fft_work.f90 ln -sf command_line_alpha.f90 command_line.f90 ln -sf mp_stub.f90 mp.f90 ln -sf redistribute_mpi.f90 redistribute.f90 ln -sf xitgc.c90 xitgc ln -sf nlps_par.f90 nlps.f90 ln -sf ncar_mod_r8.f90 ncar_mod.f90 # ln -sf ncar_mod_stub.f90 ncar_mod.f90 alpha_nag: ln -sf fft_work_unicosmk.f90 fft_work.f90 ln -sf command_line_nag.f90 command_line.f90 ln -sf mp_stub.f90 mp.f90 ln -sf redistribute_mpi.f90 redistribute.f90 ln -sf xitgc.linux xitgc ln -sf nlps_par.f90 nlps.f90 ln -sf ncar_mod_r8.f90 ncar_mod.f90 unlink: rm -f fft_work.f90 rm -f command_line.f90 rm -f mp.f90 rm -f redistribute.f90 rm -f xitgc rm -f nlps.f90 rm -f ncar_mod.f90 rm -f netcdf.inc