How To Create An SYSASM User On Release 11g

 

       On release 11g and onwards, you need to create an ASM user and grant the SYSASM role. The purpose of the SYSASM role is to provide a level of separation between the RDBMS & ASM credentials.

       The SYSASM role, which has full capability on the ASM instance, is authenticated through the OSASM user group, similar to the SYSDBA roles, which is authenticated through OSDBA.

1) The following example shows how to connect as SYSASM and configure a new user for SYSASM role:

 

+ASM:oracle> export ORACLE_SID=+ASM

+ASM:oracle>sqlplus "/as sysasm"

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Oct 1 15:44:00 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create user ASMUSER identified by oracle;

User created.

SQL> grant SYSASM, SYSOPER to ASMUSER;

Grant succeeded.

SQL> exit


2) Then connect as ASMUSER:

 

+ASM:oracle> export ORACLE_SID=+ASM

+ASM:oracle>sqlplus "ASMUSER/oracle as sysasm"

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Oct 1 15:45:26 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from v$pwfile_users;

USERNAME SYSDBA SYSOPE SYSASM
------------------------------ ------ ------ ------
SYS TRUE TRUE TRUE
ASMUSER FALSE TRUE TRUE

 

 

 

 

From Oracle

-------------------------------------------------------------------------------------------------------

QQ: 492913789
Email: ahdba@qq.com
Blog: http://www.cndba.cn/dave

DBA1 群:62697716();   DBA2 群:62697977()   DBA3 群:62697850()  

DBA 超级群:63306533();  DBA4 群: 83829929  DBA5群: 142216823   

聊天 群:40132017   聊天2群:69087192

--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请

