Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.o
*.mod
*.a
*.pyc
130 changes: 130 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
if( NOT DEFINED PHYS)
set(PHYS gfs)
endif()

if (PHYS MATCHES "nam")
add_definitions(-DNAM_phys)
endif()

if(CCPP)
add_definitions(-DCCPP)
if(STATIC)
add_definitions(-DSTATIC)
endif()
endif()

add_subdirectory(cpl)
add_subdirectory(${PHYS}physics)
add_subdirectory(ipd)
add_subdirectory(io)

# fv3core library

if(NOT CCPP)
set(FAST_PHYSICS_SRCS_F90 atmos_cubed_sphere/model/fv_cmp.F90)
endif()

add_library(
fv3core

atmos_cubed_sphere/model/a2b_edge.F90
atmos_cubed_sphere/model/multi_gases.F90
atmos_cubed_sphere/model/boundary.F90
atmos_cubed_sphere/model/dyn_core.F90
atmos_cubed_sphere/model/fv_arrays.F90
${FAST_PHYSICS_SRCS_F90}
atmos_cubed_sphere/model/fv_control.F90
atmos_cubed_sphere/model/fv_dynamics.F90
atmos_cubed_sphere/model/fv_fill.F90
atmos_cubed_sphere/model/fv_grid_utils.F90
atmos_cubed_sphere/model/fv_mapz.F90
atmos_cubed_sphere/model/fv_nesting.F90
atmos_cubed_sphere/model/fv_regional_bc.F90
atmos_cubed_sphere/model/fv_sg.F90
atmos_cubed_sphere/model/fv_tracer2d.F90
atmos_cubed_sphere/model/fv_update_phys.F90
atmos_cubed_sphere/model/sw_core.F90
atmos_cubed_sphere/model/tp_core.F90
atmos_cubed_sphere/model/nh_core.F90
atmos_cubed_sphere/model/nh_utils.F90
atmos_cubed_sphere/tools/external_ic.F90
atmos_cubed_sphere/tools/external_sst.F90
atmos_cubed_sphere/tools/fv_diagnostics.F90
atmos_cubed_sphere/tools/fv_eta.F90
atmos_cubed_sphere/tools/fv_grid_tools.F90
atmos_cubed_sphere/tools/fv_io.F90
atmos_cubed_sphere/tools/fv_mp_mod.F90
atmos_cubed_sphere/tools/fv_nudge.F90
atmos_cubed_sphere/tools/fv_treat_da_inc.F90
atmos_cubed_sphere/tools/fv_iau_mod.F90
atmos_cubed_sphere/tools/fv_restart.F90
atmos_cubed_sphere/tools/fv_surf_map.F90
atmos_cubed_sphere/tools/fv_timing.F90
atmos_cubed_sphere//tools/init_hydro.F90
atmos_cubed_sphere/tools/sim_nc_mod.F90
atmos_cubed_sphere/tools/sorted_index.F90
atmos_cubed_sphere/tools/test_cases.F90
atmos_cubed_sphere/driver/fvGFS/DYCORE_typedefs.F90
atmos_cubed_sphere/driver/fvGFS/fv_nggps_diag.F90
atmos_cubed_sphere/driver/fvGFS/atmosphere.F90
)

set_property(SOURCE atmos_cubed_sphere/model/nh_utils.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "${FAST}")
set_property(SOURCE atmos_cubed_sphere/model/fv_mapz.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "${FAST}")

target_link_libraries(fv3core PRIVATE fms)
target_link_libraries(fv3core PRIVATE ${PHYS}physics)
target_link_libraries(fv3core PRIVATE ipd)

target_include_directories(fv3core PRIVATE ${ESMF_MOD})

# end of fv3core

###############################################################################
### ccpp
###############################################################################
if(CCPP)
add_subdirectory(ccpp)
add_subdirectory(ccpp/driver)
add_dependencies(${PHYS}physics ccpp ccppphys)
add_dependencies(ccppdriver ccpp ccppphys)
add_dependencies(ccppphys ccpp)

target_include_directories(fv3core PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src)
target_include_directories(fv3core PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/driver)
endif()

set_target_properties(fv3core PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(fv3core PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod)

# When specifying an out-of-tree source a binary directory must be explicitly specified.
#add_subdirectory(../stochastic_physics stochastic_physics)
add_subdirectory(stochastic_physics)

add_library(
fv3cap

atmos_model.F90
fv3_cap.F90
module_fv3_config.F90
module_fcst_grid_comp.F90
time_utils.F90
)

if(CCPP)
target_include_directories(fv3cap PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver/mod)
endif()
target_include_directories(fv3cap PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/stochastic_physics)
target_compile_definitions(fv3cap PRIVATE -DESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR})
target_include_directories(fv3cap PRIVATE ${ESMF_MOD})

