FC = ifc CC = icc FFLAGS = -g -r8 -i4 -quiet LFLAGS = -g -quiet IPATH = -I./ -I./includes/ LIBS = -L../netcdf/lib -lnetcdf # modules to push through OpenAD SRCMODS = \ adsize.f90 \ size.f90 \ parms.f90 \ vars.f90 \ pfields.f90 \ force.f90 \ data.f90 \ weights.f90 \ mini.f90 \ size_small.f90 # code to push through OpenAD # without IO SRCFILES = \ inifields.F \ readparms.F \ iowrapper.F \ read_data.F \ make_weights.F \ map_control_vector.F \ small_routines_split.F \ small_routines_joint.F \ cost_function.F \ cost_depth.F \ loop_body_wrapper_inner.F \ loop_body_wrapper_outer.F \ forward_model.F all: shallow_water shallow_water_OpenAD links ################################################################### # shallow_water ################################################################### # netcdf IO NETCDF_IO = ionetcdf.f shallow_water: $(SRCMODS:.f90=.o) $(SRCFILES:.F=.o) $(NETCDF_IO:.f=.o) main.o $(FC) $(LFLAGS) -o $@ $^ $(LIBS) ################################################################### # shallow_water_OpenAD ################################################################### # OpenAD helper modules OADSUPPORTMODS = \ w2f__types.f90 \ active_module.f90 \ OpenAD_checkpoints.f90 \ OpenAD_dct.f90 \ OpenAD_tape.f90 \ OpenAD_rev.f90 shallow_water_OpenAD: $(addprefix OpenAD/, $(OADSUPPORTMODS:.f90=.o)) \ singleFile.xb.x2w.w2f.pp.o \ OpenAD/iaddr.o \ $(NETCDF_IO:.f=.o) \ OpenAD/main_OpenAD.o $(FC) $(LFLAGS) -o $@ $^ $(LIBS) # concatenate all sources into a single file singleFile.f : $(SRCMODS) $(SRCFILES:.F=.f) cat $^ > $@ # F -> WHIRL singleFile.B: singleFile.f ../bin/mfef90 -F -N132 $< # WHIRL -> XAIF singleFile.xaif : singleFile.B export LD_LIBRARY_PATH=../bin:${LD_LIBRARY_PATH}; ../bin/whirl2xaif -o $@ $< # XAIF -> XAIF' singleFile.xb.xaif : singleFile.xaif export LD_LIBRARY_PATH=../bin:${LD_LIBRARY_PATH}; ../bin/adm -i $< -c ../schema/inlinable_intrinsics.xaif -s ../schema -o $@ # XAIF' -> WHIRL' singleFile.xb.x2w.B : singleFile.xb.xaif export LD_LIBRARY_PATH=../bin:${LD_LIBRARY_PATH}; ../bin/xaif2whirl --structured singleFile.B $< # WHIRL' -> F' singleFile.xb.x2w.w2f.f: singleFile.xb.x2w.B export LD_LIBRARY_PATH=../bin:${LD_LIBRARY_PATH}; ../bin/whirl2f -openad $< # postprocess F' singleFile.xb.x2w.w2f.pp.f: singleFile.xb.x2w.w2f.f perl ../perl/pp.pl $(PP_FLAGS) $< # remove the extra returns cat $@ | sed 's/RETURN//' > $@.1 mv $@.1 $@ ################################################################### # generic stuff ################################################################### # cancel the built in rule: %.o:%.F # preprocessor rule: %.f:%.F $(FC) -132 -EP $(FFLAGS) $(IPATH) $< > $@ # compile rules %.o:%.f $(FC) -c -132 $(FFLAGS) $< -o $@ OpenAD/%.o:OpenAD/%.f $(FC) -c -132 $(FFLAGS) $< -o $@ %.o:%.f90 $(FC) -c -free $(FFLAGS) $< -o $@ OpenAD/%.o:OpenAD/%.f90 $(FC) -c -free $(FFLAGS) $< -o $@ OpenAD/%.o:OpenAD/%.c $(CC) -c -g -O3 $< -o $@ links: ln -sf ../shallow_water exe/shallow_water ln -sf ../shallow_water_OpenAD exe/shallow_water_OpenAD ln -sf ../data_files/data exe/data ln -sf ../data_files/data.orig exe/data.orig ln -sf ../data_files/restart_long.nc exe/restart_long.nc ln -sf ../data_files/weights_depth_diff.nc exe/weights_depth_diff.nc ln -sf ../data_files/weights_depth.nc exe/weights_depth.nc clean: rm -f singleFile* *.o *.mod *.mod-whirl rm -f OpenAD/*.o rm -f $(SRCFILES:.F=.f) rm -f ionetcdf*.f rm -f shallow_water shallow_water_OpenAD rm -f exe/shallow* exe/data* exe/*.nc exe/run.log exe/cost.txt rm -f *.xsd .SUFFIXES: .f90 .F .f .o .PHONY : all links run clean .PRECIOUS: %.f OpenAD/%.f