source: LMDZ6/trunk/libf/phylmd/ecrad-acc/Makefile.in

Last change on this file was 6016, checked in by yann meurdesoif, 3 months ago

Add new ecrad version from DWD ported onto OpenACC, closed from original ecrad ECMWF starting point for LMDZ ecrad version.

Modification from ecrad-lmdz version has been included.

YM

  • Property svn:eol-style set to native
File size: 12.2 KB
Line 
1# Path to the directory with the source files:
2srcdir:= @srcdir@
3
4# Path to the directory with the Fortran module files:
5moddir:= mod
6
7# Paths to the installation directories:
8prefix= @prefix@
9exec_prefix= @exec_prefix@
10
11# Package tarname:
12PACKAGE_TARNAME= @PACKAGE_NAME@-@PACKAGE_VERSION@
13
14# Utilities:
15SHELL= @SHELL@
16FC= @FC@
17PYTHON= @PYTHON@
18DEPLIST= ${PYTHON} $(srcdir)/mkhelper/deplist.py
19DEPGEN= ${PYTHON} $(srcdir)/mkhelper/depgen.py --src-root='@srcdir@' --pp-enable --pp-eval-expr \
20        --pp-inc-flag='@FCINCFLAG_PP@' --pp-inc-order='@FCINCORDER_PP@' --pp-macro-flag='@FCDEF_PP@' \
21        --fc-enable --fc-mod-ext='@FCMODEXT@.proxy' --fc-mod-upper='@FCMODUC@' --fc-inc-flag='@FCINCFLAG@' \
22        --fc-inc-order='@FCINCORDER@' --fc-mod-dir-flag='@FCMODOUT@' --fc-external-mods='@DEPGEN_EXTERNAL_MODS@'
23MODCMP= ${PYTHON} $(srcdir)/mkhelper/fortmodcmp.py
24AR= @AR@
25ARFLAGS= @ARFLAGS@
26INSTALL= @INSTALL@
27INSTALL_DATA= @INSTALL_DATA@
28GIT= git
29TAR= tar
30BZIP2 = bzip2
31
32# Fortran compiler and flags:
33FCFLAGS= @FCMODINC@$(moddir) @FCMODOUT@$(moddir) @FCINCFLAG_PP@$(srcdir)/include @NETCDF_FCFLAGS@ @FCFLAGS@
34LDFLAGS= @LDFLAGS@
35LIBS= @NETCDF_FCLIBS@ @LIBS@
36
37# Silent rule prefixes:
38V= @DEFAULT_VERBOSITY@
39ifeq ($(V), 0)
40silent_FC=      @echo "  FC      " $@;
41silent_MKDIR=   @echo "  MKDIR   " $(@D);
42silent_DEPGEN=  @echo "  DEPGEN  " $@;
43silent_AR=      @echo "  AR      " $@;
44endif
45
46lib_LIBRARIES:= libifsaux.a libifsrrtm.a libradiation.a libutilities.a
47
48ignored_SOURCES:=                                \
49    ifsrrtm/rrtm_ecrt_140gp_mcica.F90            \
50    ifsrrtm/rrtm_rrtm_140gp_mcica.F90            \
51    ifsrrtm/srtm_gas_optical_depth_test.F90      \
52    ifsrrtm/srtm_spcvrt_mcica.F90                \
53    ifsrrtm/srtm_srtm_224gp_mcica.F90            \
54    radiation/radiation_adding_ica_sw_test.F90   \
55    radiation/radiation_adding_ica_sw_test2.F90  \
56    radiation/radiation_ice_optics_baran2016.F90 \
57    radiation/radiation_psrad.F90                \
58    radiation/radiation_psrad_rrtm.F90
59
60libifsaux_a_SOURCES:= $(filter-out $(ignored_SOURCES),$(patsubst $(srcdir)/%,%,$(shell find $(srcdir)/ifsaux -name '*.F90')))
61libifsrrtm_a_SOURCES:= $(filter-out $(ignored_SOURCES),$(patsubst $(srcdir)/%,%,$(shell find $(srcdir)/ifsrrtm -name '*.F90')))
62libradiation_a_SOURCES:= $(filter-out $(ignored_SOURCES),$(patsubst $(srcdir)/%,%,$(shell find $(srcdir)/radiation -name '*.F90')))
63libutilities_a_SOURCES:= $(filter-out $(ignored_SOURCES),$(patsubst $(srcdir)/%,%,$(shell find $(srcdir)/utilities -name '*.F90')))
64
65all_SOURCES:= $(libifsaux_a_SOURCES) $(libifsrrtm_a_SOURCES) $(libradiation_a_SOURCES) $(libutilities_a_SOURCES)
66
67# Dependency files:
68deps:= $(addsuffix .d,$(all_SOURCES))
69
70# Stamp files of the building subdirectories:
71dirstamps= $(addsuffix .dirstamp, $(sort $(dir $(deps)))) $(moddir)/.dirstamp
72
73# PGI cross-file function inlining via an inline library:
74INLIB= @DEFAULT_INLIB@
75ifeq ($(INLIB), 1)
76
77# Additional silence prefixes:
78ifeq ($(V), 0)
79silent_FCEX= @echo "  FC (EX) " $@;
80silent_FCIN= @echo "  FC (IL) " $@;
81endif
82
83# Name of the inline library (a directory):
84inlib_name:= ecrad.il
85
86# Additional compiler flags enabling the inline library generation:
87inlib_extract_FCFLAGS:= -Mextract=lib:$(inlib_name),reshape,name:adding_ica_sw,name:beta2alpha,name:calc_fluxes_no_scattering_lw,name:calc_ice_optics_baran,name:calc_ice_optics_baran2016,name:calc_ice_optics_baran2017,name:calc_ice_optics_fu_lw,name:calc_ice_optics_fu_sw,name:calc_ice_optics_yi_lw,name:calc_ice_optics_yi_sw,name:calc_liq_optics_lindner_li,name:calc_liq_optics_slingo,name:calc_liq_optics_socrates,name:calc_no_scattering_transmittance_lw,name:calc_ref_trans_lw,name:calc_ref_trans_sw,name:calc_two_stream_gammas_lw,name:calc_two_stream_gammas_sw,name:cloud_generator_acc,name:delta_eddington_extensive,name:delta_eddington_scat_od,name:fast_adding_ica_lw,name:initialize_acc,name:radiation_liquid_optics_socrates,name:uniform_distribution_acc
88
89
90# Additional compiler flags enabling the inline library usage:
91inlib_inline_FCFLAGS:= -Minline=lib:$(inlib_name),reshape
92
93# List of source files containing functions that need to be inlined:
94inlib_SOURCES:=                    \
95                radiation/radiation_adding_ica_lw.F90 \
96                radiation/radiation_adding_ica_sw.F90 \
97                radiation/radiation_aerosol_optics.F90 \
98                radiation/radiation_cloud_generator_acc.F90 \
99                radiation/radiation_cloud_optics.F90 \
100                radiation/radiation_ice_optics_baran.F90 \
101                radiation/radiation_ice_optics_baran2017.F90 \
102                radiation/radiation_ice_optics_fu.F90 \
103                radiation/radiation_ice_optics_yi.F90 \
104                radiation/radiation_liquid_optics_slingo.F90 \
105                radiation/radiation_liquid_optics_socrates.F90 \
106                radiation/radiation_two_stream.F90 \
107                radiation/radiation_random_numbers.F90
108
109                #radiation/radiation_cloud_cover.F90 \ # leads to cyclic dependency, missing inlinling is acceptable for now, affected: beta2alpha
110
111# List of files where we need to manually limit GPU register usage
112inlib_limit_registers_OBJECTS:=            \
113                radiation/radiation_mcica_acc_lw.o \
114                radiation/radiation_mcica_acc_sw.o
115
116# And limiting flags
117inlib_limit_registers_FCFLAGS:= -gpu=maxregcount:96
118
119########################################
120
121# Object files that correspond to the source files in $(inlib_SOURCES):
122inlib_objs:= $(inlib_SOURCES:.F90=.@OBJEXT@)
123
124# List of objects that are generated using the inline library:
125inlib_target_objs:= $(filter %.@OBJEXT@,$(shell $(DEPLIST) -p $(inlib_objs) -f $(deps)))
126
127# To avoid circular dependencies, we need to account for situations when we
128# have a dependency A -> B -> C, where A and C belong to $(inlib_objs) but B
129# does not. In order to get all such B files and include them into
130# $(inlib_objs), we find the intersection of two sets: dependencies
131# (prerequisites) and dependents (targets) of $(inlib_objs):
132inlib_objs:= $(filter $(inlib_target_objs),$(shell $(DEPLIST) -t $(inlib_objs) -f $(deps)))
133
134# The commented code below generates a warning message if the list of source
135# files to be included into the inline library is automatically extended:
136#
137# inlib_extra_objs = $(filter-out $(inlib_SOURCES:.F90=.@OBJEXT@),$(inlib_objs))
138# ifneq ($(inlib_extra_objs),)
139# $(warning Additional files to be included into the inline library: $(inlib_extra_objs:.@OBJEXT@=.F90))
140# endif
141
142# Now we need to create a list of Fortran module files that must be created
143# before any of the object files $(inlib_objs) gets generated. First, we need a
144# subset of dependency files that correspond to $(inlib_objs):
145inlib_deps:= $(inlib_objs:.@OBJEXT@=.F90.d)
146
147# List of Fortran module files that at least on element of $(inlib_objs)
148# depends on:
149inlib_mods:= $(filter %.@FCMODEXT@.proxy,$(shell $(DEPLIST) -f $(inlib_deps)))
150
151# List of Fortran modules declared in source files that correspond to
152# $(inlib_objs):
153inlib_internal_mods:= $(filter %.@FCMODEXT@.proxy,$(shell $(DEPLIST) -p $(inlib_objs) -f $(inlib_deps)))
154
155# List of Fortran modules that must be created before the inline library:
156inlib_prereq_mods:= $(filter-out $(inlib_internal_mods),$(inlib_mods))
157
158endif # INLIB == 1
159
160# Selective search path:
161vpath %.F90 $(srcdir)
162
163# Disable built-in suffix rules:
164.SUFFIXES:
165# Targets not associated with files:
166.PHONY: all depend dummy-depend mostlyclean clean distclean \
167        maintainer-clean install install-libs install-mods dist \
168        check sanitize-mod-proxies
169# Targets that do not need the inclusion of the dependency files:
170NO_INC_TARGETS:= depend dummy-depend mostlyclean clean distclean \
171                 maintainer-clean dist
172# Keep directory stamps:
173.PRECIOUS: $(dirstamps)
174
175# Default rule:
176all: $(lib_LIBRARIES)
177
178# Explicit dependency generation rule:
179depend: $(deps)
180
181# Delete the results of compilation and linking:
182mostlyclean: $(bundled_subdirs)
183        rm -f $(lib_LIBRARIES) $(all_SOURCES:.F90=.@OBJEXT@)
184        rm -f $(moddir)/*.@FCMODEXT@ $(moddir)/*.@FCMODEXT@.proxy
185        rm -f $(notdir $(all_SOURCES:.F90=.i))
186        test x'$(INLIB)' != x1 || rm -rf $(inlib_name)
187
188# Delete files generated at the building stage:
189clean: mostlyclean
190
191# Delete everything generated at the configure stage (and clean the created directories if they are empty):
192distclean: clean
193        find . -name '*.pyc' -delete -o -name '*.pyo' -delete -o -name '__pycache__' -delete
194        rm -f $(deps) $(dirstamps)
195        @for dir in ifsaux ifsrrtm radiation utilities $(moddir); do \
196          if test -d "$$dir"; then \
197            echo "find '$$dir' -type d -empty -delete"; \
198            find "$$dir" -type d -empty -delete; \
199          fi; \
200        done
201        rm -f config.log config.status Makefile
202
203# Delete files generated at the autoreconf stage:
204maintainer-clean: distclean
205        rm -rf autom4te.cache
206
207# Installation rules:
208install: all install-libs install-mods
209
210# Check rule:
211check: all
212
213# Tarball creation rule:
214dist:
215        @if test ! -e @top_srcdir@/.git; then echo "'@top_srcdir@' is not a git repository" >&2; exit 1; fi
216        $(GIT) -C @top_srcdir@ archive --prefix=$(PACKAGE_TARNAME)/ --format tar -o @abs_top_builddir@/$(PACKAGE_TARNAME).tar HEAD
217        rm -f $(PACKAGE_TARNAME).tar.bz2 && BZIP2=$${BZIP2--9} $(BZIP2) $(PACKAGE_TARNAME).tar
218
219ifeq ($(INLIB), 1)
220
221# Pattern- and target-specific assignments are propagated to the prerequisites
222# and override the global assignments. Therefore, we introduce the following
223# match-anything pattern assignments to prevent that (the eval/value combination
224# is required to keep the original global values of the variables without
225# changing their flavors, i.e. keep them recursively expanded):
226${eval %: silent_FC= $(value silent_FC)}
227${eval %: FCFLAGS= $(value FCFLAGS)}
228
229# Target-specific variables for objects that use the inline library:
230$(inlib_target_objs): silent_FC= $(silent_FCIN)
231$(inlib_target_objs): FCFLAGS+= $(inlib_inline_FCFLAGS)
232$(inlib_limit_registers_OBJECTS): FCFLAGS+= $(inlib_limit_registers_FCFLAGS)
233
234# All object that can be built with the inline library depend on it:
235$(inlib_target_objs): $(inlib_name)
236
237# The inline library generation rule. Note that the source files are provided
238# to the compiler in the topological order. We also have to delete the partially
239# generated library if the compiler fails:
240$(inlib_name): $(inlib_prereq_mods) $(inlib_objs:.@OBJEXT@=.F90)
241        $(silent_FCEX)rm -rf $@ && $(FC) $(FCFLAGS) $(inlib_extract_FCFLAGS) @FCFLAGS_F90@ $(filter-out $(inlib_prereq_mods),$^) || (ec=$$?; rm -rf $@; exit $$ec)
242
243endif # INLIB == 1
244
245# Fortran compilation rule:
246%.@OBJEXT@: %.F90 | $(dirstamps)
247        $(silent_FC)$(FC) -o $@ -c $(FCFLAGS) @FCFLAGS_F90@ $<
248
249# Static library generation rule:
250%.a:
251        $(silent_AR)rm -f $@ && $(AR) $(ARFLAGS) $@ $^
252
253# Fortran module file rule:
254$(moddir)/%.@FCMODEXT@.proxy:| sanitize-mod-proxies
255        @if test -z '$<'; then \
256          echo "Cannot find Fortran source file providing module '$(basename $(@F:.proxy=))'." >&2; \
257        else \
258          if test ! -f '$(@:.proxy=)'; then rm -f '$<'; $(MAKE) '$<'; fi; \
259          if cmp '$@' '$(@:.proxy=)' >/dev/null 2>&1 || $(MODCMP) '$@' '$(@:.proxy=)' @FC_VENDOR@ 2>/dev/null; then :; \
260          else cp '$(@:.proxy=)' '$@' 2>/dev/null; fi; \
261        fi
262
263# Delete all Fortran module proxy files that do not have an existing module to
264# be a proxy of, i.e. if <filename>.proxy exists but <filename> does not,
265# delete <filename>.proxy:
266sanitize-mod-proxies:
267        @rm -f $(filter-out $(addsuffix .proxy,$(wildcard $(moddir)/*.@FCMODEXT@)),$(wildcard $(moddir)/*.@FCMODEXT@.proxy))
268
269# Directory creation rule:
270%/.dirstamp:
271        $(silent_MKDIR)@MKDIR_P@ $(@D) && touch $@
272
273# Fortran dependency generation rule:
274%.F90.d: %.F90 Makefile | $(dirstamps)
275        $(silent_DEPGEN)$(DEPGEN) -o $@ --obj-name $(@:.F90.d=.@OBJEXT@) -i $< -- $(FCFLAGS)
276
277# Dummy dependency file generation rule (called by config.status):
278dummy-depend: | $(dirstamps)
279        @for file in $(deps); do \
280          test -e "$$file" || touch "$$file"; \
281        done
282
283# Library installation rule:
284install-libs: $(lib_LIBRARIES)
285        $(INSTALL) -d $(DESTDIR)@libdir@ && $(INSTALL_DATA) $^ $(DESTDIR)@libdir@
286
287# Fortran module files installation rule:
288install-mods: $(filter %.@FCMODEXT@.proxy,$(shell $(DEPLIST) -f $(deps)))
289        $(INSTALL) -d $(DESTDIR)@includedir@ && $(INSTALL_DATA) $(basename $^) $(DESTDIR)@includedir@
290
291libifsaux.a: $(libifsaux_a_SOURCES:.F90=.@OBJEXT@)
292libifsrrtm.a: $(libifsrrtm_a_SOURCES:.F90=.@OBJEXT@)
293libradiation.a: $(libradiation_a_SOURCES:.F90=.@OBJEXT@)
294libutilities.a: $(libutilities_a_SOURCES:.F90=.@OBJEXT@)
295
296current_targets:= $(strip $(MAKECMDGOALS))
297ifeq (,$(current_targets))
298current_targets:= all
299endif
300
301ifneq (,$(filter-out $(NO_INC_TARGETS),$(current_targets)))
302include $(deps)
303endif
Note: See TracBrowser for help on using the repository browser.