target_link_libraries(fv3cap PRIVATE fms)
target_link_libraries(fv3cap PRIVATE fv3cpl)
target_link_libraries(fv3cap PRIVATE ${PHYS}physics)
target_link_libraries(fv3cap PRIVATE ipd)
target_link_libraries(fv3cap PRIVATE io)
target_link_libraries(fv3cap PRIVATE fv3core)
target_link_libraries(fv3cap PRIVATE stochastic_physics)

set_target_properties(fv3cap PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(fv3cap PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod)
34 changes: 28 additions & 6 deletions atmos_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ module atmos_model_mod
FV3GFS_diag_register, FV3GFS_diag_output, &
DIAG_SIZE
use fv_iau_mod, only: iau_external_data_type,getiauforcing,iau_initialize
use module_fv3_config, only: output_1st_tstep_rst, first_kdt, nsout
use module_fv3_config, only: output_1st_tstep_rst, first_kdt, nsout, &
frestart, restart_endfcst

!-----------------------------------------------------------------------

Expand Down Expand Up @@ -221,7 +222,8 @@ module atmos_model_mod
logical,parameter :: flip_vc = .true.
#endif

real(kind=IPD_kind_phys), parameter :: zero=0.0, one=1.0
real(kind=IPD_kind_phys), parameter :: zero = 0.0_IPD_kind_phys, &
one = 1.0_IPD_kind_phys

contains

Expand Down Expand Up @@ -944,17 +946,19 @@ end subroutine update_atmos_model_state
subroutine atmos_model_end (Atmos)
type (atmos_data_type), intent(inout) :: Atmos
!---local variables
integer :: idx
integer :: idx, seconds
#ifdef CCPP
integer :: ierr
#endif

!-----------------------------------------------------------------------
!---- termination routine for atmospheric model ----

call atmosphere_end (Atmos % Time, Atmos%grid)
call FV3GFS_restart_write (IPD_Data, IPD_Restart, Atm_block, &
IPD_Control, Atmos%domain)
call atmosphere_end (Atmos % Time, Atmos%grid, restart_endfcst)
if(restart_endfcst) then
call FV3GFS_restart_write (IPD_Data, IPD_Restart, Atm_block, &
IPD_Control, Atmos%domain)
endif

#ifdef CCPP
! Fast physics (from dynamics) are finalized in atmosphere_end above;
Expand Down Expand Up @@ -1457,6 +1461,24 @@ subroutine update_atmos_chemistry(state, rc)
enddo
enddo

! -- zero out accumulated fields
!$OMP parallel do default (none) &
!$OMP shared (nj, ni, Atm_block, IPD_Control, IPD_Data) &
!$OMP private (j, jb, i, ib, nb, ix)
do j = 1, nj
jb = j + Atm_block%jsc - 1
do i = 1, ni
ib = i + Atm_block%isc - 1
nb = Atm_block%blkno(ib,jb)
ix = Atm_block%ixp(ib,jb)
IPD_Data(nb)%coupling%rainc_cpl(ix) = zero
if (.not.IPD_Control%cplflx) then
IPD_Data(nb)%coupling%rain_cpl(ix) = zero
IPD_Data(nb)%coupling%snow_cpl(ix) = zero
end if
enddo
enddo

if (IPD_Control%debug) then
! -- diagnostics
write(6,'("update_atmos: prsi - min/max/avg",3g16.6)') minval(prsi), maxval(prsi), sum(prsi)/size(prsi)
Expand Down
43 changes: 28 additions & 15 deletions ccpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,22 @@ elseif (${CMAKE_BUILD_TYPE} MATCHES "Release")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS_RELEASE}")
elseif (${CMAKE_BUILD_TYPE} MATCHES "Bitforbit")
if (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI")
set (CMAKE_C_FLAGS_RELEASE "-O1 -fPIC" CACHE STRING "" FORCE)
set (CMAKE_CXX_FLAGS_RELEASE "-O1 -fPIC" CACHE STRING "" FORCE)
set (CMAKE_Fortran_FLAGS_RELEASE "-O1 -fPIC" CACHE STRING "" FORCE)
set (CMAKE_C_FLAGS_BITFORBIT "-O1 -g -fPIC" CACHE STRING "" FORCE)
set (CMAKE_CXX_FLAGS_BITFORBIT "-O1 -g -fPIC" CACHE STRING "" FORCE)
set (CMAKE_Fortran_FLAGS_BITFORBIT "-O1 -g -fPIC" CACHE STRING "" FORCE)
elseif (APPLE AND ${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
set (CMAKE_C_FLAGS_BITFORBIT "-O0 -g -fPIC" CACHE STRING "" FORCE)
set (CMAKE_CXX_FLAGS_BITFORBIT "-O0 -g -fPIC" CACHE STRING "" FORCE)
set (CMAKE_Fortran_FLAGS_BITFORBIT "-O0 -g -fPIC" CACHE STRING "" FORCE)
# For Intel on all platforms and for GNU on all platforms except macOS
else (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI")
set (CMAKE_C_FLAGS_RELEASE "-O2 -fPIC" CACHE STRING "" FORCE)
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -fPIC" CACHE STRING "" FORCE)
set (CMAKE_Fortran_FLAGS_RELEASE "-O2 -fPIC" CACHE STRING "" FORCE)
set (CMAKE_C_FLAGS_BITFORBIT "-O2 -g -fPIC" CACHE STRING "" FORCE)
set (CMAKE_CXX_FLAGS_BITFORBIT "-O2 -g -fPIC" CACHE STRING "" FORCE)
set (CMAKE_Fortran_FLAGS_BITFORBIT "-O2 -g -fPIC" CACHE STRING "" FORCE)
endif (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_RELEASE}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS_RELEASE}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BITFORBIT}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BITFORBIT}")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS_BITFORBIT}")
endif (${CMAKE_BUILD_TYPE} MATCHES "Debug")

