Merge pull request #22 from wirc-sjsu/develop-w21
[WRF-SFIRE.git] / external / io_netcdf / makefile
blobfa638d455f8ef931d1e01c7dd2f47b1f13970e04
1 #makefile to build a wrf_io with netCDF
3 OBJSL = wrf_io.o field_routines.o module_wrfsi_static.o
4 OBJS = $(OBJSL)
5 CODE = ext_ncd_get_dom_ti.code ext_ncd_get_var_td.code ext_ncd_get_var_ti.code ext_ncd_put_dom_ti.code ext_ncd_put_var_td.code ext_ncd_put_var_ti.code transpose.code
6 FFLAGS = $(FCFLAGS) -I$(NETCDFPATH)/include -I../ioapi_share
7 LIBS = $(LIB_LOCAL) -L$(NETCDFPATH)/lib -lnetcdf
8 LIBFFS = $(LIB_LOCAL) -L$(NETCDFPATH)/lib -lnetcdff -lnetcdf $(NETCDF4_DEP_LIB)
9 CPP1 = $(CPP) -P $(TRADFLAG)
10 M4 = m4 -Uinclude -Uindex -Ulen
11 AR = ar
13 .SUFFIXES: .F90 .f .o .code
15 all : libwrfio_nf.a
17 libwrfio_nf.a: $(OBJS) $(CODE)
18 /bin/rm -f $@
19 if [ "$(AR)" != "lib.exe" ] ; then \
20 $(AR) cr libwrfio_nf.a $(OBJSL) ; \
21 else \
22 $(AR) /out:libwrfio_nf.a $(OBJSL) ; \
24 $(RANLIB) $@
26 wrf_io.o: wrf_io.F90 $(CODE)
27 grep nf_format_64bit $(NETCDFPATH)/include/netcdf.inc ;\
28 a=$$? ; export a ; \
29 if [ $$a -a "$$WRFIO_NCD_LARGE_FILE_SUPPORT" = "1" ] ; then \
30 $(CPP1) -DWRFIO_NCD_LARGE_FILE_SUPPORT -I../ioapi_share wrf_io.F90 | $(M4) - > wrf_io.f ; \
31 else \
32 $(CPP1) -I../ioapi_share wrf_io.F90 | $(M4) - > wrf_io.f ; \
34 $(FC) -o $@ $(FFLAGS) -c wrf_io.f
37 module_wrfsi_static.o: module_wrfsi_static.F90
38 $(CPP1) -I../ioapi_share module_wrfsi_static.F90 > module_wrfsi_static.f
39 $(FC) -o $@ $(FFLAGS) -c module_wrfsi_static.f
41 # gfortran treats iargc as intrinsic, so get rid of external declaration in that case
42 diffwrf: diffwrf.F90
43 x=`echo "$(FC)" | awk '{print $$1}'` ; export x ; \
44 if [ $$x = "gfortran" ] ; then \
45 echo removing external declaration of iargc for gfortran ; \
46 $(CPP1) -I$(NETCDFPATH)/include -I../ioapi_share diffwrf.F90 | sed '/integer *, *external.*iargc/d' > diffwrf.f ;\
47 else \
48 $(CPP1) -I$(NETCDFPATH)/include -I../ioapi_share diffwrf.F90 > diffwrf.f ; \
50 $(FC) -c $(FFLAGS) diffwrf.f
51 @if [ \( -f ../../frame/wrf_debug.o \) -a \( -f ../../frame/module_wrf_error.o \) -a \( -f $(ESMF_MOD_DEPENDENCE) \) -a \( -f ../../frame/clog.o \) ] ; then \
52 echo "diffwrf io_netcdf is being built now. " ; \
53 if [ \( -f $(NETCDFPATH)/lib/libnetcdff.a -o -f $(NETCDFPATH)/lib/libnetcdff.so -o -f $(NETCDFPATH)/lib/libnetcdff.dll.a \) ] ; then \
54 $(FC) $(FFLAGS) $(LDFLAGS) -o diffwrf diffwrf.o $(OBJSL) ../../frame/wrf_debug.o ../../frame/module_wrf_error.o ../../frame/clog.o $(ESMF_IO_LIB_EXT) $(LIBFFS) ;\
55 else \
56 $(FC) $(FFLAGS) $(LDFLAGS) -o diffwrf diffwrf.o $(OBJSL) ../../frame/wrf_debug.o ../../frame/module_wrf_error.o ../../frame/clog.o $(ESMF_IO_LIB_EXT) $(LIBS) ;\
57 fi ; \
58 else \
59 echo "***************************************************************************** " ; \
60 echo "*** Rerun compile to make diffwrf in external/io_netcdf directory *** " ; \
61 echo "***************************************************************************** " ; \
64 field_routines.o: field_routines.F90 wrf_io.o
65 $(CPP1) -I../ioapi_share field_routines.F90 > field_routines.f
66 $(FC) -o $@ $(FFLAGS) -c field_routines.f
68 superclean:
69 @/bin/rm -f *.f *.o *.obj *.i testWRFWrite testWRFRead \
70 *.mod libwrfio_nf.a diffwrf