# Makefile template for MoSt
# Compiler names and options are inserted by MoSt
NGX=64

%.o : %.c 
	$(MOST_CC) -c $(MOST_CC_OPTS) $<

%.o : %.f90
	$(MOST_F90) -c $(MOST_F90_OPTS) $(MOST_PREC) $<

%.o : %.s 
	$(MOST_AS) -o $@ $<

# MPIMOD=mpimod     # single (mpimod_stub) or parallel (mpimod)
# GUIMOD=guimod     # with GUI or without (guimod_stub)
# GUIX11=guix11     # with GUI module or without (guix11_stub)
# GUILIB=${MOST_XLIB} -lX11
# MOST_F90=f90      # name of the FORTRAN compiler
# MOST_F90_OPTS=-O  # FORTRAN options
# MOST_PREC         # May be used to set double precision
# MOST_CC=cc        # name of the C compiler for GUI
# MOST_CC_OPTS=-O   # C options
# MOST_AS=as        # name of GNU assembler

# fftmod is faster than fft991mod, but fft991mod supports
# more resolutions, e.g. T63 and T106

# legfast is the assembler version of legsym and requires currently:
# 64-bit operating system, GNU assembler (as), AMD or Intel CPU
# and PUMA compiled for single precision (default).
# PUMA with legfast runs faster at the factor of 1.3 (T21), 1.7 (T42), 2.3 (T85)
# and factor 2.6 for all higher resolutions

OBJ=cat.o fftfor.o fftasm.o rstmod.o simmod.o usermod.o guimod.o guix11.o
cat.x: $(OBJ)
	$(MOST_F90) -o cat.x $(MOST_F90_OPTS) $(OBJ) ${GUILIB}

fftfor.o:	fftfor.f90

fftasm.o:	fftasm.s
	as -o fftasm.o fftasm.s

rstmod.o:	rstmod.f90

simmod.o:	simmod.f90

usermod.o:	usermod.f90

guimod.o:	guimod.f90

gui.x11.o:	gui.x11.c

clean:
	rm -f cat.x *.o *.mod

cleanall:
	rm -f cat.x *.o *.mod cat_gp cat_gp.nc cat_sp cat_sp.nc cat_tseri cat_cfl cat_diag cat_rstini cat_rstfin
	make cleanrsttest

run:
	time ./cat.x $(NGX)

nc:	
	cdo -f nc copy cat_gp cat_gp.nc

view:
	ncview cat_gp.nc
all:
	make cleanall
	make
	make run
	make nc
	make view
rsttest:
	cp ../../tools/cat_rst_test.csh .       
	csh cat_rst_test.csh
	rm -f cat_rst_test.csh
cleanrsttest:
	cp ../../tools/clean_cat_rst_test.csh .       
	csh clean_cat_rst_test.csh
	rm -f clean_cat_rst_test.csh