# Set compiler-specific options, depending on build type; some optimization flags may only be used
Expand All @@ -84,12 +89,12 @@ if (${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -ffree-line-length-none -fno-range-check")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fbacktrace -cpp")
if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffpe-trap=invalid,zero,overflow -fcheck=bounds -fbacktrace -fno-range-check")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffpe-trap=invalid,zero,overflow -fcheck=bounds -fbacktrace -fno-range-check -Wall")
elseif (${CMAKE_BUILD_TYPE} MATCHES "Bitforbit")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
endif (${CMAKE_BUILD_TYPE} MATCHES "Debug")
set (CMAKE_Fortran_FLAGS_DEFAULT_PREC "-fdefault-real-8 -fdefault-double-8")
elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI")
Expand All @@ -114,9 +119,9 @@ elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fstack-protector-all -fpe0 -traceback -debug -ftrapuv")
elseif (${CMAKE_BUILD_TYPE} MATCHES "Bitforbit")
if(LEGACY_INTEL)
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -debug minimal -fp-model strict -qoverride-limits -g -traceback")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -debug minimal -fp-model strict -qoverride-limits -traceback")
else(LEGACY_INTEL)
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -debug minimal -fp-model consistent -qoverride-limits -g -traceback")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -debug minimal -fp-model consistent -qoverride-limits -traceback")
endif (LEGACY_INTEL)
elseif (${CMAKE_BUILD_TYPE} MATCHES "Release")
# Specify aggressive optimization flags (to be overwritten for individual files in ccpp-physics' CMakeLists.txt)
Expand Down Expand Up @@ -254,12 +259,20 @@ endif(MKL_DIR)

#------------------------------------------------------------------------------
# Set netCDF flags for preprocessor, compiler and linker (if defined)
# Legacy settings for old make build
if(NETCDF_DIR)
set (NETCDF_INC "-I${NETCDF_DIR}/include")
set (NETCDF_LIB "-L${NETCDF_DIR}/lib -lnetcdff -lnetcdf")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${NETCDF_INC} ${NETCDF_LIB}")
ADD_DEFINITIONS(-DNETCDF)
message (STATUS "Enable netCDF support")
# Settings for new cmake build
elseif (NETCDF_INC_DIR AND NETCDF_LIBDIR)
set (NETCDF_INC "-I${NETCDF_INC_DIR}")
set (NETCDF_LIB "-L${NETCDF_LIBDIR} -lnetcdff -lnetcdf")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${NETCDF_INC} ${NETCDF_LIB}")
ADD_DEFINITIONS(-DNETCDF)
message (STATUS "Enable netCDF support")
else(NETCDF_DIR)
message (STATUS "Disable netCDF support")
endif(NETCDF_DIR)
Expand Down
2 changes: 1 addition & 1 deletion ccpp/build_ccpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ else
CCPP_LINK_OBJS="-L${PATH_CCPP_LIB} -lccpp ${CCPP_XML2_LIB}"
fi
fi
echo "ESMF_DEP_INCPATH=-I${PATH_CCPP_INC}" > ${CCPP_MK}
echo "ESMF_DEP_INCPATH=${PATH_CCPP_INC}" > ${CCPP_MK}
echo "ESMF_DEP_LINK_OBJS=${CCPP_LINK_OBJS}" >> ${CCPP_MK}

