@@ -12,8 +12,9 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
12
12
! could just be a function to return a string instead of passing model
13
13
! but likely to change other components like matching C compiler
14
14
15
- character (len= :),allocatable :: fflags
16
- character (len= :),allocatable :: module_path_switch
15
+ character (len= :),allocatable :: fflags ! optional flags that might be overridden by user
16
+ character (len= :),allocatable :: modpath
17
+ character (len= :),allocatable :: mandatory ! flags required for fpm to function properly
17
18
18
19
! special reserved names "debug" and "release" are for supported compilers with no user-specified compile or load flags
19
20
@@ -40,11 +41,13 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
40
41
! G95 ? ? -fmod= -I -fopenmp discontinued
41
42
! Open64 ? ? -module -I -mp discontinued
42
43
! Unisys ? ? ? ? ? discontinued
44
+ modpath= join_path(model% output_directory,model% package_name)
45
+ fflags= ' '
46
+ mandatory= ' '
43
47
44
48
select case (build_name// ' _' // compiler)
45
49
46
50
case (' release_caf' )
47
- module_path_switch= ' -J '
48
51
fflags= ' &
49
52
& -O3&
50
53
& -Wimplicit-interface&
@@ -53,8 +56,8 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
53
56
& -ffast-math&
54
57
& -funroll-loops&
55
58
&'
59
+ mandatory= ' -J ' // modpath// ' -I ' // modpath ! add module path as apprpriate
56
60
case (' debug_caf' )
57
- module_path_switch= ' -J '
58
61
fflags = ' &
59
62
& -Wall&
60
63
& -Wextra&
@@ -65,8 +68,8 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
65
68
& -fcheck-array-temporaries&
66
69
& -fbacktrace&
67
70
&'
71
+ mandatory= ' -J ' // modpath// ' -I ' // modpath ! add module path as apprpriate
68
72
case (' release_gfortran' )
69
- module_path_switch= ' -J '
70
73
fflags= ' &
71
74
& -O3&
72
75
& -Wimplicit-interface&
@@ -76,8 +79,8 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
76
79
& -funroll-loops&
77
80
& -fcoarray=single&
78
81
&'
82
+ mandatory= ' -J ' // modpath// ' -I ' // modpath ! add module path as apprpriate
79
83
case (' debug_gfortran' )
80
- module_path_switch= ' -J '
81
84
fflags = ' &
82
85
& -Wall&
83
86
& -Wextra&
@@ -89,9 +92,9 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
89
92
& -fbacktrace&
90
93
& -fcoarray=single&
91
94
&'
95
+ mandatory= ' -J ' // modpath// ' -I ' // modpath ! add module path as apprpriate
92
96
93
97
case (' release_f95' )
94
- module_path_switch= ' -J '
95
98
fflags= ' &
96
99
& -O3&
97
100
& -Wimplicit-interface&
@@ -100,8 +103,8 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
100
103
& -ffast-math&
101
104
& -funroll-loops&
102
105
&'
106
+ mandatory= ' -J ' // modpath// ' -I ' // modpath ! add module path as apprpriate
103
107
case (' debug_f95' )
104
- module_path_switch= ' -J '
105
108
fflags = ' &
106
109
& -Wall&
107
110
& -Wextra&
@@ -113,14 +116,14 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
113
116
& -Wno-maybe-uninitialized -Wno-uninitialized&
114
117
& -fbacktrace&
115
118
&'
119
+ mandatory= ' -J ' // modpath// ' -I ' // modpath ! add module path as apprpriate
116
120
117
121
case (' release_nvfortran' )
118
- module_path_switch= ' -module '
119
122
fflags = ' &
120
123
& -Mbackslash&
121
124
&'
125
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
122
126
case (' debug_nvfortran' )
123
- module_path_switch= ' -module '
124
127
fflags = ' &
125
128
& -Minform=inform&
126
129
& -Mbackslash&
@@ -130,9 +133,9 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
130
133
& -Mchkstk&
131
134
& -traceback&
132
135
&'
136
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
133
137
134
138
case (' release_ifort' )
135
- module_path_switch= ' -module '
136
139
fflags = ' &
137
140
& -fp-model precise&
138
141
& -pc 64&
@@ -144,8 +147,8 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
144
147
& -assume byterecl&
145
148
& -assume nounderscore&
146
149
&'
150
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
147
151
case (' debug_ifort' )
148
- module_path_switch= ' -module '
149
152
fflags = ' &
150
153
& -warn all&
151
154
& -check:all:noarg_temp_created&
@@ -156,43 +159,43 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
156
159
& -assume byterecl&
157
160
& -traceback&
158
161
&'
162
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
159
163
case (' release_ifx' )
160
- module_path_switch= ' -module '
161
164
fflags = ' '
165
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
162
166
case (' debug_ifx' )
163
- module_path_switch= ' -module '
164
167
fflags = ' '
168
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
165
169
166
170
case (' release_pgfortran' ,' release_pgf90' ,' release_pgf95' ) ! Portland Group F90/F95 compilers
167
- module_path_switch= ' -module '
168
171
fflags = ' '
172
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
169
173
case (' debug_pgfortran' ,' debug_pgf90' ,' debug_pgf95' ) ! Portland Group F90/F95 compilers
170
- module_path_switch= ' -module '
171
174
fflags = ' '
175
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
172
176
173
177
case (' release_flang' )
174
- module_path_switch= ' -module '
175
178
fflags = ' '
179
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
176
180
case (' debug_flang' )
177
- module_path_switch= ' -module '
178
181
fflags = ' '
182
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
179
183
180
184
case (' release_lfc' )
181
- module_path_switch= ' -M '
182
185
fflags = ' '
186
+ mandatory= ' -M ' // modpath// ' -I ' // modpath ! add module path as apprpriate
183
187
case (' debug_lfc' )
184
- module_path_switch= ' -M '
185
188
fflags = ' '
189
+ mandatory= ' -M ' // modpath// ' -I ' // modpath ! add module path as apprpriate
186
190
187
191
case (' release_nagfor' )
188
- module_path_switch= ' -mdir '
189
192
fflags = ' &
190
193
& -O4&
191
194
& -coarray=single&
192
195
& -PIC&
193
196
'
197
+ mandatory= ' -mdir ' // modpath// ' -I ' // modpath ! ! add module path as apprpriate
194
198
case (' debug_nagfor' )
195
- module_path_switch= ' -mdir '
196
199
fflags = ' &
197
200
& -g&
198
201
& -C=all&
@@ -201,34 +204,32 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
201
204
& -coarray=single&
202
205
& -PIC&
203
206
'
207
+ mandatory= ' -mdir ' // modpath// ' -I ' // modpath ! ! add module path as apprpriate
204
208
case (' release_crayftn' )
205
- module_path_switch= ' -J '
206
209
fflags = ' '
210
+ mandatory= ' -J ' // modpath// ' -I ' // modpath ! add module path as apprpriate
207
211
case (' debug_crayftn' )
208
- module_path_switch= ' -J '
209
212
fflags = ' '
213
+ mandatory= ' -J ' // modpath// ' -I ' // modpath ! add module path as apprpriate
210
214
211
215
case (' release_xlf90' )
212
- module_path_switch= ' -qmoddir '
213
216
fflags = ' '
217
+ mandatory= ' -qmoddir ' // modpath// ' -I ' // modpath ! add module path as apprpriate
214
218
case (' debug_xlf90' )
215
- module_path_switch= ' -qmoddir '
216
219
fflags = ' '
220
+ mandatory= ' -qmoddir ' // modpath// ' -I ' // modpath ! add module path as apprpriate
217
221
218
222
case default
219
- module_path_switch= ' -module '
220
223
fflags = ' '
224
+ mandatory= ' -module ' // modpath// ' -I ' // modpath ! add module path as apprpriate
221
225
write (* ,* )' <WARNING> unknown compiler (' ,compiler,' )'
222
- write (* ,* )' and build name (' ,build_name,' )'
226
+ write (* ,* )' and build name (' ,build_name,' )'
223
227
write (* ,* )' combination.'
224
228
write (* ,* )' known compilers are gfortran, nvfortran, ifort'
225
229
end select
226
230
227
- ! NOTE THAT MODULE_PATH_SWITCH IS ASSUMED TO CONTAIN REQUIRED TRAILING SPACE IF NEEDED
228
- ! so that values that do not require a space such as -moddir= will work
229
- model% fortran_compile_flags = fflags// ' ' // &
230
- & module_path_switch// join_path(model% output_directory,model% package_name)
231
-
231
+ model% fortran_compile_flags = fflags// ' ' // mandatory
232
+
232
233
end subroutine add_compile_flag_defaults
233
234
234
235
end module fpm_compiler
0 commit comments