Skip to content

Commit 0efcf7f

Browse files
authored
Merge pull request #196 from climbfuji/dynamics-real4-laurie-dom-20181226
Dynamics 32BIT compile, with CCPP (Laurie's changes with updates from Dom) for gmtb/develop
2 parents 985a8ac + f6f6aa8 commit 0efcf7f

File tree

5 files changed

+56
-26
lines changed

5 files changed

+56
-26
lines changed

CMakeLists.txt

+24-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
7373
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
7474

7575
# Set the possible values of build type for cmake-gui
76-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "Coverage")
76+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Bitforbit" "Release" "Coverage")
7777
endif()
7878

7979
#------------------------------------------------------------------------------
@@ -109,6 +109,14 @@ if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
109109
SET_SOURCE_FILES_PROPERTIES(./physics/mersenne_twister.f PROPERTIES COMPILE_FLAGS "-fdefault-real-8 -fno-range-check")
110110
SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-ffree-line-length-none -fdefault-real-8 -ffree-form")
111111
SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F ./physics/surface_perturbation.F90 PROPERTIES COMPILE_FLAGS "-fdefault-real-8 -fdefault-double-8")
112+
if (PROJECT STREQUAL "CCPP-FV3")
113+
if (DYN32)
114+
set(CMAKE_Fortran_FLAGS_OPT32BIT ${CMAKE_Fortran_FLAGS})
115+
string(REPLACE "-fdefault-real-8" "" CMAKE_Fortran_FLAGS_OPT32BIT "${CMAKE_Fortran_FLAGS_OPT32BIT}")
116+
SET_SOURCE_FILES_PROPERTIES(./physics/gfdl_fv_sat_adj.F90
117+
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_OPT32BIT}")
118+
endif (DYN32)
119+
endif (PROJECT STREQUAL "CCPP-FV3")
112120
elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
113121
# Adjust settings for bit-for-bit reproducibility of NEMSfv3gfs
114122
if (PROJECT STREQUAL "CCPP-FV3")
@@ -160,6 +168,13 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
160168
./physics/micro_mg3_0.F90
161169
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS} -fimf-arch-consistency=true")
162170
endif (${CMAKE_BUILD_TYPE} MATCHES "Debug")
171+
if (DYN32)
172+
set(CMAKE_Fortran_FLAGS_OPT32BIT ${CMAKE_Fortran_FLAGS})
173+
string(REPLACE "-real-size 64" "-real-size 32" CMAKE_Fortran_FLAGS_OPT32BIT "${CMAKE_Fortran_FLAGS_OPT32BIT}")
174+
string(REPLACE "-r8" "-r4" CMAKE_Fortran_FLAGS_OPT32BIT "${CMAKE_Fortran_FLAGS_OPT32BIT}")
175+
SET_SOURCE_FILES_PROPERTIES(./physics/gfdl_fv_sat_adj.F90
176+
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_OPT32BIT}")
177+
endif (DYN32)
163178
else (PROJECT STREQUAL "CCPP-FV3")
164179
SET_SOURCE_FILES_PROPERTIES(./physics/module_bfmicrophysics.f ./physics/rascnvv2.f ./physics/sflx.f ./physics/sfc_diff.f ./physics/sfc_diag.f PROPERTIES COMPILE_FLAGS -r8)
165180
SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_model.f90 ./physics/calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-r8 -free")
@@ -173,6 +188,14 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "PGI")
173188
SET_SOURCE_FILES_PROPERTIES(./physics/mersenne_twister.f PROPERTIES COMPILE_FLAGS "-r8 -Mnofptrap")
174189
SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-r8 -Mfree")
175190
SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F ./physics/surface_perturbation.F90 PROPERTIES COMPILE_FLAGS "-r8")
191+
if (PROJECT STREQUAL "CCPP-FV3")
192+
if (DYN32)
193+
set(CMAKE_Fortran_FLAGS_OPT32BIT ${CMAKE_Fortran_FLAGS})
194+
string(REPLACE "-r8" "-r4" CMAKE_Fortran_FLAGS_OPT32BIT "${CMAKE_Fortran_FLAGS_OPT32BIT}")
195+
SET_SOURCE_FILES_PROPERTIES(./physics/gfdl_fv_sat_adj.F90
196+
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_OPT32BIT}")
197+
endif (DYN32)
198+
endif (PROJECT STREQUAL "CCPP-FV3")
176199
else (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
177200
message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
178201
message ("Fortran compiler: " ${CMAKE_Fortran_COMPILER_ID})

physics/gcm_shoc.F90

+8-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ end subroutine shoc_init
1919
subroutine shoc_finalize ()
2020
end subroutine shoc_finalize
2121

22+
#if 0
2223
!> \section arg_table_shoc_run Argument Table
2324
!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional |
2425
!! |----------------------------|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|---------------|------|------------|-----------|--------|----------|
@@ -81,14 +82,15 @@ end subroutine shoc_finalize
8182
!! | errmsg | ccpp_error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F |
8283
!! | errflg | ccpp_error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F |
8384
!!
84-
subroutine shoc_run (ix, nx, nzm, do_shoc, shocaftcnv, mg3_as_mg2, imp_physics, imp_physics_gfdl, imp_physics_zhao_carr, &
85-
imp_physics_zhao_carr_pdf, imp_physics_mg, fprcp, tcr, tcrf, con_cp, con_g, con_hvap, con_hfus, con_rv, con_rd, con_pi, &
86-
con_fvirt, gq0_cloud_ice, gq0_rain, gq0_snow, gq0_graupel, dtp, me, prsl, phii, phil, u, v, omega, rhc, supice, pcrit, &
87-
cefac, cesfac, tkef1, dis_opt, hflx, evap, prnum, &
88-
skip_macro, clw_ice, clw_liquid, gq0_cloud_liquid, ncpl, ncpi, gt0, gq0_water_vapor, cld_sgs, tke, tkh, wthv_sec, &
85+
#endif
86+
subroutine shoc_run (ix, nx, nzm, do_shoc, shocaftcnv, mg3_as_mg2, imp_physics, imp_physics_gfdl, imp_physics_zhao_carr, &
87+
imp_physics_zhao_carr_pdf, imp_physics_mg, fprcp, tcr, tcrf, con_cp, con_g, con_hvap, con_hfus, con_rv, con_rd, con_pi, &
88+
con_fvirt, gq0_cloud_ice, gq0_rain, gq0_snow, gq0_graupel, dtp, me, prsl, phii, phil, u, v, omega, rhc, supice, pcrit, &
89+
cefac, cesfac, tkef1, dis_opt, hflx, evap, prnum, &
90+
skip_macro, clw_ice, clw_liquid, gq0_cloud_liquid, ncpl, ncpi, gt0, gq0_water_vapor, cld_sgs, tke, tkh, wthv_sec, &
8991
errmsg, errflg)
9092

91-
implicit none
93+
implicit none
9294

9395
integer, intent(in) :: ix, nx, nzm, imp_physics, imp_physics_gfdl, imp_physics_zhao_carr, imp_physics_zhao_carr_pdf, &
9496
imp_physics_mg, fprcp, me

physics/gfdl_fv_sat_adj.F90

+17-18
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ module fv_sat_adj
6363
! *DH
6464
!use fv_mp_mod, only: is_master
6565
!use fv_arrays_mod, only: r_grid
66-
use machine, only: kind_grid
67-
use CCPP_typedefs, only: kind_dyn
66+
use machine, only: kind_grid, kind_dyn
6867
use gfdl_cloud_microphys_mod, only: ql_gen, qi_gen, qi0_max, ql_mlt, ql0_max, qi_lim, qs_mlt
6968
use gfdl_cloud_microphys_mod, only: icloud_f, sat_adj0, t_sub, cld_min
7069
use gfdl_cloud_microphys_mod, only: tau_r2g, tau_smlt, tau_i2s, tau_v2l, tau_l2v, tau_imlt, tau_l2r
@@ -98,7 +97,7 @@ module fv_sat_adj
9897
real(kind=kind_dyn), parameter :: lv0 = hlv - dc_vap * tice !< 3.13905782e6, evaporation latent heat coefficient at 0 deg k
9998
real(kind=kind_dyn), parameter :: li00 = hlf - dc_ice * tice !< - 2.7105966e5, fusion latent heat coefficient at 0 deg k
10099
! real (kind_grid), parameter :: e00 = 610.71 ! gfdl: saturation vapor pressure at 0 deg c
101-
real (kind_grid), parameter :: e00 = 611.21 !< ifs: saturation vapor pressure at 0 deg c
100+
real (kind_grid), parameter :: e00 = 611.21 !< ifs: saturation vapor pressure at 0 deg c
102101
real (kind_grid), parameter :: d2ice = dc_vap + dc_ice !< - 126, isobaric heating / cooling
103102
real (kind_grid), parameter :: li2 = lv0 + li00 !< 2.86799816e6, sublimation latent heat coefficient at 0 deg k
104103
real(kind=kind_dyn), parameter :: lat2 = (hlv + hlf) ** 2 !< used in bigg mechanism
@@ -304,14 +303,14 @@ subroutine fv_sat_adj_run(mdt, zvir, is, ie, isd, ied, kmp, km, kmdelz, js, je,
304303
! as it would break a whole lot of code (including the one below)!
305304
! Assume thus that isd_2d = isd etc.
306305
real(kind_grid), intent(in) :: area(isd:ied, jsd:jed)
307-
real(kind=kind_dyn), intent(inout) :: dtdt(is:ie, js:je, 1:km)
308-
logical, intent(in) :: out_dt
309-
logical, intent(in) :: last_step
310-
logical, intent(in) :: do_qa
311-
real(kind=kind_dyn), intent( out) :: qa(isd:ied, jsd:jed, 1:km)
312-
integer, intent(in) :: nthreads
313-
character(len=*), intent( out) :: errmsg
314-
integer, intent( out) :: errflg
306+
real(kind=kind_dyn), intent(inout) :: dtdt(is:ie, js:je, 1:km)
307+
logical, intent(in) :: out_dt
308+
logical, intent(in) :: last_step
309+
logical, intent(in) :: do_qa
310+
real(kind=kind_dyn), intent( out) :: qa(isd:ied, jsd:jed, 1:km)
311+
integer, intent(in) :: nthreads
312+
character(len=*), intent( out) :: errmsg
313+
integer, intent( out) :: errflg
315314

316315
! Local variables
317316
real(kind=kind_dyn), dimension(is:ie,js:je) :: dpln
@@ -589,7 +588,7 @@ subroutine fv_sat_adj_work(mdt, zvir, is, ie, js, je, ng, hydrostatic, consv_te,
589588
lhi (i) = li00 + dc_ice * pt1 (i)
590589
lcp2 (i) = lhl (i) / cvm (i)
591590
icp2 (i) = lhi (i) / cvm (i)
592-
tcp3 (i) = lcp2 (i) + icp2 (i) * min (1., dim (tice, pt1 (i)) / 48.)
591+
tcp3 (i) = lcp2 (i) + icp2 (i) * min (1., dim (tice, pt1 (i)) /48.)
593592
enddo
594593
! -----------------------------------------------------------------------
595594
!> - Condensation/evaporation between water vapor and cloud water.
@@ -980,7 +979,7 @@ subroutine fv_sat_adj_work(mdt, zvir, is, ie, js, je, ng, hydrostatic, consv_te,
980979
enddo
981980
endif
982981
enddo ! end j loop
983-
982+
984983
end subroutine fv_sat_adj_work
985984
!! @}
986985

@@ -1156,7 +1155,7 @@ subroutine qs_table (n)
11561155
! compute es over ice between - 160 deg c and 0 deg c.
11571156
! -----------------------------------------------------------------------
11581157
do i = 1, 1600
1159-
tem = tmin + delt * real (i - 1, kind=kind_dyn)
1158+
tem = tmin + delt * real (i - 1)
11601159
fac0 = (tem - tice) / (tem * tice)
11611160
fac1 = fac0 * li2
11621161
fac2 = (d2ice * log (tem / tice) + fac1) / rvgas
@@ -1166,7 +1165,7 @@ subroutine qs_table (n)
11661165
! compute es over water between - 20 deg c and 102 deg c.
11671166
! -----------------------------------------------------------------------
11681167
do i = 1, 1221
1169-
tem = 253.16 + delt * real (i - 1, kind=kind_dyn)
1168+
tem = 253.16 + delt * real (i - 1)
11701169
fac0 = (tem - tice) / (tem * tice)
11711170
fac1 = fac0 * lv0
11721171
fac2 = (dc_vap * log (tem / tice) + fac1) / rvgas
@@ -1181,7 +1180,7 @@ subroutine qs_table (n)
11811180
! derive blended es over ice and supercooled water between - 20 deg c and 0 deg c
11821181
! -----------------------------------------------------------------------
11831182
do i = 1, 200
1184-
tem = 253.16 + delt * real (i - 1, kind=kind_dyn)
1183+
tem = 253.16 + delt * real (i - 1)
11851184
wice = 0.05 * (tice - tem)
11861185
wh2o = 0.05 * (tem - 253.16)
11871186
table (i + 1400) = wice * table (i + 1400) + wh2o * esupc (i)
@@ -1202,7 +1201,7 @@ subroutine qs_tablew (n)
12021201
! compute es over water
12031202
! -----------------------------------------------------------------------
12041203
do i = 1, n
1205-
tem = tmin + delt * real (i - 1, kind=kind_dyn)
1204+
tem = tmin + delt * real (i - 1)
12061205
fac0 = (tem - tice) / (tem * tice)
12071206
fac1 = fac0 * lv0
12081207
fac2 = (dc_vap * log (tem / tice) + fac1) / rvgas
@@ -1221,7 +1220,7 @@ subroutine qs_table2 (n)
12211220
integer :: i, i0, i1
12221221
tmin = tice - 160.
12231222
do i = 1, n
1224-
tem0 = tmin + delt * real (i - 1, kind=kind_dyn)
1223+
tem0 = tmin + delt * real (i - 1)
12251224
fac0 = (tem0 - tice) / (tem0 * tice)
12261225
if (i <= 1600) then
12271226
! -----------------------------------------------------------------------

physics/machine.F

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ MODULE MACHINE
3232

3333
#endif
3434

35+
#ifdef OVERLOAD_R4
36+
integer, parameter :: kind_dyn = 4
37+
#else
38+
integer, parameter :: kind_dyn = 8
39+
#endif
40+
3541
!
3642
real(kind=kind_evod), parameter :: mprec = 1.e-12 ! machine precision to restrict dep
3743
real(kind=kind_evod), parameter :: grib_undef = 9.99e20 ! grib undefine value

physics/physcons.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
module physcons
3838
!
3939
use machine, only : kind_phys
40-
use CCPP_typedefs, only : kind_dyn
40+
use machine, only : kind_dyn
4141
!
4242
implicit none
4343
!

0 commit comments

Comments
 (0)