#
# This is a master makefile for ARPS model and supporting program
# compilation/linking etc.
#
# It starts a make command using description file make.arps30, 
# passing system dependent flags as command line arguments.
#
# To compile and link ARPS on IBM RICS/6000, do 
# 'make -f makefile arps30.ibm' or simply 'make' since this is the default. 
#
# To compile and link ARPS on CRAY, do 
# 'make -f makefile arps30.cray'. Similarly for the other systems.
#
# This makefile also handles the installation of files in selected groups
# via RCS (Revision Control System) machanism.
#
# To install all the files related to ARPS model and postprocessing 
# you need to 
#
# 1. make an empty work directory and cd into it, copy files makefile and 
#    make.arps30 from /arps/work/mxue/arps30.wrk9.
# 2. build a logical link between the RCS directory that holds the RCS file
#    and the subdirectory called RCS inside your work directory, by doing
#    ln -s /arps/work/mxue/arps30.wrk9/RCS RCS
# 3. install the files by doing
#    make install_all 
#
# P.S. /arps/work/mxue/arps30.wrk9 is the directory that the files now
#      resides, these files will later be moved to /arps/official/arps30 
#

FFLAGS.ibm     = -O -Q -NA16384 -ND6912
FFLAGS.cray    = -Zv -F 
#FFLAGS.cray    = -Zv -F -Wf"-a stack" 
FFLAGS.alliant = -DAS -O 
FFALGS.general = 

default: arps30.sun

########################################################################
#
# Compile and link ARPS30 model for IBM system, and generate executable 
# arps30
#
########################################################################

arps30.ibm: force
	$(MAKE) -f make.arps30.f77 "LDR=f77" "FFLAGS= $(FFLAGS.ibm)" arps30.ibm

arps30.syntax:  # compilation without optimalization for faster speed. 
	$(MAKE) -f make.arps30.f77 "LDR=f77" "FFLAGS= -qsource" arps30.ibm

arps30.cray: force
	$(MAKE) -f make.arps30.f77 "LDR=cf77" 'FFLAGS= $(FFLAGS.cray)' arps30.cray 

arps30.alliant: force
	$(MAKE) -f make.arps30.f77 "LDR=fortran" "FFLAGS= $(FFLAGS.alliant)" arps30.general

arps30.convex: force
	$(MAKE) -f make.arps30.f77 "LDR=fc" "FFLAGS= -O2" arps30.general

arps30.iris: force
	$(MAKE) -f make.arps30.f77 "LDR=f77" "FFLAGS= -O2" arps30.general

arps30.sun: force
	$(MAKE) -f make.arps30.f77 "LDR=f77" "FFLAGS= -O2" arps30.general

########################################################################
#
# Graphic plotting:
#
########################################################################

########################################################################
# Compile and link graphic plotting program using ZXPLOT library for 
# NCAR graphic metafile output. Executable is arpspltncar
########################################################################

arpspltncar: force 
	$(MAKE) -f make.arps30.f77 "LDR=zxncarf77" "FFLAGS= $(FFLAGS.general)" arpspltncar

########################################################################
# Compile and link graphic plotting program using ZXPLOT library for 
# postscript output. Executable is arpspltpost
########################################################################

arpspltpost: force 
	$(MAKE) -f make.arps30.f77 "LDR=zxpostf77" "FFLAGS= $(FFLAGS.general)" arpspltpost

########################################################################
# Compile and link a program that plots the time series of max and min
# of model variables. NCAR graphic is linked. 
########################################################################
  
arpspltmax: arpspltmax.o
	zxncarf77 -o arpspltmax arpspltmax.o
#       zxpostf77 -o arpspltmax arpspltmax.o

########################################################################
#
# Data conversion:
#
########################################################################
 
arpscvt.ibm: force
	$(MAKE) -f make.arps30.f77 "LDR=f77" "FFLAGS= $(FFLAGS.ibm)" $@  

# note: here $@ = name of the target, i.e. arpscvt.ibm 

arpscvt.cray: force
	$(MAKE) -f make.arps30.f77 "LDR=cf77" "FFLAGS= $(FFLAGS.cray)" $@ 

########################################################################
#
# Data printing: 
#
########################################################################
 
arpsprt.ibm: force
	$(MAKE) -f make.arps30.f77 "LDR=f77" "FFLAGS= $(FFLAGS.ibm)" $@ 

arpsprt.cray: force
	$(MAKE) -f make.arps30.f77 "LDR=cf77" "FFLAGS= $(FFLAGS.cray)" $@ 
 
########################################################################
#
# Combine all the model source code files together into a single file
#
########################################################################

arps30.src.ibm: force  # A version to run on the CAPS IBM RISC/6000 cluster
	$(MAKE) -f make.arps30.f77 $@
 
arps30.src.cray: force # A version to run on CRAY system. 
	$(MAKE) -f make.arps30.f77 $@
 
#
# To check out from RCS all the files needed to run ARPS from RCS
#
get_arps30: force  
	$(MAKE) -f make.arps30.f77 $@

install_arps30: force  
	$(MAKE) -f make.arps30.f77 get_arps30 

#
# To check out from RCS all the files needed to run the plotting program
#
get_arpsplt: force 
	$(MAKE) -f make.arps30.f77 $@

install_plt: force 
	$(MAKE) -f make.arps30.f77 get_arpsplt 

#
# To check out from RCS all the files needed to run the conversion program
#
get_arpscvt: force 
	$(MAKE) -f make.arps30.f77 $@

install_cvt: force 
	$(MAKE) -f make.arps30.f77 get_arpscvt 

#
# To check out from RCS all the files needed to run the conversion program
#
get_arpsprt: force 
	$(MAKE) -f make.arps30.f77 $@

install_prt: force 
	$(MAKE) -f make.arps30.f77 get_arpsprt 

#
# To check out from RCS all the files to do with ARPS
#
get_all: force     
	$(MAKE) -f make.arps30.f77 $@

install_all: force     
	$(MAKE) -f make.arps30.f77 get_all 

#
# To produce a tar file of all the files to do with ARPS 
#
Allfiles.tar: force
#-/bin/rm $@; $(MAKE) -f make.arps30.f77 $@
	$(MAKE) -f make.arps30.f77 $@

#
# To compare the work version of allfiles with those inside RCS 
#
compare: force
	$(MAKE) -f make.arps30.f77 $@
#
# To produce a tar file of all the files for ARPS model run 
#
arps30.tar: force  
	$(MAKE) -f make.arps30.f77 $@

#
# To produce a tar file of all the files for plotting program 
#
arpsplt.tar: force 
	$(MAKE) -f make.arps30.f77 $@

#
# To produce a tar file of all the files for data conversion program 
#
arpscvt.tar: force 
	$(MAKE) -f make.arps30.f77 $@
 
#
# To produce a tar file of all the files for data conversion program 
#
arpsprt.tar: force 
	$(MAKE) -f make.arps30.f77 $@
 
########################################################################
# To install a split version of the model code in another directory 
# whose name is given inside make file make.arps.
########################################################################
 
arps30.split: force
	$(MAKE) -f make.arps30.f77 $@
 
install_split: force
	$(MAKE) -f make.arps30.f77 arps30.split 
 
########################################################################
#
# Check in all source files in RCS
#
########################################################################
 
arps30.checkin: force 
	$(MAKE) -f make.arps30.f77 $@

########################################################################
#
# Check out all source files in RCS
#
########################################################################

arps30.checkout: force
	$(MAKE) -f make.arps30.f77 $@

force:

arpspltmax.o:	arpspltmax.f
