source: utils/tools_dev_r12970_AGRIF_CMEMS/DOMAINcfg/Makefile @ 13024

Last change on this file since 13024 was 13024, checked in by rblod, 4 months ago

First version of new nesting tools merged with domaincfg, see ticket #2129

File size: 5.6 KB
Line 
1SHELL = /bin/bash
2AGRIF=YES
3
4include make.inc
5
6PROGS = make_domain_cfg.exe
7SFMAKEDEPEND := ./sfmakedepend
8DIR_LIB=lib
9DIR_FILES=src
10DIR_PPSRC=NEMOFILES
11DIR_PPSRC_2=ppsrc
12DIR_DOC=doc
13DIR_OBJS=obj
14DIR_LIB=lib
15
16FILENAMES =$(notdir $(basename $(wildcard src/*.F90))) $(notdir $(basename $(wildcard src/*.F))) $(notdir $(basename $(wildcard src/*.c))) $(notdir $(basename $(wildcard src/*.f))) $(notdir $(basename $(wildcard src/*.f90)))
17FILES=src/*
18ifeq ($(AGRIF),YES)
19OBJS_AGRIF=obj/agrif2model.o
20else
21OBJS_AGRIF=
22endif
23
24OBJS_CREATE_DOMCFG=$(addsuffix .o,$(addprefix $(DIR_OBJS)/,$(FILENAMES)))
25OBJS_CREATE_DOMCFG := $(filter-out $(OBJS_AGRIF),$(OBJS_CREATE_DOMCFG))
26
27all: depend conv prepagrif AGRIF_LIB $(OBJS_CREATE_DOMCFG) $(PROGS)
28      @echo
29      @echo ===================================================
30      @echo   Nesting is ok
31      @echo ===================================================
32      @echo
33
34
35ifeq ($(AGRIF),YES)
36make_domain_cfg.exe: $(DIR_LIB)/libdomcfg.a $(DIR_FILES)/nemogcm.F90 $(OBJS_AGRIF) $(OBJS_CREATE_DOMCFG)
37      $(FC) $(LINKFLAGS) $(FFLAGS) -o $(PROGS) $(OBJS_AGRIF) $(DIR_LIB)/libdomcfg.a $(LIBS) -I$(DIR_OBJS) $(FFLAGS_SPEC) -I../../ext/AGRIF -L../../ext/AGRIF -lagrif
38else
39make_domain_cfg.exe: $(DIR_LIB)/libdomcfg.a $(DIR_FILES)/nemogcm.F90 $(OBJS_CREATE_DOMCFG)
40      $(FC) $(LINKFLAGS) $(FFLAGS) -o $(PROGS)  $(DIR_LIB)/libdomcfg.a $(LIBS) -I$(DIR_OBJS) $(FFLAGS_SPEC)
41endif
42
43ifeq ($(AGRIF),YES)
44prepagrif:
45      @echo
46      @echo ===================================================
47      @echo   Create working directories for AGRIF ...
48      @echo ===================================================
49      mkdir -p obj
50      mkdir -p $(DIR_PPSRC_2)
51      mkdir -p $(DIR_LIB)
52      mkdir -p $(DIR_OBJS)
53      mkdir -p $(DIR_PPSRC)
54      mkdir -p $(DIR_PPSRC)/AGRIF_MODELFILES
55      mkdir -p $(DIR_PPSRC)/AGRIF_INC
56      \cp ../../ext/AGRIF/conv $(DIR_PPSRC)
57      \cp ../../ext/AGRIF/agrif_oce.in $(DIR_PPSRC)
58      echo $(OBJS_CREATE_DOMCFG)
59      @echo
60
61conv:
62      $(MAKE) -C ../../ext/AGRIF/LIB
63
64AGRIF_LIB: 
65      $(MAKE) -C ../../ext/AGRIF FC=$(FC) CPP=$(CPP) CPPFLAGS="" FFLAGS="$(FFLAGS)"
66else
67
68prepagrif:
69      @echo
70      @echo ===================================================
71      @echo   Create working directories  ...
72      @echo ===================================================
73      mkdir -p obj
74      mkdir -p $(DIR_PPSRC_2)
75      mkdir -p $(DIR_LIB)
76      mkdir -p $(DIR_OBJS)
77      @echo
78conv:
79AGRIF_LIB: 
80
81endif
82
83$(DIR_LIB)/libdomcfg.a: $(OBJS_CREATE_DOMCFG)
84      @echo
85      @echo ===================================================
86      @echo   Compile domcfg library...
87      @echo ===================================================
88      $(AR) -r $@ $(OBJS_CREATE_DOMCFG)
89      ranlib $@
90      @echo
91
92
93
94ifeq ($(AGRIF),YES)
95
96$(OBJS_AGRIF):src/agrif2model.F90  $(OBJS_CREATE_DOMCFG) MODEL.CPP
97      $(CPP) -I$(DIR_PPSRC)/AGRIF_INC -include MODEL.CPP $(CPPFLAGS) src/agrif2model.F90 > $(DIR_PPSRC_2)/$(*F).f90 
98      $(FC) $(FFLAGS) -c $(DIR_PPSRC_2)/$(*F).f90 -o $(DIR_OBJS)/$(*F).o -I../../ext/AGRIF -I$(DIR_OBJS)  $(FFLAGS_SPEC)
99
100$(DIR_OBJS)/%.o: $(DIR_FILES)/%.F90 make.inc MODEL.CPP
101      $(CPP) -include MODEL.CPP $(CPPFLAGS) $(DIR_FILES)/$(*F).F90 > $(DIR_PPSRC)/$(*F).f90
102      cd NEMOFILES ; ./conv ./agrif_oce.in -rm \
103      -comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile $(*F).f90
104      $(CPP) -I$(DIR_PPSRC)/AGRIF_INC -include MODEL.CPP $(CPPFLAGS)  $(DIR_PPSRC)/AGRIF_MODELFILES/$(*F).f90 >$(DIR_PPSRC_2)/$(*F).f90   
105      $(FC) $(FFLAGS) -c $(DIR_PPSRC_2)/$(*F).f90 -o $(DIR_OBJS)/$(*F).o -I../../ext/AGRIF -I$(DIR_OBJS)  $(FFLAGS_SPEC) 
106
107
108$(DIR_OBJS)/%.o: $(DIR_FILES)/%.f90 make.inc MODEL.CPP
109      $(CPP) -include MODEL.CPP $(CPPFLAGS) $(DIR_FILES)/$(*F).f90 > $(DIR_PPSRC)/$(*F).f90
110      cd NEMOFILES ; ./conv agrif_oce.in -rm \
111      -comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile $(*F).f90
112      $(CPP) -I$(DIR_PPSRC)/AGRIF_INC -include MODEL.CPP $(CPPFLAGS)  $(DIR_PPSRC)/AGRIF_MODELFILES/$(*F).f90 >$(DIR_PPSRC_2)/$(*F).f90   
113      $(FC) $(FFLAGS) -c $(DIR_PPSRC_2)/$(*F).f90 -o $(DIR_OBJS)/$(*F).o -I../../ext/AGRIF -I$(DIR_OBJS)  $(FFLAGS_SPEC) 
114
115else
116
117$(DIR_OBJS)/%.o: $(DIR_FILES)/%.F90 make.inc MODEL.CPP
118      $(CPP) -include MODEL.CPP $(CPPFLAGS) $(DIR_FILES)/$(*F).F90 > $(DIR_PPSRC_2)/$(*F).f90
119      $(FC) $(FFLAGS) -c $(DIR_PPSRC_2)/$(*F).f90 -o $(DIR_OBJS)/$(*F).o -I$(DIR_OBJS)  $(FFLAGS_SPEC) 
120
121$(DIR_OBJS)/%.o: $(DIR_FILES)/%.f90 make.inc MODEL.CPP
122      $(FC) $(FFLAGS) -c $(DIR_FILES)/$(*F).f90 -o $(DIR_OBJS)/$(*F).o -I$(DIR_OBJS)  $(FFLAGS_SPEC) 
123
124
125$(DIR_OBJS)/%.o: $(DIR_FILES)/%.c make.inc MODEL.CPP
126   $(CC) -c $(CFLAGS) -c $(DIR_FILES)/$(*F).c -o $(DIR_OBJS)/$(*F).o -I$(DIR_OBJS)  $(FFLAGS_SPEC) 
127
128endif
129#--------------------------------------------------------------------------
130#  Target to create dependeanies.
131#--------------------------------------------------------------------------
132
133MakeDepend: $(DIR_FILES)
134      $(SFMAKEDEPEND) --silent --fext=f90 --fext=f --fext=F90 --fext=F --fext=c --file=- --moddir=$(DIR_OBJS) --objdir=$(DIR_OBJS)  $(FILES) > MakeDepend
135
136depend: $(DIR_FILES)
137      @echo
138      @echo ===================================================
139      @echo   Create dependancies for Nesting ...
140      @echo ===================================================
141      $(SFMAKEDEPEND) --fext=f90 --fext=f  --silent --fext=F90 --fext=F --fext=c --file=- --moddir=$(DIR_OBJS) --objdir=$(DIR_OBJS)  $(FILES) > MakeDepend
142
143#ifneq "$(MAKECMDGOALS)" "clean"
144-include ./MakeDepend
145#endif
146
147#--------------------------------------------------------------------------
148#  Target to clean
149#--------------------------------------------------------------------------
150
151clean:
152      @echo
153      @echo ===================================================
154      @echo   Clean ...
155      @echo ===================================================
156      $(RM) -rf $(DIR_PPSRC) $(DIR_PPSRC_2) $(DIR_LIB) $(DIR_OBJS) $(PROGS) 
157   
158# DO NOT DELETE THIS LINE - used by make depend
Note: See TracBrowser for help on using the repository browser.