diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..7bd04b9b1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,305 @@ +#------------------------------------------------------------------------------ +cmake_minimum_required(VERSION 2.8.11) + +if(POLICY CMP0048) + cmake_policy(SET CMP0048 NEW) + project(check VERSION 0.0.1) +else(POLICY CMP0048) + project(check) + set(PROJECT_VERSION 0.0.1) + set(PROJECT_VERSION_MAJOR 0) + set(PROJECT_VERSION_MINOR 0) + set(PROJECT_VERSION_PATCH 1) +endif(POLICY CMP0048) + +#------------------------------------------------------------------------------ +set(PACKAGE "gfsphysics") +set(AUTHORS "Grant J. Firl") + +#------------------------------------------------------------------------------ +# Enable Fortran +enable_language(Fortran) + +#------------------------------------------------------------------------------ +# CMake Modules +# Set the CMake module path +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../gmtb-ccpp/cmake") + +#------------------------------------------------------------------------------ +# Find OpenMP for C/C++ +find_package(OpenMP) +if(OPENMP_FOUND) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + message(STATUS "Enabled OpenMP support for C/C++ compiler") +else(OPENMP_FOUND) + message (STATUS "C/C++ compiler does not support OpenMP") +endif() + +#------------------------------------------------------------------------------ +# Find OpenMP for Fortran +FIND_PACKAGE(OpenMP_Fortran) +if(OpenMP_FLAG_DETECTED) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}") + message(STATUS "Enabled OpenMP support for Fortran compiler") +else(OpenMP_FLAG_DETECTED) + message (STATUS "Fortran compiler does not support OpenMP") +endif() + +message (STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") +message (STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") +message (STATUS "CMAKE_Fortran_FLAGS: ${CMAKE_Fortran_FLAGS}") + +#------------------------------------------------------------------------------ +# The Fortran compiler/linker flag inserted by cmake to create shared libraries +# with the Intel compiler is deprecated (-i_dynamic), correct here. +# CMAKE_Fortran_COMPILER_ID = {"Intel", "PGI", "GNU", "Clang", "MSVC", ...} +if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel") + string(REPLACE "-i_dynamic" "-shared-intel" + CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS + "${CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS}") + string(REPLACE "-i_dynamic" "-shared-intel" + CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS + "${CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS}") +endif() + +#------------------------------------------------------------------------------ +# Set a default build type if none was specified +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'Debug' as none was specified.") + set(CMAKE_BUILD_TYPE Debug 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" + "MinSizeRel" "RelWithDebInfo") +endif() + +#------------------------------------------------------------------------------ +# By default we want a shared library +option(BUILD_SHARED_LIBS "Build a shared library" ON) + +#------------------------------------------------------------------------------ +# Add the CCPP include/module directory +set(CCPP_INCLUDE_DIRS "" CACHE FILEPATH "Path to ccpp includes") +set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES ${CCPP_INCLUDE_DIRS}) + +#------------------------------------------------------------------------------ +# Add the CCPP library +set(CCPP_LIB_DIRS "" CACHE FILEPATH "Path to ccpp library") +link_directories(${CCPP_LIB_DIRS}) +list(APPEND LIBS "ccpp") + +#------------------------------------------------------------------------------ +# Set the sources +set(SOURCES + ./physics/machine.F + ./physics/physcons.f90 + ./physics/funcphys.f90 + ./GFS_layer/GFS_typedefs.F90 + ./physics/radlw_param.f + ./physics/physparam.f + ./physics/radsw_param.f + ./physics/radiation_aerosols.f + ./physics/iounitdef.f + ./physics/gfs_phy_tracer_config.f + ./physics/radiation_clouds.f + ./physics/module_bfmicrophysics.f + ./physics/radiation_gases.f + ./physics/ozne_def.f + ./physics/radiation_surface.f + ./physics//h2o_def.f + ./physics/sfcsub.F + ./physics/mersenne_twister.f + ./physics/rascnvv2.f + ./physics/GFDL_parse_tracers.F90 + ./physics/wam_f107_kp_mod.f90 + ./physics/num_parthds.F + ./physics/gocart_tracer_config_stub.f + ./GFS_layer/GFS_initialize_scm.F90 + ./physics/cldwat2m_micro.F + ./physics/wv_saturation.F + ./physics/aer_cloud.F + ./physics/rad_initialize.f + ./GFS_layer/GFS_radiation_driver.F90 + ./physics/radcons.f90 + ./physics/radiation_astronomy.f + ./physics/radsw_main.f + ./physics/radsw_datatb.f + ./physics/GFS_rrtmg_pre.F90 + ./physics/GFS_rrtmg_post.F90 + ./physics/rrtmg_sw_pre.F90 + ./physics/rrtmg_sw_post.F90 + ./physics/rrtmg_lw_pre.F90 + ./physics/rrtmg_lw_post.F90 + ./physics/radlw_main.f + ./physics/radlw_datatb.f + ./physics/set_soilveg.f + ./physics/namelist_soilveg.f + ./physics/GFS_phys_time_vary.f90 + ./physics/ozinterp.f90 + ./physics/h2ointerp.f90 + ./physics/gcycle.f90 + ./physics/GFS_rad_time_vary.f90 + ./physics/GFS_radupdate.f90 + ./physics/GFS_suite_interstitial.ccpp.f90 + ./physics/get_prs_fv3.f90 + ./physics/sfc_sice.f + ./physics/dcyc2.f + ./physics/GFS_surface_generic.f90 + ./physics/GFS_PBL_generic.f90 + ./physics/sfc_drv.f + ./physics/sflx.f + ./physics/sfc_diff.f + ./physics/GFS_surface_loop_control.f + ./physics/sfc_nst.f + ./physics/date_def.f + ./physics/module_nst_water_prop.f90 + ./physics/module_nst_parameters.f90 + ./physics/module_nst_model.f90 + ./physics/sfc_diag.f + ./physics/moninedmf.f + ./physics/mfpbl.f + ./physics/tridi.f + ./physics/gwdps.f + ./physics/rayleigh_damp.f + ./physics/ozphys.f + ./physics/GFS_DCNV_generic.f90 + ./physics/GFS_zhao_carr_pre.f90 + ./physics/mfdeepcnv.f + ./physics/gwdc.f + ./physics/GFS_SCNV_generic.f90 + ./physics/mfshalcnv.f + ./physics/cnvc90.f + ./physics/GFS_MP_generic_pre.f90 + ./physics/gscond.f + ./physics/precpd.f + ./physics/GFS_calpreciptype.f90 + ./physics/GFS_MP_generic_post.f90 + ./physics/cnvc90_cap.F90 + ./physics/lsm_noah_pre_cap.F90 + ./physics/GFS_DCNV_generic_post_cap.F90 + ./physics/ozphys_pre_cap.F90 + ./physics/gwdps_pre_cap.F90 + ./physics/ozphys_cap.F90 + ./physics/GFS_suite_interstitial_rad_reset_cap.F90 + ./physics/GFS_MP_generic_post_cap.F90 + ./physics/rrtmg_sw_cap.F90 + ./physics/dcyc2t3_post_cap.F90 + ./physics/sfc_nst_cap.F90 + ./physics/rrtmg_lw_cap.F90 + ./physics/GFS_zhao_carr_pre_cap.F90 + ./physics/GFS_PBL_generic_pre_cap.F90 + ./physics/gwdps_post_cap.F90 + ./physics/GFS_suite_interstitial_1_cap.F90 + ./physics/sfc_sice_pre_cap.F90 + ./physics/GFS_suite_interstitial_2_cap.F90 + ./physics/dcyc2t3_pre_cap.F90 + ./physics/rrtmg_lw_pre_cap.F90 + ./physics/GFS_rad_time_vary_cap.F90 + ./physics/sasas_shal_post_cap.F90 + ./physics/sfc_sice_cap.F90 + ./physics/GFS_SCNV_generic_pre_cap.F90 + ./physics/GFS_PBL_generic_post_cap.F90 + ./physics/sasas_shal_cap.F90 + ./physics/GFS_surface_loop_control_part2_cap.F90 + ./physics/GFS_rrtmg_pre_cap.F90 + ./physics/GFS_phys_time_vary_2_cap.F90 + ./physics/GFS_phys_time_vary_1_cap.F90 + ./physics/dcyc2t3_cap.F90 + ./physics/gwdc_cap.F90 + ./physics/get_prs_fv3_cap.F90 + ./physics/GFS_surface_generic_post_cap.F90 + ./physics/rrtmg_sw_post_cap.F90 + ./physics/edmf_cap.F90 + ./physics/sfc_ex_coef_cap.F90 + ./physics/GFS_surface_loop_control_part1_cap.F90 + ./physics/GFS_surface_loop_control_part0_cap.F90 + ./physics/rrtmg_lw_post_cap.F90 + ./physics/rayleigh_damp_cap.F90 + ./physics/lsm_noah_post_cap.F90 + ./physics/lsm_noah_cap.F90 + ./physics/GFS_suite_interstitial_phys_reset_cap.F90 + ./physics/gwdps_cap.F90 + ./physics/sfc_nst_pre_cap.F90 + ./physics/GFS_SCNV_generic_post_cap.F90 + ./physics/sfc_diag_cap.F90 + ./physics/zhaocarr_precpd_cap.F90 + ./physics/sasas_deep_cap.F90 + ./physics/GFS_initialize_scm_cap.F90 + ./physics/GFS_DCNV_generic_pre_cap.F90 + ./physics/gwdc_pre_cap.F90 + ./physics/zhaocarr_gscond_cap.F90 + ./physics/GFS_suite_interstitial_3_cap.F90 + ./physics/GFS_calpreciptype_cap.F90 + ./physics/GFS_MP_generic_pre_cap.F90 + ./physics/sfc_sice_post_cap.F90 + ./physics/gwdc_post_cap.F90 + ./physics/GFS_suite_update_stateout_cap.F90 + ./physics/sfc_nst_post_cap.F90 + ./physics/GFS_surface_generic_pre_cap.F90 + ./physics/ozphys_post_cap.F90 + ./physics/GFS_rrtmg_post_cap.F90 + ./physics/get_phi_fv3_cap.F90 + ./physics/rrtmg_sw_pre_cap.F90 +) + +if (${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU") + set(f_flags -ffree-line-length-none) + + 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 -fdefault-real-8) + SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_model.f90 ./physics/GFS_calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-fdefault-real-8 -ffree-form") + 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 PROPERTIES COMPILE_FLAGS "-DNEMS_GSM -fdefault-real-8 -fdefault-double-8") +elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel") + set(f_flags -extend-source 132) + + 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/GFS_calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-r8 -free") + SET_SOURCE_FILES_PROPERTIES(./physics/mersenne_twister.f PROPERTIES COMPILE_FLAGS "-r8 -ftz") + SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-extend-source 132 -r8 -free") + SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F PROPERTIES COMPILE_FLAGS "-DNEMS_GSM -r8") +else (${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU") + message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER}) + message ("Fortran compiler: " ${CMAKE_Fortran_COMPILER_ID}) + message ("This program has only been compiled with gfortran and ifort. If another compiler is needed, the appropriate flags must be added in ${GFS_PHYS_SRC}/CMakeLists.txt") +endif (${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU") + +#apply general fortran tags to all fortran source files +if(${CMAKE_VERSION} LESS 3.3) + string (REPLACE ";" " " f_flags_str "${f_flags}") + SET_PROPERTY(SOURCE ${GFS_phys_source_code} APPEND_STRING PROPERTY COMPILE_FLAGS " ${f_flags_str}") +else(${CMAKE_VERSION} LESS 3.3) + add_compile_options("$<$:${f_flags}>") +endif (${CMAKE_VERSION} LESS 3.3) + +SET(W3LIB_SRC ${CMAKE_SOURCE_DIR}/w3nco/v2.0.6/src) +SET(BACIOLIB_SRC ${CMAKE_SOURCE_DIR}/bacio/v2.0.1/src) +SET(SPLIB_SRC ${CMAKE_SOURCE_DIR}/sp/v2.0.2/src) + +#add "sibling" directories (must specify the build directory too) +ADD_SUBDIRECTORY(${W3LIB_SRC} ${CMAKE_BINARY_DIR}/w3nco) +ADD_SUBDIRECTORY(${BACIOLIB_SRC} ${CMAKE_BINARY_DIR}/bacio) +ADD_SUBDIRECTORY(${SPLIB_SRC} ${CMAKE_BINARY_DIR}/sp) + +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/w3nco) +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/sp) +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/bacio) + +#------------------------------------------------------------------------------ +# Add the auto-generated caps +#add_custom_command( +# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scm_cap.f90 +# DEPENDS ${CCPP_MKCAP} +# COMMAND ${CCPP_MKCAP} -o ${CMAKE_CURRENT_BINARY_DIR}/scm_cap.f90 +# ${CMAKE_CURRENT_SOURCE_DIR}/scheme.xml +#) +#list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/scm_test1_cap.f90) + + +add_library(gfsphysics ${SOURCES}) +target_link_libraries(gfsphysics LINK_PUBLIC ${LIBS} w3 sp bacio) +set_target_properties(gfsphysics PROPERTIES VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + COMPILE_FLAGS ${OpenMP_Fortran_FLAGS} + LINK_FLAGS ${OpenMP_Fortran_FLAGS}) diff --git a/GFS_layer/GFS_initialize_scm.F90 b/GFS_layer/GFS_initialize_scm.F90 new file mode 100644 index 000000000..ca33f3477 --- /dev/null +++ b/GFS_layer/GFS_initialize_scm.F90 @@ -0,0 +1,232 @@ +module GFS_initialize_scm + + implicit none + + private + +!---------------- +! Public entities +!---------------- + public GFS_initialize_scm_init, GFS_initialize_scm_run, GFS_initialize_scm_finalize + + CONTAINS +!******************************************************************************************* + +!-------------- +! GFS initialze +!-------------- + + subroutine GFS_initialize_scm_init() + end subroutine GFS_initialize_scm_init + + subroutine GFS_initialize_scm_finalize() + end subroutine GFS_initialize_scm_finalize + +!> \section arg_table_GFS_initialize_scm_run Argument Table +!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional | +!! |----------------------|-------------------------------------------------------------|-------------------------------------------------------------------------|---------------|------|-------------------------------|-----------|--------|----------| +!! | Model | FV3-GFS_Control_type | Fortran DDT containing FV3-GFS model control parameters | DDT | 0 | GFS_control_type | | inout | F | +!! | Statein | FV3-GFS_Statein_type | Fortran DDT containing FV3-GFS prognostic state data in from dycore | DDT | 0 | GFS_statein_type | | inout | F | +!! | Stateout | FV3-GFS_Stateout_type | Fortran DDT containing FV3-GFS prognostic state to return to dycore | DDT | 0 | GFS_stateout_type | | inout | F | +!! | Sfcprop | FV3-GFS_Sfcprop_type | Fortran DDT containing FV3-GFS surface fields | DDT | 0 | GFS_sfcprop_type | | inout | F | +!! | Coupling | FV3-GFS_Coupling_type | derived type GFS_coupling_type in FV3 | DDT | 0 | GFS_coupling_type | | inout | F | +!! | Grid | FV3-GFS_Grid_type | Fortran DDT containing FV3-GFS grid and interpolation related data | DDT | 0 | GFS_grid_type | | inout | F | +!! | Tbd | FV3-GFS_Tbd_type | derived type GFS_tbd_type in FV3 | DDT | 0 | GFS_tbd_type | | inout | F | +!! | Cldprop | FV3-GFS_Cldprop_type | derived type GFS_cldprop_type in FV3 | DDT | 0 | GFS_cldprop_type | | inout | F | +!! | Radtend | FV3-GFS_Radtend_type | derived type GFS_radtend_type in FV3 | DDT | 0 | GFS_radtend_type | | inout | F | +!! | Diag | FV3-GFS_Diag_type | Fortran DDT containing FV3-GFS fields targeted for diagnostic output | DDT | 0 | GFS_diag_type | | inout | F | +!! | Sfccycle | FV3-GFS_Sfccycle_type | derived type GFS_sfccycle_type in FV3 | DDT | 0 | GFS_sfccycle_type | | inout | F | +!! | Interstitial | FV3-GFS_Interstitial_type | derived type GFS_interstitial_type in FV3 | DDT | 0 | GFS_interstitial_type | | inout | F | +!! | Init_parm | FV3-GFS_Init_type | dervied type GFS_init_type in FV3 | DDT | 0 | GFS_init_type | | in | F | +!! | n_ozone_layers | vertical_dimension_of_ozone_forcing_data_from_host | number of vertical layers in ozone forcing data coming from host | count | 0 | integer | | in | F | +!! | n_ozone_lats | number_of_latitutde_points_in_ozone_forcing_data_from_host | number of latitude points in ozone forcing data coming from host | count | 0 | integer | | in | F | +!! | n_ozone_times | number_of_time_levels_in_ozone_forcing_data_from_host | number of time levels in ozone forcing data coming from host | count | 0 | integer | | in | F | +!! | n_ozone_coefficients | number_of_coefficients_in_ozone_forcing_data_from_host | number of coeffcients in ozone forcing data coming from host | count | 0 | integer | | in | F | +!! | ozone_lat | latitude_of_ozone_forcing_data_from_host | latitude value of the ozone forcing data coming from host | degree | 1 | real | kind_phys | in | F | +!! | ozone_pres | natural_log_of_ozone_forcing_data_pressure_levels_from_host | natural logarithm of the pressure levels of the ozone forcing data | Pa | 1 | real | kind_phys | in | F | +!! | ozone_time | time_levels_in_ozone_forcing_data_from_host | time values of the ozone forcing data coming from host | day | 1 | real | kind_phys | in | F | +!! | ozone_forcing_in | ozone_forcing_from_host | ozone forcing data from host | various | 4 | real | kind_phys | in | F | +!! | errmsg | error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F | +!! | errflg | error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F | +!! + subroutine GFS_initialize_scm_run (Model, Statein, Stateout, Sfcprop, & + Coupling, Grid, Tbd, Cldprop, Radtend, Diag, & + Sfccycle, Interstitial, Init_parm, n_ozone_lats, & + n_ozone_layers, n_ozone_times, n_ozone_coefficients, & + ozone_lat, ozone_pres, ozone_time, ozone_forcing_in, & + errmsg, errflg) + + use machine, only: kind_phys + use GFS_typedefs, only: GFS_init_type, & + GFS_statein_type, GFS_stateout_type, & + GFS_sfcprop_type, GFS_coupling_type, & + GFS_control_type, GFS_grid_type, & + GFS_tbd_type, GFS_cldprop_type, & + GFS_radtend_type, GFS_diag_type, & + GFS_sfccycle_type, GFS_interstitial_type + use funcphys, only: gfuncphys + use module_microphysics, only: gsmconst + use cldwat2m_micro, only: ini_micro + use aer_cloud, only: aer_cloud_init + use module_ras, only: ras_init + use ozne_def, only: latsozp, levozp, timeoz, oz_coeff, oz_lat, oz_pres, oz_time, ozplin + + !--- interface variables + type(GFS_control_type), intent(inout) :: Model + type(GFS_statein_type), intent(inout) :: Statein + type(GFS_stateout_type), intent(inout) :: Stateout + type(GFS_sfcprop_type), intent(inout) :: Sfcprop + type(GFS_coupling_type), intent(inout) :: Coupling + type(GFS_grid_type), intent(inout) :: Grid + type(GFS_tbd_type), intent(inout) :: Tbd + type(GFS_cldprop_type), intent(inout) :: Cldprop + type(GFS_radtend_type), intent(inout) :: Radtend + type(GFS_diag_type), intent(inout) :: Diag + type(GFS_sfccycle_type), intent(inout) :: Sfccycle + type(GFS_interstitial_type), intent(inout) :: Interstitial + type(GFS_init_type), intent(in) :: Init_parm + + integer, intent(in) :: n_ozone_lats, n_ozone_layers, n_ozone_coefficients, n_ozone_times + real(kind=kind_phys), intent(in) :: ozone_lat(:), ozone_pres(:), ozone_time(:), ozone_forcing_in(:,:,:,:) + + character(len=*), intent(out) :: errmsg + integer, intent(out) :: errflg + ! + ! !--- local variables + real(kind=kind_phys), allocatable :: si(:) + real(kind=kind_phys), parameter :: p_ref = 101325.0d0 + + ! Initialize CCPP error handling variables + errmsg = '' + errflg = 0 + +! !--- set control properties (including namelist read) + call Model%init (Init_parm%nlunit, Init_parm%fn_nml, & + Init_parm%me, Init_parm%master, & + Init_parm%logunit, Init_parm%isc, & + Init_parm%jsc, Init_parm%nx, Init_parm%ny, & + Init_parm%levs, Init_parm%cnx, Init_parm%cny, & + Init_parm%gnx, Init_parm%gny, & + Init_parm%dt_dycore, Init_parm%dt_phys, & + Init_parm%bdat, Init_parm%cdat, & + Init_parm%tracer_names, Init_parm%blksz) + + !allocate memory for the variables stored in ozne_def and set them + allocate(oz_lat(n_ozone_lats), oz_pres(n_ozone_layers), oz_time(n_ozone_times+1)) + allocate(ozplin(n_ozone_lats, n_ozone_layers, n_ozone_coefficients, n_ozone_times)) + latsozp = n_ozone_lats + levozp = n_ozone_layers + timeoz = n_ozone_times + oz_coeff = n_ozone_coefficients + oz_lat = ozone_lat + oz_pres = ozone_pres + oz_time = ozone_time + ozplin = ozone_forcing_in + + call Statein%create(1, Model) + call Stateout%create(1, Model) + call Sfcprop%create(1, Model) + call Coupling%create(1, Model) + call Grid%create(1, Model) + call Tbd%create(1, 1, Model) + call Cldprop%create(1, Model) + call Radtend%create(1, Model) + !--- internal representation of diagnostics + call Diag%create(1, Model) + !--- internal representation of sfccycle + call Sfccycle%create(1, Model) + call Interstitial%create(1, Model) + +! !--- populate the grid components + call GFS_grid_populate (Grid, Init_parm%xlon, Init_parm%xlat, Init_parm%area) + + !--- read in and initialize ozone and water + if (Model%ntoz > 0) then + call setindxoz (Init_parm%blksz, Grid%xlat_d, Grid%jindx1_o3, & + Grid%jindx2_o3, Grid%ddy_o3) + endif + + if (Model%h2o_phys) then + call setindxh2o (Init_parm%blksz, Grid%xlat_d, Grid%jindx1_h, & + Grid%jindx2_h, Grid%ddy_h) + endif + +! !--- Call gfuncphys (funcphys.f) to compute all physics function tables. + call gfuncphys () +! + call gsmconst (Model%dtp, Model%me, .TRUE.) +! +! !--- define sigma level for radiation initialization +! !--- The formula converting hybrid sigma pressure coefficients to sigma coefficients follows Eckermann (2009, MWR) +! !--- ps is replaced with p0. The value of p0 uses that in http://www.emc.ncep.noaa.gov/officenotes/newernotes/on461.pdf +! !--- ak/bk have been flipped from their original FV3 orientation and are defined sfc -> toa + allocate(si(Model%levr+1)) + si = (Init_parm%ak + Init_parm%bk * p_ref - Init_parm%ak(Model%levr+1)) & + / (p_ref - Init_parm%ak(Model%levr+1)) + call rad_initialize (si, Model%levr, Model%ictm, Model%isol, & + Model%ico2, Model%iaer, Model%ialb, Model%iems, & + Model%ntcw, Model%num_p3d, Model%npdf3d, Model%ntoz, & + Model%iovr_sw, Model%iovr_lw, Model%isubc_sw, & + Model%isubc_lw, Model%crick_proof, Model%ccnorm, & + Model%norad_precip, Model%idate,Model%iflip, Model%me) + deallocate (si) +! +! !--- initialize Morrison-Gettleman microphysics + if (Model%ncld == 2) then + call ini_micro (Model%mg_dcs, Model%mg_qcvar, Model%mg_ts_auto_ice) + call aer_cloud_init () + endif +! +! !--- initialize ras + if (Model%ras) call ras_init (Model%levs, Model%me) +! +! !--- initialize soil vegetation + call set_soilveg(Model%me, Model%isot, Model%ivegsrc, Model%nlunit) +! +! !--- lsidea initialization + if (Model%lsidea) then + print *,' LSIDEA is active but needs to be reworked for FV3 - shutting down' + stop + !--- NEED TO get the logic from the old phys/gloopb.f initialization area + endif +! +! !--- sncovr may not exist in ICs from chgres. +! !--- FV3GFS handles this as part of the IC ingest +! !--- this not is placed here to alert users to the need to study +! !--- the FV3GFS_io.F90 module + + end subroutine GFS_initialize_scm_run + + !------------------ + ! GFS_grid_populate + !------------------ + subroutine GFS_grid_populate (Grid, xlon, xlat, area) + use machine, only: kind_phys + use physcons, only: pi => con_pi + use GFS_typedefs, only: GFS_grid_type + + implicit none + + type(GFS_grid_type) :: Grid + real(kind=kind_phys), intent(in) :: xlon(:,:) + real(kind=kind_phys), intent(in) :: xlat(:,:) + real(kind=kind_phys), intent(in) :: area(:,:) + + !--- local variables + integer :: n_columns, i + + n_columns = size(Grid%xlon) + + do i=1, n_columns + Grid%xlon = xlon(i,1) + Grid%xlat = xlat(i,1) + Grid%xlat_d(i) = xlat(i,1) * 180.0_kind_phys/pi + Grid%sinlat(i) = sin(Grid%xlat(i)) + Grid%coslat(i) = sqrt(1.0_kind_phys - Grid%sinlat(i)*Grid%sinlat(i)) + Grid%area(i) = area(i,1) + Grid%dx(i) = sqrt(area(i,1)) + end do + + end subroutine GFS_grid_populate + +end module GFS_initialize_scm diff --git a/input.nml b/input.nml new file mode 100644 index 000000000..ddbee87e6 --- /dev/null +++ b/input.nml @@ -0,0 +1,216 @@ +&amip_interp_nml + interp_oi_sst = .true. + use_ncep_sst = .true. + use_ncep_ice = .false. + no_anom_sst = .false. + data_set = 'reynolds_oi', + date_out_of_range = 'climo', +/ + +&atmos_model_nml + blocksize = 32 + chksum_debug = .false. + dycore_only = .false. + ccpp_suite = "suite_GFS_IPD.xml" +/ + +&diag_manager_nml + prepend_date = .F. +/ + +&fms_io_nml + checksum_required = .false. + max_files_r = 100, + max_files_w = 100, +/ + +&fms_nml + clock_grain = 'ROUTINE', + domains_stack_size = 115200, + print_memory_usage = .false. +/ + +&fv_grid_nml + grid_file = 'INPUT/grid_spec.nc' +/ + +&fv_core_nml + layout = @[INPES],@[JNPES] + io_layout = 1,1 + npx = 97 + npy = 97 + ntiles = 6, + npz = 63 + grid_type = -1 + make_nh = @[MAKE_NH] + fv_debug = .F. + range_warn = .F. + reset_eta = .F. + n_sponge = 24 + nudge_qv = .T. + tau = 5. + rf_cutoff = 7.5e2 + d2_bg_k1 = 0.15 + d2_bg_k2 = 0.02 + kord_tm = -9 + kord_mt = 9 + kord_wz = 9 + kord_tr = 9 + hydrostatic = .F. + phys_hydrostatic = .F. + use_hydro_pressure = .F. + beta = 0. + a_imp = 1. + p_fac = 0.1 + k_split = 2 + n_split = 6 + nwat = 2 + na_init = @[NA_INIT] + d_ext = 0.0 + dnats = 0 + fv_sg_adj = 450 + d2_bg = 0. + nord = 2 + dddmp = 0.1 + d4_bg = 0.12 + vtdm4 = 0.02 + delt_max = 0.002 + ke_bg = 0. + do_vort_damp = .true. + external_ic = @[EXTERNAL_IC] + gfs_phil = .false. + nggps_ic = @[NGGPS_IC] + mountain = @[MOUNTAIN] + ncep_ic = .F. + d_con = 1. + hord_mt = 6 + hord_vt = 6 + hord_tm = 6 + hord_dp = 6 + hord_tr = 8 + adjust_dry_mass = .F. + consv_te = 1. + consv_am = .F. + fill = .T. + dwind_2d = .F. + print_freq = 6 + warm_start = @[WARM_START] + no_dycore = .false. + z_tracer = .T. +/ + +#&coupler_nml +# months = 0 +# days = 1 +# hours = 0 +# dt_atmos = 225 +# dt_ocean = 225 +# current_date = 2016,10,03,00,0,0 +# calendar = 'julian' +# memuse_verbose = .false. +# atmos_nthreads = 1 +# use_hyper_thread = .false. +# ncores_per_node = 24 +#/ + +&external_ic_nml + filtered_terrain = .true. + ncep_plevels = .true. + levp = 64 + gfs_dwinds = .true. + checker_tr = .F. + nt_checker = 0 +/ + +&gfs_physics_nml + fhzero = 6. + ldiag3d = .false. + fhcyc = 0. + nst_anl = .true. + use_ufo = .true. + pre_rad = .false. + ncld = 1 + zhao_mic = .true. + pdfcld = .false. + fhswr = 3600. + fhlwr = 3600. + ialb = 1 + iems = 1 + IAER = 111 + ico2 = 2 + isubc_sw = 2 + isubc_lw = 2 + isol = 2 + lwhtr = .true. + swhtr = .true. + cnvgwd = .true. + shal_cnv = .true. + cal_pre = .true. + redrag = .true. + dspheat = .true. + hybedmf = .true. + random_clds = .true. + trans_trac = .true. + cnvcld = .true. + imfshalcnv = 2 + imfdeepcnv = 2 + cdmbgwd = 3.5,0.25 + prslrd0 = 0. + ivegsrc = 1 + isot = 1 + debug = .true. + nstf_name = 2,0,1,0,5 + + jcap = 574 + +/ + +&nggps_diag_nml + fdiag = @[FDIAG] +/ + +&interpolator_nml + interp_method = 'conserve_great_circle' +/ + +&namsfc + FNGLAC = "global_glacier.2x2.grb", + FNMXIC = "global_maxice.2x2.grb", + FNTSFC = "RTGSST.1982.2012.monthly.clim.grb", + FNSNOC = "global_snoclim.1.875.grb", + FNZORC = "igbp", + FNALBC = "global_snowfree_albedo.bosu.t126.384.190.rg.grb", + FNALBC2 = "global_albedo4.1x1.grb", + FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb", + FNTG3C = "global_tg3clim.2.6x1.5.grb", + FNVEGC = "global_vegfrac.0.144.decpercent.grb", + FNVETC = "global_vegtype.igbp.t126.384.190.rg.grb", + FNSOTC = "global_soiltype.statsgo.t126.384.190.rg.grb", + FNSMCC = "global_soilmgldas.t126.384.190.grb", + FNMSKH = "seaice_newland.grb", + FNTSFA = "", + FNACNA = "", + FNSNOA = "", + FNVMNC = "global_shdmin.0.144x0.144.grb", + FNVMXC = "global_shdmax.0.144x0.144.grb", + FNSLPC = "global_slope.1x1.grb", + FNABSC = "global_mxsnoalb.uariz.t126.384.190.rg.grb", + LDEBUG =.false., + FSMCL(2) = 99999 + FSMCL(3) = 99999 + FSMCL(4) = 99999 + FTSFS = 90 + FAISS = 99999 + FSNOL = 99999 + FSICL = 99999 + FTSFL = 99999, + FAISL = 99999, + FVETL = 99999, + FSOTL = 99999, + FvmnL = 99999, + FvmxL = 99999, + FSLPL = 99999, + FABSL = 99999, + FSNOS = 99999, + FSICS = 99999, +/ diff --git a/physics/sfc_drv.f b/physics/sfc_drv.f index 2a5544f19..ef8e57eac 100644 --- a/physics/sfc_drv.f +++ b/physics/sfc_drv.f @@ -124,7 +124,7 @@ subroutine lsm_noah_post_run & integer, intent(in) :: im, km logical, intent(in) :: flag_lssav - real, intent (in) :: dtf + real(kind=kind_phys), intent (in) :: dtf real(kind=kind_phys), dimension(im), intent(in ) :: & & drain, runof