From 4734c0455efe24f7cd61148dd66ecdb99fe11a2d Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Wed, 11 Apr 2018 14:33:54 +0200 Subject: [PATCH 1/3] Necessary modifications for comment lines exceeding 250 characters for PGI compiler --- physics/mfpbl.f | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/physics/mfpbl.f b/physics/mfpbl.f index feec08dda..3e66acfb3 100644 --- a/physics/mfpbl.f +++ b/physics/mfpbl.f @@ -4,7 +4,13 @@ !> \ingroup GFS_edmf_main !! \brief This subroutine is used for calculating the mass flux and updraft properties. !! -!! The mfpbl routines works as follows: if the PBL is convective, first, the ascending parcel entrainment rate is calculated as a function of height. Next, a surface parcel is initiated according to surface layer properties and the updraft buoyancy is calculated as a function of height. Next, using the buoyancy and entrainment values, the parcel vertical velocity is calculated using a well known steady-state budget equation. With the profile of updraft vertical velocity, the PBL height is recalculated as the height where the updraft vertical velocity returns to 0, and the entrainment profile is updated with the new PBL height. Finally, the mass flux profile is calculated using the updraft vertical velocity and assumed updraft fraction and the updraft properties are calculated using the updated entrainment profile, surface values, and environmental profiles. +!! The mfpbl routines works as follows: if the PBL is convective, first, the ascending parcel entrainment rate is calculated as a +!! function of height. Next, a surface parcel is initiated according to surface layer properties and the updraft buoyancy is calculated +!! as a function of height. Next, using the buoyancy and entrainment values, the parcel vertical velocity is calculated using a well +!! known steady-state budget equation. With the profile of updraft vertical velocity, the PBL height is recalculated as the height +!! where the updraft vertical velocity returns to 0, and the entrainment profile is updated with the new PBL height. Finally, the mass +!! flux profile is calculated using the updraft vertical velocity and assumed updraft fraction and the updraft properties are calculated +!! using the updated entrainment profile, surface values, and environmental profiles. !! \param[in] im integer, number of used points !! \param[in] ix integer, horizontal dimension !! \param[in] km integer, vertical layer dimension From 1ee04e3edda04073d53f84760fd42076af833c76 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Wed, 11 Apr 2018 14:34:15 +0200 Subject: [PATCH 2/3] Add support for PGI compiler to CMakeLists.txt files, run pgifix.py on physics caps object files --- CMakeLists.txt | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b1914cb8..c865732b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,6 +166,9 @@ set(SOURCES ./physics/precpd.f ./physics/GFS_calpreciptype.f90 ./physics/GFS_MP_generic_post.f90 +) + +set(CAPS ./physics/cnvc90_cap.F90 ./physics/lsm_noah_pre_cap.F90 ./physics/GFS_DCNV_generic_post_cap.F90 @@ -235,31 +238,34 @@ set(SOURCES ) if (${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU") - set(f_flags -ffree-line-length-none) set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_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_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") +elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI") + 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 -Mfree") + 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 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 (FATAL_ERROR "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") + message (FATAL_ERROR "This program has only been compiled with gfortran, pgf90 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}") + SET_PROPERTY(SOURCE ${SOURCES} ${CAPS} 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) @@ -287,10 +293,24 @@ INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/bacio) #) #list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/scm_test1_cap.f90) - -add_library(ccppphys ${SOURCES}) +add_library(ccppphys ${SOURCES} ${CAPS}) target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} w3 sp bacio) set_target_properties(ccppphys PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} COMPILE_FLAGS "${CMAKE_Fortran_FLAGS}" LINK_FLAGS "${CMAKE_Fortran_FLAGS}") +# DH* hack for PGI compiler: rename objects in scheme cap object files for ISO_C compliancy +if (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI") +set(CAPOBJS) +foreach(cap ${CAPS}) + string(REPLACE "_cap.F90" "_cap.F90.o" capobj "./${CMAKE_FILES_DIRECTORY}/ccppphys.dir/${cap}") + list(APPEND CAPOBJS ${capobj}) +endforeach(cap) + +add_custom_command(TARGET ccppphys + PRE_LINK + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/pgifix.py --cmake ${CAPOBJS} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Running pgifix_wrapper.py over all scheme caps") +endif (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI") +# *DH end hack for PGI compiler From 41648db60ee68ab2eaf875936ea0a6acf9cfc2dc Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Wed, 11 Apr 2018 14:34:38 +0200 Subject: [PATCH 3/3] Add support for PGI compiler to CMakeLists.txt files, run pgifix.py on physics caps object files --- pgifix.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/pgifix.py b/pgifix.py index 42eefccb0..cc6af76d2 100755 --- a/pgifix.py +++ b/pgifix.py @@ -6,12 +6,16 @@ import sys parser = argparse.ArgumentParser(description='Fix cap objects produced by PGI compiler') -parser.add_argument("cap") +parser.add_argument("--cmake", default=False, action='store_true') +parser.add_argument("caps", nargs='+') + +FIXCMD_TEMPLATE = 'objcopy ' def parse_args(): args = parser.parse_args() - cap = args.cap - return cap + cmake = args.cmake + caps = args.caps + return (cmake, caps) def execute(cmd, debug = True, abort = True): """Runs a local command in a shell. Waits for completion and @@ -39,9 +43,14 @@ def execute(cmd, debug = True, abort = True): print message return (status, stdout.rstrip('\n'), stderr.rstrip('\n')) -def correct_cap_object_names(fixcmd, cap): +def correct_cap_object_names(fixcmd, cmake, cap): (cappath, capname) = os.path.split(cap) - pgiprefix = capname.rstrip('.o').lower() + '_' + # Determine pgi-prepended prefix to remove, different + # for cmake builds and make builds (object filename) + if cmake: + pgiprefix = capname.rstrip('.F90.o').lower() + '_' + else: + pgiprefix = capname.rstrip('.o').lower() + '_' # Get list of all symbols in cap object nmcmd = 'nm {0}'.format(cap) (status, stdout, stderr) = execute(nmcmd) @@ -74,11 +83,11 @@ def correct_object_names(fixcmd, cap): execute(mvcmd) def main(): - cap = parse_args() - fixcmd = 'objcopy ' - fixcmd = correct_cap_object_names(fixcmd, cap) - if not fixcmd == 'objcopy ': + (cmake, caps) = parse_args() + for cap in caps: + fixcmd = FIXCMD_TEMPLATE + fixcmd = correct_cap_object_names(fixcmd, cmake, cap) correct_object_names(fixcmd, cap) if __name__ == '__main__': - main() \ No newline at end of file + main()