if [ $clean_after = YES ]; then
Expand Down
21 changes: 20 additions & 1 deletion ccpp/config/ccpp_prebuild_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
'FV3/ccpp/physics/physics/module_mp_radar.F90',
'FV3/ccpp/physics/physics/module_mp_thompson.F90',
'FV3/ccpp/physics/physics/module_mp_thompson_make_number_concentrations.F90',
'FV3/ccpp/physics/physics/module_MP_FER_HIRES.F90',
'FV3/ccpp/physics/physics/module_bl_mynn.F90',
'FV3/ccpp/physics/physics/module_sf_mynn.F90',
'FV3/ccpp/physics/physics/module_SF_JSFC.F90',
Expand All @@ -111,7 +112,9 @@
'FV3/ccpp/physics/physics/cires_vert_wmsdis.F90',
'FV3/ccpp/physics/physics/namelist_soilveg.f',
'FV3/ccpp/physics/physics/mfpblt.f',
'FV3/ccpp/physics/physics/mfpbltq.f',
'FV3/ccpp/physics/physics/mfscu.f',
'FV3/ccpp/physics/physics/mfscuq.f',
'FV3/ccpp/physics/physics/noahmp_tables.f90',
'FV3/ccpp/physics/physics/num_parthds.F',
'FV3/ccpp/physics/physics/ozne_def.f',
Expand Down Expand Up @@ -188,6 +191,8 @@
'FV3/ccpp/physics/physics/h2ophys.f' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/samfdeepcnv.f' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/samfshalcnv.f' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/sascnvn.F' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/shalcnv.F' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/maximum_hourly_diagnostics.F90' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/m_micro.F90' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/m_micro_interstitial.F90' : [ 'slow_physics' ],
Expand All @@ -197,6 +202,7 @@
'FV3/ccpp/physics/physics/moninedmf.f' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/moninshoc.f' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/satmedmfvdif.F' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/satmedmfvdifq.F' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/shinhongvdif.F90' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/ysuvdif.F90' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/module_MYNNPBL_wrapper.F90' : [ 'slow_physics' ],
Expand Down Expand Up @@ -225,15 +231,20 @@
'FV3/ccpp/physics/physics/sfc_cice.f' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/sfc_diff.f' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/sfc_drv.f' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/sfc_noahmp_pre.F90' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/sfc_noahmp_drv.f' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/sfc_nst.f' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/sfc_ocean.F' : [ 'slow_physics' ],
'FV3/ccpp/physics/physics/sfc_sice.f' : [ 'slow_physics' ],
# HAFS FER_HIRES
'FV3/ccpp/physics/physics/mp_fer_hires.F90' : [ 'slow_physics' ],
# for testing the <init> and <finalize> sections
'FV3/ccpp/physics/physics/GFS_suite_init_finalize_test.F90' : [ 'slow_physics' ],
}

# Default build dir, relative to current working directory,
# if not specified as command-line argument
DEFAULT_BUILD_DIR = 'FV3'

# Auto-generated makefile/cmakefile snippets that contain all schemes
SCHEMES_MAKEFILE = '{build_dir}/ccpp/physics/CCPP_SCHEMES.mk'
SCHEMES_CMAKEFILE = '{build_dir}/ccpp/physics/CCPP_SCHEMES.cmake'
Expand Down Expand Up @@ -317,6 +328,14 @@
'tendency_of_ice_friendly_aerosols_at_surface',
],
},
'mp_fer_hires' : {
'mp_fer_hires_init' : [
'fraction_of_ice_water_cloud',
'fraction_of_rain_water_cloud',
'rime_factor',
],
},

#'subroutine_name_1' : 'all',
#'subroutine_name_2' : 'none',
#'subroutine_name_2' : [ 'var1', 'var3'],
Expand Down
27 changes: 27 additions & 0 deletions ccpp/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

if(NOT DYN32)
remove_definitions(-DOVERLOAD_R8)
remove_definitions(-DOVERLOAD_R4)
endif()

message ("Force 64 bits in CCPP_layer")
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64 -no-prec-div -no-prec-sqrt" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8")
endif()

add_library(
ccppdriver

CCPP_driver.F90
)

target_link_libraries(ccppdriver ${PHYS}physics)
target_link_libraries(ccppdriver ccpp)
target_link_libraries(ccppdriver ccppphys)

target_include_directories(ccppdriver PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src)

set_target_properties(ccppdriver PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(ccppdriver PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod)
Loading