PROGRAMS = flio_rbld Fparser ncregular ncunderflow

SOURCES = defprec.f90 errioipsl.f90 stringop.f90 calendar.f90 mathelp.f90 \
          fliocom.f90 flincom.f90 getincom.f90 histcom.f90 restcom.f90 ioipsl.f90

OBJECTS = defprec.o errioipsl.o stringop.o calendar.o mathelp.o \
          fliocom.o flincom.o getincom.o histcom.o restcom.o ioipsl.o

MODULES = defprec.mod errioipsl.mod stringop.mod calendar.mod mathelp.mod \
          fliocom.mod flincom.mod getincom.mod histcom.mod restcom.mod ioipsl.mod

NETCDFF = $(shell s.locate --lib=.a netcdff)
NETCDF = $(shell s.locate --lib=.a netcdf)

.SUFFIXES: .f90 .mod

.f90.mod:
	s.f90 -c -O 2 $<

.f90.o:
	s.f90 -c -O 2 $<

all: $(PROGRAMS)

Fparser: Fparser.f90 $(OBJECTS) $(MODULES)
	s.f90 -O 2 $< $(OBJECTS) $(NETCDFF) $(NETCDF) -o $@
#	s.f90 -O 2 $< $(OBJECTS) -lnetcdff -lnetcdf -o $@

ncregular: ncregular.f90 $(OBJECTS) $(MODULES)
	s.f90 -O 2 $< $(OBJECTS) $(NETCDFF) $(NETCDF) -o $@
#	s.f90 -O 2 $< $(OBJECTS) -lnetcdff -lnetcdf -o $@

ncunderflow: ncunderflow.f90 $(OBJECTS) $(MODULES)
	s.f90 -O 2 $< $(OBJECTS) $(NETCDFF) $(NETCDF) -o $@
#	s.f90 -O 2 $< $(OBJECTS) -lnetcdff -lnetcdf -o $@

flio_rbld: flio_rbld.f90 $(OBJECTS) $(MODULES)
	s.f90 -O 2 $< $(OBJECTS) $(NETCDFF) $(NETCDF) -o $@
#	s.f90 -O 2 $< $(OBJECTS) -lnetcdff -lnetcdf -o $@

clean:
	rm -f *.o *.mod

veryclean: clean
	rm -f $(OBJECTS) $(MODULES) $(PROGRAMS)
