[4728] | 1 | # ecRad Makefile - read the README file before editing |
---|
| 2 | |
---|
| 3 | ############################# |
---|
| 4 | ### --- CONFIGURATION --- ### |
---|
| 5 | ############################# |
---|
| 6 | |
---|
| 7 | # Use the nf-config utility, if available, to set the NETCDF_INCLUDE |
---|
| 8 | # and NETCDF_LIB flags |
---|
| 9 | HAVE_NFCONFIG := $(shell nf-config --version 2> /dev/null) |
---|
| 10 | ifdef HAVE_NFCONFIG |
---|
| 11 | $(info *** Using nf-config to obtain NetCDF flags) |
---|
| 12 | NETCDF_INCLUDE = $(shell nf-config --fflags) |
---|
| 13 | NETCDF_LIB = $(shell nf-config --flibs) |
---|
| 14 | ifeq ($(shell nf-config --has-nc4),yes) |
---|
| 15 | NETCDF4 = 1 |
---|
| 16 | endif |
---|
| 17 | else |
---|
| 18 | $(info *** nf-config not found) |
---|
| 19 | endif |
---|
| 20 | |
---|
| 21 | # make can be invoked using "make PROFILE=<prof>" in which case your |
---|
| 22 | # local configuration parameters will be obtained from |
---|
| 23 | # Makefile_include.<prof> |
---|
| 24 | ifndef PROFILE |
---|
| 25 | $(info *** No "PROFILE" variable provided, assuming "gfortran") |
---|
| 26 | PROFILE = gfortran |
---|
| 27 | endif |
---|
| 28 | |
---|
| 29 | # Include a platform-specific makefile that defines FC, FCFLAGS and |
---|
| 30 | # LIBS |
---|
| 31 | include Makefile_include.$(PROFILE) |
---|
| 32 | |
---|
| 33 | # Check for presence of the NETCDF_INCLUDE and NETCDF_LIB flags |
---|
| 34 | ifndef NETCDF_INCLUDE |
---|
| 35 | $(info *** You may need to set NETCDF_INCLUDE manually) |
---|
| 36 | endif |
---|
| 37 | ifndef NETCDF_LIB |
---|
| 38 | $(info *** You may need to set NETCDF_LIB manually) |
---|
| 39 | endif |
---|
| 40 | |
---|
| 41 | # Add single-precision flag if SINGLE_PRECISION=1 was given on the |
---|
| 42 | # "make" command line |
---|
| 43 | ifdef SINGLE_PRECISION |
---|
| 44 | CPPFLAGS += -DPARKIND1_SINGLE |
---|
| 45 | endif |
---|
| 46 | |
---|
| 47 | # If PRINT_ENTRAPMENT_DATA=1 was given on the "make" command line |
---|
| 48 | # then the SPARTACUS shortwave solver will write data to fort.101 and |
---|
| 49 | # fort.102 |
---|
| 50 | ifdef PRINT_ENTRAPMENT_DATA |
---|
| 51 | CPPFLAGS += -DPRINT_ENTRAPMENT_DATA |
---|
| 52 | endif |
---|
| 53 | # For backwards compatibility we allow the following as well |
---|
| 54 | ifdef PRINT_ENCROACHMENT_DATA |
---|
| 55 | CPPFLAGS += -DPRINT_ENTRAPMENT_DATA |
---|
| 56 | endif |
---|
| 57 | # Allow the capability to write NetCDF4/HDF5 files, provided the code |
---|
| 58 | # is compiled against the NetCDF4 library |
---|
| 59 | ifdef NETCDF4 |
---|
| 60 | $(info *** Building with NetCDF4/HDF5 support) |
---|
| 61 | CPPFLAGS += -DNC_NETCDF4 |
---|
| 62 | endif |
---|
| 63 | |
---|
| 64 | # Consolidate flags |
---|
| 65 | export FC |
---|
| 66 | export FCFLAGS = $(WARNFLAGS) $(BASICFLAGS) $(CPPFLAGS) -I../include \ |
---|
| 67 | $(OPTFLAGS) $(DEBUGFLAGS) $(NETCDF_INCLUDE) $(OMPFLAG) |
---|
| 68 | export LIBS = $(LDFLAGS) -L../lib -lradiation -lutilities \ |
---|
| 69 | -lifsrrtm -lifsaux $(FCLIBS) $(NETCDF_LIB) $(OMPFLAG) |
---|
| 70 | |
---|
| 71 | # Do we include Dr Hook from ECMWF's fiat library? |
---|
| 72 | ifdef FIATDIR |
---|
| 73 | # Prepend location of yomhook.mod module file from fiat library, so |
---|
| 74 | # that it is found in preference to the dummy one in ecRad |
---|
| 75 | FCFLAGS := -I$(FIATDIR)/module/fiat $(FCFLAGS) |
---|
| 76 | # Append fiat library (usually shared: libfiat.so) |
---|
| 77 | LIBS += -L$(FIATDIR)/lib -Wl,-rpath,$(FIATDIR)/lib -lfiat |
---|
| 78 | else |
---|
| 79 | # Dummy Dr Hook library |
---|
| 80 | LIBS += -ldrhook |
---|
| 81 | endif |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | ############################# |
---|
| 85 | ### --- BUILD TARGETS --- ### |
---|
| 86 | ############################# |
---|
| 87 | |
---|
| 88 | all: build |
---|
| 89 | |
---|
| 90 | help: |
---|
| 91 | @echo "Usage:" |
---|
| 92 | @echo " make PROFILE=<prof>" |
---|
| 93 | @echo "where <prof> is one of gfortran, pgi, intel or cray (see Makefile_include.<prof>)" |
---|
| 94 | @echo "Other possible arguments are:" |
---|
| 95 | @echo " DEBUG=1 Compile with debug settings on and optimizations off" |
---|
| 96 | @echo " SINGLE_PRECISION=1 Compile with single precision" |
---|
| 97 | @echo " FIATDIR=/my/path Compile with Dr Hook, specifying the directory containing lib/libfiat.so and module/fiat/yomhook.mod" |
---|
| 98 | @echo " test Run test cases in test directory" |
---|
| 99 | @echo " clean Remove all compiled files" |
---|
| 100 | |
---|
| 101 | ifndef FIATDIR |
---|
| 102 | build: directories libifsaux libdummydrhook libutilities libifsrrtm \ |
---|
| 103 | libradiation driver ifsdriver symlinks |
---|
| 104 | libradiation libutilities: libdummydrhook |
---|
| 105 | else |
---|
| 106 | # Note that if we are using Dr Hook from the fiat library we don't |
---|
| 107 | # want to create mod/yomhook.mod as this can sometimes be found before |
---|
| 108 | # the one in the fiat directory leading to an error at link stage |
---|
| 109 | build: directories libifsaux libutilities libifsrrtm libradiation \ |
---|
| 110 | driver ifsdriver symlinks |
---|
| 111 | endif |
---|
| 112 | |
---|
| 113 | # git cannot store empty directories so they may need to be created |
---|
| 114 | directories: mod lib |
---|
| 115 | mod: |
---|
| 116 | mkdir -p mod |
---|
| 117 | lib: |
---|
| 118 | mkdir -p lib |
---|
| 119 | |
---|
| 120 | deps: clean-deps |
---|
| 121 | cd ifsaux && $(MAKE) deps |
---|
| 122 | cd ifsrrtm && $(MAKE) deps |
---|
| 123 | cd ifs && $(MAKE) deps |
---|
| 124 | |
---|
| 125 | clean-deps: |
---|
| 126 | rm -f include/*.intfb.h |
---|
| 127 | |
---|
| 128 | libifs: libradiation |
---|
| 129 | cd ifs && $(MAKE) |
---|
| 130 | |
---|
| 131 | libifsaux: |
---|
| 132 | cd ifsaux && $(MAKE) |
---|
| 133 | |
---|
| 134 | libdummydrhook: libifsaux |
---|
| 135 | cd drhook && $(MAKE) dummy |
---|
| 136 | |
---|
| 137 | libutilities: libifsaux |
---|
| 138 | cd utilities && $(MAKE) |
---|
| 139 | |
---|
| 140 | libifsrrtm: libifsaux |
---|
| 141 | cd ifsrrtm && $(MAKE) |
---|
| 142 | |
---|
| 143 | libradiation: libifsrrtm libutilities libifsaux |
---|
| 144 | cd radiation && $(MAKE) |
---|
| 145 | |
---|
| 146 | driver: libifsaux libifsrrtm libutilities libradiation |
---|
| 147 | cd driver && $(MAKE) driver |
---|
| 148 | |
---|
| 149 | ifsdriver: libifsaux libifsrrtm libutilities libradiation libifs |
---|
| 150 | cd driver && $(MAKE) ifs_driver |
---|
| 151 | |
---|
| 152 | test_programs: driver |
---|
| 153 | cd driver && $(MAKE) test_programs |
---|
| 154 | |
---|
| 155 | symlinks: clean-symlinks |
---|
| 156 | cd practical && ln -s ../bin/ecrad |
---|
| 157 | cd practical && ln -s ../data |
---|
| 158 | |
---|
| 159 | test: test_ifs test_i3rc test_ckdmip |
---|
| 160 | |
---|
| 161 | test_ifs: driver |
---|
| 162 | cd test/ifs && $(MAKE) test |
---|
| 163 | |
---|
| 164 | test_i3rc: driver |
---|
| 165 | cd test/i3rc && $(MAKE) test |
---|
| 166 | |
---|
| 167 | test_ckdmip: |
---|
| 168 | cd test/ckdmip && $(MAKE) test |
---|
| 169 | |
---|
| 170 | clean: clean-tests clean-toplevel clean-utilities clean-mods clean-symlinks |
---|
| 171 | |
---|
| 172 | clean-tests: |
---|
| 173 | cd test/ifs && $(MAKE) clean |
---|
| 174 | cd test/i3rc && $(MAKE) clean |
---|
| 175 | cd test/ckdmip && $(MAKE) clean |
---|
| 176 | |
---|
| 177 | clean-toplevel: |
---|
| 178 | cd radiation && $(MAKE) clean |
---|
| 179 | cd driver && $(MAKE) clean |
---|
| 180 | |
---|
| 181 | clean-utilities: |
---|
| 182 | cd ifsaux && $(MAKE) clean |
---|
| 183 | cd utilities && $(MAKE) clean |
---|
| 184 | cd ifsrrtm && $(MAKE) clean |
---|
| 185 | cd drhook && $(MAKE) clean |
---|
| 186 | cd ifs && $(MAKE) clean |
---|
| 187 | |
---|
| 188 | clean-mods: |
---|
| 189 | rm -f mod/*.mod |
---|
| 190 | |
---|
| 191 | clean-symlinks: |
---|
| 192 | rm -f practical/ecrad practical/data |
---|
| 193 | |
---|
| 194 | clean-autosaves: |
---|
| 195 | rm -f *~ .gitignore~ */*~ */*/*~ |
---|
| 196 | |
---|
| 197 | .PHONY: all build help deps clean-deps libifsaux libdummydrhook libutilities libifsrrtm \ |
---|
| 198 | libradiation driver symlinks clean clean-toplevel test test_ifs ifsdriver \ |
---|
| 199 | test_i3rc clean-tests clean-utilities clean-mods clean-symlinks |
---|