************************************************************************ * Build and Install HDF5 Applications with CMake * ************************************************************************ Notes: This short instruction is written for users who want to quickly build HDF5 applications using the CMake tools. Users can adapt these instructions for their own applications. For more information, see the "Minimum C Project Files for CMake" section. More information about using CMake can be found at the KitWare site, www.cmake.org. CMake uses the command line; however, the visual CMake tool is available for the configuration step. The steps are similar for all of the operating systems supported by CMake. NOTES: 1. Using CMake for building and using HDF5 is under active development. While we have attempted to provide error-free files, please understand that development with CMake has not been extensively tested outside of HDF. The CMake specific files may change before the next release. 2. CMake for HDF5 development should be usable on any system where CMake is supported. Please send us any comments on how CMake support can be improved on any system. 3. See the appendix at the bottom of this file for an example of using a ctest script for building and testing. See INSTALL_CMake.txt for more information. 4. See https://cmake.org/cmake/help/latest/command/find_package.html for more information on the CMake "Config Mode Search Procedure". ======================================================================== I. Preconditions ======================================================================== 1. We suggest you obtain the latest CMake for your platform from the Kitware web site. The HDF5 1.12.x product requires a minimum CMake version of 3.12. If you are using VS2019, the minimum version is 3.15. For VS2022, the minimum version is 3.21. 2. You have installed the HDF5 library built with CMake, by executing the HDF Install Utility (the *.msi file in the binary package for Windows or the *.sh on Linux). You can obtain pre-built binaries from The HDF Group's website at www.hdfgroup.org. 3. Set the HDF5_ROOT CMake variable, -DHDF5_ROOT=<install_path> or environment variable, set(ENV{HDF5_ROOT} "<install_path>") to the installed location of HDF5. On Windows: HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/1.12.x/ On unix: HDF5_ROOT=<install root folder>/HDF_Group/HDF5/1.12.x/ If you are using shared libraries, you may need to add to the path environment variable. Set the path environment variable to the installed location of the library files for HDF5. On Windows (*.dll): PATH=%PATH%;C:/Program Files/HDF_Group/HDF5/1.12.x/bin On unix (*.so): LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<install root folder>/HDF_Group/HDF5/1.12.x/lib If you are using filter plugin libraries, you will need to set the HDF5_PLUGIN_PATH environment variable. On Windows: HDF5_PLUGIN_PATH=C:/Program Files/HDF_Group/HDF5/1.12.x/lib/plugin On unix: HDF5_PLUGIN_PATH=<install root folder>/HDF_Group/HDF5/1.12.x/lib/plugin (Note there are no quote characters used on Windows and all platforms use forward slashes) 4. Created separate source and build directories. (CMake commands are executed in the build directory) 5. Created a CMakeLists.txt file(s) for your source. See Section III below. ======================================================================== II. Building HDF5 Applications with CMake ======================================================================== Go through these steps to build HDF5 applications with CMake. (The application must support building with CMake.) 1. Run CMake 2. Configure the cache settings 3. Build HDF5 Applications 4. Test HDF5 Applications These steps are described in more detail below. 1. Run CMake The visual CMake executable is named "cmake-gui.exe" on Windows and should be available in your Start menu. For Linux, UNIX, and Mac users the executable is named "cmake-gui" and can be found where CMake was installed. Specify the source and build directories. Make the build and source directories different. For example on Windows, if the source is at c:\MyHDFstuff\hdf5, then use c:\MyHDFstuff\hdf5\build or c:\MyHDFstuff\build\hdf5 for the build directory. PREFERRED: Users can perform the configuration step without using the visual cmake-gui program. The following is an example command line configuration step executed within the build directory: cmake -G "<generator>" [-D<options>] <sourcepath> Where <generator> is * MinGW Makefiles * NMake Makefiles * Unix Makefiles * Visual Studio 14 2015 * Visual Studio 14 2015 Win64 * Visual Studio 15 2017 * Visual Studio 15 2017 Win64 * Visual Studio 16 2019 * ... in addition VS2019 will need to set the "-A" option, * ... [Win32, x64, ARM, ARM64] * Visual Studio 17 2022 * ... in addition VS2022 will need to set the "-A" option, * ... [Win32, x64, ARM, ARM64] <options> is: * BUILD_TESTING:BOOL=ON * BUILD_SHARED_LIBS:BOOL=[ON | OFF] 2. Configure the cache settings 2.1 Visual CMake users, click the Configure button. If this is the first time you are running cmake-gui in this directory, you will be prompted for the generator you wish to use (for example on Windows, Visual Studio 14 2015 Win64). CMake will read in the CMakeLists.txt files from the source directory and display options for the HDF5 project. After the first configure you can adjust the cache settings and/or specify locations of other programs. Any conflicts or new values will be highlighted by the configure process in red. Once you are happy with all the settings and there are no more values in red, click the Generate button to produce the appropriate build files. On Windows, if you are using a Visual Studio generator, the solution and project files will be created in the build folder. On linux, if you are using the Unix Makefiles generator, the Makefiles will be created in the build folder. 2.2 Alternative command line example on Windows in c:\MyHDFstuff\hdf5\build directory: cmake -G "Visual Studio 14 2015 Win64" -DBUILD_TESTING:BOOL=ON .. 3. Build HDF5 Applications On Windows, you can build HDF5 applications using either the Visual Studio Environment or the command line. The command line is normally used on linux, Unix, and Mac. To build from the command line, navigate to your build directory and execute the following: cmake --build . --config {Debug | Release} NOTE: "--config {Debug | Release}" may be optional on your platform. We recommend choosing either Debug or Release on Windows. If you are using the pre-built binaries from HDF, use Release. 3.1 If you wish to use the Visual Studio environment, open the solution file in your build directory. Be sure to select either Debug or Release and build the solution. 4. Test HDF5 Applications To test the build, navigate to your build directory and execute: ctest . -C {Debug | Release} NOTE: "-C {Debug | Release}" may be optional on your platform. We recommend choosing either Debug or Release to match the build step on Windows. 5. The files that support building with CMake are all of the files in the config/cmake folder, the CMakeLists.txt files in each source folder, and CTestConfig.cmake. CTestConfig.cmake is specific to the internal testing performed by The HDF Group. It should be altered for the user's installation and needs. The cacheinit.cmake file settings are used by The HDF Group for daily testing. It should be altered/ignored for the user's installation and needs. ======================================================================== III. Minimum C Project Files for CMake ======================================================================== Given the preconditions in section I, create a CMakeLists.txt file at the source root. Include the following text in the file: ########################################################## cmake_minimum_required (VERSION 3.12) project (HDF5MyApp C CXX) set (LIB_TYPE STATIC) # or SHARED string(TOLOWER ${LIB_TYPE} SEARCH_TYPE) find_package (HDF5 NAMES hdf5 COMPONENTS C ${SEARCH_TYPE}) # find_package (HDF5) # Find non-cmake built HDF5 set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIR}") set (LINK_LIBS ${LINK_LIBS} ${HDF5_C_${LIB_TYPE}_LIBRARY}) set (example hdf_example) add_executable (${example} ${PROJECT_SOURCE_DIR}/${example}.c) TARGET_C_PROPERTIES (${example} PRIVATE ${LIB_TYPE}) target_link_libraries (${example} ${LINK_LIBS}) enable_testing () include (CTest) add_test (NAME test_example COMMAND ${example}) ########################################################## ======================================================================== IV. APPENDIX ======================================================================== Below is an example of a ctest script that can be used to build the examples. Adjust the values as necessary. Note that the defaults can be entered on the command line and the build folder is created as a sub-folder. Windows should adjust the forward slash to double backslashes, except for the HDF_DIR environment variable. NOTE: this file is available at the HDF web site: https://portal.hdfgroup.org/display/support/Building+HDF5+with+CMake HDF5_Examples.cmake HDF5_Examples_options.cmake Also available at the HDF web site is a CMake application framework template. You can quickly add files to the framework and execute the script to compile your application with an installed HDF5 binary. ======================================================================== For further assistance, send email to help@hdfgroup.org ========================================================================
最新发布
06-27
<think>我们正在解决的是在Windows上使用CMake配置HDF5应用程序的问题。用户提供的CMakeLists.txt中,HDF5的配置不成功,无法生成HDF5.mod文件。根据引用[1]中的示例,我们可以调整HDF5的配置方式。关键点:1.使用`find_package`来查找HDF5,并确保指定了CONFIG模式(因为HDF5提供了CMake配置文件)。2.设置HDF5的安装路径(HDF5_ROOT)以帮助CMake找到它。3.在链接时,需要将HDF5的库链接到目标,同时添加必要的编译定义(如`H5_BUILT_AS_DYNAMIC_LIB`如果使用动态库)。4.对于Fortran项目,需要确保HDF5的Fortran组件也被找到。根据用户之前的CMakeLists.txt,他们尝试使用ExternalProject_Add来构建HDF5,但可能没有正确设置后续的find_package。我们调整策略:1.如果已经预先编译了HDF5,则设置HDF5_ROOT环境变量指向安装目录,然后使用find_package。2.或者,使用ExternalProject_Add来构建HDF5,然后使用导出的配置(但这一步比较复杂,因为需要等待构建完成并生成配置文件)。考虑到用户希望生成HDF5.mod(Fortran模块文件),我们必须确保HDF5的Fortran库被正确构建和安装。步骤:1.确保HDF5的构建包含Fortran支持(在配置时添加--enable-fortran)。2.在构建并安装HDF5后,使用find_package(HDF5COMPONENTSFortranREQUIRED)来查找Fortran组件。修改CMakeLists.txt中关于HDF5的部分:由于用户使用ExternalProject_Add构建HDF5,我们需要等待构建完成,然后设置HDF5的路径。但是,ExternalProject_Add在构建期间不会使HDF5的配置文件立即可用,因此我们可能需要使用一个自定义的脚本来设置变量。另一种方法是预先构建HDF5(按照引用[3]中的方法),然后设置HDF5_ROOT。这里我们提供两种方案:方案一:预先构建HDF5,然后在CMake中设置HDF5_ROOT。方案二:在CMake中使用ExternalProject_Add构建HDF5,然后通过设置变量来使用它(需要知道构建产物的位置)。考虑到用户已经尝试了方案二但没有成功,我们尝试方案一,并给出方案二的改进方法。我们先给出一个简化的指南,包括配置、构建和测试HDF5应用程序。注意:用户的项目是SWMM5+,它需要HDF5的Fortran支持。以下步骤以Windows为例(用户的环境是Windows):步骤1:下载并安装HDF5-从HDFGroup官网下载预编译的Windows版本(包含Fortran支持)[^2]。-或者,从源代码构建HDF5(使用CMake):-下载HDF5源代码(如1.12.2版本)-使用CMake配置,生成VisualStudio工程,注意勾选Fortran支持(BUILD_FORTRAN=ON)和生成共享库(BUILD_SHARED_LIBS=ON或OFF根据需求)[^3]。-编译并安装。步骤2:设置环境变量HDF5_ROOT指向HDF5的安装目录(例如:C:/hdf5/install)。步骤3:修改SWMM5+的CMakeLists.txt,使用find_package来查找HDF5(包括Fortran组件)。修改后的HDF5配置部分:```cmake#查找HDF5,要求Fortran组件find_package(HDF5COMPONENTSFortranREQUIREDCONFIG)#添加HDF5的头文件目录include_directories(${HDF5_INCLUDE_DIRS})#添加HDF5的库目录(如果必要)link_directories(${HDF5_LIBRARY_DIRS})#在目标SWMM5p上链接HDF5库target_link_libraries(SWMM5pPRIVATE${HDF5_Fortran_LIBRARIES}${HDF5_LIBRARIES})#如果使用动态库,可能需要添加定义target_compile_definitions(SWMM5pPRIVATEH5_BUILT_AS_DYNAMIC_LIB)```注意:如果HDF5是静态库,则不需要定义`H5_BUILT_AS_DYNAMIC_LIB`。步骤4:构建项目。步骤5:测试(如果配置了测试)。如果用户希望完全在CMake中构建HDF5,可以使用ExternalProject,但需要正确设置依赖和路径。以下是一个示例:```cmake#使用ExternalProject构建HDF5include(ExternalProject)ExternalProject_Add(hdf5_projectURL"https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.2/src/hdf5-1.12.2.tar.gz"CMAKE_ARGS-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>-DBUILD_SHARED_LIBS=OFF-DHDF5_BUILD_FORTRAN=ON-DHDF5_BUILD_CPP_LIB=OFF-DHDF5_BUILD_HL_LIB=ON-DHDF5_BUILD_TOOLS=OFF-DHDF5_BUILD_EXAMPLES=OFF-DHDF5_ENABLE_Z_LIB_SUPPORT=OFF-DCMAKE_BUILD_TYPE=Release-G"VisualStudio172022"-Ax64BUILD_COMMANDcmake--build.--configReleaseINSTALL_COMMANDcmake--install.--configRelease)#获取安装目录ExternalProject_Get_Property(hdf5_projectINSTALL_DIR)#设置HDF5_ROOTset(HDF5_ROOT${INSTALL_DIR})set(HDF5_DIR${INSTALL_DIR}/share/cmake/hdf5)#由于ExternalProject在构建阶段不会影响当前项目的配置阶段,我们需要将目标SWMM5p依赖于hdf5_project,并在配置后使用find_package#注意:必须在add_executable之后,并在target_link_libraries之前,使用find_packageadd_dependencies(SWMM5phdf5_project)#然后使用find_package(在hdf5_project构建并安装后,HDF5的配置文件就可用)find_package(HDF5COMPONENTSFortranREQUIREDCONFIGHINTS${HDF5_DIR})```但是,这种方法在配置阶段可能无法立即找到HDF5,因为ExternalProject_Add的构建和安装发生在构建阶段。因此,我们通常建议预先构建HDF5。针对用户的具体问题,他们无法生成HDF5.mod,这通常是因为Fortran模块文件没有被正确安装或包含路径不对。使用find_package(HDF5COMPONENTSFortran)会设置变量`HDF5_Fortran_INCLUDE_DIRS`,其中包含.mod文件所在的目录。我们需要将这个目录添加到Fortran的包含路径中。在CMakeLists.txt中,添加:```cmakeif(HDF5_Fortran_FOUND)include_directories(${HDF5_Fortran_INCLUDE_DIRS})endif()```或者使用target_include_directories:```cmaketarget_include_directories(SWMM5pPRIVATE${HDF5_Fortran_INCLUDE_DIRS})```这样,Fortran编译器就能找到HDF5.mod文件。总结修改步骤:1.确保HDF5已安装(包含Fortran支持)并设置HDF5_ROOT。2.使用find_package(HDF5COMPONENTSFortranREQUIREDCONFIG)来查找。3.将HDF5的Fortran包含目录添加到目标。4.链接HDF5的Fortran库。根据用户的CMakeLists.txt,我们修改如下:在`add_executable(SWMM5p...)`之后:```cmake#查找HDF5(Fortran组件)find_package(HDF5COMPONENTSFortranREQUIREDCONFIG)#添加HDF5Fortran的包含目录(包含HDF5.mod)target_include_directories(SWMM5pPRIVATE${HDF5_Fortran_INCLUDE_DIRS})#添加HDF5的库目录(如果需要)target_link_directories(SWMM5pPRIVATE${HDF5_LIBRARY_DIRS})#链接HDF5库target_link_libraries(SWMM5pPRIVATE${HDF5_Fortran_LIBRARIES}${HDF5_LIBRARIES})```注意:如果HDF5是动态链接,则需要复制相应的dll到可执行文件目录。如果用户希望完全在CMake中构建HDF5,那么需要采用ExternalProject_Add,并确保在构建目标SWMM5p之前完成HDF5的构建和安装,同时正确设置find_package的路径。由于用户之前已经使用了ExternalProject_Add,但未成功,我们可以调整他们的ExternalProject_Add部分,并确保使用了Fortran支持。修改用户原来的ExternalProject_Add部分:```cmakeExternalProject_Add(hdf5SOURCE_DIR"${hdf5_SOURCE_DIR}"CMAKE_ARGS-DCMAKE_INSTALL_PREFIX=${hdf5_BINARY_DIR}/install-DBUILD_SHARED_LIBS=OFF-DHDF5_BUILD_FORTRAN=ON-DHDF5_BUILD_CPP_LIB=OFF-DHDF5_BUILD_HL_LIB=ON-DHDF5_BUILD_TOOLS=OFF-DHDF5_BUILD_EXAMPLES=OFF-DHDF5_ENABLE_Z_LIB_SUPPORT=OFF-G"VisualStudio172022"-Ax64BUILD_COMMAND${CMAKE_COMMAND}--build.--configReleaseINSTALL_COMMAND${CMAKE_COMMAND}--install.--configRelease)```然后设置:```cmakeset(HDF5_DIR${hdf5_BINARY_DIR}/install/share/cmake/hdf5)set(HDF5_ROOT${hdf5_BINARY_DIR}/install)```然后在后面使用:```cmakefind_package(HDF5COMPONENTSFortranREQUIREDCONFIGHINTS${HDF5_DIR})```注意:在配置阶段,ExternalProject_Add还没有构建,所以第一次运行cmake时,find_package会失败。因此,我们需要将find_package放在可以延迟执行的位置,或者使用两次cmake(第一次配置主项目,然后构建ExternalProject,然后再次cmake配置主项目以使find_package生效)。这通常很麻烦,所以推荐预先构建HDF5。考虑到用户的问题,我们建议采用预先构建HDF5的方式。最后,我们给出一个完整的示例指南:###使用CMake构建和安装HDF5应用程序(含Fortran)的指南####1.配置-下载HDF5源代码(例如1.12.2版本)或预编译包(含Fortran支持)。-如果使用预编译包,设置环境变量`HDF5_ROOT`指向安装目录(例如:`C:/hdf5/install`)。-在CMakeLists.txt中,使用`find_package`查找HDF5的Fortran组件:```cmakefind_package(HDF5COMPONENTSFortranREQUIREDCONFIG)```####2.构建-在CMakeLists.txt中,将HDF5的包含目录和库链接到目标:```cmakeadd_executable(my_hdf5_fortranmain.f90)target_include_directories(my_hdf5_fortranPRIVATE${HDF5_Fortran_INCLUDE_DIRS})target_link_libraries(my_hdf5_fortranPRIVATE${HDF5_Fortran_LIBRARIES})```-如果使用动态库,添加编译定义:```cmaketarget_compile_definitions(my_hdf5_fortranPRIVATEH5_BUILT_AS_DYNAMIC_LIB)```####3.测试-编写测试程序(例如main.f90):```fortranprogramtest_hdf5usehdf5implicitnoneinteger::errorcallh5open_f(error)print*,"HDF5version:",H5_VERS_INFOcallh5close_f(error)endprogramtest_hdf5```-使用CTest添加测试:```cmakeenable_testing()add_test(NAMEtest_hdf5COMMANDmy_hdf5_fortran)```####4.示例-完整CMakeLists.txt示例:```cmakecmake_minimum_required(VERSION3.20)project(my_hdf5_fortran_testFortran)#设置HDF5_ROOT(也可以在命令行设置)#set(HDF5_ROOT"C:/hdf5/install")find_package(HDF5COMPONENTSFortranREQUIREDCONFIG)add_executable(my_hdf5_fortranmain.f90)target_include_directories(my_hdf5_fortranPRIVATE${HDF5_Fortran_INCLUDE_DIRS})target_link_libraries(my_hdf5_fortranPRIVATE${HDF5_Fortran_LIBRARIES})target_compile_definitions(my_hdf5_fortranPRIVATEH5_BUILT_AS_DYNAMIC_LIB)enable_testing()add_test(NAMEtest_hdf5COMMANDmy_hdf5_fortran)```按照此指南,用户应能成功生成HDF5.mod并构建Fortran程序。§§相关问题§§1.如何在Windows上编译支持Fortran的HDF5库?2.CMake中`find_package`的CONFIG模式和MODULE模式有什么区别?3.如何解决CMake找不到HDF5的问题?4.如何在CMake中使用ExternalProject_Add管理依赖项?</think>### 使用 CMake 构建和安装 HDF5 应用程序完整指南 以下是配置、构建和测试 HDF5 应用程序的完整流程,特别针对 Windows 平台优化: #### 1. 配置阶段 ```cmake cmake_minimum_required(VERSION 3.20) project(MyHDF5App Fortran C) # 设置 HDF5 安装路径 set(HDF5_ROOT "C:/hdf5/install" CACHE PATH "HDF5 安装目录") # 查找 HDF5 库(包含 Fortran 支持) find_package(HDF5 REQUIRED COMPONENTS Fortran CONFIG) # 检查是否找到 HDF5 if(HDF5_FOUND) message(STATUS "HDF5 版本: ${HDF5_VERSION}") message(STATUS "HDF5 Fortran 包含目录: ${HDF5_Fortran_INCLUDE_DIRS}") else() message(FATAL_ERROR "HDF5 库未找到!请检查 HDF5_ROOT 路径") endif() # 添加可执行文件 add_executable(my_hdf5_app src/main.f90 src/data_processing.f90 ) # 添加 HDF5 头文件目录 target_include_directories(my_hdf5_app PRIVATE ${HDF5_INCLUDE_DIRS} ${HDF5_Fortran_INCLUDE_DIRS} ) # 添加必要的编译定义 target_compile_definitions(my_hdf5_app PRIVATE H5_BUILT_AS_DYNAMIC_LIB ) # 链接 HDF5 库 target_link_libraries(my_hdf5_app PRIVATE ${HDF5_Fortran_LIBRARIES} ${HDF5_LIBRARIES} ) ``` #### 2. 构建阶段 1. **创建构建目录**: ```bash mkdir build cd build ``` 2. **生成构建系统**(Windows 示例): ```bash cmake .. -G "Visual Studio 17 2022" -A x64 -DHDF5_ROOT="C:/hdf5/install" ``` 3. **编译项目**: ```bash cmake --build . --config Release ``` #### 3. 测试阶段 ```cmake # 启用测试 enable_testing() # 添加测试用例 add_test(NAME BasicHDF5Test COMMAND my_hdf5_app test_input.h5 ) # 添加带验证的测试 add_test(NAME OutputValidation COMMAND ${Python3_EXECUTABLE} validate_results.py ) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ``` #### 4. 完整示例:HDF5 Fortran 程序 `src/main.f90` 示例代码: ```fortran program hdf5_demo use hdf5 implicit none integer :: error integer(hid_t) :: file_id ! 初始化 HDF5 库 call h5open_f(error) ! 创建新文件 call h5fcreate_f("data.h5", H5F_ACC_TRUNC_F, file_id, error) ! 在此添加数据处理代码... ! 关闭文件 call h5fclose_f(file_id, error) ! 关闭 HDF5 库 call h5close_f(error) print *, "HDF5 文件创建成功!" end program hdf5_demo ``` #### 5. 安装部署 ```cmake # 安装可执行文件 install(TARGETS my_hdf5_app RUNTIME DESTINATION bin ) # 安装依赖的 DLL(Windows 专用) install(FILES ${HDF5_Fortran_LIBRARIES} DESTINATION bin ) ``` #### 常见问题解决 1. **HDF5.mod 文件找不到**: - 确保安装的 HDF5 包含 Fortran 支持 - 检查 `HDF5_Fortran_INCLUDE_DIRS` 路径是否正确 - 添加路径到 Fortran 模块搜索路径: ```cmake set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules) include_directories(${HDF5_Fortran_INCLUDE_DIRS}) ``` 2. **链接错误**: ```cmake # 添加额外的系统库(Windows 需要) target_link_libraries(my_hdf5_app PRIVATE ws2_32.lib dbghelp.lib ) ``` 3. **配置验证**: ```cmake # 打印详细配置信息 message(STATUS "HDF5 库路径: ${HDF5_LIBRARIES}") message(STATUS "HDF5 Fortran 模块路径: ${HDF5_Fortran_INCLUDE_DIRS}") ``` #### 测试脚本示例 `validate_results.py` ```python import h5py def validate_hdf5(file_path): try: with h5py.File(file_path, 'r') as f: print("HDF5 文件结构:") print(list(f.keys())) return 0 except Exception as e: print(f"验证失败: {str(e)}") return 1 if __name__ == "__main__": import sys sys.exit(validate_hdf5(sys.argv[1])) ``` [^1]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值