Skip to content

Commit 278d7f3

Browse files
authored
Fix user_defined physical constants not updated outside of masterproc (#295)
`user_defined` physical constants in `physconst.F90` are not saved outside of `masterproc` since the in-module variable assignments were made inside a `if(masterproc)`
2 parents 4663589 + 672a56a commit 278d7f3

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/data/physconst.F90

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,59 +207,63 @@ subroutine physconst_readnl(nlfile)
207207

208208
if (newg .or. newsday .or. newmwh2o .or. newcpwv .or. newmwdry .or. &
209209
newrearth .or. newtmelt .or. newomega) then
210+
211+
! Populate the new constants into module after mpi_bcast
212+
if(newg) gravit = user_defined_gravit
213+
if(newsday) sday = user_defined_sday
214+
if(newmwh2o) mwh2o = user_defined_mwh2o
215+
if(newcpwv) cpwv = user_defined_cpwv
216+
if(newmwdry) mwdry = user_defined_mwdry
217+
if(newcpair) cpair = user_defined_cpair
218+
if(newrearth) rearth = user_defined_rearth
219+
if(newtmelt) tmelt = user_defined_tmelt
220+
if(newomega) omega = user_defined_omega
221+
210222
if (masterproc) then
211223
write(iulog, *) banner
212224
write(iulog, *) '*** New Physical Constant Values set ', &
213225
'via namelist ***'
214226
write(iulog, *) bline
215227
write(iulog, *) '*** Physical Constant Old Value New Value ***'
216228
if (newg) then
217-
gravit = user_defined_gravit
218229
field = 'GRAVIT'
219230
write(iulog, 2000) field, shr_const_g, gravit
220231
end if
221232
if (newsday) then
222-
sday = user_defined_sday
223233
field = 'SDAY'
224234
write(iulog, 2000) field, shr_const_sday, sday
225235
end if
226236
if (newmwh2o) then
227-
mwh2o = user_defined_mwh2o
228237
field = 'MWH20'
229238
write(iulog, 2000) field, shr_const_mwwv, mwh2o
230239
end if
231240
if (newcpwv) then
232-
cpwv = user_defined_cpwv
233241
field = 'CPWV'
234242
write(iulog, 2000) field, shr_const_cpwv, cpwv
235243
end if
236244
if (newmwdry) then
237-
mwdry = user_defined_mwdry
238245
field = 'MWDRY'
239246
write(iulog, 2000) field, shr_const_mwdair, mwdry
240247
end if
241248
if (newcpair) then
242-
cpair = user_defined_cpair
243249
field = 'CPAIR'
244250
write(iulog, 2000) field, shr_const_cpdair, cpair
245251
end if
246252
if (newrearth) then
247-
rearth = user_defined_rearth
248253
field = 'REARTH'
249254
write(iulog, 2000) field, shr_const_rearth, rearth
250255
end if
251256
if (newtmelt) then
252-
tmelt = user_defined_tmelt
253257
field = 'TMELT'
254258
write(iulog, 2000) field, shr_const_tkfrz, tmelt
255259
end if
256260
if (newomega) then
257-
omega = user_defined_omega
258261
field = 'OMEGA'
259262
write(iulog, 2000) field, shr_const_omega, omega
260263
end if
261264
write(iulog,*) banner
262265
end if
266+
263267
rga = 1._kind_phys / gravit
264268
rearth_recip = 1._kind_phys / rearth
265269
if (.not. newomega) then

0 commit comments

Comments
 (0)