Skip to content

Commit ad9aee9

Browse files
committed
change way module directory is specified per concepts from @awvwgk to make nagfor work
1 parent cbdb4be commit ad9aee9

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

fpm/src/fpm_compiler.f90

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
1212
! could just be a function to return a string instead of passing model
1313
! but likely to change other components like matching C compiler
1414

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
1718

1819
! special reserved names "debug" and "release" are for supported compilers with no user-specified compile or load flags
1920

@@ -40,11 +41,13 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
4041
! G95 ? ? -fmod= -I -fopenmp discontinued
4142
! Open64 ? ? -module -I -mp discontinued
4243
! Unisys ? ? ? ? ? discontinued
44+
modpath=join_path(model%output_directory,model%package_name)
45+
fflags=''
46+
mandatory=''
4347

4448
select case(build_name//'_'//compiler)
4549

4650
case('release_caf')
47-
module_path_switch='-J '
4851
fflags='&
4952
& -O3&
5053
& -Wimplicit-interface&
@@ -53,8 +56,8 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
5356
& -ffast-math&
5457
& -funroll-loops&
5558
&'
59+
mandatory=' -J '//modpath//' -I '//modpath ! add module path as apprpriate
5660
case('debug_caf')
57-
module_path_switch='-J '
5861
fflags = '&
5962
& -Wall&
6063
& -Wextra&
@@ -65,8 +68,8 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
6568
& -fcheck-array-temporaries&
6669
& -fbacktrace&
6770
&'
71+
mandatory=' -J '//modpath//' -I '//modpath ! add module path as apprpriate
6872
case('release_gfortran')
69-
module_path_switch='-J '
7073
fflags='&
7174
& -O3&
7275
& -Wimplicit-interface&
@@ -76,8 +79,8 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
7679
& -funroll-loops&
7780
& -fcoarray=single&
7881
&'
82+
mandatory=' -J '//modpath//' -I '//modpath ! add module path as apprpriate
7983
case('debug_gfortran')
80-
module_path_switch='-J '
8184
fflags = '&
8285
& -Wall&
8386
& -Wextra&
@@ -89,9 +92,9 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
8992
& -fbacktrace&
9093
& -fcoarray=single&
9194
&'
95+
mandatory=' -J '//modpath//' -I '//modpath ! add module path as apprpriate
9296

9397
case('release_f95')
94-
module_path_switch='-J '
9598
fflags='&
9699
& -O3&
97100
& -Wimplicit-interface&
@@ -100,8 +103,8 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
100103
& -ffast-math&
101104
& -funroll-loops&
102105
&'
106+
mandatory=' -J '//modpath//' -I '//modpath ! add module path as apprpriate
103107
case('debug_f95')
104-
module_path_switch='-J '
105108
fflags = '&
106109
& -Wall&
107110
& -Wextra&
@@ -113,14 +116,14 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
113116
& -Wno-maybe-uninitialized -Wno-uninitialized&
114117
& -fbacktrace&
115118
&'
119+
mandatory=' -J '//modpath//' -I '//modpath ! add module path as apprpriate
116120

117121
case('release_nvfortran')
118-
module_path_switch='-module '
119122
fflags = '&
120123
& -Mbackslash&
121124
&'
125+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
122126
case('debug_nvfortran')
123-
module_path_switch='-module '
124127
fflags = '&
125128
& -Minform=inform&
126129
& -Mbackslash&
@@ -130,9 +133,9 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
130133
& -Mchkstk&
131134
& -traceback&
132135
&'
136+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
133137

134138
case('release_ifort')
135-
module_path_switch='-module '
136139
fflags = '&
137140
& -fp-model precise&
138141
& -pc 64&
@@ -144,8 +147,8 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
144147
& -assume byterecl&
145148
& -assume nounderscore&
146149
&'
150+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
147151
case('debug_ifort')
148-
module_path_switch='-module '
149152
fflags = '&
150153
& -warn all&
151154
& -check:all:noarg_temp_created&
@@ -156,43 +159,43 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
156159
& -assume byterecl&
157160
& -traceback&
158161
&'
162+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
159163
case('release_ifx')
160-
module_path_switch='-module '
161164
fflags = ' '
165+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
162166
case('debug_ifx')
163-
module_path_switch='-module '
164167
fflags = ' '
168+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
165169

166170
case('release_pgfortran','release_pgf90','release_pgf95') ! Portland Group F90/F95 compilers
167-
module_path_switch='-module '
168171
fflags = ' '
172+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
169173
case('debug_pgfortran','debug_pgf90','debug_pgf95') ! Portland Group F90/F95 compilers
170-
module_path_switch='-module '
171174
fflags = ' '
175+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
172176

173177
case('release_flang')
174-
module_path_switch='-module '
175178
fflags = ' '
179+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
176180
case('debug_flang')
177-
module_path_switch='-module '
178181
fflags = ' '
182+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
179183

180184
case('release_lfc')
181-
module_path_switch='-M '
182185
fflags = ' '
186+
mandatory=' -M '//modpath//' -I '//modpath ! add module path as apprpriate
183187
case('debug_lfc')
184-
module_path_switch='-M '
185188
fflags = ' '
189+
mandatory=' -M '//modpath//' -I '//modpath ! add module path as apprpriate
186190

187191
case('release_nagfor')
188-
module_path_switch='-mdir '
189192
fflags = ' &
190193
& -O4&
191194
& -coarray=single&
192195
& -PIC&
193196
'
197+
mandatory=' -mdir '//modpath//' -I '//modpath !! add module path as apprpriate
194198
case('debug_nagfor')
195-
module_path_switch='-mdir '
196199
fflags = '&
197200
& -g&
198201
& -C=all&
@@ -201,34 +204,32 @@ subroutine add_compile_flag_defaults(build_name,compiler,model)
201204
& -coarray=single&
202205
& -PIC&
203206
'
207+
mandatory=' -mdir '//modpath//' -I '//modpath !! add module path as apprpriate
204208
case('release_crayftn')
205-
module_path_switch='-J '
206209
fflags = ' '
210+
mandatory=' -J '//modpath//' -I '//modpath ! add module path as apprpriate
207211
case('debug_crayftn')
208-
module_path_switch='-J '
209212
fflags = ' '
213+
mandatory=' -J '//modpath//' -I '//modpath ! add module path as apprpriate
210214

211215
case('release_xlf90')
212-
module_path_switch='-qmoddir '
213216
fflags = ' '
217+
mandatory=' -qmoddir '//modpath//' -I '//modpath ! add module path as apprpriate
214218
case('debug_xlf90')
215-
module_path_switch='-qmoddir '
216219
fflags = ' '
220+
mandatory=' -qmoddir '//modpath//' -I '//modpath ! add module path as apprpriate
217221

218222
case default
219-
module_path_switch='-module '
220223
fflags = ' '
224+
mandatory=' -module '//modpath//' -I '//modpath ! add module path as apprpriate
221225
write(*,*)'<WARNING> unknown compiler (',compiler,')'
222-
write(*,*)' and build name (',build_name,')'
226+
write(*,*)' and build name (',build_name,')'
223227
write(*,*)' combination.'
224228
write(*,*)' known compilers are gfortran, nvfortran, ifort'
225229
end select
226230

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+
232233
end subroutine add_compile_flag_defaults
233234

234235
end module fpm_compiler

0 commit comments

Comments
 (0)