-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile.debug
More file actions
1316 lines (1076 loc) · 34.8 KB
/
Copy pathMakefile.debug
File metadata and controls
1316 lines (1076 loc) · 34.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#----------------------------------------------------------------------
# Makefile for building CAM on various platforms.
#
# This makefile assumes the existence the file:
#
# Filepath The directories, listed one per line, that contain the source
# code required to build CAM. This list is used to set the
# VPATH variable which is used by GNU make to search for
# dependencies (after it looks in the directory from which
# it was invoked). This list of directories, prepended with ./,
# is also used to construct the list of search directories
# used by the preprocessor (as specified by -I command-line options).
#
# The following macros may be set in the user's environment:
#
# ROOTDIR Root directory for the CAM source distribution. If ROOTDIR is not
# set the makefile searches for it in a file called "Rootdir".
# EXENAME Name to call the executable. Default: atm
# MODEL_EXEDIR Directory to build the executable in. Default: ./
# INC_NETCDF Directory containing the NetCDF include files. Default: /usr/local/include
# LIB_NETCDF Directory containing the NetCDF library. Default: /usr/local/lib
# MOD_NETCDF Directory containing the NetCDF module files. Default: /usr/local/lib
# INC_MPI Directory containing the MPI include files. Default: /usr/local/include
# LIB_MPI Directory containing the MPI library. Default: /usr/local/lib
# ESMF_ROOT Root directory of ESMF source tree. Default: $(ROOTDIR)/models/utils/esmf
# ESMF_BLD Upper level build directory for ESMF
# The ESMF .o files are built in $(ESMF_BLD)/obj
# The ESMF .m files are built in arch dependent subdirs of $(ESMF_BLD)/mod
# The ESMF library is built in architecture and optimization
# dependent subdirectories of $(ESMF_BLD)/lib
# Default: ./esmf
# CARMA_ROOT Root directory of CARMA source tree. Default: $(ROOTDIR)/models/utils/carma EJL - changed for Titan
# CARMA_MAKE Name of CARMA makefile. Default: Makefile.darwin.intel
# DEBUG Set to TRUE to turn on compiler debugging options. Default: FALSE
# SPMD Whether to build in SPMD mode or not. [values TRUE FALSE]
# Default: read from ./misc.h
# N.B. To ensure consistency between the Makefile and misc.h the SPMD
# macro should not be set. This forces it to be read from misc.h.
# SMP Set to TRUE to enable building in SMP mode (uses OpenMP).
# Currently implemented for IBM, SGI, linux-pgf90. (default is TRUE on IBM and
# linux-pgf90, and depends on SPMD setting on SGI).
# NESTED_OMP Set to TRUE to enable nested OpenMP support. AIX only.
# USER_FC Allow user to override the default Fortran compiler specified in Makefile.
# USER_CC Allow user to override the default C compiler specified in Makefile (linux only).
# USER_CPPDEFS Additional CPP defines.
# USER_CFLAGS Additional C compiler flags that the user wishes to set.
# USER_FFLAGS Additional Fortran compiler flags that the user wishes to set.
# USER_LDLAGS Additional load flags that the user wishes to set.
# F_OPTIMIZATION_OVERRIDE
# Use this to replace default Fortran compiler optimization.
# NO_SWITCH On Compaq if the hardware switch is not available
# set this env variable to "TRUE".
#
# Note: The ESMF library is included in the CAM distribution in
# $ROOTDIR/models/utils/esmf and is built using this makefile.
# Note: The CARMA library is included in the CAM distribution in
# $ROOTDIR/models/utils/carma and is built using this makefile.
#------------------------------------------------------------------------
# Set up special characters
null :=
space := $(null) $(null)
comma := $(null),$(null)
# Determine distribution root directory
ifeq ($(ROOTDIR),$(null))
ROOTDIR := /home/larsonej/titancarma/src
endif
# Check for override of default Fortran compiler optimizations
ifneq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION := $(F_OPTIMIZATION_OVERRIDE)
endif
# Check for the NetCDF library and include directories
ifeq ($(LIB_NETCDF),$(null))
LIB_NETCDF := /Volumes/Data/Libraries/netcdf/lib
endif
ifeq ($(INC_NETCDF),$(null))
INC_NETCDF := /Volumes/Data/Libraries/netcdf/include
endif
ifeq ($(MOD_NETCDF),$(null))
MOD_NETCDF := $(LIB_NETCDF)
endif
# Check for the MPI library and include directories
ifeq ($(LIB_MPI),$(null))
LIB_MPI := /Volumes/Data/Libraries/mpich/lib
endif
ifeq ($(INC_MPI),$(null))
INC_MPI := /Volumes/Data/Libraries/mpich/include
endif
# Build the ESMF library
ifeq ($(ESMF_ROOT),$(null))
ESMF_ROOT := ${ROOTDIR}/models/utils/esmf
endif
ifeq ($(ESMF_BLD),$(null))
ESMF_BLD := $(shell (mkdir ./esmf 2>/dev/null;cd ./esmf;pwd))
endif
ESMF_BOPT := O
ifeq ($(DEBUG),TRUE)
ESMF_BOPT := g
endif
ESMF_MOD := $(ESMF_BLD)/mod/mod$(ESMF_BOPT)
ESMF_LIB := $(ESMF_BLD)/lib/lib$(ESMF_BOPT)
# Build the CARMA libraries
#ifeq ($(CARMA_ROOT),$(null))
CARMA_ROOT := ${ROOTDIR}/models/utils/carma
#endif
ifeq ($(CARMA_ROOT),$(null))
CARMA_MAKE := Makefile.darwin.intel
endif
ifeq ($(CARMA_BLD),$(null))
CARMA_BLD := $(shell (mkdir ./carma 2>/dev/null;cd ./carma;pwd))
endif
ifeq ($(INC_CARMA),$(null))
INC_CARMA := $(CARMA_ROOT)/aer $(CARMA_ROOT)/rad $(CARMA_ROOT)/include $(CARMA_ROOT)/include/cam
endif
CARMA_BOPT := O
ifeq ($(DEBUG),TRUE)
CARMA_BOPT := g
endif
TRICK := $(shell rm $(CARMA_BLD)/aer/libaer.a $(CARMA_BLD)/rad/librad.a)
# Check for directory in which to put executable
ifeq ($(MODEL_EXEDIR),$(null))
MODEL_EXEDIR := .
endif
# Check for name of executable
ifeq ($(EXENAME),$(null))
EXENAME := atm
endif
# Check if SPMD is defined in "misc.h"
# Ensure that it is defined and not just "undef SPMD" set in file
ifeq ($(SPMD),$(null))
SPMDSET := $(shell grep SPMD misc.h)
ifneq (,$(findstring define,$(SPMDSET)))
SPMD := TRUE
else
SPMD := FALSE
endif
endif
# Load dependency search path.
dirs := . $(shell cat Filepath)
# Set cpp search path, include netcdf
cpp_dirs := $(dirs) $(INC_NETCDF) $(INC_MPI) $(INC_CARMA)
cpp_path := $(foreach dir,$(cpp_dirs),-I$(dir)) # format for command line
# Expand any tildes in directory names. Change spaces to colons.
VPATH := $(foreach dir,$(cpp_dirs),$(wildcard $(dir)))
VPATH := $(subst $(space),:,$(VPATH))
#------------------------------------------------------------------------
# Primary target: build the model
#------------------------------------------------------------------------
all: $(MODEL_EXEDIR)/$(EXENAME)
# Get list of files and build dependency file for all .o files
# using perl scripts mkSrcfiles and mkDepends
SOURCES := $(shell cat Srcfiles)
# Newer makes set the CURDIR variable.
CURDIR := $(shell pwd)
$(CURDIR)/Depends: $(CURDIR)/Srcfiles $(CURDIR)/Filepath
$(ROOTDIR)/models/atm/cam/bld/mkDepends Filepath Srcfiles > $@
$(CURDIR)/Srcfiles: $(CURDIR)/Filepath
$(ROOTDIR)/models/atm/cam/bld/mkSrcfiles > $@
OBJS := $(addsuffix .o, $(basename $(SOURCES)))
CPPDEF := -DCAM -DNO_SHR_VMATH -DHIDE_SHR_MSG $(USER_CPPDEFS)
$(MODEL_EXEDIR)/$(EXENAME): $(OBJS) $(CARMA_BLD)/aer/libaer.a $(CARMA_BLD)/rad/librad.a
$(FC) -o $@ $(OBJS) -L$(LIB_NETCDF) -lnetcdff -lnetcdf -L$(ESMF_LIB)/$(ESMF_ARCH) -lesmf -L$(CARMA_BLD)/aer -laer -L$(CARMA_BLD)/rad -lrad $(LDFLAGS)
debug: $(OBJS)
echo "FFLAGS: $(FFLAGS)"
echo "LDFLAGS: $(LDFLAGS)"
echo "OBJS: $(OBJS)"
test_fc: test_fc.o
$(FC) -o $@ test_fc.o $(LDFLAGS)
test_nc: test_nc.o
$(FC) -o $@ test_nc.o -L$(LIB_NETCDF) -lnetcdff -lnetcdf $(LDFLAGS)
test_mpi: test_mpi.o
$(FC) -o $@ test_mpi.o $(LDFLAGS)
# Architecture-specific flags and rules
#
# Determine platform
ifeq ($(UNAMES),$(null))
UNAMES := $(shell uname -s)
endif
#------------------------------------------------------------------------
# AIX
#------------------------------------------------------------------------
ifeq ($(UNAMES),AIX)
ifeq ($(SMP),$(null))
SMP := TRUE
endif
#ADDRESS := Q32
ADDRESS := Q64
ifeq ($(ADDRESS),Q32)
QCMP :=
QLDR := -bmaxdata:0x80000000 -bmaxstack:0x10000000
ESMF_ARCH := rs6000_sp
endif
ifeq ($(ADDRESS),Q64)
QCMP := -q64
QLDR := -q64
ESMF_ARCH := rs6000_64
endif
CC := xlc_r
CPPDEF += -DAIX
ifeq ($(NESTED_OMP),TRUE)
CPPDEF += -DNESTED_PAR
endif
CFLAGS := $(cpp_path) -O2 $(CPPDEF) $(QCMP)
cpre = $(null)-WF,-D$(null)
FPPFLAGS := $(patsubst -D%,$(cpre)%,$(CPPDEF))
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
FFLAGS := $(cpp_path) $(mod_path) $(FPPFLAGS) -qarch=auto -qrealsize=8 -qdpc=e \
-qspillsize=2500 -g -qfullpath $(QCMP)
FREEFLAGS := -qsuffix=f=f90:cpp=F90
FIXEDFLAGS := -qfixed=132
#
# As of Apr/15/2003 cam2_0_2_dev18 xlfrte8.1.0.3 using -lmass causes the code to core-dump
# when using DEBUG compiler options.
#
# ... hence the following ugly expedient ...
ifeq ($(DEBUG),TRUE)
LDFLAGS := $(QLDR)
else
LDFLAGS := $(QLDR)
LDFLAGS += -lmass
endif
# Use the thread-safe compilers even when disabling openMP.
ifeq ($(SPMD),TRUE)
FC := mpxlf90_r
else
FC := xlf90_r
FFLAGS += -WF,-DHIDE_MPI
endif
ifeq ($(SMP),TRUE)
# THREADED_PTHREADS is used by the timing library
CFLAGS += -DTHREADED_PTHREADS
endif
ifeq ($(DEBUG),TRUE)
#
# Bounds checking is unreliable on the IBM.
# Sometimes you can get it to go if you turn threading off (by deleting -qsmp=omp)
# Only turn float-trapping on for debug mode as it's a 20% performance hit.
#
FFLAGS += -qinitauto=FF911299 -qflttrap=ov:zero:inv:en
ifeq ($(SMP),TRUE)
ifeq ($(NESTED_OMP),TRUE)
FFLAGS += -qsmp=omp:noopt:nested_par
LDFLAGS += -qsmp=omp:noopt:nested_par
else
FFLAGS += -qsmp=omp:noopt
LDFLAGS += -qsmp=omp:noopt
endif
endif
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
# Inline when not debugging
FORTRAN_OPTIMIZATION := -O3 -qstrict -Q
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
ifeq ($(SMP),TRUE)
ifeq ($(NESTED_OMP),TRUE)
FFLAGS += -qsmp=omp:nested_par
LDFLAGS += -qsmp=omp:nested_par
else
FFLAGS += -qsmp=omp
LDFLAGS += -qsmp=omp
endif
endif
endif
.SUFFIXES:
.SUFFIXES: .F .F90 .c .o
.F.o:
$(FC) -c $(FIXEDFLAGS) $(FFLAGS) $<
.F90.o:
$(FC) -c $(FREEFLAGS) $(FFLAGS) $<
.c.o:
cc -c $(CFLAGS) $<
endif
#------------------------------------------------------------------------
# DARWIN
#------------------------------------------------------------------------
ifeq ($(UNAMES),Darwin)
ifeq ($(SMP),$(null))
SMP := TRUE
endif
# Set the Fortran compilerq
ifeq ($(USER_FC),$(null))
FC := xlf90_r
else
FC := $(USER_FC)
endif
ifeq ($(USER_CC),$(null))
CC := gcc
else
CC := $(USER_FC)
endif
ifeq ($(findstring ifort,$(FC)),ifort)
ADDRESS := Q32
# ADDRESS := Q64
ifeq ($(ADDRESS),Q32)
QCMP :=
ESMF_ARCH := Darwin_intel
CARMA_MAKE := Makefile.darwin.intel
endif
ifeq ($(ADDRESS),Q64)
QCMP := -m64
QLDR := -m64
ESMF_ARCH := Darwin_intel_64
endif
CPPDEF += -DFORTRANUNDERSCORE -DLINUX -DDARWIN
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
# -mp is needed for NAN detection of physics buffer in the CARMA init code
FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) -132 -autodouble -ftz -mp
SPEC_FFLAGS := $(FFLAGS)
LDFLAGS :=
FREEFLAGS := -FR
ifeq ($(DEBUG),TRUE)
FFLAGS += -CB -O0 -g
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION := -O2
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
ifeq ($(SMP),TRUE)
FFLAGS += -openmp
LDFLAGS += -openmp
endif
ifeq ($(SPMD),TRUE)
LDFLAGS += -L$(LIB_MPI) -l$(MPI_LIB_NAME)f90 -lp$(MPI_LIB_NAME) -l$(MPI_LIB_NAME)
else
FFLAGS += -DHIDE_MPI
endif
endif
ifeq ($(findstring xlf,$(FC)),xlf)
CARMA_MAKE := Makefile.darwin.xlf
ESMF_ARCH := Darwin_xlf
ESMF_C_COMPILER := gcc
ADDRESS := Q32
CPPDEF += -DAIX -DDARWIN
FPPFLAGS := $(patsubst -D%,$(cpre)%,$(CPPDEF))
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
FFLAGS := $(cpp_path) $(mod_path) $(FPPFLAGS) -qarch=auto -qrealsize=8 -qdpc=e \
-qspillsize=2500 -g -qfullpath $(QCMP)
FREEFLAGS := -qsuffix=f=f90:cpp=F90
FIXEDFLAGS := -qfixed=132
# Use the thread-safe compilers even when disabling openMP.
ifeq ($(SPMD),TRUE)
FC := mpxlf90_r
else
FC := xlf90_r
FFLAGS += -WF,-DHIDE_MPI
endif
ifeq ($(DEBUG),TRUE)
#
# Bounds checking is unreliable on the IBM.
# Sometimes you can get it to go if you turn threading off (by deleting -qsmp=omp)
# Only turn float-trapping on for debug mode as it's a 20% performance hit.
#
FFLAGS += -qinitauto=FF911299 -qflttrap=ov:zero:inv:en
ifeq ($(SMP),TRUE)
ifeq ($(NESTED_OMP),TRUE)
FFLAGS += -qsmp=omp:noopt:nested_par
LDFLAGS += -qsmp=omp:noopt:nested_par
else
FFLAGS += -qsmp=omp:noopt
LDFLAGS += -qsmp=omp:noopt
endif
endif
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
# Inline when not debugging
FORTRAN_OPTIMIZATION := -O3 -qstrict -Q
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
ifeq ($(SMP),TRUE)
ifeq ($(NESTED_OMP),TRUE)
FFLAGS += -qsmp=omp:nested_par
LDFLAGS += -qsmp=omp:nested_par
else
FFLAGS += -qsmp=omp
LDFLAGS += -qsmp=omp
endif
endif
endif
endif
ifeq ($(NESTED_OMP),TRUE)
CPPDEF += -DNESTED_PAR
endif
CFLAGS := $(cpp_path) -O2 $(CPPDEF) $(QCMP)
cpre = $(null)-WF,-D$(null)
LDFLAGS += -lSystemStubs
ifeq ($(SMP),TRUE)
# THREADED_PTHREADS is used by the timing library
CFLAGS += -DTHREADED_PTHREADS
endif
.SUFFIXES:
.SUFFIXES: .F .F90 .c .o
.F.o:
$(FC) -c $(FIXEDFLAGS) $(FFLAGS) $<
.F90.o:
$(FC) -c $(FREEFLAGS) $(FFLAGS) $<
.c.o:
cc -c $(CFLAGS) $<
endif
#------------------------------------------------------------------------
# SGI
#------------------------------------------------------------------------
ifeq ($(UNAMES),IRIX64)
# default is either pure SPMD or pure SMP parallelism
ifeq ($(SMP),$(null))
ifeq ($(SPMD),TRUE)
SMP := FALSE
else
SMP := TRUE
endif
endif
ESMF_ARCH := IRIX64
FC := f90
CPP := /lib/cpp
CPPDEF += -DIRIX64
CFLAGS := $(cpp_path) -64 -O2 $(CPPDEF)
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
FFLAGS := $(cpp_path) $(mod_path) -64 -r8 -i4 -c -cpp -extend_source \
$(CPPDEF)
LDFLAGS = -64 -mp
ifeq ($(SMP),TRUE)
# THREADED_OMP is used by the timing library
CFLAGS += -DTHREADED_OMP
# Only enable OpenMP, not SGI specific parallelism
# Note that -lmp should precede -lmpi when running hybrid MPI/OpenMP
FFLAGS += -mp -MP:dsm=OFF -MP:old_mp=OFF
LDFLAGS += -mp -lmp
endif
ifeq ($(SPMD),TRUE)
FFLAGS += -I$(INC_MPI)
LDFLAGS += -L$(LIB_MPI) -lmpi
else
FFLAGS += -DHIDE_MPI
endif
# WARNING: -mp and -g together has been known to cause wrong answers
ifeq ($(DEBUG),TRUE)
FFLAGS += -g -DEBUG:trap_uninitialized=ON -C
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION := -O2
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
.SUFFIXES:
.SUFFIXES: .F .F90 .c .o
.F.o:
$(FC) $(FFLAGS) $<
.F90.o:
$(FC) $(FFLAGS) $<
.c.o:
cc -c $(cpp_path) $(CFLAGS) $<
endif
#------------------------------------------------------------------------
# SUN
#------------------------------------------------------------------------
ifeq ($(UNAMES),SunOS)
ESMF_ARCH = solaris
FC := f90
FC77 := f77
CPP := /usr/ccs/lib/cpp
CFLAGS := $(cpp_path) -DSUNOS $(CPPDEF)
mod_path:= -M$(ESMF_MOD)/$(ESMF_ARCH) -M$(MOD_NETCDF)
# Don't use OpenMP on Solaris as it currently causes problems
FFLAGS := $(cpp_path) $(mod_path) -xs -stackvar -Qoption f90comp -r8const \
-xtypemap=real:64,integer:32 -e -DSUNOS -DHIDE_MPI \
$(CPPDEF)
LDFLAGS := -L/opt/SUNWspro/lib -lf77compat -openmp -fast
SPEC_FFLAGS := $(cpp_path) -r8 -i4 -c
ifeq ($(DEBUG),TRUE)
FFLAGS += -g -dalign
SPEC_FFLAGS += -g -dalign
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
# Inline code when not debugging -inline
# Use symbol table (-g) as make execution stable and can find out where problems are.
# Turn off aggressive optimization options (fsimple=1, fns=no) so the climate
# will be similar to climate on the IBM
FORTRAN_OPTIMIZATION := -inline=%auto -fast -g -fsimple=1 -fns=no -O4
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
ifeq ($(SPMD),TRUE)
FFLAGS += -I$(INC_MPI)
LDFLAGS += -L$(LIB_MPI) -lmpich -lnsl -lsocket
else
FFLAGS += -DHIDE_MPI
endif
.SUFFIXES:
.SUFFIXES: .F .F90 .c .o
.F90.o:
$(FC) -c $(FFLAGS) $<
endif
#------------------------------------------------------------------------
# Linux
#------------------------------------------------------------------------
ifeq ($(UNAMES),Linux)
CPPDEF += -DLINUX
# Set the Fortran compiler (default: PGI pgf90)
ifeq ($(USER_FC),$(null))
FC := pgf90
else
FC := $(USER_FC)
endif
# Decide whether or not a PGI Fortran compiler is being used by looking
# for a match of the string 'pgf' in the compiler name.
PGI_FC := FALSE
ifeq ($(findstring pgf,$(FC)),pgf)
PGI_FC := TRUE
endif
# Set the C compiler (default: pgcc if using PGI Fortran compiler, cc otherwise)
# and cc if not
ifeq ($(USER_CC),$(null))
ifeq ($(PGI_FC),TRUE)
CC := pgcc
else
CC := cc
endif
else
CC := $(USER_CC)
endif
ifeq ($(SMP),TRUE)
# THREADED_OMP and THREADED_PTHREADS are used by the timing library
ifeq ($(CC),pgcc)
CPPDEF += -DTHREADED_OMP
else
CPPDEF += -DTHREADED_PTHREADS
endif
endif
CFLAGS = $(cpp_path) $(CPPDEF)
ifeq ($(CC),pgcc)
CFLAGS += -fast -gdwarf-2
endif
# pgf90
# -DPGF90 is for phcs and gauaw which normally use r16 arithmetic but is unavailable under pgf90
ifeq ($(PGI_FC),TRUE)
ifeq ($(CC),pgcc)
ESMF_ARCH = linux_pgi
else
ESMF_ARCH = linux_gnupgf90
endif
ifeq ($(SMP),$(null))
SMP := TRUE
endif
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
FFLAGS := $(cpp_path) $(mod_path) -r8 -i4 $(CPPDEF) -Mdalign -Mextend -DPGF90 -DNO_R16 -byteswapio
FREEFLAGS := -Mfree
LDFLAGS :=
ifeq ($(DEBUG),TRUE)
FFLAGS += -g -Ktrap=fp -Mrecursive -Mbounds
SPEC_FFLAGS := $(FFLAGS)
else
SPEC_FFLAGS := $(FFLAGS)
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION := -O1
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
ifeq ($(SMP),TRUE)
FFLAGS += -mp
LDFLAGS += -mp
endif
endif
# lf95
#
# Note that as of lf95 version 6.1 threading does NOT work because of
# ridiculously small per thread stacksize limits.
#
# -CcdRR8 is an undocumented flag which promotes only vars declared "real", not "real*4"
# --trace produces a call traceback on abort
# --trap causes code to stop on divide by zero or overflow exceptions
# --pca prevents overwriting constant arguments
# --chk for basic compiler checking (a,e,s,u,x)
ifeq ($(FC),lf95)
ESMF_ARCH := linux_lf95
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
FFLAGS := $(cpp_path) $(mod_path) -CcdRR8 $(CPPDEF) --trace --trap --wide
SPEC_FFLAGS := $(FFLAGS)
LDFLAGS :=
ifeq ($(DEBUG),TRUE)
#TBH: this works FFLAGS += -g --chk --pca
#TBH: this FAILS FFLAGS += -g --chk a,e,s,u,x --pca
FFLAGS += -g --chk a,e,s,u --pca
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION := -O
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
endif
#ifort
ifeq ($(findstring ifort,$(FC)),ifort)
ESMF_ARCH := linux_intel
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) -132 -autodouble -ftz -g -ip -no-prec-div
SPEC_FFLAGS := $(FFLAGS)
LDFLAGS :=
FREEFLAGS := -FR
ifeq ($(DEBUG),TRUE)
FFLAGS += -CB
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION := -O2
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
ifeq ($(SMP),TRUE)
FFLAGS += -openmp
LDFLAGS += -openmp
endif
CARMA_MAKE := Makefile.linux.intel
endif
# mpif90
ifeq ($(findstring mpif90,$(FC)),mpif90)
ESMF_ARCH := linux_mpif90
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) -g -traceback -autodouble -ftz -ip -no-prec-div
SPEC_FFLAGS := $(FFLAGS)
FIXEDFLAGS := -132
LDFLAGS :=
# MPILDFLAGS := -lmpi_f90 -lmpi_f77 -lopen-rte -lopen-pal -ldl -Wl,-rpath -lnsl -lutil
MPILDFLAGS := -lmpichf90 -lmpichf77 -lopen-rte -lopen-pal -ldl -Wl,-rpath -lnsl -lutil
FREEFLAGS := -FR
ifeq ($(DEBUG),TRUE)
FFLAGS += -fp-stack-check -check bounds -check pointers -check uninit -o0 -debug -ftrapuv
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION := -O2
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
ifeq ($(SMP),TRUE)
FFLAGS += -openmp
LDFLAGS += -openmp
endif
CARMA_MAKE := Makefile.linux.mpif90
endif
# pathf90
ifeq ($(FC),pathf90)
CC := pathcc
ESMF_ARCH := linux_pathscale
CARMA_MAKE := Makefile.linux.pathscale
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) -r8 -extend_source -fno-second-underscore -DNO_R16
FREEFLAGS :=
LDFLAGS :=
ifeq ($(DEBUG),TRUE)
FFLAGS += -g -O1 -C
SPEC_FFLAGS := $(FFLAGS)
else
SPEC_FFLAGS := $(FFLAGS)
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION := -O
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
ifeq ($(SMP),TRUE)
FFLAGS +=
LDFLAGS +=
endif
endif
ifeq ($(findstring ifort,$(FC)),ifort)
ESMF_ARCH := linux_intel
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) -132 -autodouble -ftz -g
SPEC_FFLAGS := $(FFLAGS)
LDFLAGS :=
FREEFLAGS := -FR
ifeq ($(DEBUG),TRUE)
FFLAGS += -CB
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION := -O2
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
ifeq ($(SMP),TRUE)
FFLAGS += -openmp
LDFLAGS += -openmp
endif
endif
# Flags common to all compilers
ifeq ($(SPMD),TRUE)
LDFLAGS += -L$(LIB_MPI) -l$(MPI_LIB_NAME) $(MPILDFLAGS)
else
FFLAGS += -DHIDE_MPI
endif
.SUFFIXES:
.SUFFIXES: .F .F90 .c .o
ifeq ($(FC),pgf90)
#
# To fix hanging problem when using sld dynamics, compile sgexx without "-fast"
#
sgexx.o: sgexx.F
$(FC) -c $(SPEC_FFLAGS) $<
endif
ifeq ($(FC),lf95)
# lahey fails on binary_io due to writing wrap areas
binary_io.o: binary_io.F90
$(FC) -c $(SPEC_FFLAGS) $<
wrap_nf.o: wrap_nf.F90
$(FC) -c $(SPEC_FFLAGS) $<
wrap_mpi.o: wrap_mpi.F90
$(FC) -c $(SPEC_FFLAGS) $<
endif
.F90.o:
$(FC) -c $(FREEFLAGS) $(FFLAGS) $<
.F.o:
$(FC) -c $(FFLAGS) $<
.c.o:
$(CC) -c $(CFLAGS) $<
endif
#------------------------------------------------------------------------
# OSF1
#------------------------------------------------------------------------
ifeq ($(UNAMES),OSF1)
ESMF_ARCH := alpha
CFLAGS := $(cpp_path) -DOSF1 -O2 -omp $(CPPDEF)
FC := f90
mod_path := -I$(ESMF_MOD)/$(ESMF_ARCH) -I$(MOD_NETCDF)
FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) -r8 -i4 -c -omp -automatic -fpe3 \
-check omp_bindings
FFLAGS_DOTF90 := -DOSF1 -free -fpe3
FFLAGS_DOTF := -extend_source -omp -automatic
LDFLAGS := -omp -lcxml
ifeq ($(SPMD),TRUE)
FFLAGS += -I$(INC_MPI)
LDFLAGS += -lmpi
else
FFLAGS += -DHIDE_MPI
endif
ifeq ($(SMP),TRUE)
# THREADED_OMP is used by the timing library
CFLAGS += -DTHREADED_OMP
endif
ifeq ($(DEBUG),TRUE)
FFLAGS += -g3 -C
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
# Inline when not debugging
FORTRAN_OPTIMIZATION := -O2 -inline speed
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
ifeq ($(NO_SWITCH),$(null))
NO_SWITCH := FALSE
endif
ifneq ($(NO_SWITCH),TRUE)
LDFLAGS += -lelan
endif
.SUFFIXES:
.SUFFIXES: .F .F90 .c .o
.F.o:
$(FC) $(FFLAGS) $(FFLAGS_DOTF) $<
.F90.o:
$(FC) $(FFLAGS) $(FFLAGS_DOTF90) $<
.c.o:
cc -c $(CFLAGS) $<
endif
#------------------------------------------------------------------------
# NEC SX-6
#------------------------------------------------------------------------
ifeq ($(UNAMES),SUPER-UX)
ESMF_ARCH = SX6
VER = inst
VER = rev285
FC := sxf90 -Yf,/SX/opt/sxf90/$(VER)/lib -V
CC := sxc++
AS := sxas
CPP := cpp -traditional
PROF := -ftrace
CPPDEF += -USX -DFORTRANUNDERSCORE -DNEC_SX -D_SX -DDISABLE_TIMERS
cpp_path += -I$(ESMF_MOD)/$(ESMF_ARCH)
CFLAGS := $(PROF)
FFLAGS := $(PROF) -Wf,"-A idbl4 -pvctl fullmsg loopcnt=1000000 noassume noloopchg" \
-Wf,"-L fmtlist map transform -ptr byte"
LDFLAGS := $(PROF) -Wl"-Z 5000M -ZL 5000M"
ifeq ($(DEBUG),TRUE)
FFLAGS += -g -Cvsafe
else
# Check for override of default Fortran compiler optimizations
ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null))
FORTRAN_OPTIMIZATION := -Cvopt
endif
FFLAGS += $(FORTRAN_OPTIMIZATION)
endif
ifeq ($(SMP),$(null))
SMP := TRUE
endif
ifeq ($(SPMD),TRUE)
cpp_path += -I$(INC_MPI)
LDFLAGS += -L$(LIB_MPI) -lmpi
else
CPPDEF += -DHIDE_MPI
endif
ifeq ($(SMP),TRUE)
CPPDEF += -DTHREADED_OMP
CFLAGS += -P openmp
FFLAGS += -P openmp
LDFLAGS += -lcpp -P openmp
endif
CPPFLAGS := $(CPPDEF) $(cpp_path)
FPPFLAGS := $(CPPFLAGS)
.SUFFIXES:
.SUFFIXES: .F .F90 .c .s .o
.F.o:
$(FC) -c $(FPPFLAGS) $(FFLAGS) $<
.F90.o:
$(FC) -c $(FPPFLAGS) $(FFLAGS) $<
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
.s.o:
$(AS) -m $<
ifeq ($(SPMD),TRUE)
#...jps....added for MPI Global Memory usage
phys_grid.o: phys_grid.F90
$(FC) -c $(FPPFLAGS) $(FFLAGS) -gmalloc $<
spmd_dyn.o: spmd_dyn.F90
$(FC) -c $(FPPFLAGS) $(FFLAGS) -gmalloc $<
endif
radae.o: radae.F90
$(FC) -c $(FPPFLAGS) $(FFLAGS) -pi rexp=phi,psi,fh2oself $<