| 1 | #makefile to build a wrf_io with netCDF |
|---|
| 2 | |
|---|
| 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 = -L$(NETCDFPATH)/lib -lnetcdf |
|---|
| 8 | CPP1 = $(CPP) -P $(TRADFLAG) |
|---|
| 9 | M4 = m4 -Uinclude -Uindex -Ulen |
|---|
| 10 | AR = ar |
|---|
| 11 | |
|---|
| 12 | .SUFFIXES: .F90 .f .o .code |
|---|
| 13 | |
|---|
| 14 | all : libwrfio_nf.a |
|---|
| 15 | |
|---|
| 16 | libwrfio_nf.a: $(OBJS) bitwise_operators.o $(CODE) |
|---|
| 17 | /bin/rm -f $@ |
|---|
| 18 | if [ "$(AR)" != "lib.exe" ] ; then \ |
|---|
| 19 | $(AR) cr libwrfio_nf.a $(OBJSL) bitwise_operators.o ; \ |
|---|
| 20 | else \ |
|---|
| 21 | $(AR) /out:libwrfio_nf.a $(OBJSL) bitwise_operators.o ; \ |
|---|
| 22 | fi |
|---|
| 23 | $(RANLIB) $@ |
|---|
| 24 | |
|---|
| 25 | wrf_io.o: wrf_io.F90 bitwise_operators.o $(CODE) |
|---|
| 26 | grep nf_format_64bit $(NETCDFPATH)/include/netcdf.inc ;\ |
|---|
| 27 | a=$$? ; export a ; \ |
|---|
| 28 | if [ $$a -a "$$WRFIO_NCD_LARGE_FILE_SUPPORT" = "1" ] ; then \ |
|---|
| 29 | $(CPP1) -DWRFIO_NCD_LARGE_FILE_SUPPORT -I../ioapi_share wrf_io.F90 | $(M4) - > wrf_io.f ; \ |
|---|
| 30 | else \ |
|---|
| 31 | $(CPP1) -I../ioapi_share wrf_io.F90 | $(M4) - > wrf_io.f ; \ |
|---|
| 32 | fi |
|---|
| 33 | $(FC) -o $@ $(FFLAGS) -c wrf_io.f |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | module_wrfsi_static.o: module_wrfsi_static.F90 |
|---|
| 37 | $(CPP1) -I../ioapi_share module_wrfsi_static.F90 > module_wrfsi_static.f |
|---|
| 38 | $(FC) -o $@ $(FFLAGS) -c module_wrfsi_static.f |
|---|
| 39 | |
|---|
| 40 | bitwise_operators.o : |
|---|
| 41 | $(CC) -c $(CFLAGS) bitwise_operators.c |
|---|
| 42 | |
|---|
| 43 | # gfortran treats iargc as intrinsic, so get rid of external declaration in that case |
|---|
| 44 | diffwrf: diffwrf.F90 |
|---|
| 45 | x=`echo "$(FC)" | awk '{print $$1}'` ; export x ; \ |
|---|
| 46 | if [ $$x = "gfortran" ] ; then \ |
|---|
| 47 | echo removing external declaration of iargc for gfortran ; \ |
|---|
| 48 | $(CPP1) -I$(NETCDFPATH)/include -I../ioapi_share diffwrf.F90 | sed '/integer *, *external.*iargc/d' > diffwrf.f ;\ |
|---|
| 49 | else \ |
|---|
| 50 | $(CPP1) -I$(NETCDFPATH)/include -I../ioapi_share diffwrf.F90 > diffwrf.f ; \ |
|---|
| 51 | fi |
|---|
| 52 | $(FC) -c $(FFLAGS) diffwrf.f |
|---|
| 53 | @if [ \( -f ../../frame/wrf_debug.o \) -a \( -f ../../frame/module_wrf_error.o \) -a \( -f $(ESMF_MOD_DEPENDENCE) \) ] ; then \ |
|---|
| 54 | echo "diffwrf io_netcdf is being built now. " ; \ |
|---|
| 55 | if [ -f $(NETCDFPATH)/lib/libnetcdff.a ] ; then \ |
|---|
| 56 | $(FC) $(FFLAGS) $(LDFLAGS) -o diffwrf diffwrf.o $(OBJSL) bitwise_operators.o ../../frame/wrf_debug.o ../../frame/module_wrf_error.o $(ESMF_IO_LIB_EXT) $(LIBS) -lnetcdff ;\ |
|---|
| 57 | else \ |
|---|
| 58 | $(FC) $(FFLAGS) $(LDFLAGS) -o diffwrf diffwrf.o $(OBJSL) bitwise_operators.o ../../frame/wrf_debug.o ../../frame/module_wrf_error.o $(ESMF_IO_LIB_EXT) $(LIBS) ;\ |
|---|
| 59 | fi ; \ |
|---|
| 60 | else \ |
|---|
| 61 | echo "***************************************************************************** " ; \ |
|---|
| 62 | echo "*** Rerun compile to make diffwrf in external/io_netcdf directory *** " ; \ |
|---|
| 63 | echo "***************************************************************************** " ; \ |
|---|
| 64 | fi |
|---|
| 65 | |
|---|
| 66 | field_routines.o: field_routines.F90 |
|---|
| 67 | $(CPP1) -I../ioapi_share field_routines.F90 > field_routines.f |
|---|
| 68 | $(FC) -o $@ $(FFLAGS) -c field_routines.f |
|---|
| 69 | |
|---|
| 70 | superclean: |
|---|
| 71 | /bin/rm -f *.f *.o *.obj *.i testWRFWrite testWRFRead \ |
|---|
| 72 | *.mod libwrfio_nf.a diffwrf |
|---|