Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamics 32BIT compile, with CCPP (Laurie's changes with updates from Dom) for gmtb/develop #196

Merged
Merged
25 changes: 24 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)

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

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -109,6 +109,14 @@ if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
SET_SOURCE_FILES_PROPERTIES(./physics/mersenne_twister.f PROPERTIES COMPILE_FLAGS "-fdefault-real-8 -fno-range-check")
SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-ffree-line-length-none -fdefault-real-8 -ffree-form")
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")
if (PROJECT STREQUAL "CCPP-FV3")
if (DYN32)
set(CMAKE_Fortran_FLAGS_OPT32BIT ${CMAKE_Fortran_FLAGS})
string(REPLACE "-fdefault-real-8" "" CMAKE_Fortran_FLAGS_OPT32BIT "${CMAKE_Fortran_FLAGS_OPT32BIT}")
SET_SOURCE_FILES_PROPERTIES(./physics/gfdl_fv_sat_adj.F90
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_OPT32BIT}")
endif (DYN32)
endif (PROJECT STREQUAL "CCPP-FV3")
elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
# Adjust settings for bit-for-bit reproducibility of NEMSfv3gfs
if (PROJECT STREQUAL "CCPP-FV3")
Expand Down Expand Up @@ -160,6 +168,13 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
./physics/micro_mg3_0.F90
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS} -fimf-arch-consistency=true")
endif (${CMAKE_BUILD_TYPE} MATCHES "Debug")
if (DYN32)
set(CMAKE_Fortran_FLAGS_OPT32BIT ${CMAKE_Fortran_FLAGS})
string(REPLACE "-real-size 64" "-real-size 32" CMAKE_Fortran_FLAGS_OPT32BIT "${CMAKE_Fortran_FLAGS_OPT32BIT}")
string(REPLACE "-r8" "-r4" CMAKE_Fortran_FLAGS_OPT32BIT "${CMAKE_Fortran_FLAGS_OPT32BIT}")
SET_SOURCE_FILES_PROPERTIES(./physics/gfdl_fv_sat_adj.F90
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_OPT32BIT}")
endif (DYN32)
else (PROJECT STREQUAL "CCPP-FV3")
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)
SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_model.f90 ./physics/calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-r8 -free")
Expand All @@ -173,6 +188,14 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "PGI")
SET_SOURCE_FILES_PROPERTIES(./physics/mersenne_twister.f PROPERTIES COMPILE_FLAGS "-r8 -Mnofptrap")
SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-r8 -Mfree")
SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F ./physics/surface_perturbation.F90 PROPERTIES COMPILE_FLAGS "-r8")
if (PROJECT STREQUAL "CCPP-FV3")
if (DYN32)
set(CMAKE_Fortran_FLAGS_OPT32BIT ${CMAKE_Fortran_FLAGS})
string(REPLACE "-r8" "-r4" CMAKE_Fortran_FLAGS_OPT32BIT "${CMAKE_Fortran_FLAGS_OPT32BIT}")
SET_SOURCE_FILES_PROPERTIES(./physics/gfdl_fv_sat_adj.F90
PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS_OPT32BIT}")
endif (DYN32)
endif (PROJECT STREQUAL "CCPP-FV3")
else (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message ("Fortran compiler: " ${CMAKE_Fortran_COMPILER_ID})
Expand Down
14 changes: 8 additions & 6 deletions physics/gcm_shoc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ end subroutine shoc_init
subroutine shoc_finalize ()
end subroutine shoc_finalize

#if 0
!> \section arg_table_shoc_run Argument Table
!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional |
!! |----------------------------|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|---------------|------|------------|-----------|--------|----------|
Expand Down Expand Up @@ -81,14 +82,15 @@ end subroutine shoc_finalize
!! | errmsg | ccpp_error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F |
!! | errflg | ccpp_error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F |
!!
subroutine shoc_run (ix, nx, nzm, do_shoc, shocaftcnv, mg3_as_mg2, imp_physics, imp_physics_gfdl, imp_physics_zhao_carr, &
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, &
con_fvirt, gq0_cloud_ice, gq0_rain, gq0_snow, gq0_graupel, dtp, me, prsl, phii, phil, u, v, omega, rhc, supice, pcrit, &
cefac, cesfac, tkef1, dis_opt, hflx, evap, prnum, &
skip_macro, clw_ice, clw_liquid, gq0_cloud_liquid, ncpl, ncpi, gt0, gq0_water_vapor, cld_sgs, tke, tkh, wthv_sec, &
#endif
subroutine shoc_run (ix, nx, nzm, do_shoc, shocaftcnv, mg3_as_mg2, imp_physics, imp_physics_gfdl, imp_physics_zhao_carr, &
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, &
con_fvirt, gq0_cloud_ice, gq0_rain, gq0_snow, gq0_graupel, dtp, me, prsl, phii, phil, u, v, omega, rhc, supice, pcrit, &
cefac, cesfac, tkef1, dis_opt, hflx, evap, prnum, &
skip_macro, clw_ice, clw_liquid, gq0_cloud_liquid, ncpl, ncpi, gt0, gq0_water_vapor, cld_sgs, tke, tkh, wthv_sec, &
errmsg, errflg)

implicit none
implicit none

integer, intent(in) :: ix, nx, nzm, imp_physics, imp_physics_gfdl, imp_physics_zhao_carr, imp_physics_zhao_carr_pdf, &
imp_physics_mg, fprcp, me
Expand Down
35 changes: 17 additions & 18 deletions physics/gfdl_fv_sat_adj.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ module fv_sat_adj
! *DH
!use fv_mp_mod, only: is_master
!use fv_arrays_mod, only: r_grid
use machine, only: kind_grid
use CCPP_typedefs, only: kind_dyn
use machine, only: kind_grid, kind_dyn
use gfdl_cloud_microphys_mod, only: ql_gen, qi_gen, qi0_max, ql_mlt, ql0_max, qi_lim, qs_mlt
use gfdl_cloud_microphys_mod, only: icloud_f, sat_adj0, t_sub, cld_min
use gfdl_cloud_microphys_mod, only: tau_r2g, tau_smlt, tau_i2s, tau_v2l, tau_l2v, tau_imlt, tau_l2r
Expand Down Expand Up @@ -98,7 +97,7 @@ module fv_sat_adj
real(kind=kind_dyn), parameter :: lv0 = hlv - dc_vap * tice !< 3.13905782e6, evaporation latent heat coefficient at 0 deg k
real(kind=kind_dyn), parameter :: li00 = hlf - dc_ice * tice !< - 2.7105966e5, fusion latent heat coefficient at 0 deg k
! real (kind_grid), parameter :: e00 = 610.71 ! gfdl: saturation vapor pressure at 0 deg c
real (kind_grid), parameter :: e00 = 611.21 !< ifs: saturation vapor pressure at 0 deg c
real (kind_grid), parameter :: e00 = 611.21 !< ifs: saturation vapor pressure at 0 deg c
real (kind_grid), parameter :: d2ice = dc_vap + dc_ice !< - 126, isobaric heating / cooling
real (kind_grid), parameter :: li2 = lv0 + li00 !< 2.86799816e6, sublimation latent heat coefficient at 0 deg k
real(kind=kind_dyn), parameter :: lat2 = (hlv + hlf) ** 2 !< used in bigg mechanism
Expand Down Expand Up @@ -304,14 +303,14 @@ subroutine fv_sat_adj_run(mdt, zvir, is, ie, isd, ied, kmp, km, kmdelz, js, je,
! as it would break a whole lot of code (including the one below)!
! Assume thus that isd_2d = isd etc.
real(kind_grid), intent(in) :: area(isd:ied, jsd:jed)
real(kind=kind_dyn), intent(inout) :: dtdt(is:ie, js:je, 1:km)
logical, intent(in) :: out_dt
logical, intent(in) :: last_step
logical, intent(in) :: do_qa
real(kind=kind_dyn), intent( out) :: qa(isd:ied, jsd:jed, 1:km)
integer, intent(in) :: nthreads
character(len=*), intent( out) :: errmsg
integer, intent( out) :: errflg
real(kind=kind_dyn), intent(inout) :: dtdt(is:ie, js:je, 1:km)
logical, intent(in) :: out_dt
logical, intent(in) :: last_step
logical, intent(in) :: do_qa
real(kind=kind_dyn), intent( out) :: qa(isd:ied, jsd:jed, 1:km)
integer, intent(in) :: nthreads
character(len=*), intent( out) :: errmsg
integer, intent( out) :: errflg

! Local variables
real(kind=kind_dyn), dimension(is:ie,js:je) :: dpln
Expand Down Expand Up @@ -589,7 +588,7 @@ subroutine fv_sat_adj_work(mdt, zvir, is, ie, js, je, ng, hydrostatic, consv_te,
lhi (i) = li00 + dc_ice * pt1 (i)
lcp2 (i) = lhl (i) / cvm (i)
icp2 (i) = lhi (i) / cvm (i)
tcp3 (i) = lcp2 (i) + icp2 (i) * min (1., dim (tice, pt1 (i)) / 48.)
tcp3 (i) = lcp2 (i) + icp2 (i) * min (1., dim (tice, pt1 (i)) /48.)
enddo
! -----------------------------------------------------------------------
!> - Condensation/evaporation between water vapor and cloud water.
Expand Down Expand Up @@ -980,7 +979,7 @@ subroutine fv_sat_adj_work(mdt, zvir, is, ie, js, je, ng, hydrostatic, consv_te,
enddo
endif
enddo ! end j loop

end subroutine fv_sat_adj_work
!! @}

Expand Down Expand Up @@ -1156,7 +1155,7 @@ subroutine qs_table (n)
! compute es over ice between - 160 deg c and 0 deg c.
! -----------------------------------------------------------------------
do i = 1, 1600
tem = tmin + delt * real (i - 1, kind=kind_dyn)
tem = tmin + delt * real (i - 1)
fac0 = (tem - tice) / (tem * tice)
fac1 = fac0 * li2
fac2 = (d2ice * log (tem / tice) + fac1) / rvgas
Expand All @@ -1166,7 +1165,7 @@ subroutine qs_table (n)
! compute es over water between - 20 deg c and 102 deg c.
! -----------------------------------------------------------------------
do i = 1, 1221
tem = 253.16 + delt * real (i - 1, kind=kind_dyn)
tem = 253.16 + delt * real (i - 1)
fac0 = (tem - tice) / (tem * tice)
fac1 = fac0 * lv0
fac2 = (dc_vap * log (tem / tice) + fac1) / rvgas
Expand All @@ -1181,7 +1180,7 @@ subroutine qs_table (n)
! derive blended es over ice and supercooled water between - 20 deg c and 0 deg c
! -----------------------------------------------------------------------
do i = 1, 200
tem = 253.16 + delt * real (i - 1, kind=kind_dyn)
tem = 253.16 + delt * real (i - 1)
wice = 0.05 * (tice - tem)
wh2o = 0.05 * (tem - 253.16)
table (i + 1400) = wice * table (i + 1400) + wh2o * esupc (i)
Expand All @@ -1202,7 +1201,7 @@ subroutine qs_tablew (n)
! compute es over water
! -----------------------------------------------------------------------
do i = 1, n
tem = tmin + delt * real (i - 1, kind=kind_dyn)
tem = tmin + delt * real (i - 1)
fac0 = (tem - tice) / (tem * tice)
fac1 = fac0 * lv0
fac2 = (dc_vap * log (tem / tice) + fac1) / rvgas
Expand All @@ -1221,7 +1220,7 @@ subroutine qs_table2 (n)
integer :: i, i0, i1
tmin = tice - 160.
do i = 1, n
tem0 = tmin + delt * real (i - 1, kind=kind_dyn)
tem0 = tmin + delt * real (i - 1)
fac0 = (tem0 - tice) / (tem0 * tice)
if (i <= 1600) then
! -----------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions physics/machine.F
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ MODULE MACHINE

#endif

#ifdef OVERLOAD_R4
integer, parameter :: kind_dyn = 4
#else
integer, parameter :: kind_dyn = 8
#endif

!
real(kind=kind_evod), parameter :: mprec = 1.e-12 ! machine precision to restrict dep
real(kind=kind_evod), parameter :: grib_undef = 9.99e20 ! grib undefine value
Expand Down
2 changes: 1 addition & 1 deletion physics/physcons.F90
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
module physcons
!
use machine, only : kind_phys
use CCPP_typedefs, only : kind_dyn
use machine, only : kind_dyn
!
implicit none
!
Expand Down